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 v3 4/5] fuse: don't take a lookup count on the root inode
Date: Tue, 1 Dec 2026 11:58:52 +0100 [thread overview]
Message-ID: <20261201105855.430993-4-mszeredi@redhat.com> (raw)
In-Reply-To: <20261201105855.430993-1-mszeredi@redhat.com>
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
next prev parent reply other threads:[~2026-12-01 10:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
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 15:18 ` German Maglione
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
2026-12-01 10:58 ` Miklos Szeredi [this message]
2026-12-01 15:18 ` [PATCH v3 4/5] fuse: don't take a lookup count on the root inode 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
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
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=20261201105855.430993-4-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