From: Stefan Hajnoczi <stefanha@redhat.com> To: Vivek Goyal <vgoyal@redhat.com> Cc: miklos@szeredi.hu, qemu-devel@nongnu.org, iangelak@redhat.com, dgilbert@redhat.com, virtio-fs@redhat.com, jaggel@bu.edu Subject: Re: [PATCH 09/13] virtiofsd: Specify size of notification buffer using config space Date: Mon, 4 Oct 2021 15:33:47 +0100 [thread overview] Message-ID: <YVsQyxaPHyChcOel@stefanha-x1.localdomain> (raw) In-Reply-To: <20210930153037.1194279-10-vgoyal@redhat.com> [-- Attachment #1: Type: text/plain, Size: 5412 bytes --] On Thu, Sep 30, 2021 at 11:30:33AM -0400, Vivek Goyal wrote: > Daemon specifies size of notification buffer needed and that should be > done using config space. > > Only ->notify_buf_size value of config space comes from daemon. Rest of > it is filled by qemu device emulation code. > > Signed-off-by: Vivek Goyal <vgoyal@redhat.com> > Signed-off-by: Ioannis Angelakopoulos <iangelak@redhat.com> > --- > hw/virtio/vhost-user-fs.c | 27 +++++++++++++++++++ > include/hw/virtio/vhost-user-fs.h | 2 ++ > include/standard-headers/linux/virtio_fs.h | 2 ++ > tools/virtiofsd/fuse_virtio.c | 31 ++++++++++++++++++++++ > 4 files changed, 62 insertions(+) > > diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c > index 6bafcf0243..68a94708b4 100644 > --- a/hw/virtio/vhost-user-fs.c > +++ b/hw/virtio/vhost-user-fs.c > @@ -36,15 +36,41 @@ static const int user_feature_bits[] = { > VHOST_INVALID_FEATURE_BIT > }; > > +static int vhost_user_fs_handle_config_change(struct vhost_dev *dev) > +{ > + return 0; > +} > + > +const VhostDevConfigOps fs_ops = { > + .vhost_dev_config_notifier = vhost_user_fs_handle_config_change, > +}; > + > static void vuf_get_config(VirtIODevice *vdev, uint8_t *config) > { > VHostUserFS *fs = VHOST_USER_FS(vdev); > struct virtio_fs_config fscfg = {}; > + Error *local_err = NULL; > + int ret; > + > + /* > + * As of now we only get notification buffer size from device. And that's > + * needed only if notification queue is enabled. > + */ > + if (fs->notify_enabled) { > + ret = vhost_dev_get_config(&fs->vhost_dev, (uint8_t *)&fs->fscfg, > + sizeof(struct virtio_fs_config), > + &local_err); > + if (ret) { > + error_report_err(local_err); > + return; > + } > + } > > memcpy((char *)fscfg.tag, fs->conf.tag, > MIN(strlen(fs->conf.tag) + 1, sizeof(fscfg.tag))); > > virtio_stl_p(vdev, &fscfg.num_request_queues, fs->conf.num_request_queues); > + virtio_stl_p(vdev, &fscfg.notify_buf_size, fs->fscfg.notify_buf_size); > > memcpy(config, &fscfg, sizeof(fscfg)); > } > @@ -316,6 +342,7 @@ static void vuf_device_realize(DeviceState *dev, Error **errp) > sizeof(struct virtio_fs_config)); > > vuf_create_vqs(vdev, true); > + vhost_dev_set_config_notifier(&fs->vhost_dev, &fs_ops); > ret = vhost_dev_init(&fs->vhost_dev, &fs->vhost_user, > VHOST_BACKEND_TYPE_USER, 0, errp); > if (ret < 0) { > diff --git a/include/hw/virtio/vhost-user-fs.h b/include/hw/virtio/vhost-user-fs.h > index 95dc0dd402..3b114ee260 100644 > --- a/include/hw/virtio/vhost-user-fs.h > +++ b/include/hw/virtio/vhost-user-fs.h > @@ -14,6 +14,7 @@ > #ifndef _QEMU_VHOST_USER_FS_H > #define _QEMU_VHOST_USER_FS_H > > +#include "standard-headers/linux/virtio_fs.h" > #include "hw/virtio/virtio.h" > #include "hw/virtio/vhost.h" > #include "hw/virtio/vhost-user.h" > @@ -37,6 +38,7 @@ struct VHostUserFS { > struct vhost_virtqueue *vhost_vqs; > struct vhost_dev vhost_dev; > VhostUserState vhost_user; > + struct virtio_fs_config fscfg; > VirtQueue **req_vqs; > VirtQueue *hiprio_vq; > VirtQueue *notification_vq; > diff --git a/include/standard-headers/linux/virtio_fs.h b/include/standard-headers/linux/virtio_fs.h > index b7f015186e..867d18acf6 100644 > --- a/include/standard-headers/linux/virtio_fs.h > +++ b/include/standard-headers/linux/virtio_fs.h > @@ -17,6 +17,8 @@ struct virtio_fs_config { > > /* Number of request queues */ > uint32_t num_request_queues; > + /* Size of notification buffer */ > + uint32_t notify_buf_size; > } QEMU_PACKED; > > /* For the id field in virtio_pci_shm_cap */ Please put all the include/standard-headers/linux/ changes into a single commit that imports these changes from linux.git. Changes to this header shouldn't be hand-written, use scripts/update-linux-headers.sh instead. > diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c > index f5b87a508a..3b720c5d4a 100644 > --- a/tools/virtiofsd/fuse_virtio.c > +++ b/tools/virtiofsd/fuse_virtio.c > @@ -856,6 +856,35 @@ static bool fv_queue_order(VuDev *dev, int qidx) > return false; > } > > +static uint64_t fv_get_protocol_features(VuDev *dev) > +{ > + return 1ull << VHOST_USER_PROTOCOL_F_CONFIG; > +} > + > +static int fv_get_config(VuDev *dev, uint8_t *config, uint32_t len) > +{ > + struct virtio_fs_config fscfg = {}; > + unsigned notify_size, roundto = 64; > + union fuse_notify_union { > + struct fuse_notify_poll_wakeup_out wakeup_out; > + struct fuse_notify_inval_inode_out inode_out; > + struct fuse_notify_inval_entry_out entry_out; > + struct fuse_notify_delete_out delete_out; > + struct fuse_notify_store_out store_out; > + struct fuse_notify_retrieve_out retrieve_out; > + }; > + > + notify_size = sizeof(struct fuse_out_header) + > + sizeof(union fuse_notify_union); > + notify_size = ((notify_size + roundto) / roundto) * roundto; Why is the size rounded to 64 bytes? [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: Stefan Hajnoczi <stefanha@redhat.com> To: Vivek Goyal <vgoyal@redhat.com> Cc: miklos@szeredi.hu, qemu-devel@nongnu.org, virtio-fs@redhat.com Subject: Re: [Virtio-fs] [PATCH 09/13] virtiofsd: Specify size of notification buffer using config space Date: Mon, 4 Oct 2021 15:33:47 +0100 [thread overview] Message-ID: <YVsQyxaPHyChcOel@stefanha-x1.localdomain> (raw) In-Reply-To: <20210930153037.1194279-10-vgoyal@redhat.com> [-- Attachment #1: Type: text/plain, Size: 5412 bytes --] On Thu, Sep 30, 2021 at 11:30:33AM -0400, Vivek Goyal wrote: > Daemon specifies size of notification buffer needed and that should be > done using config space. > > Only ->notify_buf_size value of config space comes from daemon. Rest of > it is filled by qemu device emulation code. > > Signed-off-by: Vivek Goyal <vgoyal@redhat.com> > Signed-off-by: Ioannis Angelakopoulos <iangelak@redhat.com> > --- > hw/virtio/vhost-user-fs.c | 27 +++++++++++++++++++ > include/hw/virtio/vhost-user-fs.h | 2 ++ > include/standard-headers/linux/virtio_fs.h | 2 ++ > tools/virtiofsd/fuse_virtio.c | 31 ++++++++++++++++++++++ > 4 files changed, 62 insertions(+) > > diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c > index 6bafcf0243..68a94708b4 100644 > --- a/hw/virtio/vhost-user-fs.c > +++ b/hw/virtio/vhost-user-fs.c > @@ -36,15 +36,41 @@ static const int user_feature_bits[] = { > VHOST_INVALID_FEATURE_BIT > }; > > +static int vhost_user_fs_handle_config_change(struct vhost_dev *dev) > +{ > + return 0; > +} > + > +const VhostDevConfigOps fs_ops = { > + .vhost_dev_config_notifier = vhost_user_fs_handle_config_change, > +}; > + > static void vuf_get_config(VirtIODevice *vdev, uint8_t *config) > { > VHostUserFS *fs = VHOST_USER_FS(vdev); > struct virtio_fs_config fscfg = {}; > + Error *local_err = NULL; > + int ret; > + > + /* > + * As of now we only get notification buffer size from device. And that's > + * needed only if notification queue is enabled. > + */ > + if (fs->notify_enabled) { > + ret = vhost_dev_get_config(&fs->vhost_dev, (uint8_t *)&fs->fscfg, > + sizeof(struct virtio_fs_config), > + &local_err); > + if (ret) { > + error_report_err(local_err); > + return; > + } > + } > > memcpy((char *)fscfg.tag, fs->conf.tag, > MIN(strlen(fs->conf.tag) + 1, sizeof(fscfg.tag))); > > virtio_stl_p(vdev, &fscfg.num_request_queues, fs->conf.num_request_queues); > + virtio_stl_p(vdev, &fscfg.notify_buf_size, fs->fscfg.notify_buf_size); > > memcpy(config, &fscfg, sizeof(fscfg)); > } > @@ -316,6 +342,7 @@ static void vuf_device_realize(DeviceState *dev, Error **errp) > sizeof(struct virtio_fs_config)); > > vuf_create_vqs(vdev, true); > + vhost_dev_set_config_notifier(&fs->vhost_dev, &fs_ops); > ret = vhost_dev_init(&fs->vhost_dev, &fs->vhost_user, > VHOST_BACKEND_TYPE_USER, 0, errp); > if (ret < 0) { > diff --git a/include/hw/virtio/vhost-user-fs.h b/include/hw/virtio/vhost-user-fs.h > index 95dc0dd402..3b114ee260 100644 > --- a/include/hw/virtio/vhost-user-fs.h > +++ b/include/hw/virtio/vhost-user-fs.h > @@ -14,6 +14,7 @@ > #ifndef _QEMU_VHOST_USER_FS_H > #define _QEMU_VHOST_USER_FS_H > > +#include "standard-headers/linux/virtio_fs.h" > #include "hw/virtio/virtio.h" > #include "hw/virtio/vhost.h" > #include "hw/virtio/vhost-user.h" > @@ -37,6 +38,7 @@ struct VHostUserFS { > struct vhost_virtqueue *vhost_vqs; > struct vhost_dev vhost_dev; > VhostUserState vhost_user; > + struct virtio_fs_config fscfg; > VirtQueue **req_vqs; > VirtQueue *hiprio_vq; > VirtQueue *notification_vq; > diff --git a/include/standard-headers/linux/virtio_fs.h b/include/standard-headers/linux/virtio_fs.h > index b7f015186e..867d18acf6 100644 > --- a/include/standard-headers/linux/virtio_fs.h > +++ b/include/standard-headers/linux/virtio_fs.h > @@ -17,6 +17,8 @@ struct virtio_fs_config { > > /* Number of request queues */ > uint32_t num_request_queues; > + /* Size of notification buffer */ > + uint32_t notify_buf_size; > } QEMU_PACKED; > > /* For the id field in virtio_pci_shm_cap */ Please put all the include/standard-headers/linux/ changes into a single commit that imports these changes from linux.git. Changes to this header shouldn't be hand-written, use scripts/update-linux-headers.sh instead. > diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c > index f5b87a508a..3b720c5d4a 100644 > --- a/tools/virtiofsd/fuse_virtio.c > +++ b/tools/virtiofsd/fuse_virtio.c > @@ -856,6 +856,35 @@ static bool fv_queue_order(VuDev *dev, int qidx) > return false; > } > > +static uint64_t fv_get_protocol_features(VuDev *dev) > +{ > + return 1ull << VHOST_USER_PROTOCOL_F_CONFIG; > +} > + > +static int fv_get_config(VuDev *dev, uint8_t *config, uint32_t len) > +{ > + struct virtio_fs_config fscfg = {}; > + unsigned notify_size, roundto = 64; > + union fuse_notify_union { > + struct fuse_notify_poll_wakeup_out wakeup_out; > + struct fuse_notify_inval_inode_out inode_out; > + struct fuse_notify_inval_entry_out entry_out; > + struct fuse_notify_delete_out delete_out; > + struct fuse_notify_store_out store_out; > + struct fuse_notify_retrieve_out retrieve_out; > + }; > + > + notify_size = sizeof(struct fuse_out_header) + > + sizeof(union fuse_notify_union); > + notify_size = ((notify_size + roundto) / roundto) * roundto; Why is the size rounded to 64 bytes? [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2021-10-04 14:38 UTC|newest] Thread overview: 106+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-09-30 15:30 [PATCH 00/13] virtiofsd: Support notification queue and Vivek Goyal 2021-09-30 15:30 ` [Virtio-fs] " Vivek Goyal 2021-09-30 15:30 ` [PATCH 01/13] virtio_fs.h: Add notification queue feature bit Vivek Goyal 2021-09-30 15:30 ` [Virtio-fs] " Vivek Goyal 2021-10-04 13:12 ` Stefan Hajnoczi 2021-10-04 13:12 ` [Virtio-fs] " Stefan Hajnoczi 2021-09-30 15:30 ` [PATCH 02/13] virtiofsd: fuse.h header file changes for lock notification Vivek Goyal 2021-09-30 15:30 ` [Virtio-fs] " Vivek Goyal 2021-10-04 13:16 ` Stefan Hajnoczi 2021-10-04 13:16 ` [Virtio-fs] " Stefan Hajnoczi 2021-10-04 14:01 ` Vivek Goyal 2021-10-04 14:01 ` [Virtio-fs] " Vivek Goyal 2021-09-30 15:30 ` [PATCH 03/13] virtiofsd: Remove unused virtio_fs_config definition Vivek Goyal 2021-09-30 15:30 ` [Virtio-fs] " Vivek Goyal 2021-10-04 13:17 ` Stefan Hajnoczi 2021-10-04 13:17 ` [Virtio-fs] " Stefan Hajnoczi 2021-09-30 15:30 ` [PATCH 04/13] virtiofsd: Add a helper to send element on virtqueue Vivek Goyal 2021-09-30 15:30 ` [Virtio-fs] " Vivek Goyal 2021-10-04 13:19 ` Stefan Hajnoczi 2021-10-04 13:19 ` [Virtio-fs] " Stefan Hajnoczi 2021-09-30 15:30 ` [PATCH 05/13] virtiofsd: Add a helper to stop all queues Vivek Goyal 2021-09-30 15:30 ` [Virtio-fs] " Vivek Goyal 2021-10-04 13:22 ` Stefan Hajnoczi 2021-10-04 13:22 ` [Virtio-fs] " Stefan Hajnoczi 2021-09-30 15:30 ` [PATCH 06/13] vhost-user-fs: Use helpers to create/cleanup virtqueue Vivek Goyal 2021-09-30 15:30 ` [Virtio-fs] " Vivek Goyal 2021-10-04 13:54 ` Stefan Hajnoczi 2021-10-04 13:54 ` [Virtio-fs] " Stefan Hajnoczi 2021-10-04 19:58 ` Vivek Goyal 2021-10-04 19:58 ` [Virtio-fs] " Vivek Goyal 2021-10-05 8:09 ` Stefan Hajnoczi 2021-10-05 8:09 ` [Virtio-fs] " Stefan Hajnoczi 2021-10-06 13:35 ` Christophe de Dinechin 2021-10-06 13:35 ` Christophe de Dinechin 2021-10-06 17:40 ` Vivek Goyal 2021-10-06 17:40 ` Vivek Goyal 2021-09-30 15:30 ` [PATCH 07/13] virtiofsd: Release file locks using F_UNLCK Vivek Goyal 2021-09-30 15:30 ` [Virtio-fs] " Vivek Goyal 2021-10-05 13:37 ` Christophe de Dinechin 2021-10-05 13:37 ` Christophe de Dinechin 2021-10-05 15:38 ` Vivek Goyal 2021-10-05 15:38 ` Vivek Goyal 2021-09-30 15:30 ` [PATCH 08/13] virtiofsd: Create a notification queue Vivek Goyal 2021-09-30 15:30 ` [Virtio-fs] " Vivek Goyal 2021-10-04 14:30 ` Stefan Hajnoczi 2021-10-04 14:30 ` [Virtio-fs] " Stefan Hajnoczi 2021-10-04 21:01 ` Vivek Goyal 2021-10-04 21:01 ` [Virtio-fs] " Vivek Goyal 2021-10-05 8:14 ` Stefan Hajnoczi 2021-10-05 8:14 ` [Virtio-fs] " Stefan Hajnoczi 2021-10-05 12:31 ` Vivek Goyal 2021-10-05 12:31 ` [Virtio-fs] " Vivek Goyal 2021-09-30 15:30 ` [PATCH 09/13] virtiofsd: Specify size of notification buffer using config space Vivek Goyal 2021-09-30 15:30 ` [Virtio-fs] " Vivek Goyal 2021-10-04 14:33 ` Stefan Hajnoczi [this message] 2021-10-04 14:33 ` Stefan Hajnoczi 2021-10-04 21:10 ` Vivek Goyal 2021-10-04 21:10 ` [Virtio-fs] " Vivek Goyal 2021-10-06 10:05 ` Christophe de Dinechin 2021-10-06 10:05 ` Christophe de Dinechin 2021-09-30 15:30 ` [PATCH 10/13] virtiofsd: Custom threadpool for remote blocking posix locks requests Vivek Goyal 2021-09-30 15:30 ` [Virtio-fs] " Vivek Goyal 2021-10-04 14:54 ` Stefan Hajnoczi 2021-10-04 14:54 ` [Virtio-fs] " Stefan Hajnoczi 2021-10-05 13:06 ` Vivek Goyal 2021-10-05 13:06 ` [Virtio-fs] " Vivek Goyal 2021-10-05 20:09 ` Vivek Goyal 2021-10-05 20:09 ` [Virtio-fs] " Vivek Goyal 2021-10-06 10:26 ` Stefan Hajnoczi 2021-10-06 10:26 ` [Virtio-fs] " Stefan Hajnoczi 2021-09-30 15:30 ` [PATCH 11/13] virtiofsd: Shutdown notification queue in the end Vivek Goyal 2021-09-30 15:30 ` [Virtio-fs] " Vivek Goyal 2021-10-04 15:01 ` Stefan Hajnoczi 2021-10-04 15:01 ` [Virtio-fs] " Stefan Hajnoczi 2021-10-05 13:19 ` Vivek Goyal 2021-10-05 13:19 ` [Virtio-fs] " Vivek Goyal 2021-10-06 15:15 ` Christophe de Dinechin 2021-10-06 15:15 ` Christophe de Dinechin 2021-10-06 17:58 ` Vivek Goyal 2021-10-06 17:58 ` Vivek Goyal 2021-09-30 15:30 ` [PATCH 12/13] virtiofsd: Implement blocking posix locks Vivek Goyal 2021-09-30 15:30 ` [Virtio-fs] " Vivek Goyal 2021-10-04 15:07 ` Stefan Hajnoczi 2021-10-04 15:07 ` [Virtio-fs] " Stefan Hajnoczi 2021-10-05 13:26 ` Vivek Goyal 2021-10-05 13:26 ` [Virtio-fs] " Vivek Goyal 2021-10-05 12:22 ` Stefan Hajnoczi 2021-10-05 12:22 ` [Virtio-fs] " Stefan Hajnoczi 2021-10-05 15:14 ` Vivek Goyal 2021-10-05 15:14 ` [Virtio-fs] " Vivek Goyal 2021-10-05 15:49 ` Stefan Hajnoczi 2021-10-05 15:49 ` [Virtio-fs] " Stefan Hajnoczi 2021-10-06 15:34 ` Christophe de Dinechin 2021-10-06 15:34 ` Christophe de Dinechin 2021-10-06 18:17 ` Vivek Goyal 2021-10-06 18:17 ` Vivek Goyal 2021-09-30 15:30 ` [PATCH 13/13] virtiofsd, seccomp: Add clock_nanosleep() to allow list Vivek Goyal 2021-09-30 15:30 ` [Virtio-fs] " Vivek Goyal 2021-10-05 12:22 ` Stefan Hajnoczi 2021-10-05 12:22 ` [Virtio-fs] " Stefan Hajnoczi 2021-10-05 15:16 ` Vivek Goyal 2021-10-05 15:50 ` Stefan Hajnoczi 2021-10-05 17:28 ` Vivek Goyal 2021-10-06 10:27 ` Stefan Hajnoczi 2021-10-25 18:00 ` [PATCH 00/13] virtiofsd: Support notification queue and Dr. David Alan Gilbert 2021-10-25 18:00 ` [Virtio-fs] " Dr. David Alan Gilbert
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=YVsQyxaPHyChcOel@stefanha-x1.localdomain \ --to=stefanha@redhat.com \ --cc=dgilbert@redhat.com \ --cc=iangelak@redhat.com \ --cc=jaggel@bu.edu \ --cc=miklos@szeredi.hu \ --cc=qemu-devel@nongnu.org \ --cc=vgoyal@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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.