fs/ntfs3: end trim runs at fully allocated bitmap windows
Subsystems (2)
PATCH 1/1 fs/ntfs3: end trim runs at fully allocated bitmap windows
ntfs_trim_fs() keeps a free run pending across bitmap windows. When the cached free-bit count of a window is zero, the loop skips it without ending the pending run. Free clusters at the start of a later window are then added to the old length despite the allocated gap.
For example, two eight-cluster holes separated by fully allocated bitmap windows can be submitted as one sixteen-cluster discard starting at the first hole. This discards allocated clusters while leaving the actual second hole untrimmed.
Finish a qualifying pending run and reset its length before skipping a fully allocated window. Preserve the minimum-length check and the cached window optimization, matching the analogous handling in wnd_rescan().
--- fs/ntfs3/bitmap.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
fs/ntfs3/bitmap.c +9 -1
@@ -1447,8 +1447,16 @@ int ntfs_trim_fs(struct ntfs_sb_info *sbi, struct fstrim_range *range)if (lcn_wnd > lcn_to)break ; -if (!wnd->free_bits[iw]) +if (!wnd->free_bits[iw]) { +if (len >= minlen) { + err =ntfs_discard (sbi, lcn, len); +if (err) + goto out; + done += len; + } + len =0 ;continue ; + }if (iw +1 == wnd->nwnd) wbits = wnd->bits_last;
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
Signature · 1 line
2.43.0