Lines Matching refs:clp
150 struct nfs_client *clp;
153 if ((clp = kzalloc(sizeof(*clp), GFP_KERNEL)) == NULL)
156 clp->cl_minorversion = cl_init->minorversion;
157 clp->cl_nfs_mod = cl_init->nfs_mod;
158 if (!try_module_get(clp->cl_nfs_mod->owner))
161 clp->rpc_ops = clp->cl_nfs_mod->rpc_ops;
163 refcount_set(&clp->cl_count, 1);
164 clp->cl_cons_state = NFS_CS_INITING;
166 memcpy(&clp->cl_addr, cl_init->addr, cl_init->addrlen);
167 clp->cl_addrlen = cl_init->addrlen;
171 clp->cl_hostname = kstrdup(cl_init->hostname, GFP_KERNEL);
172 if (!clp->cl_hostname)
176 INIT_LIST_HEAD(&clp->cl_superblocks);
177 clp->cl_rpcclient = ERR_PTR(-EINVAL);
179 clp->cl_flags = cl_init->init_flags;
180 clp->cl_proto = cl_init->proto;
181 clp->cl_nconnect = cl_init->nconnect;
182 clp->cl_net = get_net(cl_init->net);
184 clp->cl_principal = "*";
185 nfs_fscache_get_client_cookie(clp);
187 return clp;
190 put_nfs_version(clp->cl_nfs_mod);
192 kfree(clp);
207 static void nfs_cb_idr_remove_locked(struct nfs_client *clp)
209 struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
211 if (clp->cl_cb_ident)
212 idr_remove(&nn->cb_ident_idr, clp->cl_cb_ident);
225 static void nfs_cb_idr_remove_locked(struct nfs_client *clp)
238 void nfs_free_client(struct nfs_client *clp)
240 nfs_fscache_release_client_cookie(clp);
243 if (!IS_ERR(clp->cl_rpcclient))
244 rpc_shutdown_client(clp->cl_rpcclient);
246 put_net(clp->cl_net);
247 put_nfs_version(clp->cl_nfs_mod);
248 kfree(clp->cl_hostname);
249 kfree(clp->cl_acceptor);
250 kfree(clp);
257 void nfs_put_client(struct nfs_client *clp)
261 if (!clp)
264 nn = net_generic(clp->cl_net, nfs_net_id);
266 if (refcount_dec_and_lock(&clp->cl_count, &nn->nfs_client_lock)) {
267 list_del(&clp->cl_share_link);
268 nfs_cb_idr_remove_locked(clp);
271 WARN_ON_ONCE(!list_empty(&clp->cl_superblocks));
273 clp->rpc_ops->free_client(clp);
284 struct nfs_client *clp;
290 list_for_each_entry(clp, &nn->nfs_client_list, cl_share_link) {
291 const struct sockaddr *clap = (struct sockaddr *)&clp->cl_addr;
293 if (clp->cl_cons_state < 0)
297 if (clp->cl_cons_state > NFS_CS_READY) {
298 refcount_inc(&clp->cl_count);
300 error = nfs_wait_client_init_complete(clp);
301 nfs_put_client(clp);
309 if (clp->rpc_ops != data->nfs_mod->rpc_ops)
312 if (clp->cl_proto != data->proto)
315 if (clp->cl_minorversion != data->minorversion)
320 test_bit(NFS_CS_DS, &clp->cl_flags))
326 if (IS_ERR(clp->cl_rpcclient) ||
327 !rpc_clnt_xprt_switch_has_addr(clp->cl_rpcclient,
331 refcount_inc(&clp->cl_count);
332 return clp;
338 * Return true if @clp is done initializing, false if still working on it.
342 bool nfs_client_init_is_complete(const struct nfs_client *clp)
344 return clp->cl_cons_state <= NFS_CS_READY;
349 * Return 0 if @clp was successfully initialized, -errno otherwise.
354 int nfs_client_init_status(const struct nfs_client *clp)
357 if (clp->cl_cons_state > NFS_CS_READY) {
361 return clp->cl_cons_state;
365 int nfs_wait_client_init_complete(const struct nfs_client *clp)
368 nfs_client_init_is_complete(clp));
377 struct nfs_client *clp)
381 error = nfs_wait_client_init_complete(clp);
383 nfs_put_client(clp);
387 if (clp->cl_cons_state < NFS_CS_READY) {
388 error = clp->cl_cons_state;
389 nfs_put_client(clp);
394 return clp;
403 struct nfs_client *clp, *new = NULL;
416 clp = nfs_match_client(cl_init);
417 if (clp) {
421 if (IS_ERR(clp))
422 return clp;
423 return nfs_found_client(cl_init, clp);
444 void nfs_mark_client_ready(struct nfs_client *clp, int state)
447 clp->cl_cons_state = state;
499 int nfs_create_rpc_client(struct nfs_client *clp,
503 struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
506 .net = clp->cl_net,
507 .protocol = clp->cl_proto,
508 .nconnect = clp->cl_nconnect,
509 .address = (struct sockaddr *)&clp->cl_addr,
510 .addrsize = clp->cl_addrlen,
512 .servername = clp->cl_hostname,
516 .version = clp->rpc_ops->version,
521 if (test_bit(NFS_CS_DISCRTRY, &clp->cl_flags))
523 if (test_bit(NFS_CS_NO_RETRANS_TIMEOUT, &clp->cl_flags))
525 if (test_bit(NFS_CS_NORESVPORT, &clp->cl_flags))
527 if (test_bit(NFS_CS_INFINITE_SLOTS, &clp->cl_flags))
529 if (test_bit(NFS_CS_NOPING, &clp->cl_flags))
531 if (test_bit(NFS_CS_REUSEPORT, &clp->cl_flags))
534 if (!IS_ERR(clp->cl_rpcclient))
544 clnt->cl_principal = clp->cl_principal;
545 clp->cl_rpcclient = clnt;
565 struct nfs_client *clp = server->nfs_client;
567 .hostname = clp->cl_hostname,
568 .address = (struct sockaddr *)&clp->cl_addr,
569 .addrlen = clp->cl_addrlen,
570 .nfs_version = clp->rpc_ops->version,
573 .net = clp->cl_net,
574 .nlmclnt_ops = clp->cl_nfs_mod->rpc_ops->nlmclnt_ops,
584 switch (clp->cl_proto) {
610 struct nfs_client *clp = server->nfs_client;
612 server->client = rpc_clone_client_set_auth(clp->cl_rpcclient,
636 * @clp: nfs_client to initialise
641 struct nfs_client *nfs_init_client(struct nfs_client *clp,
647 if (clp->cl_cons_state == NFS_CS_READY)
648 return clp;
654 error = nfs_create_rpc_client(clp, cl_init, RPC_AUTH_UNIX);
655 nfs_mark_client_ready(clp, error == 0 ? NFS_CS_READY : error);
657 nfs_put_client(clp);
658 clp = ERR_PTR(error);
660 return clp;
684 struct nfs_client *clp;
693 clp = nfs_get_client(&cl_init);
694 if (IS_ERR(clp))
695 return PTR_ERR(clp);
697 server->nfs_client = clp;
744 nfs_put_client(clp);
825 struct nfs_client *clp = server->nfs_client;
828 if (clp->rpc_ops->set_capabilities != NULL) {
829 error = clp->rpc_ops->set_capabilities(server, mntfh);
837 error = clp->rpc_ops->fsinfo(server, mntfh, &fsinfo);
850 if (clp->rpc_ops->pathconf(server, mntfh, &pathinfo) >= 0)
879 struct nfs_client *clp = server->nfs_client;
880 struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
883 list_add_tail_rcu(&server->client_link, &clp->cl_superblocks);
885 clear_bit(NFS_CS_STOP_RENEW, &clp->cl_res_state);
893 struct nfs_client *clp = server->nfs_client;
896 if (clp == NULL)
898 nn = net_generic(clp->cl_net, nfs_net_id);
901 if (list_empty(&clp->cl_superblocks))
902 set_bit(NFS_CS_STOP_RENEW, &clp->cl_res_state);
1194 struct nfs_client *clp;
1204 clp = list_entry(v, struct nfs_client, cl_share_link);
1207 if (clp->cl_cons_state != NFS_CS_READY)
1212 clp->rpc_ops->version,
1213 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_HEX_ADDR),
1214 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_HEX_PORT),
1215 refcount_read(&clp->cl_count),
1216 clp->cl_hostname);
1262 struct nfs_client *clp;
1275 clp = server->nfs_client;
1286 clp->rpc_ops->version,
1287 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_HEX_ADDR),
1288 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_HEX_PORT),