aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorTao Ma <boyu.mt@taobao.com>2012-12-10 14:05:59 -0500
committerTheodore Ts'o <tytso@mit.edu>2012-12-10 14:05:59 -0500
commit7335cd3b41b1e704608ca46159641ca9cb598121 (patch)
tree33d9d6de3fa27be5701d09e3f75cd568c3021038 /fs
parent65d165d9366dbf783d0102177006d47c8859ba31 (diff)
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: Tao Ma <boyu.mt@taobao.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs')
-rw-r--r--fs/ext4/ext4.h7
-rw-r--r--fs/ext4/namei.c26
2 files changed, 26 insertions, 7 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index e3a74658c63c..a971b65bf5ca 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -2122,6 +2122,13 @@ extern int ext4_orphan_add(handle_t *, struct inode *);
2122extern int ext4_orphan_del(handle_t *, struct inode *); 2122extern int ext4_orphan_del(handle_t *, struct inode *);
2123extern int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash, 2123extern int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,
2124 __u32 start_minor_hash, __u32 *next_hash); 2124 __u32 start_minor_hash, __u32 *next_hash);
2125extern int search_dir(struct buffer_head *bh,
2126 char *search_buf,
2127 int buf_size,
2128 struct inode *dir,
2129 const struct qstr *d_name,
2130 unsigned int offset,
2131 struct ext4_dir_entry_2 **res_dir);
2125 2132
2126/* resize.c */ 2133/* resize.c */
2127extern int ext4_group_add(struct super_block *sb, 2134extern int ext4_group_add(struct super_block *sb,
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 3cde36bd8020..d50684b91496 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -1005,6 +1005,16 @@ errout:
1005 return (err); 1005 return (err);
1006} 1006}
1007 1007
1008static inline int search_dirblock(struct buffer_head *bh,
1009 struct inode *dir,
1010 const struct qstr *d_name,
1011 unsigned int offset,
1012 struct ext4_dir_entry_2 **res_dir)
1013{
1014 return search_dir(bh, bh->b_data, dir->i_sb->s_blocksize, dir,
1015 d_name, offset, res_dir);
1016}
1017
1008 1018
1009/* 1019/*
1010 * Directory block splitting, compacting 1020 * Directory block splitting, compacting
@@ -1098,11 +1108,13 @@ static inline int ext4_match (int len, const char * const name,
1098/* 1108/*
1099 * Returns 0 if not found, -1 on failure, and 1 on success 1109 * Returns 0 if not found, -1 on failure, and 1 on success
1100 */ 1110 */
1101static inline int search_dirblock(struct buffer_head *bh, 1111int search_dir(struct buffer_head *bh,
1102 struct inode *dir, 1112 char *search_buf,
1103 const struct qstr *d_name, 1113 int buf_size,
1104 unsigned int offset, 1114 struct inode *dir,
1105 struct ext4_dir_entry_2 ** res_dir) 1115 const struct qstr *d_name,
1116 unsigned int offset,
1117 struct ext4_dir_entry_2 **res_dir)
1106{ 1118{
1107 struct ext4_dir_entry_2 * de; 1119 struct ext4_dir_entry_2 * de;
1108 char * dlimit; 1120 char * dlimit;
@@ -1110,8 +1122,8 @@ static inline int search_dirblock(struct buffer_head *bh,
1110 const char *name = d_name->name; 1122 const char *name = d_name->name;
1111 int namelen = d_name->len; 1123 int namelen = d_name->len;
1112 1124
1113 de = (struct ext4_dir_entry_2 *) bh->b_data; 1125 de = (struct ext4_dir_entry_2 *)search_buf;
1114 dlimit = bh->b_data + dir->i_sb->s_blocksize; 1126 dlimit = search_buf + buf_size;
1115 while ((char *) de < dlimit) { 1127 while ((char *) de < dlimit) {
1116 /* this code is executed quadratically often */ 1128 /* this code is executed quadratically often */
1117 /* do minimal checking `by hand' */ 1129 /* do minimal checking `by hand' */