From: Al Viro <viro@zeniv.linux.org.uk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-fsdevel@vger.kernel.org, Miklos Szeredi <miklos@szeredi.hu>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.com>,
Christoph Hellwig <hch@infradead.org>
Subject: Re: [RFC] MNT_WRITE_HOLD mess
Date: Sun, 6 Jul 2025 00:26:21 +0100 [thread overview]
Message-ID: <20250705232621.GA1880847@ZenIV> (raw)
In-Reply-To: <20250705185359.GZ1880847@ZenIV>
On Sat, Jul 05, 2025 at 07:53:59PM +0100, Al Viro wrote:
> On Sat, Jul 05, 2025 at 01:01:14AM +0100, Al Viro wrote:
>
> > FWIW, several observations around that thing:
> > * mnt_get_write_access(), vfs_create_mount() and clone_mnt()
> > definitely do not need to touch the seqcount component of mount_lock.
> > read_seqlock_excl() is enough there.
> > * AFAICS, the same goes for sb_prepare_remount_readonly(),
> > do_remount() and do_reconfigure_mnt() - no point bumping the seqcount
> > side of mount_lock there; only spinlock is needed.
> > * failure exit in mount_setattr_prepare() needs only clearing the
> > bit; smp_wmb() is pointless there (especially done for each mount involved).
>
> The following appears to work; writing docs now...
More fun questions in the area: is there any reason we have mnt_want_write()
doing
int mnt_want_write(struct vfsmount *m)
{
int ret;
sb_start_write(m->mnt_sb);
ret = mnt_get_write_access(m);
if (ret)
sb_end_write(m->mnt_sb);
return ret;
}
rather than
int mnt_want_write(struct vfsmount *m)
{
int ret = mnt_get_write_access(m);
if (!ret)
sb_start_write(m->mnt_sb);
return ret;
}
Note that mnt_want_write_file() on e.g. a regular file opened
for write will have sb_start_write() done with mnt_get_write_access()
already in place since open(2). So the nesting shouldn't be an issue
here... The same order (mount then superblock) is used for overlayfs
copyup, for that matter.
So if it's a matter of waiting for thaw with mount write
count already incremented, simple echo foo > pathname would already
demonstrate the same, no matter of which order mnt_want_write() uses.
What am I missing there?
IIRC, that was Jan's stuff... <checks git log> yep - eb04c28288bb
"fs: Add freezing handling to mnt_want_write() / mnt_drop_write()" is
where it came from...
next prev parent reply other threads:[~2025-07-05 23:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-04 19:44 [RFC] MNT_WRITE_HOLD mess Al Viro
2025-07-04 19:57 ` Linus Torvalds
2025-07-04 20:23 ` Al Viro
2025-07-05 0:01 ` Al Viro
2025-07-05 4:52 ` Miklos Szeredi
2025-07-05 5:57 ` Al Viro
2025-07-05 8:16 ` Al Viro
2025-07-05 18:53 ` Al Viro
2025-07-05 23:26 ` Al Viro [this message]
2025-07-07 10:26 ` Jan Kara
2025-07-06 1:26 ` [PATCH] fix a mount write count leak in ksmbd_vfs_kern_path_locked() (was Re: [RFC] MNT_WRITE_HOLD mess) Al Viro
2025-07-06 3:49 ` Namjae Jeon
2025-07-07 8:24 ` [RFC] MNT_WRITE_HOLD mess 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=20250705232621.GA1880847@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=brauner@kernel.org \
--cc=hch@infradead.org \
--cc=jack@suse.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=torvalds@linux-foundation.org \
/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