1
0
Fork 0

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: 033853325f (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>
hifive-unleashed-5.1
Trond Myklebust 2018-09-18 10:07:44 -04:00
parent ace9fad43a
commit 943cff67b8
1 changed files with 9 additions and 7 deletions

View File

@ -950,10 +950,10 @@ EXPORT_SYMBOL_GPL(nfs4_set_ds_client);
/* /*
* Session has been established, and the client marked ready. * Session has been established, and the client marked ready.
* Set the mount rsize and wsize with negotiated fore channel * Limit the mount rsize, wsize and dtsize using negotiated fore
* attributes which will be bound checked in nfs_server_set_fsinfo. * channel attributes.
*/ */
static void nfs4_session_set_rwsize(struct nfs_server *server) static void nfs4_session_limit_rwsize(struct nfs_server *server)
{ {
#ifdef CONFIG_NFS_V4_1 #ifdef CONFIG_NFS_V4_1
struct nfs4_session *sess; struct nfs4_session *sess;
@ -966,9 +966,11 @@ static void nfs4_session_set_rwsize(struct nfs_server *server)
server_resp_sz = sess->fc_attrs.max_resp_sz - nfs41_maxread_overhead; server_resp_sz = sess->fc_attrs.max_resp_sz - nfs41_maxread_overhead;
server_rqst_sz = sess->fc_attrs.max_rqst_sz - nfs41_maxwrite_overhead; server_rqst_sz = sess->fc_attrs.max_rqst_sz - nfs41_maxwrite_overhead;
if (!server->rsize || server->rsize > server_resp_sz) if (server->dtsize > server_resp_sz)
server->dtsize = server_resp_sz;
if (server->rsize > server_resp_sz)
server->rsize = server_resp_sz; server->rsize = server_resp_sz;
if (!server->wsize || server->wsize > server_rqst_sz) if (server->wsize > server_rqst_sz)
server->wsize = server_rqst_sz; server->wsize = server_rqst_sz;
#endif /* CONFIG_NFS_V4_1 */ #endif /* CONFIG_NFS_V4_1 */
} }
@ -1015,12 +1017,12 @@ static int nfs4_server_common_setup(struct nfs_server *server,
(unsigned long long) server->fsid.minor); (unsigned long long) server->fsid.minor);
nfs_display_fhandle(mntfh, "Pseudo-fs root FH"); nfs_display_fhandle(mntfh, "Pseudo-fs root FH");
nfs4_session_set_rwsize(server);
error = nfs_probe_fsinfo(server, mntfh, fattr); error = nfs_probe_fsinfo(server, mntfh, fattr);
if (error < 0) if (error < 0)
goto out; goto out;
nfs4_session_limit_rwsize(server);
if (server->namelen == 0 || server->namelen > NFS4_MAXNAMLEN) if (server->namelen == 0 || server->namelen > NFS4_MAXNAMLEN)
server->namelen = NFS4_MAXNAMLEN; server->namelen = NFS4_MAXNAMLEN;