linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] virtio_fs: fix the hash table using in virtio_fs_enqueue_req()
@ 2025-07-03  6:47 lirongqing
  2025-07-07 13:35 ` Stefan Hajnoczi
  2025-08-18 12:39 ` Miklos Szeredi
  0 siblings, 2 replies; 3+ messages in thread
From: lirongqing @ 2025-07-03  6:47 UTC (permalink / raw)
  To: vgoyal, stefanha, miklos, eperezma, virtualization, linux-fsdevel,
	linux-kernel
  Cc: Li RongQing, Fushuai Wang

From: Li RongQing <lirongqing@baidu.com>

The original commit be2ff42c5d6e ("fuse: Use hash table to link
processing request") converted fuse_pqueue->processing to a hash table,
but virtio_fs_enqueue_req() was not updated to use it correctly.
So use fuse_pqueue->processing as a hash table, this make the code
more coherent

Co-developed-by: Fushuai Wang <wangfushuai@baidu.com>
Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
 fs/fuse/dev.c       | 1 +
 fs/fuse/virtio_fs.c | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index e80cd8f..4659bc8 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -322,6 +322,7 @@ unsigned int fuse_req_hash(u64 unique)
 {
 	return hash_long(unique & ~FUSE_INT_REQ_BIT, FUSE_PQ_HASH_BITS);
 }
+EXPORT_SYMBOL_GPL(fuse_req_hash);
 
 /*
  * A new request is available, wake fiq->waitq
diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c
index b8a99d3..d050470 100644
--- a/fs/fuse/virtio_fs.c
+++ b/fs/fuse/virtio_fs.c
@@ -21,6 +21,7 @@
 #include <linux/cleanup.h>
 #include <linux/uio.h>
 #include "fuse_i.h"
+#include "fuse_dev_i.h"
 
 /* Used to help calculate the FUSE connection's max_pages limit for a request's
  * size. Parts of the struct fuse_req are sliced into scattergather lists in
@@ -1382,7 +1383,7 @@ static int virtio_fs_enqueue_req(struct virtio_fs_vq *fsvq,
 	unsigned int out_sgs = 0;
 	unsigned int in_sgs = 0;
 	unsigned int total_sgs;
-	unsigned int i;
+	unsigned int i, hash;
 	int ret;
 	bool notify;
 	struct fuse_pqueue *fpq;
@@ -1442,8 +1443,9 @@ static int virtio_fs_enqueue_req(struct virtio_fs_vq *fsvq,
 
 	/* Request successfully sent. */
 	fpq = &fsvq->fud->pq;
+	hash = fuse_req_hash(req->in.h.unique);
 	spin_lock(&fpq->lock);
-	list_add_tail(&req->list, fpq->processing);
+	list_add_tail(&req->list, &fpq->processing[hash]);
 	spin_unlock(&fpq->lock);
 	set_bit(FR_SENT, &req->flags);
 	/* matches barrier in request_wait_answer() */
-- 
2.9.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] virtio_fs: fix the hash table using in virtio_fs_enqueue_req()
  2025-07-03  6:47 [PATCH] virtio_fs: fix the hash table using in virtio_fs_enqueue_req() lirongqing
@ 2025-07-07 13:35 ` Stefan Hajnoczi
  2025-08-18 12:39 ` Miklos Szeredi
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2025-07-07 13:35 UTC (permalink / raw)
  To: lirongqing
  Cc: vgoyal, stefanha, miklos, eperezma, virtualization, linux-fsdevel,
	linux-kernel, Fushuai Wang

