mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-26 14:17:26 -04:00
SUNRPC: Clean up scheduling of autoclose
Consolidate duplicated code in xprt_force_disconnect() and xprt_conditional_disconnect(). Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
This commit is contained in:
parent
c2dc3e5fad
commit
e26d997272
1 changed files with 16 additions and 12 deletions
|
@ -760,6 +760,20 @@ void xprt_disconnect_done(struct rpc_xprt *xprt)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(xprt_disconnect_done);
|
EXPORT_SYMBOL_GPL(xprt_disconnect_done);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xprt_schedule_autoclose_locked - Try to schedule an autoclose RPC call
|
||||||
|
* @xprt: transport to disconnect
|
||||||
|
*/
|
||||||
|
static void xprt_schedule_autoclose_locked(struct rpc_xprt *xprt)
|
||||||
|
{
|
||||||
|
set_bit(XPRT_CLOSE_WAIT, &xprt->state);
|
||||||
|
if (test_and_set_bit(XPRT_LOCKED, &xprt->state) == 0)
|
||||||
|
queue_work(xprtiod_workqueue, &xprt->task_cleanup);
|
||||||
|
else if (xprt->snd_task && !test_bit(XPRT_SND_IS_COOKIE, &xprt->state))
|
||||||
|
rpc_wake_up_queued_task_set_status(&xprt->pending,
|
||||||
|
xprt->snd_task, -ENOTCONN);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xprt_force_disconnect - force a transport to disconnect
|
* xprt_force_disconnect - force a transport to disconnect
|
||||||
* @xprt: transport to disconnect
|
* @xprt: transport to disconnect
|
||||||
|
@ -771,13 +785,7 @@ void xprt_force_disconnect(struct rpc_xprt *xprt)
|
||||||
|
|
||||||
/* Don't race with the test_bit() in xprt_clear_locked() */
|
/* Don't race with the test_bit() in xprt_clear_locked() */
|
||||||
spin_lock(&xprt->transport_lock);
|
spin_lock(&xprt->transport_lock);
|
||||||
set_bit(XPRT_CLOSE_WAIT, &xprt->state);
|
xprt_schedule_autoclose_locked(xprt);
|
||||||
/* Try to schedule an autoclose RPC call */
|
|
||||||
if (test_and_set_bit(XPRT_LOCKED, &xprt->state) == 0)
|
|
||||||
queue_work(xprtiod_workqueue, &xprt->task_cleanup);
|
|
||||||
else if (xprt->snd_task && !test_bit(XPRT_SND_IS_COOKIE, &xprt->state))
|
|
||||||
rpc_wake_up_queued_task_set_status(&xprt->pending,
|
|
||||||
xprt->snd_task, -ENOTCONN);
|
|
||||||
spin_unlock(&xprt->transport_lock);
|
spin_unlock(&xprt->transport_lock);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(xprt_force_disconnect);
|
EXPORT_SYMBOL_GPL(xprt_force_disconnect);
|
||||||
|
@ -817,11 +825,7 @@ void xprt_conditional_disconnect(struct rpc_xprt *xprt, unsigned int cookie)
|
||||||
goto out;
|
goto out;
|
||||||
if (test_bit(XPRT_CLOSING, &xprt->state))
|
if (test_bit(XPRT_CLOSING, &xprt->state))
|
||||||
goto out;
|
goto out;
|
||||||
set_bit(XPRT_CLOSE_WAIT, &xprt->state);
|
xprt_schedule_autoclose_locked(xprt);
|
||||||
/* Try to schedule an autoclose RPC call */
|
|
||||||
if (test_and_set_bit(XPRT_LOCKED, &xprt->state) == 0)
|
|
||||||
queue_work(xprtiod_workqueue, &xprt->task_cleanup);
|
|
||||||
xprt_wake_pending_tasks(xprt, -EAGAIN);
|
|
||||||
out:
|
out:
|
||||||
spin_unlock(&xprt->transport_lock);
|
spin_unlock(&xprt->transport_lock);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue