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 1/4] ntfs: bound the adjacent cluster in MFT bitmap extension
Date: Thu, 24 Sep 2026 10:26:14 +0800	[thread overview]
Message-ID: <d99b5d9c-1abe-4d5b-9f87-3596bd18f4d8@163.com> (raw)
In-Reply-To: <20260924014514.1678828-2-wangxuewen@kylinos.cn>



在 2026/9/24 09:45, Xuewen Wang 写道:
> When the last MFT bitmap run reaches the volume boundary, the direct
> allocation path tests the bit for nr_clusters, an invalid LCN. A clear
> bit allows an out-of-volume allocation; a bitmap read failure aborts
> extension even if valid clusters remain available.
> 
> Check the candidate LCN before accessing $Bitmap and fall back to
> ntfs_cluster_alloc() with no locality hint when it is outside the volume.
> 
> Reviewed-by: Baolin Liu <liubaolin@kylinos.cn>
> Signed-off-by: Xuewen Wang <wangxuewen@kylinos.cn>
> ---
>   fs/ntfs/mft.c | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c
> index 8bb8b4085c8b..88bac85d22bc 100644
> --- a/fs/ntfs/mft.c
> +++ b/fs/ntfs/mft.c
> @@ -1377,6 +1377,11 @@ static int ntfs_mft_bitmap_extend_allocation_nolock(struct ntfs_volume *vol)
>   	lcn = rl->lcn + rl->length;
>   	ntfs_debug("Last lcn of mft bitmap attribute is 0x%llx.",
>   			(long long)lcn);
> +	/* There is no adjacent cluster if the last run ends at the volume end. */
> +	if (lcn >= vol->nr_clusters) {
> +		lcn = -1;
> +		goto alloc_cluster;
> +	}
>   	/*
>   	 * Attempt to get the cluster following the last allocated cluster by
>   	 * hand as it may be in the MFT zone so the allocator would not give it
> @@ -1413,6 +1418,7 @@ static int ntfs_mft_bitmap_extend_allocation_nolock(struct ntfs_volume *vol)
>   		kunmap_local(b);
>   		folio_put(folio);
>   		up_write(&vol->lcnbmp_lock);
> +alloc_cluster:
>   		/* Allocate a cluster from the DATA_ZONE. */
>   		rl2 = ntfs_cluster_alloc(vol, rl[1].vcn, 1, lcn, DATA_ZONE,
>   				true, false, false);

Looks good to me.

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


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

Thread overview: 11+ 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 [this message]
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
2026-09-24  2:10 ` [PATCH v1 0/4] ntfs: fix MFT bitmap extension allocation liubaolin
  -- strict thread matches above, loose matches on Subject: below --
2026-09-24  1:42 Xuewen Wang
2026-09-24  1:42 ` [PATCH v1 1/4] ntfs: bound the adjacent cluster in MFT bitmap extension Xuewen Wang

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=d99b5d9c-1abe-4d5b-9f87-3596bd18f4d8@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®