* [PATCH v3 2/5] virtiofs: don't abort DAX removemapping on allocation failure
2026-12-01 10:58 [PATCH v3 1/5] virtiofs: fix DAX range leak on unmount Miklos Szeredi
@ 2026-12-01 10:58 ` Miklos Szeredi
2026-12-01 15:18 ` German Maglione
2026-12-01 10:58 ` [PATCH v3 3/5] virtiofs: retry request submission from the worker on -ENOMEM Miklos Szeredi
` (4 subsequent siblings)
5 siblings, 1 reply; 14+ messages in thread
From: Miklos Szeredi @ 2026-12-01 10:58 UTC (permalink / raw)
To: fuse-devel, virtualization; +Cc: Li Wang, German Maglione, Stefan Hajnoczi
dmap_removemapping_list() allocates an array of fuse_removemapping_one
entries to batch the FUSE_REMOVEMAPPING request, and returns -ENOMEM if
that fails.
The batch array is only a convenience: dmap_removemapping_one() already
sends a single entry entirely from the stack. Move it above
dmap_removemapping_list() and use it to remove the ranges one at a time
when the array cannot be allocated. That is slower, but it cannot fail
for lack of memory, and it only happens under memory pressure.
While at it, initialize ret, which was left uninitialized if the list
passed in was empty. The current caller checks for that beforehand, so
this is not a bug today.
Fixes: c2d0ad00d948 ("virtiofs: implement dax read/write operations")
Reviewed-by: Li Wang <liwang@kylinos.cn>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
fs/fuse/dax.c | 49 +++++++++++++++++++++++++++++++------------------
1 file changed, 31 insertions(+), 18 deletions(-)
diff --git a/fs/fuse/dax.c b/fs/fuse/dax.c
index e20a5ae6fecc..e60665bb597e 100644
--- a/fs/fuse/dax.c
+++ b/fs/fuse/dax.c
@@ -248,18 +248,46 @@ static int fuse_send_removemapping(struct inode *inode,
return fuse_simple_request(fm, &args);
}
+static int dmap_removemapping_one(struct inode *inode,
+ struct fuse_dax_mapping *dmap)
+{
+ struct fuse_removemapping_one forget_one;
+ struct fuse_removemapping_in inarg;
+
+ memset(&inarg, 0, sizeof(inarg));
+ inarg.count = 1;
+ memset(&forget_one, 0, sizeof(forget_one));
+ forget_one.moffset = dmap->window_offset;
+ forget_one.len = dmap->length;
+
+ return fuse_send_removemapping(inode, &inarg, &forget_one);
+}
+
static int dmap_removemapping_list(struct inode *inode, unsigned int num,
struct list_head *to_remove)
{
struct fuse_removemapping_one *remove_one, *ptr;
struct fuse_removemapping_in inarg;
struct fuse_dax_mapping *dmap;
- int ret, i = 0, nr_alloc;
+ int ret = 0, i = 0, nr_alloc;
nr_alloc = min_t(unsigned int, num, FUSE_REMOVEMAPPING_MAX_ENTRY);
remove_one = kmalloc_objs(*remove_one, nr_alloc, GFP_NOFS);
- if (!remove_one)
- return -ENOMEM;
+ if (!remove_one) {
+ /*
+ * Fall back to removing the ranges one at a time, which needs
+ * no allocation. It is slower, but this only happens under
+ * memory pressure. The caller ignores the error and recycles
+ * the ranges regardless, so bailing out here would just leave
+ * the server holding mappings for an inode that is gone.
+ */
+ list_for_each_entry(dmap, to_remove, list) {
+ ret = dmap_removemapping_one(inode, dmap);
+ if (ret)
+ break;
+ }
+ return ret;
+ }
ptr = remove_one;
list_for_each_entry(dmap, to_remove, list) {
@@ -350,21 +378,6 @@ static void inode_reclaim_dmap_range(struct fuse_conn_vdax *fcd,
spin_unlock(&fcd->lock);
}
-static int dmap_removemapping_one(struct inode *inode,
- struct fuse_dax_mapping *dmap)
-{
- struct fuse_removemapping_one forget_one;
- struct fuse_removemapping_in inarg;
-
- memset(&inarg, 0, sizeof(inarg));
- inarg.count = 1;
- memset(&forget_one, 0, sizeof(forget_one));
- forget_one.moffset = dmap->window_offset;
- forget_one.len = dmap->length;
-
- return fuse_send_removemapping(inode, &inarg, &forget_one);
-}
-
/*
* It is called from evict_inode() and by that time inode is going away. So
* this function does not take any locks like fi->vdax->sem for traversing
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v3 2/5] virtiofs: don't abort DAX removemapping on allocation failure
2026-12-01 10:58 ` [PATCH v3 2/5] virtiofs: don't abort DAX removemapping on allocation failure Miklos Szeredi
@ 2026-12-01 15:18 ` German Maglione
0 siblings, 0 replies; 14+ messages in thread
From: German Maglione @ 2026-12-01 15:18 UTC (permalink / raw)
To: Miklos Szeredi
Cc: fuse-devel, virtualization, Li Wang, German Maglione,
Stefan Hajnoczi
On Tue, 01 Dec 2026 11:58:50 +0100, Miklos Szeredi <mszeredi@redhat.com> wrote:
> dmap_removemapping_list() allocates an array of fuse_removemapping_one
> entries to batch the FUSE_REMOVEMAPPING request, and returns -ENOMEM if
> that fails.
>
> The batch array is only a convenience: dmap_removemapping_one() already
> sends a single entry entirely from the stack. Move it above
> dmap_removemapping_list() and use it to remove the ranges one at a time
> when the array cannot be allocated. That is slower, but it cannot fail
> for lack of memory, and it only happens under memory pressure.
>
> [...]
Reviewed-by: German Maglione <gmaglione@redhat.com>
--
German Maglione <gmaglione@redhat.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v3 3/5] virtiofs: retry request submission from the worker on -ENOMEM
2026-12-01 10:58 [PATCH v3 1/5] virtiofs: fix DAX range leak on unmount Miklos Szeredi
2026-12-01 10:58 ` [PATCH v3 2/5] virtiofs: don't abort DAX removemapping on allocation failure Miklos Szeredi
@ 2026-12-01 10:58 ` Miklos Szeredi
2026-12-01 11:05 ` sashiko-bot
2026-12-01 15:18 ` German Maglione
2026-12-01 10:58 ` [PATCH v3 4/5] fuse: don't take a lookup count on the root inode Miklos Szeredi
` (3 subsequent siblings)
5 siblings, 2 replies; 14+ messages in thread
From: Miklos Szeredi @ 2026-12-01 10:58 UTC (permalink / raw)
To: fuse-devel, virtualization; +Cc: Li Wang, German Maglione, Stefan Hajnoczi
virtio_fs_send_req() enqueues with GFP_ATOMIC, because it may be called
with fc->chan->bg_lock held. The sg arrays and, via
copy_args_to_argbuf(), the bounce buffer are allocated 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.
virtqueue_add_sgs() can also report -ENOMEM, but only for a DMA mapping
failure, which the retry will not fix (failure to allocate the indirect
descriptor table falls back to direct descriptors and does not return
-ENOMEM). Such a request is retried once and then ended with -ENOMEM by
the worker, so the two cases are not worth telling apart.
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")
Reviewed-by: Li Wang <liwang@kylinos.cn>
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
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v3 3/5] virtiofs: retry request submission from the worker on -ENOMEM
2026-12-01 10:58 ` [PATCH v3 3/5] virtiofs: retry request submission from the worker on -ENOMEM Miklos Szeredi
@ 2026-12-01 11:05 ` sashiko-bot
2026-12-01 15:18 ` German Maglione
1 sibling, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-12-01 11:05 UTC (permalink / raw)
To: Miklos Szeredi, virtualization; +Cc: Michael S. Tsirkin, Eugenio Perez
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] virtiofs: inaccurate Fixes trailer in commit message
--
commit 339631fd56eaa181fdd0c0ebe1ee0c1ec631f226
Author: Miklos Szeredi <mszeredi@redhat.com>
> virtiofs: retry request submission from the worker on -ENOMEM
>
> virtio_fs_send_req() enqueues with GFP_ATOMIC, because it may be called
> with fc->chan->bg_lock held. The sg arrays and, via
> copy_args_to_argbuf(), the bounce buffer are allocated 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.
>
> virtqueue_add_sgs() can also report -ENOMEM, but only for a DMA mapping
> failure, which the retry will not fix (failure to allocate the indirect
> descriptor table falls back to direct descriptors and does not return
> -ENOMEM). Such a request is retried once and then ended with -ENOMEM by
> the worker, so the two cases are not worth telling apart.
>
> 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")
> Reviewed-by: Li Wang <liwang@kylinos.cn>
> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
[Severity: Low]
In commit a62a8ef9d97d ("virtio-fs: add virtiofs filesystem"), initial
submission already retried on -ENOMEM alongside -ENOSPC, and commit
a9bfd9dd3417 ("virtiofs: Retry request submission from worker context")
preserved that when moving retries to fsvq->queued_reqs and
fsvq->dispatch_work. It was commit 2106e1f444d9 ("virtio-fs: let -ENOMEM
bubble up or burst gently") that dropped -ENOMEM from the retry check and
caused GFP_ATOMIC allocation failures to end the request immediately.
Should the Fixes tag be:
Fixes: 2106e1f444d9 ("virtio-fs: let -ENOMEM bubble up or burst gently")
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201105855.430993-1-mszeredi@redhat.com?part=3
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH v3 3/5] virtiofs: retry request submission from the worker on -ENOMEM
2026-12-01 10:58 ` [PATCH v3 3/5] virtiofs: retry request submission from the worker on -ENOMEM Miklos Szeredi
2026-12-01 11:05 ` sashiko-bot
@ 2026-12-01 15:18 ` German Maglione
1 sibling, 0 replies; 14+ messages in thread
From: German Maglione @ 2026-12-01 15:18 UTC (permalink / raw)
To: Miklos Szeredi
Cc: fuse-devel, virtualization, Li Wang, German Maglione,
Stefan Hajnoczi
On Tue, 01 Dec 2026 11:58:51 +0100, Miklos Szeredi <mszeredi@redhat.com> wrote:
> virtio_fs_send_req() enqueues with GFP_ATOMIC, because it may be called
> with fc->chan->bg_lock held. The sg arrays and, via
> copy_args_to_argbuf(), the bounce buffer are allocated 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.
>
> [...]
Reviewed-by: German Maglione <gmaglione@redhat.com>
--
German Maglione <gmaglione@redhat.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v3 4/5] fuse: don't take a lookup count on the root inode
2026-12-01 10:58 [PATCH v3 1/5] virtiofs: fix DAX range leak on unmount Miklos Szeredi
2026-12-01 10:58 ` [PATCH v3 2/5] virtiofs: don't abort DAX removemapping on allocation failure Miklos Szeredi
2026-12-01 10:58 ` [PATCH v3 3/5] virtiofs: retry request submission from the worker on -ENOMEM Miklos Szeredi
@ 2026-12-01 10:58 ` Miklos Szeredi
2026-12-01 15:18 ` German Maglione
2026-12-02 3:50 ` Li Wang
2026-12-01 10:58 ` [PATCH v3 5/5] virtiofs: fix forget leak on submount unmount Miklos Szeredi
` (2 subsequent siblings)
5 siblings, 2 replies; 14+ messages in thread
From: Miklos Szeredi @ 2026-12-01 10:58 UTC (permalink / raw)
To: fuse-devel, virtualization; +Cc: Li Wang, German Maglione, Stefan Hajnoczi
The root inode is not obtained through a lookup, so the server holds no
lookup count for FUSE_ROOT_ID and must never be sent a FUSE_FORGET for
it. fuse_iget() increments nlookup for every inode it instantiates,
though, leaving the root with a lookup count of one that does not
correspond to anything on the server side.
This is harmless today: the root inode is pinned by sb->s_root for the
lifetime of the mount, and the only eviction happens from
generic_shutdown_super(), which clears SB_ACTIVE before calling
evict_inodes(), so fuse_evict_inode() never acts on the count. That
makes the invariant depend on eviction ordering rather than on anything
explicit, which is a trap for future changes to that logic.
Drop the bogus reference where it is taken, the same way
fuse_fill_super_submount() already does for the duplicate root of a
submount.
No functional change.
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
fs/fuse/inode.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 344fcb55a64b..7849cbbdcab6 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -1085,12 +1085,23 @@ dev_t fuse_conn_get_id(struct fuse_conn *fc)
static struct inode *fuse_get_root_inode(struct super_block *sb, unsigned int mode)
{
struct fuse_attr attr;
+ struct inode *inode;
+
memset(&attr, 0, sizeof(attr));
attr.mode = mode;
attr.ino = FUSE_ROOT_ID;
attr.nlink = 1;
- return fuse_iget(sb, FUSE_ROOT_ID, 0, &attr, 0, 0, 0);
+ inode = fuse_iget(sb, FUSE_ROOT_ID, 0, &attr, 0, 0, 0);
+ /*
+ * The root is not looked up, so the server holds no lookup count for
+ * it and must never be sent a FUSE_FORGET for FUSE_ROOT_ID.
+ * fuse_iget() incremented nlookup, though, so undo it here.
+ */
+ if (inode)
+ get_fuse_inode(inode)->nlookup--;
+
+ return inode;
}
struct fuse_inode_handle {
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v3 4/5] fuse: don't take a lookup count on the root inode
2026-12-01 10:58 ` [PATCH v3 4/5] fuse: don't take a lookup count on the root inode Miklos Szeredi
@ 2026-12-01 15:18 ` German Maglione
2026-12-02 3:50 ` Li Wang
1 sibling, 0 replies; 14+ messages in thread
From: German Maglione @ 2026-12-01 15:18 UTC (permalink / raw)
To: Miklos Szeredi
Cc: fuse-devel, virtualization, Li Wang, German Maglione,
Stefan Hajnoczi
On Tue, 01 Dec 2026 11:58:52 +0100, Miklos Szeredi <mszeredi@redhat.com> wrote:
> The root inode is not obtained through a lookup, so the server holds no
> lookup count for FUSE_ROOT_ID and must never be sent a FUSE_FORGET for
> it. fuse_iget() increments nlookup for every inode it instantiates,
> though, leaving the root with a lookup count of one that does not
> correspond to anything on the server side.
>
> This is harmless today: the root inode is pinned by sb->s_root for the
> lifetime of the mount, and the only eviction happens from
> generic_shutdown_super(), which clears SB_ACTIVE before calling
> evict_inodes(), so fuse_evict_inode() never acts on the count. That
> makes the invariant depend on eviction ordering rather than on anything
> explicit, which is a trap for future changes to that logic.
>
> [...]
Reviewed-by: German Maglione <gmaglione@redhat.com>
--
German Maglione <gmaglione@redhat.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 4/5] fuse: don't take a lookup count on the root inode
2026-12-01 10:58 ` [PATCH v3 4/5] fuse: don't take a lookup count on the root inode Miklos Szeredi
2026-12-01 15:18 ` German Maglione
@ 2026-12-02 3:50 ` Li Wang
1 sibling, 0 replies; 14+ messages in thread
From: Li Wang @ 2026-12-02 3:50 UTC (permalink / raw)
To: Miklos Szeredi, fuse-devel, virtualization
Cc: German Maglione, Stefan Hajnoczi
Hi Miklos,
On 01/12/2026 18:58, Miklos Szeredi wrote:
> The root inode is not obtained through a lookup, so the server holds no
> lookup count for FUSE_ROOT_ID and must never be sent a FUSE_FORGET for
> it. fuse_iget() increments nlookup for every inode it instantiates,
> though, leaving the root with a lookup count of one that does not
> correspond to anything on the server side.
>
> This is harmless today: the root inode is pinned by sb->s_root for the
> lifetime of the mount, and the only eviction happens from
> generic_shutdown_super(), which clears SB_ACTIVE before calling
> evict_inodes(), so fuse_evict_inode() never acts on the count. That
> makes the invariant depend on eviction ordering rather than on anything
> explicit, which is a trap for future changes to that logic.
>
> Drop the bogus reference where it is taken, the same way
> fuse_fill_super_submount() already does for the duplicate root of a
> submount.
>
> No functional change.
>
> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
> ---
> fs/fuse/inode.c | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
> index 344fcb55a64b..7849cbbdcab6 100644
> --- a/fs/fuse/inode.c
> +++ b/fs/fuse/inode.c
> @@ -1085,12 +1085,23 @@ dev_t fuse_conn_get_id(struct fuse_conn *fc)
> static struct inode *fuse_get_root_inode(struct super_block *sb, unsigned int mode)
> {
> struct fuse_attr attr;
> + struct inode *inode;
> +
> memset(&attr, 0, sizeof(attr));
>
> attr.mode = mode;
> attr.ino = FUSE_ROOT_ID;
> attr.nlink = 1;
> - return fuse_iget(sb, FUSE_ROOT_ID, 0, &attr, 0, 0, 0);
> + inode = fuse_iget(sb, FUSE_ROOT_ID, 0, &attr, 0, 0, 0);
> + /*
> + * The root is not looked up, so the server holds no lookup count for
> + * it and must never be sent a FUSE_FORGET for FUSE_ROOT_ID.
> + * fuse_iget() incremented nlookup, though, so undo it here.
> + */
> + if (inode)
> + get_fuse_inode(inode)->nlookup--;
Just a thought: fuse_iget()'s semantics are simply to look up or allocate
the client-side inode by nodeid, which does not necessarily map 1:1 to a server
lookup (for example, fuse_get_root_inode() and fuse_fill_super_submount() are
local operations and do not issue a server lookup). It might be worth considering
adding a bool nlookup parameter to fuse_iget() to control whether nlookup is incremented,
avoiding the somewhat awkward nlookup-- dance in callers.
Reviewed-by: Li Wang <liwang@kylinos.cn>
Thanks,
Li Wang
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v3 5/5] virtiofs: fix forget leak on submount unmount
2026-12-01 10:58 [PATCH v3 1/5] virtiofs: fix DAX range leak on unmount Miklos Szeredi
` (2 preceding siblings ...)
2026-12-01 10:58 ` [PATCH v3 4/5] fuse: don't take a lookup count on the root inode Miklos Szeredi
@ 2026-12-01 10:58 ` Miklos Szeredi
2026-12-01 13:23 ` Li Wang
2026-12-01 15:18 ` German Maglione
2026-12-01 11:11 ` [PATCH v3 1/5] virtiofs: fix DAX range leak on unmount sashiko-bot
2026-12-01 15:18 ` German Maglione
5 siblings, 2 replies; 14+ messages in thread
From: Miklos Szeredi @ 2026-12-01 10:58 UTC (permalink / raw)
To: fuse-devel, virtualization; +Cc: Li Wang, German Maglione, Stefan Hajnoczi
generic_shutdown_super() clears SB_ACTIVE before calling evict_inodes(),
so fuse_evict_inode() skipped both the FUSE_FORGET for fi->nlookup and
fuse_cleanup_submount_lookup() for every remaining inode.
For a full unmount that is mostly fine: FUSE_DESTROY has already told the
server to drop everything. But a submount unmount takes the same path
with the connection still alive: fuse_mount_remove() returns false, so
fuse_conn_destroy() is not called and no FUSE_DESTROY is sent. The
server then keeps the lookup count of every inode of the submount for the
lifetime of the connection, which can be arbitrarily long if the parent
mount stays around and submounts come and go.
fuse_submount_lookup is worse, because it is freed nowhere else: the
object and its embedded forget are leaked on any unmount, including a
full one, for every inode that has one.
Queue both regardless of SB_ACTIVE. On a full unmount, and on an aborted
connection, fuse_conn_destroy() has disconnected the input queue before
inodes are evicted, so both fuse_dev_queue_forget() and
virtio_fs_send_forget() just free the link; fc->chan stays valid until
fuse_free_conn(), well after evict_inodes().
A failed mount is different: sb->s_root is NULL, so fuse_sb_destroy()
never calls fuse_conn_destroy() and the input queue stays connected.
Anything queued on it would be leaked, as the forget list is drained
only by fuse_chan_abort(). Nothing is queued there, though: the only
inode such a mount evicts is the root, which has no submount lookup and,
since commit d34e012c92a4 ("fuse: don't take a lookup count on the root
inode"), no lookup count either. That commit is a prerequisite for this
one.
Fixes: c4d361f66ac9 ("fuse: share lookup state between submount and its parent")
Cc: <stable@vger.kernel.org> # 8ebc672894c3: fuse: don't take a lookup count on the root inode
Cc: <stable@vger.kernel.org>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
fs/fuse/inode.c | 34 +++++++++++++++++++++++-----------
1 file changed, 23 insertions(+), 11 deletions(-)
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 7849cbbdcab6..a69d6a7701ac 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -141,6 +141,7 @@ static void fuse_cleanup_submount_lookup(struct fuse_conn *fc,
static void fuse_evict_inode(struct inode *inode)
{
struct fuse_inode *fi = get_fuse_inode(inode);
+ struct fuse_conn *fc = get_fuse_conn(inode);
/* Will write inode on close/munmap and in all other dirtiers */
WARN_ON(inode_state_read_once(inode) & I_DIRTY_INODE);
@@ -157,19 +158,30 @@ static void fuse_evict_inode(struct inode *inode)
*/
if (FUSE_IS_VDAX(inode))
fuse_vdax_inode_cleanup(inode);
- if (inode->i_sb->s_flags & SB_ACTIVE) {
- struct fuse_conn *fc = get_fuse_conn(inode);
+ /*
+ * Must be done unconditionally as well: on a submount unmount the
+ * connection stays alive and no FUSE_DESTROY is sent, so without
+ * this the server keeps the lookup counts of every inode in the
+ * submount for the lifetime of the connection. The
+ * fuse_submount_lookup object is freed nowhere else, so skipping it
+ * leaks that too. On a full unmount or an aborted connection the
+ * input queue is already disconnected, so fuse_chan_queue_forget()
+ * just frees the forget. A failed mount does not disconnect the
+ * queue, but the only inode it evicts is the root, which carries
+ * neither a lookup count nor a submount lookup.
+ */
+ if (fi->nlookup) {
+ fuse_chan_queue_forget(fc->chan, fi->forget, fi->nodeid,
+ fi->nlookup);
+ fi->forget = NULL;
+ }
- if (fi->nlookup) {
- fuse_chan_queue_forget(fc->chan, fi->forget, fi->nodeid,
- fi->nlookup);
- fi->forget = NULL;
- }
+ if (fi->submount_lookup) {
+ fuse_cleanup_submount_lookup(fc, fi->submount_lookup);
+ fi->submount_lookup = NULL;
+ }
- if (fi->submount_lookup) {
- fuse_cleanup_submount_lookup(fc, fi->submount_lookup);
- fi->submount_lookup = NULL;
- }
+ if (inode->i_sb->s_flags & SB_ACTIVE) {
/*
* Evict of non-deleted inode may race with outstanding
* LOOKUP/READDIRPLUS requests and result in inconsistency when
--
2.56.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v3 5/5] virtiofs: fix forget leak on submount unmount
2026-12-01 10:58 ` [PATCH v3 5/5] virtiofs: fix forget leak on submount unmount Miklos Szeredi
@ 2026-12-01 13:23 ` Li Wang
2026-12-01 15:18 ` German Maglione
1 sibling, 0 replies; 14+ messages in thread
From: Li Wang @ 2026-12-01 13:23 UTC (permalink / raw)
To: Miklos Szeredi, fuse-devel, virtualization
Cc: German Maglione, Stefan Hajnoczi
Hi Miklos,
On 01/12/2026 18:58, Miklos Szeredi wrote:
> generic_shutdown_super() clears SB_ACTIVE before calling evict_inodes(),
> so fuse_evict_inode() skipped both the FUSE_FORGET for fi->nlookup and
> fuse_cleanup_submount_lookup() for every remaining inode.
>
> For a full unmount that is mostly fine: FUSE_DESTROY has already told the
> server to drop everything. But a submount unmount takes the same path
> with the connection still alive: fuse_mount_remove() returns false, so
> fuse_conn_destroy() is not called and no FUSE_DESTROY is sent. The
> server then keeps the lookup count of every inode of the submount for the
> lifetime of the connection, which can be arbitrarily long if the parent
> mount stays around and submounts come and go.
>
> fuse_submount_lookup is worse, because it is freed nowhere else: the
> object and its embedded forget are leaked on any unmount, including a
> full one, for every inode that has one.
>
> Queue both regardless of SB_ACTIVE. On a full unmount, and on an aborted
> connection, fuse_conn_destroy() has disconnected the input queue before
> inodes are evicted, so both fuse_dev_queue_forget() and
> virtio_fs_send_forget() just free the link; fc->chan stays valid until
> fuse_free_conn(), well after evict_inodes().
>
> A failed mount is different: sb->s_root is NULL, so fuse_sb_destroy()
> never calls fuse_conn_destroy() and the input queue stays connected.
> Anything queued on it would be leaked, as the forget list is drained
> only by fuse_chan_abort(). Nothing is queued there, though: the only
> inode such a mount evicts is the root, which has no submount lookup and,
> since commit d34e012c92a4 ("fuse: don't take a lookup count on the root
> inode"), no lookup count either. That commit is a prerequisite for this
> one.
>
> Fixes: c4d361f66ac9 ("fuse: share lookup state between submount and its parent")
> Cc: <stable@vger.kernel.org> # 8ebc672894c3: fuse: don't take a lookup count on the root inode
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
> ---
> fs/fuse/inode.c | 34 +++++++++++++++++++++++-----------
> 1 file changed, 23 insertions(+), 11 deletions(-)
>
It looks like this patch touches generic FUSE submount logic rather than
virtiofs-specific code. Since virtiofs enables auto_submounts=true by default,
it benefits here, and in principle any FUSE server advertising submounts could benefit
as well. Perhaps we could change the commit title prefix to fuse.
Reviewed-by: Li Wang <liwang@kylinos.cn>
Thanks,
Li Wang
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH v3 5/5] virtiofs: fix forget leak on submount unmount
2026-12-01 10:58 ` [PATCH v3 5/5] virtiofs: fix forget leak on submount unmount Miklos Szeredi
2026-12-01 13:23 ` Li Wang
@ 2026-12-01 15:18 ` German Maglione
1 sibling, 0 replies; 14+ messages in thread
From: German Maglione @ 2026-12-01 15:18 UTC (permalink / raw)
To: Miklos Szeredi
Cc: fuse-devel, virtualization, Li Wang, German Maglione,
Stefan Hajnoczi
On Tue, 01 Dec 2026 11:58:53 +0100, Miklos Szeredi <mszeredi@redhat.com> wrote:
> generic_shutdown_super() clears SB_ACTIVE before calling evict_inodes(),
> so fuse_evict_inode() skipped both the FUSE_FORGET for fi->nlookup and
> fuse_cleanup_submount_lookup() for every remaining inode.
>
> For a full unmount that is mostly fine: FUSE_DESTROY has already told the
> server to drop everything. But a submount unmount takes the same path
> with the connection still alive: fuse_mount_remove() returns false, so
> fuse_conn_destroy() is not called and no FUSE_DESTROY is sent. The
> server then keeps the lookup count of every inode of the submount for the
> lifetime of the connection, which can be arbitrarily long if the parent
> mount stays around and submounts come and go.
>
> [...]
Reviewed-by: German Maglione <gmaglione@redhat.com>
--
German Maglione <gmaglione@redhat.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 1/5] virtiofs: fix DAX range leak on unmount
2026-12-01 10:58 [PATCH v3 1/5] virtiofs: fix DAX range leak on unmount Miklos Szeredi
` (3 preceding siblings ...)
2026-12-01 10:58 ` [PATCH v3 5/5] virtiofs: fix forget leak on submount unmount Miklos Szeredi
@ 2026-12-01 11:11 ` sashiko-bot
2026-12-01 15:18 ` German Maglione
5 siblings, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-12-01 11:11 UTC (permalink / raw)
To: Miklos Szeredi, virtualization; +Cc: Michael S. Tsirkin, Eugenio Perez
Sashiko has finished reviewing this 5-patch series:
- Patches 1, 2, 4, and 5: no issues found.
- Patch 3 ("virtiofs: retry request submission from the worker o..."): 1
potential issue (1 Low)
A detailed review has been sent as a separate reply to patch 3.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201105855.430993-1-mszeredi@redhat.com
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH v3 1/5] virtiofs: fix DAX range leak on unmount
2026-12-01 10:58 [PATCH v3 1/5] virtiofs: fix DAX range leak on unmount Miklos Szeredi
` (4 preceding siblings ...)
2026-12-01 11:11 ` [PATCH v3 1/5] virtiofs: fix DAX range leak on unmount sashiko-bot
@ 2026-12-01 15:18 ` German Maglione
5 siblings, 0 replies; 14+ messages in thread
From: German Maglione @ 2026-12-01 15:18 UTC (permalink / raw)
To: Miklos Szeredi
Cc: fuse-devel, virtualization, Li Wang, German Maglione,
Stefan Hajnoczi
On Tue, 01 Dec 2026 11:58:49 +0100, Miklos Szeredi <mszeredi@redhat.com> wrote:
> generic_shutdown_super() clears SB_ACTIVE before calling evict_inodes(),
> so at unmount time fuse_evict_inode() skipped fuse_vdax_inode_cleanup()
> for every remaining inode. The DAX ranges owned by those inodes stay on
> fc->vdax->busy_ranges instead of being returned to the free pool, and
> fuse_vdax_conn_free() only frees free_ranges before kfree()ing the
> connection, so the busy fuse_dax_mapping objects are leaked. Nothing
> warns about it: fuse_free_inode() kfree()s fi->vdax without checking
> that the interval tree is empty.
>
> [...]
Reviewed-by: German Maglione <gmaglione@redhat.com>
--
German Maglione <gmaglione@redhat.com>
^ permalink raw reply [flat|nested] 14+ messages in thread