From: Bernd Schubert <bernd@bsbernd.com>
To: Christian Brauner <brauner@kernel.org>
Cc: Horst Birthelmer <horst@birthelmer.com>,
Miklos Szeredi <miklos@szeredi.hu>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Horst Birthelmer <hbirthelmer@ddn.com>
Subject: Re: [PATCH] fuse: fix inode initialization race
Date: Thu, 26 Mar 2026 16:13:00 +0100 [thread overview]
Message-ID: <b53e0176-6575-4ec7-bf44-8dea9fc8121e@bsbernd.com> (raw)
In-Reply-To: <20260326-reorganisation-bemessen-c6643edcf629@brauner>
On 3/26/26 15:26, Christian Brauner wrote:
> On Wed, Mar 25, 2026 at 08:54:57AM +0100, Bernd Schubert wrote:
>>
>>
>> On 3/18/26 14:43, Horst Birthelmer wrote:
>>> From: Horst Birthelmer <hbirthelmer@ddn.com>
>>>
>>> Fix a race between fuse_iget() and fuse_reverse_inval_inode() where
>>> invalidation can arrive while an inode is being initialized, causing
>>> the invalidation to be lost.
>>>
>>> Add a waitqueue to make fuse_reverse_inval_inode() wait when it
>>> encounters an inode with attr_version == 0 (still initializing).
>>> When fuse_change_attributes_common() completes initialization, it
>>> wakes waiting threads.
>>>
>>> This ensures invalidations are properly serialized with inode
>>> initialization, maintaining cache coherency.
>>>
>>> Signed-off-by: Horst Birthelmer <hbirthelmer@ddn.com>
>>> ---
>>> fs/fuse/fuse_i.h | 3 +++
>>> fs/fuse/inode.c | 8 ++++++++
>>> 2 files changed, 11 insertions(+)
>>>
>>> diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
>>> index 7f16049387d15e869db4be23a93605098588eda9..1be611472eee276371b3bde1a55257c1116cfedd 100644
>>> --- a/fs/fuse/fuse_i.h
>>> +++ b/fs/fuse/fuse_i.h
>>> @@ -945,6 +945,9 @@ struct fuse_conn {
>>> /** Version counter for attribute changes */
>>> atomic64_t attr_version;
>>>
>>> + /** Waitqueue for attr_version initialization */
>>> + wait_queue_head_t attr_version_waitq;
>>> +
>>> /** Version counter for evict inode */
>>> atomic64_t evict_ctr;
>>>
>>> diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
>>> index e57b8af06be93ecc29c58864a9c9e99c68e3283b..c6e7e50d80c0edaea57d9342869eaf811786e342 100644
>>> --- a/fs/fuse/inode.c
>>> +++ b/fs/fuse/inode.c
>>> @@ -246,6 +246,7 @@ void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr,
>>> set_mask_bits(&fi->inval_mask, STATX_BASIC_STATS, 0);
>>>
>>> fi->attr_version = atomic64_inc_return(&fc->attr_version);
>>> + wake_up_all(&fc->attr_version_waitq);
>>> fi->i_time = attr_valid;
While I'm looking at this again, wouldn't it make sense to make this
conditional? Because we wake this queue on every attr change for every
inode. And the conditional in fuse_iget() based on I_NEW?
Thanks,
Bernd
next prev parent reply other threads:[~2026-03-26 15:13 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-18 13:43 [PATCH] fuse: fix inode initialization race Horst Birthelmer
2026-03-25 7:54 ` Bernd Schubert
2026-03-26 14:26 ` Christian Brauner
2026-03-26 15:13 ` Bernd Schubert [this message]
2026-03-26 15:19 ` Miklos Szeredi
2026-03-26 15:45 ` Horst Birthelmer
2026-03-26 16:43 ` Joanne Koong
2026-03-26 17:54 ` Horst Birthelmer
2026-03-26 18:00 ` Joanne Koong
2026-03-26 18:11 ` Horst Birthelmer
2026-03-26 18:37 ` Joanne Koong
2026-03-26 18:16 ` Bernd Schubert
2026-03-26 19:00 ` Joanne Koong
2026-03-26 19:14 ` Bernd Schubert
2026-03-26 14:51 ` Miklos Szeredi
2026-03-26 14:56 ` Horst Birthelmer
2026-03-26 15:06 ` 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=b53e0176-6575-4ec7-bf44-8dea9fc8121e@bsbernd.com \
--to=bernd@bsbernd.com \
--cc=brauner@kernel.org \
--cc=hbirthelmer@ddn.com \
--cc=horst@birthelmer.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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