aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs/dir.c
diff options
context:
space:
mode:
authorNamjae Jeon <namjae.jeon@samsung.com>2012-12-08 00:54:50 -0500
committerJaegeuk Kim <jaegeuk.kim@samsung.com>2012-12-10 23:43:45 -0500
commit457d08ee4fd91c8df17917ff2d32565e6adacbfc (patch)
treed97e620d4617642414cdec0ecc9bae9081e156b6 /fs/f2fs/dir.c
parent508198be3c2f7f8929101bb0daeb8f0039c1dc7f (diff)
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: Namjae Jeon <namjae.jeon@samsung.com> Signed-off-by: Amit Sahrawat <a.sahrawat@samsung.com>
Diffstat (limited to 'fs/f2fs/dir.c')
-rw-r--r--fs/f2fs/dir.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index fc02d8b43aea..d900c088c7c6 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -99,8 +99,7 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page,
99 NR_DENTRY_IN_BLOCK, 0); 99 NR_DENTRY_IN_BLOCK, 0);
100 while (bit_pos < NR_DENTRY_IN_BLOCK) { 100 while (bit_pos < NR_DENTRY_IN_BLOCK) {
101 de = &dentry_blk->dentry[bit_pos]; 101 de = &dentry_blk->dentry[bit_pos];
102 slots = (le16_to_cpu(de->name_len) + F2FS_NAME_LEN - 1) / 102 slots = GET_DENTRY_SLOTS(le16_to_cpu(de->name_len));
103 F2FS_NAME_LEN;
104 103
105 if (early_match_name(name, namelen, namehash, de)) { 104 if (early_match_name(name, namelen, namehash, de)) {
106 if (!memcmp(dentry_blk->filename[bit_pos], 105 if (!memcmp(dentry_blk->filename[bit_pos],
@@ -130,7 +129,7 @@ static struct f2fs_dir_entry *find_in_level(struct inode *dir,
130 unsigned int level, const char *name, int namelen, 129 unsigned int level, const char *name, int namelen,
131 f2fs_hash_t namehash, struct page **res_page) 130 f2fs_hash_t namehash, struct page **res_page)
132{ 131{
133 int s = (namelen + F2FS_NAME_LEN - 1) / F2FS_NAME_LEN; 132 int s = GET_DENTRY_SLOTS(namelen);
134 unsigned int nbucket, nblock; 133 unsigned int nbucket, nblock;
135 unsigned int bidx, end_block; 134 unsigned int bidx, end_block;
136 struct page *dentry_page; 135 struct page *dentry_page;
@@ -383,7 +382,7 @@ int f2fs_add_link(struct dentry *dentry, struct inode *inode)
383 int namelen = dentry->d_name.len; 382 int namelen = dentry->d_name.len;
384 struct page *dentry_page = NULL; 383 struct page *dentry_page = NULL;
385 struct f2fs_dentry_block *dentry_blk = NULL; 384 struct f2fs_dentry_block *dentry_blk = NULL;
386 int slots = (namelen + F2FS_NAME_LEN - 1) / F2FS_NAME_LEN; 385 int slots = GET_DENTRY_SLOTS(namelen);
387 int err = 0; 386 int err = 0;
388 int i; 387 int i;
389 388
@@ -465,8 +464,7 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page,
465 struct address_space *mapping = page->mapping; 464 struct address_space *mapping = page->mapping;
466 struct inode *dir = mapping->host; 465 struct inode *dir = mapping->host;
467 struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); 466 struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb);
468 int slots = (le16_to_cpu(dentry->name_len) + F2FS_NAME_LEN - 1) / 467 int slots = GET_DENTRY_SLOTS(le16_to_cpu(dentry->name_len));
469 F2FS_NAME_LEN;
470 void *kaddr = page_address(page); 468 void *kaddr = page_address(page);
471 int i; 469 int i;
472 470
@@ -641,8 +639,7 @@ static int f2fs_readdir(struct file *file, void *dirent, filldir_t filldir)
641 file->f_pos += bit_pos - start_bit_pos; 639 file->f_pos += bit_pos - start_bit_pos;
642 goto success; 640 goto success;
643 } 641 }
644 slots = (le16_to_cpu(de->name_len) + F2FS_NAME_LEN - 1) 642 slots = GET_DENTRY_SLOTS(le16_to_cpu(de->name_len));
645 / F2FS_NAME_LEN;
646 bit_pos += slots; 643 bit_pos += slots;
647 } 644 }
648 bit_pos = 0; 645 bit_pos = 0;