Skip to contentSkip to conversation

ntfs: do not update ctime when setxattr fails

PATCH Applied Baolin Liu 3 participants 3 messages Aug 18 – Aug 19

Subsystems (2)
lore
Share & tools
lore

Baolin Liu

author
#0 lore raw

PATCH 1/1 ntfs: do not update ctime when setxattr fails

From: Baolin Liu <[email protected]>

ntfs_setxattr() updates ctime and marks the inode dirty even when the operation fails. A failed setxattr(2) must not change file metadata.

Update ctime only on success.

Fixes fc053f05ca28 ("ntfs: add reparse and ea operations")
---
 fs/ntfs/ea.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
fs/ntfs/ea.c +4 -2
index 0cd192752b7c..47ff40aa8e0f 100644
@@ -768,8 +768,10 @@ static int ntfs_setxattr(const struct xattr_handler *handler,
 	mutex_unlock(&ni->mrec_lock);
 
 out:
-	inode_set_ctime_current(inode);
-	mark_inode_dirty(inode);
+	if (!err) {
+		inode_set_ctime_current(inode);
+		mark_inode_dirty(inode);
+	}
 	return err;
 }
 
Signature · 1 line
2.51.0
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi Baolin,

2026년 8월 18일 (화) 오후 5:28, Baolin Liu <[email protected]>님이 작성:

Quoted 11 lines

From: Baolin Liu <[email protected]>

ntfs_setxattr() updates ctime and marks the inode dirty even when the operation fails. A failed setxattr(2) must not change file metadata.

Update ctime only on success.

Fixes fc053f05ca28 ("ntfs: add reparse and ea operations")

Looks good to me.

Signature · 2 lines
Thanks,
Hyunchul
maintainer Applied
#2 lore raw
In reply to Baolin Liu
Quoted 11 lines · Baolin Liu

From: Baolin Liu <[email protected]>

ntfs_setxattr() updates ctime and marks the inode dirty even when the operation fails. A failed setxattr(2) must not change file metadata.

Update ctime only on success.

Fixes fc053f05ca28 ("ntfs: add reparse and ea operations")

Applied it to #ntfs-next.
Thanks!