Commit 7ffcdaa6 authored by Olga Kornievskaia's avatar Olga Kornievskaia Committed by Trond Myklebust

SUNRPC expose functions for offline remote xprt functionality

Re-arrange the code that make offline transport and delete transport
callable functions.
Signed-off-by: default avatarOlga Kornievskaia <kolga@netapp.com>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 29946fbc
...@@ -505,4 +505,7 @@ static inline int xprt_test_and_set_binding(struct rpc_xprt *xprt) ...@@ -505,4 +505,7 @@ static inline int xprt_test_and_set_binding(struct rpc_xprt *xprt)
return test_and_set_bit(XPRT_BINDING, &xprt->state); return test_and_set_bit(XPRT_BINDING, &xprt->state);
} }
void xprt_set_offline_locked(struct rpc_xprt *xprt, struct rpc_xprt_switch *xps);
void xprt_set_online_locked(struct rpc_xprt *xprt, struct rpc_xprt_switch *xps);
void xprt_delete_locked(struct rpc_xprt *xprt, struct rpc_xprt_switch *xps);
#endif /* _LINUX_SUNRPC_XPRT_H */ #endif /* _LINUX_SUNRPC_XPRT_H */
...@@ -314,33 +314,15 @@ static ssize_t rpc_sysfs_xprt_state_change(struct kobject *kobj, ...@@ -314,33 +314,15 @@ static ssize_t rpc_sysfs_xprt_state_change(struct kobject *kobj,
goto release_tasks; goto release_tasks;
} }
if (offline) { if (offline) {
if (!test_and_set_bit(XPRT_OFFLINE, &xprt->state)) { xprt_set_offline_locked(xprt, xps);
spin_lock(&xps->xps_lock);
xps->xps_nactive--;
spin_unlock(&xps->xps_lock);
}
} else if (online) { } else if (online) {
if (test_and_clear_bit(XPRT_OFFLINE, &xprt->state)) { xprt_set_online_locked(xprt, xps);
spin_lock(&xps->xps_lock);
xps->xps_nactive++;
spin_unlock(&xps->xps_lock);
}
} else if (remove) { } else if (remove) {
if (test_bit(XPRT_OFFLINE, &xprt->state)) { if (test_bit(XPRT_OFFLINE, &xprt->state))
if (!test_and_set_bit(XPRT_REMOVE, &xprt->state)) { xprt_delete_locked(xprt, xps);
xprt_force_disconnect(xprt); else
if (test_bit(XPRT_CONNECTED, &xprt->state)) {
if (!xprt->sending.qlen &&
!xprt->pending.qlen &&
!xprt->backlog.qlen &&
!atomic_long_read(&xprt->queuelen))
rpc_xprt_switch_remove_xprt(xps, xprt);
}
}
} else {
count = -EINVAL; count = -EINVAL;
} }
}
release_tasks: release_tasks:
xprt_release_write(xprt, NULL); xprt_release_write(xprt, NULL);
......
...@@ -2152,3 +2152,35 @@ void xprt_put(struct rpc_xprt *xprt) ...@@ -2152,3 +2152,35 @@ void xprt_put(struct rpc_xprt *xprt)
kref_put(&xprt->kref, xprt_destroy_kref); kref_put(&xprt->kref, xprt_destroy_kref);
} }
EXPORT_SYMBOL_GPL(xprt_put); EXPORT_SYMBOL_GPL(xprt_put);
void xprt_set_offline_locked(struct rpc_xprt *xprt, struct rpc_xprt_switch *xps)
{
if (!test_and_set_bit(XPRT_OFFLINE, &xprt->state)) {
spin_lock(&xps->xps_lock);
xps->xps_nactive--;
spin_unlock(&xps->xps_lock);
}
}
void xprt_set_online_locked(struct rpc_xprt *xprt, struct rpc_xprt_switch *xps)
{
if (test_and_clear_bit(XPRT_OFFLINE, &xprt->state)) {
spin_lock(&xps->xps_lock);
xps->xps_nactive++;
spin_unlock(&xps->xps_lock);
}
}
void xprt_delete_locked(struct rpc_xprt *xprt, struct rpc_xprt_switch *xps)
{
if (test_and_set_bit(XPRT_REMOVE, &xprt->state))
return;
xprt_force_disconnect(xprt);
if (!test_bit(XPRT_CONNECTED, &xprt->state))
return;
if (!xprt->sending.qlen && !xprt->pending.qlen &&
!xprt->backlog.qlen && !atomic_long_read(&xprt->queuelen))
rpc_xprt_switch_remove_xprt(xps, xprt);
}
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