nfs41: V2 adjust max_rqst_sz, max_resp_sz w.r.t to rsize, wsize
Subsystems (2)
PATCH 1/10 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 <[email protected]>
--- fs/nfs/client.c | 14 ++++++++++++-- fs/nfs/internal.h | 4 ++++ fs/nfs/nfs4proc.c | 7 +++++-- fs/nfs/nfs4xdr.c | 14 ++++++++++++++ 4 files changed, 35 insertions(+), 4 deletions(-)
fs/nfs/client.c +12 -2
@@ -1260,10 +1260,20 @@ error:static void nfs4_session_set_rwsize (struct nfs_server *server) {#ifdef CONFIG_NFS_V4_1 +struct nfs4_session *sess; +u32 server_resp_sz; +u32 server_rqst_sz; +if (!nfs4_has_session (server->nfs_client))return ; - server->rsize = server->nfs_client->cl_session->fc_attrs.max_resp_sz; - server->wsize = server->nfs_client->cl_session->fc_attrs.max_rqst_sz; + sess = server->nfs_client->cl_session; + server_resp_sz = sess->fc_attrs.max_resp_sz - nfs41_maxread_overhead; + server_rqst_sz = sess->fc_attrs.max_rqst_sz - nfs41_maxwrite_overhead; + +if (server->rsize > server_resp_sz) + server->rsize = server_resp_sz; +if (server->wsize > server_rqst_sz) + server->wsize = server_rqst_sz;#endif /* CONFIG_NFS_V4_1 */ }
fs/nfs/internal.h +4 -0
@@ -195,6 +195,10 @@ static inline void nfs4_restart_rpc(struct rpc_task *task,#ifdef CONFIG_NFS_V4 extern __be32 *nfs4_decode_dirent (__be32 *p,struct nfs_entry *entry,int plus);#endif +#ifdef CONFIG_NFS_V4_1 +extern const u32 nfs41_maxread_overhead; +extern const u32 nfs41_maxwrite_overhead; +#endif /* nfs4proc.c */ #ifdef CONFIG_NFS_V4
fs/nfs/nfs4proc.c +5 -2
@@ -4827,13 +4827,16 @@ int nfs4_proc_destroy_session(struct nfs4_session *session)int nfs4_init_session (struct nfs_server *server) {struct nfs_client *clp = server->nfs_client; +struct nfs4_session *session;int ret;if (!nfs4_has_session (clp))return 0 ; - clp->cl_session->fc_attrs.max_rqst_sz = server->wsize; - clp->cl_session->fc_attrs.max_resp_sz = server->rsize; + session = clp->cl_session; + session->fc_attrs.max_rqst_sz = server->wsize + nfs41_maxwrite_overhead; + session->fc_attrs.max_resp_sz = server->rsize + nfs41_maxread_overhead; + ret =nfs4_recover_expired_lease (server);if (!ret) ret =nfs4_check_client_ready (clp);
fs/nfs/nfs4xdr.c +14 -0
@@ -46,6 +46,7 @@#include <linux/proc_fs.h> #include <linux/kdev_t.h> #include <linux/sunrpc/clnt.h> +#include <linux/sunrpc/msg_prot.h> #include <linux/nfs.h> #include <linux/nfs4.h> #include <linux/nfs_fs.h>
@@ -676,6 +677,19 @@ static int nfs4_stat_to_errno(int); decode_sequence_maxsz + \ decode_putrootfh_maxsz + \ decode_fsinfo_maxsz) + +const u32 nfs41_maxwrite_overhead = ((RPC_MAX_HEADER_WITH_AUTH + + compound_encode_hdr_maxsz + + encode_sequence_maxsz + + encode_putfh_maxsz + + encode_getattr_maxsz) * +XDR_UNIT ); + +const u32 nfs41_maxread_overhead = ((RPC_MAX_HEADER_WITH_AUTH + + compound_decode_hdr_maxsz + + decode_sequence_maxsz + + decode_putfh_maxsz) * +XDR_UNIT );#endif /* CONFIG_NFS_V4_1 */ static const umode_t nfs_type2fmt[] = {
Signature · 1 line
1.6.2.5
PATCH 3/10 nfs41: v2 fix cb_recall bug
in NFSv4.1 the seqid part of a stateid in CB_RECALL must be 0
Signed-off-by Alexandros Batsakis <[email protected]>
--- fs/nfs/callback.h | 6 ++++-- fs/nfs/callback_proc.c | 37 +++++++++++++++++++++++++++++++++++-- fs/nfs/delegation.c | 9 ++++++--- fs/nfs/delegation.h | 4 +++- 4 files changed, 48 insertions(+), 8 deletions(-)
fs/nfs/callback.h +4 -2
@@ -105,7 +105,8 @@ struct cb_sequenceres {extern unsigned nfs4_callback_sequence (struct cb_sequenceargs *args,struct cb_sequenceres *res); - +extern int nfs41_validate_delegation_stateid (struct nfs_delegation *delegation, +const nfs4_stateid *stateid);#endif /* CONFIG_NFS_V4_1 */ extern __be32 nfs4_callback_getattr (struct cb_getattrargs *args,struct cb_getattrres *res);
@@ -114,8 +115,9 @@ extern __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy);#ifdef CONFIG_NFS_V4 extern int nfs_callback_up (u32 minorversion,struct rpc_xprt *xprt);extern void nfs_callback_down (int minorversion); +extern int nfs4_validate_delegation_stateid (struct nfs_delegation *delegation, +const nfs4_stateid *stateid);#endif /* CONFIG_NFS_V4 */ -/* * nfs41: Callbacks are expected to not cause substantial latency, * so we limit their concurrency to 1 by setting up the maximum number
fs/nfs/callback_proc.c +35 -2
@@ -61,6 +61,16 @@ out:return res->status; } +static int (*nfs_validate_delegation_stateid (struct nfs_client *clp))(struct nfs_delegation *,const nfs4_stateid *) +{ +#if defined(CONFIG_NFS_V4_1 ) +if (clp->cl_minorversion >0 ) +return nfs41_validate_delegation_stateid; +#endif +return nfs4_validate_delegation_stateid; +} + +__be32 nfs4_callback_recall (struct cb_recallargs *args,void *dummy) {struct nfs_client *clp;
@@ -81,7 +91,8 @@ __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy) inode =nfs_delegation_find_inode (clp, &args->fh);if (inode !=NULL ) {/* Set up a helper thread to actually return the delegation */ -switch (nfs_async_inode_return_delegation (inode, &args->stateid)) { +switch (nfs_async_inode_return_delegation (inode, &args->stateid, +nfs_validate_delegation_stateid (clp))) {case 0 : res =0 ;break ;
@@ -102,8 +113,31 @@ out:return res; } +int nfs4_validate_delegation_stateid (struct nfs_delegation *delegation,const nfs4_stateid *stateid) +{ +if (delegation ==NULL ||memcmp (delegation->stateid.data, stateid->data, +sizeof (delegation->stateid.data)) !=0 ) +return 0 ; +return 1 ; +} +#if defined(CONFIG_NFS_V4_1 ) +int nfs41_validate_delegation_stateid (struct nfs_delegation *delegation,const nfs4_stateid *stateid) +{ +if (delegation ==NULL ) +return 0 ; + +/* seqid is 4-bytes long */ +if (((u32 *) &stateid->data)[0 ] !=0 ) +return 0 ; +if (memcmp (&delegation->stateid.data[4 ], &stateid->data[4 ], +sizeof (stateid->data)-4 )) +return 0 ; + +return 1 ; +} +/* * Validate the sequenceID sent by the server. * Return success if the sequenceID is one more than what we last saw on
@@ -226,5 +260,4 @@ out: res->csr_status = status; return res->csr_status; } -#endif /* CONFIG_NFS_V4_1 */
fs/nfs/delegation.c +6 -3
@@ -428,18 +428,21 @@ void nfs_expire_unreferenced_delegations(struct nfs_client *clp)/* * Asynchronous delegation recall! */ -int nfs_async_inode_return_delegation (struct inode *inode,const nfs4_stateid *stateid) +int nfs_async_inode_return_delegation (struct inode *inode,const nfs4_stateid *stateid, +int (*validate_stateid)(struct nfs_delegation *delegation, +const nfs4_stateid *stateid)) {struct nfs_client *clp =NFS_SERVER (inode)->nfs_client;struct nfs_delegation *delegation;rcu_read_lock (); delegation =rcu_dereference (NFS_I (inode)->delegation); -if (delegation ==NULL ||memcmp (delegation->stateid.data, stateid->data, -sizeof (delegation->stateid.data)) !=0 ) { + +if (!validate_stateid (delegation, stateid)) {rcu_read_unlock ();return -ENOENT ; } +nfs_mark_return_delegation (clp, delegation);rcu_read_unlock ();nfs_delegation_run_state_manager (clp);
fs/nfs/delegation.h +3 -1
@@ -34,7 +34,9 @@ enum {int nfs_inode_set_delegation (struct inode *inode,struct rpc_cred *cred,struct nfs_openres *res);void nfs_inode_reclaim_delegation (struct inode *inode,struct rpc_cred *cred,struct nfs_openres *res);int nfs_inode_return_delegation (struct inode *inode); -int nfs_async_inode_return_delegation (struct inode *inode,const nfs4_stateid *stateid); +int nfs_async_inode_return_delegation (struct inode *inode,const nfs4_stateid *stateid, +int (*validate_stateid)(struct nfs_delegation *delegation, +const nfs4_stateid *stateid));void nfs_inode_return_delegation_noreclaim (struct inode *inode);struct inode *nfs_delegation_find_inode (struct nfs_client *clp,const struct nfs_fh *fhandle);
Signature · 1 line
1.6.2.5