Lines Matching refs:clp

151 	struct nfs_client *clp;
154 if ((clp = kzalloc(sizeof(*clp), GFP_KERNEL)) == NULL)
157 clp->cl_minorversion = cl_init->minorversion;
158 clp->cl_nfs_mod = cl_init->nfs_mod;
159 if (!try_module_get(clp->cl_nfs_mod->owner))
162 clp->rpc_ops = clp->cl_nfs_mod->rpc_ops;
164 refcount_set(&clp->cl_count, 1);
165 clp->cl_cons_state = NFS_CS_INITING;
167 memcpy(&clp->cl_addr, cl_init->addr, cl_init->addrlen);
168 clp->cl_addrlen = cl_init->addrlen;
172 clp->cl_hostname = kstrdup(cl_init->hostname, GFP_KERNEL);
173 if (!clp->cl_hostname)
177 INIT_LIST_HEAD(&clp->cl_superblocks);
178 clp->cl_rpcclient = ERR_PTR(-EINVAL);
180 clp->cl_flags = cl_init->init_flags;
181 clp->cl_proto = cl_init->proto;
182 clp->cl_nconnect = cl_init->nconnect;
183 clp->cl_max_connect = cl_init->max_connect ? cl_init->max_connect : 1;
184 clp->cl_net = get_net(cl_init->net);
186 clp->cl_principal = "*";
187 clp->cl_xprtsec = cl_init->xprtsec;
188 return clp;
191 put_nfs_version(clp->cl_nfs_mod);
193 kfree(clp);
208 static void nfs_cb_idr_remove_locked(struct nfs_client *clp)
210 struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
212 if (clp->cl_cb_ident)
213 idr_remove(&nn->cb_ident_idr, clp->cl_cb_ident);
226 static void nfs_cb_idr_remove_locked(struct nfs_client *clp)
239 void nfs_free_client(struct nfs_client *clp)
242 if (!IS_ERR(clp->cl_rpcclient))
243 rpc_shutdown_client(clp->cl_rpcclient);
245 put_net(clp->cl_net);
246 put_nfs_version(clp->cl_nfs_mod);
247 kfree(clp->cl_hostname);
248 kfree(clp->cl_acceptor);
249 kfree(clp);
256 void nfs_put_client(struct nfs_client *clp)
260 if (!clp)
263 nn = net_generic(clp->cl_net, nfs_net_id);
265 if (refcount_dec_and_lock(&clp->cl_count, &nn->nfs_client_lock)) {
266 list_del(&clp->cl_share_link);
267 nfs_cb_idr_remove_locked(clp);
270 WARN_ON_ONCE(!list_empty(&clp->cl_superblocks));
272 clp->rpc_ops->free_client(clp);
283 struct nfs_client *clp;
289 list_for_each_entry(clp, &nn->nfs_client_list, cl_share_link) {
290 const struct sockaddr *clap = (struct sockaddr *)&clp->cl_addr;
292 if (clp->cl_cons_state < 0)
296 if (clp->cl_cons_state > NFS_CS_READY) {
297 refcount_inc(&clp->cl_count);
299 error = nfs_wait_client_init_complete(clp);
300 nfs_put_client(clp);
308 if (clp->rpc_ops != data->nfs_mod->rpc_ops)
311 if (clp->cl_proto != data->proto)
314 if (clp->cl_minorversion != data->minorversion)
319 test_bit(NFS_CS_DS, &clp->cl_flags))
325 if (IS_ERR(clp->cl_rpcclient) ||
326 !rpc_clnt_xprt_switch_has_addr(clp->cl_rpcclient,
331 if (clp->cl_xprtsec.policy != data->xprtsec.policy)
334 refcount_inc(&clp->cl_count);
335 return clp;
341 * Return true if @clp is done initializing, false if still working on it.
345 bool nfs_client_init_is_complete(const struct nfs_client *clp)
347 return clp->cl_cons_state <= NFS_CS_READY;
352 * Return 0 if @clp was successfully initialized, -errno otherwise.
357 int nfs_client_init_status(const struct nfs_client *clp)
360 if (clp->cl_cons_state > NFS_CS_READY) {
364 return clp->cl_cons_state;
368 int nfs_wait_client_init_complete(const struct nfs_client *clp)
371 nfs_client_init_is_complete(clp));
380 struct nfs_client *clp)
384 error = nfs_wait_client_init_complete(clp);
386 nfs_put_client(clp);
390 if (clp->cl_cons_state < NFS_CS_READY) {
391 error = clp->cl_cons_state;
392 nfs_put_client(clp);
397 return clp;
406 struct nfs_client *clp, *new = NULL;
419 clp = nfs_match_client(cl_init);
420 if (clp) {
424 if (IS_ERR(clp))
425 return clp;
426 return nfs_found_client(cl_init, clp);
447 void nfs_mark_client_ready(struct nfs_client *clp, int state)
450 clp->cl_cons_state = state;
501 int nfs_create_rpc_client(struct nfs_client *clp,
507 .net = clp->cl_net,
508 .protocol = clp->cl_proto,
509 .nconnect = clp->cl_nconnect,
510 .address = (struct sockaddr *)&clp->cl_addr,
511 .addrsize = clp->cl_addrlen,
513 .servername = clp->cl_hostname,
516 .version = clp->rpc_ops->version,
524 if (test_bit(NFS_CS_DISCRTRY, &clp->cl_flags))
526 if (test_bit(NFS_CS_NO_RETRANS_TIMEOUT, &clp->cl_flags))
528 if (test_bit(NFS_CS_NORESVPORT, &clp->cl_flags))
530 if (test_bit(NFS_CS_INFINITE_SLOTS, &clp->cl_flags))
532 if (test_bit(NFS_CS_NOPING, &clp->cl_flags))
534 if (test_bit(NFS_CS_REUSEPORT, &clp->cl_flags))
537 if (!IS_ERR(clp->cl_rpcclient))
547 clnt->cl_principal = clp->cl_principal;
548 clp->cl_rpcclient = clnt;
549 clnt->cl_max_connect = clp->cl_max_connect;
569 struct nfs_client *clp = server->nfs_client;
571 .hostname = clp->cl_hostname,
572 .address = (struct sockaddr *)&clp->cl_addr,
573 .addrlen = clp->cl_addrlen,
574 .nfs_version = clp->rpc_ops->version,
577 .net = clp->cl_net,
578 .nlmclnt_ops = clp->cl_nfs_mod->rpc_ops->nlmclnt_ops,
588 switch (clp->cl_proto) {
615 struct nfs_client *clp = server->nfs_client;
617 server->client = rpc_clone_client_set_auth(clp->cl_rpcclient,
642 * @clp: nfs_client to initialise
647 struct nfs_client *nfs_init_client(struct nfs_client *clp,
653 if (clp->cl_cons_state == NFS_CS_READY)
654 return clp;
660 error = nfs_create_rpc_client(clp, cl_init, RPC_AUTH_UNIX);
661 nfs_mark_client_ready(clp, error == 0 ? NFS_CS_READY : error);
663 nfs_put_client(clp);
664 clp = ERR_PTR(error);
666 return clp;
691 struct nfs_client *clp;
700 clp = nfs_get_client(&cl_init);
701 if (IS_ERR(clp))
702 return PTR_ERR(clp);
704 server->nfs_client = clp;
706 nfs_sysfs_link_rpc_client(server, clp->cl_rpcclient, "_state");
713 switch (clp->rpc_ops->version) {
725 server->rsize = nfs_io_size(ctx->rsize, clp->cl_proto);
727 server->wsize = nfs_io_size(ctx->wsize, clp->cl_proto);
762 nfs_put_client(clp);
772 struct nfs_client *clp = server->nfs_client;
777 server->rsize = nfs_io_size(fsinfo->rtpref, clp->cl_proto);
779 server->wsize = nfs_io_size(fsinfo->wtpref, clp->cl_proto);
782 server->rsize = nfs_io_size(fsinfo->rtmax, clp->cl_proto);
784 server->wsize = nfs_io_size(fsinfo->wtmax, clp->cl_proto);
845 struct nfs_client *clp = server->nfs_client;
848 if (clp->rpc_ops->set_capabilities != NULL) {
849 error = clp->rpc_ops->set_capabilities(server, mntfh);
857 error = clp->rpc_ops->fsinfo(server, mntfh, &fsinfo);
870 if (clp->rpc_ops->pathconf(server, mntfh, &pathinfo) >= 0)
874 if (clp->rpc_ops->discover_trunking != NULL &&
877 error = clp->rpc_ops->discover_trunking(server, mntfh);
930 struct nfs_client *clp = server->nfs_client;
931 struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
934 list_add_tail_rcu(&server->client_link, &clp->cl_superblocks);
936 clear_bit(NFS_CS_STOP_RENEW, &clp->cl_res_state);
944 struct nfs_client *clp = server->nfs_client;
947 if (clp == NULL)
949 nn = net_generic(clp->cl_net, nfs_net_id);
952 if (list_empty(&clp->cl_superblocks))
953 set_bit(NFS_CS_STOP_RENEW, &clp->cl_res_state);
1256 struct nfs_client *clp;
1266 clp = list_entry(v, struct nfs_client, cl_share_link);
1269 if (clp->cl_cons_state != NFS_CS_READY)
1274 clp->rpc_ops->version,
1275 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_HEX_ADDR),
1276 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_HEX_PORT),
1277 refcount_read(&clp->cl_count),
1278 clp->cl_hostname);
1324 struct nfs_client *clp;
1337 clp = server->nfs_client;
1348 clp->rpc_ops->version,
1349 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_HEX_ADDR),
1350 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_HEX_PORT),