mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: liubaolin <liubaolin12138@163.com>
To: Hongling Zeng <zenghongling@kylinos.cn>,
	linkinjeon@kernel.org, hyc.lee@gmail.com
Cc: ntfs@lists.linux.dev, linux-kernel@vger.kernel.org,
	zhongling0719@126.com, stable@vger.kernel.org
Subject: Re: [PATCH v13 7/7] ntfs: fail remount on sync errors and keep the dirty bit on SB_FORCE
Date: Thu, 17 Sep 2026 05:18:35 +0800	[thread overview]
Message-ID: <3e9cb05c-8790-4ccb-a435-2013c474b06a@163.com> (raw)
In-Reply-To: <20260915083252.812126-8-zenghongling@kylinos.cn>



在 2026/9/15 16:32, Hongling Zeng 写道:
> ntfs_reconfigure() currently ignores sync_filesystem() errors, allowing
> a regular read-only remount to succeed even when dirty data was not
> synced. Check the error and fail regular remounts, leaving the
> superblock read-write so ntfs_put_super() can retry at unmount.
> 
> SB_FORCE does not wait for writers already in progress, so it must not
> clear the on-disk dirty bit. Warn and continue on sync errors for
> SB_FORCE. A forced remount updates the dirty state only when errors
> have been recorded, and never clears the dirty bit. Skip the commit if
> that state update fails, since the in-memory flags may be inconsistent.
> 
> Reported-by: Hyunchul Lee <hyc.lee@gmail.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
> ---
>   fs/ntfs/super.c | 27 +++++++++++++++++++++------
>   1 file changed, 21 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
> index 0228d7429596..82b5bf28b6ab 100644
> --- a/fs/ntfs/super.c
> +++ b/fs/ntfs/super.c
> @@ -272,7 +272,13 @@ static int ntfs_reconfigure(struct fs_context *fc)
>   
>   	ntfs_debug("Entering with remount");
>   
> -	sync_filesystem(sb);
> +	err = sync_filesystem(sb);
> +	if (err) {
> +		ntfs_warning(sb, "Failed to sync the filesystem.");
> +		/* A forced remount must still turn the superblock read-only. */
> +		if (!(fc->sb_flags & SB_FORCE))
> +			return err;
> +	}
>   
>   	/*
>   	 * For the read-write compiled driver, if we are remounting read-write,
> @@ -329,11 +335,20 @@ static int ntfs_reconfigure(struct fs_context *fc)
>   		 * or flush fails the remount, leaving the superblock
>   		 * read-write so ntfs_put_super() retries at unmount.
>   		 */
> -		err = ntfs_sync_volume_dirty_state(vol);
> -		if (err) {
> -			ntfs_warning(sb,
> -				"Failed to update dirty bit in volume information flags.  Run chkdsk.");
> -			return err;
> +		/*
> +		 * A forced remount does not drain writers in progress,
> +		 * so one may still be modifying metadata when the flags
> +		 * are committed: never clear the dirty bit then; if
> +		 * errors have been recorded, the update preserves or
> +		 * sets it; otherwise, skip the update entirely.
> +		 */
> +		if (!(fc->sb_flags & SB_FORCE) || NVolErrors(vol)) {
> +			err = ntfs_sync_volume_dirty_state(vol);
> +			if (err) {
> +				ntfs_warning(sb,
> +					"Failed to update dirty bit in volume information flags.  Run chkdsk.");
> +				return err;
> +			}
>   		}
>   		if (NInoDirty(NTFS_I(vol->vol_ino))) {
>   			/* ntfs_commit_inode() would discard the error. */

Looks good to me.

Reviewed-by: Baolin Liu <liubaolin@kylinos.cn>


  reply	other threads:[~2026-09-16 21:19 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-15  8:32 [PATCH v13 0/7] ntfs: fix volume flag races and persist the recorded error state Hongling Zeng
2026-09-15  8:32 ` [PATCH v13 1/7] ntfs: fix volume flag update races Hongling Zeng
2026-09-16 20:23   ` liubaolin
2026-09-15  8:32 ` [PATCH v13 2/7] ntfs: set the volume dirty bit unconditionally on metadata changes Hongling Zeng
2026-09-16 20:23   ` liubaolin
2026-09-15  8:32 ` [PATCH v13 3/7] ntfs: sync the volume dirty bit with the recorded error state Hongling Zeng
2026-09-16 20:23   ` liubaolin
2026-09-16 21:17   ` liubaolin
2026-09-15  8:32 ` [PATCH v13 4/7] ntfs: persist the dirty state after the final put_super() commits Hongling Zeng
2026-09-16 21:18   ` liubaolin
2026-09-15  8:32 ` [PATCH v13 5/7] ntfs: do not clear the volume dirty bit during sync Hongling Zeng
2026-09-16 21:18   ` liubaolin
2026-09-15  8:32 ` [PATCH v13 6/7] ntfs: check the dirty-state commit on remount and unmount Hongling Zeng
2026-09-16 21:18   ` liubaolin
2026-09-15  8:32 ` [PATCH v13 7/7] ntfs: fail remount on sync errors and keep the dirty bit on SB_FORCE Hongling Zeng
2026-09-16 21:18   ` liubaolin [this message]
2026-09-16  0:42 ` [PATCH v13 0/7] ntfs: fix volume flag races and persist the recorded error state Hyunchul Lee
2026-09-16 21:36 ` liubaolin
2026-09-16 23:36 ` Namjae Jeon

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=3e9cb05c-8790-4ccb-a435-2013c474b06a@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®