file->f_ra->ra_pages will remain the initialized value since it opend, which may
be NOT equal to bdi->ra_pages as the latter one is updated somehow(etc,
echo xxx > /sys/block/dm/queue/read_ahead_kb).So sync ra->ra_pages to the
updated value when sync read.

Signed-off-by: Zhaoyang Huang <zhaoyang.hu...@unisoc.com>
---
 mm/filemap.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mm/filemap.c b/mm/filemap.c
index d78f577..5c2d7cc 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2470,6 +2470,8 @@ static struct file *do_sync_mmap_readahead(struct 
vm_fault *vmf)
        struct file *fpin = NULL;
        pgoff_t offset = vmf->pgoff;
 
+       if (ra->ra_pages != inode_to_bdi(mapping->host)->ra_pages)
+               ra->ra_pages = inode_to_bdi(mapping->host)->ra_pages;
        /* If we don't want any read-ahead, don't bother */
        if (vmf->vma->vm_flags & VM_RAND_READ)
                return fpin;
-- 
1.9.1

Reply via email to