Skip to content

Commit 817202d

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: readahead multi pages of directory for performance
We have no so such readahead mechanism in ->iterate() path as the one in ->read() path, it cause low performance when we read large directory. This patch add readahead in f2fs_readdir() for better performance. Signed-off-by: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
1 parent 5c1f992 commit 817202d

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

‎fs/f2fs/dir.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,11 +637,17 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx)
637637
struct f2fs_dentry_block *dentry_blk = NULL;
638638
struct f2fs_dir_entry *de = NULL;
639639
struct page *dentry_page = NULL;
640+
struct file_ra_state *ra = &file->f_ra;
640641
unsigned int n = ((unsigned long)ctx->pos / NR_DENTRY_IN_BLOCK);
641642
unsigned char d_type = DT_UNKNOWN;
642643

643644
bit_pos = ((unsigned long)ctx->pos % NR_DENTRY_IN_BLOCK);
644645

646+
/* readahead for multi pages of dir */
647+
if (npages - n > 1 && !ra_has_index(ra, n))
648+
page_cache_sync_readahead(inode->i_mapping, ra, file, n,
649+
min(npages - n, (pgoff_t)MAX_DIR_RA_PAGES));
650+
645651
for (; n < npages; n++) {
646652
dentry_page = get_lock_data_page(inode, n);
647653
if (IS_ERR(dentry_page))

‎fs/f2fs/f2fs.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ enum {
182182

183183
#define F2FS_LINK_MAX 32000 /* maximum link count per file */
184184

185+
#define MAX_DIR_RA_PAGES 4 /* maximum ra pages of dir */
186+
185187
/* for in-memory extent cache entry */
186188
#define F2FS_MIN_EXTENT_LEN 16 /* minimum extent length */
187189

0 commit comments

Comments
 (0)