From: Christoph Hellwig <hch@lst.de>
To: Chuck Lever <chuck.lever@oracle.com>,
Jeff Layton <jlayton@kernel.org>,
Amir Goldstein <amir73il@gmail.com>
Cc: NeilBrown <neil@brown.name>,
Olga Kornievskaia <okorniev@redhat.com>,
Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
Carlos Maiolino <cem@kernel.org>,
linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org,
linux-fsdevel@vger.kernel.org
Subject: [PATCH 7/7] xfs: support layout-based block device access on the RT device
Date: Mon, 23 Mar 2026 08:07:23 +0100 [thread overview]
Message-ID: <20260323070746.2940140-8-hch@lst.de> (raw)
In-Reply-To: <20260323070746.2940140-1-hch@lst.de>
Implement the devid_to_bdev method so that device index one can be
used for the RT device, and allow block-style layouts on the
conventional RT device.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/xfs_pnfs.c | 52 ++++++++++++++++++++++++++++++++++++-----------
1 file changed, 40 insertions(+), 12 deletions(-)
diff --git a/fs/xfs/xfs_pnfs.c b/fs/xfs/xfs_pnfs.c
index 7ef5a3f522f6..4302df26bfc2 100644
--- a/fs/xfs/xfs_pnfs.c
+++ b/fs/xfs/xfs_pnfs.c
@@ -46,17 +46,50 @@ xfs_break_leased_layouts(
return error;
}
+/*
+ * Check what layouts we support for direct block device access.
+ */
static expfs_block_layouts_t
xfs_fs_layouts_supported(
struct super_block *sb)
{
- expfs_block_layouts_t supported = EXPFS_BLOCK_IN_BAND_ID;
+ struct xfs_mount *mp = XFS_M(sb);
+ expfs_block_layouts_t supported = 0;
- if (exportfs_bdev_supports_out_of_band_id(sb->s_bdev))
+ /*
+ * We don't have a good way to identify a specific RT device. And
+ * there's really no point in trying hard just for the deprecated
+ * block layout support.
+ */
+ if (!xfs_has_realtime(mp))
+ supported |= EXPFS_BLOCK_IN_BAND_ID;
+
+ if (exportfs_bdev_supports_out_of_band_id(sb->s_bdev) ||
+ (mp->m_rtdev_targp &&
+ exportfs_bdev_supports_out_of_band_id(mp->m_rtdev_targp->bt_bdev)))
supported |= EXPFS_BLOCK_OUT_OF_BAND_ID;
return supported;
}
+static struct block_device *
+xfs_fs_devid_to_bdev(
+ struct super_block *sb,
+ u32 dev_idx)
+{
+ struct xfs_mount *mp = XFS_M(sb);
+
+ switch (dev_idx) {
+ case 0:
+ return sb->s_bdev;
+ case 1:
+ if (mp->m_rtdev_targp && mp->m_rtdev_targp->bt_bdev)
+ return mp->m_rtdev_targp->bt_bdev;
+ fallthrough;
+ default:
+ return ERR_PTR(-EINVAL);
+ }
+}
+
/*
* Get a unique ID including its location so that the client can identify
* the exported device.
@@ -141,20 +174,14 @@ xfs_fs_map_blocks(
return -EIO;
*dev_idx = 0;
-
- /*
- * We can't export inodes residing on the realtime device. The realtime
- * device doesn't have a UUID to identify it, so the client has no way
- * to find it.
- */
if (XFS_IS_REALTIME_INODE(ip))
- return -ENXIO;
+ *dev_idx = 1;
/*
- * The pNFS block layout spec actually supports reflink like
- * functionality, but the Linux pNFS server doesn't implement it yet.
+ * The pNFS block layout spec supports out of place writes, but the
+ * Linux pNFS server doesn't implement it yet.
*/
- if (xfs_is_reflink_inode(ip))
+ if (xfs_is_cow_inode(ip))
return -ENXIO;
/*
@@ -351,6 +378,7 @@ xfs_fs_commit_blocks(
struct exportfs_block_ops xfs_export_block_ops = {
.layouts_supported = xfs_fs_layouts_supported,
+ .devid_to_bdev = xfs_fs_devid_to_bdev,
.get_uuid = xfs_fs_get_uuid,
.map_blocks = xfs_fs_map_blocks,
.commit_blocks = xfs_fs_commit_blocks,
--
2.47.3
prev parent reply other threads:[~2026-03-23 7:08 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-23 7:07 support multiple block devices per file system for block-style layouts Christoph Hellwig
2026-03-23 7:07 ` [PATCH 1/7] exportfs: split out the ops for layout-based block device access Christoph Hellwig
2026-03-23 13:39 ` Chuck Lever
2026-03-26 5:33 ` Christoph Hellwig
2026-03-23 7:07 ` [PATCH 2/7] exportfs: don't pass struct iattr to ->commit_blocks Christoph Hellwig
2026-03-23 14:05 ` Chuck Lever
2026-03-26 5:36 ` Christoph Hellwig
2026-03-23 7:07 ` [PATCH 3/7] exportfs,nfsd: rework checking for layout-based block device access support Christoph Hellwig
2026-03-23 7:07 ` [PATCH 4/7] nfsd: support multiple pNFS device IDs Christoph Hellwig
2026-03-23 7:07 ` [PATCH 5/7] nfsd/blocklayout: support GETDEVICEINFO for multiple devices Christoph Hellwig
2026-03-23 13:53 ` Chuck Lever
2026-03-26 5:38 ` Christoph Hellwig
2026-03-26 12:37 ` Chuck Lever
2026-03-23 7:07 ` [PATCH 6/7] exportfs: return a device index from ->map_blocks Christoph Hellwig
2026-03-23 7:07 ` Christoph Hellwig [this message]
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=20260323070746.2940140-8-hch@lst.de \
--to=hch@lst.de \
--cc=Dai.Ngo@oracle.com \
--cc=amir73il@gmail.com \
--cc=cem@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=jlayton@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=neil@brown.name \
--cc=okorniev@redhat.com \
--cc=tom@talpey.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