Tom Tucker wrote: > Store the max payload supported by the transport in the switch > instead of reaching into the socket since not all transports > (RDMA) have a socket. > > Signed-off-by: Greg Banks > Signed-off-by: Peter Leckie > Signed-off-by: Tom Tucker > --- > > include/linux/sunrpc/svcsock.h | 6 ++++++ > net/sunrpc/svc.c | 5 ++--- > net/sunrpc/svcsock.c | 2 ++ > 3 files changed, 10 insertions(+), 3 deletions(-) > > diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h > index 3faa95c..4e24e6d 100644 > --- a/include/linux/sunrpc/svcsock.h > +++ b/include/linux/sunrpc/svcsock.h > @@ -35,6 +35,12 @@ struct svc_xprt { > * Return 1 if sufficient space to write reply to network. > */ > int (*xpt_has_wspace)(struct svc_sock *); > + /* > + * Stores the largest payload (i.e. READ, WRITE or READDIR > + * data length not including NFS headers) supported by the > + * svc_sock. > + */ > + u32 xpt_max_payload; > }; Only worth 2 cents, but perhaps you could make a separate section within svc_xprt for these variables, rather than mixing them with the xpt methods. I think separating these is more traditional Linux style. I notice that the type of the client's rpc_xprt->max_payload is size_t, which may be the wrong type -- u32 might be better. > /* > diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c > index 72a900f..41f9ee0 100644 > --- a/net/sunrpc/svc.c > +++ b/net/sunrpc/svc.c > @@ -1036,10 +1036,9 @@ err_bad: > */ > u32 svc_max_payload(const struct svc_rqst *rqstp) > { > - int max = RPCSVC_MAXPAYLOAD_TCP; > + struct svc_sock *svsk = rqstp->rq_sock; > + int max = svsk->sk_xprt->xpt_max_payload; > > - if (rqstp->rq_sock->sk_sock->type == SOCK_DGRAM) > - max = RPCSVC_MAXPAYLOAD_UDP; > if (rqstp->rq_server->sv_max_payload < max) > max = rqstp->rq_server->sv_max_payload; > return max; > diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c > index b16dad4..0dc94a8 100644 > --- a/net/sunrpc/svcsock.c > +++ b/net/sunrpc/svcsock.c > @@ -897,6 +897,7 @@ static const struct svc_xprt svc_udp_xpr > .xpt_detach = svc_sock_detach, > .xpt_free = svc_sock_free, > .xpt_has_wspace = svc_udp_has_wspace, > + .xpt_max_payload = RPCSVC_MAXPAYLOAD_UDP, > }; > > static void > @@ -1368,6 +1369,7 @@ static const struct svc_xprt svc_tcp_xpr > .xpt_free = svc_sock_free, > .xpt_prep_reply_hdr = svc_tcp_prep_reply_hdr, > .xpt_has_wspace = svc_tcp_has_wspace, > + .xpt_max_payload = RPCSVC_MAXPAYLOAD_TCP, > }; > > static void