[Virtio-fs] [fuse-devel] 'FORGET' ordering semantics (vs unlink & NFS)

Miklos Szeredi miklos at szeredi.hu
Wed Jan 6 13:40:45 UTC 2021


On Wed, Jan 6, 2021 at 10:16 AM Amir Goldstein <amir73il at gmail.com> wrote:

> Please note that NFS doesn't do "silly rename" for directories,
> so mitigation is mostly needed for non-dir.

Okay.

> An alternative method if daemon is not capable, is to store parent dirfd
> in addition to filehandle and implement open_child_by_handle_at(int
> parent_fd, ...):
> - readdir(parend_fd)
> - search a match for d_ino
> - name_to_handle_at() and verify match to stored filehandle
>
> This is essentially what open_by_handle_at(2) does under the covers
> with a "connectable" non-dir filehandle after having resolved the
> parent file handle part. And "connectable" file handles are used by nfsd
> to enforce "subtree_check" to make sure that file wasn't moved outside
> obtainable path after initial lookup.

Yes, sort of makes sense, but will have corner cases for hard links in
different directories, open files after unlink, etc..

Also back to the original problem: what we really want is to close the
O_PATH descriptor on unlink().  This should be possible, regardless of
any FORGET, assuming

1) no open files exist that reference the inode
2) no aliases have been looked up (i.e. just one cached dentry)

The attached untested patch tries to do this.

Thanks,
Miklos
-------------- next part --------------
A non-text attachment was scrubbed...
Name: virtiofsd-close-on-unlink.patch
Type: text/x-patch
Size: 3920 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virtio-fs/attachments/20210106/88668d25/attachment.bin>


More information about the Virtio-fs mailing list