[Virtio-fs] [PATCH] virtiofsd: During setup mapping, open file O_RDWR only if needed
Vivek Goyal
vgoyal at redhat.com
Thu Jul 25 15:21:19 UTC 2019
On Thu, Jul 25, 2019 at 02:27:43PM +0100, Dr. David Alan Gilbert wrote:
> * Liu Bo (bo.liu at linux.alibaba.com) wrote:
> > On Wed, Jul 24, 2019 at 05:10:24PM -0400, Vivek Goyal wrote:
> > > As of now we always open file O_RDWR (even if writable mappings are not
> > > required). This leads to copy up of file if file is backed by overlayfs
> > > and hence nullying advantages of overlayfs.
> > >
> > > So open file O_RDONLY if writable mappings are not required. Open O_RDWR
> > > if writable mappings are needed.
> > >
> > > Signed-off-by: Vivek Goyal <vgoyal at redhat.com>
> > > ---
> > > contrib/virtiofsd/passthrough_ll.c | 9 ++++++---
> > > 1 file changed, 6 insertions(+), 3 deletions(-)
> > >
> > > Index: qemu/contrib/virtiofsd/passthrough_ll.c
> > > ===================================================================
> > > --- qemu.orig/contrib/virtiofsd/passthrough_ll.c 2019-07-24 16:31:07.014871768 -0400
> > > +++ qemu/contrib/virtiofsd/passthrough_ll.c 2019-07-24 16:32:10.064412722 -0400
> > > @@ -2197,15 +2197,15 @@ static void lo_setupmapping(fuse_req_t r
> > > VhostUserFSSlaveMsg msg = { 0 };
> > > uint64_t vhu_flags;
> > > char *buf;
> > > + bool writable = flags & FUSE_SETUPMAPPING_FLAG_WRITE;
> >
> > typo? flags is set to O_WRONLY or 0 in do_lookup, although this may work as same.
>
> Right; that should be O_WRONLY;
> do_setupmapping does:
>
> genflags = 0;
> genflags |= (arg->flags & FUSE_SETUPMAPPING_FLAG_WRITE) ? O_WRONLY : 0;
>
> to convert from the fuse definition on the wire to the O_ notation
> before calling the filesstem code.
So I have two questions.
- O_WRONLY does not sound like correct mapping. FUSE_SETUPMAPPING_FLAG_WRITE
only says that write behavior is required. It does not say *write only*.
- Is it must that we need to translate fuse message specific flag
to O_* notation. How about let filesystem code parse it?
Thanks
Vivek
More information about the Virtio-fs
mailing list