[PATCH v4 03/10] ntfs: propagate EA write and truncate errors
From: Baolin Liu
Date: Wed Sep 23 2026 - 02:08:01 EST
From: Baolin Liu <liubaolin@xxxxxxxxxx>
ntfs_write_ea() replaces negative write errors with EIO and ignores
errors when shrinking the attribute after writing a shorter list. This
can report success even though the final resize failed.
Preserve negative write errors, use EIO for short writes, and return
truncate failures to the caller.
Signed-off-by: Baolin Liu <liubaolin@xxxxxxxxxx>
Reviewed-by: Hyunchul Lee <hyc.lee@xxxxxxxxx>
---
fs/ntfs/ea.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/ntfs/ea.c b/fs/ntfs/ea.c
index 2ee700f8227e..98ca9e4f8d25 100644
--- a/fs/ntfs/ea.c
+++ b/fs/ntfs/ea.c
@@ -32,12 +32,12 @@ static int ntfs_write_ea(struct ntfs_inode *ni, __le32 type, char *value, s64 ea
written = ntfs_inode_attr_pwrite(ea_vi, ea_off, ea_size, value, false);
if (written != ea_size)
- err = -EIO;
+ err = written < 0 ? written : -EIO;
else {
struct ntfs_inode *ea_ni = NTFS_I(ea_vi);
if (need_truncate && ea_ni->data_size > ea_off + ea_size)
- ntfs_attr_truncate(ea_ni, ea_off + ea_size);
+ err = ntfs_attr_truncate(ea_ni, ea_off + ea_size);
mark_mft_record_dirty(ni);
}
--
2.51.0