]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
f2fs: relocate readahead codes in readdir()
authorChao Yu <yuchao0@huawei.com>
Fri, 13 Oct 2017 10:01:35 +0000 (18:01 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Thu, 26 Oct 2017 08:44:19 +0000 (10:44 +0200)
Previously, for large directory, we just do readahead only once in
readdir(), readdir()'s performance may drop when traversing latter
blocks. In order to avoid this, relocate readahead codes to covering
all traverse flow.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/dir.c

index 1ebd206a40858b214fcbbd64e7472a246bd463c6..14646440b662e4ce8d162051bbce64718d370d67 100644 (file)
@@ -870,11 +870,6 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx)
                goto out_free;
        }
 
-       /* 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++) {
 
                /* allow readdir() to be interrupted */
@@ -884,6 +879,11 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx)
                }
                cond_resched();
 
+               /* 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));
+
                dentry_page = get_lock_data_page(inode, n, false);
                if (IS_ERR(dentry_page)) {
                        err = PTR_ERR(dentry_page);