From: liubaolin <liubaolin12138@163.com>
To: Hongling Zeng <zhongling0719@126.com>,
Hongling Zeng <zenghongling@kylinos.cn>,
linkinjeon@kernel.org, hyc.lee@gmail.com
Cc: ntfs@lists.linux.dev, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH 1/2] ntfs: fix volume flag update races
Date: Fri, 4 Sep 2026 07:37:35 +0800 [thread overview]
Message-ID: <c43b2ea8-e80f-4f63-8b07-4c3f5b845edb@163.com> (raw)
In-Reply-To: <6A99158E.2040006@126.com>
在 2026/9/3 14:37, Hongling Zeng 写道:
> Thanks for the careful reading
>
> These two sites cannot actually race ntfs_sync_fs(): ntfs_reconfigure()
> (via do_remount()) and ntfs_put_super() (via generic_shutdown_super())
> both run with sb->s_umount
> held for write, while the sync(2)/syncfs(2) paths only take it for read
> through iterate_supers(). So the check and the clear inside
> ntfs_clear_volume_flags() are
> effectively a single non-interleavable pair with respect to sync — the
> window is not merely narrow but structurally closed.
>
> We deliberately keep ntfs_clear_volume_dirty_if_no_errors() for the
> paths that can genuinely race sync (currently only ntfs_sync_fs()
> itself), so converting these two would
> blur that line rather than improve consistency.
Hi Hongling,
Thank you for the explanation.
However, I believe we may be discussing different races.
Your explanation addresses why ntfs_reconfigure()/ntfs_put_super()
cannot run concurrently with ntfs_sync_fs().
My concern is whether these paths can race with an NTFS writer/error
path while checking NVolErrors(vol) and clearing VOLUME_IS_DIRTY.
For ntfs_put_super(), I agree that no change is needed.
It runs only during the final filesystem shutdown, when ordinary
userspace writers and related I/O can no longer run concurrently with it.
For a normal read-only remount, reconfigure_super() calls
sb_prepare_remount_readonly(). This blocks new mount writers and checks
for existing writers; if writers are present, the remount does not
proceed. Therefore, the normal remount-ro path does not have the
concurrency issue I was concerned about.
However, an emergency/forced remount uses SB_FORCE and skips
sb_prepare_remount_readonly(), calling only sb_start_ro_state_change().
This does not wait for writers that have already entered the filesystem.
Such writers use sb->s_writers and do not need to acquire s_umount.
The following sequence is therefore possible:
NTFS writer forced remount
----------- -------------
file_start_write()
Enter the NTFS write path
Set or prepare to set VOLUME_IS_DIRTY
Pause
Acquire s_umount for writing
SB_FORCE
sb_start_ro_state_change()
ntfs_reconfigure()
sync_filesystem()
NVolErrors() == false
Clear VOLUME_IS_DIRTY
Set SB_RDONLY
Resume the writer
Continue modifying metadata
An error occurs
NVolSetErrors(vol)
The final state may be:
NVolErrors(vol) == true
VOLUME_IS_DIRTY == false
Therefore, the s_umount locking relationship only rules out
concurrency with ntfs_sync_fs(); it does not rule out concurrency
between a forced/emergency remount and an NTFS writer that is already in
progress.
Please consider whether this case also needs to be handled. If you
agree with my analysis, I suggest adding a follow-up patch to address
this race.
This is my current understanding of the issue. I welcome further
discussion, and please feel free to correct me if any part of my
analysis is inaccurate.
Thanks,
Baolin.
prev parent reply other threads:[~2026-09-03 23:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 1:21 Hongling Zeng
2026-09-03 1:21 ` [PATCH 2/2] ntfs: add helper to record error flag before setting volume dirty bit Hongling Zeng
2026-09-03 3:01 ` [PATCH 1/2] ntfs: fix volume flag update races liubaolin
2026-09-03 6:37 ` Hongling Zeng
2026-09-03 23:37 ` liubaolin [this message]
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=c43b2ea8-e80f-4f63-8b07-4c3f5b845edb@163.com \
--to=liubaolin12138@163.com \
--cc=hyc.lee@gmail.com \
--cc=linkinjeon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ntfs@lists.linux.dev \
--cc=stable@vger.kernel.org \
--cc=zenghongling@kylinos.cn \
--cc=zhongling0719@126.com \
/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
all inboxes | Powered by JetHome®