From: Miklos Szeredi <mszeredi@redhat.com>
To: fuse-devel@lists.linux.dev, virtualization@lists.linux.dev
Cc: Li Wang <liwang@kylinos.cn>,
German Maglione <gmaglione@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: [PATCH 3/5] virtiofs: retry request submission from the worker on -ENOMEM
Date: Thu, 26 Nov 2026 15:47:16 +0100 [thread overview]
Message-ID: <20261126144719.232329-3-mszeredi@redhat.com> (raw)
In-Reply-To: <20261126144719.232329-1-mszeredi@redhat.com>
virtio_fs_send_req() enqueues with GFP_ATOMIC, because it may be called
with fc->chan->bg_lock held. copy_args_to_argbuf() allocates the bounce
buffer with those flags, so under memory pressure a request can be
failed with -ENOMEM even though nothing is wrong with it. The buffer is
as large as the request arguments, so this is not limited to tiny
allocations: FUSE_REMOVEMAPPING, for example, can ask for just over
4 KiB, an order-1 allocation out of the atomic reserves with no reclaim.
A virtqueue that is merely full is already handled gracefully: -ENOSPC
puts the request on fsvq->queued_reqs and virtio_fs_request_dispatch_work()
retries it with GFP_KERNEL under memalloc_nofs_save(). A failed atomic
allocation is just as transient, so treat it the same way instead of
ending the request. Unlike -ENOSPC there is no completion to kick the
worker afterwards, so schedule it here.
virtio_fs_enqueue_req() queues on -ENOSPC only after checking
fsvq->connected under fsvq->lock; do the same here and fail the request
with -ENOTCONN if the queue is gone. req->argbuf has already been freed
and cleared on the error path, so the retry reallocates it.
Fixes: a62a8ef9d97d ("virtio-fs: add virtiofs filesystem")
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
fs/fuse/virtio_fs.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c
index 8bd63c6165d2..6ddb2f181a16 100644
--- a/fs/fuse/virtio_fs.c
+++ b/fs/fuse/virtio_fs.c
@@ -1586,6 +1586,23 @@ static void virtio_fs_send_req(struct fuse_iqueue *fiq, struct fuse_req *req)
*/
return;
}
+ if (ret == -ENOMEM) {
+ /*
+ * Only the GFP_ATOMIC allocation failed. Hand the
+ * request to the dispatch worker, which retries with
+ * GFP_KERNEL, rather than failing it outright.
+ */
+ spin_lock(&fsvq->lock);
+ if (fsvq->connected) {
+ list_add_tail(&req->list, &fsvq->queued_reqs);
+ inc_in_flight_req(fsvq);
+ schedule_work(&fsvq->dispatch_work);
+ spin_unlock(&fsvq->lock);
+ return;
+ }
+ spin_unlock(&fsvq->lock);
+ ret = -ENOTCONN;
+ }
req->out.h.error = ret;
pr_err("virtio-fs: virtio_fs_enqueue_req() failed %d\n", ret);
--
2.56.1
next prev parent reply other threads:[~2026-11-26 14:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 14:47 [PATCH 1/5] virtiofs: fix DAX range leak on unmount Miklos Szeredi
2026-11-26 14:47 ` [PATCH 2/5] virtiofs: don't abort DAX removemapping on allocation failure Miklos Szeredi
2026-11-26 14:47 ` Miklos Szeredi [this message]
2026-11-26 14:47 ` [PATCH 4/5] virtiofs: abort the connection if the server fails to unmap a DAX range Miklos Szeredi
2026-11-26 14:47 ` [PATCH 5/5] virtiofs: fix forget leak on submount unmount Miklos Szeredi
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=20261126144719.232329-3-mszeredi@redhat.com \
--to=mszeredi@redhat.com \
--cc=fuse-devel@lists.linux.dev \
--cc=gmaglione@redhat.com \
--cc=liwang@kylinos.cn \
--cc=stefanha@redhat.com \
--cc=virtualization@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