Commit eee6160f authored by Gu Zheng's avatar Gu Zheng Committed by Jaegeuk Kim

f2fs: arguments cleanup of finding file flow functions

Signed-off-by: default avatarGu Zheng <guz.fnst@cn.fujitsu.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 1c3bb978
...@@ -77,8 +77,8 @@ static unsigned long dir_block_index(unsigned int level, ...@@ -77,8 +77,8 @@ static unsigned long dir_block_index(unsigned int level,
return bidx; return bidx;
} }
static bool early_match_name(const char *name, size_t namelen, static bool early_match_name(size_t namelen, f2fs_hash_t namehash,
f2fs_hash_t namehash, struct f2fs_dir_entry *de) struct f2fs_dir_entry *de)
{ {
if (le16_to_cpu(de->name_len) != namelen) if (le16_to_cpu(de->name_len) != namelen)
return false; return false;
...@@ -90,7 +90,7 @@ static bool early_match_name(const char *name, size_t namelen, ...@@ -90,7 +90,7 @@ static bool early_match_name(const char *name, size_t namelen,
} }
static struct f2fs_dir_entry *find_in_block(struct page *dentry_page, static struct f2fs_dir_entry *find_in_block(struct page *dentry_page,
const char *name, size_t namelen, int *max_slots, struct qstr *name, int *max_slots,
f2fs_hash_t namehash, struct page **res_page) f2fs_hash_t namehash, struct page **res_page)
{ {
struct f2fs_dir_entry *de; struct f2fs_dir_entry *de;
...@@ -109,9 +109,10 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page, ...@@ -109,9 +109,10 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page,
continue; continue;
} }
de = &dentry_blk->dentry[bit_pos]; de = &dentry_blk->dentry[bit_pos];
if (early_match_name(name, namelen, namehash, de)) { if (early_match_name(name->len, namehash, de)) {
if (!memcmp(dentry_blk->filename[bit_pos], if (!memcmp(dentry_blk->filename[bit_pos],
name, namelen)) { name->name,
name->len)) {
*res_page = dentry_page; *res_page = dentry_page;
goto found; goto found;
} }
...@@ -132,10 +133,10 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page, ...@@ -132,10 +133,10 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page,
} }
static struct f2fs_dir_entry *find_in_level(struct inode *dir, static struct f2fs_dir_entry *find_in_level(struct inode *dir,
unsigned int level, const char *name, size_t namelen, unsigned int level, struct qstr *name,
f2fs_hash_t namehash, struct page **res_page) f2fs_hash_t namehash, struct page **res_page)
{ {
int s = GET_DENTRY_SLOTS(namelen); int s = GET_DENTRY_SLOTS(name->len);
unsigned int nbucket, nblock; unsigned int nbucket, nblock;
unsigned int bidx, end_block; unsigned int bidx, end_block;
struct page *dentry_page; struct page *dentry_page;
...@@ -160,8 +161,8 @@ static struct f2fs_dir_entry *find_in_level(struct inode *dir, ...@@ -160,8 +161,8 @@ static struct f2fs_dir_entry *find_in_level(struct inode *dir,
continue; continue;
} }
de = find_in_block(dentry_page, name, namelen, de = find_in_block(dentry_page, name, &max_slots,
&max_slots, namehash, res_page); namehash, res_page);
if (de) if (de)
break; break;
...@@ -187,8 +188,6 @@ static struct f2fs_dir_entry *find_in_level(struct inode *dir, ...@@ -187,8 +188,6 @@ static struct f2fs_dir_entry *find_in_level(struct inode *dir,
struct f2fs_dir_entry *f2fs_find_entry(struct inode *dir, struct f2fs_dir_entry *f2fs_find_entry(struct inode *dir,
struct qstr *child, struct page **res_page) struct qstr *child, struct page **res_page)
{ {
const char *name = child->name;
size_t namelen = child->len;
unsigned long npages = dir_blocks(dir); unsigned long npages = dir_blocks(dir);
struct f2fs_dir_entry *de = NULL; struct f2fs_dir_entry *de = NULL;
f2fs_hash_t name_hash; f2fs_hash_t name_hash;
...@@ -200,12 +199,11 @@ struct f2fs_dir_entry *f2fs_find_entry(struct inode *dir, ...@@ -200,12 +199,11 @@ struct f2fs_dir_entry *f2fs_find_entry(struct inode *dir,
*res_page = NULL; *res_page = NULL;
name_hash = f2fs_dentry_hash(name, namelen); name_hash = f2fs_dentry_hash(child);
max_depth = F2FS_I(dir)->i_current_depth; max_depth = F2FS_I(dir)->i_current_depth;
for (level = 0; level < max_depth; level++) { for (level = 0; level < max_depth; level++) {
de = find_in_level(dir, level, name, de = find_in_level(dir, level, child, name_hash, res_page);
namelen, name_hash, res_page);
if (de) if (de)
break; break;
} }
...@@ -460,7 +458,7 @@ int __f2fs_add_link(struct inode *dir, const struct qstr *name, ...@@ -460,7 +458,7 @@ int __f2fs_add_link(struct inode *dir, const struct qstr *name,
int err = 0; int err = 0;
int i; int i;
dentry_hash = f2fs_dentry_hash(name->name, name->len); dentry_hash = f2fs_dentry_hash(name);
level = 0; level = 0;
current_depth = F2FS_I(dir)->i_current_depth; current_depth = F2FS_I(dir)->i_current_depth;
if (F2FS_I(dir)->chash == dentry_hash) { if (F2FS_I(dir)->chash == dentry_hash) {
......
...@@ -1158,7 +1158,7 @@ void f2fs_msg(struct super_block *, const char *, const char *, ...); ...@@ -1158,7 +1158,7 @@ void f2fs_msg(struct super_block *, const char *, const char *, ...);
/* /*
* hash.c * hash.c
*/ */
f2fs_hash_t f2fs_dentry_hash(const char *, size_t); f2fs_hash_t f2fs_dentry_hash(const struct qstr *);
/* /*
* node.c * node.c
......
...@@ -69,12 +69,14 @@ static void str2hashbuf(const char *msg, size_t len, unsigned int *buf, int num) ...@@ -69,12 +69,14 @@ static void str2hashbuf(const char *msg, size_t len, unsigned int *buf, int num)
*buf++ = pad; *buf++ = pad;
} }
f2fs_hash_t f2fs_dentry_hash(const char *name, size_t len) f2fs_hash_t f2fs_dentry_hash(const struct qstr *name_info)
{ {
__u32 hash; __u32 hash;
f2fs_hash_t f2fs_hash; f2fs_hash_t f2fs_hash;
const char *p; const char *p;
__u32 in[8], buf[4]; __u32 in[8], buf[4];
const char *name = name_info->name;
size_t len = name_info->len;
if ((len <= 2) && (name[0] == '.') && if ((len <= 2) && (name[0] == '.') &&
(name[1] == '.' || name[1] == '\0')) (name[1] == '.' || name[1] == '\0'))
......
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