diff options
-rw-r--r-- | fs/nfs/callback.c | 13 | ||||
-rw-r--r-- | fs/nfs/callback.h | 16 | ||||
-rw-r--r-- | fs/nfs/callback_proc.c | 64 | ||||
-rw-r--r-- | fs/nfs/callback_xdr.c | 34 | ||||
-rw-r--r-- | fs/nfs/client.c | 14 | ||||
-rw-r--r-- | fs/nfs/delegation.c | 77 | ||||
-rw-r--r-- | fs/nfs/delegation.h | 7 | ||||
-rw-r--r-- | fs/nfs/dir.c | 67 | ||||
-rw-r--r-- | fs/nfs/dns_resolve.c | 4 | ||||
-rw-r--r-- | fs/nfs/internal.h | 54 | ||||
-rw-r--r-- | fs/nfs/nfs4_fs.h | 12 | ||||
-rw-r--r-- | fs/nfs/nfs4proc.c | 458 | ||||
-rw-r--r-- | fs/nfs/nfs4state.c | 225 | ||||
-rw-r--r-- | fs/nfs/nfs4xdr.c | 135 | ||||
-rw-r--r-- | fs/nfs/read.c | 12 | ||||
-rw-r--r-- | fs/nfs/super.c | 104 | ||||
-rw-r--r-- | fs/nfs/unlink.c | 2 | ||||
-rw-r--r-- | fs/nfs/write.c | 8 | ||||
-rw-r--r-- | include/linux/nfs4.h | 3 | ||||
-rw-r--r-- | include/linux/nfs_fs_sb.h | 1 | ||||
-rw-r--r-- | include/linux/nfs_xdr.h | 13 | ||||
-rw-r--r-- | include/linux/sunrpc/sched.h | 2 | ||||
-rw-r--r-- | net/sunrpc/addr.c | 10 | ||||
-rw-r--r-- | net/sunrpc/auth.c | 39 | ||||
-rw-r--r-- | net/sunrpc/auth_gss/auth_gss.c | 6 | ||||
-rw-r--r-- | net/sunrpc/clnt.c | 54 | ||||
-rw-r--r-- | net/sunrpc/rpcb_clnt.c | 104 | ||||
-rw-r--r-- | net/sunrpc/sunrpc_syms.c | 3 | ||||
-rw-r--r-- | net/sunrpc/xprt.c | 4 | ||||
-rw-r--r-- | net/sunrpc/xprtsock.c | 2 |
30 files changed, 1078 insertions, 469 deletions
diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c index 293fa0528a6e..73ab220354df 100644 --- a/fs/nfs/callback.c +++ b/fs/nfs/callback.c | |||
@@ -78,11 +78,6 @@ nfs4_callback_svc(void *vrqstp) | |||
78 | 78 | ||
79 | set_freezable(); | 79 | set_freezable(); |
80 | 80 | ||
81 | /* | ||
82 | * FIXME: do we really need to run this under the BKL? If so, please | ||
83 | * add a comment about what it's intended to protect. | ||
84 | */ | ||
85 | lock_kernel(); | ||
86 | while (!kthread_should_stop()) { | 81 | while (!kthread_should_stop()) { |
87 | /* | 82 | /* |
88 | * Listen for a request on the socket | 83 | * Listen for a request on the socket |
@@ -104,7 +99,6 @@ nfs4_callback_svc(void *vrqstp) | |||
104 | preverr = err; | 99 | preverr = err; |
105 | svc_process(rqstp); | 100 | svc_process(rqstp); |
106 | } | 101 | } |
107 | unlock_kernel(); | ||
108 | return 0; | 102 | return 0; |
109 | } | 103 | } |
110 | 104 | ||
@@ -160,11 +154,6 @@ nfs41_callback_svc(void *vrqstp) | |||
160 | 154 | ||
161 | set_freezable(); | 155 | set_freezable(); |
162 | 156 | ||
163 | /* | ||
164 | * FIXME: do we really need to run this under the BKL? If so, please | ||
165 | * add a comment about what it's intended to protect. | ||
166 | */ | ||
167 | lock_kernel(); | ||
168 | while (!kthread_should_stop()) { | 157 | while (!kthread_should_stop()) { |
169 | prepare_to_wait(&serv->sv_cb_waitq, &wq, TASK_INTERRUPTIBLE); | 158 | prepare_to_wait(&serv->sv_cb_waitq, &wq, TASK_INTERRUPTIBLE); |
170 | spin_lock_bh(&serv->sv_cb_lock); | 159 | spin_lock_bh(&serv->sv_cb_lock); |
@@ -183,7 +172,6 @@ nfs41_callback_svc(void *vrqstp) | |||
183 | } | 172 | } |
184 | finish_wait(&serv->sv_cb_waitq, &wq); | 173 | finish_wait(&serv->sv_cb_waitq, &wq); |
185 | } | 174 | } |
186 | unlock_kernel(); | ||
187 | return 0; | 175 | return 0; |
188 | } | 176 | } |
189 | 177 | ||
@@ -397,6 +385,7 @@ static int nfs_callback_authenticate(struct svc_rqst *rqstp) | |||
397 | */ | 385 | */ |
398 | static struct svc_version *nfs4_callback_version[] = { | 386 | static struct svc_version *nfs4_callback_version[] = { |
399 | [1] = &nfs4_callback_version1, | 387 | [1] = &nfs4_callback_version1, |
388 | [4] = &nfs4_callback_version4, | ||
400 | }; | 389 | }; |
401 | 390 | ||
402 | static struct svc_stat nfs4_callback_stats; | 391 | static struct svc_stat nfs4_callback_stats; |
diff --git a/fs/nfs/callback.h b/fs/nfs/callback.h index 07baa8254ca1..d4036be0b589 100644 --- a/fs/nfs/callback.h +++ b/fs/nfs/callback.h | |||
@@ -106,6 +106,19 @@ struct cb_sequenceres { | |||
106 | extern unsigned nfs4_callback_sequence(struct cb_sequenceargs *args, | 106 | extern unsigned nfs4_callback_sequence(struct cb_sequenceargs *args, |
107 | struct cb_sequenceres *res); | 107 | struct cb_sequenceres *res); |
108 | 108 | ||
109 | extern int nfs41_validate_delegation_stateid(struct nfs_delegation *delegation, | ||
110 | const nfs4_stateid *stateid); | ||
111 | |||
112 | #define RCA4_TYPE_MASK_RDATA_DLG 0 | ||
113 | #define RCA4_TYPE_MASK_WDATA_DLG 1 | ||
114 | |||
115 | struct cb_recallanyargs { | ||
116 | struct sockaddr *craa_addr; | ||
117 | uint32_t craa_objs_to_keep; | ||
118 | uint32_t craa_type_mask; | ||
119 | }; | ||
120 | |||
121 | extern unsigned nfs4_callback_recallany(struct cb_recallanyargs *args, void *dummy); | ||
109 | #endif /* CONFIG_NFS_V4_1 */ | 122 | #endif /* CONFIG_NFS_V4_1 */ |
110 | 123 | ||
111 | extern __be32 nfs4_callback_getattr(struct cb_getattrargs *args, struct cb_getattrres *res); | 124 | extern __be32 nfs4_callback_getattr(struct cb_getattrargs *args, struct cb_getattrres *res); |
@@ -114,8 +127,9 @@ extern __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy); | |||
114 | #ifdef CONFIG_NFS_V4 | 127 | #ifdef CONFIG_NFS_V4 |
115 | extern int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt); | 128 | extern int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt); |
116 | extern void nfs_callback_down(int minorversion); | 129 | extern void nfs_callback_down(int minorversion); |
130 | extern int nfs4_validate_delegation_stateid(struct nfs_delegation *delegation, | ||
131 | const nfs4_stateid *stateid); | ||
117 | #endif /* CONFIG_NFS_V4 */ | 132 | #endif /* CONFIG_NFS_V4 */ |
118 | |||
119 | /* | 133 | /* |
120 | * nfs41: Callbacks are expected to not cause substantial latency, | 134 | * nfs41: Callbacks are expected to not cause substantial latency, |
121 | * so we limit their concurrency to 1 by setting up the maximum number | 135 | * so we limit their concurrency to 1 by setting up the maximum number |
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c index b7da1f54da68..defa9b4c470e 100644 --- a/fs/nfs/callback_proc.c +++ b/fs/nfs/callback_proc.c | |||
@@ -61,6 +61,16 @@ out: | |||
61 | return res->status; | 61 | return res->status; |
62 | } | 62 | } |
63 | 63 | ||
64 | static int (*nfs_validate_delegation_stateid(struct nfs_client *clp))(struct nfs_delegation *, const nfs4_stateid *) | ||
65 | { | ||
66 | #if defined(CONFIG_NFS_V4_1) | ||
67 | if (clp->cl_minorversion > 0) | ||
68 | return nfs41_validate_delegation_stateid; | ||
69 | #endif | ||
70 | return nfs4_validate_delegation_stateid; | ||
71 | } | ||
72 | |||
73 | |||
64 | __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy) | 74 | __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy) |
65 | { | 75 | { |
66 | struct nfs_client *clp; | 76 | struct nfs_client *clp; |
@@ -81,7 +91,8 @@ __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy) | |||
81 | inode = nfs_delegation_find_inode(clp, &args->fh); | 91 | inode = nfs_delegation_find_inode(clp, &args->fh); |
82 | if (inode != NULL) { | 92 | if (inode != NULL) { |
83 | /* Set up a helper thread to actually return the delegation */ | 93 | /* Set up a helper thread to actually return the delegation */ |
84 | switch(nfs_async_inode_return_delegation(inode, &args->stateid)) { | 94 | switch (nfs_async_inode_return_delegation(inode, &args->stateid, |
95 | nfs_validate_delegation_stateid(clp))) { | ||
85 | case 0: | 96 | case 0: |
86 | res = 0; | 97 | res = 0; |
87 | break; | 98 | break; |
@@ -102,8 +113,31 @@ out: | |||
102 | return res; | 113 | return res; |
103 | } | 114 | } |
104 | 115 | ||
116 | int nfs4_validate_delegation_stateid(struct nfs_delegation *delegation, const nfs4_stateid *stateid) | ||
117 | { | ||
118 | if (delegation == NULL || memcmp(delegation->stateid.data, stateid->data, | ||
119 | sizeof(delegation->stateid.data)) != 0) | ||
120 | return 0; | ||
121 | return 1; | ||
122 | } | ||
123 | |||
105 | #if defined(CONFIG_NFS_V4_1) | 124 | #if defined(CONFIG_NFS_V4_1) |
106 | 125 | ||
126 | int nfs41_validate_delegation_stateid(struct nfs_delegation *delegation, const nfs4_stateid *stateid) | ||
127 | { | ||
128 | if (delegation == NULL) | ||
129 | return 0; | ||
130 | |||
131 | /* seqid is 4-bytes long */ | ||
132 | if (((u32 *) &stateid->data)[0] != 0) | ||
133 | return 0; | ||
134 | if (memcmp(&delegation->stateid.data[4], &stateid->data[4], | ||
135 | sizeof(stateid->data)-4)) | ||
136 | return 0; | ||
137 | |||
138 | return 1; | ||
139 | } | ||
140 | |||
107 | /* | 141 | /* |
108 | * Validate the sequenceID sent by the server. | 142 | * Validate the sequenceID sent by the server. |
109 | * Return success if the sequenceID is one more than what we last saw on | 143 | * Return success if the sequenceID is one more than what we last saw on |
@@ -227,4 +261,32 @@ out: | |||
227 | return res->csr_status; | 261 | return res->csr_status; |
228 | } | 262 | } |
229 | 263 | ||
264 | unsigned nfs4_callback_recallany(struct cb_recallanyargs *args, void *dummy) | ||
265 | { | ||
266 | struct nfs_client *clp; | ||
267 | int status; | ||
268 | fmode_t flags = 0; | ||
269 | |||
270 | status = htonl(NFS4ERR_OP_NOT_IN_SESSION); | ||
271 | clp = nfs_find_client(args->craa_addr, 4); | ||
272 | if (clp == NULL) | ||
273 | goto out; | ||
274 | |||
275 | dprintk("NFS: RECALL_ANY callback request from %s\n", | ||
276 | rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR)); | ||
277 | |||
278 | if (test_bit(RCA4_TYPE_MASK_RDATA_DLG, (const unsigned long *) | ||
279 | &args->craa_type_mask)) | ||
280 | flags = FMODE_READ; | ||
281 | if (test_bit(RCA4_TYPE_MASK_WDATA_DLG, (const unsigned long *) | ||
282 | &args->craa_type_mask)) | ||
283 | flags |= FMODE_WRITE; | ||
284 | |||
285 | if (flags) | ||
286 | nfs_expire_all_delegation_types(clp, flags); | ||
287 | status = htonl(NFS4_OK); | ||
288 | out: | ||
289 | dprintk("%s: exit with status = %d\n", __func__, ntohl(status)); | ||
290 | return status; | ||
291 | } | ||
230 | #endif /* CONFIG_NFS_V4_1 */ | 292 | #endif /* CONFIG_NFS_V4_1 */ |
diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c index 76b0aa0f73bf..8e1a2511c8be 100644 --- a/fs/nfs/callback_xdr.c +++ b/fs/nfs/callback_xdr.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #if defined(CONFIG_NFS_V4_1) | 23 | #if defined(CONFIG_NFS_V4_1) |
24 | #define CB_OP_SEQUENCE_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ + \ | 24 | #define CB_OP_SEQUENCE_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ + \ |
25 | 4 + 1 + 3) | 25 | 4 + 1 + 3) |
26 | #define CB_OP_RECALLANY_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) | ||
26 | #endif /* CONFIG_NFS_V4_1 */ | 27 | #endif /* CONFIG_NFS_V4_1 */ |
27 | 28 | ||
28 | #define NFSDBG_FACILITY NFSDBG_CALLBACK | 29 | #define NFSDBG_FACILITY NFSDBG_CALLBACK |
@@ -326,6 +327,25 @@ out_free: | |||
326 | goto out; | 327 | goto out; |
327 | } | 328 | } |
328 | 329 | ||
330 | static unsigned decode_recallany_args(struct svc_rqst *rqstp, | ||
331 | struct xdr_stream *xdr, | ||
332 | struct cb_recallanyargs *args) | ||
333 | { | ||
334 | uint32_t *p; | ||
335 | |||
336 | args->craa_addr = svc_addr(rqstp); | ||
337 | p = read_buf(xdr, 4); | ||
338 | if (unlikely(p == NULL)) | ||
339 | return htonl(NFS4ERR_BADXDR); | ||
340 | args->craa_objs_to_keep = ntohl(*p++); | ||
341 | p = read_buf(xdr, 4); | ||
342 | if (unlikely(p == NULL)) | ||
343 | return htonl(NFS4ERR_BADXDR); | ||
344 | args->craa_type_mask = ntohl(*p); | ||
345 | |||
346 | return 0; | ||
347 | } | ||
348 | |||
329 | #endif /* CONFIG_NFS_V4_1 */ | 349 | #endif /* CONFIG_NFS_V4_1 */ |
330 | 350 | ||
331 | static __be32 encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) | 351 | static __be32 encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) |
@@ -533,6 +553,7 @@ preprocess_nfs41_op(int nop, unsigned int op_nr, struct callback_op **op) | |||
533 | case OP_CB_GETATTR: | 553 | case OP_CB_GETATTR: |
534 | case OP_CB_RECALL: | 554 | case OP_CB_RECALL: |
535 | case OP_CB_SEQUENCE: | 555 | case OP_CB_SEQUENCE: |
556 | case OP_CB_RECALL_ANY: | ||
536 | *op = &callback_ops[op_nr]; | 557 | *op = &callback_ops[op_nr]; |
537 | break; | 558 | break; |
538 | 559 | ||
@@ -540,7 +561,6 @@ preprocess_nfs41_op(int nop, unsigned int op_nr, struct callback_op **op) | |||
540 | case OP_CB_NOTIFY_DEVICEID: | 561 | case OP_CB_NOTIFY_DEVICEID: |
541 | case OP_CB_NOTIFY: | 562 | case OP_CB_NOTIFY: |
542 | case OP_CB_PUSH_DELEG: | 563 | case OP_CB_PUSH_DELEG: |
543 | case OP_CB_RECALL_ANY: | ||
544 | case OP_CB_RECALLABLE_OBJ_AVAIL: | 564 | case OP_CB_RECALLABLE_OBJ_AVAIL: |
545 | case OP_CB_RECALL_SLOT: | 565 | case OP_CB_RECALL_SLOT: |
546 | case OP_CB_WANTS_CANCELLED: | 566 | case OP_CB_WANTS_CANCELLED: |
@@ -688,6 +708,11 @@ static struct callback_op callback_ops[] = { | |||
688 | .encode_res = (callback_encode_res_t)encode_cb_sequence_res, | 708 | .encode_res = (callback_encode_res_t)encode_cb_sequence_res, |
689 | .res_maxsize = CB_OP_SEQUENCE_RES_MAXSZ, | 709 | .res_maxsize = CB_OP_SEQUENCE_RES_MAXSZ, |
690 | }, | 710 | }, |
711 | [OP_CB_RECALL_ANY] = { | ||
712 | .process_op = (callback_process_op_t)nfs4_callback_recallany, | ||
713 | .decode_args = (callback_decode_arg_t)decode_recallany_args, | ||
714 | .res_maxsize = CB_OP_RECALLANY_RES_MAXSZ, | ||
715 | }, | ||
691 | #endif /* CONFIG_NFS_V4_1 */ | 716 | #endif /* CONFIG_NFS_V4_1 */ |
692 | }; | 717 | }; |
693 | 718 | ||
@@ -718,3 +743,10 @@ struct svc_version nfs4_callback_version1 = { | |||
718 | .vs_dispatch = NULL, | 743 | .vs_dispatch = NULL, |
719 | }; | 744 | }; |
720 | 745 | ||
746 | struct svc_version nfs4_callback_version4 = { | ||
747 | .vs_vers = 4, | ||
748 | .vs_nproc = ARRAY_SIZE(nfs4_callback_procedures1), | ||
749 | .vs_proc = nfs4_callback_procedures1, | ||
750 | .vs_xdrsize = NFS4_CALLBACK_XDRSIZE, | ||
751 | .vs_dispatch = NULL, | ||
752 | }; | ||
diff --git a/fs/nfs/client.c b/fs/nfs/client.c index 99ea196f071f..ee77713ce68b 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c | |||
@@ -1260,10 +1260,20 @@ error: | |||
1260 | static void nfs4_session_set_rwsize(struct nfs_server *server) | 1260 | static void nfs4_session_set_rwsize(struct nfs_server *server) |
1261 | { | 1261 | { |
1262 | #ifdef CONFIG_NFS_V4_1 | 1262 | #ifdef CONFIG_NFS_V4_1 |
1263 | struct nfs4_session *sess; | ||
1264 | u32 server_resp_sz; | ||
1265 | u32 server_rqst_sz; | ||
1266 | |||
1263 | if (!nfs4_has_session(server->nfs_client)) | 1267 | if (!nfs4_has_session(server->nfs_client)) |
1264 | return; | 1268 | return; |
1265 | server->rsize = server->nfs_client->cl_session->fc_attrs.max_resp_sz; | 1269 | sess = server->nfs_client->cl_session; |
1266 | server->wsize = server->nfs_client->cl_session->fc_attrs.max_rqst_sz; | 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 | #endif /* CONFIG_NFS_V4_1 */ | 1277 | #endif /* CONFIG_NFS_V4_1 */ |
1268 | } | 1278 | } |
1269 | 1279 | ||
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 6dd48a4405b4..2563bebc4c67 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c | |||
@@ -92,7 +92,7 @@ out: | |||
92 | return status; | 92 | return status; |
93 | } | 93 | } |
94 | 94 | ||
95 | static void nfs_delegation_claim_opens(struct inode *inode, const nfs4_stateid *stateid) | 95 | static int nfs_delegation_claim_opens(struct inode *inode, const nfs4_stateid *stateid) |
96 | { | 96 | { |
97 | struct nfs_inode *nfsi = NFS_I(inode); | 97 | struct nfs_inode *nfsi = NFS_I(inode); |
98 | struct nfs_open_context *ctx; | 98 | struct nfs_open_context *ctx; |
@@ -116,10 +116,11 @@ again: | |||
116 | err = nfs_delegation_claim_locks(ctx, state); | 116 | err = nfs_delegation_claim_locks(ctx, state); |
117 | put_nfs_open_context(ctx); | 117 | put_nfs_open_context(ctx); |
118 | if (err != 0) | 118 | if (err != 0) |
119 | return; | 119 | return err; |
120 | goto again; | 120 | goto again; |
121 | } | 121 | } |
122 | spin_unlock(&inode->i_lock); | 122 | spin_unlock(&inode->i_lock); |
123 | return 0; | ||
123 | } | 124 | } |
124 | 125 | ||
125 | /* | 126 | /* |
@@ -261,30 +262,34 @@ static void nfs_msync_inode(struct inode *inode) | |||
261 | /* | 262 | /* |
262 | * Basic procedure for returning a delegation to the server | 263 | * Basic procedure for returning a delegation to the server |
263 | */ | 264 | */ |
264 | static int __nfs_inode_return_delegation(struct inode *inode, struct nfs_delegation *delegation) | 265 | static int __nfs_inode_return_delegation(struct inode *inode, struct nfs_delegation *delegation, int issync) |
265 | { | 266 | { |
266 | struct nfs_inode *nfsi = NFS_I(inode); | 267 | struct nfs_inode *nfsi = NFS_I(inode); |
268 | int err; | ||
267 | 269 | ||
268 | nfs_msync_inode(inode); | ||
269 | /* | 270 | /* |
270 | * Guard against new delegated open/lock/unlock calls and against | 271 | * Guard against new delegated open/lock/unlock calls and against |
271 | * state recovery | 272 | * state recovery |
272 | */ | 273 | */ |
273 | down_write(&nfsi->rwsem); | 274 | down_write(&nfsi->rwsem); |
274 | nfs_delegation_claim_opens(inode, &delegation->stateid); | 275 | err = nfs_delegation_claim_opens(inode, &delegation->stateid); |
275 | up_write(&nfsi->rwsem); | 276 | up_write(&nfsi->rwsem); |
276 | nfs_msync_inode(inode); | 277 | if (err) |
278 | goto out; | ||
277 | 279 | ||
278 | return nfs_do_return_delegation(inode, delegation, 1); | 280 | err = nfs_do_return_delegation(inode, delegation, issync); |
281 | out: | ||
282 | return err; | ||
279 | } | 283 | } |
280 | 284 | ||
281 | /* | 285 | /* |
282 | * Return all delegations that have been marked for return | 286 | * Return all delegations that have been marked for return |
283 | */ | 287 | */ |
284 | void nfs_client_return_marked_delegations(struct nfs_client *clp) | 288 | int nfs_client_return_marked_delegations(struct nfs_client *clp) |
285 | { | 289 | { |
286 | struct nfs_delegation *delegation; | 290 | struct nfs_delegation *delegation; |
287 | struct inode *inode; | 291 | struct inode *inode; |
292 | int err = 0; | ||
288 | 293 | ||
289 | restart: | 294 | restart: |
290 | rcu_read_lock(); | 295 | rcu_read_lock(); |
@@ -298,12 +303,18 @@ restart: | |||
298 | delegation = nfs_detach_delegation_locked(NFS_I(inode), NULL); | 303 | delegation = nfs_detach_delegation_locked(NFS_I(inode), NULL); |
299 | spin_unlock(&clp->cl_lock); | 304 | spin_unlock(&clp->cl_lock); |
300 | rcu_read_unlock(); | 305 | rcu_read_unlock(); |
301 | if (delegation != NULL) | 306 | if (delegation != NULL) { |
302 | __nfs_inode_return_delegation(inode, delegation); | 307 | filemap_flush(inode->i_mapping); |
308 | err = __nfs_inode_return_delegation(inode, delegation, 0); | ||
309 | } | ||
303 | iput(inode); | 310 | iput(inode); |
304 | goto restart; | 311 | if (!err) |
312 | goto restart; | ||
313 | set_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state); | ||
314 | return err; | ||
305 | } | 315 | } |
306 | rcu_read_unlock(); | 316 | rcu_read_unlock(); |
317 | return 0; | ||
307 | } | 318 | } |
308 | 319 | ||
309 | /* | 320 | /* |
@@ -338,8 +349,10 @@ int nfs_inode_return_delegation(struct inode *inode) | |||
338 | spin_lock(&clp->cl_lock); | 349 | spin_lock(&clp->cl_lock); |
339 | delegation = nfs_detach_delegation_locked(nfsi, NULL); | 350 | delegation = nfs_detach_delegation_locked(nfsi, NULL); |
340 | spin_unlock(&clp->cl_lock); | 351 | spin_unlock(&clp->cl_lock); |
341 | if (delegation != NULL) | 352 | if (delegation != NULL) { |
342 | err = __nfs_inode_return_delegation(inode, delegation); | 353 | nfs_msync_inode(inode); |
354 | err = __nfs_inode_return_delegation(inode, delegation, 1); | ||
355 | } | ||
343 | } | 356 | } |
344 | return err; | 357 | return err; |
345 | } | 358 | } |
@@ -368,33 +381,47 @@ void nfs_super_return_all_delegations(struct super_block *sb) | |||
368 | spin_unlock(&delegation->lock); | 381 | spin_unlock(&delegation->lock); |
369 | } | 382 | } |
370 | rcu_read_unlock(); | 383 | rcu_read_unlock(); |
371 | nfs_client_return_marked_delegations(clp); | 384 | if (nfs_client_return_marked_delegations(clp) != 0) |
385 | nfs4_schedule_state_manager(clp); | ||
372 | } | 386 | } |
373 | 387 | ||
374 | static void nfs_client_mark_return_all_delegations(struct nfs_client *clp) | 388 | static |
389 | void nfs_client_mark_return_all_delegation_types(struct nfs_client *clp, fmode_t flags) | ||
375 | { | 390 | { |
376 | struct nfs_delegation *delegation; | 391 | struct nfs_delegation *delegation; |
377 | 392 | ||
378 | rcu_read_lock(); | 393 | rcu_read_lock(); |
379 | list_for_each_entry_rcu(delegation, &clp->cl_delegations, super_list) { | 394 | list_for_each_entry_rcu(delegation, &clp->cl_delegations, super_list) { |
380 | set_bit(NFS_DELEGATION_RETURN, &delegation->flags); | 395 | if ((delegation->type == (FMODE_READ|FMODE_WRITE)) && !(flags & FMODE_WRITE)) |
381 | set_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state); | 396 | continue; |
397 | if (delegation->type & flags) | ||
398 | nfs_mark_return_delegation(clp, delegation); | ||
382 | } | 399 | } |
383 | rcu_read_unlock(); | 400 | rcu_read_unlock(); |
384 | } | 401 | } |
385 | 402 | ||
403 | static void nfs_client_mark_return_all_delegations(struct nfs_client *clp) | ||
404 | { | ||
405 | nfs_client_mark_return_all_delegation_types(clp, FMODE_READ|FMODE_WRITE); | ||
406 | } | ||
407 | |||
386 | static void nfs_delegation_run_state_manager(struct nfs_client *clp) | 408 | static void nfs_delegation_run_state_manager(struct nfs_client *clp) |
387 | { | 409 | { |
388 | if (test_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state)) | 410 | if (test_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state)) |
389 | nfs4_schedule_state_manager(clp); | 411 | nfs4_schedule_state_manager(clp); |
390 | } | 412 | } |
391 | 413 | ||
392 | void nfs_expire_all_delegations(struct nfs_client *clp) | 414 | void nfs_expire_all_delegation_types(struct nfs_client *clp, fmode_t flags) |
393 | { | 415 | { |
394 | nfs_client_mark_return_all_delegations(clp); | 416 | nfs_client_mark_return_all_delegation_types(clp, flags); |
395 | nfs_delegation_run_state_manager(clp); | 417 | nfs_delegation_run_state_manager(clp); |
396 | } | 418 | } |
397 | 419 | ||
420 | void nfs_expire_all_delegations(struct nfs_client *clp) | ||
421 | { | ||
422 | nfs_expire_all_delegation_types(clp, FMODE_READ|FMODE_WRITE); | ||
423 | } | ||
424 | |||
398 | /* | 425 | /* |
399 | * Return all delegations following an NFS4ERR_CB_PATH_DOWN error. | 426 | * Return all delegations following an NFS4ERR_CB_PATH_DOWN error. |
400 | */ | 427 | */ |
@@ -413,8 +440,7 @@ static void nfs_client_mark_return_unreferenced_delegations(struct nfs_client *c | |||
413 | list_for_each_entry_rcu(delegation, &clp->cl_delegations, super_list) { | 440 | list_for_each_entry_rcu(delegation, &clp->cl_delegations, super_list) { |
414 | if (test_and_clear_bit(NFS_DELEGATION_REFERENCED, &delegation->flags)) | 441 | if (test_and_clear_bit(NFS_DELEGATION_REFERENCED, &delegation->flags)) |
415 | continue; | 442 | continue; |
416 | set_bit(NFS_DELEGATION_RETURN, &delegation->flags); | 443 | nfs_mark_return_delegation(clp, delegation); |
417 | set_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state); | ||
418 | } | 444 | } |
419 | rcu_read_unlock(); | 445 | rcu_read_unlock(); |
420 | } | 446 | } |
@@ -428,18 +454,21 @@ void nfs_expire_unreferenced_delegations(struct nfs_client *clp) | |||
428 | /* | 454 | /* |
429 | * Asynchronous delegation recall! | 455 | * Asynchronous delegation recall! |
430 | */ | 456 | */ |
431 | int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid) | 457 | int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid, |
458 | int (*validate_stateid)(struct nfs_delegation *delegation, | ||
459 | const nfs4_stateid *stateid)) | ||
432 | { | 460 | { |
433 | struct nfs_client *clp = NFS_SERVER(inode)->nfs_client; | 461 | struct nfs_client *clp = NFS_SERVER(inode)->nfs_client; |
434 | struct nfs_delegation *delegation; | 462 | struct nfs_delegation *delegation; |
435 | 463 | ||
436 | rcu_read_lock(); | 464 | rcu_read_lock(); |
437 | delegation = rcu_dereference(NFS_I(inode)->delegation); | 465 | delegation = rcu_dereference(NFS_I(inode)->delegation); |
438 | if (delegation == NULL || memcmp(delegation->stateid.data, stateid->data, | 466 | |
439 | sizeof(delegation->stateid.data)) != 0) { | 467 | if (!validate_stateid(delegation, stateid)) { |
440 | rcu_read_unlock(); | 468 | rcu_read_unlock(); |
441 | return -ENOENT; | 469 | return -ENOENT; |
442 | } | 470 | } |
471 | |||
443 | nfs_mark_return_delegation(clp, delegation); | 472 | nfs_mark_return_delegation(clp, delegation); |
444 | rcu_read_unlock(); | 473 | rcu_read_unlock(); |
445 | nfs_delegation_run_state_manager(clp); | 474 | nfs_delegation_run_state_manager(clp); |
diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h index 09f383795174..944b627ec6e1 100644 --- a/fs/nfs/delegation.h +++ b/fs/nfs/delegation.h | |||
@@ -34,15 +34,18 @@ enum { | |||
34 | int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res); | 34 | int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res); |
35 | void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res); | 35 | void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res); |
36 | int nfs_inode_return_delegation(struct inode *inode); | 36 | int nfs_inode_return_delegation(struct inode *inode); |
37 | int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid); | 37 | int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid, |
38 | int (*validate_stateid)(struct nfs_delegation *delegation, | ||
39 | const nfs4_stateid *stateid)); | ||
38 | void nfs_inode_return_delegation_noreclaim(struct inode *inode); | 40 | void nfs_inode_return_delegation_noreclaim(struct inode *inode); |
39 | 41 | ||
40 | struct inode *nfs_delegation_find_inode(struct nfs_client *clp, const struct nfs_fh *fhandle); | 42 | struct inode *nfs_delegation_find_inode(struct nfs_client *clp, const struct nfs_fh *fhandle); |
41 | void nfs_super_return_all_delegations(struct super_block *sb); | 43 | void nfs_super_return_all_delegations(struct super_block *sb); |
42 | void nfs_expire_all_delegations(struct nfs_client *clp); | 44 | void nfs_expire_all_delegations(struct nfs_client *clp); |
45 | void nfs_expire_all_delegation_types(struct nfs_client *clp, fmode_t flags); | ||
43 | void nfs_expire_unreferenced_delegations(struct nfs_client *clp); | 46 | void nfs_expire_unreferenced_delegations(struct nfs_client *clp); |
44 | void nfs_handle_cb_pathdown(struct nfs_client *clp); | 47 | void nfs_handle_cb_pathdown(struct nfs_client *clp); |
45 | void nfs_client_return_marked_delegations(struct nfs_client *clp); | 48 | int nfs_client_return_marked_delegations(struct nfs_client *clp); |
46 | 49 | ||
47 | void nfs_delegation_mark_reclaim(struct nfs_client *clp); | 50 | void nfs_delegation_mark_reclaim(struct nfs_client *clp); |
48 | void nfs_delegation_reap_unclaimed(struct nfs_client *clp); | 51 | void nfs_delegation_reap_unclaimed(struct nfs_client *clp); |
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 7cb298525eef..2c5ace4f00a7 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -1579,55 +1579,46 @@ static int nfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1579 | struct dentry *dentry = NULL, *rehash = NULL; | 1579 | struct dentry *dentry = NULL, *rehash = NULL; |
1580 | int error = -EBUSY; | 1580 | int error = -EBUSY; |
1581 | 1581 | ||
1582 | /* | ||
1583 | * To prevent any new references to the target during the rename, | ||
1584 | * we unhash the dentry and free the inode in advance. | ||
1585 | */ | ||
1586 | if (!d_unhashed(new_dentry)) { | ||
1587 | d_drop(new_dentry); | ||
1588 | rehash = new_dentry; | ||
1589 | } | ||
1590 | |||
1591 | dfprintk(VFS, "NFS: rename(%s/%s -> %s/%s, ct=%d)\n", | 1582 | dfprintk(VFS, "NFS: rename(%s/%s -> %s/%s, ct=%d)\n", |
1592 | old_dentry->d_parent->d_name.name, old_dentry->d_name.name, | 1583 | old_dentry->d_parent->d_name.name, old_dentry->d_name.name, |
1593 | new_dentry->d_parent->d_name.name, new_dentry->d_name.name, | 1584 | new_dentry->d_parent->d_name.name, new_dentry->d_name.name, |
1594 | atomic_read(&new_dentry->d_count)); | 1585 | atomic_read(&new_dentry->d_count)); |
1595 | 1586 | ||
1596 | /* | 1587 | /* |
1597 | * First check whether the target is busy ... we can't | 1588 | * For non-directories, check whether the target is busy and if so, |
1598 | * safely do _any_ rename if the target is in use. | 1589 | * make a copy of the dentry and then do a silly-rename. If the |
1599 | * | 1590 | * silly-rename succeeds, the copied dentry is hashed and becomes |
1600 | * For files, make a copy of the dentry and then do a | 1591 | * the new target. |
1601 | * silly-rename. If the silly-rename succeeds, the | ||
1602 | * copied dentry is hashed and becomes the new target. | ||
1603 | */ | 1592 | */ |
1604 | if (!new_inode) | 1593 | if (new_inode && !S_ISDIR(new_inode->i_mode)) { |
1605 | goto go_ahead; | 1594 | /* |
1606 | if (S_ISDIR(new_inode->i_mode)) { | 1595 | * To prevent any new references to the target during the |
1607 | error = -EISDIR; | 1596 | * rename, we unhash the dentry in advance. |
1608 | if (!S_ISDIR(old_inode->i_mode)) | 1597 | */ |
1609 | goto out; | 1598 | if (!d_unhashed(new_dentry)) { |
1610 | } else if (atomic_read(&new_dentry->d_count) > 2) { | 1599 | d_drop(new_dentry); |
1611 | int err; | 1600 | rehash = new_dentry; |
1612 | /* copy the target dentry's name */ | 1601 | } |
1613 | dentry = d_alloc(new_dentry->d_parent, | 1602 | |
1614 | &new_dentry->d_name); | 1603 | if (atomic_read(&new_dentry->d_count) > 2) { |
1615 | if (!dentry) | 1604 | int err; |
1616 | goto out; | 1605 | |
1606 | /* copy the target dentry's name */ | ||
1607 | dentry = d_alloc(new_dentry->d_parent, | ||
1608 | &new_dentry->d_name); | ||
1609 | if (!dentry) | ||
1610 | goto out; | ||
1617 | 1611 | ||
1618 | /* silly-rename the existing target ... */ | 1612 | /* silly-rename the existing target ... */ |
1619 | err = nfs_sillyrename(new_dir, new_dentry); | 1613 | err = nfs_sillyrename(new_dir, new_dentry); |
1620 | if (!err) { | 1614 | if (err) |
1621 | new_dentry = rehash = dentry; | 1615 | goto out; |
1616 | |||
1617 | new_dentry = dentry; | ||
1622 | new_inode = NULL; | 1618 | new_inode = NULL; |
1623 | /* instantiate the replacement target */ | 1619 | } |
1624 | d_instantiate(new_dentry, NULL); | ||
1625 | } else if (atomic_read(&new_dentry->d_count) > 1) | ||
1626 | /* dentry still busy? */ | ||
1627 | goto out; | ||
1628 | } | 1620 | } |
1629 | 1621 | ||
1630 | go_ahead: | ||
1631 | /* | 1622 | /* |
1632 | * ... prune child dentries and writebacks if needed. | 1623 | * ... prune child dentries and writebacks if needed. |
1633 | */ | 1624 | */ |
diff --git a/fs/nfs/dns_resolve.c b/fs/nfs/dns_resolve.c index f4d54ba97cc6..95e1ca765d47 100644 --- a/fs/nfs/dns_resolve.c +++ b/fs/nfs/dns_resolve.c | |||
@@ -146,7 +146,7 @@ static int nfs_dns_show(struct seq_file *m, struct cache_detail *cd, | |||
146 | return 0; | 146 | return 0; |
147 | } | 147 | } |
148 | 148 | ||
149 | struct nfs_dns_ent *nfs_dns_lookup(struct cache_detail *cd, | 149 | static struct nfs_dns_ent *nfs_dns_lookup(struct cache_detail *cd, |
150 | struct nfs_dns_ent *key) | 150 | struct nfs_dns_ent *key) |
151 | { | 151 | { |
152 | struct cache_head *ch; | 152 | struct cache_head *ch; |
@@ -159,7 +159,7 @@ struct nfs_dns_ent *nfs_dns_lookup(struct cache_detail *cd, | |||
159 | return container_of(ch, struct nfs_dns_ent, h); | 159 | return container_of(ch, struct nfs_dns_ent, h); |
160 | } | 160 | } |
161 | 161 | ||
162 | struct nfs_dns_ent *nfs_dns_update(struct cache_detail *cd, | 162 | static struct nfs_dns_ent *nfs_dns_update(struct cache_detail *cd, |
163 | struct nfs_dns_ent *new, | 163 | struct nfs_dns_ent *new, |
164 | struct nfs_dns_ent *key) | 164 | struct nfs_dns_ent *key) |
165 | { | 165 | { |
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index e21b1bb9972f..29e464d23b32 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h | |||
@@ -30,6 +30,15 @@ static inline int nfs4_has_session(const struct nfs_client *clp) | |||
30 | return 0; | 30 | return 0; |
31 | } | 31 | } |
32 | 32 | ||
33 | static inline int nfs4_has_persistent_session(const struct nfs_client *clp) | ||
34 | { | ||
35 | #ifdef CONFIG_NFS_V4_1 | ||
36 | if (nfs4_has_session(clp)) | ||
37 | return (clp->cl_session->flags & SESSION4_PERSIST); | ||
38 | #endif /* CONFIG_NFS_V4_1 */ | ||
39 | return 0; | ||
40 | } | ||
41 | |||
33 | struct nfs_clone_mount { | 42 | struct nfs_clone_mount { |
34 | const struct super_block *sb; | 43 | const struct super_block *sb; |
35 | const struct dentry *dentry; | 44 | const struct dentry *dentry; |
@@ -156,6 +165,7 @@ struct vfsmount *nfs_do_refmount(const struct vfsmount *mnt_parent, struct dentr | |||
156 | 165 | ||
157 | /* callback_xdr.c */ | 166 | /* callback_xdr.c */ |
158 | extern struct svc_version nfs4_callback_version1; | 167 | extern struct svc_version nfs4_callback_version1; |
168 | extern struct svc_version nfs4_callback_version4; | ||
159 | 169 | ||
160 | /* pagelist.c */ | 170 | /* pagelist.c */ |
161 | extern int __init nfs_init_nfspagecache(void); | 171 | extern int __init nfs_init_nfspagecache(void); |
@@ -177,24 +187,14 @@ extern __be32 * nfs_decode_dirent(__be32 *, struct nfs_entry *, int); | |||
177 | extern struct rpc_procinfo nfs3_procedures[]; | 187 | extern struct rpc_procinfo nfs3_procedures[]; |
178 | extern __be32 *nfs3_decode_dirent(__be32 *, struct nfs_entry *, int); | 188 | extern __be32 *nfs3_decode_dirent(__be32 *, struct nfs_entry *, int); |
179 | 189 | ||
180 | /* nfs4proc.c */ | ||
181 | static inline void nfs4_restart_rpc(struct rpc_task *task, | ||
182 | const struct nfs_client *clp) | ||
183 | { | ||
184 | #ifdef CONFIG_NFS_V4_1 | ||
185 | if (nfs4_has_session(clp) && | ||
186 | test_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state)) { | ||
187 | rpc_restart_call_prepare(task); | ||
188 | return; | ||
189 | } | ||
190 | #endif /* CONFIG_NFS_V4_1 */ | ||
191 | rpc_restart_call(task); | ||
192 | } | ||
193 | |||
194 | /* nfs4xdr.c */ | 190 | /* nfs4xdr.c */ |
195 | #ifdef CONFIG_NFS_V4 | 191 | #ifdef CONFIG_NFS_V4 |
196 | extern __be32 *nfs4_decode_dirent(__be32 *p, struct nfs_entry *entry, int plus); | 192 | extern __be32 *nfs4_decode_dirent(__be32 *p, struct nfs_entry *entry, int plus); |
197 | #endif | 193 | #endif |
194 | #ifdef CONFIG_NFS_V4_1 | ||
195 | extern const u32 nfs41_maxread_overhead; | ||
196 | extern const u32 nfs41_maxwrite_overhead; | ||
197 | #endif | ||
198 | 198 | ||
199 | /* nfs4proc.c */ | 199 | /* nfs4proc.c */ |
200 | #ifdef CONFIG_NFS_V4 | 200 | #ifdef CONFIG_NFS_V4 |
@@ -273,20 +273,6 @@ extern int _nfs4_call_sync_session(struct nfs_server *server, | |||
273 | struct nfs4_sequence_res *res, | 273 | struct nfs4_sequence_res *res, |
274 | int cache_reply); | 274 | int cache_reply); |
275 | 275 | ||
276 | #ifdef CONFIG_NFS_V4_1 | ||
277 | extern void nfs41_sequence_free_slot(const struct nfs_client *, | ||
278 | struct nfs4_sequence_res *res); | ||
279 | #endif /* CONFIG_NFS_V4_1 */ | ||
280 | |||
281 | static inline void nfs4_sequence_free_slot(const struct nfs_client *clp, | ||
282 | struct nfs4_sequence_res *res) | ||
283 | { | ||
284 | #ifdef CONFIG_NFS_V4_1 | ||
285 | if (nfs4_has_session(clp)) | ||
286 | nfs41_sequence_free_slot(clp, res); | ||
287 | #endif /* CONFIG_NFS_V4_1 */ | ||
288 | } | ||
289 | |||
290 | /* | 276 | /* |
291 | * Determine the device name as a string | 277 | * Determine the device name as a string |
292 | */ | 278 | */ |
@@ -380,3 +366,15 @@ unsigned int nfs_page_array_len(unsigned int base, size_t len) | |||
380 | return ((unsigned long)len + (unsigned long)base + | 366 | return ((unsigned long)len + (unsigned long)base + |
381 | PAGE_SIZE - 1) >> PAGE_SHIFT; | 367 | PAGE_SIZE - 1) >> PAGE_SHIFT; |
382 | } | 368 | } |
369 | |||
370 | /* | ||
371 | * Helper for restarting RPC calls in the possible presence of NFSv4.1 | ||
372 | * sessions. | ||
373 | */ | ||
374 | static inline void nfs_restart_rpc(struct rpc_task *task, const struct nfs_client *clp) | ||
375 | { | ||
376 | if (nfs4_has_session(clp)) | ||
377 | rpc_restart_call_prepare(task); | ||
378 | else | ||
379 | rpc_restart_call(task); | ||
380 | } | ||
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 6ea07a3c75d4..7e57b04e4014 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h | |||
@@ -44,7 +44,8 @@ enum nfs4_client_state { | |||
44 | NFS4CLNT_RECLAIM_REBOOT, | 44 | NFS4CLNT_RECLAIM_REBOOT, |
45 | NFS4CLNT_RECLAIM_NOGRACE, | 45 | NFS4CLNT_RECLAIM_NOGRACE, |
46 | NFS4CLNT_DELEGRETURN, | 46 | NFS4CLNT_DELEGRETURN, |
47 | NFS4CLNT_SESSION_SETUP, | 47 | NFS4CLNT_SESSION_RESET, |
48 | NFS4CLNT_SESSION_DRAINING, | ||
48 | }; | 49 | }; |
49 | 50 | ||
50 | /* | 51 | /* |
@@ -180,6 +181,7 @@ struct nfs4_state_recovery_ops { | |||
180 | int (*recover_lock)(struct nfs4_state *, struct file_lock *); | 181 | int (*recover_lock)(struct nfs4_state *, struct file_lock *); |
181 | int (*establish_clid)(struct nfs_client *, struct rpc_cred *); | 182 | int (*establish_clid)(struct nfs_client *, struct rpc_cred *); |
182 | struct rpc_cred * (*get_clid_cred)(struct nfs_client *); | 183 | struct rpc_cred * (*get_clid_cred)(struct nfs_client *); |
184 | int (*reclaim_complete)(struct nfs_client *); | ||
183 | }; | 185 | }; |
184 | 186 | ||
185 | struct nfs4_state_maintenance_ops { | 187 | struct nfs4_state_maintenance_ops { |
@@ -200,9 +202,11 @@ extern ssize_t nfs4_listxattr(struct dentry *, char *, size_t); | |||
200 | /* nfs4proc.c */ | 202 | /* nfs4proc.c */ |
201 | extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, struct rpc_cred *); | 203 | extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, struct rpc_cred *); |
202 | extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct rpc_cred *); | 204 | extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct rpc_cred *); |
205 | extern int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred); | ||
203 | extern int nfs4_proc_async_renew(struct nfs_client *, struct rpc_cred *); | 206 | extern int nfs4_proc_async_renew(struct nfs_client *, struct rpc_cred *); |
204 | extern int nfs4_proc_renew(struct nfs_client *, struct rpc_cred *); | 207 | extern int nfs4_proc_renew(struct nfs_client *, struct rpc_cred *); |
205 | extern int nfs4_init_clientid(struct nfs_client *, struct rpc_cred *); | 208 | extern int nfs4_init_clientid(struct nfs_client *, struct rpc_cred *); |
209 | extern int nfs41_init_clientid(struct nfs_client *, struct rpc_cred *); | ||
206 | extern int nfs4_do_close(struct path *path, struct nfs4_state *state, int wait); | 210 | extern int nfs4_do_close(struct path *path, struct nfs4_state *state, int wait); |
207 | extern struct dentry *nfs4_atomic_open(struct inode *, struct dentry *, struct nameidata *); | 211 | extern struct dentry *nfs4_atomic_open(struct inode *, struct dentry *, struct nameidata *); |
208 | extern int nfs4_open_revalidate(struct inode *, struct dentry *, int, struct nameidata *); | 212 | extern int nfs4_open_revalidate(struct inode *, struct dentry *, int, struct nameidata *); |
@@ -218,9 +222,11 @@ extern int nfs4_setup_sequence(struct nfs_client *clp, | |||
218 | int cache_reply, struct rpc_task *task); | 222 | int cache_reply, struct rpc_task *task); |
219 | extern void nfs4_destroy_session(struct nfs4_session *session); | 223 | extern void nfs4_destroy_session(struct nfs4_session *session); |
220 | extern struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp); | 224 | extern struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp); |
221 | extern int nfs4_proc_create_session(struct nfs_client *, int reset); | 225 | extern int nfs4_proc_create_session(struct nfs_client *); |
222 | extern int nfs4_proc_destroy_session(struct nfs4_session *); | 226 | extern int nfs4_proc_destroy_session(struct nfs4_session *); |
223 | extern int nfs4_init_session(struct nfs_server *server); | 227 | extern int nfs4_init_session(struct nfs_server *server); |
228 | extern int nfs4_proc_get_lease_time(struct nfs_client *clp, | ||
229 | struct nfs_fsinfo *fsinfo); | ||
224 | #else /* CONFIG_NFS_v4_1 */ | 230 | #else /* CONFIG_NFS_v4_1 */ |
225 | static inline int nfs4_setup_sequence(struct nfs_client *clp, | 231 | static inline int nfs4_setup_sequence(struct nfs_client *clp, |
226 | struct nfs4_sequence_args *args, struct nfs4_sequence_res *res, | 232 | struct nfs4_sequence_args *args, struct nfs4_sequence_res *res, |
@@ -267,6 +273,7 @@ extern void nfs4_state_set_mode_locked(struct nfs4_state *, fmode_t); | |||
267 | extern void nfs4_schedule_state_recovery(struct nfs_client *); | 273 | extern void nfs4_schedule_state_recovery(struct nfs_client *); |
268 | extern void nfs4_schedule_state_manager(struct nfs_client *); | 274 | extern void nfs4_schedule_state_manager(struct nfs_client *); |
269 | extern int nfs4_state_mark_reclaim_nograce(struct nfs_client *clp, struct nfs4_state *state); | 275 | extern int nfs4_state_mark_reclaim_nograce(struct nfs_client *clp, struct nfs4_state *state); |
276 | extern void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags); | ||
270 | extern void nfs4_put_lock_state(struct nfs4_lock_state *lsp); | 277 | extern void nfs4_put_lock_state(struct nfs4_lock_state *lsp); |
271 | extern int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl); | 278 | extern int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl); |
272 | extern void nfs4_copy_stateid(nfs4_stateid *, struct nfs4_state *, fl_owner_t); | 279 | extern void nfs4_copy_stateid(nfs4_stateid *, struct nfs4_state *, fl_owner_t); |
@@ -287,6 +294,7 @@ struct nfs4_mount_data; | |||
287 | 294 | ||
288 | /* callback_xdr.c */ | 295 | /* callback_xdr.c */ |
289 | extern struct svc_version nfs4_callback_version1; | 296 | extern struct svc_version nfs4_callback_version1; |
297 | extern struct svc_version nfs4_callback_version4; | ||
290 | 298 | ||
291 | #else | 299 | #else |
292 | 300 | ||
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 741a562177fc..9f5f11ecfd93 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -270,11 +270,18 @@ static int nfs4_handle_exception(const struct nfs_server *server, int errorcode, | |||
270 | case -NFS4ERR_SEQ_MISORDERED: | 270 | case -NFS4ERR_SEQ_MISORDERED: |
271 | dprintk("%s ERROR: %d Reset session\n", __func__, | 271 | dprintk("%s ERROR: %d Reset session\n", __func__, |
272 | errorcode); | 272 | errorcode); |
273 | set_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state); | 273 | nfs4_schedule_state_recovery(clp); |
274 | exception->retry = 1; | 274 | exception->retry = 1; |
275 | /* FALLTHROUGH */ | 275 | break; |
276 | #endif /* !defined(CONFIG_NFS_V4_1) */ | 276 | #endif /* !defined(CONFIG_NFS_V4_1) */ |
277 | case -NFS4ERR_FILE_OPEN: | 277 | case -NFS4ERR_FILE_OPEN: |
278 | if (exception->timeout > HZ) { | ||
279 | /* We have retried a decent amount, time to | ||
280 | * fail | ||
281 | */ | ||
282 | ret = -EBUSY; | ||
283 | break; | ||
284 | } | ||
278 | case -NFS4ERR_GRACE: | 285 | case -NFS4ERR_GRACE: |
279 | case -NFS4ERR_DELAY: | 286 | case -NFS4ERR_DELAY: |
280 | ret = nfs4_delay(server->client, &exception->timeout); | 287 | ret = nfs4_delay(server->client, &exception->timeout); |
@@ -311,48 +318,54 @@ static void renew_lease(const struct nfs_server *server, unsigned long timestamp | |||
311 | * so we need to scan down from highest_used_slotid to 0 looking for the now | 318 | * so we need to scan down from highest_used_slotid to 0 looking for the now |
312 | * highest slotid in use. | 319 | * highest slotid in use. |
313 | * If none found, highest_used_slotid is set to -1. | 320 | * If none found, highest_used_slotid is set to -1. |
321 | * | ||
322 | * Must be called while holding tbl->slot_tbl_lock | ||
314 | */ | 323 | */ |
315 | static void | 324 | static void |
316 | nfs4_free_slot(struct nfs4_slot_table *tbl, u8 free_slotid) | 325 | nfs4_free_slot(struct nfs4_slot_table *tbl, u8 free_slotid) |
317 | { | 326 | { |
318 | int slotid = free_slotid; | 327 | int slotid = free_slotid; |
319 | 328 | ||
320 | spin_lock(&tbl->slot_tbl_lock); | ||
321 | /* clear used bit in bitmap */ | 329 | /* clear used bit in bitmap */ |
322 | __clear_bit(slotid, tbl->used_slots); | 330 | __clear_bit(slotid, tbl->used_slots); |
323 | 331 | ||
324 | /* update highest_used_slotid when it is freed */ | 332 | /* update highest_used_slotid when it is freed */ |
325 | if (slotid == tbl->highest_used_slotid) { | 333 | if (slotid == tbl->highest_used_slotid) { |
326 | slotid = find_last_bit(tbl->used_slots, tbl->max_slots); | 334 | slotid = find_last_bit(tbl->used_slots, tbl->max_slots); |
327 | if (slotid >= 0 && slotid < tbl->max_slots) | 335 | if (slotid < tbl->max_slots) |
328 | tbl->highest_used_slotid = slotid; | 336 | tbl->highest_used_slotid = slotid; |
329 | else | 337 | else |
330 | tbl->highest_used_slotid = -1; | 338 | tbl->highest_used_slotid = -1; |
331 | } | 339 | } |
332 | rpc_wake_up_next(&tbl->slot_tbl_waitq); | ||
333 | spin_unlock(&tbl->slot_tbl_lock); | ||
334 | dprintk("%s: free_slotid %u highest_used_slotid %d\n", __func__, | 340 | dprintk("%s: free_slotid %u highest_used_slotid %d\n", __func__, |
335 | free_slotid, tbl->highest_used_slotid); | 341 | free_slotid, tbl->highest_used_slotid); |
336 | } | 342 | } |
337 | 343 | ||
338 | void nfs41_sequence_free_slot(const struct nfs_client *clp, | 344 | static void nfs41_sequence_free_slot(const struct nfs_client *clp, |
339 | struct nfs4_sequence_res *res) | 345 | struct nfs4_sequence_res *res) |
340 | { | 346 | { |
341 | struct nfs4_slot_table *tbl; | 347 | struct nfs4_slot_table *tbl; |
342 | 348 | ||
343 | if (!nfs4_has_session(clp)) { | ||
344 | dprintk("%s: No session\n", __func__); | ||
345 | return; | ||
346 | } | ||
347 | tbl = &clp->cl_session->fc_slot_table; | 349 | tbl = &clp->cl_session->fc_slot_table; |
348 | if (res->sr_slotid == NFS4_MAX_SLOT_TABLE) { | 350 | if (res->sr_slotid == NFS4_MAX_SLOT_TABLE) { |
349 | dprintk("%s: No slot\n", __func__); | ||
350 | /* just wake up the next guy waiting since | 351 | /* just wake up the next guy waiting since |
351 | * we may have not consumed a slot after all */ | 352 | * we may have not consumed a slot after all */ |
352 | rpc_wake_up_next(&tbl->slot_tbl_waitq); | 353 | dprintk("%s: No slot\n", __func__); |
353 | return; | 354 | return; |
354 | } | 355 | } |
356 | |||
357 | spin_lock(&tbl->slot_tbl_lock); | ||
355 | nfs4_free_slot(tbl, res->sr_slotid); | 358 | nfs4_free_slot(tbl, res->sr_slotid); |
359 | |||
360 | /* Signal state manager thread if session is drained */ | ||
361 | if (test_bit(NFS4CLNT_SESSION_DRAINING, &clp->cl_state)) { | ||
362 | if (tbl->highest_used_slotid == -1) { | ||
363 | dprintk("%s COMPLETE: Session Drained\n", __func__); | ||
364 | complete(&clp->cl_session->complete); | ||
365 | } | ||
366 | } else | ||
367 | rpc_wake_up_next(&tbl->slot_tbl_waitq); | ||
368 | spin_unlock(&tbl->slot_tbl_lock); | ||
356 | res->sr_slotid = NFS4_MAX_SLOT_TABLE; | 369 | res->sr_slotid = NFS4_MAX_SLOT_TABLE; |
357 | } | 370 | } |
358 | 371 | ||
@@ -377,10 +390,10 @@ static void nfs41_sequence_done(struct nfs_client *clp, | |||
377 | if (res->sr_slotid == NFS4_MAX_SLOT_TABLE) | 390 | if (res->sr_slotid == NFS4_MAX_SLOT_TABLE) |
378 | goto out; | 391 | goto out; |
379 | 392 | ||
380 | tbl = &clp->cl_session->fc_slot_table; | 393 | /* Check the SEQUENCE operation status */ |
381 | slot = tbl->slots + res->sr_slotid; | ||
382 | |||
383 | if (res->sr_status == 0) { | 394 | if (res->sr_status == 0) { |
395 | tbl = &clp->cl_session->fc_slot_table; | ||
396 | slot = tbl->slots + res->sr_slotid; | ||
384 | /* Update the slot's sequence and clientid lease timer */ | 397 | /* Update the slot's sequence and clientid lease timer */ |
385 | ++slot->seq_nr; | 398 | ++slot->seq_nr; |
386 | timestamp = res->sr_renewal_time; | 399 | timestamp = res->sr_renewal_time; |
@@ -388,7 +401,8 @@ static void nfs41_sequence_done(struct nfs_client *clp, | |||
388 | if (time_before(clp->cl_last_renewal, timestamp)) | 401 | if (time_before(clp->cl_last_renewal, timestamp)) |
389 | clp->cl_last_renewal = timestamp; | 402 | clp->cl_last_renewal = timestamp; |
390 | spin_unlock(&clp->cl_lock); | 403 | spin_unlock(&clp->cl_lock); |
391 | return; | 404 | /* Check sequence flags */ |
405 | nfs41_handle_sequence_flag_errors(clp, res->sr_status_flags); | ||
392 | } | 406 | } |
393 | out: | 407 | out: |
394 | /* The session may be reset by one of the error handlers. */ | 408 | /* The session may be reset by one of the error handlers. */ |
@@ -429,24 +443,6 @@ out: | |||
429 | return ret_id; | 443 | return ret_id; |
430 | } | 444 | } |
431 | 445 | ||
432 | static int nfs4_recover_session(struct nfs4_session *session) | ||
433 | { | ||
434 | struct nfs_client *clp = session->clp; | ||
435 | unsigned int loop; | ||
436 | int ret; | ||
437 | |||
438 | for (loop = NFS4_MAX_LOOP_ON_RECOVER; loop != 0; loop--) { | ||
439 | ret = nfs4_wait_clnt_recover(clp); | ||
440 | if (ret != 0) | ||
441 | break; | ||
442 | if (!test_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state)) | ||
443 | break; | ||
444 | nfs4_schedule_state_manager(clp); | ||
445 | ret = -EIO; | ||
446 | } | ||
447 | return ret; | ||
448 | } | ||
449 | |||
450 | static int nfs41_setup_sequence(struct nfs4_session *session, | 446 | static int nfs41_setup_sequence(struct nfs4_session *session, |
451 | struct nfs4_sequence_args *args, | 447 | struct nfs4_sequence_args *args, |
452 | struct nfs4_sequence_res *res, | 448 | struct nfs4_sequence_res *res, |
@@ -455,7 +451,6 @@ static int nfs41_setup_sequence(struct nfs4_session *session, | |||
455 | { | 451 | { |
456 | struct nfs4_slot *slot; | 452 | struct nfs4_slot *slot; |
457 | struct nfs4_slot_table *tbl; | 453 | struct nfs4_slot_table *tbl; |
458 | int status = 0; | ||
459 | u8 slotid; | 454 | u8 slotid; |
460 | 455 | ||
461 | dprintk("--> %s\n", __func__); | 456 | dprintk("--> %s\n", __func__); |
@@ -468,21 +463,15 @@ static int nfs41_setup_sequence(struct nfs4_session *session, | |||
468 | tbl = &session->fc_slot_table; | 463 | tbl = &session->fc_slot_table; |
469 | 464 | ||
470 | spin_lock(&tbl->slot_tbl_lock); | 465 | spin_lock(&tbl->slot_tbl_lock); |
471 | if (test_bit(NFS4CLNT_SESSION_SETUP, &session->clp->cl_state)) { | 466 | if (test_bit(NFS4CLNT_SESSION_DRAINING, &session->clp->cl_state)) { |
472 | if (tbl->highest_used_slotid != -1) { | 467 | /* |
473 | rpc_sleep_on(&tbl->slot_tbl_waitq, task, NULL); | 468 | * The state manager will wait until the slot table is empty. |
474 | spin_unlock(&tbl->slot_tbl_lock); | 469 | * Schedule the reset thread |
475 | dprintk("<-- %s: Session reset: draining\n", __func__); | 470 | */ |
476 | return -EAGAIN; | 471 | rpc_sleep_on(&tbl->slot_tbl_waitq, task, NULL); |
477 | } | ||
478 | |||
479 | /* The slot table is empty; start the reset thread */ | ||
480 | dprintk("%s Session Reset\n", __func__); | ||
481 | spin_unlock(&tbl->slot_tbl_lock); | 472 | spin_unlock(&tbl->slot_tbl_lock); |
482 | status = nfs4_recover_session(session); | 473 | dprintk("%s Schedule Session Reset\n", __func__); |
483 | if (status) | 474 | return -EAGAIN; |
484 | return status; | ||
485 | spin_lock(&tbl->slot_tbl_lock); | ||
486 | } | 475 | } |
487 | 476 | ||
488 | slotid = nfs4_find_slot(tbl, task); | 477 | slotid = nfs4_find_slot(tbl, task); |
@@ -527,7 +516,7 @@ int nfs4_setup_sequence(struct nfs_client *clp, | |||
527 | goto out; | 516 | goto out; |
528 | ret = nfs41_setup_sequence(clp->cl_session, args, res, cache_reply, | 517 | ret = nfs41_setup_sequence(clp->cl_session, args, res, cache_reply, |
529 | task); | 518 | task); |
530 | if (ret != -EAGAIN) { | 519 | if (ret && ret != -EAGAIN) { |
531 | /* terminate rpc task */ | 520 | /* terminate rpc task */ |
532 | task->tk_status = ret; | 521 | task->tk_status = ret; |
533 | task->tk_action = NULL; | 522 | task->tk_action = NULL; |
@@ -561,7 +550,6 @@ static void nfs41_call_sync_done(struct rpc_task *task, void *calldata) | |||
561 | struct nfs41_call_sync_data *data = calldata; | 550 | struct nfs41_call_sync_data *data = calldata; |
562 | 551 | ||
563 | nfs41_sequence_done(data->clp, data->seq_res, task->tk_status); | 552 | nfs41_sequence_done(data->clp, data->seq_res, task->tk_status); |
564 | nfs41_sequence_free_slot(data->clp, data->seq_res); | ||
565 | } | 553 | } |
566 | 554 | ||
567 | struct rpc_call_ops nfs41_call_sync_ops = { | 555 | struct rpc_call_ops nfs41_call_sync_ops = { |
@@ -637,15 +625,6 @@ static void nfs4_sequence_done(const struct nfs_server *server, | |||
637 | #endif /* CONFIG_NFS_V4_1 */ | 625 | #endif /* CONFIG_NFS_V4_1 */ |
638 | } | 626 | } |
639 | 627 | ||
640 | /* no restart, therefore free slot here */ | ||
641 | static void nfs4_sequence_done_free_slot(const struct nfs_server *server, | ||
642 | struct nfs4_sequence_res *res, | ||
643 | int rpc_status) | ||
644 | { | ||
645 | nfs4_sequence_done(server, res, rpc_status); | ||
646 | nfs4_sequence_free_slot(server->nfs_client, res); | ||
647 | } | ||
648 | |||
649 | static void update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo) | 628 | static void update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo) |
650 | { | 629 | { |
651 | struct nfs_inode *nfsi = NFS_I(dir); | 630 | struct nfs_inode *nfsi = NFS_I(dir); |
@@ -720,9 +699,15 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct path *path, | |||
720 | p->o_arg.bitmask = server->attr_bitmask; | 699 | p->o_arg.bitmask = server->attr_bitmask; |
721 | p->o_arg.claim = NFS4_OPEN_CLAIM_NULL; | 700 | p->o_arg.claim = NFS4_OPEN_CLAIM_NULL; |
722 | if (flags & O_EXCL) { | 701 | if (flags & O_EXCL) { |
723 | u32 *s = (u32 *) p->o_arg.u.verifier.data; | 702 | if (nfs4_has_persistent_session(server->nfs_client)) { |
724 | s[0] = jiffies; | 703 | /* GUARDED */ |
725 | s[1] = current->pid; | 704 | p->o_arg.u.attrs = &p->attrs; |
705 | memcpy(&p->attrs, attrs, sizeof(p->attrs)); | ||
706 | } else { /* EXCLUSIVE4_1 */ | ||
707 | u32 *s = (u32 *) p->o_arg.u.verifier.data; | ||
708 | s[0] = jiffies; | ||
709 | s[1] = current->pid; | ||
710 | } | ||
726 | } else if (flags & O_CREAT) { | 711 | } else if (flags & O_CREAT) { |
727 | p->o_arg.u.attrs = &p->attrs; | 712 | p->o_arg.u.attrs = &p->attrs; |
728 | memcpy(&p->attrs, attrs, sizeof(p->attrs)); | 713 | memcpy(&p->attrs, attrs, sizeof(p->attrs)); |
@@ -776,13 +761,16 @@ static int can_open_cached(struct nfs4_state *state, fmode_t mode, int open_mode | |||
776 | goto out; | 761 | goto out; |
777 | switch (mode & (FMODE_READ|FMODE_WRITE)) { | 762 | switch (mode & (FMODE_READ|FMODE_WRITE)) { |
778 | case FMODE_READ: | 763 | case FMODE_READ: |
779 | ret |= test_bit(NFS_O_RDONLY_STATE, &state->flags) != 0; | 764 | ret |= test_bit(NFS_O_RDONLY_STATE, &state->flags) != 0 |
765 | && state->n_rdonly != 0; | ||
780 | break; | 766 | break; |
781 | case FMODE_WRITE: | 767 | case FMODE_WRITE: |
782 | ret |= test_bit(NFS_O_WRONLY_STATE, &state->flags) != 0; | 768 | ret |= test_bit(NFS_O_WRONLY_STATE, &state->flags) != 0 |
769 | && state->n_wronly != 0; | ||
783 | break; | 770 | break; |
784 | case FMODE_READ|FMODE_WRITE: | 771 | case FMODE_READ|FMODE_WRITE: |
785 | ret |= test_bit(NFS_O_RDWR_STATE, &state->flags) != 0; | 772 | ret |= test_bit(NFS_O_RDWR_STATE, &state->flags) != 0 |
773 | && state->n_rdwr != 0; | ||
786 | } | 774 | } |
787 | out: | 775 | out: |
788 | return ret; | 776 | return ret; |
@@ -1183,6 +1171,14 @@ int nfs4_open_delegation_recall(struct nfs_open_context *ctx, struct nfs4_state | |||
1183 | case -ENOENT: | 1171 | case -ENOENT: |
1184 | case -ESTALE: | 1172 | case -ESTALE: |
1185 | goto out; | 1173 | goto out; |
1174 | case -NFS4ERR_BADSESSION: | ||
1175 | case -NFS4ERR_BADSLOT: | ||
1176 | case -NFS4ERR_BAD_HIGH_SLOT: | ||
1177 | case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: | ||
1178 | case -NFS4ERR_DEADSESSION: | ||
1179 | nfs4_schedule_state_recovery( | ||
1180 | server->nfs_client); | ||
1181 | goto out; | ||
1186 | case -NFS4ERR_STALE_CLIENTID: | 1182 | case -NFS4ERR_STALE_CLIENTID: |
1187 | case -NFS4ERR_STALE_STATEID: | 1183 | case -NFS4ERR_STALE_STATEID: |
1188 | case -NFS4ERR_EXPIRED: | 1184 | case -NFS4ERR_EXPIRED: |
@@ -1336,8 +1332,8 @@ static void nfs4_open_done(struct rpc_task *task, void *calldata) | |||
1336 | 1332 | ||
1337 | data->rpc_status = task->tk_status; | 1333 | data->rpc_status = task->tk_status; |
1338 | 1334 | ||
1339 | nfs4_sequence_done_free_slot(data->o_arg.server, &data->o_res.seq_res, | 1335 | nfs4_sequence_done(data->o_arg.server, &data->o_res.seq_res, |
1340 | task->tk_status); | 1336 | task->tk_status); |
1341 | 1337 | ||
1342 | if (RPC_ASSASSINATED(task)) | 1338 | if (RPC_ASSASSINATED(task)) |
1343 | return; | 1339 | return; |
@@ -1488,7 +1484,7 @@ static int _nfs4_open_expired(struct nfs_open_context *ctx, struct nfs4_state *s | |||
1488 | return ret; | 1484 | return ret; |
1489 | } | 1485 | } |
1490 | 1486 | ||
1491 | static inline int nfs4_do_open_expired(struct nfs_open_context *ctx, struct nfs4_state *state) | 1487 | static int nfs4_do_open_expired(struct nfs_open_context *ctx, struct nfs4_state *state) |
1492 | { | 1488 | { |
1493 | struct nfs_server *server = NFS_SERVER(state->inode); | 1489 | struct nfs_server *server = NFS_SERVER(state->inode); |
1494 | struct nfs4_exception exception = { }; | 1490 | struct nfs4_exception exception = { }; |
@@ -1496,10 +1492,16 @@ static inline int nfs4_do_open_expired(struct nfs_open_context *ctx, struct nfs4 | |||
1496 | 1492 | ||
1497 | do { | 1493 | do { |
1498 | err = _nfs4_open_expired(ctx, state); | 1494 | err = _nfs4_open_expired(ctx, state); |
1499 | if (err != -NFS4ERR_DELAY) | 1495 | switch (err) { |
1500 | break; | 1496 | default: |
1501 | nfs4_handle_exception(server, err, &exception); | 1497 | goto out; |
1498 | case -NFS4ERR_GRACE: | ||
1499 | case -NFS4ERR_DELAY: | ||
1500 | nfs4_handle_exception(server, err, &exception); | ||
1501 | err = 0; | ||
1502 | } | ||
1502 | } while (exception.retry); | 1503 | } while (exception.retry); |
1504 | out: | ||
1503 | return err; | 1505 | return err; |
1504 | } | 1506 | } |
1505 | 1507 | ||
@@ -1712,6 +1714,18 @@ static void nfs4_free_closedata(void *data) | |||
1712 | kfree(calldata); | 1714 | kfree(calldata); |
1713 | } | 1715 | } |
1714 | 1716 | ||
1717 | static void nfs4_close_clear_stateid_flags(struct nfs4_state *state, | ||
1718 | fmode_t fmode) | ||
1719 | { | ||
1720 | spin_lock(&state->owner->so_lock); | ||
1721 | if (!(fmode & FMODE_READ)) | ||
1722 | clear_bit(NFS_O_RDONLY_STATE, &state->flags); | ||
1723 | if (!(fmode & FMODE_WRITE)) | ||
1724 | clear_bit(NFS_O_WRONLY_STATE, &state->flags); | ||
1725 | clear_bit(NFS_O_RDWR_STATE, &state->flags); | ||
1726 | spin_unlock(&state->owner->so_lock); | ||
1727 | } | ||
1728 | |||
1715 | static void nfs4_close_done(struct rpc_task *task, void *data) | 1729 | static void nfs4_close_done(struct rpc_task *task, void *data) |
1716 | { | 1730 | { |
1717 | struct nfs4_closedata *calldata = data; | 1731 | struct nfs4_closedata *calldata = data; |
@@ -1728,6 +1742,8 @@ static void nfs4_close_done(struct rpc_task *task, void *data) | |||
1728 | case 0: | 1742 | case 0: |
1729 | nfs_set_open_stateid(state, &calldata->res.stateid, 0); | 1743 | nfs_set_open_stateid(state, &calldata->res.stateid, 0); |
1730 | renew_lease(server, calldata->timestamp); | 1744 | renew_lease(server, calldata->timestamp); |
1745 | nfs4_close_clear_stateid_flags(state, | ||
1746 | calldata->arg.fmode); | ||
1731 | break; | 1747 | break; |
1732 | case -NFS4ERR_STALE_STATEID: | 1748 | case -NFS4ERR_STALE_STATEID: |
1733 | case -NFS4ERR_OLD_STATEID: | 1749 | case -NFS4ERR_OLD_STATEID: |
@@ -1737,11 +1753,10 @@ static void nfs4_close_done(struct rpc_task *task, void *data) | |||
1737 | break; | 1753 | break; |
1738 | default: | 1754 | default: |
1739 | if (nfs4_async_handle_error(task, server, state) == -EAGAIN) { | 1755 | if (nfs4_async_handle_error(task, server, state) == -EAGAIN) { |
1740 | nfs4_restart_rpc(task, server->nfs_client); | 1756 | nfs_restart_rpc(task, server->nfs_client); |
1741 | return; | 1757 | return; |
1742 | } | 1758 | } |
1743 | } | 1759 | } |
1744 | nfs4_sequence_free_slot(server->nfs_client, &calldata->res.seq_res); | ||
1745 | nfs_refresh_inode(calldata->inode, calldata->res.fattr); | 1760 | nfs_refresh_inode(calldata->inode, calldata->res.fattr); |
1746 | } | 1761 | } |
1747 | 1762 | ||
@@ -1749,38 +1764,39 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data) | |||
1749 | { | 1764 | { |
1750 | struct nfs4_closedata *calldata = data; | 1765 | struct nfs4_closedata *calldata = data; |
1751 | struct nfs4_state *state = calldata->state; | 1766 | struct nfs4_state *state = calldata->state; |
1752 | int clear_rd, clear_wr, clear_rdwr; | 1767 | int call_close = 0; |
1753 | 1768 | ||
1754 | if (nfs_wait_on_sequence(calldata->arg.seqid, task) != 0) | 1769 | if (nfs_wait_on_sequence(calldata->arg.seqid, task) != 0) |
1755 | return; | 1770 | return; |
1756 | 1771 | ||
1757 | clear_rd = clear_wr = clear_rdwr = 0; | 1772 | task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_DOWNGRADE]; |
1773 | calldata->arg.fmode = FMODE_READ|FMODE_WRITE; | ||
1758 | spin_lock(&state->owner->so_lock); | 1774 | spin_lock(&state->owner->so_lock); |
1759 | /* Calculate the change in open mode */ | 1775 | /* Calculate the change in open mode */ |
1760 | if (state->n_rdwr == 0) { | 1776 | if (state->n_rdwr == 0) { |
1761 | if (state->n_rdonly == 0) { | 1777 | if (state->n_rdonly == 0) { |
1762 | clear_rd |= test_and_clear_bit(NFS_O_RDONLY_STATE, &state->flags); | 1778 | call_close |= test_bit(NFS_O_RDONLY_STATE, &state->flags); |
1763 | clear_rdwr |= test_and_clear_bit(NFS_O_RDWR_STATE, &state->flags); | 1779 | call_close |= test_bit(NFS_O_RDWR_STATE, &state->flags); |
1780 | calldata->arg.fmode &= ~FMODE_READ; | ||
1764 | } | 1781 | } |
1765 | if (state->n_wronly == 0) { | 1782 | if (state->n_wronly == 0) { |
1766 | clear_wr |= test_and_clear_bit(NFS_O_WRONLY_STATE, &state->flags); | 1783 | call_close |= test_bit(NFS_O_WRONLY_STATE, &state->flags); |
1767 | clear_rdwr |= test_and_clear_bit(NFS_O_RDWR_STATE, &state->flags); | 1784 | call_close |= test_bit(NFS_O_RDWR_STATE, &state->flags); |
1785 | calldata->arg.fmode &= ~FMODE_WRITE; | ||
1768 | } | 1786 | } |
1769 | } | 1787 | } |
1770 | spin_unlock(&state->owner->so_lock); | 1788 | spin_unlock(&state->owner->so_lock); |
1771 | if (!clear_rd && !clear_wr && !clear_rdwr) { | 1789 | |
1790 | if (!call_close) { | ||
1772 | /* Note: exit _without_ calling nfs4_close_done */ | 1791 | /* Note: exit _without_ calling nfs4_close_done */ |
1773 | task->tk_action = NULL; | 1792 | task->tk_action = NULL; |
1774 | return; | 1793 | return; |
1775 | } | 1794 | } |
1795 | |||
1796 | if (calldata->arg.fmode == 0) | ||
1797 | task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CLOSE]; | ||
1798 | |||
1776 | nfs_fattr_init(calldata->res.fattr); | 1799 | nfs_fattr_init(calldata->res.fattr); |
1777 | if (test_bit(NFS_O_RDONLY_STATE, &state->flags) != 0) { | ||
1778 | task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_DOWNGRADE]; | ||
1779 | calldata->arg.fmode = FMODE_READ; | ||
1780 | } else if (test_bit(NFS_O_WRONLY_STATE, &state->flags) != 0) { | ||
1781 | task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_DOWNGRADE]; | ||
1782 | calldata->arg.fmode = FMODE_WRITE; | ||
1783 | } | ||
1784 | calldata->timestamp = jiffies; | 1800 | calldata->timestamp = jiffies; |
1785 | if (nfs4_setup_sequence((NFS_SERVER(calldata->inode))->nfs_client, | 1801 | if (nfs4_setup_sequence((NFS_SERVER(calldata->inode))->nfs_client, |
1786 | &calldata->arg.seq_args, &calldata->res.seq_res, | 1802 | &calldata->arg.seq_args, &calldata->res.seq_res, |
@@ -1981,7 +1997,7 @@ out_drop: | |||
1981 | return 0; | 1997 | return 0; |
1982 | } | 1998 | } |
1983 | 1999 | ||
1984 | void nfs4_close_context(struct nfs_open_context *ctx, int is_sync) | 2000 | static void nfs4_close_context(struct nfs_open_context *ctx, int is_sync) |
1985 | { | 2001 | { |
1986 | if (ctx->state == NULL) | 2002 | if (ctx->state == NULL) |
1987 | return; | 2003 | return; |
@@ -2532,7 +2548,6 @@ static int nfs4_proc_unlink_done(struct rpc_task *task, struct inode *dir) | |||
2532 | nfs4_sequence_done(res->server, &res->seq_res, task->tk_status); | 2548 | nfs4_sequence_done(res->server, &res->seq_res, task->tk_status); |
2533 | if (nfs4_async_handle_error(task, res->server, NULL) == -EAGAIN) | 2549 | if (nfs4_async_handle_error(task, res->server, NULL) == -EAGAIN) |
2534 | return 0; | 2550 | return 0; |
2535 | nfs4_sequence_free_slot(res->server->nfs_client, &res->seq_res); | ||
2536 | update_changeattr(dir, &res->cinfo); | 2551 | update_changeattr(dir, &res->cinfo); |
2537 | nfs_post_op_update_inode(dir, &res->dir_attr); | 2552 | nfs_post_op_update_inode(dir, &res->dir_attr); |
2538 | return 1; | 2553 | return 1; |
@@ -2971,11 +2986,10 @@ static int nfs4_read_done(struct rpc_task *task, struct nfs_read_data *data) | |||
2971 | 2986 | ||
2972 | dprintk("--> %s\n", __func__); | 2987 | dprintk("--> %s\n", __func__); |
2973 | 2988 | ||
2974 | /* nfs4_sequence_free_slot called in the read rpc_call_done */ | ||
2975 | nfs4_sequence_done(server, &data->res.seq_res, task->tk_status); | 2989 | nfs4_sequence_done(server, &data->res.seq_res, task->tk_status); |
2976 | 2990 | ||
2977 | if (nfs4_async_handle_error(task, server, data->args.context->state) == -EAGAIN) { | 2991 | if (nfs4_async_handle_error(task, server, data->args.context->state) == -EAGAIN) { |
2978 | nfs4_restart_rpc(task, server->nfs_client); | 2992 | nfs_restart_rpc(task, server->nfs_client); |
2979 | return -EAGAIN; | 2993 | return -EAGAIN; |
2980 | } | 2994 | } |
2981 | 2995 | ||
@@ -2995,12 +3009,11 @@ static int nfs4_write_done(struct rpc_task *task, struct nfs_write_data *data) | |||
2995 | { | 3009 | { |
2996 | struct inode *inode = data->inode; | 3010 | struct inode *inode = data->inode; |
2997 | 3011 | ||
2998 | /* slot is freed in nfs_writeback_done */ | ||
2999 | nfs4_sequence_done(NFS_SERVER(inode), &data->res.seq_res, | 3012 | nfs4_sequence_done(NFS_SERVER(inode), &data->res.seq_res, |
3000 | task->tk_status); | 3013 | task->tk_status); |
3001 | 3014 | ||
3002 | if (nfs4_async_handle_error(task, NFS_SERVER(inode), data->args.context->state) == -EAGAIN) { | 3015 | if (nfs4_async_handle_error(task, NFS_SERVER(inode), data->args.context->state) == -EAGAIN) { |
3003 | nfs4_restart_rpc(task, NFS_SERVER(inode)->nfs_client); | 3016 | nfs_restart_rpc(task, NFS_SERVER(inode)->nfs_client); |
3004 | return -EAGAIN; | 3017 | return -EAGAIN; |
3005 | } | 3018 | } |
3006 | if (task->tk_status >= 0) { | 3019 | if (task->tk_status >= 0) { |
@@ -3028,11 +3041,9 @@ static int nfs4_commit_done(struct rpc_task *task, struct nfs_write_data *data) | |||
3028 | nfs4_sequence_done(NFS_SERVER(inode), &data->res.seq_res, | 3041 | nfs4_sequence_done(NFS_SERVER(inode), &data->res.seq_res, |
3029 | task->tk_status); | 3042 | task->tk_status); |
3030 | if (nfs4_async_handle_error(task, NFS_SERVER(inode), NULL) == -EAGAIN) { | 3043 | if (nfs4_async_handle_error(task, NFS_SERVER(inode), NULL) == -EAGAIN) { |
3031 | nfs4_restart_rpc(task, NFS_SERVER(inode)->nfs_client); | 3044 | nfs_restart_rpc(task, NFS_SERVER(inode)->nfs_client); |
3032 | return -EAGAIN; | 3045 | return -EAGAIN; |
3033 | } | 3046 | } |
3034 | nfs4_sequence_free_slot(NFS_SERVER(inode)->nfs_client, | ||
3035 | &data->res.seq_res); | ||
3036 | nfs_refresh_inode(inode, data->res.fattr); | 3047 | nfs_refresh_inode(inode, data->res.fattr); |
3037 | return 0; | 3048 | return 0; |
3038 | } | 3049 | } |
@@ -3350,7 +3361,7 @@ _nfs4_async_handle_error(struct rpc_task *task, const struct nfs_server *server, | |||
3350 | case -NFS4ERR_SEQ_MISORDERED: | 3361 | case -NFS4ERR_SEQ_MISORDERED: |
3351 | dprintk("%s ERROR %d, Reset session\n", __func__, | 3362 | dprintk("%s ERROR %d, Reset session\n", __func__, |
3352 | task->tk_status); | 3363 | task->tk_status); |
3353 | set_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state); | 3364 | nfs4_schedule_state_recovery(clp); |
3354 | task->tk_status = 0; | 3365 | task->tk_status = 0; |
3355 | return -EAGAIN; | 3366 | return -EAGAIN; |
3356 | #endif /* CONFIG_NFS_V4_1 */ | 3367 | #endif /* CONFIG_NFS_V4_1 */ |
@@ -3483,12 +3494,23 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata) | |||
3483 | { | 3494 | { |
3484 | struct nfs4_delegreturndata *data = calldata; | 3495 | struct nfs4_delegreturndata *data = calldata; |
3485 | 3496 | ||
3486 | nfs4_sequence_done_free_slot(data->res.server, &data->res.seq_res, | 3497 | nfs4_sequence_done(data->res.server, &data->res.seq_res, |
3487 | task->tk_status); | 3498 | task->tk_status); |
3488 | 3499 | ||
3489 | data->rpc_status = task->tk_status; | 3500 | switch (task->tk_status) { |
3490 | if (data->rpc_status == 0) | 3501 | case -NFS4ERR_STALE_STATEID: |
3502 | case -NFS4ERR_EXPIRED: | ||
3503 | case 0: | ||
3491 | renew_lease(data->res.server, data->timestamp); | 3504 | renew_lease(data->res.server, data->timestamp); |
3505 | break; | ||
3506 | default: | ||
3507 | if (nfs4_async_handle_error(task, data->res.server, NULL) == | ||
3508 | -EAGAIN) { | ||
3509 | nfs_restart_rpc(task, data->res.server->nfs_client); | ||
3510 | return; | ||
3511 | } | ||
3512 | } | ||
3513 | data->rpc_status = task->tk_status; | ||
3492 | } | 3514 | } |
3493 | 3515 | ||
3494 | static void nfs4_delegreturn_release(void *calldata) | 3516 | static void nfs4_delegreturn_release(void *calldata) |
@@ -3741,11 +3763,9 @@ static void nfs4_locku_done(struct rpc_task *task, void *data) | |||
3741 | break; | 3763 | break; |
3742 | default: | 3764 | default: |
3743 | if (nfs4_async_handle_error(task, calldata->server, NULL) == -EAGAIN) | 3765 | if (nfs4_async_handle_error(task, calldata->server, NULL) == -EAGAIN) |
3744 | nfs4_restart_rpc(task, | 3766 | nfs_restart_rpc(task, |
3745 | calldata->server->nfs_client); | 3767 | calldata->server->nfs_client); |
3746 | } | 3768 | } |
3747 | nfs4_sequence_free_slot(calldata->server->nfs_client, | ||
3748 | &calldata->res.seq_res); | ||
3749 | } | 3769 | } |
3750 | 3770 | ||
3751 | static void nfs4_locku_prepare(struct rpc_task *task, void *data) | 3771 | static void nfs4_locku_prepare(struct rpc_task *task, void *data) |
@@ -3927,8 +3947,8 @@ static void nfs4_lock_done(struct rpc_task *task, void *calldata) | |||
3927 | 3947 | ||
3928 | dprintk("%s: begin!\n", __func__); | 3948 | dprintk("%s: begin!\n", __func__); |
3929 | 3949 | ||
3930 | nfs4_sequence_done_free_slot(data->server, &data->res.seq_res, | 3950 | nfs4_sequence_done(data->server, &data->res.seq_res, |
3931 | task->tk_status); | 3951 | task->tk_status); |
3932 | 3952 | ||
3933 | data->rpc_status = task->tk_status; | 3953 | data->rpc_status = task->tk_status; |
3934 | if (RPC_ASSASSINATED(task)) | 3954 | if (RPC_ASSASSINATED(task)) |
@@ -4049,10 +4069,16 @@ static int nfs4_lock_expired(struct nfs4_state *state, struct file_lock *request | |||
4049 | if (test_bit(NFS_DELEGATED_STATE, &state->flags) != 0) | 4069 | if (test_bit(NFS_DELEGATED_STATE, &state->flags) != 0) |
4050 | return 0; | 4070 | return 0; |
4051 | err = _nfs4_do_setlk(state, F_SETLK, request, 0); | 4071 | err = _nfs4_do_setlk(state, F_SETLK, request, 0); |
4052 | if (err != -NFS4ERR_DELAY) | 4072 | switch (err) { |
4053 | break; | 4073 | default: |
4054 | nfs4_handle_exception(server, err, &exception); | 4074 | goto out; |
4075 | case -NFS4ERR_GRACE: | ||
4076 | case -NFS4ERR_DELAY: | ||
4077 | nfs4_handle_exception(server, err, &exception); | ||
4078 | err = 0; | ||
4079 | } | ||
4055 | } while (exception.retry); | 4080 | } while (exception.retry); |
4081 | out: | ||
4056 | return err; | 4082 | return err; |
4057 | } | 4083 | } |
4058 | 4084 | ||
@@ -4172,6 +4198,11 @@ int nfs4_lock_delegation_recall(struct nfs4_state *state, struct file_lock *fl) | |||
4172 | case -NFS4ERR_EXPIRED: | 4198 | case -NFS4ERR_EXPIRED: |
4173 | case -NFS4ERR_STALE_CLIENTID: | 4199 | case -NFS4ERR_STALE_CLIENTID: |
4174 | case -NFS4ERR_STALE_STATEID: | 4200 | case -NFS4ERR_STALE_STATEID: |
4201 | case -NFS4ERR_BADSESSION: | ||
4202 | case -NFS4ERR_BADSLOT: | ||
4203 | case -NFS4ERR_BAD_HIGH_SLOT: | ||
4204 | case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: | ||
4205 | case -NFS4ERR_DEADSESSION: | ||
4175 | nfs4_schedule_state_recovery(server->nfs_client); | 4206 | nfs4_schedule_state_recovery(server->nfs_client); |
4176 | goto out; | 4207 | goto out; |
4177 | case -ERESTARTSYS: | 4208 | case -ERESTARTSYS: |
@@ -4296,7 +4327,7 @@ int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name, | |||
4296 | * NFS4ERR_BADSESSION in the sequence operation, and will therefore | 4327 | * NFS4ERR_BADSESSION in the sequence operation, and will therefore |
4297 | * be in some phase of session reset. | 4328 | * be in some phase of session reset. |
4298 | */ | 4329 | */ |
4299 | static int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred) | 4330 | int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred) |
4300 | { | 4331 | { |
4301 | nfs4_verifier verifier; | 4332 | nfs4_verifier verifier; |
4302 | struct nfs41_exchange_id_args args = { | 4333 | struct nfs41_exchange_id_args args = { |
@@ -4318,6 +4349,9 @@ static int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred) | |||
4318 | dprintk("--> %s\n", __func__); | 4349 | dprintk("--> %s\n", __func__); |
4319 | BUG_ON(clp == NULL); | 4350 | BUG_ON(clp == NULL); |
4320 | 4351 | ||
4352 | /* Remove server-only flags */ | ||
4353 | args.flags &= ~EXCHGID4_FLAG_CONFIRMED_R; | ||
4354 | |||
4321 | p = (u32 *)verifier.data; | 4355 | p = (u32 *)verifier.data; |
4322 | *p++ = htonl((u32)clp->cl_boot_time.tv_sec); | 4356 | *p++ = htonl((u32)clp->cl_boot_time.tv_sec); |
4323 | *p = htonl((u32)clp->cl_boot_time.tv_nsec); | 4357 | *p = htonl((u32)clp->cl_boot_time.tv_nsec); |
@@ -4389,10 +4423,9 @@ static void nfs4_get_lease_time_done(struct rpc_task *task, void *calldata) | |||
4389 | dprintk("%s Retry: tk_status %d\n", __func__, task->tk_status); | 4423 | dprintk("%s Retry: tk_status %d\n", __func__, task->tk_status); |
4390 | rpc_delay(task, NFS4_POLL_RETRY_MIN); | 4424 | rpc_delay(task, NFS4_POLL_RETRY_MIN); |
4391 | task->tk_status = 0; | 4425 | task->tk_status = 0; |
4392 | nfs4_restart_rpc(task, data->clp); | 4426 | nfs_restart_rpc(task, data->clp); |
4393 | return; | 4427 | return; |
4394 | } | 4428 | } |
4395 | nfs41_sequence_free_slot(data->clp, &data->res->lr_seq_res); | ||
4396 | dprintk("<-- %s\n", __func__); | 4429 | dprintk("<-- %s\n", __func__); |
4397 | } | 4430 | } |
4398 | 4431 | ||
@@ -4465,7 +4498,6 @@ static int nfs4_reset_slot_table(struct nfs4_slot_table *tbl, int max_slots, | |||
4465 | spin_lock(&tbl->slot_tbl_lock); | 4498 | spin_lock(&tbl->slot_tbl_lock); |
4466 | for (i = 0; i < max_slots; ++i) | 4499 | for (i = 0; i < max_slots; ++i) |
4467 | tbl->slots[i].seq_nr = ivalue; | 4500 | tbl->slots[i].seq_nr = ivalue; |
4468 | tbl->highest_used_slotid = -1; | ||
4469 | spin_unlock(&tbl->slot_tbl_lock); | 4501 | spin_unlock(&tbl->slot_tbl_lock); |
4470 | dprintk("%s: tbl=%p slots=%p max_slots=%d\n", __func__, | 4502 | dprintk("%s: tbl=%p slots=%p max_slots=%d\n", __func__, |
4471 | tbl, tbl->slots, tbl->max_slots); | 4503 | tbl, tbl->slots, tbl->max_slots); |
@@ -4515,7 +4547,6 @@ static void nfs4_destroy_slot_tables(struct nfs4_session *session) | |||
4515 | static int nfs4_init_slot_table(struct nfs4_slot_table *tbl, | 4547 | static int nfs4_init_slot_table(struct nfs4_slot_table *tbl, |
4516 | int max_slots, int ivalue) | 4548 | int max_slots, int ivalue) |
4517 | { | 4549 | { |
4518 | int i; | ||
4519 | struct nfs4_slot *slot; | 4550 | struct nfs4_slot *slot; |
4520 | int ret = -ENOMEM; | 4551 | int ret = -ENOMEM; |
4521 | 4552 | ||
@@ -4526,18 +4557,9 @@ static int nfs4_init_slot_table(struct nfs4_slot_table *tbl, | |||
4526 | slot = kcalloc(max_slots, sizeof(struct nfs4_slot), GFP_KERNEL); | 4557 | slot = kcalloc(max_slots, sizeof(struct nfs4_slot), GFP_KERNEL); |
4527 | if (!slot) | 4558 | if (!slot) |
4528 | goto out; | 4559 | goto out; |
4529 | for (i = 0; i < max_slots; ++i) | ||
4530 | slot[i].seq_nr = ivalue; | ||
4531 | ret = 0; | 4560 | ret = 0; |
4532 | 4561 | ||
4533 | spin_lock(&tbl->slot_tbl_lock); | 4562 | spin_lock(&tbl->slot_tbl_lock); |
4534 | if (tbl->slots != NULL) { | ||
4535 | spin_unlock(&tbl->slot_tbl_lock); | ||
4536 | dprintk("%s: slot table already initialized. tbl=%p slots=%p\n", | ||
4537 | __func__, tbl, tbl->slots); | ||
4538 | WARN_ON(1); | ||
4539 | goto out_free; | ||
4540 | } | ||
4541 | tbl->max_slots = max_slots; | 4563 | tbl->max_slots = max_slots; |
4542 | tbl->slots = slot; | 4564 | tbl->slots = slot; |
4543 | tbl->highest_used_slotid = -1; /* no slot is currently used */ | 4565 | tbl->highest_used_slotid = -1; /* no slot is currently used */ |
@@ -4547,10 +4569,6 @@ static int nfs4_init_slot_table(struct nfs4_slot_table *tbl, | |||
4547 | out: | 4569 | out: |
4548 | dprintk("<-- %s: return %d\n", __func__, ret); | 4570 | dprintk("<-- %s: return %d\n", __func__, ret); |
4549 | return ret; | 4571 | return ret; |
4550 | |||
4551 | out_free: | ||
4552 | kfree(slot); | ||
4553 | goto out; | ||
4554 | } | 4572 | } |
4555 | 4573 | ||
4556 | /* | 4574 | /* |
@@ -4558,17 +4576,24 @@ out_free: | |||
4558 | */ | 4576 | */ |
4559 | static int nfs4_init_slot_tables(struct nfs4_session *session) | 4577 | static int nfs4_init_slot_tables(struct nfs4_session *session) |
4560 | { | 4578 | { |
4561 | int status; | 4579 | struct nfs4_slot_table *tbl; |
4580 | int status = 0; | ||
4562 | 4581 | ||
4563 | status = nfs4_init_slot_table(&session->fc_slot_table, | 4582 | tbl = &session->fc_slot_table; |
4564 | session->fc_attrs.max_reqs, 1); | 4583 | if (tbl->slots == NULL) { |
4565 | if (status) | 4584 | status = nfs4_init_slot_table(tbl, |
4566 | return status; | 4585 | session->fc_attrs.max_reqs, 1); |
4586 | if (status) | ||
4587 | return status; | ||
4588 | } | ||
4567 | 4589 | ||
4568 | status = nfs4_init_slot_table(&session->bc_slot_table, | 4590 | tbl = &session->bc_slot_table; |
4569 | session->bc_attrs.max_reqs, 0); | 4591 | if (tbl->slots == NULL) { |
4570 | if (status) | 4592 | status = nfs4_init_slot_table(tbl, |
4571 | nfs4_destroy_slot_tables(session); | 4593 | session->bc_attrs.max_reqs, 0); |
4594 | if (status) | ||
4595 | nfs4_destroy_slot_tables(session); | ||
4596 | } | ||
4572 | 4597 | ||
4573 | return status; | 4598 | return status; |
4574 | } | 4599 | } |
@@ -4582,7 +4607,6 @@ struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp) | |||
4582 | if (!session) | 4607 | if (!session) |
4583 | return NULL; | 4608 | return NULL; |
4584 | 4609 | ||
4585 | set_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state); | ||
4586 | /* | 4610 | /* |
4587 | * The create session reply races with the server back | 4611 | * The create session reply races with the server back |
4588 | * channel probe. Mark the client NFS_CS_SESSION_INITING | 4612 | * channel probe. Mark the client NFS_CS_SESSION_INITING |
@@ -4590,12 +4614,15 @@ struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp) | |||
4590 | * nfs_client struct | 4614 | * nfs_client struct |
4591 | */ | 4615 | */ |
4592 | clp->cl_cons_state = NFS_CS_SESSION_INITING; | 4616 | clp->cl_cons_state = NFS_CS_SESSION_INITING; |
4617 | init_completion(&session->complete); | ||
4593 | 4618 | ||
4594 | tbl = &session->fc_slot_table; | 4619 | tbl = &session->fc_slot_table; |
4620 | tbl->highest_used_slotid = -1; | ||
4595 | spin_lock_init(&tbl->slot_tbl_lock); | 4621 | spin_lock_init(&tbl->slot_tbl_lock); |
4596 | rpc_init_wait_queue(&tbl->slot_tbl_waitq, "ForeChannel Slot table"); | 4622 | rpc_init_wait_queue(&tbl->slot_tbl_waitq, "ForeChannel Slot table"); |
4597 | 4623 | ||
4598 | tbl = &session->bc_slot_table; | 4624 | tbl = &session->bc_slot_table; |
4625 | tbl->highest_used_slotid = -1; | ||
4599 | spin_lock_init(&tbl->slot_tbl_lock); | 4626 | spin_lock_init(&tbl->slot_tbl_lock); |
4600 | rpc_init_wait_queue(&tbl->slot_tbl_waitq, "BackChannel Slot table"); | 4627 | rpc_init_wait_queue(&tbl->slot_tbl_waitq, "BackChannel Slot table"); |
4601 | 4628 | ||
@@ -4747,11 +4774,10 @@ static int _nfs4_proc_create_session(struct nfs_client *clp) | |||
4747 | * It is the responsibility of the caller to verify the session is | 4774 | * It is the responsibility of the caller to verify the session is |
4748 | * expired before calling this routine. | 4775 | * expired before calling this routine. |
4749 | */ | 4776 | */ |
4750 | int nfs4_proc_create_session(struct nfs_client *clp, int reset) | 4777 | int nfs4_proc_create_session(struct nfs_client *clp) |
4751 | { | 4778 | { |
4752 | int status; | 4779 | int status; |
4753 | unsigned *ptr; | 4780 | unsigned *ptr; |
4754 | struct nfs_fsinfo fsinfo; | ||
4755 | struct nfs4_session *session = clp->cl_session; | 4781 | struct nfs4_session *session = clp->cl_session; |
4756 | 4782 | ||
4757 | dprintk("--> %s clp=%p session=%p\n", __func__, clp, session); | 4783 | dprintk("--> %s clp=%p session=%p\n", __func__, clp, session); |
@@ -4760,35 +4786,19 @@ int nfs4_proc_create_session(struct nfs_client *clp, int reset) | |||
4760 | if (status) | 4786 | if (status) |
4761 | goto out; | 4787 | goto out; |
4762 | 4788 | ||
4763 | /* Init or reset the fore channel */ | 4789 | /* Init and reset the fore channel */ |
4764 | if (reset) | 4790 | status = nfs4_init_slot_tables(session); |
4765 | status = nfs4_reset_slot_tables(session); | 4791 | dprintk("slot table initialization returned %d\n", status); |
4766 | else | 4792 | if (status) |
4767 | status = nfs4_init_slot_tables(session); | 4793 | goto out; |
4768 | dprintk("fore channel slot table initialization returned %d\n", status); | 4794 | status = nfs4_reset_slot_tables(session); |
4795 | dprintk("slot table reset returned %d\n", status); | ||
4769 | if (status) | 4796 | if (status) |
4770 | goto out; | 4797 | goto out; |
4771 | 4798 | ||
4772 | ptr = (unsigned *)&session->sess_id.data[0]; | 4799 | ptr = (unsigned *)&session->sess_id.data[0]; |
4773 | dprintk("%s client>seqid %d sessionid %u:%u:%u:%u\n", __func__, | 4800 | dprintk("%s client>seqid %d sessionid %u:%u:%u:%u\n", __func__, |
4774 | clp->cl_seqid, ptr[0], ptr[1], ptr[2], ptr[3]); | 4801 | clp->cl_seqid, ptr[0], ptr[1], ptr[2], ptr[3]); |
4775 | |||
4776 | if (reset) | ||
4777 | /* Lease time is aleady set */ | ||
4778 | goto out; | ||
4779 | |||
4780 | /* Get the lease time */ | ||
4781 | status = nfs4_proc_get_lease_time(clp, &fsinfo); | ||
4782 | if (status == 0) { | ||
4783 | /* Update lease time and schedule renewal */ | ||
4784 | spin_lock(&clp->cl_lock); | ||
4785 | clp->cl_lease_time = fsinfo.lease_time * HZ; | ||
4786 | clp->cl_last_renewal = jiffies; | ||
4787 | clear_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); | ||
4788 | spin_unlock(&clp->cl_lock); | ||
4789 | |||
4790 | nfs4_schedule_state_renewal(clp); | ||
4791 | } | ||
4792 | out: | 4802 | out: |
4793 | dprintk("<-- %s\n", __func__); | 4803 | dprintk("<-- %s\n", __func__); |
4794 | return status; | 4804 | return status; |
@@ -4827,13 +4837,16 @@ int nfs4_proc_destroy_session(struct nfs4_session *session) | |||
4827 | int nfs4_init_session(struct nfs_server *server) | 4837 | int nfs4_init_session(struct nfs_server *server) |
4828 | { | 4838 | { |
4829 | struct nfs_client *clp = server->nfs_client; | 4839 | struct nfs_client *clp = server->nfs_client; |
4840 | struct nfs4_session *session; | ||
4830 | int ret; | 4841 | int ret; |
4831 | 4842 | ||
4832 | if (!nfs4_has_session(clp)) | 4843 | if (!nfs4_has_session(clp)) |
4833 | return 0; | 4844 | return 0; |
4834 | 4845 | ||
4835 | clp->cl_session->fc_attrs.max_rqst_sz = server->wsize; | 4846 | session = clp->cl_session; |
4836 | clp->cl_session->fc_attrs.max_resp_sz = server->rsize; | 4847 | session->fc_attrs.max_rqst_sz = server->wsize + nfs41_maxwrite_overhead; |
4848 | session->fc_attrs.max_resp_sz = server->rsize + nfs41_maxread_overhead; | ||
4849 | |||
4837 | ret = nfs4_recover_expired_lease(server); | 4850 | ret = nfs4_recover_expired_lease(server); |
4838 | if (!ret) | 4851 | if (!ret) |
4839 | ret = nfs4_check_client_ready(clp); | 4852 | ret = nfs4_check_client_ready(clp); |
@@ -4872,11 +4885,10 @@ void nfs41_sequence_call_done(struct rpc_task *task, void *data) | |||
4872 | 4885 | ||
4873 | if (_nfs4_async_handle_error(task, NULL, clp, NULL) | 4886 | if (_nfs4_async_handle_error(task, NULL, clp, NULL) |
4874 | == -EAGAIN) { | 4887 | == -EAGAIN) { |
4875 | nfs4_restart_rpc(task, clp); | 4888 | nfs_restart_rpc(task, clp); |
4876 | return; | 4889 | return; |
4877 | } | 4890 | } |
4878 | } | 4891 | } |
4879 | nfs41_sequence_free_slot(clp, task->tk_msg.rpc_resp); | ||
4880 | dprintk("%s rpc_cred %p\n", __func__, task->tk_msg.rpc_cred); | 4892 | dprintk("%s rpc_cred %p\n", __func__, task->tk_msg.rpc_cred); |
4881 | 4893 | ||
4882 | kfree(task->tk_msg.rpc_argp); | 4894 | kfree(task->tk_msg.rpc_argp); |
@@ -4931,6 +4943,109 @@ static int nfs41_proc_async_sequence(struct nfs_client *clp, | |||
4931 | &nfs41_sequence_ops, (void *)clp); | 4943 | &nfs41_sequence_ops, (void *)clp); |
4932 | } | 4944 | } |
4933 | 4945 | ||
4946 | struct nfs4_reclaim_complete_data { | ||
4947 | struct nfs_client *clp; | ||
4948 | struct nfs41_reclaim_complete_args arg; | ||
4949 | struct nfs41_reclaim_complete_res res; | ||
4950 | }; | ||
4951 | |||
4952 | static void nfs4_reclaim_complete_prepare(struct rpc_task *task, void *data) | ||
4953 | { | ||
4954 | struct nfs4_reclaim_complete_data *calldata = data; | ||
4955 | |||
4956 | if (nfs4_setup_sequence(calldata->clp, &calldata->arg.seq_args, | ||
4957 | &calldata->res.seq_res, 0, task)) | ||
4958 | return; | ||
4959 | |||
4960 | rpc_call_start(task); | ||
4961 | } | ||
4962 | |||
4963 | static void nfs4_reclaim_complete_done(struct rpc_task *task, void *data) | ||
4964 | { | ||
4965 | struct nfs4_reclaim_complete_data *calldata = data; | ||
4966 | struct nfs_client *clp = calldata->clp; | ||
4967 | struct nfs4_sequence_res *res = &calldata->res.seq_res; | ||
4968 | |||
4969 | dprintk("--> %s\n", __func__); | ||
4970 | nfs41_sequence_done(clp, res, task->tk_status); | ||
4971 | switch (task->tk_status) { | ||
4972 | case 0: | ||
4973 | case -NFS4ERR_COMPLETE_ALREADY: | ||
4974 | break; | ||
4975 | case -NFS4ERR_BADSESSION: | ||
4976 | case -NFS4ERR_DEADSESSION: | ||
4977 | /* | ||
4978 | * Handle the session error, but do not retry the operation, as | ||
4979 | * we have no way of telling whether the clientid had to be | ||
4980 | * reset before we got our reply. If reset, a new wave of | ||
4981 | * reclaim operations will follow, containing their own reclaim | ||
4982 | * complete. We don't want our retry to get on the way of | ||
4983 | * recovery by incorrectly indicating to the server that we're | ||
4984 | * done reclaiming state since the process had to be restarted. | ||
4985 | */ | ||
4986 | _nfs4_async_handle_error(task, NULL, clp, NULL); | ||
4987 | break; | ||
4988 | default: | ||
4989 | if (_nfs4_async_handle_error( | ||
4990 | task, NULL, clp, NULL) == -EAGAIN) { | ||
4991 | rpc_restart_call_prepare(task); | ||
4992 | return; | ||
4993 | } | ||
4994 | } | ||
4995 | |||
4996 | dprintk("<-- %s\n", __func__); | ||
4997 | } | ||
4998 | |||
4999 | static void nfs4_free_reclaim_complete_data(void *data) | ||
5000 | { | ||
5001 | struct nfs4_reclaim_complete_data *calldata = data; | ||
5002 | |||
5003 | kfree(calldata); | ||
5004 | } | ||
5005 | |||
5006 | static const struct rpc_call_ops nfs4_reclaim_complete_call_ops = { | ||
5007 | .rpc_call_prepare = nfs4_reclaim_complete_prepare, | ||
5008 | .rpc_call_done = nfs4_reclaim_complete_done, | ||
5009 | .rpc_release = nfs4_free_reclaim_complete_data, | ||
5010 | }; | ||
5011 | |||
5012 | /* | ||
5013 | * Issue a global reclaim complete. | ||
5014 | */ | ||
5015 | static int nfs41_proc_reclaim_complete(struct nfs_client *clp) | ||
5016 | { | ||
5017 | struct nfs4_reclaim_complete_data *calldata; | ||
5018 | struct rpc_task *task; | ||
5019 | struct rpc_message msg = { | ||
5020 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RECLAIM_COMPLETE], | ||
5021 | }; | ||
5022 | struct rpc_task_setup task_setup_data = { | ||
5023 | .rpc_client = clp->cl_rpcclient, | ||
5024 | .rpc_message = &msg, | ||
5025 | .callback_ops = &nfs4_reclaim_complete_call_ops, | ||
5026 | .flags = RPC_TASK_ASYNC, | ||
5027 | }; | ||
5028 | int status = -ENOMEM; | ||
5029 | |||
5030 | dprintk("--> %s\n", __func__); | ||
5031 | calldata = kzalloc(sizeof(*calldata), GFP_KERNEL); | ||
5032 | if (calldata == NULL) | ||
5033 | goto out; | ||
5034 | calldata->clp = clp; | ||
5035 | calldata->arg.one_fs = 0; | ||
5036 | calldata->res.seq_res.sr_slotid = NFS4_MAX_SLOT_TABLE; | ||
5037 | |||
5038 | msg.rpc_argp = &calldata->arg; | ||
5039 | msg.rpc_resp = &calldata->res; | ||
5040 | task_setup_data.callback_data = calldata; | ||
5041 | task = rpc_run_task(&task_setup_data); | ||
5042 | if (IS_ERR(task)) | ||
5043 | status = PTR_ERR(task); | ||
5044 | rpc_put_task(task); | ||
5045 | out: | ||
5046 | dprintk("<-- %s status=%d\n", __func__, status); | ||
5047 | return status; | ||
5048 | } | ||
4934 | #endif /* CONFIG_NFS_V4_1 */ | 5049 | #endif /* CONFIG_NFS_V4_1 */ |
4935 | 5050 | ||
4936 | struct nfs4_state_recovery_ops nfs40_reboot_recovery_ops = { | 5051 | struct nfs4_state_recovery_ops nfs40_reboot_recovery_ops = { |
@@ -4948,8 +5063,9 @@ struct nfs4_state_recovery_ops nfs41_reboot_recovery_ops = { | |||
4948 | .state_flag_bit = NFS_STATE_RECLAIM_REBOOT, | 5063 | .state_flag_bit = NFS_STATE_RECLAIM_REBOOT, |
4949 | .recover_open = nfs4_open_reclaim, | 5064 | .recover_open = nfs4_open_reclaim, |
4950 | .recover_lock = nfs4_lock_reclaim, | 5065 | .recover_lock = nfs4_lock_reclaim, |
4951 | .establish_clid = nfs4_proc_exchange_id, | 5066 | .establish_clid = nfs41_init_clientid, |
4952 | .get_clid_cred = nfs4_get_exchange_id_cred, | 5067 | .get_clid_cred = nfs4_get_exchange_id_cred, |
5068 | .reclaim_complete = nfs41_proc_reclaim_complete, | ||
4953 | }; | 5069 | }; |
4954 | #endif /* CONFIG_NFS_V4_1 */ | 5070 | #endif /* CONFIG_NFS_V4_1 */ |
4955 | 5071 | ||
@@ -4968,7 +5084,7 @@ struct nfs4_state_recovery_ops nfs41_nograce_recovery_ops = { | |||
4968 | .state_flag_bit = NFS_STATE_RECLAIM_NOGRACE, | 5084 | .state_flag_bit = NFS_STATE_RECLAIM_NOGRACE, |
4969 | .recover_open = nfs4_open_expired, | 5085 | .recover_open = nfs4_open_expired, |
4970 | .recover_lock = nfs4_lock_expired, | 5086 | .recover_lock = nfs4_lock_expired, |
4971 | .establish_clid = nfs4_proc_exchange_id, | 5087 | .establish_clid = nfs41_init_clientid, |
4972 | .get_clid_cred = nfs4_get_exchange_id_cred, | 5088 | .get_clid_cred = nfs4_get_exchange_id_cred, |
4973 | }; | 5089 | }; |
4974 | #endif /* CONFIG_NFS_V4_1 */ | 5090 | #endif /* CONFIG_NFS_V4_1 */ |
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 2ef4fecf3984..e76427e6346f 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c | |||
@@ -116,6 +116,68 @@ struct rpc_cred *nfs4_get_renew_cred_locked(struct nfs_client *clp) | |||
116 | 116 | ||
117 | #if defined(CONFIG_NFS_V4_1) | 117 | #if defined(CONFIG_NFS_V4_1) |
118 | 118 | ||
119 | static int nfs41_setup_state_renewal(struct nfs_client *clp) | ||
120 | { | ||
121 | int status; | ||
122 | struct nfs_fsinfo fsinfo; | ||
123 | |||
124 | status = nfs4_proc_get_lease_time(clp, &fsinfo); | ||
125 | if (status == 0) { | ||
126 | /* Update lease time and schedule renewal */ | ||
127 | spin_lock(&clp->cl_lock); | ||
128 | clp->cl_lease_time = fsinfo.lease_time * HZ; | ||
129 | clp->cl_last_renewal = jiffies; | ||
130 | spin_unlock(&clp->cl_lock); | ||
131 | |||
132 | nfs4_schedule_state_renewal(clp); | ||
133 | } | ||
134 | |||
135 | return status; | ||
136 | } | ||
137 | |||
138 | static void nfs41_end_drain_session(struct nfs_client *clp, | ||
139 | struct nfs4_session *ses) | ||
140 | { | ||
141 | if (test_and_clear_bit(NFS4CLNT_SESSION_DRAINING, &clp->cl_state)) | ||
142 | rpc_wake_up(&ses->fc_slot_table.slot_tbl_waitq); | ||
143 | } | ||
144 | |||
145 | static int nfs41_begin_drain_session(struct nfs_client *clp, | ||
146 | struct nfs4_session *ses) | ||
147 | { | ||
148 | struct nfs4_slot_table *tbl = &ses->fc_slot_table; | ||
149 | |||
150 | spin_lock(&tbl->slot_tbl_lock); | ||
151 | set_bit(NFS4CLNT_SESSION_DRAINING, &clp->cl_state); | ||
152 | if (tbl->highest_used_slotid != -1) { | ||
153 | INIT_COMPLETION(ses->complete); | ||
154 | spin_unlock(&tbl->slot_tbl_lock); | ||
155 | return wait_for_completion_interruptible(&ses->complete); | ||
156 | } | ||
157 | spin_unlock(&tbl->slot_tbl_lock); | ||
158 | return 0; | ||
159 | } | ||
160 | |||
161 | int nfs41_init_clientid(struct nfs_client *clp, struct rpc_cred *cred) | ||
162 | { | ||
163 | int status; | ||
164 | |||
165 | status = nfs41_begin_drain_session(clp, clp->cl_session); | ||
166 | if (status != 0) | ||
167 | goto out; | ||
168 | status = nfs4_proc_exchange_id(clp, cred); | ||
169 | if (status != 0) | ||
170 | goto out; | ||
171 | status = nfs4_proc_create_session(clp); | ||
172 | if (status != 0) | ||
173 | goto out; | ||
174 | nfs41_end_drain_session(clp, clp->cl_session); | ||
175 | nfs41_setup_state_renewal(clp); | ||
176 | nfs_mark_client_ready(clp, NFS_CS_READY); | ||
177 | out: | ||
178 | return status; | ||
179 | } | ||
180 | |||
119 | struct rpc_cred *nfs4_get_exchange_id_cred(struct nfs_client *clp) | 181 | struct rpc_cred *nfs4_get_exchange_id_cred(struct nfs_client *clp) |
120 | { | 182 | { |
121 | struct rpc_cred *cred; | 183 | struct rpc_cred *cred; |
@@ -877,6 +939,10 @@ static int nfs4_reclaim_locks(struct nfs4_state *state, const struct nfs4_state_ | |||
877 | case -NFS4ERR_EXPIRED: | 939 | case -NFS4ERR_EXPIRED: |
878 | case -NFS4ERR_NO_GRACE: | 940 | case -NFS4ERR_NO_GRACE: |
879 | case -NFS4ERR_STALE_CLIENTID: | 941 | case -NFS4ERR_STALE_CLIENTID: |
942 | case -NFS4ERR_BADSESSION: | ||
943 | case -NFS4ERR_BADSLOT: | ||
944 | case -NFS4ERR_BAD_HIGH_SLOT: | ||
945 | case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: | ||
880 | goto out; | 946 | goto out; |
881 | default: | 947 | default: |
882 | printk(KERN_ERR "%s: unhandled error %d. Zeroing state\n", | 948 | printk(KERN_ERR "%s: unhandled error %d. Zeroing state\n", |
@@ -959,6 +1025,10 @@ restart: | |||
959 | case -NFS4ERR_NO_GRACE: | 1025 | case -NFS4ERR_NO_GRACE: |
960 | nfs4_state_mark_reclaim_nograce(sp->so_client, state); | 1026 | nfs4_state_mark_reclaim_nograce(sp->so_client, state); |
961 | case -NFS4ERR_STALE_CLIENTID: | 1027 | case -NFS4ERR_STALE_CLIENTID: |
1028 | case -NFS4ERR_BADSESSION: | ||
1029 | case -NFS4ERR_BADSLOT: | ||
1030 | case -NFS4ERR_BAD_HIGH_SLOT: | ||
1031 | case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: | ||
962 | goto out_err; | 1032 | goto out_err; |
963 | } | 1033 | } |
964 | nfs4_put_open_state(state); | 1034 | nfs4_put_open_state(state); |
@@ -1011,6 +1081,14 @@ static void nfs4_state_start_reclaim_reboot(struct nfs_client *clp) | |||
1011 | nfs4_state_mark_reclaim_helper(clp, nfs4_state_mark_reclaim_reboot); | 1081 | nfs4_state_mark_reclaim_helper(clp, nfs4_state_mark_reclaim_reboot); |
1012 | } | 1082 | } |
1013 | 1083 | ||
1084 | static void nfs4_reclaim_complete(struct nfs_client *clp, | ||
1085 | const struct nfs4_state_recovery_ops *ops) | ||
1086 | { | ||
1087 | /* Notify the server we're done reclaiming our state */ | ||
1088 | if (ops->reclaim_complete) | ||
1089 | (void)ops->reclaim_complete(clp); | ||
1090 | } | ||
1091 | |||
1014 | static void nfs4_state_end_reclaim_reboot(struct nfs_client *clp) | 1092 | static void nfs4_state_end_reclaim_reboot(struct nfs_client *clp) |
1015 | { | 1093 | { |
1016 | struct nfs4_state_owner *sp; | 1094 | struct nfs4_state_owner *sp; |
@@ -1020,6 +1098,9 @@ static void nfs4_state_end_reclaim_reboot(struct nfs_client *clp) | |||
1020 | if (!test_and_clear_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state)) | 1098 | if (!test_and_clear_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state)) |
1021 | return; | 1099 | return; |
1022 | 1100 | ||
1101 | nfs4_reclaim_complete(clp, | ||
1102 | nfs4_reboot_recovery_ops[clp->cl_minorversion]); | ||
1103 | |||
1023 | for (pos = rb_first(&clp->cl_state_owners); pos != NULL; pos = rb_next(pos)) { | 1104 | for (pos = rb_first(&clp->cl_state_owners); pos != NULL; pos = rb_next(pos)) { |
1024 | sp = rb_entry(pos, struct nfs4_state_owner, so_client_node); | 1105 | sp = rb_entry(pos, struct nfs4_state_owner, so_client_node); |
1025 | spin_lock(&sp->so_lock); | 1106 | spin_lock(&sp->so_lock); |
@@ -1046,25 +1127,25 @@ static void nfs4_state_start_reclaim_nograce(struct nfs_client *clp) | |||
1046 | nfs4_state_mark_reclaim_helper(clp, nfs4_state_mark_reclaim_nograce); | 1127 | nfs4_state_mark_reclaim_helper(clp, nfs4_state_mark_reclaim_nograce); |
1047 | } | 1128 | } |
1048 | 1129 | ||
1049 | static void nfs4_state_end_reclaim_nograce(struct nfs_client *clp) | 1130 | static int nfs4_recovery_handle_error(struct nfs_client *clp, int error) |
1050 | { | ||
1051 | clear_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state); | ||
1052 | } | ||
1053 | |||
1054 | static void nfs4_recovery_handle_error(struct nfs_client *clp, int error) | ||
1055 | { | 1131 | { |
1056 | switch (error) { | 1132 | switch (error) { |
1057 | case -NFS4ERR_CB_PATH_DOWN: | 1133 | case -NFS4ERR_CB_PATH_DOWN: |
1058 | nfs_handle_cb_pathdown(clp); | 1134 | nfs_handle_cb_pathdown(clp); |
1059 | break; | 1135 | return 0; |
1136 | case -NFS4ERR_NO_GRACE: | ||
1137 | nfs4_state_end_reclaim_reboot(clp); | ||
1138 | return 0; | ||
1060 | case -NFS4ERR_STALE_CLIENTID: | 1139 | case -NFS4ERR_STALE_CLIENTID: |
1061 | case -NFS4ERR_LEASE_MOVED: | 1140 | case -NFS4ERR_LEASE_MOVED: |
1062 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); | 1141 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); |
1142 | nfs4_state_end_reclaim_reboot(clp); | ||
1063 | nfs4_state_start_reclaim_reboot(clp); | 1143 | nfs4_state_start_reclaim_reboot(clp); |
1064 | break; | 1144 | break; |
1065 | case -NFS4ERR_EXPIRED: | 1145 | case -NFS4ERR_EXPIRED: |
1066 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); | 1146 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); |
1067 | nfs4_state_start_reclaim_nograce(clp); | 1147 | nfs4_state_start_reclaim_nograce(clp); |
1148 | break; | ||
1068 | case -NFS4ERR_BADSESSION: | 1149 | case -NFS4ERR_BADSESSION: |
1069 | case -NFS4ERR_BADSLOT: | 1150 | case -NFS4ERR_BADSLOT: |
1070 | case -NFS4ERR_BAD_HIGH_SLOT: | 1151 | case -NFS4ERR_BAD_HIGH_SLOT: |
@@ -1072,8 +1153,11 @@ static void nfs4_recovery_handle_error(struct nfs_client *clp, int error) | |||
1072 | case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: | 1153 | case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: |
1073 | case -NFS4ERR_SEQ_FALSE_RETRY: | 1154 | case -NFS4ERR_SEQ_FALSE_RETRY: |
1074 | case -NFS4ERR_SEQ_MISORDERED: | 1155 | case -NFS4ERR_SEQ_MISORDERED: |
1075 | set_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state); | 1156 | set_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state); |
1157 | /* Zero session reset errors */ | ||
1158 | return 0; | ||
1076 | } | 1159 | } |
1160 | return error; | ||
1077 | } | 1161 | } |
1078 | 1162 | ||
1079 | static int nfs4_do_reclaim(struct nfs_client *clp, const struct nfs4_state_recovery_ops *ops) | 1163 | static int nfs4_do_reclaim(struct nfs_client *clp, const struct nfs4_state_recovery_ops *ops) |
@@ -1093,8 +1177,7 @@ restart: | |||
1093 | if (status < 0) { | 1177 | if (status < 0) { |
1094 | set_bit(ops->owner_flag_bit, &sp->so_flags); | 1178 | set_bit(ops->owner_flag_bit, &sp->so_flags); |
1095 | nfs4_put_state_owner(sp); | 1179 | nfs4_put_state_owner(sp); |
1096 | nfs4_recovery_handle_error(clp, status); | 1180 | return nfs4_recovery_handle_error(clp, status); |
1097 | return status; | ||
1098 | } | 1181 | } |
1099 | nfs4_put_state_owner(sp); | 1182 | nfs4_put_state_owner(sp); |
1100 | goto restart; | 1183 | goto restart; |
@@ -1124,8 +1207,7 @@ static int nfs4_check_lease(struct nfs_client *clp) | |||
1124 | status = ops->renew_lease(clp, cred); | 1207 | status = ops->renew_lease(clp, cred); |
1125 | put_rpccred(cred); | 1208 | put_rpccred(cred); |
1126 | out: | 1209 | out: |
1127 | nfs4_recovery_handle_error(clp, status); | 1210 | return nfs4_recovery_handle_error(clp, status); |
1128 | return status; | ||
1129 | } | 1211 | } |
1130 | 1212 | ||
1131 | static int nfs4_reclaim_lease(struct nfs_client *clp) | 1213 | static int nfs4_reclaim_lease(struct nfs_client *clp) |
@@ -1151,55 +1233,65 @@ static int nfs4_reclaim_lease(struct nfs_client *clp) | |||
1151 | } | 1233 | } |
1152 | 1234 | ||
1153 | #ifdef CONFIG_NFS_V4_1 | 1235 | #ifdef CONFIG_NFS_V4_1 |
1154 | static void nfs4_session_recovery_handle_error(struct nfs_client *clp, int err) | 1236 | void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags) |
1155 | { | 1237 | { |
1156 | switch (err) { | 1238 | if (!flags) |
1157 | case -NFS4ERR_STALE_CLIENTID: | 1239 | return; |
1240 | else if (flags & SEQ4_STATUS_RESTART_RECLAIM_NEEDED) { | ||
1158 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); | 1241 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); |
1159 | set_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state); | 1242 | nfs4_state_start_reclaim_reboot(clp); |
1160 | } | 1243 | nfs4_schedule_state_recovery(clp); |
1244 | } else if (flags & (SEQ4_STATUS_EXPIRED_ALL_STATE_REVOKED | | ||
1245 | SEQ4_STATUS_EXPIRED_SOME_STATE_REVOKED | | ||
1246 | SEQ4_STATUS_ADMIN_STATE_REVOKED | | ||
1247 | SEQ4_STATUS_RECALLABLE_STATE_REVOKED | | ||
1248 | SEQ4_STATUS_LEASE_MOVED)) { | ||
1249 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); | ||
1250 | nfs4_state_start_reclaim_nograce(clp); | ||
1251 | nfs4_schedule_state_recovery(clp); | ||
1252 | } else if (flags & (SEQ4_STATUS_CB_PATH_DOWN | | ||
1253 | SEQ4_STATUS_BACKCHANNEL_FAULT | | ||
1254 | SEQ4_STATUS_CB_PATH_DOWN_SESSION)) | ||
1255 | nfs_expire_all_delegations(clp); | ||
1161 | } | 1256 | } |
1162 | 1257 | ||
1163 | static int nfs4_reset_session(struct nfs_client *clp) | 1258 | static int nfs4_reset_session(struct nfs_client *clp) |
1164 | { | 1259 | { |
1260 | struct nfs4_session *ses = clp->cl_session; | ||
1165 | int status; | 1261 | int status; |
1166 | 1262 | ||
1263 | status = nfs41_begin_drain_session(clp, ses); | ||
1264 | if (status != 0) | ||
1265 | return status; | ||
1266 | |||
1167 | status = nfs4_proc_destroy_session(clp->cl_session); | 1267 | status = nfs4_proc_destroy_session(clp->cl_session); |
1168 | if (status && status != -NFS4ERR_BADSESSION && | 1268 | if (status && status != -NFS4ERR_BADSESSION && |
1169 | status != -NFS4ERR_DEADSESSION) { | 1269 | status != -NFS4ERR_DEADSESSION) { |
1170 | nfs4_session_recovery_handle_error(clp, status); | 1270 | status = nfs4_recovery_handle_error(clp, status); |
1171 | goto out; | 1271 | goto out; |
1172 | } | 1272 | } |
1173 | 1273 | ||
1174 | memset(clp->cl_session->sess_id.data, 0, NFS4_MAX_SESSIONID_LEN); | 1274 | memset(clp->cl_session->sess_id.data, 0, NFS4_MAX_SESSIONID_LEN); |
1175 | status = nfs4_proc_create_session(clp, 1); | 1275 | status = nfs4_proc_create_session(clp); |
1176 | if (status) | 1276 | if (status) |
1177 | nfs4_session_recovery_handle_error(clp, status); | 1277 | status = nfs4_recovery_handle_error(clp, status); |
1178 | /* fall through*/ | ||
1179 | out: | ||
1180 | /* Wake up the next rpc task even on error */ | ||
1181 | rpc_wake_up_next(&clp->cl_session->fc_slot_table.slot_tbl_waitq); | ||
1182 | return status; | ||
1183 | } | ||
1184 | |||
1185 | static int nfs4_initialize_session(struct nfs_client *clp) | ||
1186 | { | ||
1187 | int status; | ||
1188 | 1278 | ||
1189 | status = nfs4_proc_create_session(clp, 0); | 1279 | out: |
1190 | if (!status) { | 1280 | /* |
1191 | nfs_mark_client_ready(clp, NFS_CS_READY); | 1281 | * Let the state manager reestablish state |
1192 | } else if (status == -NFS4ERR_STALE_CLIENTID) { | 1282 | * without waking other tasks yet. |
1193 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); | 1283 | */ |
1194 | set_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state); | 1284 | if (!test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state)) { |
1195 | } else { | 1285 | /* Wake up the next rpc task */ |
1196 | nfs_mark_client_ready(clp, status); | 1286 | nfs41_end_drain_session(clp, ses); |
1287 | if (status == 0) | ||
1288 | nfs41_setup_state_renewal(clp); | ||
1197 | } | 1289 | } |
1198 | return status; | 1290 | return status; |
1199 | } | 1291 | } |
1292 | |||
1200 | #else /* CONFIG_NFS_V4_1 */ | 1293 | #else /* CONFIG_NFS_V4_1 */ |
1201 | static int nfs4_reset_session(struct nfs_client *clp) { return 0; } | 1294 | static int nfs4_reset_session(struct nfs_client *clp) { return 0; } |
1202 | static int nfs4_initialize_session(struct nfs_client *clp) { return 0; } | ||
1203 | #endif /* CONFIG_NFS_V4_1 */ | 1295 | #endif /* CONFIG_NFS_V4_1 */ |
1204 | 1296 | ||
1205 | /* Set NFS4CLNT_LEASE_EXPIRED for all v4.0 errors and for recoverable errors | 1297 | /* Set NFS4CLNT_LEASE_EXPIRED for all v4.0 errors and for recoverable errors |
@@ -1234,7 +1326,8 @@ static void nfs4_state_manager(struct nfs_client *clp) | |||
1234 | status = nfs4_reclaim_lease(clp); | 1326 | status = nfs4_reclaim_lease(clp); |
1235 | if (status) { | 1327 | if (status) { |
1236 | nfs4_set_lease_expired(clp, status); | 1328 | nfs4_set_lease_expired(clp, status); |
1237 | if (status == -EAGAIN) | 1329 | if (test_bit(NFS4CLNT_LEASE_EXPIRED, |
1330 | &clp->cl_state)) | ||
1238 | continue; | 1331 | continue; |
1239 | if (clp->cl_cons_state == | 1332 | if (clp->cl_cons_state == |
1240 | NFS_CS_SESSION_INITING) | 1333 | NFS_CS_SESSION_INITING) |
@@ -1242,55 +1335,51 @@ static void nfs4_state_manager(struct nfs_client *clp) | |||
1242 | goto out_error; | 1335 | goto out_error; |
1243 | } | 1336 | } |
1244 | clear_bit(NFS4CLNT_CHECK_LEASE, &clp->cl_state); | 1337 | clear_bit(NFS4CLNT_CHECK_LEASE, &clp->cl_state); |
1338 | set_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state); | ||
1245 | } | 1339 | } |
1246 | 1340 | ||
1247 | if (test_and_clear_bit(NFS4CLNT_CHECK_LEASE, &clp->cl_state)) { | 1341 | if (test_and_clear_bit(NFS4CLNT_CHECK_LEASE, &clp->cl_state)) { |
1248 | status = nfs4_check_lease(clp); | 1342 | status = nfs4_check_lease(clp); |
1249 | if (status != 0) | 1343 | if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state)) |
1250 | continue; | 1344 | continue; |
1345 | if (status < 0 && status != -NFS4ERR_CB_PATH_DOWN) | ||
1346 | goto out_error; | ||
1251 | } | 1347 | } |
1348 | |||
1252 | /* Initialize or reset the session */ | 1349 | /* Initialize or reset the session */ |
1253 | if (test_and_clear_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state) | 1350 | if (test_and_clear_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state) |
1254 | && nfs4_has_session(clp)) { | 1351 | && nfs4_has_session(clp)) { |
1255 | if (clp->cl_cons_state == NFS_CS_SESSION_INITING) | 1352 | status = nfs4_reset_session(clp); |
1256 | status = nfs4_initialize_session(clp); | 1353 | if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state)) |
1257 | else | 1354 | continue; |
1258 | status = nfs4_reset_session(clp); | 1355 | if (status < 0) |
1259 | if (status) { | ||
1260 | if (status == -NFS4ERR_STALE_CLIENTID) | ||
1261 | continue; | ||
1262 | goto out_error; | 1356 | goto out_error; |
1263 | } | ||
1264 | } | 1357 | } |
1358 | |||
1265 | /* First recover reboot state... */ | 1359 | /* First recover reboot state... */ |
1266 | if (test_and_clear_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state)) { | 1360 | if (test_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state)) { |
1267 | status = nfs4_do_reclaim(clp, | 1361 | status = nfs4_do_reclaim(clp, |
1268 | nfs4_reboot_recovery_ops[clp->cl_minorversion]); | 1362 | nfs4_reboot_recovery_ops[clp->cl_minorversion]); |
1269 | if (status == -NFS4ERR_STALE_CLIENTID) | 1363 | if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state) || |
1270 | continue; | 1364 | test_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state)) |
1271 | if (test_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state)) | ||
1272 | continue; | 1365 | continue; |
1273 | nfs4_state_end_reclaim_reboot(clp); | 1366 | nfs4_state_end_reclaim_reboot(clp); |
1274 | continue; | 1367 | if (test_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state)) |
1368 | continue; | ||
1369 | if (status < 0) | ||
1370 | goto out_error; | ||
1275 | } | 1371 | } |
1276 | 1372 | ||
1277 | /* Now recover expired state... */ | 1373 | /* Now recover expired state... */ |
1278 | if (test_and_clear_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state)) { | 1374 | if (test_and_clear_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state)) { |
1279 | status = nfs4_do_reclaim(clp, | 1375 | status = nfs4_do_reclaim(clp, |
1280 | nfs4_nograce_recovery_ops[clp->cl_minorversion]); | 1376 | nfs4_nograce_recovery_ops[clp->cl_minorversion]); |
1281 | if (status < 0) { | 1377 | if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state) || |
1282 | set_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state); | 1378 | test_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state) || |
1283 | if (status == -NFS4ERR_STALE_CLIENTID) | 1379 | test_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state)) |
1284 | continue; | 1380 | continue; |
1285 | if (status == -NFS4ERR_EXPIRED) | 1381 | if (status < 0) |
1286 | continue; | ||
1287 | if (test_bit(NFS4CLNT_SESSION_SETUP, | ||
1288 | &clp->cl_state)) | ||
1289 | continue; | ||
1290 | goto out_error; | 1382 | goto out_error; |
1291 | } else | ||
1292 | nfs4_state_end_reclaim_nograce(clp); | ||
1293 | continue; | ||
1294 | } | 1383 | } |
1295 | 1384 | ||
1296 | if (test_and_clear_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state)) { | 1385 | if (test_and_clear_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state)) { |
@@ -1309,8 +1398,6 @@ static void nfs4_state_manager(struct nfs_client *clp) | |||
1309 | out_error: | 1398 | out_error: |
1310 | printk(KERN_WARNING "Error: state manager failed on NFSv4 server %s" | 1399 | printk(KERN_WARNING "Error: state manager failed on NFSv4 server %s" |
1311 | " with error %d\n", clp->cl_hostname, -status); | 1400 | " with error %d\n", clp->cl_hostname, -status); |
1312 | if (test_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state)) | ||
1313 | nfs4_state_end_reclaim_reboot(clp); | ||
1314 | nfs4_clear_state_manager_bit(clp); | 1401 | nfs4_clear_state_manager_bit(clp); |
1315 | } | 1402 | } |
1316 | 1403 | ||
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 20b4e30e6c82..e437fd6a819f 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c | |||
@@ -46,11 +46,13 @@ | |||
46 | #include <linux/proc_fs.h> | 46 | #include <linux/proc_fs.h> |
47 | #include <linux/kdev_t.h> | 47 | #include <linux/kdev_t.h> |
48 | #include <linux/sunrpc/clnt.h> | 48 | #include <linux/sunrpc/clnt.h> |
49 | #include <linux/sunrpc/msg_prot.h> | ||
49 | #include <linux/nfs.h> | 50 | #include <linux/nfs.h> |
50 | #include <linux/nfs4.h> | 51 | #include <linux/nfs4.h> |
51 | #include <linux/nfs_fs.h> | 52 | #include <linux/nfs_fs.h> |
52 | #include <linux/nfs_idmap.h> | 53 | #include <linux/nfs_idmap.h> |
53 | #include "nfs4_fs.h" | 54 | #include "nfs4_fs.h" |
55 | #include "internal.h" | ||
54 | 56 | ||
55 | #define NFSDBG_FACILITY NFSDBG_XDR | 57 | #define NFSDBG_FACILITY NFSDBG_XDR |
56 | 58 | ||
@@ -134,7 +136,7 @@ static int nfs4_stat_to_errno(int); | |||
134 | #define decode_lookup_maxsz (op_decode_hdr_maxsz) | 136 | #define decode_lookup_maxsz (op_decode_hdr_maxsz) |
135 | #define encode_share_access_maxsz \ | 137 | #define encode_share_access_maxsz \ |
136 | (2) | 138 | (2) |
137 | #define encode_createmode_maxsz (1 + encode_attrs_maxsz) | 139 | #define encode_createmode_maxsz (1 + encode_attrs_maxsz + encode_verifier_maxsz) |
138 | #define encode_opentype_maxsz (1 + encode_createmode_maxsz) | 140 | #define encode_opentype_maxsz (1 + encode_createmode_maxsz) |
139 | #define encode_claim_null_maxsz (1 + nfs4_name_maxsz) | 141 | #define encode_claim_null_maxsz (1 + nfs4_name_maxsz) |
140 | #define encode_open_maxsz (op_encode_hdr_maxsz + \ | 142 | #define encode_open_maxsz (op_encode_hdr_maxsz + \ |
@@ -299,6 +301,8 @@ static int nfs4_stat_to_errno(int); | |||
299 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 4) | 301 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 4) |
300 | #define decode_sequence_maxsz (op_decode_hdr_maxsz + \ | 302 | #define decode_sequence_maxsz (op_decode_hdr_maxsz + \ |
301 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5) | 303 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5) |
304 | #define encode_reclaim_complete_maxsz (op_encode_hdr_maxsz + 4) | ||
305 | #define decode_reclaim_complete_maxsz (op_decode_hdr_maxsz + 4) | ||
302 | #else /* CONFIG_NFS_V4_1 */ | 306 | #else /* CONFIG_NFS_V4_1 */ |
303 | #define encode_sequence_maxsz 0 | 307 | #define encode_sequence_maxsz 0 |
304 | #define decode_sequence_maxsz 0 | 308 | #define decode_sequence_maxsz 0 |
@@ -676,6 +680,25 @@ static int nfs4_stat_to_errno(int); | |||
676 | decode_sequence_maxsz + \ | 680 | decode_sequence_maxsz + \ |
677 | decode_putrootfh_maxsz + \ | 681 | decode_putrootfh_maxsz + \ |
678 | decode_fsinfo_maxsz) | 682 | decode_fsinfo_maxsz) |
683 | #define NFS4_enc_reclaim_complete_sz (compound_encode_hdr_maxsz + \ | ||
684 | encode_sequence_maxsz + \ | ||
685 | encode_reclaim_complete_maxsz) | ||
686 | #define NFS4_dec_reclaim_complete_sz (compound_decode_hdr_maxsz + \ | ||
687 | decode_sequence_maxsz + \ | ||
688 | decode_reclaim_complete_maxsz) | ||
689 | |||
690 | const u32 nfs41_maxwrite_overhead = ((RPC_MAX_HEADER_WITH_AUTH + | ||
691 | compound_encode_hdr_maxsz + | ||
692 | encode_sequence_maxsz + | ||
693 | encode_putfh_maxsz + | ||
694 | encode_getattr_maxsz) * | ||
695 | XDR_UNIT); | ||
696 | |||
697 | const u32 nfs41_maxread_overhead = ((RPC_MAX_HEADER_WITH_AUTH + | ||
698 | compound_decode_hdr_maxsz + | ||
699 | decode_sequence_maxsz + | ||
700 | decode_putfh_maxsz) * | ||
701 | XDR_UNIT); | ||
679 | #endif /* CONFIG_NFS_V4_1 */ | 702 | #endif /* CONFIG_NFS_V4_1 */ |
680 | 703 | ||
681 | static const umode_t nfs_type2fmt[] = { | 704 | static const umode_t nfs_type2fmt[] = { |
@@ -1140,6 +1163,7 @@ static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_opena | |||
1140 | static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg) | 1163 | static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
1141 | { | 1164 | { |
1142 | __be32 *p; | 1165 | __be32 *p; |
1166 | struct nfs_client *clp; | ||
1143 | 1167 | ||
1144 | p = reserve_space(xdr, 4); | 1168 | p = reserve_space(xdr, 4); |
1145 | switch(arg->open_flags & O_EXCL) { | 1169 | switch(arg->open_flags & O_EXCL) { |
@@ -1148,8 +1172,23 @@ static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_op | |||
1148 | encode_attrs(xdr, arg->u.attrs, arg->server); | 1172 | encode_attrs(xdr, arg->u.attrs, arg->server); |
1149 | break; | 1173 | break; |
1150 | default: | 1174 | default: |
1151 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE); | 1175 | clp = arg->server->nfs_client; |
1152 | encode_nfs4_verifier(xdr, &arg->u.verifier); | 1176 | if (clp->cl_minorversion > 0) { |
1177 | if (nfs4_has_persistent_session(clp)) { | ||
1178 | *p = cpu_to_be32(NFS4_CREATE_GUARDED); | ||
1179 | encode_attrs(xdr, arg->u.attrs, arg->server); | ||
1180 | } else { | ||
1181 | struct iattr dummy; | ||
1182 | |||
1183 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1); | ||
1184 | encode_nfs4_verifier(xdr, &arg->u.verifier); | ||
1185 | dummy.ia_valid = 0; | ||
1186 | encode_attrs(xdr, &dummy, arg->server); | ||
1187 | } | ||
1188 | } else { | ||
1189 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE); | ||
1190 | encode_nfs4_verifier(xdr, &arg->u.verifier); | ||
1191 | } | ||
1153 | } | 1192 | } |
1154 | } | 1193 | } |
1155 | 1194 | ||
@@ -1592,6 +1631,19 @@ static void encode_destroy_session(struct xdr_stream *xdr, | |||
1592 | hdr->nops++; | 1631 | hdr->nops++; |
1593 | hdr->replen += decode_destroy_session_maxsz; | 1632 | hdr->replen += decode_destroy_session_maxsz; |
1594 | } | 1633 | } |
1634 | |||
1635 | static void encode_reclaim_complete(struct xdr_stream *xdr, | ||
1636 | struct nfs41_reclaim_complete_args *args, | ||
1637 | struct compound_hdr *hdr) | ||
1638 | { | ||
1639 | __be32 *p; | ||
1640 | |||
1641 | p = reserve_space(xdr, 8); | ||
1642 | *p++ = cpu_to_be32(OP_RECLAIM_COMPLETE); | ||
1643 | *p++ = cpu_to_be32(args->one_fs); | ||
1644 | hdr->nops++; | ||
1645 | hdr->replen += decode_reclaim_complete_maxsz; | ||
1646 | } | ||
1595 | #endif /* CONFIG_NFS_V4_1 */ | 1647 | #endif /* CONFIG_NFS_V4_1 */ |
1596 | 1648 | ||
1597 | static void encode_sequence(struct xdr_stream *xdr, | 1649 | static void encode_sequence(struct xdr_stream *xdr, |
@@ -2096,7 +2148,7 @@ nfs4_xdr_enc_getacl(struct rpc_rqst *req, __be32 *p, | |||
2096 | encode_compound_hdr(&xdr, req, &hdr); | 2148 | encode_compound_hdr(&xdr, req, &hdr); |
2097 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2149 | encode_sequence(&xdr, &args->seq_args, &hdr); |
2098 | encode_putfh(&xdr, args->fh, &hdr); | 2150 | encode_putfh(&xdr, args->fh, &hdr); |
2099 | replen = hdr.replen + nfs4_fattr_bitmap_maxsz + 1; | 2151 | replen = hdr.replen + op_decode_hdr_maxsz + nfs4_fattr_bitmap_maxsz + 1; |
2100 | encode_getattr_two(&xdr, FATTR4_WORD0_ACL, 0, &hdr); | 2152 | encode_getattr_two(&xdr, FATTR4_WORD0_ACL, 0, &hdr); |
2101 | 2153 | ||
2102 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, | 2154 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, |
@@ -2420,6 +2472,26 @@ static int nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req, uint32_t *p, | |||
2420 | encode_nops(&hdr); | 2472 | encode_nops(&hdr); |
2421 | return 0; | 2473 | return 0; |
2422 | } | 2474 | } |
2475 | |||
2476 | /* | ||
2477 | * a RECLAIM_COMPLETE request | ||
2478 | */ | ||
2479 | static int nfs4_xdr_enc_reclaim_complete(struct rpc_rqst *req, uint32_t *p, | ||
2480 | struct nfs41_reclaim_complete_args *args) | ||
2481 | { | ||
2482 | struct xdr_stream xdr; | ||
2483 | struct compound_hdr hdr = { | ||
2484 | .minorversion = nfs4_xdr_minorversion(&args->seq_args) | ||
2485 | }; | ||
2486 | |||
2487 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | ||
2488 | encode_compound_hdr(&xdr, req, &hdr); | ||
2489 | encode_sequence(&xdr, &args->seq_args, &hdr); | ||
2490 | encode_reclaim_complete(&xdr, args, &hdr); | ||
2491 | encode_nops(&hdr); | ||
2492 | return 0; | ||
2493 | } | ||
2494 | |||
2423 | #endif /* CONFIG_NFS_V4_1 */ | 2495 | #endif /* CONFIG_NFS_V4_1 */ |
2424 | 2496 | ||
2425 | static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) | 2497 | static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) |
@@ -4528,6 +4600,11 @@ static int decode_destroy_session(struct xdr_stream *xdr, void *dummy) | |||
4528 | { | 4600 | { |
4529 | return decode_op_hdr(xdr, OP_DESTROY_SESSION); | 4601 | return decode_op_hdr(xdr, OP_DESTROY_SESSION); |
4530 | } | 4602 | } |
4603 | |||
4604 | static int decode_reclaim_complete(struct xdr_stream *xdr, void *dummy) | ||
4605 | { | ||
4606 | return decode_op_hdr(xdr, OP_RECLAIM_COMPLETE); | ||
4607 | } | ||
4531 | #endif /* CONFIG_NFS_V4_1 */ | 4608 | #endif /* CONFIG_NFS_V4_1 */ |
4532 | 4609 | ||
4533 | static int decode_sequence(struct xdr_stream *xdr, | 4610 | static int decode_sequence(struct xdr_stream *xdr, |
@@ -4583,8 +4660,8 @@ static int decode_sequence(struct xdr_stream *xdr, | |||
4583 | dummy = be32_to_cpup(p++); | 4660 | dummy = be32_to_cpup(p++); |
4584 | /* target highest slot id - currently not processed */ | 4661 | /* target highest slot id - currently not processed */ |
4585 | dummy = be32_to_cpup(p++); | 4662 | dummy = be32_to_cpup(p++); |
4586 | /* result flags - currently not processed */ | 4663 | /* result flags */ |
4587 | dummy = be32_to_cpup(p); | 4664 | res->sr_status_flags = be32_to_cpup(p); |
4588 | status = 0; | 4665 | status = 0; |
4589 | out_err: | 4666 | out_err: |
4590 | res->sr_status = status; | 4667 | res->sr_status = status; |
@@ -5309,7 +5386,7 @@ out: | |||
5309 | } | 5386 | } |
5310 | 5387 | ||
5311 | /* | 5388 | /* |
5312 | * FSINFO request | 5389 | * Decode FSINFO response |
5313 | */ | 5390 | */ |
5314 | static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, __be32 *p, | 5391 | static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, __be32 *p, |
5315 | struct nfs4_fsinfo_res *res) | 5392 | struct nfs4_fsinfo_res *res) |
@@ -5330,7 +5407,7 @@ static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, __be32 *p, | |||
5330 | } | 5407 | } |
5331 | 5408 | ||
5332 | /* | 5409 | /* |
5333 | * PATHCONF request | 5410 | * Decode PATHCONF response |
5334 | */ | 5411 | */ |
5335 | static int nfs4_xdr_dec_pathconf(struct rpc_rqst *req, __be32 *p, | 5412 | static int nfs4_xdr_dec_pathconf(struct rpc_rqst *req, __be32 *p, |
5336 | struct nfs4_pathconf_res *res) | 5413 | struct nfs4_pathconf_res *res) |
@@ -5351,7 +5428,7 @@ static int nfs4_xdr_dec_pathconf(struct rpc_rqst *req, __be32 *p, | |||
5351 | } | 5428 | } |
5352 | 5429 | ||
5353 | /* | 5430 | /* |
5354 | * STATFS request | 5431 | * Decode STATFS response |
5355 | */ | 5432 | */ |
5356 | static int nfs4_xdr_dec_statfs(struct rpc_rqst *req, __be32 *p, | 5433 | static int nfs4_xdr_dec_statfs(struct rpc_rqst *req, __be32 *p, |
5357 | struct nfs4_statfs_res *res) | 5434 | struct nfs4_statfs_res *res) |
@@ -5372,7 +5449,7 @@ static int nfs4_xdr_dec_statfs(struct rpc_rqst *req, __be32 *p, | |||
5372 | } | 5449 | } |
5373 | 5450 | ||
5374 | /* | 5451 | /* |
5375 | * GETATTR_BITMAP request | 5452 | * Decode GETATTR_BITMAP response |
5376 | */ | 5453 | */ |
5377 | static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req, __be32 *p, struct nfs4_server_caps_res *res) | 5454 | static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req, __be32 *p, struct nfs4_server_caps_res *res) |
5378 | { | 5455 | { |
@@ -5411,7 +5488,7 @@ static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, __be32 *p, void *dummy) | |||
5411 | } | 5488 | } |
5412 | 5489 | ||
5413 | /* | 5490 | /* |
5414 | * a SETCLIENTID request | 5491 | * Decode SETCLIENTID response |
5415 | */ | 5492 | */ |
5416 | static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, __be32 *p, | 5493 | static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, __be32 *p, |
5417 | struct nfs_client *clp) | 5494 | struct nfs_client *clp) |
@@ -5428,7 +5505,7 @@ static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, __be32 *p, | |||
5428 | } | 5505 | } |
5429 | 5506 | ||
5430 | /* | 5507 | /* |
5431 | * a SETCLIENTID_CONFIRM request | 5508 | * Decode SETCLIENTID_CONFIRM response |
5432 | */ | 5509 | */ |
5433 | static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, __be32 *p, struct nfs_fsinfo *fsinfo) | 5510 | static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, __be32 *p, struct nfs_fsinfo *fsinfo) |
5434 | { | 5511 | { |
@@ -5448,7 +5525,7 @@ static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, __be32 *p, str | |||
5448 | } | 5525 | } |
5449 | 5526 | ||
5450 | /* | 5527 | /* |
5451 | * DELEGRETURN request | 5528 | * Decode DELEGRETURN response |
5452 | */ | 5529 | */ |
5453 | static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_delegreturnres *res) | 5530 | static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_delegreturnres *res) |
5454 | { | 5531 | { |
@@ -5474,7 +5551,7 @@ out: | |||
5474 | } | 5551 | } |
5475 | 5552 | ||
5476 | /* | 5553 | /* |
5477 | * FS_LOCATIONS request | 5554 | * Decode FS_LOCATIONS response |
5478 | */ | 5555 | */ |
5479 | static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, __be32 *p, | 5556 | static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, __be32 *p, |
5480 | struct nfs4_fs_locations_res *res) | 5557 | struct nfs4_fs_locations_res *res) |
@@ -5504,7 +5581,7 @@ out: | |||
5504 | 5581 | ||
5505 | #if defined(CONFIG_NFS_V4_1) | 5582 | #if defined(CONFIG_NFS_V4_1) |
5506 | /* | 5583 | /* |
5507 | * EXCHANGE_ID request | 5584 | * Decode EXCHANGE_ID response |
5508 | */ | 5585 | */ |
5509 | static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp, uint32_t *p, | 5586 | static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp, uint32_t *p, |
5510 | void *res) | 5587 | void *res) |
@@ -5521,7 +5598,7 @@ static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp, uint32_t *p, | |||
5521 | } | 5598 | } |
5522 | 5599 | ||
5523 | /* | 5600 | /* |
5524 | * a CREATE_SESSION request | 5601 | * Decode CREATE_SESSION response |
5525 | */ | 5602 | */ |
5526 | static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp, uint32_t *p, | 5603 | static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp, uint32_t *p, |
5527 | struct nfs41_create_session_res *res) | 5604 | struct nfs41_create_session_res *res) |
@@ -5538,7 +5615,7 @@ static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp, uint32_t *p, | |||
5538 | } | 5615 | } |
5539 | 5616 | ||
5540 | /* | 5617 | /* |
5541 | * a DESTROY_SESSION request | 5618 | * Decode DESTROY_SESSION response |
5542 | */ | 5619 | */ |
5543 | static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp, uint32_t *p, | 5620 | static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp, uint32_t *p, |
5544 | void *dummy) | 5621 | void *dummy) |
@@ -5555,7 +5632,7 @@ static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp, uint32_t *p, | |||
5555 | } | 5632 | } |
5556 | 5633 | ||
5557 | /* | 5634 | /* |
5558 | * a SEQUENCE request | 5635 | * Decode SEQUENCE response |
5559 | */ | 5636 | */ |
5560 | static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp, uint32_t *p, | 5637 | static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp, uint32_t *p, |
5561 | struct nfs4_sequence_res *res) | 5638 | struct nfs4_sequence_res *res) |
@@ -5572,7 +5649,7 @@ static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp, uint32_t *p, | |||
5572 | } | 5649 | } |
5573 | 5650 | ||
5574 | /* | 5651 | /* |
5575 | * a GET_LEASE_TIME request | 5652 | * Decode GET_LEASE_TIME response |
5576 | */ | 5653 | */ |
5577 | static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, uint32_t *p, | 5654 | static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, uint32_t *p, |
5578 | struct nfs4_get_lease_time_res *res) | 5655 | struct nfs4_get_lease_time_res *res) |
@@ -5591,6 +5668,25 @@ static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, uint32_t *p, | |||
5591 | status = decode_fsinfo(&xdr, res->lr_fsinfo); | 5668 | status = decode_fsinfo(&xdr, res->lr_fsinfo); |
5592 | return status; | 5669 | return status; |
5593 | } | 5670 | } |
5671 | |||
5672 | /* | ||
5673 | * Decode RECLAIM_COMPLETE response | ||
5674 | */ | ||
5675 | static int nfs4_xdr_dec_reclaim_complete(struct rpc_rqst *rqstp, uint32_t *p, | ||
5676 | struct nfs41_reclaim_complete_res *res) | ||
5677 | { | ||
5678 | struct xdr_stream xdr; | ||
5679 | struct compound_hdr hdr; | ||
5680 | int status; | ||
5681 | |||
5682 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | ||
5683 | status = decode_compound_hdr(&xdr, &hdr); | ||
5684 | if (!status) | ||
5685 | status = decode_sequence(&xdr, &res->seq_res, rqstp); | ||
5686 | if (!status) | ||
5687 | status = decode_reclaim_complete(&xdr, (void *)NULL); | ||
5688 | return status; | ||
5689 | } | ||
5594 | #endif /* CONFIG_NFS_V4_1 */ | 5690 | #endif /* CONFIG_NFS_V4_1 */ |
5595 | 5691 | ||
5596 | __be32 *nfs4_decode_dirent(__be32 *p, struct nfs_entry *entry, int plus) | 5692 | __be32 *nfs4_decode_dirent(__be32 *p, struct nfs_entry *entry, int plus) |
@@ -5767,6 +5863,7 @@ struct rpc_procinfo nfs4_procedures[] = { | |||
5767 | PROC(DESTROY_SESSION, enc_destroy_session, dec_destroy_session), | 5863 | PROC(DESTROY_SESSION, enc_destroy_session, dec_destroy_session), |
5768 | PROC(SEQUENCE, enc_sequence, dec_sequence), | 5864 | PROC(SEQUENCE, enc_sequence, dec_sequence), |
5769 | PROC(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time), | 5865 | PROC(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time), |
5866 | PROC(RECLAIM_COMPLETE, enc_reclaim_complete, dec_reclaim_complete), | ||
5770 | #endif /* CONFIG_NFS_V4_1 */ | 5867 | #endif /* CONFIG_NFS_V4_1 */ |
5771 | }; | 5868 | }; |
5772 | 5869 | ||
diff --git a/fs/nfs/read.c b/fs/nfs/read.c index 12c9e66d3f1d..db9b360ae19d 100644 --- a/fs/nfs/read.c +++ b/fs/nfs/read.c | |||
@@ -356,25 +356,19 @@ static void nfs_readpage_retry(struct rpc_task *task, struct nfs_read_data *data | |||
356 | struct nfs_readres *resp = &data->res; | 356 | struct nfs_readres *resp = &data->res; |
357 | 357 | ||
358 | if (resp->eof || resp->count == argp->count) | 358 | if (resp->eof || resp->count == argp->count) |
359 | goto out; | 359 | return; |
360 | 360 | ||
361 | /* This is a short read! */ | 361 | /* This is a short read! */ |
362 | nfs_inc_stats(data->inode, NFSIOS_SHORTREAD); | 362 | nfs_inc_stats(data->inode, NFSIOS_SHORTREAD); |
363 | /* Has the server at least made some progress? */ | 363 | /* Has the server at least made some progress? */ |
364 | if (resp->count == 0) | 364 | if (resp->count == 0) |
365 | goto out; | 365 | return; |
366 | 366 | ||
367 | /* Yes, so retry the read at the end of the data */ | 367 | /* Yes, so retry the read at the end of the data */ |
368 | argp->offset += resp->count; | 368 | argp->offset += resp->count; |
369 | argp->pgbase += resp->count; | 369 | argp->pgbase += resp->count; |
370 | argp->count -= resp->count; | 370 | argp->count -= resp->count; |
371 | nfs4_restart_rpc(task, NFS_SERVER(data->inode)->nfs_client); | 371 | nfs_restart_rpc(task, NFS_SERVER(data->inode)->nfs_client); |
372 | return; | ||
373 | out: | ||
374 | nfs4_sequence_free_slot(NFS_SERVER(data->inode)->nfs_client, | ||
375 | &data->res.seq_res); | ||
376 | return; | ||
377 | |||
378 | } | 372 | } |
379 | 373 | ||
380 | /* | 374 | /* |
diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 90be551b80c1..ce907efc5508 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c | |||
@@ -175,14 +175,16 @@ static const match_table_t nfs_mount_option_tokens = { | |||
175 | }; | 175 | }; |
176 | 176 | ||
177 | enum { | 177 | enum { |
178 | Opt_xprt_udp, Opt_xprt_tcp, Opt_xprt_rdma, | 178 | Opt_xprt_udp, Opt_xprt_udp6, Opt_xprt_tcp, Opt_xprt_tcp6, Opt_xprt_rdma, |
179 | 179 | ||
180 | Opt_xprt_err | 180 | Opt_xprt_err |
181 | }; | 181 | }; |
182 | 182 | ||
183 | static const match_table_t nfs_xprt_protocol_tokens = { | 183 | static const match_table_t nfs_xprt_protocol_tokens = { |
184 | { Opt_xprt_udp, "udp" }, | 184 | { Opt_xprt_udp, "udp" }, |
185 | { Opt_xprt_udp6, "udp6" }, | ||
185 | { Opt_xprt_tcp, "tcp" }, | 186 | { Opt_xprt_tcp, "tcp" }, |
187 | { Opt_xprt_tcp6, "tcp6" }, | ||
186 | { Opt_xprt_rdma, "rdma" }, | 188 | { Opt_xprt_rdma, "rdma" }, |
187 | 189 | ||
188 | { Opt_xprt_err, NULL } | 190 | { Opt_xprt_err, NULL } |
@@ -492,6 +494,45 @@ static const char *nfs_pseudoflavour_to_name(rpc_authflavor_t flavour) | |||
492 | return sec_flavours[i].str; | 494 | return sec_flavours[i].str; |
493 | } | 495 | } |
494 | 496 | ||
497 | static void nfs_show_mountd_netid(struct seq_file *m, struct nfs_server *nfss, | ||
498 | int showdefaults) | ||
499 | { | ||
500 | struct sockaddr *sap = (struct sockaddr *) &nfss->mountd_address; | ||
501 | |||
502 | seq_printf(m, ",mountproto="); | ||
503 | switch (sap->sa_family) { | ||
504 | case AF_INET: | ||
505 | switch (nfss->mountd_protocol) { | ||
506 | case IPPROTO_UDP: | ||
507 | seq_printf(m, RPCBIND_NETID_UDP); | ||
508 | break; | ||
509 | case IPPROTO_TCP: | ||
510 | seq_printf(m, RPCBIND_NETID_TCP); | ||
511 | break; | ||
512 | default: | ||
513 | if (showdefaults) | ||
514 | seq_printf(m, "auto"); | ||
515 | } | ||
516 | break; | ||
517 | case AF_INET6: | ||
518 | switch (nfss->mountd_protocol) { | ||
519 | case IPPROTO_UDP: | ||
520 | seq_printf(m, RPCBIND_NETID_UDP6); | ||
521 | break; | ||
522 | case IPPROTO_TCP: | ||
523 | seq_printf(m, RPCBIND_NETID_TCP6); | ||
524 | break; | ||
525 | default: | ||
526 | if (showdefaults) | ||
527 | seq_printf(m, "auto"); | ||
528 | } | ||
529 | break; | ||
530 | default: | ||
531 | if (showdefaults) | ||
532 | seq_printf(m, "auto"); | ||
533 | } | ||
534 | } | ||
535 | |||
495 | static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss, | 536 | static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss, |
496 | int showdefaults) | 537 | int showdefaults) |
497 | { | 538 | { |
@@ -505,7 +546,7 @@ static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss, | |||
505 | } | 546 | } |
506 | case AF_INET6: { | 547 | case AF_INET6: { |
507 | struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap; | 548 | struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap; |
508 | seq_printf(m, ",mountaddr=%pI6", &sin6->sin6_addr); | 549 | seq_printf(m, ",mountaddr=%pI6c", &sin6->sin6_addr); |
509 | break; | 550 | break; |
510 | } | 551 | } |
511 | default: | 552 | default: |
@@ -518,17 +559,7 @@ static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss, | |||
518 | if (nfss->mountd_port || showdefaults) | 559 | if (nfss->mountd_port || showdefaults) |
519 | seq_printf(m, ",mountport=%u", nfss->mountd_port); | 560 | seq_printf(m, ",mountport=%u", nfss->mountd_port); |
520 | 561 | ||
521 | switch (nfss->mountd_protocol) { | 562 | nfs_show_mountd_netid(m, nfss, showdefaults); |
522 | case IPPROTO_UDP: | ||
523 | seq_printf(m, ",mountproto=udp"); | ||
524 | break; | ||
525 | case IPPROTO_TCP: | ||
526 | seq_printf(m, ",mountproto=tcp"); | ||
527 | break; | ||
528 | default: | ||
529 | if (showdefaults) | ||
530 | seq_printf(m, ",mountproto=auto"); | ||
531 | } | ||
532 | } | 563 | } |
533 | 564 | ||
534 | /* | 565 | /* |
@@ -578,7 +609,7 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss, | |||
578 | seq_puts(m, nfs_infop->nostr); | 609 | seq_puts(m, nfs_infop->nostr); |
579 | } | 610 | } |
580 | seq_printf(m, ",proto=%s", | 611 | seq_printf(m, ",proto=%s", |
581 | rpc_peeraddr2str(nfss->client, RPC_DISPLAY_PROTO)); | 612 | rpc_peeraddr2str(nfss->client, RPC_DISPLAY_NETID)); |
582 | if (version == 4) { | 613 | if (version == 4) { |
583 | if (nfss->port != NFS_PORT) | 614 | if (nfss->port != NFS_PORT) |
584 | seq_printf(m, ",port=%u", nfss->port); | 615 | seq_printf(m, ",port=%u", nfss->port); |
@@ -714,8 +745,6 @@ static void nfs_umount_begin(struct super_block *sb) | |||
714 | struct nfs_server *server; | 745 | struct nfs_server *server; |
715 | struct rpc_clnt *rpc; | 746 | struct rpc_clnt *rpc; |
716 | 747 | ||
717 | lock_kernel(); | ||
718 | |||
719 | server = NFS_SB(sb); | 748 | server = NFS_SB(sb); |
720 | /* -EIO all pending I/O */ | 749 | /* -EIO all pending I/O */ |
721 | rpc = server->client_acl; | 750 | rpc = server->client_acl; |
@@ -724,8 +753,6 @@ static void nfs_umount_begin(struct super_block *sb) | |||
724 | rpc = server->client; | 753 | rpc = server->client; |
725 | if (!IS_ERR(rpc)) | 754 | if (!IS_ERR(rpc)) |
726 | rpc_killall_tasks(rpc); | 755 | rpc_killall_tasks(rpc); |
727 | |||
728 | unlock_kernel(); | ||
729 | } | 756 | } |
730 | 757 | ||
731 | static struct nfs_parsed_mount_data *nfs_alloc_parsed_mount_data(unsigned int version) | 758 | static struct nfs_parsed_mount_data *nfs_alloc_parsed_mount_data(unsigned int version) |
@@ -734,8 +761,6 @@ static struct nfs_parsed_mount_data *nfs_alloc_parsed_mount_data(unsigned int ve | |||
734 | 761 | ||
735 | data = kzalloc(sizeof(*data), GFP_KERNEL); | 762 | data = kzalloc(sizeof(*data), GFP_KERNEL); |
736 | if (data) { | 763 | if (data) { |
737 | data->rsize = NFS_MAX_FILE_IO_SIZE; | ||
738 | data->wsize = NFS_MAX_FILE_IO_SIZE; | ||
739 | data->acregmin = NFS_DEF_ACREGMIN; | 764 | data->acregmin = NFS_DEF_ACREGMIN; |
740 | data->acregmax = NFS_DEF_ACREGMAX; | 765 | data->acregmax = NFS_DEF_ACREGMAX; |
741 | data->acdirmin = NFS_DEF_ACDIRMIN; | 766 | data->acdirmin = NFS_DEF_ACDIRMIN; |
@@ -887,6 +912,8 @@ static int nfs_parse_mount_options(char *raw, | |||
887 | { | 912 | { |
888 | char *p, *string, *secdata; | 913 | char *p, *string, *secdata; |
889 | int rc, sloppy = 0, invalid_option = 0; | 914 | int rc, sloppy = 0, invalid_option = 0; |
915 | unsigned short protofamily = AF_UNSPEC; | ||
916 | unsigned short mountfamily = AF_UNSPEC; | ||
890 | 917 | ||
891 | if (!raw) { | 918 | if (!raw) { |
892 | dfprintk(MOUNT, "NFS: mount options string was NULL.\n"); | 919 | dfprintk(MOUNT, "NFS: mount options string was NULL.\n"); |
@@ -1232,12 +1259,17 @@ static int nfs_parse_mount_options(char *raw, | |||
1232 | token = match_token(string, | 1259 | token = match_token(string, |
1233 | nfs_xprt_protocol_tokens, args); | 1260 | nfs_xprt_protocol_tokens, args); |
1234 | 1261 | ||
1262 | protofamily = AF_INET; | ||
1235 | switch (token) { | 1263 | switch (token) { |
1264 | case Opt_xprt_udp6: | ||
1265 | protofamily = AF_INET6; | ||
1236 | case Opt_xprt_udp: | 1266 | case Opt_xprt_udp: |
1237 | mnt->flags &= ~NFS_MOUNT_TCP; | 1267 | mnt->flags &= ~NFS_MOUNT_TCP; |
1238 | mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP; | 1268 | mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP; |
1239 | kfree(string); | 1269 | kfree(string); |
1240 | break; | 1270 | break; |
1271 | case Opt_xprt_tcp6: | ||
1272 | protofamily = AF_INET6; | ||
1241 | case Opt_xprt_tcp: | 1273 | case Opt_xprt_tcp: |
1242 | mnt->flags |= NFS_MOUNT_TCP; | 1274 | mnt->flags |= NFS_MOUNT_TCP; |
1243 | mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP; | 1275 | mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP; |
@@ -1265,10 +1297,15 @@ static int nfs_parse_mount_options(char *raw, | |||
1265 | nfs_xprt_protocol_tokens, args); | 1297 | nfs_xprt_protocol_tokens, args); |
1266 | kfree(string); | 1298 | kfree(string); |
1267 | 1299 | ||
1300 | mountfamily = AF_INET; | ||
1268 | switch (token) { | 1301 | switch (token) { |
1302 | case Opt_xprt_udp6: | ||
1303 | mountfamily = AF_INET6; | ||
1269 | case Opt_xprt_udp: | 1304 | case Opt_xprt_udp: |
1270 | mnt->mount_server.protocol = XPRT_TRANSPORT_UDP; | 1305 | mnt->mount_server.protocol = XPRT_TRANSPORT_UDP; |
1271 | break; | 1306 | break; |
1307 | case Opt_xprt_tcp6: | ||
1308 | mountfamily = AF_INET6; | ||
1272 | case Opt_xprt_tcp: | 1309 | case Opt_xprt_tcp: |
1273 | mnt->mount_server.protocol = XPRT_TRANSPORT_TCP; | 1310 | mnt->mount_server.protocol = XPRT_TRANSPORT_TCP; |
1274 | break; | 1311 | break; |
@@ -1367,8 +1404,33 @@ static int nfs_parse_mount_options(char *raw, | |||
1367 | if (!sloppy && invalid_option) | 1404 | if (!sloppy && invalid_option) |
1368 | return 0; | 1405 | return 0; |
1369 | 1406 | ||
1407 | /* | ||
1408 | * verify that any proto=/mountproto= options match the address | ||
1409 | * familiies in the addr=/mountaddr= options. | ||
1410 | */ | ||
1411 | if (protofamily != AF_UNSPEC && | ||
1412 | protofamily != mnt->nfs_server.address.ss_family) | ||
1413 | goto out_proto_mismatch; | ||
1414 | |||
1415 | if (mountfamily != AF_UNSPEC) { | ||
1416 | if (mnt->mount_server.addrlen) { | ||
1417 | if (mountfamily != mnt->mount_server.address.ss_family) | ||
1418 | goto out_mountproto_mismatch; | ||
1419 | } else { | ||
1420 | if (mountfamily != mnt->nfs_server.address.ss_family) | ||
1421 | goto out_mountproto_mismatch; | ||
1422 | } | ||
1423 | } | ||
1424 | |||
1370 | return 1; | 1425 | return 1; |
1371 | 1426 | ||
1427 | out_mountproto_mismatch: | ||
1428 | printk(KERN_INFO "NFS: mount server address does not match mountproto= " | ||
1429 | "option\n"); | ||
1430 | return 0; | ||
1431 | out_proto_mismatch: | ||
1432 | printk(KERN_INFO "NFS: server address does not match proto= option\n"); | ||
1433 | return 0; | ||
1372 | out_invalid_address: | 1434 | out_invalid_address: |
1373 | printk(KERN_INFO "NFS: bad IP address specified: %s\n", p); | 1435 | printk(KERN_INFO "NFS: bad IP address specified: %s\n", p); |
1374 | return 0; | 1436 | return 0; |
@@ -1881,7 +1943,6 @@ nfs_remount(struct super_block *sb, int *flags, char *raw_data) | |||
1881 | if (data == NULL) | 1943 | if (data == NULL) |
1882 | return -ENOMEM; | 1944 | return -ENOMEM; |
1883 | 1945 | ||
1884 | lock_kernel(); | ||
1885 | /* fill out struct with values from existing mount */ | 1946 | /* fill out struct with values from existing mount */ |
1886 | data->flags = nfss->flags; | 1947 | data->flags = nfss->flags; |
1887 | data->rsize = nfss->rsize; | 1948 | data->rsize = nfss->rsize; |
@@ -1907,7 +1968,6 @@ nfs_remount(struct super_block *sb, int *flags, char *raw_data) | |||
1907 | error = nfs_compare_remount_data(nfss, data); | 1968 | error = nfs_compare_remount_data(nfss, data); |
1908 | out: | 1969 | out: |
1909 | kfree(data); | 1970 | kfree(data); |
1910 | unlock_kernel(); | ||
1911 | return error; | 1971 | return error; |
1912 | } | 1972 | } |
1913 | 1973 | ||
diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c index 1064c91ae810..6da3d3ff6edd 100644 --- a/fs/nfs/unlink.c +++ b/fs/nfs/unlink.c | |||
@@ -83,7 +83,7 @@ static void nfs_async_unlink_done(struct rpc_task *task, void *calldata) | |||
83 | struct inode *dir = data->dir; | 83 | struct inode *dir = data->dir; |
84 | 84 | ||
85 | if (!NFS_PROTO(dir)->unlink_done(task, dir)) | 85 | if (!NFS_PROTO(dir)->unlink_done(task, dir)) |
86 | nfs4_restart_rpc(task, NFS_SERVER(dir)->nfs_client); | 86 | nfs_restart_rpc(task, NFS_SERVER(dir)->nfs_client); |
87 | } | 87 | } |
88 | 88 | ||
89 | /** | 89 | /** |
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index b1ce2ea9b93b..d171696017f4 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c | |||
@@ -1216,7 +1216,7 @@ int nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data) | |||
1216 | */ | 1216 | */ |
1217 | argp->stable = NFS_FILE_SYNC; | 1217 | argp->stable = NFS_FILE_SYNC; |
1218 | } | 1218 | } |
1219 | nfs4_restart_rpc(task, server->nfs_client); | 1219 | nfs_restart_rpc(task, server->nfs_client); |
1220 | return -EAGAIN; | 1220 | return -EAGAIN; |
1221 | } | 1221 | } |
1222 | if (time_before(complain, jiffies)) { | 1222 | if (time_before(complain, jiffies)) { |
@@ -1228,7 +1228,6 @@ int nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data) | |||
1228 | /* Can't do anything about it except throw an error. */ | 1228 | /* Can't do anything about it except throw an error. */ |
1229 | task->tk_status = -EIO; | 1229 | task->tk_status = -EIO; |
1230 | } | 1230 | } |
1231 | nfs4_sequence_free_slot(server->nfs_client, &data->res.seq_res); | ||
1232 | return 0; | 1231 | return 0; |
1233 | } | 1232 | } |
1234 | 1233 | ||
@@ -1612,15 +1611,16 @@ int nfs_migrate_page(struct address_space *mapping, struct page *newpage, | |||
1612 | if (ret) | 1611 | if (ret) |
1613 | goto out_unlock; | 1612 | goto out_unlock; |
1614 | page_cache_get(newpage); | 1613 | page_cache_get(newpage); |
1614 | spin_lock(&mapping->host->i_lock); | ||
1615 | req->wb_page = newpage; | 1615 | req->wb_page = newpage; |
1616 | SetPagePrivate(newpage); | 1616 | SetPagePrivate(newpage); |
1617 | set_page_private(newpage, page_private(page)); | 1617 | set_page_private(newpage, (unsigned long)req); |
1618 | ClearPagePrivate(page); | 1618 | ClearPagePrivate(page); |
1619 | set_page_private(page, 0); | 1619 | set_page_private(page, 0); |
1620 | spin_unlock(&mapping->host->i_lock); | ||
1620 | page_cache_release(page); | 1621 | page_cache_release(page); |
1621 | out_unlock: | 1622 | out_unlock: |
1622 | nfs_clear_page_tag_locked(req); | 1623 | nfs_clear_page_tag_locked(req); |
1623 | nfs_release_request(req); | ||
1624 | out: | 1624 | out: |
1625 | return ret; | 1625 | return ret; |
1626 | } | 1626 | } |
diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h index c4c060208109..9b8299af3741 100644 --- a/include/linux/nfs4.h +++ b/include/linux/nfs4.h | |||
@@ -128,6 +128,8 @@ | |||
128 | #define SEQ4_STATUS_RECALLABLE_STATE_REVOKED 0x00000040 | 128 | #define SEQ4_STATUS_RECALLABLE_STATE_REVOKED 0x00000040 |
129 | #define SEQ4_STATUS_LEASE_MOVED 0x00000080 | 129 | #define SEQ4_STATUS_LEASE_MOVED 0x00000080 |
130 | #define SEQ4_STATUS_RESTART_RECLAIM_NEEDED 0x00000100 | 130 | #define SEQ4_STATUS_RESTART_RECLAIM_NEEDED 0x00000100 |
131 | #define SEQ4_STATUS_CB_PATH_DOWN_SESSION 0x00000200 | ||
132 | #define SEQ4_STATUS_BACKCHANNEL_FAULT 0x00000400 | ||
131 | 133 | ||
132 | #define NFS4_MAX_UINT64 (~(u64)0) | 134 | #define NFS4_MAX_UINT64 (~(u64)0) |
133 | 135 | ||
@@ -528,6 +530,7 @@ enum { | |||
528 | NFSPROC4_CLNT_DESTROY_SESSION, | 530 | NFSPROC4_CLNT_DESTROY_SESSION, |
529 | NFSPROC4_CLNT_SEQUENCE, | 531 | NFSPROC4_CLNT_SEQUENCE, |
530 | NFSPROC4_CLNT_GET_LEASE_TIME, | 532 | NFSPROC4_CLNT_GET_LEASE_TIME, |
533 | NFSPROC4_CLNT_RECLAIM_COMPLETE, | ||
531 | }; | 534 | }; |
532 | 535 | ||
533 | /* nfs41 types */ | 536 | /* nfs41 types */ |
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h index 320569eabe3b..34fc6be5bfcf 100644 --- a/include/linux/nfs_fs_sb.h +++ b/include/linux/nfs_fs_sb.h | |||
@@ -209,6 +209,7 @@ struct nfs4_session { | |||
209 | unsigned long session_state; | 209 | unsigned long session_state; |
210 | u32 hash_alg; | 210 | u32 hash_alg; |
211 | u32 ssv_len; | 211 | u32 ssv_len; |
212 | struct completion complete; | ||
212 | 213 | ||
213 | /* The fore and back channel */ | 214 | /* The fore and back channel */ |
214 | struct nfs4_channel_attrs fc_attrs; | 215 | struct nfs4_channel_attrs fc_attrs; |
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 62f63fb0c4c8..51071b335751 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h | |||
@@ -170,8 +170,9 @@ struct nfs4_sequence_args { | |||
170 | struct nfs4_sequence_res { | 170 | struct nfs4_sequence_res { |
171 | struct nfs4_session *sr_session; | 171 | struct nfs4_session *sr_session; |
172 | u8 sr_slotid; /* slot used to send request */ | 172 | u8 sr_slotid; /* slot used to send request */ |
173 | unsigned long sr_renewal_time; | ||
174 | int sr_status; /* sequence operation status */ | 173 | int sr_status; /* sequence operation status */ |
174 | unsigned long sr_renewal_time; | ||
175 | u32 sr_status_flags; | ||
175 | }; | 176 | }; |
176 | 177 | ||
177 | struct nfs4_get_lease_time_args { | 178 | struct nfs4_get_lease_time_args { |
@@ -938,6 +939,16 @@ struct nfs41_create_session_args { | |||
938 | struct nfs41_create_session_res { | 939 | struct nfs41_create_session_res { |
939 | struct nfs_client *client; | 940 | struct nfs_client *client; |
940 | }; | 941 | }; |
942 | |||
943 | struct nfs41_reclaim_complete_args { | ||
944 | /* In the future extend to include curr_fh for use with migration */ | ||
945 | unsigned char one_fs:1; | ||
946 | struct nfs4_sequence_args seq_args; | ||
947 | }; | ||
948 | |||
949 | struct nfs41_reclaim_complete_res { | ||
950 | struct nfs4_sequence_res seq_res; | ||
951 | }; | ||
941 | #endif /* CONFIG_NFS_V4_1 */ | 952 | #endif /* CONFIG_NFS_V4_1 */ |
942 | 953 | ||
943 | struct nfs_page; | 954 | struct nfs_page; |
diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h index 401097781fc0..1906782ec86b 100644 --- a/include/linux/sunrpc/sched.h +++ b/include/linux/sunrpc/sched.h | |||
@@ -130,12 +130,14 @@ struct rpc_task_setup { | |||
130 | #define RPC_TASK_DYNAMIC 0x0080 /* task was kmalloc'ed */ | 130 | #define RPC_TASK_DYNAMIC 0x0080 /* task was kmalloc'ed */ |
131 | #define RPC_TASK_KILLED 0x0100 /* task was killed */ | 131 | #define RPC_TASK_KILLED 0x0100 /* task was killed */ |
132 | #define RPC_TASK_SOFT 0x0200 /* Use soft timeouts */ | 132 | #define RPC_TASK_SOFT 0x0200 /* Use soft timeouts */ |
133 | #define RPC_TASK_SOFTCONN 0x0400 /* Fail if can't connect */ | ||
133 | 134 | ||
134 | #define RPC_IS_ASYNC(t) ((t)->tk_flags & RPC_TASK_ASYNC) | 135 | #define RPC_IS_ASYNC(t) ((t)->tk_flags & RPC_TASK_ASYNC) |
135 | #define RPC_IS_SWAPPER(t) ((t)->tk_flags & RPC_TASK_SWAPPER) | 136 | #define RPC_IS_SWAPPER(t) ((t)->tk_flags & RPC_TASK_SWAPPER) |
136 | #define RPC_DO_ROOTOVERRIDE(t) ((t)->tk_flags & RPC_TASK_ROOTCREDS) | 137 | #define RPC_DO_ROOTOVERRIDE(t) ((t)->tk_flags & RPC_TASK_ROOTCREDS) |
137 | #define RPC_ASSASSINATED(t) ((t)->tk_flags & RPC_TASK_KILLED) | 138 | #define RPC_ASSASSINATED(t) ((t)->tk_flags & RPC_TASK_KILLED) |
138 | #define RPC_IS_SOFT(t) ((t)->tk_flags & RPC_TASK_SOFT) | 139 | #define RPC_IS_SOFT(t) ((t)->tk_flags & RPC_TASK_SOFT) |
140 | #define RPC_IS_SOFTCONN(t) ((t)->tk_flags & RPC_TASK_SOFTCONN) | ||
139 | 141 | ||
140 | #define RPC_TASK_RUNNING 0 | 142 | #define RPC_TASK_RUNNING 0 |
141 | #define RPC_TASK_QUEUED 1 | 143 | #define RPC_TASK_QUEUED 1 |
diff --git a/net/sunrpc/addr.c b/net/sunrpc/addr.c index c7450c8f0a7c..6dcdd2517819 100644 --- a/net/sunrpc/addr.c +++ b/net/sunrpc/addr.c | |||
@@ -55,16 +55,8 @@ static size_t rpc_ntop6_noscopeid(const struct sockaddr *sap, | |||
55 | 55 | ||
56 | /* | 56 | /* |
57 | * RFC 4291, Section 2.2.1 | 57 | * RFC 4291, Section 2.2.1 |
58 | * | ||
59 | * To keep the result as short as possible, especially | ||
60 | * since we don't shorthand, we don't want leading zeros | ||
61 | * in each halfword, so avoid %pI6. | ||
62 | */ | 58 | */ |
63 | return snprintf(buf, buflen, "%x:%x:%x:%x:%x:%x:%x:%x", | 59 | return snprintf(buf, buflen, "%pI6c", addr); |
64 | ntohs(addr->s6_addr16[0]), ntohs(addr->s6_addr16[1]), | ||
65 | ntohs(addr->s6_addr16[2]), ntohs(addr->s6_addr16[3]), | ||
66 | ntohs(addr->s6_addr16[4]), ntohs(addr->s6_addr16[5]), | ||
67 | ntohs(addr->s6_addr16[6]), ntohs(addr->s6_addr16[7])); | ||
68 | } | 60 | } |
69 | 61 | ||
70 | static size_t rpc_ntop6(const struct sockaddr *sap, | 62 | static size_t rpc_ntop6(const struct sockaddr *sap, |
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c index 7535a7bed2fa..f394fc190a49 100644 --- a/net/sunrpc/auth.c +++ b/net/sunrpc/auth.c | |||
@@ -123,16 +123,19 @@ rpcauth_unhash_cred_locked(struct rpc_cred *cred) | |||
123 | clear_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags); | 123 | clear_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags); |
124 | } | 124 | } |
125 | 125 | ||
126 | static void | 126 | static int |
127 | rpcauth_unhash_cred(struct rpc_cred *cred) | 127 | rpcauth_unhash_cred(struct rpc_cred *cred) |
128 | { | 128 | { |
129 | spinlock_t *cache_lock; | 129 | spinlock_t *cache_lock; |
130 | int ret; | ||
130 | 131 | ||
131 | cache_lock = &cred->cr_auth->au_credcache->lock; | 132 | cache_lock = &cred->cr_auth->au_credcache->lock; |
132 | spin_lock(cache_lock); | 133 | spin_lock(cache_lock); |
133 | if (atomic_read(&cred->cr_count) == 0) | 134 | ret = atomic_read(&cred->cr_count) == 0; |
135 | if (ret) | ||
134 | rpcauth_unhash_cred_locked(cred); | 136 | rpcauth_unhash_cred_locked(cred); |
135 | spin_unlock(cache_lock); | 137 | spin_unlock(cache_lock); |
138 | return ret; | ||
136 | } | 139 | } |
137 | 140 | ||
138 | /* | 141 | /* |
@@ -446,31 +449,35 @@ void | |||
446 | put_rpccred(struct rpc_cred *cred) | 449 | put_rpccred(struct rpc_cred *cred) |
447 | { | 450 | { |
448 | /* Fast path for unhashed credentials */ | 451 | /* Fast path for unhashed credentials */ |
449 | if (test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0) | 452 | if (test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) == 0) { |
450 | goto need_lock; | 453 | if (atomic_dec_and_test(&cred->cr_count)) |
451 | 454 | cred->cr_ops->crdestroy(cred); | |
452 | if (!atomic_dec_and_test(&cred->cr_count)) | ||
453 | return; | 455 | return; |
454 | goto out_destroy; | 456 | } |
455 | need_lock: | 457 | |
456 | if (!atomic_dec_and_lock(&cred->cr_count, &rpc_credcache_lock)) | 458 | if (!atomic_dec_and_lock(&cred->cr_count, &rpc_credcache_lock)) |
457 | return; | 459 | return; |
458 | if (!list_empty(&cred->cr_lru)) { | 460 | if (!list_empty(&cred->cr_lru)) { |
459 | number_cred_unused--; | 461 | number_cred_unused--; |
460 | list_del_init(&cred->cr_lru); | 462 | list_del_init(&cred->cr_lru); |
461 | } | 463 | } |
462 | if (test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) == 0) | ||
463 | rpcauth_unhash_cred(cred); | ||
464 | if (test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0) { | 464 | if (test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0) { |
465 | cred->cr_expire = jiffies; | 465 | if (test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) != 0) { |
466 | list_add_tail(&cred->cr_lru, &cred_unused); | 466 | cred->cr_expire = jiffies; |
467 | number_cred_unused++; | 467 | list_add_tail(&cred->cr_lru, &cred_unused); |
468 | spin_unlock(&rpc_credcache_lock); | 468 | number_cred_unused++; |
469 | return; | 469 | goto out_nodestroy; |
470 | } | ||
471 | if (!rpcauth_unhash_cred(cred)) { | ||
472 | /* We were hashed and someone looked us up... */ | ||
473 | goto out_nodestroy; | ||
474 | } | ||
470 | } | 475 | } |
471 | spin_unlock(&rpc_credcache_lock); | 476 | spin_unlock(&rpc_credcache_lock); |
472 | out_destroy: | ||
473 | cred->cr_ops->crdestroy(cred); | 477 | cred->cr_ops->crdestroy(cred); |
478 | return; | ||
479 | out_nodestroy: | ||
480 | spin_unlock(&rpc_credcache_lock); | ||
474 | } | 481 | } |
475 | EXPORT_SYMBOL_GPL(put_rpccred); | 482 | EXPORT_SYMBOL_GPL(put_rpccred); |
476 | 483 | ||
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c index fc6a43ccd950..3c3c50f38a1c 100644 --- a/net/sunrpc/auth_gss/auth_gss.c +++ b/net/sunrpc/auth_gss/auth_gss.c | |||
@@ -304,7 +304,7 @@ __gss_find_upcall(struct rpc_inode *rpci, uid_t uid) | |||
304 | * to that upcall instead of adding the new upcall. | 304 | * to that upcall instead of adding the new upcall. |
305 | */ | 305 | */ |
306 | static inline struct gss_upcall_msg * | 306 | static inline struct gss_upcall_msg * |
307 | gss_add_msg(struct gss_auth *gss_auth, struct gss_upcall_msg *gss_msg) | 307 | gss_add_msg(struct gss_upcall_msg *gss_msg) |
308 | { | 308 | { |
309 | struct rpc_inode *rpci = gss_msg->inode; | 309 | struct rpc_inode *rpci = gss_msg->inode; |
310 | struct inode *inode = &rpci->vfs_inode; | 310 | struct inode *inode = &rpci->vfs_inode; |
@@ -445,7 +445,7 @@ gss_setup_upcall(struct rpc_clnt *clnt, struct gss_auth *gss_auth, struct rpc_cr | |||
445 | gss_new = gss_alloc_msg(gss_auth, uid, clnt, gss_cred->gc_machine_cred); | 445 | gss_new = gss_alloc_msg(gss_auth, uid, clnt, gss_cred->gc_machine_cred); |
446 | if (IS_ERR(gss_new)) | 446 | if (IS_ERR(gss_new)) |
447 | return gss_new; | 447 | return gss_new; |
448 | gss_msg = gss_add_msg(gss_auth, gss_new); | 448 | gss_msg = gss_add_msg(gss_new); |
449 | if (gss_msg == gss_new) { | 449 | if (gss_msg == gss_new) { |
450 | struct inode *inode = &gss_new->inode->vfs_inode; | 450 | struct inode *inode = &gss_new->inode->vfs_inode; |
451 | int res = rpc_queue_upcall(inode, &gss_new->msg); | 451 | int res = rpc_queue_upcall(inode, &gss_new->msg); |
@@ -485,7 +485,7 @@ gss_refresh_upcall(struct rpc_task *task) | |||
485 | dprintk("RPC: %5u gss_refresh_upcall for uid %u\n", task->tk_pid, | 485 | dprintk("RPC: %5u gss_refresh_upcall for uid %u\n", task->tk_pid, |
486 | cred->cr_uid); | 486 | cred->cr_uid); |
487 | gss_msg = gss_setup_upcall(task->tk_client, gss_auth, cred); | 487 | gss_msg = gss_setup_upcall(task->tk_client, gss_auth, cred); |
488 | if (IS_ERR(gss_msg) == -EAGAIN) { | 488 | if (PTR_ERR(gss_msg) == -EAGAIN) { |
489 | /* XXX: warning on the first, under the assumption we | 489 | /* XXX: warning on the first, under the assumption we |
490 | * shouldn't normally hit this case on a refresh. */ | 490 | * shouldn't normally hit this case on a refresh. */ |
491 | warn_gssd(); | 491 | warn_gssd(); |
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 38829e20500b..154034b675bd 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c | |||
@@ -79,7 +79,7 @@ static void call_connect_status(struct rpc_task *task); | |||
79 | 79 | ||
80 | static __be32 *rpc_encode_header(struct rpc_task *task); | 80 | static __be32 *rpc_encode_header(struct rpc_task *task); |
81 | static __be32 *rpc_verify_header(struct rpc_task *task); | 81 | static __be32 *rpc_verify_header(struct rpc_task *task); |
82 | static int rpc_ping(struct rpc_clnt *clnt, int flags); | 82 | static int rpc_ping(struct rpc_clnt *clnt); |
83 | 83 | ||
84 | static void rpc_register_client(struct rpc_clnt *clnt) | 84 | static void rpc_register_client(struct rpc_clnt *clnt) |
85 | { | 85 | { |
@@ -340,7 +340,7 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args) | |||
340 | return clnt; | 340 | return clnt; |
341 | 341 | ||
342 | if (!(args->flags & RPC_CLNT_CREATE_NOPING)) { | 342 | if (!(args->flags & RPC_CLNT_CREATE_NOPING)) { |
343 | int err = rpc_ping(clnt, RPC_TASK_SOFT); | 343 | int err = rpc_ping(clnt); |
344 | if (err != 0) { | 344 | if (err != 0) { |
345 | rpc_shutdown_client(clnt); | 345 | rpc_shutdown_client(clnt); |
346 | return ERR_PTR(err); | 346 | return ERR_PTR(err); |
@@ -528,7 +528,7 @@ struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *old, | |||
528 | clnt->cl_prog = program->number; | 528 | clnt->cl_prog = program->number; |
529 | clnt->cl_vers = version->number; | 529 | clnt->cl_vers = version->number; |
530 | clnt->cl_stats = program->stats; | 530 | clnt->cl_stats = program->stats; |
531 | err = rpc_ping(clnt, RPC_TASK_SOFT); | 531 | err = rpc_ping(clnt); |
532 | if (err != 0) { | 532 | if (err != 0) { |
533 | rpc_shutdown_client(clnt); | 533 | rpc_shutdown_client(clnt); |
534 | clnt = ERR_PTR(err); | 534 | clnt = ERR_PTR(err); |
@@ -1060,7 +1060,7 @@ call_bind_status(struct rpc_task *task) | |||
1060 | goto retry_timeout; | 1060 | goto retry_timeout; |
1061 | case -EPFNOSUPPORT: | 1061 | case -EPFNOSUPPORT: |
1062 | /* server doesn't support any rpcbind version we know of */ | 1062 | /* server doesn't support any rpcbind version we know of */ |
1063 | dprintk("RPC: %5u remote rpcbind service unavailable\n", | 1063 | dprintk("RPC: %5u unrecognized remote rpcbind service\n", |
1064 | task->tk_pid); | 1064 | task->tk_pid); |
1065 | break; | 1065 | break; |
1066 | case -EPROTONOSUPPORT: | 1066 | case -EPROTONOSUPPORT: |
@@ -1069,6 +1069,21 @@ call_bind_status(struct rpc_task *task) | |||
1069 | task->tk_status = 0; | 1069 | task->tk_status = 0; |
1070 | task->tk_action = call_bind; | 1070 | task->tk_action = call_bind; |
1071 | return; | 1071 | return; |
1072 | case -ECONNREFUSED: /* connection problems */ | ||
1073 | case -ECONNRESET: | ||
1074 | case -ENOTCONN: | ||
1075 | case -EHOSTDOWN: | ||
1076 | case -EHOSTUNREACH: | ||
1077 | case -ENETUNREACH: | ||
1078 | case -EPIPE: | ||
1079 | dprintk("RPC: %5u remote rpcbind unreachable: %d\n", | ||
1080 | task->tk_pid, task->tk_status); | ||
1081 | if (!RPC_IS_SOFTCONN(task)) { | ||
1082 | rpc_delay(task, 5*HZ); | ||
1083 | goto retry_timeout; | ||
1084 | } | ||
1085 | status = task->tk_status; | ||
1086 | break; | ||
1072 | default: | 1087 | default: |
1073 | dprintk("RPC: %5u unrecognized rpcbind error (%d)\n", | 1088 | dprintk("RPC: %5u unrecognized rpcbind error (%d)\n", |
1074 | task->tk_pid, -task->tk_status); | 1089 | task->tk_pid, -task->tk_status); |
@@ -1180,11 +1195,25 @@ static void | |||
1180 | call_transmit_status(struct rpc_task *task) | 1195 | call_transmit_status(struct rpc_task *task) |
1181 | { | 1196 | { |
1182 | task->tk_action = call_status; | 1197 | task->tk_action = call_status; |
1198 | |||
1199 | /* | ||
1200 | * Common case: success. Force the compiler to put this | ||
1201 | * test first. | ||
1202 | */ | ||
1203 | if (task->tk_status == 0) { | ||
1204 | xprt_end_transmit(task); | ||
1205 | rpc_task_force_reencode(task); | ||
1206 | return; | ||
1207 | } | ||
1208 | |||
1183 | switch (task->tk_status) { | 1209 | switch (task->tk_status) { |
1184 | case -EAGAIN: | 1210 | case -EAGAIN: |
1185 | break; | 1211 | break; |
1186 | default: | 1212 | default: |
1213 | dprint_status(task); | ||
1187 | xprt_end_transmit(task); | 1214 | xprt_end_transmit(task); |
1215 | rpc_task_force_reencode(task); | ||
1216 | break; | ||
1188 | /* | 1217 | /* |
1189 | * Special cases: if we've been waiting on the | 1218 | * Special cases: if we've been waiting on the |
1190 | * socket's write_space() callback, or if the | 1219 | * socket's write_space() callback, or if the |
@@ -1192,11 +1221,16 @@ call_transmit_status(struct rpc_task *task) | |||
1192 | * then hold onto the transport lock. | 1221 | * then hold onto the transport lock. |
1193 | */ | 1222 | */ |
1194 | case -ECONNREFUSED: | 1223 | case -ECONNREFUSED: |
1195 | case -ECONNRESET: | ||
1196 | case -ENOTCONN: | ||
1197 | case -EHOSTDOWN: | 1224 | case -EHOSTDOWN: |
1198 | case -EHOSTUNREACH: | 1225 | case -EHOSTUNREACH: |
1199 | case -ENETUNREACH: | 1226 | case -ENETUNREACH: |
1227 | if (RPC_IS_SOFTCONN(task)) { | ||
1228 | xprt_end_transmit(task); | ||
1229 | rpc_exit(task, task->tk_status); | ||
1230 | break; | ||
1231 | } | ||
1232 | case -ECONNRESET: | ||
1233 | case -ENOTCONN: | ||
1200 | case -EPIPE: | 1234 | case -EPIPE: |
1201 | rpc_task_force_reencode(task); | 1235 | rpc_task_force_reencode(task); |
1202 | } | 1236 | } |
@@ -1346,6 +1380,10 @@ call_timeout(struct rpc_task *task) | |||
1346 | dprintk("RPC: %5u call_timeout (major)\n", task->tk_pid); | 1380 | dprintk("RPC: %5u call_timeout (major)\n", task->tk_pid); |
1347 | task->tk_timeouts++; | 1381 | task->tk_timeouts++; |
1348 | 1382 | ||
1383 | if (RPC_IS_SOFTCONN(task)) { | ||
1384 | rpc_exit(task, -ETIMEDOUT); | ||
1385 | return; | ||
1386 | } | ||
1349 | if (RPC_IS_SOFT(task)) { | 1387 | if (RPC_IS_SOFT(task)) { |
1350 | if (clnt->cl_chatty) | 1388 | if (clnt->cl_chatty) |
1351 | printk(KERN_NOTICE "%s: server %s not responding, timed out\n", | 1389 | printk(KERN_NOTICE "%s: server %s not responding, timed out\n", |
@@ -1675,14 +1713,14 @@ static struct rpc_procinfo rpcproc_null = { | |||
1675 | .p_decode = rpcproc_decode_null, | 1713 | .p_decode = rpcproc_decode_null, |
1676 | }; | 1714 | }; |
1677 | 1715 | ||
1678 | static int rpc_ping(struct rpc_clnt *clnt, int flags) | 1716 | static int rpc_ping(struct rpc_clnt *clnt) |
1679 | { | 1717 | { |
1680 | struct rpc_message msg = { | 1718 | struct rpc_message msg = { |
1681 | .rpc_proc = &rpcproc_null, | 1719 | .rpc_proc = &rpcproc_null, |
1682 | }; | 1720 | }; |
1683 | int err; | 1721 | int err; |
1684 | msg.rpc_cred = authnull_ops.lookup_cred(NULL, NULL, 0); | 1722 | msg.rpc_cred = authnull_ops.lookup_cred(NULL, NULL, 0); |
1685 | err = rpc_call_sync(clnt, &msg, flags); | 1723 | err = rpc_call_sync(clnt, &msg, RPC_TASK_SOFT | RPC_TASK_SOFTCONN); |
1686 | put_rpccred(msg.rpc_cred); | 1724 | put_rpccred(msg.rpc_cred); |
1687 | return err; | 1725 | return err; |
1688 | } | 1726 | } |
diff --git a/net/sunrpc/rpcb_clnt.c b/net/sunrpc/rpcb_clnt.c index 830faf4d9997..3e3772d8eb92 100644 --- a/net/sunrpc/rpcb_clnt.c +++ b/net/sunrpc/rpcb_clnt.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/in6.h> | 20 | #include <linux/in6.h> |
21 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
22 | #include <linux/errno.h> | 22 | #include <linux/errno.h> |
23 | #include <linux/mutex.h> | ||
23 | #include <net/ipv6.h> | 24 | #include <net/ipv6.h> |
24 | 25 | ||
25 | #include <linux/sunrpc/clnt.h> | 26 | #include <linux/sunrpc/clnt.h> |
@@ -110,6 +111,9 @@ static void rpcb_getport_done(struct rpc_task *, void *); | |||
110 | static void rpcb_map_release(void *data); | 111 | static void rpcb_map_release(void *data); |
111 | static struct rpc_program rpcb_program; | 112 | static struct rpc_program rpcb_program; |
112 | 113 | ||
114 | static struct rpc_clnt * rpcb_local_clnt; | ||
115 | static struct rpc_clnt * rpcb_local_clnt4; | ||
116 | |||
113 | struct rpcbind_args { | 117 | struct rpcbind_args { |
114 | struct rpc_xprt * r_xprt; | 118 | struct rpc_xprt * r_xprt; |
115 | 119 | ||
@@ -163,21 +167,60 @@ static const struct sockaddr_in rpcb_inaddr_loopback = { | |||
163 | .sin_port = htons(RPCBIND_PORT), | 167 | .sin_port = htons(RPCBIND_PORT), |
164 | }; | 168 | }; |
165 | 169 | ||
166 | static struct rpc_clnt *rpcb_create_local(struct sockaddr *addr, | 170 | static DEFINE_MUTEX(rpcb_create_local_mutex); |
167 | size_t addrlen, u32 version) | 171 | |
172 | /* | ||
173 | * Returns zero on success, otherwise a negative errno value | ||
174 | * is returned. | ||
175 | */ | ||
176 | static int rpcb_create_local(void) | ||
168 | { | 177 | { |
169 | struct rpc_create_args args = { | 178 | struct rpc_create_args args = { |
170 | .protocol = XPRT_TRANSPORT_UDP, | 179 | .protocol = XPRT_TRANSPORT_TCP, |
171 | .address = addr, | 180 | .address = (struct sockaddr *)&rpcb_inaddr_loopback, |
172 | .addrsize = addrlen, | 181 | .addrsize = sizeof(rpcb_inaddr_loopback), |
173 | .servername = "localhost", | 182 | .servername = "localhost", |
174 | .program = &rpcb_program, | 183 | .program = &rpcb_program, |
175 | .version = version, | 184 | .version = RPCBVERS_2, |
176 | .authflavor = RPC_AUTH_UNIX, | 185 | .authflavor = RPC_AUTH_UNIX, |
177 | .flags = RPC_CLNT_CREATE_NOPING, | 186 | .flags = RPC_CLNT_CREATE_NOPING, |
178 | }; | 187 | }; |
188 | struct rpc_clnt *clnt, *clnt4; | ||
189 | int result = 0; | ||
190 | |||
191 | if (rpcb_local_clnt) | ||
192 | return result; | ||
193 | |||
194 | mutex_lock(&rpcb_create_local_mutex); | ||
195 | if (rpcb_local_clnt) | ||
196 | goto out; | ||
197 | |||
198 | clnt = rpc_create(&args); | ||
199 | if (IS_ERR(clnt)) { | ||
200 | dprintk("RPC: failed to create local rpcbind " | ||
201 | "client (errno %ld).\n", PTR_ERR(clnt)); | ||
202 | result = -PTR_ERR(clnt); | ||
203 | goto out; | ||
204 | } | ||
179 | 205 | ||
180 | return rpc_create(&args); | 206 | /* |
207 | * This results in an RPC ping. On systems running portmapper, | ||
208 | * the v4 ping will fail. Proceed anyway, but disallow rpcb | ||
209 | * v4 upcalls. | ||
210 | */ | ||
211 | clnt4 = rpc_bind_new_program(clnt, &rpcb_program, RPCBVERS_4); | ||
212 | if (IS_ERR(clnt4)) { | ||
213 | dprintk("RPC: failed to create local rpcbind v4 " | ||
214 | "cleint (errno %ld).\n", PTR_ERR(clnt4)); | ||
215 | clnt4 = NULL; | ||
216 | } | ||
217 | |||
218 | rpcb_local_clnt = clnt; | ||
219 | rpcb_local_clnt4 = clnt4; | ||
220 | |||
221 | out: | ||
222 | mutex_unlock(&rpcb_create_local_mutex); | ||
223 | return result; | ||
181 | } | 224 | } |
182 | 225 | ||
183 | static struct rpc_clnt *rpcb_create(char *hostname, struct sockaddr *srvaddr, | 226 | static struct rpc_clnt *rpcb_create(char *hostname, struct sockaddr *srvaddr, |
@@ -209,22 +252,13 @@ static struct rpc_clnt *rpcb_create(char *hostname, struct sockaddr *srvaddr, | |||
209 | return rpc_create(&args); | 252 | return rpc_create(&args); |
210 | } | 253 | } |
211 | 254 | ||
212 | static int rpcb_register_call(const u32 version, struct rpc_message *msg) | 255 | static int rpcb_register_call(struct rpc_clnt *clnt, struct rpc_message *msg) |
213 | { | 256 | { |
214 | struct sockaddr *addr = (struct sockaddr *)&rpcb_inaddr_loopback; | ||
215 | size_t addrlen = sizeof(rpcb_inaddr_loopback); | ||
216 | struct rpc_clnt *rpcb_clnt; | ||
217 | int result, error = 0; | 257 | int result, error = 0; |
218 | 258 | ||
219 | msg->rpc_resp = &result; | 259 | msg->rpc_resp = &result; |
220 | 260 | ||
221 | rpcb_clnt = rpcb_create_local(addr, addrlen, version); | 261 | error = rpc_call_sync(clnt, msg, RPC_TASK_SOFTCONN); |
222 | if (!IS_ERR(rpcb_clnt)) { | ||
223 | error = rpc_call_sync(rpcb_clnt, msg, 0); | ||
224 | rpc_shutdown_client(rpcb_clnt); | ||
225 | } else | ||
226 | error = PTR_ERR(rpcb_clnt); | ||
227 | |||
228 | if (error < 0) { | 262 | if (error < 0) { |
229 | dprintk("RPC: failed to contact local rpcbind " | 263 | dprintk("RPC: failed to contact local rpcbind " |
230 | "server (errno %d).\n", -error); | 264 | "server (errno %d).\n", -error); |
@@ -279,6 +313,11 @@ int rpcb_register(u32 prog, u32 vers, int prot, unsigned short port) | |||
279 | struct rpc_message msg = { | 313 | struct rpc_message msg = { |
280 | .rpc_argp = &map, | 314 | .rpc_argp = &map, |
281 | }; | 315 | }; |
316 | int error; | ||
317 | |||
318 | error = rpcb_create_local(); | ||
319 | if (error) | ||
320 | return error; | ||
282 | 321 | ||
283 | dprintk("RPC: %sregistering (%u, %u, %d, %u) with local " | 322 | dprintk("RPC: %sregistering (%u, %u, %d, %u) with local " |
284 | "rpcbind\n", (port ? "" : "un"), | 323 | "rpcbind\n", (port ? "" : "un"), |
@@ -288,7 +327,7 @@ int rpcb_register(u32 prog, u32 vers, int prot, unsigned short port) | |||
288 | if (port) | 327 | if (port) |
289 | msg.rpc_proc = &rpcb_procedures2[RPCBPROC_SET]; | 328 | msg.rpc_proc = &rpcb_procedures2[RPCBPROC_SET]; |
290 | 329 | ||
291 | return rpcb_register_call(RPCBVERS_2, &msg); | 330 | return rpcb_register_call(rpcb_local_clnt, &msg); |
292 | } | 331 | } |
293 | 332 | ||
294 | /* | 333 | /* |
@@ -313,7 +352,7 @@ static int rpcb_register_inet4(const struct sockaddr *sap, | |||
313 | if (port) | 352 | if (port) |
314 | msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET]; | 353 | msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET]; |
315 | 354 | ||
316 | result = rpcb_register_call(RPCBVERS_4, msg); | 355 | result = rpcb_register_call(rpcb_local_clnt4, msg); |
317 | kfree(map->r_addr); | 356 | kfree(map->r_addr); |
318 | return result; | 357 | return result; |
319 | } | 358 | } |
@@ -340,7 +379,7 @@ static int rpcb_register_inet6(const struct sockaddr *sap, | |||
340 | if (port) | 379 | if (port) |
341 | msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET]; | 380 | msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET]; |
342 | 381 | ||
343 | result = rpcb_register_call(RPCBVERS_4, msg); | 382 | result = rpcb_register_call(rpcb_local_clnt4, msg); |
344 | kfree(map->r_addr); | 383 | kfree(map->r_addr); |
345 | return result; | 384 | return result; |
346 | } | 385 | } |
@@ -356,7 +395,7 @@ static int rpcb_unregister_all_protofamilies(struct rpc_message *msg) | |||
356 | map->r_addr = ""; | 395 | map->r_addr = ""; |
357 | msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET]; | 396 | msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET]; |
358 | 397 | ||
359 | return rpcb_register_call(RPCBVERS_4, msg); | 398 | return rpcb_register_call(rpcb_local_clnt4, msg); |
360 | } | 399 | } |
361 | 400 | ||
362 | /** | 401 | /** |
@@ -414,6 +453,13 @@ int rpcb_v4_register(const u32 program, const u32 version, | |||
414 | struct rpc_message msg = { | 453 | struct rpc_message msg = { |
415 | .rpc_argp = &map, | 454 | .rpc_argp = &map, |
416 | }; | 455 | }; |
456 | int error; | ||
457 | |||
458 | error = rpcb_create_local(); | ||
459 | if (error) | ||
460 | return error; | ||
461 | if (rpcb_local_clnt4 == NULL) | ||
462 | return -EPROTONOSUPPORT; | ||
417 | 463 | ||
418 | if (address == NULL) | 464 | if (address == NULL) |
419 | return rpcb_unregister_all_protofamilies(&msg); | 465 | return rpcb_unregister_all_protofamilies(&msg); |
@@ -491,7 +537,7 @@ static struct rpc_task *rpcb_call_async(struct rpc_clnt *rpcb_clnt, struct rpcbi | |||
491 | .rpc_message = &msg, | 537 | .rpc_message = &msg, |
492 | .callback_ops = &rpcb_getport_ops, | 538 | .callback_ops = &rpcb_getport_ops, |
493 | .callback_data = map, | 539 | .callback_data = map, |
494 | .flags = RPC_TASK_ASYNC, | 540 | .flags = RPC_TASK_ASYNC | RPC_TASK_SOFTCONN, |
495 | }; | 541 | }; |
496 | 542 | ||
497 | return rpc_run_task(&task_setup_data); | 543 | return rpc_run_task(&task_setup_data); |
@@ -1027,3 +1073,15 @@ static struct rpc_program rpcb_program = { | |||
1027 | .version = rpcb_version, | 1073 | .version = rpcb_version, |
1028 | .stats = &rpcb_stats, | 1074 | .stats = &rpcb_stats, |
1029 | }; | 1075 | }; |
1076 | |||
1077 | /** | ||
1078 | * cleanup_rpcb_clnt - remove xprtsock's sysctls, unregister | ||
1079 | * | ||
1080 | */ | ||
1081 | void cleanup_rpcb_clnt(void) | ||
1082 | { | ||
1083 | if (rpcb_local_clnt4) | ||
1084 | rpc_shutdown_client(rpcb_local_clnt4); | ||
1085 | if (rpcb_local_clnt) | ||
1086 | rpc_shutdown_client(rpcb_local_clnt); | ||
1087 | } | ||
diff --git a/net/sunrpc/sunrpc_syms.c b/net/sunrpc/sunrpc_syms.c index 8cce92189019..f438347d817b 100644 --- a/net/sunrpc/sunrpc_syms.c +++ b/net/sunrpc/sunrpc_syms.c | |||
@@ -24,6 +24,8 @@ | |||
24 | 24 | ||
25 | extern struct cache_detail ip_map_cache, unix_gid_cache; | 25 | extern struct cache_detail ip_map_cache, unix_gid_cache; |
26 | 26 | ||
27 | extern void cleanup_rpcb_clnt(void); | ||
28 | |||
27 | static int __init | 29 | static int __init |
28 | init_sunrpc(void) | 30 | init_sunrpc(void) |
29 | { | 31 | { |
@@ -53,6 +55,7 @@ out: | |||
53 | static void __exit | 55 | static void __exit |
54 | cleanup_sunrpc(void) | 56 | cleanup_sunrpc(void) |
55 | { | 57 | { |
58 | cleanup_rpcb_clnt(); | ||
56 | rpcauth_remove_module(); | 59 | rpcauth_remove_module(); |
57 | cleanup_socket_xprt(); | 60 | cleanup_socket_xprt(); |
58 | svc_cleanup_xprt_sock(); | 61 | svc_cleanup_xprt_sock(); |
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index fd46d42afa89..469de292c23c 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c | |||
@@ -700,6 +700,10 @@ void xprt_connect(struct rpc_task *task) | |||
700 | } | 700 | } |
701 | if (!xprt_lock_write(xprt, task)) | 701 | if (!xprt_lock_write(xprt, task)) |
702 | return; | 702 | return; |
703 | |||
704 | if (test_and_clear_bit(XPRT_CLOSE_WAIT, &xprt->state)) | ||
705 | xprt->ops->close(xprt); | ||
706 | |||
703 | if (xprt_connected(xprt)) | 707 | if (xprt_connected(xprt)) |
704 | xprt_release_write(xprt, task); | 708 | xprt_release_write(xprt, task); |
705 | else { | 709 | else { |
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 04732d09013e..3d739e5d15d8 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c | |||
@@ -2019,7 +2019,7 @@ static void xs_connect(struct rpc_task *task) | |||
2019 | if (xprt_test_and_set_connecting(xprt)) | 2019 | if (xprt_test_and_set_connecting(xprt)) |
2020 | return; | 2020 | return; |
2021 | 2021 | ||
2022 | if (transport->sock != NULL) { | 2022 | if (transport->sock != NULL && !RPC_IS_SOFTCONN(task)) { |
2023 | dprintk("RPC: xs_connect delayed xprt %p for %lu " | 2023 | dprintk("RPC: xs_connect delayed xprt %p for %lu " |
2024 | "seconds\n", | 2024 | "seconds\n", |
2025 | xprt, xprt->reestablish_timeout / HZ); | 2025 | xprt, xprt->reestablish_timeout / HZ); |