Lines Matching refs:clp
917 static void nfsd41_cb_inflight_begin(struct nfs4_client *clp)
919 atomic_inc(&clp->cl_cb_inflight);
922 static void nfsd41_cb_inflight_end(struct nfs4_client *clp)
925 if (atomic_dec_and_test(&clp->cl_cb_inflight))
926 wake_up_var(&clp->cl_cb_inflight);
929 static void nfsd41_cb_inflight_wait_complete(struct nfs4_client *clp)
931 wait_var_event(&clp->cl_cb_inflight,
932 !atomic_read(&clp->cl_cb_inflight));
935 static const struct cred *get_backchannel_cred(struct nfs4_client *clp, struct rpc_clnt *client, struct nfsd4_session *ses)
937 if (clp->cl_minorversion == 0) {
938 client->cl_principal = clp->cl_cred.cr_targ_princ ?
939 clp->cl_cred.cr_targ_princ : "nfs";
955 static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *conn, struct nfsd4_session *ses)
957 int maxtime = max_cb_time(clp->net);
964 .net = clp->net,
977 if (clp->cl_minorversion == 0) {
978 if (!clp->cl_cred.cr_principal &&
979 (clp->cl_cred.cr_flavor >= RPC_AUTH_GSS_KRB5)) {
980 trace_nfsd_cb_setup_err(clp, -EINVAL);
983 args.client_name = clp->cl_cred.cr_principal;
986 args.authflavor = clp->cl_cred.cr_flavor;
987 clp->cl_cb_ident = conn->cb_ident;
991 clp->cl_cb_session = ses;
993 args.prognumber = clp->cl_cb_session->se_cb_prog;
1001 trace_nfsd_cb_setup_err(clp, PTR_ERR(client));
1004 cred = get_backchannel_cred(clp, client, ses);
1006 trace_nfsd_cb_setup_err(clp, -ENOMEM);
1011 if (clp->cl_minorversion != 0)
1012 clp->cl_cb_conn.cb_xprt = conn->cb_xprt;
1013 clp->cl_cb_client = client;
1014 clp->cl_cb_cred = cred;
1016 trace_nfsd_cb_setup(clp, rpc_peeraddr2str(client, RPC_DISPLAY_NETID),
1022 static void nfsd4_mark_cb_state(struct nfs4_client *clp, int newstate)
1024 if (clp->cl_cb_state != newstate) {
1025 clp->cl_cb_state = newstate;
1026 trace_nfsd_cb_state(clp);
1030 static void nfsd4_mark_cb_down(struct nfs4_client *clp, int reason)
1032 if (test_bit(NFSD4_CLIENT_CB_UPDATE, &clp->cl_flags))
1034 nfsd4_mark_cb_state(clp, NFSD4_CB_DOWN);
1037 static void nfsd4_mark_cb_fault(struct nfs4_client *clp, int reason)
1039 if (test_bit(NFSD4_CLIENT_CB_UPDATE, &clp->cl_flags))
1041 nfsd4_mark_cb_state(clp, NFSD4_CB_FAULT);
1046 struct nfs4_client *clp = container_of(calldata, struct nfs4_client, cl_cb_null);
1049 nfsd4_mark_cb_down(clp, task->tk_status);
1051 nfsd4_mark_cb_state(clp, NFSD4_CB_UP);
1056 struct nfs4_client *clp = container_of(calldata, struct nfs4_client, cl_cb_null);
1058 nfsd41_cb_inflight_end(clp);
1073 void nfsd4_probe_callback(struct nfs4_client *clp)
1075 trace_nfsd_cb_probe(clp);
1076 nfsd4_mark_cb_state(clp, NFSD4_CB_UNKNOWN);
1077 set_bit(NFSD4_CLIENT_CB_UPDATE, &clp->cl_flags);
1078 nfsd4_run_cb(&clp->cl_cb_null);
1081 void nfsd4_probe_callback_sync(struct nfs4_client *clp)
1083 nfsd4_probe_callback(clp);
1087 void nfsd4_change_callback(struct nfs4_client *clp, struct nfs4_cb_conn *conn)
1089 nfsd4_mark_cb_state(clp, NFSD4_CB_UNKNOWN);
1090 spin_lock(&clp->cl_lock);
1091 memcpy(&clp->cl_cb_conn, conn, sizeof(struct nfs4_cb_conn));
1092 spin_unlock(&clp->cl_lock);
1102 struct nfs4_client *clp = cb->cb_clp;
1105 test_and_set_bit(0, &clp->cl_cb_slot_busy) != 0) {
1106 rpc_sleep_on(&clp->cl_cb_waitq, task, NULL);
1108 if (test_and_set_bit(0, &clp->cl_cb_slot_busy) != 0) {
1112 rpc_wake_up_queued_task(&clp->cl_cb_waitq, task);
1120 struct nfs4_client *clp = cb->cb_clp;
1124 clear_bit(0, &clp->cl_cb_slot_busy);
1125 rpc_wake_up_next(&clp->cl_cb_waitq);
1131 struct nfs4_client *clp = cb->cb_clp;
1136 nfsd41_cb_inflight_end(clp);
1146 struct nfs4_client *clp = cb->cb_clp;
1147 u32 minorversion = clp->cl_minorversion;
1162 struct nfs4_client *clp = cb->cb_clp;
1163 struct nfsd4_session *session = clp->cl_cb_session;
1166 if (!clp->cl_minorversion) {
1226 clp->cl_cb_session->se_cb_seq_nr);
1237 if (!test_bit(NFSD4_CLIENT_CB_KILL, &clp->cl_flags)) {
1247 struct nfs4_client *clp = cb->cb_clp;
1267 nfsd4_mark_cb_down(clp, task->tk_status);
1306 void nfsd4_shutdown_callback(struct nfs4_client *clp)
1308 if (clp->cl_cb_state != NFSD4_CB_UNKNOWN)
1309 trace_nfsd_cb_shutdown(clp);
1311 set_bit(NFSD4_CLIENT_CB_KILL, &clp->cl_flags);
1317 nfsd4_run_cb(&clp->cl_cb_null);
1319 nfsd41_cb_inflight_wait_complete(clp);
1323 static struct nfsd4_conn * __nfsd4_find_backchannel(struct nfs4_client *clp)
1328 list_for_each_entry(s, &clp->cl_sessions, se_perclnt) {
1346 struct nfs4_client *clp = cb->cb_clp;
1355 if (clp->cl_cb_client) {
1356 rpc_shutdown_client(clp->cl_cb_client);
1357 clp->cl_cb_client = NULL;
1358 put_cred(clp->cl_cb_cred);
1359 clp->cl_cb_cred = NULL;
1361 if (clp->cl_cb_conn.cb_xprt) {
1362 svc_xprt_put(clp->cl_cb_conn.cb_xprt);
1363 clp->cl_cb_conn.cb_xprt = NULL;
1365 if (test_bit(NFSD4_CLIENT_CB_KILL, &clp->cl_flags))
1367 spin_lock(&clp->cl_lock);
1372 BUG_ON(!(clp->cl_flags & NFSD4_CLIENT_CB_FLAG_MASK));
1373 clear_bit(NFSD4_CLIENT_CB_UPDATE, &clp->cl_flags);
1375 c = __nfsd4_find_backchannel(clp);
1381 spin_unlock(&clp->cl_lock);
1383 err = setup_callback_client(clp, &conn, ses);
1385 nfsd4_mark_cb_down(clp, err);
1397 struct nfs4_client *clp = cb->cb_clp;
1408 if (clp->cl_flags & NFSD4_CLIENT_CB_FLAG_MASK)
1411 clnt = clp->cl_cb_client;
1421 if (!cb->cb_ops && clp->cl_minorversion) {
1422 nfsd4_mark_cb_state(clp, NFSD4_CB_UP);
1427 cb->cb_msg.rpc_cred = clp->cl_cb_cred;
1428 flags = clp->cl_minorversion ? RPC_TASK_NOCONNECT : RPC_TASK_SOFTCONN;
1433 void nfsd4_init_cb(struct nfsd4_callback *cb, struct nfs4_client *clp,
1436 cb->cb_clp = clp;
1457 struct nfs4_client *clp = cb->cb_clp;
1460 nfsd41_cb_inflight_begin(clp);
1463 nfsd41_cb_inflight_end(clp);