Linux XFS filesystem development
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: stable-commits@vger.kernel.org, daejun7.park@samsung.com
Cc: Amir Goldstein <amir73il@gmail.com>,
	"Darrick J. Wong" <djwong@kernel.org>,
	linux-xfs@vger.kernel.org
Subject: Patch "xfs: don't skip free extents of the longest length in a whole-AG FITRIM" has been added to the 7.3-stable tree
Date: Mon,  9 Nov 2026 19:04:49 -0500	[thread overview]
Message-ID: <20261110000449.3482084-1-sashal@kernel.org> (raw)

This is a note to let you know that I've just added the patch titled

    xfs: don't skip free extents of the longest length in a whole-AG FITRIM

to the 7.3-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     xfs-don-t-skip-free-extents-of-the-longest-length-in.patch
and it can be found in the queue-7.3 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.



commit 9661004d580814f4be2838b1020ab0123f4da2b4
Author: Daejun Park <daejun7.park@samsung.com>
Date:   Mon Oct 26 10:54:06 2026 +0900

    xfs: don't skip free extents of the longest length in a whole-AG FITRIM
    
    [ Upstream commit 5745f4f10a1a16aa5bb020acc38afa33f2d5ff99 ]
    
    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 <dgc@kernel.org>
    Link: https://lore.kernel.org/r/ZgiJWxVcVwag0fIP@dread.disaster.area
    Cc: stable@vger.kernel.org
    Fixes: a66d636385d6 ("xfs: fix fstrim offset calculations")
    Signed-off-by: Daejun Park <daejun7.park@samsung.com>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Signed-off-by: Carlos Maiolino <cem@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c
index 8120f136af931..cdf660344c281 100644
--- a/fs/xfs/xfs_discard.c
+++ b/fs/xfs/xfs_discard.c
@@ -200,12 +200,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);

                 reply	other threads:[~2026-11-10  0:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261110000449.3482084-1-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=amir73il@gmail.com \
    --cc=daejun7.park@samsung.com \
    --cc=djwong@kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=stable-commits@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /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