From: Horst Birthelmer <horst@birthelmer.de>
To: Joanne Koong <joannelkoong@gmail.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
Bernd Schubert <bernd@bsbernd.com>,
Christian Brauner <brauner@kernel.org>,
Horst Birthelmer <horst@birthelmer.com>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Horst Birthelmer <hbirthelmer@ddn.com>
Subject: Re: Re: Re: Re: [PATCH] fuse: fix inode initialization race
Date: Thu, 26 Mar 2026 19:11:13 +0100 [thread overview]
Message-ID: <acV14YU0dZqARY_Y@fedora> (raw)
In-Reply-To: <CAJnrk1ax2bK-FQXDEc=OGvYS7YvCvL3YsKWv1gmzwkS_QSz+fw@mail.gmail.com>
On Thu, Mar 26, 2026 at 11:00:54AM -0700, Joanne Koong wrote:
> On Thu, Mar 26, 2026 at 10:54 AM Horst Birthelmer <horst@birthelmer.de> wrote:
> >
> > On Thu, Mar 26, 2026 at 09:43:00AM -0700, Joanne Koong wrote:
> > > On Thu, Mar 26, 2026 at 8:48 AM Horst Birthelmer <horst@birthelmer.de> wrote:
> > > >
> > > > On Thu, Mar 26, 2026 at 04:19:24PM +0100, Miklos Szeredi wrote:
> > > > > On Thu, 26 Mar 2026 at 16:13, Bernd Schubert <bernd@bsbernd.com> wrote:
> > > > > >
> > > > > >
> > > > > >
> > > > > > 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>
> > > > >
> > > > > > >>> 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?
> > > > >
> > > > > Right, should only wake if fi->attr_version old value was zero.
> > > > >
> > > > > BTW I have a hunch that there are better solutions, but it's simple
> > > > > enough as a stopgap measure.
> > > >
> > > > OK, I'll send a new version.
> > > >
> > > > Just out of curiosity, what would be a better solution?
> > >
> > > I'm probably missing something here but why can't we just call the
> > >
> > > fi = get_fuse_inode(inode);
> > > spin_lock(&fi->lock);
> > > fi->nlookup++;
> > > spin_unlock(&fi->lock);
> > > fuse_change_attributes_i(inode, attr, NULL, attr_valid, attr_version,
> > > evict_ctr);
> > >
> > > logic before releasing the inode lock (the unlock_new_inode() call) in
> > > fuse_iget() to address the race? unlock_new_inode() clears I_NEW so
> > > fuse_reverse_inval_inode()'s fuse_ilookup() would only get the inode
> > > after the attributes initialization has finished.
> > >
> > > As I understand it, fuse_change_attributes_i() would be pretty
> > > straightforward / fast for I_NEW inodes, as it doesn't send any
> > > synchronous requests and for the I_NEW case the
> > > invalidate_inode_pages2() and truncate_pagecache() calls would get
> > > skipped. (truncate_pagecache() getting skipped because inode->i_size
> > > is already attr->size from fuse_init_inode(), so "oldsize !=
> > > attr->size" is never true; and invalidate_inode_pages2() getting
> > > skipped because "oldsize != attr->size" is never true and "if
> > > (!timespec64_equal(&old_mtime, &new_mtime))" is never true because
> > > fuse_init_inode() initialized the inode's mtime to attr->mtime).
> >
> > You understand the pretty well, I think.
> > The problem I have there is that fuse_change_attributes_i() takes
> > its own lock.
> > That would be a pretty big operation to split that function.
>
> I believe fuse_change_attribtues_i() takes the fi lock, not the inode
> lock, so this should be fine.
>
Yes, I got confused there, sorry.
Still, a pretty big change for a corner case. Don't you think?
What would be the advantage to the current situation with the requested
changes from Miklos and Bernd, of course? So that we only do the
wakeup_all() call only if we have initialized a new inode?
> Thanks,
> Joanne
> >
> > Is that required for this small (as Miklos put it, rare) case?
> >
> > If you guys want me to do that, I will.
> >
> > Thanks,
> > Horst
next prev parent reply other threads:[~2026-03-26 18:11 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
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 [this message]
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=acV14YU0dZqARY_Y@fedora \
--to=horst@birthelmer.de \
--cc=bernd@bsbernd.com \
--cc=brauner@kernel.org \
--cc=hbirthelmer@ddn.com \
--cc=horst@birthelmer.com \
--cc=joannelkoong@gmail.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