Commit 2449ea2e191123729b2dc37a06fcb9d6ea7e2736

Authored by Alexandros Batsakis
Committed by Trond Myklebust
1 parent 7b183d0d43

nfs41: V2 adjust max_rqst_sz, max_resp_sz w.r.t to rsize, wsize

The v4.1 client should take into account the desired rsize, wsize when
negotiating the max size in CREATE_SESSION. Accordingly, it should use
rsize, wsize that are smaller than the session negotiated values.

Signed-off-by: Alexandros Batsakis <batsakis@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>

Showing 4 changed files with 35 additions and 4 deletions Side-by-side Diff

... ... @@ -1260,10 +1260,20 @@
1260 1260 static void nfs4_session_set_rwsize(struct nfs_server *server)
1261 1261 {
1262 1262 #ifdef CONFIG_NFS_V4_1
  1263 + struct nfs4_session *sess;
  1264 + u32 server_resp_sz;
  1265 + u32 server_rqst_sz;
  1266 +
1263 1267 if (!nfs4_has_session(server->nfs_client))
1264 1268 return;
1265   - server->rsize = server->nfs_client->cl_session->fc_attrs.max_resp_sz;
1266   - server->wsize = server->nfs_client->cl_session->fc_attrs.max_rqst_sz;
  1269 + sess = server->nfs_client->cl_session;
  1270 + server_resp_sz = sess->fc_attrs.max_resp_sz - nfs41_maxread_overhead;
  1271 + server_rqst_sz = sess->fc_attrs.max_rqst_sz - nfs41_maxwrite_overhead;
  1272 +
  1273 + if (server->rsize > server_resp_sz)
  1274 + server->rsize = server_resp_sz;
  1275 + if (server->wsize > server_rqst_sz)
  1276 + server->wsize = server_rqst_sz;
1267 1277 #endif /* CONFIG_NFS_V4_1 */
1268 1278 }
1269 1279  
... ... @@ -191,6 +191,10 @@
191 191 #ifdef CONFIG_NFS_V4
192 192 extern __be32 *nfs4_decode_dirent(__be32 *p, struct nfs_entry *entry, int plus);
193 193 #endif
  194 +#ifdef CONFIG_NFS_V4_1
  195 +extern const u32 nfs41_maxread_overhead;
  196 +extern const u32 nfs41_maxwrite_overhead;
  197 +#endif
194 198  
195 199 /* nfs4proc.c */
196 200 extern void nfs4_restart_rpc(struct rpc_task *, const struct nfs_client *,
... ... @@ -4862,13 +4862,16 @@
4862 4862 int nfs4_init_session(struct nfs_server *server)
4863 4863 {
4864 4864 struct nfs_client *clp = server->nfs_client;
  4865 + struct nfs4_session *session;
4865 4866 int ret;
4866 4867  
4867 4868 if (!nfs4_has_session(clp))
4868 4869 return 0;
4869 4870  
4870   - clp->cl_session->fc_attrs.max_rqst_sz = server->wsize;
4871   - clp->cl_session->fc_attrs.max_resp_sz = server->rsize;
  4871 + session = clp->cl_session;
  4872 + session->fc_attrs.max_rqst_sz = server->wsize + nfs41_maxwrite_overhead;
  4873 + session->fc_attrs.max_resp_sz = server->rsize + nfs41_maxread_overhead;
  4874 +
4872 4875 ret = nfs4_recover_expired_lease(server);
4873 4876 if (!ret)
4874 4877 ret = nfs4_check_client_ready(clp);
... ... @@ -46,6 +46,7 @@
46 46 #include <linux/proc_fs.h>
47 47 #include <linux/kdev_t.h>
48 48 #include <linux/sunrpc/clnt.h>
  49 +#include <linux/sunrpc/msg_prot.h>
49 50 #include <linux/nfs.h>
50 51 #include <linux/nfs4.h>
51 52 #include <linux/nfs_fs.h>
... ... @@ -677,6 +678,19 @@
677 678 decode_sequence_maxsz + \
678 679 decode_putrootfh_maxsz + \
679 680 decode_fsinfo_maxsz)
  681 +
  682 +const u32 nfs41_maxwrite_overhead = ((RPC_MAX_HEADER_WITH_AUTH +
  683 + compound_encode_hdr_maxsz +
  684 + encode_sequence_maxsz +
  685 + encode_putfh_maxsz +
  686 + encode_getattr_maxsz) *
  687 + XDR_UNIT);
  688 +
  689 +const u32 nfs41_maxread_overhead = ((RPC_MAX_HEADER_WITH_AUTH +
  690 + compound_decode_hdr_maxsz +
  691 + decode_sequence_maxsz +
  692 + decode_putfh_maxsz) *
  693 + XDR_UNIT);
680 694 #endif /* CONFIG_NFS_V4_1 */
681 695  
682 696 static const umode_t nfs_type2fmt[] = {