Lines Matching refs:clnt

81 static int	rpc_ping(struct rpc_clnt *clnt);
83 static void rpc_register_client(struct rpc_clnt *clnt) in rpc_register_client() argument
85 struct net *net = rpc_net_ns(clnt); in rpc_register_client()
89 list_add(&clnt->cl_clients, &sn->all_clients); in rpc_register_client()
93 static void rpc_unregister_client(struct rpc_clnt *clnt) in rpc_unregister_client() argument
95 struct net *net = rpc_net_ns(clnt); in rpc_unregister_client()
99 list_del(&clnt->cl_clients); in rpc_unregister_client()
103 static void __rpc_clnt_remove_pipedir(struct rpc_clnt *clnt) in __rpc_clnt_remove_pipedir() argument
105 rpc_remove_client_dir(clnt); in __rpc_clnt_remove_pipedir()
108 static void rpc_clnt_remove_pipedir(struct rpc_clnt *clnt) in rpc_clnt_remove_pipedir() argument
110 struct net *net = rpc_net_ns(clnt); in rpc_clnt_remove_pipedir()
115 __rpc_clnt_remove_pipedir(clnt); in rpc_clnt_remove_pipedir()
121 struct rpc_clnt *clnt) in rpc_setup_pipedir_sb() argument
124 const char *dir_name = clnt->cl_program->pipe_dir_name; in rpc_setup_pipedir_sb()
136 dentry = rpc_create_client_dir(dir, name, clnt); in rpc_setup_pipedir_sb()
151 rpc_setup_pipedir(struct super_block *pipefs_sb, struct rpc_clnt *clnt) in rpc_setup_pipedir() argument
155 if (clnt->cl_program->pipe_dir_name != NULL) { in rpc_setup_pipedir()
156 dentry = rpc_setup_pipedir_sb(pipefs_sb, clnt); in rpc_setup_pipedir()
163 static int rpc_clnt_skip_event(struct rpc_clnt *clnt, unsigned long event) in rpc_clnt_skip_event() argument
165 if (clnt->cl_program->pipe_dir_name == NULL) in rpc_clnt_skip_event()
170 if (clnt->cl_pipedir_objects.pdh_dentry != NULL) in rpc_clnt_skip_event()
172 if (atomic_read(&clnt->cl_count) == 0) in rpc_clnt_skip_event()
176 if (clnt->cl_pipedir_objects.pdh_dentry == NULL) in rpc_clnt_skip_event()
183 static int __rpc_clnt_handle_event(struct rpc_clnt *clnt, unsigned long event, in __rpc_clnt_handle_event() argument
191 dentry = rpc_setup_pipedir_sb(sb, clnt); in __rpc_clnt_handle_event()
198 __rpc_clnt_remove_pipedir(clnt); in __rpc_clnt_handle_event()
207 static int __rpc_pipefs_event(struct rpc_clnt *clnt, unsigned long event, in __rpc_pipefs_event() argument
212 for (;; clnt = clnt->cl_parent) { in __rpc_pipefs_event()
213 if (!rpc_clnt_skip_event(clnt, event)) in __rpc_pipefs_event()
214 error = __rpc_clnt_handle_event(clnt, event, sb); in __rpc_pipefs_event()
215 if (error || clnt == clnt->cl_parent) in __rpc_pipefs_event()
224 struct rpc_clnt *clnt; in rpc_get_client_for_event() local
227 list_for_each_entry(clnt, &sn->all_clients, cl_clients) { in rpc_get_client_for_event()
228 if (rpc_clnt_skip_event(clnt, event)) in rpc_get_client_for_event()
231 return clnt; in rpc_get_client_for_event()
241 struct rpc_clnt *clnt; in rpc_pipefs_event() local
244 while ((clnt = rpc_get_client_for_event(sb->s_fs_info, event))) { in rpc_pipefs_event()
245 error = __rpc_pipefs_event(clnt, event, sb); in rpc_pipefs_event()
267 static struct rpc_xprt *rpc_clnt_set_transport(struct rpc_clnt *clnt, in rpc_clnt_set_transport() argument
273 spin_lock(&clnt->cl_lock); in rpc_clnt_set_transport()
274 old = rcu_dereference_protected(clnt->cl_xprt, in rpc_clnt_set_transport()
275 lockdep_is_held(&clnt->cl_lock)); in rpc_clnt_set_transport()
278 clnt->cl_autobind = 1; in rpc_clnt_set_transport()
280 clnt->cl_timeout = timeout; in rpc_clnt_set_transport()
281 rcu_assign_pointer(clnt->cl_xprt, xprt); in rpc_clnt_set_transport()
282 spin_unlock(&clnt->cl_lock); in rpc_clnt_set_transport()
287 static void rpc_clnt_set_nodename(struct rpc_clnt *clnt, const char *nodename) in rpc_clnt_set_nodename() argument
289 clnt->cl_nodelen = strlcpy(clnt->cl_nodename, in rpc_clnt_set_nodename()
290 nodename, sizeof(clnt->cl_nodename)); in rpc_clnt_set_nodename()
293 static int rpc_client_register(struct rpc_clnt *clnt, in rpc_client_register() argument
302 struct net *net = rpc_net_ns(clnt); in rpc_client_register()
306 rpc_clnt_debugfs_register(clnt); in rpc_client_register()
310 err = rpc_setup_pipedir(pipefs_sb, clnt); in rpc_client_register()
315 rpc_register_client(clnt); in rpc_client_register()
319 auth = rpcauth_create(&auth_args, clnt); in rpc_client_register()
329 rpc_unregister_client(clnt); in rpc_client_register()
330 __rpc_clnt_remove_pipedir(clnt); in rpc_client_register()
334 rpc_clnt_debugfs_unregister(clnt); in rpc_client_register()
340 static int rpc_alloc_clid(struct rpc_clnt *clnt) in rpc_alloc_clid() argument
347 clnt->cl_clid = clid; in rpc_alloc_clid()
351 static void rpc_free_clid(struct rpc_clnt *clnt) in rpc_free_clid() argument
353 ida_simple_remove(&rpc_clids, clnt->cl_clid); in rpc_free_clid()
362 struct rpc_clnt *clnt = NULL; in rpc_new_client() local
383 clnt = kzalloc(sizeof(*clnt), GFP_KERNEL); in rpc_new_client()
384 if (!clnt) in rpc_new_client()
386 clnt->cl_parent = parent ? : clnt; in rpc_new_client()
388 err = rpc_alloc_clid(clnt); in rpc_new_client()
392 clnt->cl_procinfo = version->procs; in rpc_new_client()
393 clnt->cl_maxproc = version->nrprocs; in rpc_new_client()
394 clnt->cl_prog = args->prognumber ? : program->number; in rpc_new_client()
395 clnt->cl_vers = version->number; in rpc_new_client()
396 clnt->cl_stats = program->stats; in rpc_new_client()
397 clnt->cl_metrics = rpc_alloc_iostats(clnt); in rpc_new_client()
398 rpc_init_pipe_dir_head(&clnt->cl_pipedir_objects); in rpc_new_client()
400 if (clnt->cl_metrics == NULL) in rpc_new_client()
402 clnt->cl_program = program; in rpc_new_client()
403 INIT_LIST_HEAD(&clnt->cl_tasks); in rpc_new_client()
404 spin_lock_init(&clnt->cl_lock); in rpc_new_client()
408 memcpy(&clnt->cl_timeout_default, args->timeout, in rpc_new_client()
409 sizeof(clnt->cl_timeout_default)); in rpc_new_client()
410 timeout = &clnt->cl_timeout_default; in rpc_new_client()
413 rpc_clnt_set_transport(clnt, xprt, timeout); in rpc_new_client()
415 clnt->cl_rtt = &clnt->cl_rtt_default; in rpc_new_client()
416 rpc_init_rtt(&clnt->cl_rtt_default, clnt->cl_timeout->to_initval); in rpc_new_client()
418 atomic_set(&clnt->cl_count, 1); in rpc_new_client()
423 rpc_clnt_set_nodename(clnt, nodename); in rpc_new_client()
425 err = rpc_client_register(clnt, args->authflavor, args->client_name); in rpc_new_client()
430 return clnt; in rpc_new_client()
433 rpc_free_iostats(clnt->cl_metrics); in rpc_new_client()
435 rpc_free_clid(clnt); in rpc_new_client()
437 kfree(clnt); in rpc_new_client()
448 struct rpc_clnt *clnt = NULL; in rpc_create_xprt() local
450 clnt = rpc_new_client(args, xprt, NULL); in rpc_create_xprt()
451 if (IS_ERR(clnt)) in rpc_create_xprt()
452 return clnt; in rpc_create_xprt()
455 int err = rpc_ping(clnt); in rpc_create_xprt()
457 rpc_shutdown_client(clnt); in rpc_create_xprt()
462 clnt->cl_softrtry = 1; in rpc_create_xprt()
464 clnt->cl_softrtry = 0; in rpc_create_xprt()
467 clnt->cl_autobind = 1; in rpc_create_xprt()
469 clnt->cl_noretranstimeo = 1; in rpc_create_xprt()
471 clnt->cl_discrtry = 1; in rpc_create_xprt()
473 clnt->cl_chatty = 1; in rpc_create_xprt()
475 return clnt; in rpc_create_xprt()
565 struct rpc_clnt *clnt) in __rpc_clone_client() argument
573 xprt = xprt_get(rcu_dereference(clnt->cl_xprt)); in __rpc_clone_client()
578 args->nodename = clnt->cl_nodename; in __rpc_clone_client()
580 new = rpc_new_client(args, xprt, clnt); in __rpc_clone_client()
588 new->cl_softrtry = clnt->cl_softrtry; in __rpc_clone_client()
589 new->cl_noretranstimeo = clnt->cl_noretranstimeo; in __rpc_clone_client()
590 new->cl_discrtry = clnt->cl_discrtry; in __rpc_clone_client()
591 new->cl_chatty = clnt->cl_chatty; in __rpc_clone_client()
606 struct rpc_clnt *rpc_clone_client(struct rpc_clnt *clnt) in rpc_clone_client() argument
609 .program = clnt->cl_program, in rpc_clone_client()
610 .prognumber = clnt->cl_prog, in rpc_clone_client()
611 .version = clnt->cl_vers, in rpc_clone_client()
612 .authflavor = clnt->cl_auth->au_flavor, in rpc_clone_client()
614 return __rpc_clone_client(&args, clnt); in rpc_clone_client()
627 rpc_clone_client_set_auth(struct rpc_clnt *clnt, rpc_authflavor_t flavor) in rpc_clone_client_set_auth() argument
630 .program = clnt->cl_program, in rpc_clone_client_set_auth()
631 .prognumber = clnt->cl_prog, in rpc_clone_client_set_auth()
632 .version = clnt->cl_vers, in rpc_clone_client_set_auth()
635 return __rpc_clone_client(&args, clnt); in rpc_clone_client_set_auth()
654 int rpc_switch_client_transport(struct rpc_clnt *clnt, in rpc_switch_client_transport() argument
667 clnt); in rpc_switch_client_transport()
671 pseudoflavor = clnt->cl_auth->au_flavor; in rpc_switch_client_transport()
673 old_timeo = clnt->cl_timeout; in rpc_switch_client_transport()
674 old = rpc_clnt_set_transport(clnt, xprt, timeout); in rpc_switch_client_transport()
676 rpc_unregister_client(clnt); in rpc_switch_client_transport()
677 __rpc_clnt_remove_pipedir(clnt); in rpc_switch_client_transport()
678 rpc_clnt_debugfs_unregister(clnt); in rpc_switch_client_transport()
685 parent = clnt->cl_parent; in rpc_switch_client_transport()
686 clnt->cl_parent = clnt; in rpc_switch_client_transport()
693 err = rpc_client_register(clnt, pseudoflavor, NULL); in rpc_switch_client_transport()
698 if (parent != clnt) in rpc_switch_client_transport()
701 dprintk("RPC: replaced xprt for clnt %p\n", clnt); in rpc_switch_client_transport()
705 rpc_clnt_set_transport(clnt, old, old_timeo); in rpc_switch_client_transport()
706 clnt->cl_parent = parent; in rpc_switch_client_transport()
707 rpc_client_register(clnt, pseudoflavor, NULL); in rpc_switch_client_transport()
709 dprintk("RPC: failed to switch xprt for clnt %p\n", clnt); in rpc_switch_client_transport()
718 void rpc_killall_tasks(struct rpc_clnt *clnt) in rpc_killall_tasks() argument
723 if (list_empty(&clnt->cl_tasks)) in rpc_killall_tasks()
725 dprintk("RPC: killing all tasks for client %p\n", clnt); in rpc_killall_tasks()
729 spin_lock(&clnt->cl_lock); in rpc_killall_tasks()
730 list_for_each_entry(rovr, &clnt->cl_tasks, tk_task) { in rpc_killall_tasks()
741 spin_unlock(&clnt->cl_lock); in rpc_killall_tasks()
749 void rpc_shutdown_client(struct rpc_clnt *clnt) in rpc_shutdown_client() argument
754 clnt->cl_program->name, in rpc_shutdown_client()
755 rcu_dereference(clnt->cl_xprt)->servername); in rpc_shutdown_client()
757 while (!list_empty(&clnt->cl_tasks)) { in rpc_shutdown_client()
758 rpc_killall_tasks(clnt); in rpc_shutdown_client()
760 list_empty(&clnt->cl_tasks), 1*HZ); in rpc_shutdown_client()
763 rpc_release_client(clnt); in rpc_shutdown_client()
771 rpc_free_client(struct rpc_clnt *clnt) in rpc_free_client() argument
776 clnt->cl_program->name, in rpc_free_client()
777 rcu_dereference(clnt->cl_xprt)->servername); in rpc_free_client()
778 if (clnt->cl_parent != clnt) in rpc_free_client()
779 parent = clnt->cl_parent; in rpc_free_client()
780 rpc_clnt_debugfs_unregister(clnt); in rpc_free_client()
781 rpc_clnt_remove_pipedir(clnt); in rpc_free_client()
782 rpc_unregister_client(clnt); in rpc_free_client()
783 rpc_free_iostats(clnt->cl_metrics); in rpc_free_client()
784 clnt->cl_metrics = NULL; in rpc_free_client()
785 xprt_put(rcu_dereference_raw(clnt->cl_xprt)); in rpc_free_client()
787 rpc_free_clid(clnt); in rpc_free_client()
788 kfree(clnt); in rpc_free_client()
796 rpc_free_auth(struct rpc_clnt *clnt) in rpc_free_auth() argument
798 if (clnt->cl_auth == NULL) in rpc_free_auth()
799 return rpc_free_client(clnt); in rpc_free_auth()
806 atomic_inc(&clnt->cl_count); in rpc_free_auth()
807 rpcauth_release(clnt->cl_auth); in rpc_free_auth()
808 clnt->cl_auth = NULL; in rpc_free_auth()
809 if (atomic_dec_and_test(&clnt->cl_count)) in rpc_free_auth()
810 return rpc_free_client(clnt); in rpc_free_auth()
818 rpc_release_client(struct rpc_clnt *clnt) in rpc_release_client() argument
820 dprintk("RPC: rpc_release_client(%p)\n", clnt); in rpc_release_client()
823 if (list_empty(&clnt->cl_tasks)) in rpc_release_client()
825 if (!atomic_dec_and_test(&clnt->cl_count)) in rpc_release_client()
827 clnt = rpc_free_auth(clnt); in rpc_release_client()
828 } while (clnt != NULL); in rpc_release_client()
852 struct rpc_clnt *clnt; in rpc_bind_new_program() local
855 clnt = __rpc_clone_client(&args, old); in rpc_bind_new_program()
856 if (IS_ERR(clnt)) in rpc_bind_new_program()
858 err = rpc_ping(clnt); in rpc_bind_new_program()
860 rpc_shutdown_client(clnt); in rpc_bind_new_program()
861 clnt = ERR_PTR(err); in rpc_bind_new_program()
864 return clnt; in rpc_bind_new_program()
870 struct rpc_clnt *clnt = task->tk_client; in rpc_task_release_client() local
872 if (clnt != NULL) { in rpc_task_release_client()
874 spin_lock(&clnt->cl_lock); in rpc_task_release_client()
876 spin_unlock(&clnt->cl_lock); in rpc_task_release_client()
879 rpc_release_client(clnt); in rpc_task_release_client()
884 void rpc_task_set_client(struct rpc_task *task, struct rpc_clnt *clnt) in rpc_task_set_client() argument
886 if (clnt != NULL) { in rpc_task_set_client()
888 task->tk_client = clnt; in rpc_task_set_client()
889 atomic_inc(&clnt->cl_count); in rpc_task_set_client()
890 if (clnt->cl_softrtry) in rpc_task_set_client()
892 if (clnt->cl_noretranstimeo) in rpc_task_set_client()
894 if (atomic_read(&clnt->cl_swapper)) in rpc_task_set_client()
897 spin_lock(&clnt->cl_lock); in rpc_task_set_client()
898 list_add_tail(&task->tk_task, &clnt->cl_tasks); in rpc_task_set_client()
899 spin_unlock(&clnt->cl_lock); in rpc_task_set_client()
903 void rpc_task_reset_client(struct rpc_task *task, struct rpc_clnt *clnt) in rpc_task_reset_client() argument
906 rpc_task_set_client(task, clnt); in rpc_task_reset_client()
966 int rpc_call_sync(struct rpc_clnt *clnt, const struct rpc_message *msg, int flags) in rpc_call_sync() argument
970 .rpc_client = clnt, in rpc_call_sync()
1002 rpc_call_async(struct rpc_clnt *clnt, const struct rpc_message *msg, int flags, in rpc_call_async() argument
1007 .rpc_client = clnt, in rpc_call_async()
1081 size_t rpc_peeraddr(struct rpc_clnt *clnt, struct sockaddr *buf, size_t bufsize) in rpc_peeraddr() argument
1087 xprt = rcu_dereference(clnt->cl_xprt); in rpc_peeraddr()
1108 const char *rpc_peeraddr2str(struct rpc_clnt *clnt, in rpc_peeraddr2str() argument
1113 xprt = rcu_dereference(clnt->cl_xprt); in rpc_peeraddr2str()
1245 int rpc_localaddr(struct rpc_clnt *clnt, struct sockaddr *buf, size_t buflen) in rpc_localaddr() argument
1255 xprt = rcu_dereference(clnt->cl_xprt); in rpc_localaddr()
1272 rpc_setbufsize(struct rpc_clnt *clnt, unsigned int sndsize, unsigned int rcvsize) in rpc_setbufsize() argument
1277 xprt = rcu_dereference(clnt->cl_xprt); in rpc_setbufsize()
1289 int rpc_protocol(struct rpc_clnt *clnt) in rpc_protocol() argument
1294 protocol = rcu_dereference(clnt->cl_xprt)->prot; in rpc_protocol()
1305 struct net *rpc_net_ns(struct rpc_clnt *clnt) in rpc_net_ns() argument
1310 ret = rcu_dereference(clnt->cl_xprt)->xprt_net; in rpc_net_ns()
1325 size_t rpc_max_payload(struct rpc_clnt *clnt) in rpc_max_payload() argument
1330 ret = rcu_dereference(clnt->cl_xprt)->max_payload; in rpc_max_payload()
1340 unsigned long rpc_get_timeout(struct rpc_clnt *clnt) in rpc_get_timeout() argument
1345 ret = rcu_dereference(clnt->cl_xprt)->timeout->to_initval; in rpc_get_timeout()
1356 void rpc_force_rebind(struct rpc_clnt *clnt) in rpc_force_rebind() argument
1358 if (clnt->cl_autobind) { in rpc_force_rebind()
1360 xprt_clear_bound(rcu_dereference(clnt->cl_xprt)); in rpc_force_rebind()
1423 struct rpc_clnt *clnt = task->tk_client; in call_start() local
1426 clnt->cl_program->name, clnt->cl_vers, in call_start()
1432 clnt->cl_stats->rpccnt++; in call_start()
1807 struct rpc_clnt *clnt = task->tk_client; in call_connect_status() local
1833 clnt->cl_stats->netreconn++; in call_connect_status()
2017 struct rpc_clnt *clnt = task->tk_client; in call_status() local
2058 rpc_force_rebind(clnt); in call_status()
2075 if (clnt->cl_chatty) in call_status()
2077 clnt->cl_program->name, -status); in call_status()
2090 struct rpc_clnt *clnt = task->tk_client; in call_timeout() local
2105 if (clnt->cl_chatty) { in call_timeout()
2108 clnt->cl_program->name, in call_timeout()
2109 rcu_dereference(clnt->cl_xprt)->servername); in call_timeout()
2121 if (clnt->cl_chatty) { in call_timeout()
2124 clnt->cl_program->name, in call_timeout()
2125 rcu_dereference(clnt->cl_xprt)->servername); in call_timeout()
2129 rpc_force_rebind(clnt); in call_timeout()
2147 struct rpc_clnt *clnt = task->tk_client; in call_decode() local
2155 if (clnt->cl_chatty) { in call_decode()
2158 clnt->cl_program->name, in call_decode()
2159 rcu_dereference(clnt->cl_xprt)->servername); in call_decode()
2182 clnt->cl_program->name, task->tk_status); in call_decode()
2217 struct rpc_clnt *clnt = task->tk_client; in rpc_encode_header() local
2227 *p++ = htonl(clnt->cl_prog); /* program number */ in rpc_encode_header()
2228 *p++ = htonl(clnt->cl_vers); /* program version */ in rpc_encode_header()
2238 struct rpc_clnt *clnt = task->tk_client; in rpc_verify_header() local
2317 rcu_dereference(clnt->cl_xprt)->servername); in rpc_verify_header()
2345 (unsigned int)clnt->cl_prog, in rpc_verify_header()
2346 rcu_dereference(clnt->cl_xprt)->servername); in rpc_verify_header()
2352 (unsigned int)clnt->cl_prog, in rpc_verify_header()
2353 (unsigned int)clnt->cl_vers, in rpc_verify_header()
2354 rcu_dereference(clnt->cl_xprt)->servername); in rpc_verify_header()
2362 clnt->cl_prog, clnt->cl_vers, in rpc_verify_header()
2363 rcu_dereference(clnt->cl_xprt)->servername); in rpc_verify_header()
2377 clnt->cl_stats->rpcgarbage++; in rpc_verify_header()
2411 static int rpc_ping(struct rpc_clnt *clnt) in rpc_ping() argument
2418 err = rpc_call_sync(clnt, &msg, RPC_TASK_SOFT | RPC_TASK_SOFTCONN); in rpc_ping()
2423 struct rpc_task *rpc_call_null(struct rpc_clnt *clnt, struct rpc_cred *cred, int flags) in rpc_call_null() argument
2430 .rpc_client = clnt, in rpc_call_null()
2446 static void rpc_show_task(const struct rpc_clnt *clnt, in rpc_show_task() argument
2456 clnt, task->tk_rqstp, task->tk_timeout, task->tk_ops, in rpc_show_task()
2457 clnt->cl_program->name, clnt->cl_vers, rpc_proc_name(task), in rpc_show_task()
2463 struct rpc_clnt *clnt; in rpc_show_tasks() local
2469 list_for_each_entry(clnt, &sn->all_clients, cl_clients) { in rpc_show_tasks()
2470 spin_lock(&clnt->cl_lock); in rpc_show_tasks()
2471 list_for_each_entry(task, &clnt->cl_tasks, tk_task) { in rpc_show_tasks()
2476 rpc_show_task(clnt, task); in rpc_show_tasks()
2478 spin_unlock(&clnt->cl_lock); in rpc_show_tasks()
2486 rpc_clnt_swap_activate(struct rpc_clnt *clnt) in rpc_clnt_swap_activate() argument
2491 if (atomic_inc_return(&clnt->cl_swapper) == 1) { in rpc_clnt_swap_activate()
2494 xprt = xprt_get(rcu_dereference(clnt->cl_xprt)); in rpc_clnt_swap_activate()
2514 rpc_clnt_swap_deactivate(struct rpc_clnt *clnt) in rpc_clnt_swap_deactivate() argument
2518 if (atomic_dec_if_positive(&clnt->cl_swapper) == 0) { in rpc_clnt_swap_deactivate()
2521 xprt = xprt_get(rcu_dereference(clnt->cl_xprt)); in rpc_clnt_swap_deactivate()