From: Luis Henriques <luis@igalia.com>
To: Jan Kara <jack@suse.cz>
Cc: Christian Brauner <brauner@kernel.org>,
linux-fsdevel@vger.kernel.org, Jeff Layton <jlayton@kernel.org>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Amir Goldstein <amir73il@gmail.com>,
Mateusz Guzik <mjguzik@gmail.com>
Subject: Re: [PATCH] fs: don't needlessly acquire f_lock
Date: Thu, 05 Jun 2025 08:35:42 +0100 [thread overview]
Message-ID: <87tt4u4p4h.fsf@igalia.com> (raw)
In-Reply-To: <3cmucyvaapaiucekac2xdpdatyti7jatbt2kugcmpgnwjdhae3@ywg4ied3mq6a> (Jan Kara's message of "Wed, 4 Jun 2025 11:53:40 +0200")
On Wed, Jun 04 2025, Jan Kara wrote:
> On Wed 04-06-25 10:33:13, Christian Brauner wrote:
>> On Tue, Jun 03, 2025 at 11:34:53AM +0200, Jan Kara wrote:
>> > On Mon 02-06-25 16:52:22, Luis Henriques wrote:
>> > > On Mon, Jun 02 2025, Luis Henriques wrote:
>> > > > Hi Christian,
>> > > >
>> > > > On Fri, Feb 07 2025, Christian Brauner wrote:
>> > > >
>> > > >> Before 2011 there was no meaningful synchronization between
>> > > >> read/readdir/write/seek. Only in commit
>> > > >> ef3d0fd27e90 ("vfs: do (nearly) lockless generic_file_llseek")
>> > > >> synchronization was added for SEEK_CUR by taking f_lock around
>> > > >> vfs_setpos().
>> > > >>
>> > > >> Then in 2014 full synchronization between read/readdir/write/seek was
>> > > >> added in commit 9c225f2655e3 ("vfs: atomic f_pos accesses as per POSIX")
>> > > >> by introducing f_pos_lock for regular files with FMODE_ATOMIC_POS and
>> > > >> for directories. At that point taking f_lock became unnecessary for such
>> > > >> files.
>> > > >>
>> > > >> So only acquire f_lock for SEEK_CUR if this isn't a file that would have
>> > > >> acquired f_pos_lock if necessary.
>> > > >
>> > > > I'm seeing the splat below with current master. It's unlikely to be
>> > > > related with this patch, but with recent overlayfs changes. I'm just
>> > > > dropping it here before looking, as maybe it has already been reported.
>> > >
>> > > OK, just to confirm that it looks like this is indeed due to this patch.
>> > > I can reproduce it easily, and I'm not sure why I haven't seen it before.
>> >
>> > Thanks for report! Curious. This is:
>> >
>> > VFS_WARN_ON_ONCE((file_count(file) > 1) &&
>> > !mutex_is_locked(&file->f_pos_lock));
>> >
>> > Based on the fact this is ld(1) I expect this is a regular file.
>> > Christian, cannot it happen that we race with dup2() so file_count is
>> > increased after we've checked it in fdget_pos() and before we get to this
>> > assert?
>>
>> Yes I somehow thought the two of us had already discussed this and
>> either concluded to change it or drop the assert. Maybe I forgot that?
>> I'll remove the assert.
>
> I don't remember discussing this particular assert, I think it was a
> different one of a similar kind :). Nevertheless I agree removing the
> assert here is the right thing to do, it doesn't make too much sense in
> this context.
Awesome, thanks for looking into this Jan and Christian.
Cheers,
--
Luís
next prev parent reply other threads:[~2025-06-05 7:35 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-07 14:10 [PATCH] fs: don't needlessly acquire f_lock Christian Brauner
2025-02-07 14:18 ` Matthew Wilcox
2025-02-07 15:50 ` Jan Kara
2025-02-07 16:42 ` Mateusz Guzik
2025-02-10 12:01 ` Christian Brauner
2025-02-10 14:58 ` Jan Kara
2025-02-13 15:10 ` Christian Brauner
2025-02-13 16:17 ` Jan Kara
2025-06-02 9:47 ` Luis Henriques
2025-06-02 15:52 ` Luis Henriques
2025-06-03 9:34 ` Jan Kara
2025-06-04 8:33 ` Christian Brauner
2025-06-04 9:53 ` Jan Kara
2025-06-05 7:35 ` Luis Henriques [this message]
2025-06-12 9:41 ` [PATCH] fs: drop assert in file_seek_cur_needs_f_lock Luis Henriques
2025-06-12 11:08 ` Jan Kara
2025-06-12 12:33 ` Christian Brauner
2025-06-12 13:55 ` Mateusz Guzik
2025-06-12 13:59 ` Mateusz Guzik
2025-06-12 16:23 ` Jan Kara
2025-06-12 18:07 ` Luis Henriques
2025-06-12 21:35 ` Mateusz Guzik
2025-06-13 10:05 ` Jan Kara
2025-06-13 10:11 ` [PATCH v2] " Luis Henriques
2025-06-13 10:35 ` Mateusz Guzik
2025-06-16 7:59 ` Christian Brauner
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=87tt4u4p4h.fsf@igalia.com \
--to=luis@igalia.com \
--cc=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=jlayton@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=mjguzik@gmail.com \
--cc=viro@zeniv.linux.org.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.