ntfs: read MFT writeback bounds under size_lock

Read the MFT inode size and allocated size under the size_lock critical
section before deriving the folio writeback limits. This prevents
writeback from combining an old allocation boundary with a concurrently
updated file size while the MFT is extended.

Fixes: 115380f9a2 ("ntfs: update mft operations")
Cc: stable@vger.kernel.org
Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
This commit is contained in:
Hyunchul Lee 2026-09-21 15:44:03 +09:00 committed by Namjae Jeon
parent f47d223627
commit 50ed298b6a

View File

@ -2901,9 +2901,17 @@ static int ntfs_write_mft_block(struct folio *folio, struct writeback_control *w
struct ntfs_inode *tni;
s64 lcn;
s64 vcn = ntfs_pidx_to_cluster(vol, folio->index);
s64 end_vcn = ntfs_bytes_to_cluster(vol, ni->allocated_size);
s64 end_vcn;
unsigned int folio_sz;
loff_t i_size = i_size_read(vi);
loff_t i_size;
s64 allocated_size;
unsigned long flags;
read_lock_irqsave(&ni->size_lock, flags);
i_size = i_size_read(vi);
allocated_size = ni->allocated_size;
read_unlock_irqrestore(&ni->size_lock, flags);
end_vcn = ntfs_bytes_to_cluster(vol, allocated_size);
ntfs_debug("Entering for inode 0x%llx, attribute type 0x%x, folio index 0x%lx.",
ni->mft_no, ni->type, folio->index);