From: Christoph Hellwig <hch@lst.de>
To: Carlos Maiolino <cem@kernel.org>
Cc: Jan Kara <jack@suse.cz>,
Filip Blagojevic <filip.blagojevic@wdc.com>,
Matthew Wilcox <willy@infradead.org>,
Damien Le Moal <dlemoal@kernel.org>,
linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: [PATCH] xfs: update BDI {io,ra}_pages values based on the RT device limits
Date: Mon, 20 Jul 2026 16:08:47 +0200 [thread overview]
Message-ID: <20260720140849.2269776-2-hch@lst.de> (raw)
In-Reply-To: <20260720140849.2269776-1-hch@lst.de>
When using XFS with a main device on an SSD that stores metadata and a RT
device to store data on a HDD, we fail to take the I/O sizes for the RT
device into accounting, leading to up to 5% slower read performance when
using an SSD for metadata vs storing data and metadata on the HDD.
Fix this up by taking the RT settings into account at mount an restoring
the old settings at unmount time, unless the BDI settings have changed
from those set by XFS.
Reported-by: Filip Blagojevic <filip.blagojevic@wdc.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/xfs_mount.h | 7 ++++++
fs/xfs/xfs_super.c | 53 +++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 59 insertions(+), 1 deletion(-)
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index 66a02d1b9ad7..216a38a354e7 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -349,6 +349,13 @@ typedef struct xfs_mount {
/* Index of uuid record in the uuid xarray. */
unsigned int m_uuid_table_index;
+
+ /*
+ * Old io_pages/ra_pages valued in the main bdev BDI, and our initial
+ * calculated values.
+ */
+ unsigned long m_old_io_pages, m_initial_io_pages;
+ unsigned long m_old_ra_pages, m_initial_ra_pages;
} xfs_mount_t;
#define M_IGEO(mp) (&(mp)->m_ino_geo)
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 8531d526fc44..63c4bcbe6c2b 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -548,6 +548,52 @@ xfs_open_devices(
return error;
}
+/*
+ * When using a RT device some or all data I/O is using the RT device, but
+ * the BDI is inherited from the main data device. When the underlying block
+ * device for the RT device has larger I/O sizes, the BDI settings might be
+ * incorrect, which is especially bad if the main device is a SSD and the
+ * RT device is a HDD, as the io_opt fixup in blk_apply_bdi_limits is missing
+ * for this case.
+ *
+ * Update the BDI values to the max of the data and RT device to cover our
+ * bases.
+ */
+static void
+xfs_update_bdi_rahead(
+ struct xfs_mount *mp)
+{
+ struct backing_dev_info *rt_bdi =
+ mp->m_rtdev_targp->bt_bdev->bd_disk->bdi;
+ struct backing_dev_info *sb_bdi = mp->m_super->s_bdi;
+
+ mp->m_old_io_pages = sb_bdi->io_pages;
+ mp->m_old_ra_pages = sb_bdi->ra_pages;
+
+ sb_bdi->io_pages = mp->m_initial_io_pages =
+ max(sb_bdi->io_pages, rt_bdi->io_pages);
+ sb_bdi->ra_pages = mp->m_initial_ra_pages =
+ max(sb_bdi->ra_pages, rt_bdi->ra_pages);
+}
+
+static void
+xfs_restore_bdi_rahead(
+ struct xfs_mount *mp)
+{
+ struct backing_dev_info *sb_bdi = mp->m_super->s_bdi;
+
+ if (sb_bdi->io_pages == mp->m_initial_io_pages)
+ sb_bdi->io_pages = mp->m_old_io_pages;
+ else
+ xfs_info(mp, "io_pages changed from %lu to %lu, not restoring.",
+ mp->m_initial_io_pages, sb_bdi->io_pages);
+ if (sb_bdi->ra_pages == mp->m_initial_ra_pages)
+ sb_bdi->ra_pages = mp->m_old_ra_pages;
+ else
+ xfs_info(mp, "ra_pages changed from %lu to %lu, not restoring.",
+ mp->m_initial_ra_pages, sb_bdi->ra_pages);
+}
+
/*
* Setup xfs_mount buffer target pointers based on superblock
*/
@@ -585,6 +631,7 @@ xfs_setup_devices(
mp->m_sb.sb_sectsize, mp->m_sb.sb_rblocks);
if (error)
return error;
+ xfs_update_bdi_rahead(mp);
}
return 0;
@@ -2283,8 +2330,12 @@ static void
xfs_kill_sb(
struct super_block *sb)
{
+ struct xfs_mount *mp = XFS_M(sb);
+
+ if (mp->m_rtdev_targp && mp->m_rtdev_targp != mp->m_ddev_targp)
+ xfs_restore_bdi_rahead(mp);
kill_block_super(sb);
- xfs_mount_free(XFS_M(sb));
+ xfs_mount_free(mp);
}
static struct file_system_type xfs_fs_type = {
--
2.53.0
next prev parent reply other threads:[~2026-07-20 14:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 14:08 update BDI {io,ra}_pages values based on the RT device limits v2 Christoph Hellwig
2026-07-20 14:08 ` Christoph Hellwig [this message]
2026-07-20 23:07 ` [PATCH] xfs: update BDI {io,ra}_pages values based on the RT device limits Damien Le Moal
2026-07-21 4:30 ` Christoph Hellwig
2026-07-21 9:23 ` Carlos Maiolino
2026-07-21 15:18 ` Darrick J. Wong
2026-07-21 9:24 ` Carlos Maiolino
2026-07-21 10:44 ` Carlos Maiolino
-- strict thread matches above, loose matches on Subject: below --
2026-06-23 14:21 Christoph Hellwig
2026-06-23 14:21 ` [PATCH] xfs: " Christoph Hellwig
2026-07-02 22:25 ` Damien Le Moal
2026-07-20 9:02 ` Carlos Maiolino
2026-07-20 9:11 ` Christoph Hellwig
2026-07-20 9:38 ` Carlos Maiolino
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=20260720140849.2269776-2-hch@lst.de \
--to=hch@lst.de \
--cc=cem@kernel.org \
--cc=dlemoal@kernel.org \
--cc=filip.blagojevic@wdc.com \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.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