All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] 9p: avoid attaching writeback_fid on mmap with type PRIVATE
@ 2019-08-20 10:03 Chengguang Xu
  2019-08-20 11:49 ` Dominique Martinet
  0 siblings, 1 reply; 3+ messages in thread
From: Chengguang Xu @ 2019-08-20 10:03 UTC (permalink / raw)
  To: ericvh, lucho, asmadeus; +Cc: v9fs-developer, linux-kernel, Chengguang Xu

Currently on mmap cache policy, we always attach writeback_fid
whether mmap type is SHARED or PRIVATE. However, in the use case
of kata-container which combines 9p(Guest OS) with overlayfs(Host OS),
this behavior will trigger overlayfs' copy-up when excute command
inside container.

Signed-off-by: Chengguang Xu <cgxu519@zoho.com.cn>
---
 fs/9p/vfs_file.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index 4cc966a31cb3..fe7f0bd2048e 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -513,6 +513,7 @@ v9fs_mmap_file_mmap(struct file *filp, struct vm_area_struct *vma)
 	v9inode = V9FS_I(inode);
 	mutex_lock(&v9inode->v_mutex);
 	if (!v9inode->writeback_fid &&
+	    (vma->vm_flags & VM_SHARED) &&
 	    (vma->vm_flags & VM_WRITE)) {
 		/*
 		 * clone a fid and add it to writeback_fid
@@ -614,6 +615,8 @@ static void v9fs_mmap_vm_close(struct vm_area_struct *vma)
 			(vma->vm_end - vma->vm_start - 1),
 	};
 
+	if (!(vma->vm_flags & VM_SHARED))
+		return;
 
 	p9_debug(P9_DEBUG_VFS, "9p VMA close, %p, flushing", vma);
 
-- 
2.20.1




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] 9p: avoid attaching writeback_fid on mmap with type PRIVATE
  2019-08-20 10:03 [PATCH] 9p: avoid attaching writeback_fid on mmap with type PRIVATE Chengguang Xu
@ 2019-08-20 11:49 ` Dominique Martinet
  2019-08-21  1:33   ` cgxu519
  0 siblings, 1 reply; 3+ messages in thread
From: Dominique Martinet @ 2019-08-20 11:49 UTC (permalink / raw)
  To: Chengguang Xu; +Cc: ericvh, lucho, v9fs-developer, linux-kernel

Chengguang Xu wrote on Tue, Aug 20, 2019:
> Currently on mmap cache policy, we always attach writeback_fid
> whether mmap type is SHARED or PRIVATE. However, in the use case
> of kata-container which combines 9p(Guest OS) with overlayfs(Host OS),
> this behavior will trigger overlayfs' copy-up when excute command
> inside container.

hmm, I guess this just works for non-ovl cases because sync_inode()
realizes there is nothing to sync, but the fsync at the end still
triggers the copy-up ?

Well, I guess there really is no need to flush for private mappings,
so might as well go for this; sparing an extra useless clone walk cannot
hurt.

I'll queue this up after tests, no promise on delay sorry :/
-- 
Dominique

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] 9p: avoid attaching writeback_fid on mmap with type PRIVATE
  2019-08-20 11:49 ` Dominique Martinet
@ 2019-08-21  1:33   ` cgxu519
  0 siblings, 0 replies; 3+ messages in thread
From: cgxu519 @ 2019-08-21  1:33 UTC (permalink / raw)
  To: Dominique Martinet; +Cc: ericvh, lucho, v9fs-developer, linux-kernel

On Tue, 2019-08-20 at 13:49 +0200, Dominique Martinet wrote:
> Chengguang Xu wrote on Tue, Aug 20, 2019:
> > Currently on mmap cache policy, we always attach writeback_fid
> > whether mmap type is SHARED or PRIVATE. However, in the use case
> > of kata-container which combines 9p(Guest OS) with overlayfs(Host OS),
> > this behavior will trigger overlayfs' copy-up when excute command
> > inside container.
> 
> hmm, I guess this just works for non-ovl cases because sync_inode()
> realizes there is nothing to sync, but the fsync at the end still
> triggers the copy-up ?
> 
> Well, I guess there really is no need to flush for private mappings,
> so might as well go for this; sparing an extra useless clone walk cannot
> hurt.

Unfortunately, overlayfs does copy-up at open operation if the open flags
indicate data/meta modification, so as long as we attach writeback_fid with
O_RDWR on private mmap there are a lot of unnecessary copy-up of binary and
shared library files on backedn overlayfs when executing command inside kata
containers. After this patch we found there are no useless copy-up files anymore
and also private/shared mmap worked as expected.


Thanks,
Chengguang.

> 
> I'll queue this up after tests, no promise on delay sorry :/




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-08-21  1:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-20 10:03 [PATCH] 9p: avoid attaching writeback_fid on mmap with type PRIVATE Chengguang Xu
2019-08-20 11:49 ` Dominique Martinet
2019-08-21  1:33   ` cgxu519

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.