From: Baolin Liu <liubaolin12138@163.com>
To: linkinjeon@kernel.org, hyc.lee@gmail.com
Cc: ntfs@lists.linux.dev, linux-kernel@vger.kernel.org,
Baolin Liu <liubaolin@kylinos.cn>
Subject: [PATCH v3 5/6] ntfs: report MFT writeback errors to fsnotify
Date: Thu, 24 Sep 2026 17:01:01 +0800 [thread overview]
Message-ID: <20260924090102.2865942-6-liubaolin12138@163.com> (raw)
In-Reply-To: <20260924090102.2865942-1-liubaolin12138@163.com>
From: Baolin Liu <liubaolin@kylinos.cn>
MFT writeback failures need to reach filesystem health monitors as well
as the kernel log and mapping error state.
Report device errors from the existing parent BIO completion callback for
both synchronous and asynchronous writes, before ending folio writeback.
The generic fserror code queues notification work and takes its own inode
reference, so no additional NTFS completion work is needed.
Report mirror and preparation failures where they are detected, including
failures that occur before a BIO can be submitted. Keep these reports
together with completion reporting so errors retained in the write context
still mark the volume and notify userspace independently of device errors.
Preserve the retry handling for allocation failures in MFT write
preparation.
Signed-off-by: Baolin Liu <liubaolin@kylinos.cn>
---
fs/ntfs/mft.c | 34 ++++++++++++++++++++++++----------
1 file changed, 24 insertions(+), 10 deletions(-)
diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c
index a1b1c080b256..6a202ffc513a 100644
--- a/fs/ntfs/mft.c
+++ b/fs/ntfs/mft.c
@@ -481,9 +481,11 @@ static void ntfs_mft_end_io(struct bio *bio)
err = blk_status_to_errno(bio->bi_status);
else
err = ctx->error;
+ /* Report device errors from both synchronous and asynchronous writes. */
+ if (bio->bi_status)
+ ntfs_report_file_metadata_error(ctx->mapping->host, err);
if (err) {
mapping_set_error(ctx->mapping, err);
- NVolSetErrors(ctx->vol);
ntfs_error(ctx->vol->sb, "I/O error while writing MFT: %d",
err);
}
@@ -544,22 +546,24 @@ static int ntfs_sync_mft_mirror_unit(struct ntfs_volume *vol,
u64 mirror_size;
unsigned int mirror_ofs;
u8 *src, *dst;
- int err;
+ int err = -EIO;
if (unlikely(!vol->mftmirr_ino))
- return -EIO;
+ goto out_report;
mirror_size = (u64)vol->mftmirr_size * vol->mft_record_size;
if (mirror_file_ofs >= mirror_size ||
unit->len > mirror_size - mirror_file_ofs)
- return -EIO;
+ goto out_report;
if (unit->folio_ofs + unit->len > folio_size(source))
- return -EIO;
+ goto out_report;
mirror = read_mapping_folio(vol->mftmirr_ino->i_mapping,
mirror_file_ofs >> PAGE_SHIFT, NULL);
- if (IS_ERR(mirror))
- return PTR_ERR(mirror);
+ if (IS_ERR(mirror)) {
+ err = PTR_ERR(mirror);
+ goto out_report;
+ }
folio_lock(mirror);
if (folio_test_writeback(mirror))
@@ -598,6 +602,9 @@ static int ntfs_sync_mft_mirror_unit(struct ntfs_volume *vol,
out_unlock:
folio_unlock(mirror);
folio_put(mirror);
+out_report:
+ if (err)
+ ntfs_report_metadata_error(vol, err);
return err;
}
@@ -815,8 +822,14 @@ int write_mft_record_nolock(struct ntfs_inode *ni, struct mft_record *m, int syn
mark_mft_record_dirty(ni);
if (!sync)
err = 0;
- } else
- NVolSetErrors(vol);
+ } else {
+ struct ntfs_inode *base_ni = ni;
+
+ if (ni->nr_extents < 0)
+ base_ni = ni->ext.base_ntfs_ino;
+ mapping_set_error(folio->mapping, err);
+ ntfs_report_file_metadata_error(VFS_I(base_ni), err);
+ }
return err;
}
@@ -3188,7 +3201,7 @@ static void ntfs_mft_write_error(struct ntfs_volume *vol,
struct address_space *mapping, int err)
{
mapping_set_error(mapping, err);
- NVolSetErrors(vol);
+ ntfs_report_file_metadata_error(mapping->host, err);
ntfs_error(vol->sb, "Error while writing MFT folio: %d", err);
}
@@ -3346,6 +3359,7 @@ static int ntfs_write_mft_block(struct folio *folio, struct writeback_control *w
ctx->error = -EIO;
redirty = true;
err = -EIO;
+ ntfs_mft_write_error(vol, mapping, err);
break;
}
}
--
2.51.0
next prev parent reply other threads:[~2026-09-24 9:01 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 9:00 [PATCH v3 0/6] ntfs: report filesystem errors through fsnotify Baolin Liu
2026-09-24 9:00 ` [PATCH v3 1/6] ntfs: report allocation metadata errors to fsnotify Baolin Liu
2026-09-24 9:00 ` [PATCH v3 2/6] ntfs: report attribute " Baolin Liu
2026-09-24 9:00 ` [PATCH v3 3/6] ntfs: report inode metadata " Baolin Liu
2026-09-24 9:01 ` [PATCH v3 4/6] ntfs: report MFT metadata and recovery " Baolin Liu
2026-09-26 0:36 ` Hyunchul Lee
2026-09-26 12:43 ` liubaolin
2026-09-24 9:01 ` Baolin Liu [this message]
2026-09-24 9:01 ` [PATCH v3 6/6] ntfs: report shutdown " Baolin Liu
2026-09-26 0:40 ` Hyunchul Lee
2026-09-26 12:52 ` liubaolin
2026-09-26 0:33 ` [PATCH v3 0/6] ntfs: report filesystem errors through fsnotify Hyunchul Lee
2026-09-26 13:49 ` liubaolin
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=20260924090102.2865942-6-liubaolin12138@163.com \
--to=liubaolin12138@163.com \
--cc=hyc.lee@gmail.com \
--cc=linkinjeon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liubaolin@kylinos.cn \
--cc=ntfs@lists.linux.dev \
/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®