diff options
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/nfs4callback.c | 73 | ||||
-rw-r--r-- | fs/nfsd/nfs4state.c | 7 | ||||
-rw-r--r-- | fs/nfsd/state.h | 10 |
3 files changed, 63 insertions, 27 deletions
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index 07c3be6eea64..a269dbeff150 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c | |||
@@ -284,7 +284,7 @@ nfs4_xdr_enc_cb_recall(struct rpc_rqst *req, __be32 *p, | |||
284 | struct xdr_stream xdr; | 284 | struct xdr_stream xdr; |
285 | struct nfs4_delegation *args = cb->cb_op; | 285 | struct nfs4_delegation *args = cb->cb_op; |
286 | struct nfs4_cb_compound_hdr hdr = { | 286 | struct nfs4_cb_compound_hdr hdr = { |
287 | .ident = args->dl_ident, | 287 | .ident = cb->cb_clp->cl_cb_ident, |
288 | .minorversion = cb->cb_minorversion, | 288 | .minorversion = cb->cb_minorversion, |
289 | }; | 289 | }; |
290 | 290 | ||
@@ -506,7 +506,8 @@ int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *conn) | |||
506 | PTR_ERR(client)); | 506 | PTR_ERR(client)); |
507 | return PTR_ERR(client); | 507 | return PTR_ERR(client); |
508 | } | 508 | } |
509 | nfsd4_set_callback_client(clp, client); | 509 | clp->cl_cb_ident = conn->cb_ident; |
510 | clp->cl_cb_client = client; | ||
510 | return 0; | 511 | return 0; |
511 | 512 | ||
512 | } | 513 | } |
@@ -569,15 +570,12 @@ void do_probe_callback(struct nfs4_client *clp) | |||
569 | */ | 570 | */ |
570 | void nfsd4_probe_callback(struct nfs4_client *clp, struct nfs4_cb_conn *conn) | 571 | void nfsd4_probe_callback(struct nfs4_client *clp, struct nfs4_cb_conn *conn) |
571 | { | 572 | { |
572 | int status; | ||
573 | |||
574 | BUG_ON(atomic_read(&clp->cl_cb_set)); | 573 | BUG_ON(atomic_read(&clp->cl_cb_set)); |
575 | 574 | ||
576 | status = setup_callback_client(clp, conn); | 575 | spin_lock(&clp->cl_lock); |
577 | if (status) { | 576 | memcpy(&clp->cl_cb_conn, conn, sizeof(struct nfs4_cb_conn)); |
578 | warn_no_callback_path(clp, status); | 577 | set_bit(NFSD4_CLIENT_CB_UPDATE, &clp->cl_cb_flags); |
579 | return; | 578 | spin_unlock(&clp->cl_lock); |
580 | } | ||
581 | do_probe_callback(clp); | 579 | do_probe_callback(clp); |
582 | } | 580 | } |
583 | 581 | ||
@@ -730,19 +728,16 @@ void nfsd4_destroy_callback_queue(void) | |||
730 | } | 728 | } |
731 | 729 | ||
732 | /* must be called under the state lock */ | 730 | /* must be called under the state lock */ |
733 | void nfsd4_set_callback_client(struct nfs4_client *clp, struct rpc_clnt *new) | 731 | void nfsd4_shutdown_callback(struct nfs4_client *clp) |
734 | { | 732 | { |
735 | struct rpc_clnt *old = clp->cl_cb_client; | 733 | set_bit(NFSD4_CLIENT_KILL, &clp->cl_cb_flags); |
736 | |||
737 | clp->cl_cb_client = new; | ||
738 | /* | 734 | /* |
739 | * After this, any work that saw the old value of cl_cb_client will | 735 | * Note this won't actually result in a null callback; |
740 | * be gone: | 736 | * instead, nfsd4_do_callback_rpc() will detect the killed |
737 | * client, destroy the rpc client, and stop: | ||
741 | */ | 738 | */ |
739 | do_probe_callback(clp); | ||
742 | flush_workqueue(callback_wq); | 740 | flush_workqueue(callback_wq); |
743 | /* So we can safely shut it down: */ | ||
744 | if (old) | ||
745 | rpc_shutdown_client(old); | ||
746 | } | 741 | } |
747 | 742 | ||
748 | void nfsd4_release_cb(struct nfsd4_callback *cb) | 743 | void nfsd4_release_cb(struct nfsd4_callback *cb) |
@@ -751,15 +746,51 @@ void nfsd4_release_cb(struct nfsd4_callback *cb) | |||
751 | cb->cb_ops->rpc_release(cb); | 746 | cb->cb_ops->rpc_release(cb); |
752 | } | 747 | } |
753 | 748 | ||
749 | void nfsd4_process_cb_update(struct nfsd4_callback *cb) | ||
750 | { | ||
751 | struct nfs4_cb_conn conn; | ||
752 | struct nfs4_client *clp = cb->cb_clp; | ||
753 | int err; | ||
754 | |||
755 | /* | ||
756 | * This is either an update, or the client dying; in either case, | ||
757 | * kill the old client: | ||
758 | */ | ||
759 | if (clp->cl_cb_client) { | ||
760 | rpc_shutdown_client(clp->cl_cb_client); | ||
761 | clp->cl_cb_client = NULL; | ||
762 | } | ||
763 | if (test_bit(NFSD4_CLIENT_KILL, &clp->cl_cb_flags)) | ||
764 | return; | ||
765 | spin_lock(&clp->cl_lock); | ||
766 | /* | ||
767 | * Only serialized callback code is allowed to clear these | ||
768 | * flags; main nfsd code can only set them: | ||
769 | */ | ||
770 | BUG_ON(!clp->cl_cb_flags); | ||
771 | clear_bit(NFSD4_CLIENT_CB_UPDATE, &clp->cl_cb_flags); | ||
772 | memcpy(&conn, &cb->cb_clp->cl_cb_conn, sizeof(struct nfs4_cb_conn)); | ||
773 | spin_unlock(&clp->cl_lock); | ||
774 | |||
775 | err = setup_callback_client(clp, &conn); | ||
776 | if (err) | ||
777 | warn_no_callback_path(clp, err); | ||
778 | } | ||
779 | |||
754 | void nfsd4_do_callback_rpc(struct work_struct *w) | 780 | void nfsd4_do_callback_rpc(struct work_struct *w) |
755 | { | 781 | { |
756 | struct nfsd4_callback *cb = container_of(w, struct nfsd4_callback, cb_work); | 782 | struct nfsd4_callback *cb = container_of(w, struct nfsd4_callback, cb_work); |
757 | struct nfs4_client *clp = cb->cb_clp; | 783 | struct nfs4_client *clp = cb->cb_clp; |
758 | struct rpc_clnt *clnt = clp->cl_cb_client; | 784 | struct rpc_clnt *clnt; |
759 | 785 | ||
760 | if (clnt == NULL) { | 786 | if (clp->cl_cb_flags) |
787 | nfsd4_process_cb_update(cb); | ||
788 | |||
789 | clnt = clp->cl_cb_client; | ||
790 | if (!clnt) { | ||
791 | /* Callback channel broken, or client killed; give up: */ | ||
761 | nfsd4_release_cb(cb); | 792 | nfsd4_release_cb(cb); |
762 | return; /* Client is shutting down; give up. */ | 793 | return; |
763 | } | 794 | } |
764 | rpc_call_async(clnt, &cb->cb_msg, RPC_TASK_SOFT | RPC_TASK_SOFTCONN, | 795 | rpc_call_async(clnt, &cb->cb_msg, RPC_TASK_SOFT | RPC_TASK_SOFTCONN, |
765 | cb->cb_ops, cb); | 796 | cb->cb_ops, cb); |
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 2f464fb26afc..d3f12dcc1696 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -207,7 +207,6 @@ alloc_init_deleg(struct nfs4_client *clp, struct nfs4_stateid *stp, struct svc_f | |||
207 | { | 207 | { |
208 | struct nfs4_delegation *dp; | 208 | struct nfs4_delegation *dp; |
209 | struct nfs4_file *fp = stp->st_file; | 209 | struct nfs4_file *fp = stp->st_file; |
210 | struct nfs4_cb_conn *conn = &stp->st_stateowner->so_client->cl_cb_conn; | ||
211 | 210 | ||
212 | dprintk("NFSD alloc_init_deleg\n"); | 211 | dprintk("NFSD alloc_init_deleg\n"); |
213 | /* | 212 | /* |
@@ -234,7 +233,6 @@ alloc_init_deleg(struct nfs4_client *clp, struct nfs4_stateid *stp, struct svc_f | |||
234 | nfs4_file_get_access(fp, O_RDONLY); | 233 | nfs4_file_get_access(fp, O_RDONLY); |
235 | dp->dl_flock = NULL; | 234 | dp->dl_flock = NULL; |
236 | dp->dl_type = type; | 235 | dp->dl_type = type; |
237 | dp->dl_ident = conn->cb_ident; | ||
238 | dp->dl_stateid.si_boot = boot_time; | 236 | dp->dl_stateid.si_boot = boot_time; |
239 | dp->dl_stateid.si_stateownerid = current_delegid++; | 237 | dp->dl_stateid.si_stateownerid = current_delegid++; |
240 | dp->dl_stateid.si_fileid = 0; | 238 | dp->dl_stateid.si_fileid = 0; |
@@ -875,7 +873,7 @@ expire_client(struct nfs4_client *clp) | |||
875 | sop = list_entry(clp->cl_openowners.next, struct nfs4_stateowner, so_perclient); | 873 | sop = list_entry(clp->cl_openowners.next, struct nfs4_stateowner, so_perclient); |
876 | release_openowner(sop); | 874 | release_openowner(sop); |
877 | } | 875 | } |
878 | nfsd4_set_callback_client(clp, NULL); | 876 | nfsd4_shutdown_callback(clp); |
879 | if (clp->cl_cb_conn.cb_xprt) | 877 | if (clp->cl_cb_conn.cb_xprt) |
880 | svc_xprt_put(clp->cl_cb_conn.cb_xprt); | 878 | svc_xprt_put(clp->cl_cb_conn.cb_xprt); |
881 | list_del(&clp->cl_idhash); | 879 | list_del(&clp->cl_idhash); |
@@ -978,6 +976,7 @@ static struct nfs4_client *create_client(struct xdr_netobj name, char *recdir, | |||
978 | INIT_LIST_HEAD(&clp->cl_delegations); | 976 | INIT_LIST_HEAD(&clp->cl_delegations); |
979 | INIT_LIST_HEAD(&clp->cl_sessions); | 977 | INIT_LIST_HEAD(&clp->cl_sessions); |
980 | INIT_LIST_HEAD(&clp->cl_lru); | 978 | INIT_LIST_HEAD(&clp->cl_lru); |
979 | spin_lock_init(&clp->cl_lock); | ||
981 | INIT_WORK(&clp->cl_cb_null.cb_work, nfsd4_do_callback_rpc); | 980 | INIT_WORK(&clp->cl_cb_null.cb_work, nfsd4_do_callback_rpc); |
982 | clp->cl_time = get_seconds(); | 981 | clp->cl_time = get_seconds(); |
983 | clear_bit(0, &clp->cl_cb_slot_busy); | 982 | clear_bit(0, &clp->cl_cb_slot_busy); |
@@ -1547,7 +1546,7 @@ nfsd4_destroy_session(struct svc_rqst *r, | |||
1547 | 1546 | ||
1548 | nfs4_lock_state(); | 1547 | nfs4_lock_state(); |
1549 | /* wait for callbacks */ | 1548 | /* wait for callbacks */ |
1550 | nfsd4_set_callback_client(ses->se_client, NULL); | 1549 | nfsd4_shutdown_callback(ses->se_client); |
1551 | nfs4_unlock_state(); | 1550 | nfs4_unlock_state(); |
1552 | nfsd4_put_session(ses); | 1551 | nfsd4_put_session(ses); |
1553 | status = nfs_ok; | 1552 | status = nfs_ok; |
diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index 2ece6bee65f7..58bc2a63ca14 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h | |||
@@ -84,7 +84,6 @@ struct nfs4_delegation { | |||
84 | u32 dl_type; | 84 | u32 dl_type; |
85 | time_t dl_time; | 85 | time_t dl_time; |
86 | /* For recall: */ | 86 | /* For recall: */ |
87 | u32 dl_ident; | ||
88 | stateid_t dl_stateid; | 87 | stateid_t dl_stateid; |
89 | struct knfsd_fh dl_fh; | 88 | struct knfsd_fh dl_fh; |
90 | int dl_retries; | 89 | int dl_retries; |
@@ -217,10 +216,17 @@ struct nfs4_client { | |||
217 | 216 | ||
218 | /* for v4.0 and v4.1 callbacks: */ | 217 | /* for v4.0 and v4.1 callbacks: */ |
219 | struct nfs4_cb_conn cl_cb_conn; | 218 | struct nfs4_cb_conn cl_cb_conn; |
219 | #define NFSD4_CLIENT_CB_UPDATE 1 | ||
220 | #define NFSD4_CLIENT_KILL 2 | ||
221 | unsigned long cl_cb_flags; | ||
220 | struct rpc_clnt *cl_cb_client; | 222 | struct rpc_clnt *cl_cb_client; |
223 | u32 cl_cb_ident; | ||
221 | atomic_t cl_cb_set; | 224 | atomic_t cl_cb_set; |
222 | struct nfsd4_callback cl_cb_null; | 225 | struct nfsd4_callback cl_cb_null; |
223 | 226 | ||
227 | /* for all client information that callback code might need: */ | ||
228 | spinlock_t cl_lock; | ||
229 | |||
224 | /* for nfs41 */ | 230 | /* for nfs41 */ |
225 | struct list_head cl_sessions; | 231 | struct list_head cl_sessions; |
226 | struct nfsd4_clid_slot cl_cs_slot; /* create_session slot */ | 232 | struct nfsd4_clid_slot cl_cs_slot; /* create_session slot */ |
@@ -439,7 +445,7 @@ extern void nfsd4_do_callback_rpc(struct work_struct *); | |||
439 | extern void nfsd4_cb_recall(struct nfs4_delegation *dp); | 445 | extern void nfsd4_cb_recall(struct nfs4_delegation *dp); |
440 | extern int nfsd4_create_callback_queue(void); | 446 | extern int nfsd4_create_callback_queue(void); |
441 | extern void nfsd4_destroy_callback_queue(void); | 447 | extern void nfsd4_destroy_callback_queue(void); |
442 | extern void nfsd4_set_callback_client(struct nfs4_client *, struct rpc_clnt *); | 448 | extern void nfsd4_shutdown_callback(struct nfs4_client *); |
443 | extern void nfs4_put_delegation(struct nfs4_delegation *dp); | 449 | extern void nfs4_put_delegation(struct nfs4_delegation *dp); |
444 | extern __be32 nfs4_make_rec_clidname(char *clidname, struct xdr_netobj *clname); | 450 | extern __be32 nfs4_make_rec_clidname(char *clidname, struct xdr_netobj *clname); |
445 | extern void nfsd4_init_recdir(char *recdir_name); | 451 | extern void nfsd4_init_recdir(char *recdir_name); |