On Thu, Jul 3, 2025 at 2:48 AM lirongqing <lirongqing@baidu.com> wrote:
>
> From: Li RongQing <lirongqing@baidu.com>
>
> The original commit be2ff42c5d6e ("fuse: Use hash table to link
> processing request") converted fuse_pqueue->processing to a hash table,
> but virtio_fs_enqueue_req() was not updated to use it correctly.
> So use fuse_pqueue->processing as a hash table, this make the code
> more coherent
>
> Co-developed-by: Fushuai Wang <wangfushuai@baidu.com>
> Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
> ---
>  fs/fuse/dev.c       | 1 +
>  fs/fuse/virtio_fs.c | 6 ++++--
>  2 files changed, 5 insertions(+), 2 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

>
> diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
> index e80cd8f..4659bc8 100644
> --- a/fs/fuse/dev.c
> +++ b/fs/fuse/dev.c
> @@ -322,6 +322,7 @@ unsigned int fuse_req_hash(u64 unique)
>  {
>         return hash_long(unique & ~FUSE_INT_REQ_BIT, FUSE_PQ_HASH_BITS);
>  }
> +EXPORT_SYMBOL_GPL(fuse_req_hash);
>
>  /*
>   * A new request is available, wake fiq->waitq
> diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c
> index b8a99d3..d050470 100644
> --- a/fs/fuse/virtio_fs.c
> +++ b/fs/fuse/virtio_fs.c
> @@ -21,6 +21,7 @@
>  #include <linux/cleanup.h>
>  #include <linux/uio.h>
>  #include "fuse_i.h"
> +#include "fuse_dev_i.h"
>
>  /* Used to help calculate the FUSE connection's max_pages limit for a request's
>   * size. Parts of the struct fuse_req are sliced into scattergather lists in
> @@ -1382,7 +1383,7 @@ static int virtio_fs_enqueue_req(struct virtio_fs_vq *fsvq,
>         unsigned int out_sgs = 0;
>         unsigned int in_sgs = 0;
>         unsigned int total_sgs;
> -       unsigned int i;
> +       unsigned int i, hash;
>         int ret;
>         bool notify;
>         struct fuse_pqueue *fpq;
> @@ -1442,8 +1443,9 @@ static int virtio_fs_enqueue_req(struct virtio_fs_vq *fsvq,
>
>         /* Request successfully sent. */
>         fpq = &fsvq->fud->pq;
> +       hash = fuse_req_hash(req->in.h.unique);
>         spin_lock(&fpq->lock);
> -       list_add_tail(&req->list, fpq->processing);
> +       list_add_tail(&req->list, &fpq->processing[hash]);
>         spin_unlock(&fpq->lock);
>         set_bit(FR_SENT, &req->flags);
>         /* matches barrier in request_wait_answer() */
> --
> 2.9.4
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] virtio_fs: fix the hash table using in virtio_fs_enqueue_req()
  2025-07-03  6:47 [PATCH] virtio_fs: fix the hash table using in virtio_fs_enqueue_req() lirongqing
  2025-07-07 13:35 ` Stefan Hajnoczi
@ 2025-08-18 12:39 ` Miklos Szeredi
  1 sibling, 0 replies; 3+ messages in thread
From: Miklos Szeredi @ 2025-08-18 12:39 UTC (permalink / raw)
  To: lirongqing
  Cc: vgoyal, stefanha, eperezma, virtualization, linux-fsdevel,
	linux-kernel, Fushuai Wang

On Thu, 3 Jul 2025 at 08:48, lirongqing <lirongqing@baidu.com> wrote:
>
> From: Li RongQing <lirongqing@baidu.com>
>
> The original commit be2ff42c5d6e ("fuse: Use hash table to link
> processing request") converted fuse_pqueue->processing to a hash table,
> but virtio_fs_enqueue_req() was not updated to use it correctly.
> So use fuse_pqueue->processing as a hash table, this make the code
> more coherent

Applied, thanks.

Miklos

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-08-18 12:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-03  6:47 [PATCH] virtio_fs: fix the hash table using in virtio_fs_enqueue_req() lirongqing
2025-07-07 13:35 ` Stefan Hajnoczi
2025-08-18 12:39 ` Miklos Szeredi

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).