• Home
  • Raw
  • Download

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()
345 static int rpc_alloc_clid(struct rpc_clnt *clnt) in rpc_alloc_clid() argument
352 clnt->cl_clid = clid; in rpc_alloc_clid()
356 static void rpc_free_clid(struct rpc_clnt *clnt) in rpc_free_clid() argument
358 ida_simple_remove(&rpc_clids, clnt->cl_clid); in rpc_free_clid()
367 struct rpc_clnt *clnt = NULL; in rpc_new_client() local
388 clnt = kzalloc(sizeof(*clnt), GFP_KERNEL); in rpc_new_client()
389 if (!clnt) in rpc_new_client()
391 clnt->cl_parent = parent ? : clnt; in rpc_new_client()
393 err = rpc_alloc_clid(clnt); in rpc_new_client()
397 clnt->cl_procinfo = version->procs; in rpc_new_client()
398 clnt->cl_maxproc = version->nrprocs; in rpc_new_client()
399 clnt->cl_prog = args->prognumber ? : program->number; in rpc_new_client()
400 clnt->cl_vers = version->number; in rpc_new_client()
401 clnt->cl_stats = program->stats; in rpc_new_client()
402 clnt->cl_metrics = rpc_alloc_iostats(clnt); in rpc_new_client()
403 rpc_init_pipe_dir_head(&clnt->cl_pipedir_objects); in rpc_new_client()
405 if (clnt->cl_metrics == NULL) in rpc_new_client()
407 clnt->cl_program = program; in rpc_new_client()
408 INIT_LIST_HEAD(&clnt->cl_tasks); in rpc_new_client()
409 spin_lock_init(&clnt->cl_lock); in rpc_new_client()
413 memcpy(&clnt->cl_timeout_default, args->timeout, in rpc_new_client()
414 sizeof(clnt->cl_timeout_default)); in rpc_new_client()
415 timeout = &clnt->cl_timeout_default; in rpc_new_client()
418 rpc_clnt_set_transport(clnt, xprt, timeout); in rpc_new_client()
420 clnt->cl_rtt = &clnt->cl_rtt_default; in rpc_new_client()
421 rpc_init_rtt(&clnt->cl_rtt_default, clnt->cl_timeout->to_initval); in rpc_new_client()
423 atomic_set(&clnt->cl_count, 1); in rpc_new_client()
428 rpc_clnt_set_nodename(clnt, nodename); in rpc_new_client()
430 err = rpc_client_register(clnt, args->authflavor, args->client_name); in rpc_new_client()
435 return clnt; in rpc_new_client()
438 rpc_free_iostats(clnt->cl_metrics); in rpc_new_client()
440 rpc_free_clid(clnt); in rpc_new_client()
442 kfree(clnt); in rpc_new_client()
453 struct rpc_clnt *clnt = NULL; in rpc_create_xprt() local
455 clnt = rpc_new_client(args, xprt, NULL); in rpc_create_xprt()
456 if (IS_ERR(clnt)) in rpc_create_xprt()
457 return clnt; in rpc_create_xprt()
460 int err = rpc_ping(clnt); in rpc_create_xprt()
462 rpc_shutdown_client(clnt); in rpc_create_xprt()
467 clnt->cl_softrtry = 1; in rpc_create_xprt()
469 clnt->cl_softrtry = 0; in rpc_create_xprt()
472 clnt->cl_autobind = 1; in rpc_create_xprt()
474 clnt->cl_noretranstimeo = 1; in rpc_create_xprt()
476 clnt->cl_discrtry = 1; in rpc_create_xprt()
478 clnt->cl_chatty = 1; in rpc_create_xprt()
480 return clnt; in rpc_create_xprt()
578 struct rpc_clnt *clnt) in __rpc_clone_client() argument
586 xprt = xprt_get(rcu_dereference(clnt->cl_xprt)); in __rpc_clone_client()
591 args->nodename = clnt->cl_nodename; in __rpc_clone_client()
593 new = rpc_new_client(args, xprt, clnt); in __rpc_clone_client()
601 new->cl_softrtry = clnt->cl_softrtry; in __rpc_clone_client()
602 new->cl_noretranstimeo = clnt->cl_noretranstimeo; in __rpc_clone_client()
603 new->cl_discrtry = clnt->cl_discrtry; in __rpc_clone_client()
604 new->cl_chatty = clnt->cl_chatty; in __rpc_clone_client()
619 struct rpc_clnt *rpc_clone_client(struct rpc_clnt *clnt) in rpc_clone_client() argument
622 .program = clnt->cl_program, in rpc_clone_client()
623 .prognumber = clnt->cl_prog, in rpc_clone_client()
624 .version = clnt->cl_vers, in rpc_clone_client()
625 .authflavor = clnt->cl_auth->au_flavor, in rpc_clone_client()
627 return __rpc_clone_client(&args, clnt); in rpc_clone_client()
640 rpc_clone_client_set_auth(struct rpc_clnt *clnt, rpc_authflavor_t flavor) in rpc_clone_client_set_auth() argument
643 .program = clnt->cl_program, in rpc_clone_client_set_auth()
644 .prognumber = clnt->cl_prog, in rpc_clone_client_set_auth()
645 .version = clnt->cl_vers, in rpc_clone_client_set_auth()
648 return __rpc_clone_client(&args, clnt); in rpc_clone_client_set_auth()
667 int rpc_switch_client_transport(struct rpc_clnt *clnt, in rpc_switch_client_transport() argument
680 clnt); in rpc_switch_client_transport()
684 pseudoflavor = clnt->cl_auth->au_flavor; in rpc_switch_client_transport()
686 old_timeo = clnt->cl_timeout; in rpc_switch_client_transport()
687 old = rpc_clnt_set_transport(clnt, xprt, timeout); in rpc_switch_client_transport()
689 rpc_unregister_client(clnt); in rpc_switch_client_transport()
690 __rpc_clnt_remove_pipedir(clnt); in rpc_switch_client_transport()
691 rpc_clnt_debugfs_unregister(clnt); in rpc_switch_client_transport()
698 parent = clnt->cl_parent; in rpc_switch_client_transport()
699 clnt->cl_parent = clnt; in rpc_switch_client_transport()
706 err = rpc_client_register(clnt, pseudoflavor, NULL); in rpc_switch_client_transport()
711 if (parent != clnt) in rpc_switch_client_transport()
714 dprintk("RPC: replaced xprt for clnt %p\n", clnt); in rpc_switch_client_transport()
718 rpc_clnt_set_transport(clnt, old, old_timeo); in rpc_switch_client_transport()
719 clnt->cl_parent = parent; in rpc_switch_client_transport()
720 rpc_client_register(clnt, pseudoflavor, NULL); in rpc_switch_client_transport()
722 dprintk("RPC: failed to switch xprt for clnt %p\n", clnt); in rpc_switch_client_transport()
731 void rpc_killall_tasks(struct rpc_clnt *clnt) in rpc_killall_tasks() argument
736 if (list_empty(&clnt->cl_tasks)) in rpc_killall_tasks()
738 dprintk("RPC: killing all tasks for client %p\n", clnt); in rpc_killall_tasks()
742 spin_lock(&clnt->cl_lock); in rpc_killall_tasks()
743 list_for_each_entry(rovr, &clnt->cl_tasks, tk_task) { in rpc_killall_tasks()
754 spin_unlock(&clnt->cl_lock); in rpc_killall_tasks()
762 void rpc_shutdown_client(struct rpc_clnt *clnt) in rpc_shutdown_client() argument
767 clnt->cl_program->name, in rpc_shutdown_client()
768 rcu_dereference(clnt->cl_xprt)->servername); in rpc_shutdown_client()
770 while (!list_empty(&clnt->cl_tasks)) { in rpc_shutdown_client()
771 rpc_killall_tasks(clnt); in rpc_shutdown_client()
773 list_empty(&clnt->cl_tasks), 1*HZ); in rpc_shutdown_client()
776 rpc_release_client(clnt); in rpc_shutdown_client()
784 rpc_free_client(struct rpc_clnt *clnt) in rpc_free_client() argument
789 clnt->cl_program->name, in rpc_free_client()
790 rcu_dereference(clnt->cl_xprt)->servername); in rpc_free_client()
791 if (clnt->cl_parent != clnt) in rpc_free_client()
792 parent = clnt->cl_parent; in rpc_free_client()
793 rpc_clnt_debugfs_unregister(clnt); in rpc_free_client()
794 rpc_clnt_remove_pipedir(clnt); in rpc_free_client()
795 rpc_unregister_client(clnt); in rpc_free_client()
796 rpc_free_iostats(clnt->cl_metrics); in rpc_free_client()
797 clnt->cl_metrics = NULL; in rpc_free_client()
798 xprt_put(rcu_dereference_raw(clnt->cl_xprt)); in rpc_free_client()
800 rpc_free_clid(clnt); in rpc_free_client()
801 kfree(clnt); in rpc_free_client()
809 rpc_free_auth(struct rpc_clnt *clnt) in rpc_free_auth() argument
811 if (clnt->cl_auth == NULL) in rpc_free_auth()
812 return rpc_free_client(clnt); in rpc_free_auth()
819 atomic_inc(&clnt->cl_count); in rpc_free_auth()
820 rpcauth_release(clnt->cl_auth); in rpc_free_auth()
821 clnt->cl_auth = NULL; in rpc_free_auth()
822 if (atomic_dec_and_test(&clnt->cl_count)) in rpc_free_auth()
823 return rpc_free_client(clnt); in rpc_free_auth()
831 rpc_release_client(struct rpc_clnt *clnt) in rpc_release_client() argument
833 dprintk("RPC: rpc_release_client(%p)\n", clnt); in rpc_release_client()
836 if (list_empty(&clnt->cl_tasks)) in rpc_release_client()
838 if (!atomic_dec_and_test(&clnt->cl_count)) in rpc_release_client()
840 clnt = rpc_free_auth(clnt); in rpc_release_client()
841 } while (clnt != NULL); in rpc_release_client()
865 struct rpc_clnt *clnt; in rpc_bind_new_program() local
868 clnt = __rpc_clone_client(&args, old); in rpc_bind_new_program()
869 if (IS_ERR(clnt)) in rpc_bind_new_program()
871 err = rpc_ping(clnt); in rpc_bind_new_program()
873 rpc_shutdown_client(clnt); in rpc_bind_new_program()
874 clnt = ERR_PTR(err); in rpc_bind_new_program()
877 return clnt; in rpc_bind_new_program()
883 struct rpc_clnt *clnt = task->tk_client; in rpc_task_release_client() local
885 if (clnt != NULL) { in rpc_task_release_client()
887 spin_lock(&clnt->cl_lock); in rpc_task_release_client()
889 spin_unlock(&clnt->cl_lock); in rpc_task_release_client()
892 rpc_release_client(clnt); in rpc_task_release_client()
897 void rpc_task_set_client(struct rpc_task *task, struct rpc_clnt *clnt) in rpc_task_set_client() argument
899 if (clnt != NULL) { in rpc_task_set_client()
901 task->tk_client = clnt; in rpc_task_set_client()
902 atomic_inc(&clnt->cl_count); in rpc_task_set_client()
903 if (clnt->cl_softrtry) in rpc_task_set_client()
905 if (clnt->cl_noretranstimeo) in rpc_task_set_client()
907 if (atomic_read(&clnt->cl_swapper)) in rpc_task_set_client()
910 spin_lock(&clnt->cl_lock); in rpc_task_set_client()
911 list_add_tail(&task->tk_task, &clnt->cl_tasks); in rpc_task_set_client()
912 spin_unlock(&clnt->cl_lock); in rpc_task_set_client()
916 void rpc_task_reset_client(struct rpc_task *task, struct rpc_clnt *clnt) in rpc_task_reset_client() argument
919 rpc_task_set_client(task, clnt); in rpc_task_reset_client()
979 int rpc_call_sync(struct rpc_clnt *clnt, const struct rpc_message *msg, int flags) in rpc_call_sync() argument
983 .rpc_client = clnt, in rpc_call_sync()
1015 rpc_call_async(struct rpc_clnt *clnt, const struct rpc_message *msg, int flags, in rpc_call_async() argument
1020 .rpc_client = clnt, in rpc_call_async()
1094 size_t rpc_peeraddr(struct rpc_clnt *clnt, struct sockaddr *buf, size_t bufsize) in rpc_peeraddr() argument
1100 xprt = rcu_dereference(clnt->cl_xprt); in rpc_peeraddr()
1121 const char *rpc_peeraddr2str(struct rpc_clnt *clnt, in rpc_peeraddr2str() argument
1126 xprt = rcu_dereference(clnt->cl_xprt); in rpc_peeraddr2str()
1258 int rpc_localaddr(struct rpc_clnt *clnt, struct sockaddr *buf, size_t buflen) in rpc_localaddr() argument
1268 xprt = rcu_dereference(clnt->cl_xprt); in rpc_localaddr()
1285 rpc_setbufsize(struct rpc_clnt *clnt, unsigned int sndsize, unsigned int rcvsize) in rpc_setbufsize() argument
1290 xprt = rcu_dereference(clnt->cl_xprt); in rpc_setbufsize()
1302 int rpc_protocol(struct rpc_clnt *clnt) in rpc_protocol() argument
1307 protocol = rcu_dereference(clnt->cl_xprt)->prot; in rpc_protocol()
1318 struct net *rpc_net_ns(struct rpc_clnt *clnt) in rpc_net_ns() argument
1323 ret = rcu_dereference(clnt->cl_xprt)->xprt_net; in rpc_net_ns()
1338 size_t rpc_max_payload(struct rpc_clnt *clnt) in rpc_max_payload() argument
1343 ret = rcu_dereference(clnt->cl_xprt)->max_payload; in rpc_max_payload()
1353 unsigned long rpc_get_timeout(struct rpc_clnt *clnt) in rpc_get_timeout() argument
1358 ret = rcu_dereference(clnt->cl_xprt)->timeout->to_initval; in rpc_get_timeout()
1369 void rpc_force_rebind(struct rpc_clnt *clnt) in rpc_force_rebind() argument
1371 if (clnt->cl_autobind) { in rpc_force_rebind()
1373 xprt_clear_bound(rcu_dereference(clnt->cl_xprt)); in rpc_force_rebind()
1436 struct rpc_clnt *clnt = task->tk_client; in call_start() local
1439 clnt->cl_program->name, clnt->cl_vers, in call_start()
1445 clnt->cl_stats->rpccnt++; in call_start()
1820 struct rpc_clnt *clnt = task->tk_client; in call_connect_status() local
1832 if (clnt->cl_autobind) { in call_connect_status()
1833 rpc_force_rebind(clnt); in call_connect_status()
1854 clnt->cl_stats->netreconn++; in call_connect_status()
2038 struct rpc_clnt *clnt = task->tk_client; in call_status() local
2079 rpc_force_rebind(clnt); in call_status()
2096 if (clnt->cl_chatty) in call_status()
2098 clnt->cl_program->name, -status); in call_status()
2111 struct rpc_clnt *clnt = task->tk_client; in call_timeout() local
2126 if (clnt->cl_chatty) { in call_timeout()
2129 clnt->cl_program->name, in call_timeout()
2130 rcu_dereference(clnt->cl_xprt)->servername); in call_timeout()
2142 if (clnt->cl_chatty) { in call_timeout()
2145 clnt->cl_program->name, in call_timeout()
2146 rcu_dereference(clnt->cl_xprt)->servername); in call_timeout()
2150 rpc_force_rebind(clnt); in call_timeout()
2168 struct rpc_clnt *clnt = task->tk_client; in call_decode() local
2176 if (clnt->cl_chatty) { in call_decode()
2179 clnt->cl_program->name, in call_decode()
2180 rcu_dereference(clnt->cl_xprt)->servername); in call_decode()
2203 clnt->cl_program->name, task->tk_status); in call_decode()
2238 struct rpc_clnt *clnt = task->tk_client; in rpc_encode_header() local
2248 *p++ = htonl(clnt->cl_prog); /* program number */ in rpc_encode_header()
2249 *p++ = htonl(clnt->cl_vers); /* program version */ in rpc_encode_header()
2259 struct rpc_clnt *clnt = task->tk_client; in rpc_verify_header() local
2338 rcu_dereference(clnt->cl_xprt)->servername); in rpc_verify_header()
2366 (unsigned int)clnt->cl_prog, in rpc_verify_header()
2367 rcu_dereference(clnt->cl_xprt)->servername); in rpc_verify_header()
2373 (unsigned int)clnt->cl_prog, in rpc_verify_header()
2374 (unsigned int)clnt->cl_vers, in rpc_verify_header()
2375 rcu_dereference(clnt->cl_xprt)->servername); in rpc_verify_header()
2383 clnt->cl_prog, clnt->cl_vers, in rpc_verify_header()
2384 rcu_dereference(clnt->cl_xprt)->servername); in rpc_verify_header()
2398 clnt->cl_stats->rpcgarbage++; in rpc_verify_header()
2432 static int rpc_ping(struct rpc_clnt *clnt) in rpc_ping() argument
2439 err = rpc_call_sync(clnt, &msg, RPC_TASK_SOFT | RPC_TASK_SOFTCONN); in rpc_ping()
2444 struct rpc_task *rpc_call_null(struct rpc_clnt *clnt, struct rpc_cred *cred, int flags) in rpc_call_null() argument
2451 .rpc_client = clnt, in rpc_call_null()
2467 static void rpc_show_task(const struct rpc_clnt *clnt, in rpc_show_task() argument
2477 clnt, task->tk_rqstp, task->tk_timeout, task->tk_ops, in rpc_show_task()
2478 clnt->cl_program->name, clnt->cl_vers, rpc_proc_name(task), in rpc_show_task()
2484 struct rpc_clnt *clnt; in rpc_show_tasks() local
2490 list_for_each_entry(clnt, &sn->all_clients, cl_clients) { in rpc_show_tasks()
2491 spin_lock(&clnt->cl_lock); in rpc_show_tasks()
2492 list_for_each_entry(task, &clnt->cl_tasks, tk_task) { in rpc_show_tasks()
2497 rpc_show_task(clnt, task); in rpc_show_tasks()
2499 spin_unlock(&clnt->cl_lock); in rpc_show_tasks()
2507 rpc_clnt_swap_activate(struct rpc_clnt *clnt) in rpc_clnt_swap_activate() argument
2512 if (atomic_inc_return(&clnt->cl_swapper) == 1) { in rpc_clnt_swap_activate()
2515 xprt = xprt_get(rcu_dereference(clnt->cl_xprt)); in rpc_clnt_swap_activate()
2535 rpc_clnt_swap_deactivate(struct rpc_clnt *clnt) in rpc_clnt_swap_deactivate() argument
2539 if (atomic_dec_if_positive(&clnt->cl_swapper) == 0) { in rpc_clnt_swap_deactivate()
2542 xprt = xprt_get(rcu_dereference(clnt->cl_xprt)); in rpc_clnt_swap_deactivate()