virtiofsd: Announce sub-mount points
commit9d82f6a3e68c2986633ad11687da2193e9acb0cb
authorMax Reitz <mreitz@redhat.com>
Mon, 2 Nov 2020 16:18:57 +0000 (2 17:18 +0100)
committerDr. David Alan Gilbert <dgilbert@redhat.com>
Mon, 2 Nov 2020 19:22:51 +0000 (2 19:22 +0000)
tree463f082d36d7351cef563d740a0e1a9a47f52410
parentd672fce6baa0a02dfa64d717fb072c06e301d695
virtiofsd: Announce sub-mount points

Whenever we encounter a directory with an st_dev or mount ID that
differs from that of its parent, we set the FUSE_ATTR_SUBMOUNT flag so
the guest can create a submount for it.

We only need to do so in lo_do_lookup().  The following functions return
a fuse_attr object:
- lo_create(), though fuse_reply_create(): Calls lo_do_lookup().
- lo_lookup(), though fuse_reply_entry(): Calls lo_do_lookup().
- lo_mknod_symlink(), through fuse_reply_entry(): Calls lo_do_lookup().
- lo_link(), through fuse_reply_entry(): Creating a link cannot create a
  submount, so there is no need to check for it.
- lo_getattr(), through fuse_reply_attr(): Announcing submounts when the
  node is first detected (at lookup) is sufficient.  We do not need to
  return the submount attribute later.
- lo_do_readdir(), through fuse_add_direntry_plus(): Calls
  lo_do_lookup().

Make announcing submounts optional, so submounts are only announced to
the guest with the announce_submounts option.  Some users may prefer the
current behavior, so that the guest learns nothing about the host mount
structure.

(announce_submounts is force-disabled when the guest does not present
the FUSE_SUBMOUNTS capability, or when there is no statx().)

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20201102161859.156603-6-mreitz@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
tools/virtiofsd/helper.c
tools/virtiofsd/passthrough_ll.c