svcrdma: advertise the correct max payload
authorSteve Wise <swise@opengridcomputing.com>
Tue, 23 Sep 2014 22:11:22 +0000 (17:11 -0500)
committerJ. Bruce Fields <bfields@redhat.com>
Mon, 29 Sep 2014 18:35:18 +0000 (14:35 -0400)
Svcrdma currently advertises 1MB, which is too large.  The correct value
is the minimum of RPCSVC_MAXPAYLOAD and the max scatter-gather allowed
in an NFSRDMA IO chunk * the host page size. This bug is usually benign
because the Linux X64 NFSRDMA client correctly limits the payload size to
the correct value (64*4096 = 256KB).  But if the Linux client is PPC64
with a 64KB page size, then the client will indeed use a payload size
that will overflow the server.

Signed-off-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
net/sunrpc/xprtrdma/svc_rdma_transport.c
net/sunrpc/xprtrdma/xprt_rdma.h

index 374feb44afeacefd7c4f49fea3839b25fd0ba7c4..4e618808bc98d2960f16f4d195b2194e947374d0 100644 (file)
@@ -91,7 +91,7 @@ struct svc_xprt_class svc_rdma_class = {
        .xcl_name = "rdma",
        .xcl_owner = THIS_MODULE,
        .xcl_ops = &svc_rdma_ops,
-       .xcl_max_payload = RPCSVC_MAXPAYLOAD_TCP,
+       .xcl_max_payload = RPCSVC_MAXPAYLOAD_RDMA,
        .xcl_ident = XPRT_TRANSPORT_RDMA,
 };
 
index c419498b8f468a3a1c14bdb1a8f7f1200d32160c..ac7fc9a3134276bba8f67ad2cf9b84714ee3b3f4 100644 (file)
@@ -51,6 +51,7 @@
 #include <linux/sunrpc/clnt.h>                 /* rpc_xprt */
 #include <linux/sunrpc/rpc_rdma.h>     /* RPC/RDMA protocol */
 #include <linux/sunrpc/xprtrdma.h>     /* xprt parameters */
+#include <linux/sunrpc/svc.h>          /* RPCSVC_MAXPAYLOAD */
 
 #define RDMA_RESOLVE_TIMEOUT   (5000)  /* 5 seconds */
 #define RDMA_CONNECT_RETRY_MAX (2)     /* retries if no listener backlog */
@@ -392,4 +393,10 @@ extern struct kmem_cache *svc_rdma_ctxt_cachep;
 /* Workqueue created in svc_rdma.c */
 extern struct workqueue_struct *svc_rdma_wq;
 
+#if RPCSVC_MAXPAYLOAD < (RPCRDMA_MAX_DATA_SEGS << PAGE_SHIFT)
+#define RPCSVC_MAXPAYLOAD_RDMA RPCSVC_MAXPAYLOAD
+#else
+#define RPCSVC_MAXPAYLOAD_RDMA (RPCRDMA_MAX_DATA_SEGS << PAGE_SHIFT)
+#endif
+
 #endif                         /* _LINUX_SUNRPC_XPRT_RDMA_H */