From: Christoph Hellwig <hch@lst.de>
To: Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
Carlos Maiolino <cem@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
willy@infradead.org, dlemoal@kernel.org, hans.holmberg@wdc.com,
linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
linux-xfs@vger.kernel.org, "Darrick J. Wong" <djwong@kernel.org>
Subject: [PATCH 3/3] xfs: set s_min_writeback_pages for zoned file systems
Date: Fri, 17 Oct 2025 05:45:49 +0200 [thread overview]
Message-ID: <20251017034611.651385-4-hch@lst.de> (raw)
In-Reply-To: <20251017034611.651385-1-hch@lst.de>
Set s_min_writeback_pages to the zone size, so that writeback always
writes up to a full zone. This ensures that writeback does not add
spurious file fragmentation when writing back a large number of
files that are larger than the zone size.
Fixes: 4e4d52075577 ("xfs: add the zoned space allocator")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
---
fs/xfs/xfs_zone_alloc.c | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/fs/xfs/xfs_zone_alloc.c b/fs/xfs/xfs_zone_alloc.c
index 1147bacb2da8..c342595acc3e 100644
--- a/fs/xfs/xfs_zone_alloc.c
+++ b/fs/xfs/xfs_zone_alloc.c
@@ -1215,6 +1215,7 @@ xfs_mount_zones(
.mp = mp,
};
struct xfs_buftarg *bt = mp->m_rtdev_targp;
+ xfs_extlen_t zone_blocks = mp->m_groups[XG_TYPE_RTG].blocks;
int error;
if (!bt) {
@@ -1245,10 +1246,33 @@ xfs_mount_zones(
return -ENOMEM;
xfs_info(mp, "%u zones of %u blocks (%u max open zones)",
- mp->m_sb.sb_rgcount, mp->m_groups[XG_TYPE_RTG].blocks,
- mp->m_max_open_zones);
+ mp->m_sb.sb_rgcount, zone_blocks, mp->m_max_open_zones);
trace_xfs_zones_mount(mp);
+ /*
+ * The writeback code switches between inodes regularly to provide
+ * fairness. The default lower bound is 4MiB, but for zoned file
+ * systems we want to increase that both to reduce seeks, but also more
+ * importantly so that workloads that writes files in a multiple of the
+ * zone size do not get fragmented and require garbage collection when
+ * they shouldn't. Increase is to the zone size capped by the max
+ * extent len.
+ *
+ * Note that because s_min_writeback_pages is a superblock field, this
+ * value also get applied to non-zoned files on the data device if
+ * there are any. On typical zoned setup all data is on the RT device
+ * because using the more efficient sequential write required zones
+ * is the reason for using the zone allocator, and either the RT device
+ * and the (meta)data device are on the same block device, or the
+ * (meta)data device is on a fast SSD while the data on the RT device
+ * is on a SMR HDD. In any combination of the above cases enforcing
+ * the higher min_writeback_pages for non-RT inodes is either a noop
+ * or beneficial.
+ */
+ mp->m_super->s_min_writeback_pages =
+ XFS_FSB_TO_B(mp, min(zone_blocks, XFS_MAX_BMBT_EXTLEN)) >>
+ PAGE_SHIFT;
+
if (bdev_is_zoned(bt->bt_bdev)) {
error = blkdev_report_zones(bt->bt_bdev,
XFS_FSB_TO_BB(mp, mp->m_sb.sb_rtstart),
--
2.47.3
next prev parent reply other threads:[~2025-10-17 3:46 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-17 3:45 allow file systems to increase the minimum writeback chunk size v2 Christoph Hellwig
2025-10-17 3:45 ` [PATCH 1/3] writeback: cleanup writeback_chunk_size Christoph Hellwig
2025-10-17 12:31 ` Jan Kara
2025-10-20 9:35 ` Jan Kara
2025-10-24 14:11 ` Nirjhar Roy (IBM)
2025-10-17 3:45 ` [PATCH 2/3] writeback: allow the file system to override MIN_WRITEBACK_PAGES Christoph Hellwig
2025-10-17 12:32 ` Jan Kara
2025-10-17 15:45 ` Darrick J. Wong
2025-10-20 9:35 ` Jan Kara
2025-10-24 14:33 ` Nirjhar Roy (IBM)
2025-10-24 15:12 ` Christoph Hellwig
2025-10-17 3:45 ` Christoph Hellwig [this message]
2025-10-22 5:34 ` allow file systems to increase the minimum writeback chunk size v2 Christoph Hellwig
2025-10-22 18:38 ` Andrew Morton
2025-10-29 14:55 ` Christian Brauner
2025-10-29 14:56 ` Christian Brauner
-- strict thread matches above, loose matches on Subject: below --
2025-10-15 6:27 allow file systems to increase the minimum writeback chunk size Christoph Hellwig
2025-10-15 6:27 ` [PATCH 3/3] xfs: set s_min_writeback_pages for zoned file systems Christoph Hellwig
2025-10-15 7:10 ` Damien Le Moal
2025-10-15 16:01 ` Darrick J. Wong
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=20251017034611.651385-4-hch@lst.de \
--to=hch@lst.de \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=cem@kernel.org \
--cc=djwong@kernel.org \
--cc=dlemoal@kernel.org \
--cc=hans.holmberg@wdc.com \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-xfs@vger.kernel.org \
--cc=willy@infradead.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