Re: [PATCH 3/3] ntfs: capture mft mirror sync errors in ntfs_write_mft_block()

From: Hyunchul Lee

Date: Fri May 01 2026 - 09:05:48 EST


2026년 5월 1일 (금) 오전 2:21, DaeMyung Kang <charsyam@xxxxxxxxx>님이 작성:
>
> After ntfs_sync_mft_mirror() became able to return real I/O errors,
> ntfs_write_mft_block() still discards its return value at the call
> site inside the per-record loop. A failed $MFTMirr write therefore
> leaves the volume looking clean from the writeback path even though
> the on-disk mirror is now stale.
>
> Capture the return value and feed it into the function's existing
> @err variable using the same "first error wins" pattern already used
> on other failure paths. The error is propagated to the caller and,
> via the existing tail of the function, sets NVolErrors so umount and
> chkdsk see the volume as inconsistent.
>
> Fixes: 115380f9a2f9 ("ntfs: update mft operations")
> Signed-off-by: DaeMyung Kang <charsyam@xxxxxxxxx>

Looks good to me.

Reviewed-by: Hyunchul Lee <hyc.lee@xxxxxxxxx>


> ---
> fs/ntfs/mft.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c
> index 00f172fd1b21..866816f710b5 100644
> --- a/fs/ntfs/mft.c
> +++ b/fs/ntfs/mft.c
> @@ -2862,9 +2862,13 @@ static int ntfs_write_mft_block(struct folio *folio, struct writeback_control *w
> }
> prev_mft_ofs = mft_ofs;
>
> - if (mft_no < vol->mftmirr_size)
> - ntfs_sync_mft_mirror(vol, mft_no,
> + if (mft_no < vol->mftmirr_size) {
> + int sub_err = ntfs_sync_mft_mirror(vol, mft_no,
> (struct mft_record *)(kaddr + mft_ofs));
> +
> + if (unlikely(sub_err) && !err)
> + err = sub_err;
> + }
> } else if (ref_inos[nr_ref_inos])
> nr_ref_inos++;
> }
> --
> 2.43.0
>


--
Thanks,
Hyunchul