From: Stefan Hajnoczi <stefanha@redhat.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: linux-fsdevel@vger.kernel.org, Alyssa Ross <hi@alyssa.is>,
gmaglione@redhat.com, virtio-fs@lists.linux.dev,
vgoyal@redhat.com, mzxreary@0pointer.de, miklos@szeredi.hu
Subject: Re: [PATCH v2 2/3] virtiofs: export filesystem tags through sysfs
Date: Fri, 9 Feb 2024 06:33:28 -0500 [thread overview]
Message-ID: <20240209113328.GB748645@fedora> (raw)
In-Reply-To: <2024020940-stinking-encrust-3754@gregkh>
[-- Attachment #1: Type: text/plain, Size: 3514 bytes --]
On Fri, Feb 09, 2024 at 10:36:47AM +0000, Greg KH wrote:
> On Thu, Feb 08, 2024 at 02:32:10PM -0500, Stefan Hajnoczi wrote:
> > The virtiofs filesystem is mounted using a "tag" which is exported by
> > the virtiofs device:
> >
> > # mount -t virtiofs <tag> /mnt
> >
> > The virtiofs driver knows about all the available tags but these are
> > currently not exported to user space.
> >
> > People have asked for these tags to be exported to user space. Most
> > recently Lennart Poettering has asked for it as he wants to scan the
> > tags and mount virtiofs automatically in certain cases.
> >
> > https://gitlab.com/virtio-fs/virtiofsd/-/issues/128
> >
> > This patch exports tags at /sys/fs/virtiofs/<N>/tag where N is the id of
> > the virtiofs device. The filesystem tag can be obtained by reading this
> > "tag" file.
> >
> > There is also a symlink at /sys/fs/virtiofs/<N>/device that points to
> > the virtiofs device that exports this tag.
> >
> > This patch converts the existing struct virtio_fs into a full kobject.
> > It already had a refcount so it's an easy change. The virtio_fs objects
> > can then be exposed in a kset at /sys/fs/virtiofs/. Note that virtio_fs
> > objects may live slightly longer than we wish for them to be exposed to
> > userspace, so kobject_del() is called explicitly when the underlying
> > virtio_device is removed. The virtio_fs object is freed when all
> > references are dropped (e.g. active mounts) but disappears as soon as
> > the virtiofs device is gone.
> >
> > Originally-by: Vivek Goyal <vgoyal@redhat.com>
> > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> > ---
> > fs/fuse/virtio_fs.c | 113 ++++++++++++++++----
> > Documentation/ABI/testing/sysfs-fs-virtiofs | 11 ++
> > 2 files changed, 103 insertions(+), 21 deletions(-)
> > create mode 100644 Documentation/ABI/testing/sysfs-fs-virtiofs
> >
> > diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c
> > index de9a38efdf1e..28e96b7cde00 100644
> > --- a/fs/fuse/virtio_fs.c
> > +++ b/fs/fuse/virtio_fs.c
> > @@ -31,6 +31,9 @@
> > static DEFINE_MUTEX(virtio_fs_mutex);
> > static LIST_HEAD(virtio_fs_instances);
> >
> > +/* The /sys/fs/virtio_fs/ kset */
> > +static struct kset *virtio_fs_kset;
> > +
> > enum {
> > VQ_HIPRIO,
> > VQ_REQUEST
> > @@ -55,7 +58,7 @@ struct virtio_fs_vq {
> >
> > /* A virtio-fs device instance */
> > struct virtio_fs {
> > - struct kref refcount;
> > + struct kobject kobj;
> > struct list_head list; /* on virtio_fs_instances */
> > char *tag;
> > struct virtio_fs_vq *vqs;
> > @@ -161,18 +164,43 @@ static inline void dec_in_flight_req(struct virtio_fs_vq *fsvq)
> > complete(&fsvq->in_flight_zero);
> > }
> >
> > -static void release_virtio_fs_obj(struct kref *ref)
> > +static ssize_t virtio_fs_tag_attr_show(struct kobject *kobj,
> > + struct kobj_attribute *attr, char *buf)
> > {
> > - struct virtio_fs *vfs = container_of(ref, struct virtio_fs, refcount);
> > + struct virtio_fs *fs = container_of(kobj, struct virtio_fs, kobj);
> > +
> > + return sysfs_emit(buf, fs->tag);
> > +}
> > +
> > +static struct kobj_attribute virtio_fs_tag_attr = {
> > + .attr = { .name = "tag", .mode= 0644 },
> > + .show = virtio_fs_tag_attr_show,
> > +};
>
> __ATTR_RO()?
> That way we all know you got the mode setting correct :)
>
> Other than that minor thing, looks good, nice job!
Will fix, thanks!
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2024-02-09 11:33 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-08 19:32 [PATCH v2 0/3] virtiofs: export filesystem tags through sysfs Stefan Hajnoczi
2024-02-08 19:32 ` [PATCH v2 1/3] virtiofs: forbid newlines in tags Stefan Hajnoczi
2024-02-09 10:33 ` Greg KH
2024-02-09 11:30 ` Stefan Hajnoczi
2024-02-08 19:32 ` [PATCH v2 2/3] virtiofs: export filesystem tags through sysfs Stefan Hajnoczi
2024-02-09 10:36 ` Greg KH
2024-02-09 11:33 ` Stefan Hajnoczi [this message]
2024-02-08 19:32 ` [PATCH v2 3/3] virtiofs: emit uevents on filesystem events Stefan Hajnoczi
2024-02-09 10:39 ` Greg KH
2024-02-09 12:15 ` Stefan Hajnoczi
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=20240209113328.GB748645@fedora \
--to=stefanha@redhat.com \
--cc=gmaglione@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=hi@alyssa.is \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=mzxreary@0pointer.de \
--cc=vgoyal@redhat.com \
--cc=virtio-fs@lists.linux.dev \
/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).