Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

SUNRPC create a function that probes only offline transports

For only offline transports, attempt to check connectivity via
a NULL call and, if that succeeds, call a provided session trunking
detection function.

Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>

authored by

Olga Kornievskaia and committed by
Trond Myklebust
92cc04f6 273d6aed

+67
+2
include/linux/sunrpc/clnt.h
··· 235 235 struct rpc_xprt *, 236 236 void *); 237 237 void rpc_clnt_manage_trunked_xprts(struct rpc_clnt *); 238 + void rpc_clnt_probe_trunked_xprts(struct rpc_clnt *, 239 + struct rpc_add_xprt_test *); 238 240 239 241 const char *rpc_proc_name(const struct rpc_task *task); 240 242
+65
net/sunrpc/clnt.c
··· 807 807 return _rpc_clnt_xprt_iter_init(clnt, xpi, xprt_iter_init_listall); 808 808 } 809 809 810 + static 811 + int rpc_clnt_xprt_iter_offline_init(struct rpc_clnt *clnt, 812 + struct rpc_xprt_iter *xpi) 813 + { 814 + return _rpc_clnt_xprt_iter_init(clnt, xpi, xprt_iter_init_listoffline); 815 + } 816 + 810 817 /** 811 818 * rpc_clnt_iterate_for_each_xprt - Apply a function to all transports 812 819 * @clnt: pointer to client ··· 3024 3017 return ret; 3025 3018 } 3026 3019 EXPORT_SYMBOL_GPL(rpc_clnt_add_xprt); 3020 + 3021 + static int rpc_xprt_probe_trunked(struct rpc_clnt *clnt, 3022 + struct rpc_xprt *xprt, 3023 + struct rpc_add_xprt_test *data) 3024 + { 3025 + struct rpc_xprt_switch *xps; 3026 + struct rpc_xprt *main_xprt; 3027 + int status = 0; 3028 + 3029 + xprt_get(xprt); 3030 + 3031 + rcu_read_lock(); 3032 + main_xprt = xprt_get(rcu_dereference(clnt->cl_xprt)); 3033 + xps = xprt_switch_get(rcu_dereference(clnt->cl_xpi.xpi_xpswitch)); 3034 + status = rpc_cmp_addr_port((struct sockaddr *)&xprt->addr, 3035 + (struct sockaddr *)&main_xprt->addr); 3036 + rcu_read_unlock(); 3037 + xprt_put(main_xprt); 3038 + if (status || !test_bit(XPRT_OFFLINE, &xprt->state)) 3039 + goto out; 3040 + 3041 + status = rpc_clnt_add_xprt_helper(clnt, xprt, data); 3042 + out: 3043 + xprt_put(xprt); 3044 + xprt_switch_put(xps); 3045 + return status; 3046 + } 3047 + 3048 + /* rpc_clnt_probe_trunked_xprt -- probe offlined transport for session trunking 3049 + * @clnt rpc_clnt structure 3050 + * 3051 + * For each offlined transport found in the rpc_clnt structure call 3052 + * the function rpc_xprt_probe_trunked() which will determine if this 3053 + * transport still belongs to the trunking group. 3054 + */ 3055 + void rpc_clnt_probe_trunked_xprts(struct rpc_clnt *clnt, 3056 + struct rpc_add_xprt_test *data) 3057 + { 3058 + struct rpc_xprt_iter xpi; 3059 + int ret; 3060 + 3061 + ret = rpc_clnt_xprt_iter_offline_init(clnt, &xpi); 3062 + if (ret) 3063 + return; 3064 + for (;;) { 3065 + struct rpc_xprt *xprt = xprt_iter_get_next(&xpi); 3066 + 3067 + if (!xprt) 3068 + break; 3069 + ret = rpc_xprt_probe_trunked(clnt, xprt, data); 3070 + xprt_put(xprt); 3071 + if (ret < 0) 3072 + break; 3073 + xprt_iter_rewind(&xpi); 3074 + } 3075 + xprt_iter_destroy(&xpi); 3076 + } 3077 + EXPORT_SYMBOL_GPL(rpc_clnt_probe_trunked_xprts); 3027 3078 3028 3079 static int rpc_xprt_offline(struct rpc_clnt *clnt, 3029 3080 struct rpc_xprt *xprt,