[RHEL7,COMMIT] pfcache: do not drop pfcache checksum during mmap(SHARED) of ro-files

Submitted by Konstantin Khorenko on Feb. 28, 2020, 9:51 a.m.


Message ID 202002280951.01S9pHTh029570@finist-ce7.sw.ru
State New
Series "pfcache: do not drop pfcache checksum during mmap(SHARED) of ro-files"
Headers show

Commit Message

Konstantin Khorenko Feb. 28, 2020, 9:51 a.m.
The commit is pushed to "branch-rh7-3.10.0-1062.12.1.vz7.131.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1062.12.1.vz7.131.5
commit 59b9ebc6a940e1f346bb4c15655c6f1229264494
Author: Vasily Averin <vvs@virtuozzo.com>
Date:   Fri Feb 28 12:35:38 2020 +0300

    pfcache: do not drop pfcache checksum during mmap(SHARED) of ro-files
    Currently any mmap(SHARED) removes pfcache mark, even for
    read_only-opened files. It is required to guarantee that
    shared mappings will see changes if mapped file will be
    write-opened and modified.
    On the other hand we do not want to drop pfcache mark without the
    necessity. At the moment ldconfig calls mmap(SHARED) before adding
    any new files into library cache. It removes pfcache mark and
    does not allow to add libraries into pfcache.
    This patch helps to avoid the problem: during mmap(SHARED) for read-only
    files kernel does not drop pfcache mark from inode but closes file in
    pfcache area and use its local copy.
    Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
    Acked-by: Konstantin Khorenko <khorenko@virtuozzo.com>
 mm/util.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/mm/util.c b/mm/util.c
index 69dd74900ae6d..6b1cf7620e846 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -331,7 +331,8 @@  unsigned long vm_mmap_pgoff(struct file *file, unsigned long addr,
 		/* Ugly fix for PSBM-23133 vdavydov@ */
 		if (file && file->f_op && (flag & MAP_TYPE) == MAP_SHARED &&
 		    S_ISREG(file_inode(file)->i_mode) &&
-		    (file_inode(file)->i_sb->s_type->fs_flags & FS_HAS_MMAP_PREP))
+		    (file_inode(file)->i_sb->s_type->fs_flags & FS_HAS_MMAP_PREP) &&
+		    (file->f_mode & FMODE_WRITE))
 			file->f_op->mmap(file, NULL);
 		ret = do_mmap_pgoff(file, addr, len, prot, flag, pgoff,