aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2010-10-27 21:30:08 -0400
committerTheodore Ts'o <tytso@mit.edu>2010-10-27 21:30:08 -0400
commit7845c0497536c566bfef08db1a38ae1ad2c25464 (patch)
tree1d5fc97acad87341c6a703dc0763fa95135923ef /fs/ext4
parent8941ec8bb6443d28d5c25311870aeaa809cf1538 (diff)
ext4: use search_dirblock() in ext4_dx_find_entry()
Use the search_dirblock() in ext4_dx_find_entry(). It makes the code easier to read, and it takes advantage of common code. It also saves 100 bytes or so of text space. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Cc: Brad Spengler <spender@grsecurity.net>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/namei.c33
1 files changed, 12 insertions, 21 deletions
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 213523803dff..86a7870babbd 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -974,39 +974,30 @@ static struct buffer_head * ext4_dx_find_entry(struct inode *dir, const struct q
974 struct super_block * sb = dir->i_sb; 974 struct super_block * sb = dir->i_sb;
975 struct dx_hash_info hinfo; 975 struct dx_hash_info hinfo;
976 struct dx_frame frames[2], *frame; 976 struct dx_frame frames[2], *frame;
977 struct ext4_dir_entry_2 *de, *top;
978 struct buffer_head *bh; 977 struct buffer_head *bh;
979 ext4_lblk_t block; 978 ext4_lblk_t block;
980 int retval; 979 int retval;
981 int namelen = d_name->len;
982 const u8 *name = d_name->name;
983 980
984 if (!(frame = dx_probe(d_name, dir, &hinfo, frames, err))) 981 if (!(frame = dx_probe(d_name, dir, &hinfo, frames, err)))
985 return NULL; 982 return NULL;
986 do { 983 do {
987 block = dx_get_block(frame->at); 984 block = dx_get_block(frame->at);
988 if (!(bh = ext4_bread (NULL,dir, block, 0, err))) 985 if (!(bh = ext4_bread(NULL, dir, block, 0, err)))
989 goto errout; 986 goto errout;
990 de = (struct ext4_dir_entry_2 *) bh->b_data;
991 top = (struct ext4_dir_entry_2 *) ((char *) de + sb->s_blocksize -
992 EXT4_DIR_REC_LEN(0));
993 for (; de < top; de = ext4_next_entry(de, sb->s_blocksize)) {
994 int off = (block << EXT4_BLOCK_SIZE_BITS(sb))
995 + ((char *) de - bh->b_data);
996
997 if (!ext4_check_dir_entry(dir, de, bh, off)) {
998 brelse(bh);
999 *err = ERR_BAD_DX_DIR;
1000 goto errout;
1001 }
1002 987
1003 if (ext4_match(namelen, name, de)) { 988 retval = search_dirblock(bh, dir, d_name,
1004 *res_dir = de; 989 block << EXT4_BLOCK_SIZE_BITS(sb),
1005 dx_release(frames); 990 res_dir);
1006 return bh; 991 if (retval == 1) { /* Success! */
1007 } 992 dx_release(frames);
993 return bh;
1008 } 994 }
1009 brelse(bh); 995 brelse(bh);
996 if (retval == -1) {
997 *err = ERR_BAD_DX_DIR;
998 goto errout;
999 }
1000
1010 /* Check to see if we should continue to search */ 1001 /* Check to see if we should continue to search */
1011 retval = ext4_htree_next_block(dir, hinfo.hash, frame, 1002 retval = ext4_htree_next_block(dir, hinfo.hash, frame,
1012 frames, NULL); 1003 frames, NULL);