mirror of
https://github.com/torvalds/linux.git
synced 2026-11-10 17:11:02 +01:00
ntfs: account for direct MFT bitmap cluster allocation
The MFT bitmap extension fast path sets $Bitmap directly, bypassing
ntfs_cluster_alloc() and its free_clusters and lcn_empty_bits_per_page
updates. Successful extensions overreport free space, and rollback adds
back counts that were never deducted.
Update both counts under lcnbmp_lock and the bitmap folio lock. Require
a nonzero page count and space remaining after delayed-allocation
reservations; otherwise use the regular allocator. The page check also
prevents underflow when the initial scan recorded zero after a read error.
Fixes: 6251f0b0de ("ntfs: update super block operations")
Suggested-by: Baolin Liu <liubaolin@kylinos.cn>
Reviewed-by: Baolin Liu <liubaolin@kylinos.cn>
Signed-off-by: Xuewen Wang <wangxuewen@kylinos.cn>
Reviewed-by: Baolin Liu <liubaolin@kylinos.cn>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
This commit is contained in:
parent
0c3f2944e9
commit
109c9b0f67
|
|
@ -1404,10 +1404,18 @@ static int ntfs_mft_bitmap_extend_allocation_nolock(struct ntfs_volume *vol)
|
|||
folio_lock(folio);
|
||||
b = (u8 *)kmap_local_folio(folio, 0) + (ll & ~PAGE_MASK);
|
||||
tb = 1 << (lcn & 7ull);
|
||||
if (*b != 0xff && !(*b & tb)) {
|
||||
/*
|
||||
* A page skipped by the initial scan has no free bits recorded.
|
||||
* Honor that and the space reserved for delayed allocation.
|
||||
*/
|
||||
if (*b != 0xff && !(*b & tb) &&
|
||||
vol->lcn_empty_bits_per_page[ll >> PAGE_SHIFT] &&
|
||||
ntfs_available_clusters_count(vol, 1) > 0) {
|
||||
/* Next cluster is free, allocate it. */
|
||||
*b |= tb;
|
||||
folio_mark_dirty(folio);
|
||||
ntfs_dec_free_clusters(vol, 1);
|
||||
ntfs_set_lcn_empty_bits(vol, ll >> PAGE_SHIFT, 1, 1);
|
||||
folio_unlock(folio);
|
||||
kunmap_local(b);
|
||||
folio_put(folio);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user