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 2/4] ntfs: fix rollback after MFT bitmap run coalescing
Date: Thu, 24 Sep 2026 10:26:34 +0800 [thread overview]
Message-ID: <b7326c4e-d408-46a4-abdd-e815c280da3e@163.com> (raw)
In-Reply-To: <20260924014514.1678828-3-wangxuewen@kylinos.cn>
在 2026/9/24 09:45, Xuewen Wang 写道:
> After the direct allocation attempt drops lcnbmp_lock, a concurrent free
> can let ntfs_cluster_alloc() return the adjacent cluster. The merged
> runlist then extends the existing last run, but rollback assumes a new
> run was added. A later metadata failure removes the old mapping and
> frees its first cluster.
>
> Record whether the allocated cluster is adjacent before merging the
> runlists. On rollback, shorten a coalesced run by one cluster and free
> only that cluster; remove the new run for a non-adjacent allocation.
>
> 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 | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c
> index 88bac85d22bc..12666668a80e 100644
> --- a/fs/ntfs/mft.c
> +++ b/fs/ntfs/mft.c
> @@ -1428,6 +1428,8 @@ static int ntfs_mft_bitmap_extend_allocation_nolock(struct ntfs_volume *vol)
> "Failed to allocate a cluster for the mft bitmap.");
> return PTR_ERR(rl2);
> }
> + /* The adjacent cluster may have become available while unlocked. */
> + status.added_cluster = rl2->lcn == lcn;
> rl = ntfs_runlists_merge(&mftbmp_ni->runlist, rl2, 0, &new_rl_count);
> if (IS_ERR(rl)) {
> up_write(&mftbmp_ni->runlist.lock);
> @@ -1442,8 +1444,8 @@ static int ntfs_mft_bitmap_extend_allocation_nolock(struct ntfs_volume *vol)
> }
> mftbmp_ni->runlist.rl = rl;
> mftbmp_ni->runlist.count = new_rl_count;
> - status.added_run = 1;
> - ntfs_debug("Adding one run to mft bitmap.");
> + status.added_run = !status.added_cluster;
> + ntfs_debug("Allocated one cluster for mft bitmap.");
> /* Find the last run in the new runlist. */
> for (; rl[1].length; rl++)
> ;
Looks good to me.
Reviewed-by: Baolin Liu <liubaolin@kylinos.cn>
next prev parent reply other threads:[~2026-09-24 2:26 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 [this message]
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
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=b7326c4e-d408-46a4-abdd-e815c280da3e@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®