summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBaolin Liu <liubaolin@kylinos.cn>2026-08-21 13:32:37 +0800
committerNamjae Jeon <linkinjeon@kernel.org>2026-08-26 20:15:56 +0900
commitbe9e89ccb8e52a3e4b67feeb03ebd8133091dc7e (patch)
tree05fda6880d160de63f3ed2d328d249016bbe981e
parentcf06dcd572845723821b54a608fc2da995c3c8e2 (diff)
downloadlinux-be9e89ccb8e52a3e4b67feeb03ebd8133091dc7e.tar.gz
linux-be9e89ccb8e52a3e4b67feeb03ebd8133091dc7e.zip
ntfs: only count successfully cleared runs when freeing clusters
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 <liubaolin@kylinos.cn> Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
-rw-r--r--fs/ntfs/lcnalloc.c6
1 files 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.");