Commit 7335cd3b authored by Tao Ma's avatar Tao Ma Committed by Theodore Ts'o

ext4: create a new function search_dir

search_dirblock is used to search a dir block, but the code is almost
the same for searching an inline dir.

So create a new fuction search_dir and let search_dirblock call it.
Signed-off-by: default avatarTao Ma <boyu.mt@taobao.com>
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
parent 65d165d9
...@@ -2122,6 +2122,13 @@ extern int ext4_orphan_add(handle_t *, struct inode *); ...@@ -2122,6 +2122,13 @@ extern int ext4_orphan_add(handle_t *, struct inode *);
extern int ext4_orphan_del(handle_t *, struct inode *); extern int ext4_orphan_del(handle_t *, struct inode *);
extern int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash, extern int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,
__u32 start_minor_hash, __u32 *next_hash); __u32 start_minor_hash, __u32 *next_hash);
extern int search_dir(struct buffer_head *bh,
char *search_buf,
int buf_size,
struct inode *dir,
const struct qstr *d_name,
unsigned int offset,
struct ext4_dir_entry_2 **res_dir);
/* resize.c */ /* resize.c */
extern int ext4_group_add(struct super_block *sb, extern int ext4_group_add(struct super_block *sb,
......
...@@ -1005,6 +1005,16 @@ int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash, ...@@ -1005,6 +1005,16 @@ int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,
return (err); return (err);
} }
static inline int search_dirblock(struct buffer_head *bh,
struct inode *dir,
const struct qstr *d_name,
unsigned int offset,
struct ext4_dir_entry_2 **res_dir)
{
return search_dir(bh, bh->b_data, dir->i_sb->s_blocksize, dir,
d_name, offset, res_dir);
}
/* /*
* Directory block splitting, compacting * Directory block splitting, compacting
...@@ -1098,11 +1108,13 @@ static inline int ext4_match (int len, const char * const name, ...@@ -1098,11 +1108,13 @@ static inline int ext4_match (int len, const char * const name,
/* /*
* Returns 0 if not found, -1 on failure, and 1 on success * Returns 0 if not found, -1 on failure, and 1 on success
*/ */
static inline int search_dirblock(struct buffer_head *bh, int search_dir(struct buffer_head *bh,
struct inode *dir, char *search_buf,
const struct qstr *d_name, int buf_size,
unsigned int offset, struct inode *dir,
struct ext4_dir_entry_2 ** res_dir) const struct qstr *d_name,
unsigned int offset,
struct ext4_dir_entry_2 **res_dir)
{ {
struct ext4_dir_entry_2 * de; struct ext4_dir_entry_2 * de;
char * dlimit; char * dlimit;
...@@ -1110,8 +1122,8 @@ static inline int search_dirblock(struct buffer_head *bh, ...@@ -1110,8 +1122,8 @@ static inline int search_dirblock(struct buffer_head *bh,
const char *name = d_name->name; const char *name = d_name->name;
int namelen = d_name->len; int namelen = d_name->len;
de = (struct ext4_dir_entry_2 *) bh->b_data; de = (struct ext4_dir_entry_2 *)search_buf;
dlimit = bh->b_data + dir->i_sb->s_blocksize; dlimit = search_buf + buf_size;
while ((char *) de < dlimit) { while ((char *) de < dlimit) {
/* this code is executed quadratically often */ /* this code is executed quadratically often */
/* do minimal checking `by hand' */ /* do minimal checking `by hand' */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment