[PATCH v2] ntfs: leave HasEA flag untouched on setxattr failure

Baolin Liu posted 1 patch 1 month ago
fs/ntfs/ea.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
[PATCH v2] ntfs: leave HasEA flag untouched on setxattr failure
Posted by Baolin Liu 1 month ago
From: Baolin Liu <liubaolin@kylinos.cn>

In ntfs_set_ea(), the exit path unconditionally updates the HasEA
flag based on ea_info_qsize. When an error occurs before
ea_info_qsize is updated, NInoClearHasEA() hides existing on-disk
EAs until the inode is evicted.

Only update the flag on success.

Fixes: fc053f05ca28 ("ntfs: add reparse and ea operations")
Signed-off-by: Baolin Liu <liubaolin@kylinos.cn>
---
v1 was posted as "[PATCH v1 2/9] ntfs: fail EA update when reading
$EA_INFORMATION fails" in the "ntfs: assorted error path fixes" series.

Changes in v2:
 - Rebased on ntfs-next.
 - Dropped the -EIO return for a failed $EA_INFORMATION read, which is
   already handled on ntfs-next by 56cc42a7b387 ("ntfs: return errors
   from ntfs_attr_readall"). Only the HasEA flag part remains.
 - Updated the subject to match the remaining change.

 fs/ntfs/ea.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/ntfs/ea.c b/fs/ntfs/ea.c
index 9f0222c172d9..33ef4f4b439c 100644
--- a/fs/ntfs/ea.c
+++ b/fs/ntfs/ea.c
@@ -404,10 +404,12 @@ static int ntfs_set_ea(struct inode *inode, const char *name, size_t name_len,
 		*packed_ea_size = p_ea_info->ea_length;
 	mark_mft_record_dirty(ni);
 out:
-	if (ea_info_qsize > 0)
-		NInoSetHasEA(ni);
-	else
-		NInoClearHasEA(ni);
+	if (!err) {
+		if (ea_info_qsize > 0)
+			NInoSetHasEA(ni);
+		else
+			NInoClearHasEA(ni);
+	}
 
 	kvfree(ea_buf);
 	kvfree(old_ea_buf);
-- 
2.51.0
Re: [PATCH v2] ntfs: leave HasEA flag untouched on setxattr failure
Posted by Namjae Jeon 1 month ago
On Thu, Aug 27, 2026 at 3:43 PM Baolin Liu <liubaolin12138@163.com> wrote:
>
> From: Baolin Liu <liubaolin@kylinos.cn>
>
> In ntfs_set_ea(), the exit path unconditionally updates the HasEA
> flag based on ea_info_qsize. When an error occurs before
> ea_info_qsize is updated, NInoClearHasEA() hides existing on-disk
> EAs until the inode is evicted.
>
> Only update the flag on success.
>
> Fixes: fc053f05ca28 ("ntfs: add reparse and ea operations")
> Signed-off-by: Baolin Liu <liubaolin@kylinos.cn>
Applied it to #ntfs-next.
Thanks!