summaryrefslogtreecommitdiff
path: root/fs/f2fs/inline.c
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2014-10-15 21:29:51 -0700
committerJaegeuk Kim <jaegeuk@kernel.org>2014-11-03 16:07:34 -0800
commit38594de767b32db62b7213631772d050690d3803 (patch)
tree5f83dc3156cde9431b2f9c2fa813993d9bafbdc8 /fs/f2fs/inline.c
parente7a2bf2283d368ada40ae52152b7ab2304a76d95 (diff)
f2fs: reuse core function in f2fs_readdir for inline_dentry
This patch introduces a core function, f2fs_fill_dentries, to remove redundant code in f2fs_readdir and f2fs_read_inline_dir. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/inline.c')
-rw-r--r--fs/f2fs/inline.c39
1 files changed, 7 insertions, 32 deletions
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 4219bf475d72..38a6aa792534 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -517,49 +517,24 @@ bool f2fs_empty_inline_dir(struct inode *dir)
int f2fs_read_inline_dir(struct file *file, struct dir_context *ctx)
{
struct inode *inode = file_inode(file);
- struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
- unsigned int bit_pos = 0;
struct f2fs_inline_dentry *inline_dentry = NULL;
- struct f2fs_dir_entry *de = NULL;
struct page *ipage = NULL;
- unsigned char d_type = DT_UNKNOWN;
if (ctx->pos == NR_INLINE_DENTRY)
return 0;
- ipage = get_node_page(sbi, inode->i_ino);
+ ipage = get_node_page(F2FS_I_SB(inode), inode->i_ino);
if (IS_ERR(ipage))
return PTR_ERR(ipage);
- bit_pos = ((unsigned long)ctx->pos % NR_INLINE_DENTRY);
-
inline_dentry = inline_data_addr(ipage);
- while (bit_pos < NR_INLINE_DENTRY) {
- bit_pos = find_next_bit_le(&inline_dentry->dentry_bitmap,
- NR_INLINE_DENTRY,
- bit_pos);
- if (bit_pos >= NR_INLINE_DENTRY)
- break;
-
- de = &inline_dentry->dentry[bit_pos];
- if (de->file_type < F2FS_FT_MAX)
- d_type = f2fs_filetype_table[de->file_type];
- else
- d_type = DT_UNKNOWN;
-
- if (!dir_emit(ctx,
- inline_dentry->filename[bit_pos],
- le16_to_cpu(de->name_len),
- le32_to_cpu(de->ino), d_type))
- goto out;
-
- bit_pos += GET_DENTRY_SLOTS(le16_to_cpu(de->name_len));
- ctx->pos = bit_pos;
- }
- ctx->pos = NR_INLINE_DENTRY;
-out:
- f2fs_put_page(ipage, 1);
+ if (!f2fs_fill_dentries(ctx, &inline_dentry->dentry_bitmap,
+ inline_dentry->dentry,
+ inline_dentry->filename,
+ NR_INLINE_DENTRY, 0))
+ ctx->pos = NR_INLINE_DENTRY;
+ f2fs_put_page(ipage, 1);
return 0;
}