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);