[RFC PATCH 2/4] nfs: add NFS_CAP_P2PDMA and detect transport support

Pranjal Shrivastava
2026-04-01T19:45:14Z

The NFS server capabilities bitmask (server->caps) is currently full,
utilizing all 32 bits of the existing unsigned int. Expand the bitmask
to 64 bits (u64) to allow for new feature flags.

Introduce a new capability bit, NFS_CAP_P2PDMA, to indicate that the
local mount is backed by hardware and a transport capable of PCI
Peer-to-Peer DMA.

Update nfs_server_set_init_caps() to query the underlying SunRPC
transport for P2PDMA support during the mount process. If the transport
(e.g., RDMA) signals support, set the NFS_CAP_P2PDMA bit in the mount's
capabilities. This allows the high-performance Direct I/O path to
efficiently determine if it should allow P2P memory buffers.

Signed-off-by: Pranjal Shrivastava <praan@google.com>
---
fs/nfs/client.c | 8 +++++
fs/nfs/nfs4_fs.h | 2 +-
fs/nfs/super.c | 2 +-
include/linux/nfs_fs_sb.h | 67 ++++++++++++++++++++-------------------
4 files changed, 44 insertions(+), 35 deletions(-)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index be02bb227741..f177cf098d44 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -712,6 +712,8 @@ static void nfs4_server_set_init_caps(struct nfs_server *server)

void nfs_server_set_init_caps(struct nfs_server *server)
{
+ struct rpc_xprt *xprt;
+
switch (server->nfs_client->rpc_ops->version) {
case 2:
server->caps = NFS_CAP_HARDLINKS | NFS_CAP_SYMLINKS;
@@ -725,6 +727,12 @@ void nfs_server_set_init_caps(struct nfs_server *server)
nfs4_server_set_init_caps(server);
break;
}
+
+ rcu_read_lock();
+ xprt = rcu_dereference(server->client->cl_xprt);
+ if (xprt->ops->supports_p2pdma && xprt->ops->supports_p2pdma(xprt))
+ server->caps |= NFS_CAP_P2PDMA;
+ rcu_read_unlock();
}
EXPORT_SYMBOL_GPL(nfs_server_set_init_caps);

diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index b48e5b87cb2a..a309cc739fa3 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -60,7 +60,7 @@ enum nfs4_client_state {
struct nfs_seqid_counter;
struct nfs4_minor_version_ops {
u32 minor_version;
- unsigned init_caps;
+ u64 init_caps;

int (*init_client)(struct nfs_client *);
void (*shutdown_client)(struct nfs_client *);
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 7a318581f85b..b2de13a355df 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -672,7 +672,7 @@ int nfs_show_stats(struct seq_file *m, struct dentry *root)
show_implementation_id(m, nfss);

seq_puts(m, "\n\tcaps:\t");
- seq_printf(m, "caps=0x%x", nfss->caps);
+ seq_printf(m, "caps=0x%llx", nfss->caps);
seq_printf(m, ",wtmult=%u", nfss->wtmult);
seq_printf(m, ",dtsize=%u", nfss->dtsize);
seq_printf(m, ",bsize=%u", nfss->bsize);
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
index 4daee27fa5eb..e66818c7a0b8 100644
--- a/include/linux/nfs_fs_sb.h
+++ b/include/linux/nfs_fs_sb.h
@@ -175,7 +175,7 @@ struct nfs_server {
#define NFS_AUTOMOUNT_INHERIT_RSIZE 0x0002
#define NFS_AUTOMOUNT_INHERIT_WSIZE 0x0004

- unsigned int caps; /* server capabilities */
+ __u64 caps; /* server capabilities */
__u64 fattr_valid; /* Valid attributes */
unsigned int rsize; /* read size */
unsigned int rpages; /* read size (in pages) */
@@ -299,36 +299,37 @@ struct nfs_server {
};

/* Server capabilities */
-#define NFS_CAP_READDIRPLUS (1U << 0)
-#define NFS_CAP_HARDLINKS (1U << 1)
-#define NFS_CAP_SYMLINKS (1U << 2)
-#define NFS_CAP_ACLS (1U << 3)
-#define NFS_CAP_ATOMIC_OPEN (1U << 4)
-#define NFS_CAP_LGOPEN (1U << 5)
-#define NFS_CAP_CASE_INSENSITIVE (1U << 6)
-#define NFS_CAP_CASE_PRESERVING (1U << 7)
-#define NFS_CAP_REBOOT_LAYOUTRETURN (1U << 8)
-#define NFS_CAP_OFFLOAD_STATUS (1U << 9)
-#define NFS_CAP_ZERO_RANGE (1U << 10)
-#define NFS_CAP_DIR_DELEG (1U << 11)
-#define NFS_CAP_OPEN_XOR (1U << 12)
-#define NFS_CAP_DELEGTIME (1U << 13)
-#define NFS_CAP_POSIX_LOCK (1U << 14)
-#define NFS_CAP_UIDGID_NOMAP (1U << 15)
-#define NFS_CAP_STATEID_NFSV41 (1U << 16)
-#define NFS_CAP_ATOMIC_OPEN_V1 (1U << 17)
-#define NFS_CAP_SECURITY_LABEL (1U << 18)
-#define NFS_CAP_SEEK (1U << 19)
-#define NFS_CAP_ALLOCATE (1U << 20)
-#define NFS_CAP_DEALLOCATE (1U << 21)
-#define NFS_CAP_LAYOUTSTATS (1U << 22)
-#define NFS_CAP_CLONE (1U << 23)
-#define NFS_CAP_COPY (1U << 24)
-#define NFS_CAP_OFFLOAD_CANCEL (1U << 25)
-#define NFS_CAP_LAYOUTERROR (1U << 26)
-#define NFS_CAP_COPY_NOTIFY (1U << 27)
-#define NFS_CAP_XATTR (1U << 28)
-#define NFS_CAP_READ_PLUS (1U << 29)
-#define NFS_CAP_FS_LOCATIONS (1U << 30)
-#define NFS_CAP_MOVEABLE (1U << 31)
+#define NFS_CAP_READDIRPLUS (1ULL << 0)
+#define NFS_CAP_HARDLINKS (1ULL << 1)
+#define NFS_CAP_SYMLINKS (1ULL << 2)
+#define NFS_CAP_ACLS (1ULL << 3)
+#define NFS_CAP_ATOMIC_OPEN (1ULL << 4)
+#define NFS_CAP_LGOPEN (1ULL << 5)
+#define NFS_CAP_CASE_INSENSITIVE (1ULL << 6)
+#define NFS_CAP_CASE_PRESERVING (1ULL << 7)
+#define NFS_CAP_REBOOT_LAYOUTRETURN (1ULL << 8)
+#define NFS_CAP_OFFLOAD_STATUS (1ULL << 9)
+#define NFS_CAP_ZERO_RANGE (1ULL << 10)
+#define NFS_CAP_DIR_DELEG (1ULL << 11)
+#define NFS_CAP_OPEN_XOR (1ULL << 12)
+#define NFS_CAP_DELEGTIME (1ULL << 13)
+#define NFS_CAP_POSIX_LOCK (1ULL << 14)
+#define NFS_CAP_UIDGID_NOMAP (1ULL << 15)
+#define NFS_CAP_STATEID_NFSV41 (1ULL << 16)
+#define NFS_CAP_ATOMIC_OPEN_V1 (1ULL << 17)
+#define NFS_CAP_SECURITY_LABEL (1ULL << 18)
+#define NFS_CAP_SEEK (1ULL << 19)
+#define NFS_CAP_ALLOCATE (1ULL << 20)
+#define NFS_CAP_DEALLOCATE (1ULL << 21)
+#define NFS_CAP_LAYOUTSTATS (1ULL << 22)
+#define NFS_CAP_CLONE (1ULL << 23)
+#define NFS_CAP_COPY (1ULL << 24)
+#define NFS_CAP_OFFLOAD_CANCEL (1ULL << 25)
+#define NFS_CAP_LAYOUTERROR (1ULL << 26)
+#define NFS_CAP_COPY_NOTIFY (1ULL << 27)
+#define NFS_CAP_XATTR (1ULL << 28)
+#define NFS_CAP_READ_PLUS (1ULL << 29)
+#define NFS_CAP_FS_LOCATIONS (1ULL << 30)
+#define NFS_CAP_MOVEABLE (1ULL << 31)
+#define NFS_CAP_P2PDMA (1ULL << 32)
#endif
--
2.53.0.1185.g05d4b7b318-goog