summaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4client.c
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@hammerspace.com>2018-09-18 10:07:44 -0400
committerTrond Myklebust <trond.myklebust@hammerspace.com>2018-09-30 15:35:17 -0400
commit943cff67b842839f4f35364ba2db5c2d3f025d94 (patch)
tree01b5c6d006612a9ebe1057baa49914cbaa2e45db /fs/nfs/nfs4client.c
parentace9fad43aa60a88af4b57a8328f0958e3d07bf0 (diff)
NFSv4.1: Fix the r/wsize checking
The intention of nfs4_session_set_rwsize() was to cap the r/wsize to the buffer sizes negotiated by the CREATE_SESSION. The initial code had a bug whereby we would not check the values negotiated by nfs_probe_fsinfo() (the assumption being that CREATE_SESSION will always negotiate buffer values that are sane w.r.t. the server's preferred r/wsizes) but would only check values set by the user in the 'mount' command. The code was changed in 4.11 to _always_ set the r/wsize, meaning that we now never use the server preferred r/wsizes. This is the regression that this patch fixes. Also rename the function to nfs4_session_limit_rwsize() in order to avoid future confusion. Fixes: 033853325fe3 (NFSv4.1 respect server's max size in CREATE_SESSION") Cc: stable@vger.kernel.org # v4.11+ Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Diffstat (limited to 'fs/nfs/nfs4client.c')
-rw-r--r--fs/nfs/nfs4client.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
index 146e30862234..8f53455c4765 100644
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -950,10 +950,10 @@ EXPORT_SYMBOL_GPL(nfs4_set_ds_client);
950 950
951/* 951/*
952 * Session has been established, and the client marked ready. 952 * Session has been established, and the client marked ready.
953 * Set the mount rsize and wsize with negotiated fore channel 953 * Limit the mount rsize, wsize and dtsize using negotiated fore
954 * attributes which will be bound checked in nfs_server_set_fsinfo. 954 * channel attributes.
955 */ 955 */
956static void nfs4_session_set_rwsize(struct nfs_server *server) 956static void nfs4_session_limit_rwsize(struct nfs_server *server)
957{ 957{
958#ifdef CONFIG_NFS_V4_1 958#ifdef CONFIG_NFS_V4_1
959 struct nfs4_session *sess; 959 struct nfs4_session *sess;
@@ -966,9 +966,11 @@ static void nfs4_session_set_rwsize(struct nfs_server *server)
966 server_resp_sz = sess->fc_attrs.max_resp_sz - nfs41_maxread_overhead; 966 server_resp_sz = sess->fc_attrs.max_resp_sz - nfs41_maxread_overhead;
967 server_rqst_sz = sess->fc_attrs.max_rqst_sz - nfs41_maxwrite_overhead; 967 server_rqst_sz = sess->fc_attrs.max_rqst_sz - nfs41_maxwrite_overhead;
968 968
969 if (!server->rsize || server->rsize > server_resp_sz) 969 if (server->dtsize > server_resp_sz)
970 server->dtsize = server_resp_sz;
971 if (server->rsize > server_resp_sz)
970 server->rsize = server_resp_sz; 972 server->rsize = server_resp_sz;
971 if (!server->wsize || server->wsize > server_rqst_sz) 973 if (server->wsize > server_rqst_sz)
972 server->wsize = server_rqst_sz; 974 server->wsize = server_rqst_sz;
973#endif /* CONFIG_NFS_V4_1 */ 975#endif /* CONFIG_NFS_V4_1 */
974} 976}
@@ -1015,12 +1017,12 @@ static int nfs4_server_common_setup(struct nfs_server *server,
1015 (unsigned long long) server->fsid.minor); 1017 (unsigned long long) server->fsid.minor);
1016 nfs_display_fhandle(mntfh, "Pseudo-fs root FH"); 1018 nfs_display_fhandle(mntfh, "Pseudo-fs root FH");
1017 1019
1018 nfs4_session_set_rwsize(server);
1019
1020 error = nfs_probe_fsinfo(server, mntfh, fattr); 1020 error = nfs_probe_fsinfo(server, mntfh, fattr);
1021 if (error < 0) 1021 if (error < 0)
1022 goto out; 1022 goto out;
1023 1023
1024 nfs4_session_limit_rwsize(server);
1025
1024 if (server->namelen == 0 || server->namelen > NFS4_MAXNAMLEN) 1026 if (server->namelen == 0 || server->namelen > NFS4_MAXNAMLEN)
1025 server->namelen = NFS4_MAXNAMLEN; 1027 server->namelen = NFS4_MAXNAMLEN;
1026 1028