From: Daejun Park <[email protected]> Since commit a66d636385d6 ("xfs: fix fstrim offset calculations"), the by-length walk of an AG in FITRIM starts with xfs_alloc_lookup_ge(cur, 0, pagf_longest) and walks down. The lookup lands on the longest free extent with the lowest block number. The other free extents of that length sort after it and are never discarded.
Start every by-length batch with xfs_alloc_lookup_le() at restart_bno. Suggested-by: Dave Chinner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: [email protected] Fixes: a66d636385d6 ("xfs: fix fstrim offset calculations") Signed-off-by: Daejun Park <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Carlos Maiolino <[email protected]> (cherry picked from commit 5745f4f10a1a16aa5bb020acc38afa33f2d5ff99) https://virtuozzo.atlassian.net/browse/VSTOR-153590 Feature: fix ms/xfs Signed-off-by: Denis V. Lunev <[email protected]> --- Notes: A clean cherry-pick of mainline 5745f4f10a1a (v7.4-rc2) on top of patch 1, no changes. This is the bug the ploop tests hit on xfs: one of several free extents of the longest length discarded. fs/xfs/xfs_discard.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c index 41c98f9abde1..a6c43e4fdec3 100644 --- a/fs/xfs/xfs_discard.c +++ b/fs/xfs/xfs_discard.c @@ -228,12 +228,12 @@ xfs_trim_gather_extents( error = xfs_alloc_lookup_le(cur, tcur->start, 0, &i); if (!error && !i) error = xfs_alloc_lookup_ge(cur, tcur->start, 0, &i); - } else if (tcur->restart_bno == NULLAGBLOCK) { - /* first time through a by-len starts with max length */ - cur = xfs_cntbt_init_cursor(mp, tp, agbp, pag); - error = xfs_alloc_lookup_ge(cur, 0, tcur->count, &i); } else { - /* nth time through a by-len starts where we left off */ + /* + * A by-len walk starts at the last record of the longest + * length (restart_bno is NULLAGBLOCK until the first batch + * ends) and then where the previous batch stopped. + */ cur = xfs_cntbt_init_cursor(mp, tp, agbp, pag); error = xfs_alloc_lookup_le(cur, tcur->restart_bno, tcur->count, &i); -- 2.53.0 _______________________________________________ Devel mailing list [email protected] https://lists.openvz.org/mailman/listinfo/devel
