[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openvz-devel
Subject:    [Devel] [PATCH rh7 v2] pfcache: do not drop pfcache checksum during mmap(SHARED) of ro-files
From:       Konstantin Khorenko <khorenko () virtuozzo ! com>
Date:       2020-02-28 9:48:24
Message-ID: 20200228094824.29474-1-khorenko () virtuozzo ! com
[Download RAW message or body]

From: Vasily Averin <vvs@virtuozzo.com>

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.

https://jira.sw.ru/browse/PSBM-64045

Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
Acked-by: Konstantin Khorenko <khorenko@virtuozzo.com>

v2:
* if we do mmap(SHARED) in ro mode, we still can use pfcache file
  mapping safely because any open in rw mode will close peer (pfcache)
  file anyway, so don't close pfcache on ro mmap(SHARED) move the check

* for open mode a step above, so don't need to call prep
  ext4_file_mmap(vma==NULL) if open in ro mode.
---
 mm/util.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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);
 		down_write(&mm->mmap_sem);
 		ret = do_mmap_pgoff(file, addr, len, prot, flag, pgoff,
-- 
2.15.1

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic