mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: liubaolin <liubaolin12138@163.com>
To: Xuewen Wang <wangxuewen@kylinos.cn>,
	linkinjeon@kernel.org, hyc.lee@gmail.com
Cc: ntfs@lists.linux.dev, linux-kernel@vger.kernel.org,
	Baolin Liu <liubaolin@kylinos.cn>
Subject: Re: [PATCH v1 4/4] ntfs: account for direct MFT bitmap cluster allocation
Date: Thu, 24 Sep 2026 10:26:53 +0800	[thread overview]
Message-ID: <4fcb44c4-2008-4c07-b32a-b8a3e324a7ac@163.com> (raw)
In-Reply-To: <20260924014514.1678828-5-wangxuewen@kylinos.cn>



在 2026/9/24 09:45, Xuewen Wang 写道:
> 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: 6251f0b0de7d ("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>
> ---
>   fs/ntfs/mft.c | 10 +++++++++-
>   1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c
> index 489a5935202c..e01e367a588d 100644
> --- a/fs/ntfs/mft.c
> +++ b/fs/ntfs/mft.c
> @@ -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);

Looks good to me.

Reviewed-by: Baolin Liu <liubaolin@kylinos.cn>


  reply	other threads:[~2026-09-24  2:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24  1:45 [PATCH v1 0/4] ntfs: fix MFT bitmap extension allocation Xuewen Wang
2026-09-24  1:45 ` [PATCH v1 1/4] ntfs: bound the adjacent cluster in MFT bitmap extension Xuewen Wang
2026-09-24  2:26   ` liubaolin
2026-09-24  1:45 ` [PATCH v1 2/4] ntfs: fix rollback after MFT bitmap run coalescing Xuewen Wang
2026-09-24  2:26   ` liubaolin
2026-09-24  1:45 ` [PATCH v1 3/4] ntfs: wait for the bitmap scan before MFT bitmap extension Xuewen Wang
2026-09-24  2:26   ` liubaolin
2026-09-24  1:45 ` [PATCH v1 4/4] ntfs: account for direct MFT bitmap cluster allocation Xuewen Wang
2026-09-24  2:26   ` liubaolin [this message]
2026-09-24  2:10 ` [PATCH v1 0/4] ntfs: fix MFT bitmap extension allocation liubaolin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4fcb44c4-2008-4c07-b32a-b8a3e324a7ac@163.com \
    --to=liubaolin12138@163.com \
    --cc=hyc.lee@gmail.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liubaolin@kylinos.cn \
    --cc=ntfs@lists.linux.dev \
    --cc=wangxuewen@kylinos.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®