Re: [PATCH v2 4/5] ntfs: write unlinked file attributes before dropping their cache
From: liubaolin
Date: Wed Nov 04 2026 - 04:38:56 EST
在 2026/11/4 17:06, Namjae Jeon 写道:
@@ -4052,6 +4052,14 @@ s64 ntfs_inode_attr_pwrite(struct inode *vi, s64 pos, s64 count, u8 *buf, bool sThis misses data dirtied by ntfs_attr_make_non_resident(). For
WARN_ON(!NInoAttr(ni));
+ /*
+ * Attribute inodes of an unlinked file have no links either and are
+ * evicted at the final iput(). Do not leave their data in dirty pages
+ * that eviction would discard while the base file is still open.
+ */
+ if (!VFS_I(base_ni)->i_nlink && !ntfs_inode_is_named_stream(ni))
+ sync = true;
example, with 1 KiB MFT records, create an O_TMPFILE, nearly fill
its MFT record with a resident EA, then write 4 KiB to the file.
Growing $DATA can force ntfs_resident_attr_resize() to convert
SECURITY_DESCRIPTOR to nonresident form to make room. the conversion
only dirties the folio. With patch 5, the subsequent
iput(tvi) can evict the zero-link attribute inode and discard the SD
contents before writeback. If the file is later linked with linkat(),
it can retain invalid SD data after close. Please also ensure that the
converted data is written back before dropping the last
attribute-inode reference.
Thanks!
Hi Namjae,
Thank you for the review. I will fix this issue and send v3 soon.
Thanks,
Baolin.