f2fs: readahead multi pages of directory for performance
[deliverable/linux.git] / fs / f2fs / dir.c
index 972fd0ef230f9aff12f877a4f056980ad07757f3..3581c2bde21b1f53ab2483b4df57c35ae6e88e19 100644 (file)
@@ -637,11 +637,17 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx)
        struct f2fs_dentry_block *dentry_blk = NULL;
        struct f2fs_dir_entry *de = 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 char d_type = DT_UNKNOWN;
 
        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++) {
                dentry_page = get_lock_data_page(inode, n);
                if (IS_ERR(dentry_page))
This page took 0.044782 seconds and 5 git commands to generate.