From 50ed298b6a4be68cac85801d21a5e25555f64668 Mon Sep 17 00:00:00 2001 From: Hyunchul Lee Date: Mon, 21 Sep 2026 15:44:03 +0900 Subject: [PATCH] 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: 115380f9a2f9 ("ntfs: update mft operations") Cc: stable@vger.kernel.org Signed-off-by: Hyunchul Lee Signed-off-by: Namjae Jeon --- fs/ntfs/mft.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c index 4b7449495375..c9ea11198aa6 100644 --- a/fs/ntfs/mft.c +++ b/fs/ntfs/mft.c @@ -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);