Re: [PATCH v1 8/9] ntfs: only count successfully cleared runs when freeing clusters

Hyunchul Lee <[email protected]>
Newsgroups org.kernel.vger.linux-kernel,dev.linux.lists.ntfs
Message-ID <CANFS6baAZz_Hv2Qes3O=VzCB-PEsQySp_3HnV6cc6LGfvexYsA@mail.gmail.com>
2026년 8월 21일 (금) 오후 2:33, Baolin Liu <[email protected]>님이 작성:
>
> From: Baolin Liu <[email protected]>
>
> ntfs_cluster_free_from_rl_nolock() adds a run's length to nr_freed
> whenever the error bookkeeping condition is false, which includes
> cases where ntfs_bitmap_clear_run() actually failed - e.g. a second
> run failing with the same errno as an earlier one, or any failure
> after a non-ENOMEM error was already recorded. Since a failed
> ntfs_bitmap_clear_run() rolls back its partial modifications, no
> bits were cleared for that run, yet its length still inflates
> vol->free_clusters, corrupting statfs output and the allocator's
> free space gate.
>
> Only count runs whose bitmap clear succeeded.
>
> Fixes: 11ccc9107dc4 ("ntfs: update runlist handling and cluster allocator")
> Signed-off-by: Baolin Liu <[email protected]>

Looks good to me.

Reviewed-by: Hyunchul Lee <[email protected]>

> ---
>  fs/ntfs/lcnalloc.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/ntfs/lcnalloc.c b/fs/ntfs/lcnalloc.c
> index aa2e017a4384..795f71d26895 100644
> --- a/fs/ntfs/lcnalloc.c
> +++ b/fs/ntfs/lcnalloc.c
> @@ -53,10 +53,10 @@ int ntfs_cluster_free_from_rl_nolock(struct ntfs_volume *vol,
>                 if (rl->lcn < 0)
>                         continue;
>                 err = ntfs_bitmap_clear_run(lcnbmp_vi, rl->lcn, rl->length);
> -               if (unlikely(err && (!ret || ret == -ENOMEM) && ret != err))
> -                       ret = err;
> -               else
> +               if (likely(!err))
>                         nr_freed += rl->length;
> +               else if (!ret || ret == -ENOMEM)
> +                       ret = err;
>         }
>         ntfs_inc_free_clusters(vol, nr_freed);
>         ntfs_debug("Done.");
> --
> 2.51.0
>
>


-- 
Thanks,
Hyunchul
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.