Skip to content

Commit 05afeee

Browse files
fs/ntfs3: Fix case when index is reused during tree transformation
In most cases when adding a cluster to the directory index, they are placed at the end, and in the bitmap, this cluster corresponds to the last bit. The new directory size is calculated as follows: data_size = (u64)(bit + 1) << indx->index_bits; In the case of reusing a non-final cluster from the index, data_size is calculated incorrectly, resulting in the directory size differing from the actual size. A check for cluster reuse has been added, and the size update is skipped. Fixes: 82cae26 ("fs/ntfs3: Add initialization of super block") Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com> Cc: stable@vger.kernel.org
1 parent 24f6f50 commit 05afeee

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

fs/ntfs3/index.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,6 +1533,11 @@ static int indx_add_allocate(struct ntfs_index *indx, struct ntfs_inode *ni,
15331533
goto out1;
15341534
}
15351535

1536+
if (data_size <= le64_to_cpu(alloc->nres.data_size)) {
1537+
/* Reuse index. */
1538+
goto out;
1539+
}
1540+
15361541
/* Increase allocation. */
15371542
err = attr_set_size(ni, ATTR_ALLOC, in->name, in->name_len,
15381543
&indx->alloc_run, data_size, &data_size, true,
@@ -1546,6 +1551,7 @@ static int indx_add_allocate(struct ntfs_index *indx, struct ntfs_inode *ni,
15461551
if (in->name == I30_NAME)
15471552
i_size_write(&ni->vfs_inode, data_size);
15481553

1554+
out:
15491555
*vbn = bit << indx->idx2vbn_bits;
15501556

15511557
return 0;

0 commit comments

Comments
 (0)