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>
This commit is contained in:
parent
5c1f9927ec
commit
817202d937
|
@ -637,11 +637,17 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx)
|
||||||
struct f2fs_dentry_block *dentry_blk = NULL;
|
struct f2fs_dentry_block *dentry_blk = NULL;
|
||||||
struct f2fs_dir_entry *de = NULL;
|
struct f2fs_dir_entry *de = NULL;
|
||||||
struct page *dentry_page = NULL;
|
struct page *dentry_page = NULL;
|
||||||
|
struct file_ra_state *ra = &file->f_ra;
|
||||||
unsigned int n = ((unsigned long)ctx->pos / NR_DENTRY_IN_BLOCK);
|
unsigned int n = ((unsigned long)ctx->pos / NR_DENTRY_IN_BLOCK);
|
||||||
unsigned char d_type = DT_UNKNOWN;
|
unsigned char d_type = DT_UNKNOWN;
|
||||||
|
|
||||||
bit_pos = ((unsigned long)ctx->pos % NR_DENTRY_IN_BLOCK);
|
bit_pos = ((unsigned long)ctx->pos % NR_DENTRY_IN_BLOCK);
|
||||||
|
|
||||||
|
/* readahead for multi pages of dir */
|
||||||
|
if (npages - n > 1 && !ra_has_index(ra, n))
|
||||||
|
page_cache_sync_readahead(inode->i_mapping, ra, file, n,
|
||||||
|
min(npages - n, (pgoff_t)MAX_DIR_RA_PAGES));
|
||||||
|
|
||||||
for (; n < npages; n++) {
|
for (; n < npages; n++) {
|
||||||
dentry_page = get_lock_data_page(inode, n);
|
dentry_page = get_lock_data_page(inode, n);
|
||||||
if (IS_ERR(dentry_page))
|
if (IS_ERR(dentry_page))
|
||||||
|
|
|
@ -182,6 +182,8 @@ enum {
|
||||||
|
|
||||||
#define F2FS_LINK_MAX 32000 /* maximum link count per file */
|
#define F2FS_LINK_MAX 32000 /* maximum link count per file */
|
||||||
|
|
||||||
|
#define MAX_DIR_RA_PAGES 4 /* maximum ra pages of dir */
|
||||||
|
|
||||||
/* for in-memory extent cache entry */
|
/* for in-memory extent cache entry */
|
||||||
#define F2FS_MIN_EXTENT_LEN 16 /* minimum extent length */
|
#define F2FS_MIN_EXTENT_LEN 16 /* minimum extent length */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue