Lines Matching refs:clp
29 static int nfs_get_cb_ident_idr(struct nfs_client *clp, int minorversion)
32 struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
34 if (clp->rpc_ops->version != 4 || minorversion != 0)
38 ret = idr_alloc(&nn->cb_ident_idr, clp, 1, 0, GFP_NOWAIT);
40 clp->cl_cb_ident = ret;
153 nfs4_shutdown_ds_clients(struct nfs_client *clp)
157 while (!list_empty(&clp->cl_ds_clients)) {
158 dss = list_entry(clp->cl_ds_clients.next,
167 nfs4_cleanup_callback(struct nfs_client *clp)
171 while (!list_empty(&clp->pending_cb_stateids)) {
172 cp_state = list_entry(clp->pending_cb_stateids.next,
179 void nfs41_shutdown_client(struct nfs_client *clp)
181 if (nfs4_has_session(clp)) {
182 nfs4_cleanup_callback(clp);
183 nfs4_shutdown_ds_clients(clp);
184 nfs4_destroy_session(clp->cl_session);
185 nfs4_destroy_clientid(clp);
191 void nfs40_shutdown_client(struct nfs_client *clp)
193 if (clp->cl_slot_tbl) {
194 nfs4_shutdown_slot_table(clp->cl_slot_tbl);
195 kfree(clp->cl_slot_tbl);
203 struct nfs_client *clp = nfs_alloc_client(cl_init);
206 if (IS_ERR(clp))
207 return clp;
209 err = nfs_get_cb_ident_idr(clp, cl_init->minorversion);
218 spin_lock_init(&clp->cl_lock);
219 INIT_DELAYED_WORK(&clp->cl_renewd, nfs4_renew_state);
220 INIT_LIST_HEAD(&clp->cl_ds_clients);
221 rpc_init_wait_queue(&clp->cl_rpcwaitq, "NFS client");
222 clp->cl_state = 1 << NFS4CLNT_LEASE_EXPIRED;
223 clp->cl_mvops = nfs_v4_minor_ops[cl_init->minorversion];
224 clp->cl_mig_gen = 1;
226 init_waitqueue_head(&clp->cl_lock_waitq);
228 INIT_LIST_HEAD(&clp->pending_cb_stateids);
231 __set_bit(NFS_CS_INFINITE_SLOTS, &clp->cl_flags);
232 __set_bit(NFS_CS_DISCRTRY, &clp->cl_flags);
233 __set_bit(NFS_CS_NO_RETRANS_TIMEOUT, &clp->cl_flags);
236 __set_bit(NFS_CS_DS, &clp->cl_flags);
241 err = nfs_create_rpc_client(clp, cl_init, RPC_AUTH_GSS_KRB5I);
243 err = nfs_create_rpc_client(clp, cl_init, RPC_AUTH_UNIX);
252 err = rpc_localaddr(clp->cl_rpcclient, sap, sizeof(cb_addr));
260 strscpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr));
262 err = nfs_idmap_new(clp);
268 __set_bit(NFS_CS_IDMAP, &clp->cl_res_state);
269 return clp;
272 nfs_free_client(clp);
279 static void nfs4_destroy_callback(struct nfs_client *clp)
281 if (__test_and_clear_bit(NFS_CS_CALLBACK, &clp->cl_res_state))
282 nfs_callback_down(clp->cl_mvops->minor_version, clp->cl_net);
285 static void nfs4_shutdown_client(struct nfs_client *clp)
287 if (__test_and_clear_bit(NFS_CS_RENEWD, &clp->cl_res_state))
288 nfs4_kill_renewd(clp);
289 clp->cl_mvops->shutdown_client(clp);
290 nfs4_destroy_callback(clp);
291 if (__test_and_clear_bit(NFS_CS_IDMAP, &clp->cl_res_state))
292 nfs_idmap_delete(clp);
294 rpc_destroy_wait_queue(&clp->cl_rpcwaitq);
295 kfree(clp->cl_serverowner);
296 kfree(clp->cl_serverscope);
297 kfree(clp->cl_implid);
298 kfree(clp->cl_owner_id);
301 void nfs4_free_client(struct nfs_client *clp)
303 nfs4_shutdown_client(clp);
304 nfs_free_client(clp);
310 static int nfs4_init_callback(struct nfs_client *clp)
315 xprt = rcu_dereference_raw(clp->cl_rpcclient->cl_xprt);
317 if (nfs4_has_session(clp)) {
323 error = nfs_callback_up(clp->cl_mvops->minor_version, xprt);
329 __set_bit(NFS_CS_CALLBACK, &clp->cl_res_state);
336 * @clp: nfs_client to initialize
340 int nfs40_init_client(struct nfs_client *clp)
357 clp->cl_slot_tbl = tbl;
365 * @clp: nfs_client to initialize
369 int nfs41_init_client(struct nfs_client *clp)
378 session = nfs4_alloc_session(clp);
382 clp->cl_session = session;
390 nfs_mark_client_ready(clp, NFS_CS_SESSION_INITING);
399 static int nfs4_init_client_minor_version(struct nfs_client *clp)
403 ret = clp->cl_mvops->init_client(clp);
406 return nfs4_init_callback(clp);
409 static void nfs4_add_trunk(struct nfs_client *clp, struct nfs_client *old)
420 int max_connect = test_bit(NFS_CS_PNFS, &clp->cl_flags) ?
421 clp->cl_max_connect : old->cl_max_connect;
423 if (clp->cl_proto != old->cl_proto)
425 clp_salen = rpc_peeraddr(clp->cl_rpcclient, clp_sap, sizeof(clp_addr));
441 * @clp: nfs_client to initialise
446 struct nfs_client *nfs4_init_client(struct nfs_client *clp,
452 if (clp->cl_cons_state == NFS_CS_READY)
454 return clp;
456 error = nfs4_init_client_minor_version(clp);
460 error = nfs4_discover_server_trunking(clp, &old);
464 if (clp != old) {
465 clp->cl_preserve_clid = true;
471 nfs_mark_client_ready(clp, -EPERM);
473 nfs4_add_trunk(clp, old);
475 clear_bit(NFS_CS_TSM_POSSIBLE, &clp->cl_flags);
476 nfs_put_client(clp);
480 nfs_mark_client_ready(clp, error);
481 nfs_put_client(clp);
693 * @clp: original mount nfs_client
707 int nfs4_detect_session_trunking(struct nfs_client *clp,
712 if (clp->cl_clientid != res->clientid)
716 if (!nfs4_check_serverowner_major_id(clp->cl_serverowner,
721 if (clp->cl_serverowner->minor_id != res->server_owner->minor_id)
725 if (!nfs4_check_server_scope(clp->cl_serverscope, res->server_scope))
729 clp->cl_hostname,
734 pr_info("NFS: %s: Session trunking failed for %s\n", clp->cl_hostname,
814 struct nfs_client *clp;
818 clp = idr_find(&nn->cb_ident_idr, cb_ident);
819 if (clp)
820 refcount_inc(&clp->cl_count);
822 return clp;
828 struct nfs_client *clp, u32 minorversion)
830 struct sockaddr *clap = (struct sockaddr *)&clp->cl_addr;
833 if (!(clp->cl_cons_state == NFS_CS_READY ||
834 clp->cl_cons_state == NFS_CS_SESSION_INITING))
840 if (clp->rpc_ops->version != 4 ||
841 clp->cl_minorversion != minorversion)
859 struct nfs_client *clp;
863 list_for_each_entry(clp, &nn->nfs_client_list, cl_share_link) {
864 if (!nfs4_cb_match_client(addr, clp, minorversion))
867 if (!nfs4_has_session(clp))
871 if (memcmp(clp->cl_session->sess_id.data,
875 refcount_inc(&clp->cl_count);
877 return clp;
920 struct nfs_client *clp;
941 clp = nfs_get_client(&cl_init);
942 if (IS_ERR(clp))
943 return PTR_ERR(clp);
945 if (server->nfs_client == clp) {
946 nfs_put_client(clp);
957 set_bit(NFS_CS_CHECK_LEASE_TIME, &clp->cl_res_state);
959 server->nfs_client = clp;
961 nfs_sysfs_link_rpc_client(server, clp->cl_rpcclient, "_state");
1336 struct nfs_client *clp = server->nfs_client;
1339 .ident = clp->cl_proto,
1365 clp->cl_proto, clnt->cl_timeout,
1366 clp->cl_minorversion,
1367 clp->cl_nconnect, clp->cl_max_connect,
1368 net, &clp->cl_xprtsec);
1374 nfs_put_client(clp);