Skip to content

Commit 943cff6

Browse files
author
Trond Myklebust
committed
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: 0338533 (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>
1 parent ace9fad commit 943cff6

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

fs/nfs/nfs4client.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -950,10 +950,10 @@ EXPORT_SYMBOL_GPL(nfs4_set_ds_client);
950950

951951
/*
952952
* Session has been established, and the client marked ready.
953-
* Set the mount rsize and wsize with negotiated fore channel
954-
* attributes which will be bound checked in nfs_server_set_fsinfo.
953+
* Limit the mount rsize, wsize and dtsize using negotiated fore
954+
* channel attributes.
955955
*/
956-
static void nfs4_session_set_rwsize(struct nfs_server *server)
956+
static void nfs4_session_limit_rwsize(struct nfs_server *server)
957957
{
958958
#ifdef CONFIG_NFS_V4_1
959959
struct nfs4_session *sess;
@@ -966,9 +966,11 @@ static void nfs4_session_set_rwsize(struct nfs_server *server)
966966
server_resp_sz = sess->fc_attrs.max_resp_sz - nfs41_maxread_overhead;
967967
server_rqst_sz = sess->fc_attrs.max_rqst_sz - nfs41_maxwrite_overhead;
968968

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)
970972
server->rsize = server_resp_sz;
971-
if (!server->wsize || server->wsize > server_rqst_sz)
973+
if (server->wsize > server_rqst_sz)
972974
server->wsize = server_rqst_sz;
973975
#endif /* CONFIG_NFS_V4_1 */
974976
}
@@ -1015,12 +1017,12 @@ static int nfs4_server_common_setup(struct nfs_server *server,
10151017
(unsigned long long) server->fsid.minor);
10161018
nfs_display_fhandle(mntfh, "Pseudo-fs root FH");
10171019

1018-
nfs4_session_set_rwsize(server);
1019-
10201020
error = nfs_probe_fsinfo(server, mntfh, fattr);
10211021
if (error < 0)
10221022
goto out;
10231023

1024+
nfs4_session_limit_rwsize(server);
1025+
10241026
if (server->namelen == 0 || server->namelen > NFS4_MAXNAMLEN)
10251027
server->namelen = NFS4_MAXNAMLEN;
10261028

0 commit comments

Comments
 (0)