All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@redhat.com>
To: Max Reitz <mreitz@redhat.com>
Cc: Gal Hammer <ghammer@redhat.com>, virtio-fs@redhat.com
Subject: Re: [Virtio-fs] Deleting files when using NFS as a shared folder
Date: Mon, 2 Aug 2021 17:15:41 -0400	[thread overview]
Message-ID: <YQhgfZNfgANlrExk@redhat.com> (raw)
In-Reply-To: <854b3e0c-9140-4f9f-93f8-1fe93d061be7@redhat.com>

On Mon, Aug 02, 2021 at 06:34:17PM +0200, Max Reitz wrote:
> On 02.08.21 13:30, Gal Hammer wrote:
> > 
> > 
> > On Mon, 2 Aug 2021 at 13:49, Max Reitz <mreitz@redhat.com
> > <mailto:mreitz@redhat.com>> wrote:
> > 
> >     On 02.08.21 12:44, Gal Hammer wrote:
> >     >
> >     >
> >     > On Mon, 2 Aug 2021 at 13:36, Dr. David Alan Gilbert
> >     > <dgilbert@redhat.com <mailto:dgilbert@redhat.com>
> >     <mailto:dgilbert@redhat.com <mailto:dgilbert@redhat.com>>> wrote:
> >     >
> >     >     * Gal Hammer (ghammer@redhat.com <mailto:ghammer@redhat.com>
> >     <mailto:ghammer@redhat.com <mailto:ghammer@redhat.com>>) wrote:
> >     >     > Hello,
> >     >     >
> >     >     > When using NFS as a shared folder (mount type nfs4) with a
> >     Linux
> >     >     guest I
> >     >     > have the following issue:
> >     >     >
> >     >     > Guest:
> >     >     > $ ls -la /mnt/shared
> >     >     > total 8
> >     >     > drwxr-xrwx.  2  135  135 4096 Aug  2 13:08 .
> >     >     > dr-xr-xr-x. 17 root   root    224 May 23 10:58 ..
> >     >     > -rw-r--rw-.  1  135  135   27 Aug  2 13:07 readme.txt
> >     >     >
> >     >     > Host:
> >     >     > $ rm readme.txt
> >     >     >
> >     >     > Guest:
> >     >     > $ ls -la /mnt/shared
> >     >     > total 8
> >     >     > drwxr-xrwx.  2  135  135 4096 Aug  2 13:10 .
> >     >     > dr-xr-xr-x. 17 root   root    224 May 23 10:58 ..
> >     >     > -rw-r--rw-.  1  135  135   27 Aug  2 13:07
> >     >     .nfs0000000001b600d000000005
> >     >     >
> >     >     > Guest:
> >     >     > $ cat /mnt/shared/readme.txt
> >     >     > This is a readme.txt file.
> >     >     >
> >     >     > So it seems that the virtiofsd has a reference to the file
> >     which
> >     >     the guest
> >     >     > is not aware of and is unable to send a FUSE_FORGET message.
> >     >     This results
> >     >     > in a file not actually deleted (renamed to .nfsXXX) and is
> >     still
> >     >     accessible
> >     >     > by the guest.
> >     >     >
> >     >     > I have a similar problem when deleting a file from a Windows
> >     >     guest side.
> >     >     > The FUSE_READDIR(PLUS) commands add a reference count to files
> >     >     which the OS
> >     >     > doesn't have a file context for. However I was able to
> >     solve it
> >     >     (for now?)
> >     >     > by keeping track of returned files' inodes.
> >     >     >
> >     >     > Is this behaviour current and by design?
> >     >
> >     >     Current problem, not really by design; the problem is the
> >     O_PATH files
> >     >     that we have open for the inodes.  I thought if the guest
> >     sent the
> >     >     forget for the file then it got closed.
> >     >
> >     >
> >     > So if I understand then sending forget message for each inode
> >     returned
> >     > by readdir won't solve the problem because you need the open
> >     files for
> >     > inodes?
> > 
> >     virtiofsd internally keeps an lo_inode object for every inode that
> >     has
> >     been looked up at some point, and every such lo_inode contains an
> >     O_PATH
> >     fd referencing that inode.  I don’t know by heart what the conditions
> >     for dropping those lo_inode objects are.
> > 
> > 
> > I think it depends on the guest's forget message.
> 
> Yes, it looks like it.
> 
> >     However, once it’s possible to use file handles to reference inodes
> >     instead of O_PATH fds (already in virtiofsd-rs, for virtiofsd there’s
> >     this series:
> >     https://listman.redhat.com/archives/virtio-fs/2021-July/msg00050.html
> >     <https://listman.redhat.com/archives/virtio-fs/2021-July/msg00050.html>),
> > 
> >     then giving the appropriate options (-o inode_file_handles -o
> >     modcaps=+dac_read_search) should result in no O_PATH fds being kept
> >     around anymore, so that deleting an inode on the host will result
> >     in the
> >     inode being truly deleted (unless the guest still has it open).
> > 
> > 
> > Will the guest will still need to send forget messages with this new
> > feature?
> 
> I don’t think so.  With file handles, FDs should only be opened (and kept
> open) when the guest actually opens some file.  (Aside from temporary O_PATH
> FDs e.g. during a lookup.)

I guess FORGET messages will still have to be sent so that virtiofsd can
free lo_inode() and associated data structrues when reference count
reaches zero. So FORGET message is more like a dropping guest's reference
count on lo_inode.

Gal, I think we had discussed this nfs issue in the past. And problem
probably is that dentry/inode is cached in guest. And that's why
lo_inode is around hence O_PATH fd is around. If you do drop caches
in guest, that might lead to removal of this temp file (sync; echo 3 >
/proc/sys/vm/drop_caches).

Max, interesting point that using file handles should help with this
situation.

Vivek


  reply	other threads:[~2021-08-02 21:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-02 10:18 [Virtio-fs] Deleting files when using NFS as a shared folder Gal Hammer
2021-08-02 10:36 ` Dr. David Alan Gilbert
2021-08-02 10:44   ` Gal Hammer
2021-08-02 10:49     ` Max Reitz
2021-08-02 11:30       ` Gal Hammer
2021-08-02 16:34         ` Max Reitz
2021-08-02 21:15           ` Vivek Goyal [this message]
2021-08-04  9:08             ` Gal Hammer
2021-08-04 13:35               ` Vivek Goyal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YQhgfZNfgANlrExk@redhat.com \
    --to=vgoyal@redhat.com \
    --cc=ghammer@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=virtio-fs@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.