Lines Matching refs:clp
28 static int nfs_get_cb_ident_idr(struct nfs_client *clp, int minorversion)
31 struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
33 if (clp->rpc_ops->version != 4 || minorversion != 0)
37 ret = idr_alloc(&nn->cb_ident_idr, clp, 1, 0, GFP_NOWAIT);
39 clp->cl_cb_ident = ret;
152 nfs4_shutdown_ds_clients(struct nfs_client *clp)
156 while (!list_empty(&clp->cl_ds_clients)) {
157 dss = list_entry(clp->cl_ds_clients.next,
166 nfs4_cleanup_callback(struct nfs_client *clp)
170 while (!list_empty(&clp->pending_cb_stateids)) {
171 cp_state = list_entry(clp->pending_cb_stateids.next,
178 void nfs41_shutdown_client(struct nfs_client *clp)
180 if (nfs4_has_session(clp)) {
181 nfs4_cleanup_callback(clp);
182 nfs4_shutdown_ds_clients(clp);
183 nfs4_destroy_session(clp->cl_session);
184 nfs4_destroy_clientid(clp);
190 void nfs40_shutdown_client(struct nfs_client *clp)
192 if (clp->cl_slot_tbl) {
193 nfs4_shutdown_slot_table(clp->cl_slot_tbl);
194 kfree(clp->cl_slot_tbl);
202 struct nfs_client *clp = nfs_alloc_client(cl_init);
205 if (IS_ERR(clp))
206 return clp;
208 err = nfs_get_cb_ident_idr(clp, cl_init->minorversion);
217 spin_lock_init(&clp->cl_lock);
218 INIT_DELAYED_WORK(&clp->cl_renewd, nfs4_renew_state);
219 INIT_LIST_HEAD(&clp->cl_ds_clients);
220 rpc_init_wait_queue(&clp->cl_rpcwaitq, "NFS client");
221 clp->cl_state = 1 << NFS4CLNT_LEASE_EXPIRED;
222 clp->cl_mvops = nfs_v4_minor_ops[cl_init->minorversion];
223 clp->cl_mig_gen = 1;
225 init_waitqueue_head(&clp->cl_lock_waitq);
227 INIT_LIST_HEAD(&clp->pending_cb_stateids);
230 __set_bit(NFS_CS_INFINITE_SLOTS, &clp->cl_flags);
231 __set_bit(NFS_CS_DISCRTRY, &clp->cl_flags);
232 __set_bit(NFS_CS_NO_RETRANS_TIMEOUT, &clp->cl_flags);
238 err = nfs_create_rpc_client(clp, cl_init, RPC_AUTH_GSS_KRB5I);
240 err = nfs_create_rpc_client(clp, cl_init, RPC_AUTH_UNIX);
249 err = rpc_localaddr(clp->cl_rpcclient, sap, sizeof(cb_addr));
257 strlcpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr));
259 err = nfs_idmap_new(clp);
265 __set_bit(NFS_CS_IDMAP, &clp->cl_res_state);
266 return clp;
269 nfs_free_client(clp);
276 static void nfs4_destroy_callback(struct nfs_client *clp)
278 if (__test_and_clear_bit(NFS_CS_CALLBACK, &clp->cl_res_state))
279 nfs_callback_down(clp->cl_mvops->minor_version, clp->cl_net);
282 static void nfs4_shutdown_client(struct nfs_client *clp)
284 if (__test_and_clear_bit(NFS_CS_RENEWD, &clp->cl_res_state))
285 nfs4_kill_renewd(clp);
286 clp->cl_mvops->shutdown_client(clp);
287 nfs4_destroy_callback(clp);
288 if (__test_and_clear_bit(NFS_CS_IDMAP, &clp->cl_res_state))
289 nfs_idmap_delete(clp);
291 rpc_destroy_wait_queue(&clp->cl_rpcwaitq);
292 kfree(clp->cl_serverowner);
293 kfree(clp->cl_serverscope);
294 kfree(clp->cl_implid);
295 kfree(clp->cl_owner_id);
298 void nfs4_free_client(struct nfs_client *clp)
300 nfs4_shutdown_client(clp);
301 nfs_free_client(clp);
307 static int nfs4_init_callback(struct nfs_client *clp)
312 xprt = rcu_dereference_raw(clp->cl_rpcclient->cl_xprt);
314 if (nfs4_has_session(clp)) {
320 error = nfs_callback_up(clp->cl_mvops->minor_version, xprt);
326 __set_bit(NFS_CS_CALLBACK, &clp->cl_res_state);
333 * @clp: nfs_client to initialize
337 int nfs40_init_client(struct nfs_client *clp)
354 clp->cl_slot_tbl = tbl;
362 * @clp: nfs_client to initialize
366 int nfs41_init_client(struct nfs_client *clp)
375 session = nfs4_alloc_session(clp);
379 clp->cl_session = session;
387 nfs_mark_client_ready(clp, NFS_CS_SESSION_INITING);
396 static int nfs4_init_client_minor_version(struct nfs_client *clp)
400 ret = clp->cl_mvops->init_client(clp);
403 return nfs4_init_callback(clp);
409 * @clp: nfs_client to initialise
414 struct nfs_client *nfs4_init_client(struct nfs_client *clp,
420 if (clp->cl_cons_state == NFS_CS_READY)
422 return clp;
424 error = nfs4_init_client_minor_version(clp);
428 error = nfs4_discover_server_trunking(clp, &old);
432 if (clp != old) {
433 clp->cl_preserve_clid = true;
439 nfs_mark_client_ready(clp, -EPERM);
441 clear_bit(NFS_CS_TSM_POSSIBLE, &clp->cl_flags);
442 nfs_put_client(clp);
446 nfs_mark_client_ready(clp, error);
447 nfs_put_client(clp);
658 * @clp: original mount nfs_client
672 int nfs4_detect_session_trunking(struct nfs_client *clp,
677 if (clp->cl_clientid != res->clientid)
681 if (!nfs4_check_serverowner_major_id(clp->cl_serverowner,
686 if (clp->cl_serverowner->minor_id != res->server_owner->minor_id)
690 if (!nfs4_check_server_scope(clp->cl_serverscope, res->server_scope))
694 clp->cl_hostname,
699 pr_info("NFS: %s: Session trunking failed for %s\n", clp->cl_hostname,
779 struct nfs_client *clp;
783 clp = idr_find(&nn->cb_ident_idr, cb_ident);
784 if (clp)
785 refcount_inc(&clp->cl_count);
787 return clp;
793 struct nfs_client *clp, u32 minorversion)
795 struct sockaddr *clap = (struct sockaddr *)&clp->cl_addr;
798 if (!(clp->cl_cons_state == NFS_CS_READY ||
799 clp->cl_cons_state == NFS_CS_SESSION_INITING))
805 if (clp->rpc_ops->version != 4 ||
806 clp->cl_minorversion != minorversion)
824 struct nfs_client *clp;
828 list_for_each_entry(clp, &nn->nfs_client_list, cl_share_link) {
829 if (!nfs4_cb_match_client(addr, clp, minorversion))
832 if (!nfs4_has_session(clp))
836 if (memcmp(clp->cl_session->sess_id.data,
840 refcount_inc(&clp->cl_count);
842 return clp;
882 struct nfs_client *clp;
898 clp = nfs_get_client(&cl_init);
899 if (IS_ERR(clp))
900 return PTR_ERR(clp);
902 if (server->nfs_client == clp) {
903 nfs_put_client(clp);
914 set_bit(NFS_CS_CHECK_LEASE_TIME, &clp->cl_res_state);
916 server->nfs_client = clp;
1296 struct nfs_client *clp = server->nfs_client;
1299 .ident = clp->cl_proto,
1324 clp->cl_proto, clnt->cl_timeout,
1325 clp->cl_minorversion,
1326 clp->cl_nconnect, net);
1332 nfs_put_client(clp);