aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChao Yu <chao2.yu@samsung.com>2014-04-28 05:59:43 -0400
committerJaegeuk Kim <jaegeuk.kim@samsung.com>2014-05-06 21:21:57 -0400
commit817202d937e6cca7e60f42e6495aaa51d70d9d7e (patch)
tree24ea4565ddf464250fa39a0e4735d01b14ebf6d6
parent5c1f9927ec1a4753e845193bde99ac3b03b08818 (diff)
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>
-rw-r--r--fs/f2fs/dir.c6
-rw-r--r--fs/f2fs/f2fs.h2
2 files changed, 8 insertions, 0 deletions
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index 972fd0ef230f..3581c2bde21b 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -637,11 +637,17 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx)
637 struct f2fs_dentry_block *dentry_blk = NULL; 637 struct f2fs_dentry_block *dentry_blk = NULL;
638 struct f2fs_dir_entry *de = NULL; 638 struct f2fs_dir_entry *de = NULL;
639 struct page *dentry_page = NULL; 639 struct page *dentry_page = NULL;
640 struct file_ra_state *ra = &file->f_ra;
640 unsigned int n = ((unsigned long)ctx->pos / NR_DENTRY_IN_BLOCK); 641 unsigned int n = ((unsigned long)ctx->pos / NR_DENTRY_IN_BLOCK);
641 unsigned char d_type = DT_UNKNOWN; 642 unsigned char d_type = DT_UNKNOWN;
642 643
643 bit_pos = ((unsigned long)ctx->pos % NR_DENTRY_IN_BLOCK); 644 bit_pos = ((unsigned long)ctx->pos % NR_DENTRY_IN_BLOCK);
644 645
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
645 for (; n < npages; n++) { 651 for (; n < npages; n++) {
646 dentry_page = get_lock_data_page(inode, n); 652 dentry_page = get_lock_data_page(inode, n);
647 if (IS_ERR(dentry_page)) 653 if (IS_ERR(dentry_page))
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index e77be7cb1e60..2b67679f88b6 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -182,6 +182,8 @@ enum {
182 182
183#define F2FS_LINK_MAX 32000 /* maximum link count per file */ 183#define F2FS_LINK_MAX 32000 /* maximum link count per file */
184 184
185#define MAX_DIR_RA_PAGES 4 /* maximum ra pages of dir */
186
185/* for in-memory extent cache entry */ 187/* for in-memory extent cache entry */
186#define F2FS_MIN_EXTENT_LEN 16 /* minimum extent length */ 188#define F2FS_MIN_EXTENT_LEN 16 /* minimum extent length */
187 189