提交 457d08ee 编写于 作者: N Namjae Jeon 提交者: Jaegeuk Kim

f2fs: introduce accessor to retrieve number of dentry slots

Simplify code by providing the accessor macro to retrieve the
number of dentry slots for a given filename length.
Signed-off-by: NNamjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: NAmit Sahrawat <a.sahrawat@samsung.com>
上级 508198be
...@@ -99,8 +99,7 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page, ...@@ -99,8 +99,7 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page,
NR_DENTRY_IN_BLOCK, 0); NR_DENTRY_IN_BLOCK, 0);
while (bit_pos < NR_DENTRY_IN_BLOCK) { while (bit_pos < NR_DENTRY_IN_BLOCK) {
de = &dentry_blk->dentry[bit_pos]; de = &dentry_blk->dentry[bit_pos];
slots = (le16_to_cpu(de->name_len) + F2FS_NAME_LEN - 1) / slots = GET_DENTRY_SLOTS(le16_to_cpu(de->name_len));
F2FS_NAME_LEN;
if (early_match_name(name, namelen, namehash, de)) { if (early_match_name(name, namelen, namehash, de)) {
if (!memcmp(dentry_blk->filename[bit_pos], if (!memcmp(dentry_blk->filename[bit_pos],
...@@ -130,7 +129,7 @@ static struct f2fs_dir_entry *find_in_level(struct inode *dir, ...@@ -130,7 +129,7 @@ static struct f2fs_dir_entry *find_in_level(struct inode *dir,
unsigned int level, const char *name, int namelen, unsigned int level, const char *name, int namelen,
f2fs_hash_t namehash, struct page **res_page) f2fs_hash_t namehash, struct page **res_page)
{ {
int s = (namelen + F2FS_NAME_LEN - 1) / F2FS_NAME_LEN; int s = GET_DENTRY_SLOTS(namelen);
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;
...@@ -383,7 +382,7 @@ int f2fs_add_link(struct dentry *dentry, struct inode *inode) ...@@ -383,7 +382,7 @@ int f2fs_add_link(struct dentry *dentry, struct inode *inode)
int namelen = dentry->d_name.len; int namelen = dentry->d_name.len;
struct page *dentry_page = NULL; struct page *dentry_page = NULL;
struct f2fs_dentry_block *dentry_blk = NULL; struct f2fs_dentry_block *dentry_blk = NULL;
int slots = (namelen + F2FS_NAME_LEN - 1) / F2FS_NAME_LEN; int slots = GET_DENTRY_SLOTS(namelen);
int err = 0; int err = 0;
int i; int i;
...@@ -465,8 +464,7 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page, ...@@ -465,8 +464,7 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page,
struct address_space *mapping = page->mapping; struct address_space *mapping = page->mapping;
struct inode *dir = mapping->host; struct inode *dir = mapping->host;
struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb);
int slots = (le16_to_cpu(dentry->name_len) + F2FS_NAME_LEN - 1) / int slots = GET_DENTRY_SLOTS(le16_to_cpu(dentry->name_len));
F2FS_NAME_LEN;
void *kaddr = page_address(page); void *kaddr = page_address(page);
int i; int i;
...@@ -641,8 +639,7 @@ static int f2fs_readdir(struct file *file, void *dirent, filldir_t filldir) ...@@ -641,8 +639,7 @@ static int f2fs_readdir(struct file *file, void *dirent, filldir_t filldir)
file->f_pos += bit_pos - start_bit_pos; file->f_pos += bit_pos - start_bit_pos;
goto success; goto success;
} }
slots = (le16_to_cpu(de->name_len) + F2FS_NAME_LEN - 1) slots = GET_DENTRY_SLOTS(le16_to_cpu(de->name_len));
/ F2FS_NAME_LEN;
bit_pos += slots; bit_pos += slots;
} }
bit_pos = 0; bit_pos = 0;
......
...@@ -363,6 +363,9 @@ typedef __le32 f2fs_hash_t; ...@@ -363,6 +363,9 @@ typedef __le32 f2fs_hash_t;
/* One directory entry slot covers 8bytes-long file name */ /* One directory entry slot covers 8bytes-long file name */
#define F2FS_NAME_LEN 8 #define F2FS_NAME_LEN 8
#define F2FS_NAME_LEN_BITS 3
#define GET_DENTRY_SLOTS(x) ((x + F2FS_NAME_LEN - 1) >> F2FS_NAME_LEN_BITS)
/* the number of dentry in a block */ /* the number of dentry in a block */
#define NR_DENTRY_IN_BLOCK 214 #define NR_DENTRY_IN_BLOCK 214
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册