qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: qemu-devel@nongnu.org, virtio-fs@redhat.com
Cc: "Dr . David Alan Gilbert" <dgilbert@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Max Reitz <mreitz@redhat.com>
Subject: [PATCH 0/9] virtiofsd: Allow using file handles instead of O_PATH FDs
Date: Fri,  4 Jun 2021 18:13:28 +0200	[thread overview]
Message-ID: <20210604161337.16048-1-mreitz@redhat.com> (raw)

Hi,

This is the C virtiofsd equivalent to
https://gitlab.com/virtio-fs/virtiofsd-rs/-/merge_requests/26.  As such,
the summary is pretty much the same:

Storing an O_PATH file descriptor in every lo_inode object means we have
a lot of FDs open, which is sometimes bad.  This series adds an option
(-o inode_file_handles) that will make virtiofsd attempt to generate a
file handle for new inodes and store that instead of an FD.  When an FD
is needed for a given inode, we open the handle.

To accomplish this, lo_inode.fd is should not be accessed directly
anymore, but only through helper functions (mainly lo_inode_fd() and
lo_inode_open()).  A TempFd object is added to hide the difference
between FDs that are bound to the lo_inode object (and so need not be
closed after use) and temporary FDs from open_by_handle_at() (which do
need to be closed after use).

To prevent the problem I spent a long time talking about (if we don’t
have an FD open for every inode, the inode can be deleted, its ID
reused, and then the lookup in lo_data.inodes will find the old deleted
inode), patch 7 adds a second hash table lo_data.inodes_by_handle that
maps file handles to lo_inode objects.  (Because file handles include a
generation ID, so we can discern between the old and the new inode.)

Patch 9 is completely optional, but I just really felt compelled to
write it.


Max Reitz (9):
  virtiofsd: Add TempFd structure
  virtiofsd: Use lo_inode_open() instead of openat()
  virtiofsd: Add lo_inode_fd() helper
  virtiofsd: Let lo_fd() return a TempFd
  virtiofsd: Let lo_inode_open() return a TempFd
  virtiofsd: Add lo_inode.fhandle
  virtiofsd: Add inodes_by_handle hash table
  virtiofsd: Optionally fill lo_inode.fhandle
  virtiofsd: Add lazy lo_do_find()

 tools/virtiofsd/helper.c              |   3 +
 tools/virtiofsd/passthrough_ll.c      | 809 +++++++++++++++++++++-----
 tools/virtiofsd/passthrough_seccomp.c |   2 +
 3 files changed, 667 insertions(+), 147 deletions(-)

-- 
2.31.1



             reply	other threads:[~2021-06-04 17:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-04 16:13 Max Reitz [this message]
2021-06-04 16:13 ` [PATCH 1/9] virtiofsd: Add TempFd structure Max Reitz
2021-06-04 16:13 ` [PATCH 2/9] virtiofsd: Use lo_inode_open() instead of openat() Max Reitz
2021-06-04 16:13 ` [PATCH 3/9] virtiofsd: Add lo_inode_fd() helper Max Reitz
2021-06-04 16:13 ` [PATCH 4/9] virtiofsd: Let lo_fd() return a TempFd Max Reitz
2021-06-04 16:13 ` [PATCH 5/9] virtiofsd: Let lo_inode_open() " Max Reitz
2021-06-04 16:13 ` [PATCH 6/9] virtiofsd: Add lo_inode.fhandle Max Reitz
2021-06-04 16:13 ` [PATCH 7/9] virtiofsd: Add inodes_by_handle hash table Max Reitz
2021-06-04 16:13 ` [PATCH 8/9] virtiofsd: Optionally fill lo_inode.fhandle Max Reitz
2021-06-08 10:43   ` Dr. David Alan Gilbert
2021-06-08 11:05     ` Max Reitz
2021-06-04 16:13 ` [PATCH 9/9] virtiofsd: Add lazy lo_do_find() Max Reitz
2021-06-04 21:17 ` [Virtio-fs] [PATCH 0/9] virtiofsd: Allow using file handles instead of O_PATH FDs Connor Kuehl

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=20210604161337.16048-1-mreitz@redhat.com \
    --to=mreitz@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).