Commit 497e6464 authored by Olga Kornievskaia's avatar Olga Kornievskaia Committed by Trond Myklebust

SUNRPC create an rpc function that allows xprt removal from rpc_clnt

Expose a function that allows a removal of xprt from the rpc_clnt.

When called from NFS that's running a trunked transport then don't
decrement the active transport counter.
Signed-off-by: default avatarOlga Kornievskaia <kolga@netapp.com>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 9368fd6c
...@@ -240,6 +240,7 @@ const char *rpc_proc_name(const struct rpc_task *task); ...@@ -240,6 +240,7 @@ const char *rpc_proc_name(const struct rpc_task *task);
void rpc_clnt_xprt_switch_put(struct rpc_clnt *); void rpc_clnt_xprt_switch_put(struct rpc_clnt *);
void rpc_clnt_xprt_switch_add_xprt(struct rpc_clnt *, struct rpc_xprt *); void rpc_clnt_xprt_switch_add_xprt(struct rpc_clnt *, struct rpc_xprt *);
void rpc_clnt_xprt_switch_remove_xprt(struct rpc_clnt *, struct rpc_xprt *);
bool rpc_clnt_xprt_switch_has_addr(struct rpc_clnt *clnt, bool rpc_clnt_xprt_switch_has_addr(struct rpc_clnt *clnt,
const struct sockaddr *sap); const struct sockaddr *sap);
void rpc_clnt_xprt_set_online(struct rpc_clnt *clnt, struct rpc_xprt *xprt); void rpc_clnt_xprt_set_online(struct rpc_clnt *clnt, struct rpc_xprt *xprt);
......
...@@ -55,7 +55,7 @@ extern void rpc_xprt_switch_set_roundrobin(struct rpc_xprt_switch *xps); ...@@ -55,7 +55,7 @@ extern void rpc_xprt_switch_set_roundrobin(struct rpc_xprt_switch *xps);
extern void rpc_xprt_switch_add_xprt(struct rpc_xprt_switch *xps, extern void rpc_xprt_switch_add_xprt(struct rpc_xprt_switch *xps,
struct rpc_xprt *xprt); struct rpc_xprt *xprt);
extern void rpc_xprt_switch_remove_xprt(struct rpc_xprt_switch *xps, extern void rpc_xprt_switch_remove_xprt(struct rpc_xprt_switch *xps,
struct rpc_xprt *xprt); struct rpc_xprt *xprt, bool offline);
extern void xprt_iter_init(struct rpc_xprt_iter *xpi, extern void xprt_iter_init(struct rpc_xprt_iter *xpi,
struct rpc_xprt_switch *xps); struct rpc_xprt_switch *xps);
......
...@@ -2144,7 +2144,8 @@ call_connect_status(struct rpc_task *task) ...@@ -2144,7 +2144,8 @@ call_connect_status(struct rpc_task *task)
xprt_release(task); xprt_release(task);
value = atomic_long_dec_return(&xprt->queuelen); value = atomic_long_dec_return(&xprt->queuelen);
if (value == 0) if (value == 0)
rpc_xprt_switch_remove_xprt(xps, saved); rpc_xprt_switch_remove_xprt(xps, saved,
true);
xprt_put(saved); xprt_put(saved);
task->tk_xprt = NULL; task->tk_xprt = NULL;
task->tk_action = call_start; task->tk_action = call_start;
...@@ -3118,6 +3119,19 @@ void rpc_clnt_xprt_switch_add_xprt(struct rpc_clnt *clnt, struct rpc_xprt *xprt) ...@@ -3118,6 +3119,19 @@ void rpc_clnt_xprt_switch_add_xprt(struct rpc_clnt *clnt, struct rpc_xprt *xprt)
} }
EXPORT_SYMBOL_GPL(rpc_clnt_xprt_switch_add_xprt); EXPORT_SYMBOL_GPL(rpc_clnt_xprt_switch_add_xprt);
void rpc_clnt_xprt_switch_remove_xprt(struct rpc_clnt *clnt, struct rpc_xprt *xprt)
{
struct rpc_xprt_switch *xps;
rcu_read_lock();
xps = rcu_dereference(clnt->cl_xpi.xpi_xpswitch);
rpc_xprt_switch_remove_xprt(rcu_dereference(clnt->cl_xpi.xpi_xpswitch),
xprt, 0);
xps->xps_nunique_destaddr_xprts--;
rcu_read_unlock();
}
EXPORT_SYMBOL_GPL(rpc_clnt_xprt_switch_remove_xprt);
bool rpc_clnt_xprt_switch_has_addr(struct rpc_clnt *clnt, bool rpc_clnt_xprt_switch_has_addr(struct rpc_clnt *clnt,
const struct sockaddr *sap) const struct sockaddr *sap)
{ {
......
...@@ -2182,5 +2182,5 @@ void xprt_delete_locked(struct rpc_xprt *xprt, struct rpc_xprt_switch *xps) ...@@ -2182,5 +2182,5 @@ void xprt_delete_locked(struct rpc_xprt *xprt, struct rpc_xprt_switch *xps)
if (!xprt->sending.qlen && !xprt->pending.qlen && if (!xprt->sending.qlen && !xprt->pending.qlen &&
!xprt->backlog.qlen && !atomic_long_read(&xprt->queuelen)) !xprt->backlog.qlen && !atomic_long_read(&xprt->queuelen))
rpc_xprt_switch_remove_xprt(xps, xprt); rpc_xprt_switch_remove_xprt(xps, xprt, true);
} }
...@@ -62,11 +62,11 @@ void rpc_xprt_switch_add_xprt(struct rpc_xprt_switch *xps, ...@@ -62,11 +62,11 @@ void rpc_xprt_switch_add_xprt(struct rpc_xprt_switch *xps,
} }
static void xprt_switch_remove_xprt_locked(struct rpc_xprt_switch *xps, static void xprt_switch_remove_xprt_locked(struct rpc_xprt_switch *xps,
struct rpc_xprt *xprt) struct rpc_xprt *xprt, bool offline)
{ {
if (unlikely(xprt == NULL)) if (unlikely(xprt == NULL))
return; return;
if (!test_bit(XPRT_OFFLINE, &xprt->state)) if (!test_bit(XPRT_OFFLINE, &xprt->state) && offline)
xps->xps_nactive--; xps->xps_nactive--;
xps->xps_nxprts--; xps->xps_nxprts--;
if (xps->xps_nxprts == 0) if (xps->xps_nxprts == 0)
...@@ -79,14 +79,15 @@ static void xprt_switch_remove_xprt_locked(struct rpc_xprt_switch *xps, ...@@ -79,14 +79,15 @@ static void xprt_switch_remove_xprt_locked(struct rpc_xprt_switch *xps,
* rpc_xprt_switch_remove_xprt - Removes an rpc_xprt from a rpc_xprt_switch * rpc_xprt_switch_remove_xprt - Removes an rpc_xprt from a rpc_xprt_switch
* @xps: pointer to struct rpc_xprt_switch * @xps: pointer to struct rpc_xprt_switch
* @xprt: pointer to struct rpc_xprt * @xprt: pointer to struct rpc_xprt
* @offline: indicates if the xprt that's being removed is in an offline state
* *
* Removes xprt from the list of struct rpc_xprt in xps. * Removes xprt from the list of struct rpc_xprt in xps.
*/ */
void rpc_xprt_switch_remove_xprt(struct rpc_xprt_switch *xps, void rpc_xprt_switch_remove_xprt(struct rpc_xprt_switch *xps,
struct rpc_xprt *xprt) struct rpc_xprt *xprt, bool offline)
{ {
spin_lock(&xps->xps_lock); spin_lock(&xps->xps_lock);
xprt_switch_remove_xprt_locked(xps, xprt); xprt_switch_remove_xprt_locked(xps, xprt, offline);
spin_unlock(&xps->xps_lock); spin_unlock(&xps->xps_lock);
xprt_put(xprt); xprt_put(xprt);
} }
...@@ -155,7 +156,7 @@ static void xprt_switch_free_entries(struct rpc_xprt_switch *xps) ...@@ -155,7 +156,7 @@ static void xprt_switch_free_entries(struct rpc_xprt_switch *xps)
xprt = list_first_entry(&xps->xps_xprt_list, xprt = list_first_entry(&xps->xps_xprt_list,
struct rpc_xprt, xprt_switch); struct rpc_xprt, xprt_switch);
xprt_switch_remove_xprt_locked(xps, xprt); xprt_switch_remove_xprt_locked(xps, xprt, true);
spin_unlock(&xps->xps_lock); spin_unlock(&xps->xps_lock);
xprt_put(xprt); xprt_put(xprt);
spin_lock(&xps->xps_lock); spin_lock(&xps->xps_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment