[PATCH v4 04/12] ntfs: remove remaining attribute lists on creation failure
From: Baolin Liu
Date: Sun Nov 15 2026 - 08:27:01 EST
From: Xuewen Wang <wangxuewen@xxxxxxxxxx>
Creation rollback can leave an ATTRIBUTE_LIST inode cached after freeing
the base and extent MFT records. MFT reuse can find that stale inode;
dropping it under another inode's record lock can trigger a lockdep
warning.
Remove any remaining ATTRIBUTE_LIST before freeing extent records to
release its storage and invalidate the cached inode. Drop the returned
reference after releasing the record locks.
Fixes: af0db57d4293 ("ntfs: update inode operations")
Reviewed-by: Baolin Liu <liubaolin@xxxxxxxxxx>
Signed-off-by: Xuewen Wang <wangxuewen@xxxxxxxxxx>
---
New in v4.
Tested rollback with large ACLs and long names forcing attribute lists
and extent records. Offline reclamation checks, space counts and retries
passed with 512-byte/4 KiB clusters.
fs/ntfs/namei.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c
index a84d7bc9bc28..abb3675757e9 100644
--- a/fs/ntfs/namei.c
+++ b/fs/ntfs/namei.c
@@ -429,7 +429,7 @@ static struct ntfs_inode *__ntfs_create(const struct mnt_idmap *idmap, struct in
struct mft_record *ni_mrec, *dni_mrec;
struct super_block *sb = dir_ni->vol->sb;
struct inode *rollback_data_vi = NULL, *rollback_sd_vi = NULL;
- struct inode *rollback_rp_vi = NULL;
+ struct inode *rollback_rp_vi = NULL, *rollback_al_vi = NULL;
__le64 parent_mft_ref;
u64 child_mft_ref;
__le16 ea_size;
@@ -748,6 +748,10 @@ static struct ntfs_inode *__ntfs_create(const struct mnt_idmap *idmap, struct in
&rollback_rp_vi))
ntfs_error(sb, "Failed to roll back REPARSE_POINT attribute.");
}
+ if (NInoAttrList(ni) &&
+ ntfs_attr_remove(ni, AT_ATTRIBUTE_LIST, AT_UNNAMED, 0,
+ &rollback_al_vi))
+ ntfs_error(sb, "Failed to roll back ATTRIBUTE_LIST attribute.");
/*
* Free extent MFT records (should not exist any with current
* ntfs_create implementation, but for any case if something will be
@@ -772,6 +776,8 @@ static struct ntfs_inode *__ntfs_create(const struct mnt_idmap *idmap, struct in
mutex_unlock(&dir_ni->mrec_lock);
mutex_unlock(&ni->mrec_lock);
+ if (rollback_al_vi)
+ iput(rollback_al_vi);
if (rollback_rp_vi)
iput(rollback_rp_vi);
if (rollback_data_vi)