From: Greg KH <gregkh@linuxfoundation.org>
To: Stefan Hajnoczi <stefanha@redhat.com>
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 3/3] virtiofs: emit uevents on filesystem events
Date: Fri, 9 Feb 2024 10:39:04 +0000 [thread overview]
Message-ID: <2024020943-hedge-majority-ef34@gregkh> (raw)
In-Reply-To: <20240208193212.731978-4-stefanha@redhat.com>
On Thu, Feb 08, 2024 at 02:32:11PM -0500, Stefan Hajnoczi wrote:
> Alyssa Ross <hi@alyssa.is> requested that virtiofs notifies userspace
> when filesytems become available. This can be used to detect when a
> filesystem with a given tag is hotplugged, for example. uevents allow
> userspace to detect changes without resorting to polling.
>
> The tag is included as a uevent property so it's easy for userspace to
> identify the filesystem in question even when the sysfs directory goes
> away during removal.
>
> Here are example uevents:
>
> # udevadm monitor -k -p
>
> KERNEL[111.113221] add /fs/virtiofs/2 (virtiofs)
> ACTION=add
> DEVPATH=/fs/virtiofs/2
> SUBSYSTEM=virtiofs
> TAG=test
>
> KERNEL[165.527167] remove /fs/virtiofs/2 (virtiofs)
> ACTION=remove
> DEVPATH=/fs/virtiofs/2
> SUBSYSTEM=virtiofs
> TAG=test
>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
> fs/fuse/virtio_fs.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c
> index 28e96b7cde00..18a8f531e5d4 100644
> --- a/fs/fuse/virtio_fs.c
> +++ b/fs/fuse/virtio_fs.c
> @@ -270,6 +270,17 @@ static void virtio_fs_start_all_queues(struct virtio_fs *fs)
> }
> }
>
> +static void virtio_fs_uevent(struct virtio_fs *fs, enum kobject_action action)
> +{
> + char tag_str[sizeof("TAG=") +
> + sizeof_field(struct virtio_fs_config, tag) + 1];
> + char *envp[] = {tag_str, NULL};
> +
> + snprintf(tag_str, sizeof(tag_str), "TAG=%s", fs->tag);
> +
> + kobject_uevent_env(&fs->kobj, action, envp);
> +}
> +
> /* Add a new instance to the list or return -EEXIST if tag name exists*/
> static int virtio_fs_add_instance(struct virtio_device *vdev,
> struct virtio_fs *fs)
> @@ -309,6 +320,8 @@ static int virtio_fs_add_instance(struct virtio_device *vdev,
>
> mutex_unlock(&virtio_fs_mutex);
>
> + virtio_fs_uevent(fs, KOBJ_ADD);
Why do you have to explicitly ask for the event? Doesn't sysfs trigger
this for you automatically? Set the kset uevent callback for this,
right?
thanks,
greg k-h
next prev parent reply other threads:[~2024-02-09 10:39 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
2024-02-08 19:32 ` [PATCH v2 3/3] virtiofs: emit uevents on filesystem events Stefan Hajnoczi
2024-02-09 10:39 ` Greg KH [this message]
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=2024020943-hedge-majority-ef34@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=gmaglione@redhat.com \
--cc=hi@alyssa.is \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=mzxreary@0pointer.de \
--cc=stefanha@redhat.com \
--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