From: Kanchan Joshi <joshi.k@samsung.com>
To: brauner@kernel.org, hch@lst.de, djwong@kernel.org,
dgc@kernel.org, jack@suse.cz, cem@kernel.org, axboe@kernel.dk,
kbusch@kernel.org, ritesh.list@gmail.com
Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-block@vger.kernel.org, gost.dev@samsung.com,
Kanchan Joshi <joshi.k@samsung.com>,
Anuj Gupta <anuj20.g@samsung.com>
Subject: [PATCH v3 4/6] xfs: generic AG set based steering
Date: Tue, 16 Jun 2026 23:35:53 +0530 [thread overview]
Message-ID: <20260616180555.33338-5-joshi.k@samsung.com> (raw)
In-Reply-To: <20260616180555.33338-1-joshi.k@samsung.com>
Improve allocator concurrency and reduce interlaving by introducing
fixed sized AG set.
Use low bits of the inode as a hash to select AG within the AG set.
Overall, a file will try to use the same AG (and contiguity is maintained),
but multiple files will be spread across all AGs in the target AG set.
Suggested-by: Dave Chinner <dgc@kernel.org>
Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
---
fs/xfs/libxfs/xfs_bmap.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 7a4c8f1aa76c..6685220ec59a 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -3194,6 +3194,36 @@ xfs_bmap_select_minlen(
return args->maxlen;
}
+#define GENERIC_AG_SET_SZ (2)
+
+static inline xfs_agnumber_t
+xfs_default_ag_set_size(
+ struct xfs_inode *ip)
+{
+ struct xfs_mount *mp = ip->i_mount;
+
+ return min_t(xfs_agnumber_t, GENERIC_AG_SET_SZ, mp->m_sb.sb_agcount);
+}
+
+static xfs_agnumber_t
+xfs_ag_to_ag_set(
+ struct xfs_bmalloca *ap,
+ xfs_agnumber_t base_agno)
+{
+ struct xfs_inode *ip = ap->ip;
+ struct xfs_mount *mp = ip->i_mount;
+ xfs_agnumber_t set_size;
+
+ /* Apply fanning only for regular file data */
+ if (!(ap->datatype & XFS_ALLOC_USERDATA))
+ return base_agno;
+
+ set_size = xfs_default_ag_set_size(ip);
+ /* Fan out within the AG set using low bits of the inode */
+ return (base_agno + (XFS_INO_TO_AGINO(mp, ip->i_ino) % set_size)) %
+ mp->m_sb.sb_agcount;
+}
+
static int
xfs_bmap_btalloc_select_lengths(
struct xfs_bmalloca *ap,
@@ -3589,8 +3619,16 @@ xfs_bmap_btalloc_best_length(
{
xfs_extlen_t blen = 0;
int error;
+ xfs_agnumber_t target_ag, start_ag;
ap->blkno = XFS_INO_TO_FSB(args->mp, ap->ip->i_ino);
+
+ /* fan out initial AG across the generic AG set */
+ start_ag = XFS_FSB_TO_AGNO(args->mp, ap->blkno);
+ target_ag = xfs_ag_to_ag_set(ap, start_ag);
+ if (target_ag != start_ag)
+ ap->blkno = XFS_AGB_TO_FSB(args->mp, target_ag, 0);
+
if (!xfs_bmap_adjacent(ap))
ap->eof = false;
--
2.25.1
next prev parent reply other threads:[~2026-06-16 18:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20260616181240epcas5p3f86fbb67f0d04cb0ee4b34839c9522b5@epcas5p3.samsung.com>
2026-06-16 18:05 ` [PATCH v3 0/6] xfs write streams Kanchan Joshi
2026-06-16 18:05 ` [PATCH v3 1/6] fs: add generic write-stream management ioctl Kanchan Joshi
2026-06-16 18:05 ` [PATCH v3 2/6] iomap: introduce and propagate write_stream Kanchan Joshi
2026-06-16 18:05 ` [PATCH v3 3/6] xfs: implement write-stream management support Kanchan Joshi
2026-06-16 18:05 ` Kanchan Joshi [this message]
2026-06-16 18:05 ` [PATCH v3 5/6] xfs: write stream based AG placement Kanchan Joshi
2026-06-16 18:05 ` [PATCH v3 6/6] xfs: introduce software write streams Kanchan Joshi
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=20260616180555.33338-5-joshi.k@samsung.com \
--to=joshi.k@samsung.com \
--cc=anuj20.g@samsung.com \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=cem@kernel.org \
--cc=dgc@kernel.org \
--cc=djwong@kernel.org \
--cc=gost.dev@samsung.com \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=ritesh.list@gmail.com \
/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