mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
fs/ntfs3: Fix case when index is reused during tree transformation
commit 05afeeebcac850a016ec4fb1f681ceda11963562 upstream.
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: 82cae269cf ("fs/ntfs3: Add initialization of super block")
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
df40783dc3
commit
c494fe4ccd
@@ -1531,6 +1531,11 @@ static int indx_add_allocate(struct ntfs_index *indx, struct ntfs_inode *ni,
|
|||||||
goto out1;
|
goto out1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data_size <= le64_to_cpu(alloc->nres.data_size)) {
|
||||||
|
/* Reuse index. */
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
/* Increase allocation. */
|
/* Increase allocation. */
|
||||||
err = attr_set_size(ni, ATTR_ALLOC, in->name, in->name_len,
|
err = attr_set_size(ni, ATTR_ALLOC, in->name, in->name_len,
|
||||||
&indx->alloc_run, data_size, &data_size, true,
|
&indx->alloc_run, data_size, &data_size, true,
|
||||||
@@ -1541,6 +1546,7 @@ static int indx_add_allocate(struct ntfs_index *indx, struct ntfs_inode *ni,
|
|||||||
goto out1;
|
goto out1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
*vbn = bit << indx->idx2vbn_bits;
|
*vbn = bit << indx->idx2vbn_bits;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user