lib/nbd: refine _nbd_fini process
_nbd_fini will make all NBDs into closing state. remove _nbd_async, beasue it will call asynchronous error. Signed-off-by: MengjinWu <mengjin.wu@intel.com> Change-Id: Ifb873b7f079b735983bdf20c2df652be0a21919f Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8035 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Ziye Yang <ziye.yang@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
628c230de4
commit
ab5cc9dd6e
@ -147,38 +147,24 @@ spdk_nbd_init(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_nbd_stop_async(void *arg)
|
||||
{
|
||||
struct spdk_nbd_disk *nbd = arg;
|
||||
int rc;
|
||||
|
||||
rc = spdk_nbd_stop(nbd);
|
||||
if (rc) {
|
||||
/* spdk_nbd_stop failed because some IO are still executing. Send a message
|
||||
* to this thread to try again later. */
|
||||
spdk_thread_send_msg(spdk_get_thread(),
|
||||
_nbd_stop_async, nbd);
|
||||
} else {
|
||||
_nbd_fini(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_nbd_fini(void *arg1)
|
||||
{
|
||||
struct spdk_nbd_disk *nbd_first;
|
||||
struct spdk_nbd_disk *nbd, *nbd_tmp;
|
||||
|
||||
nbd_first = TAILQ_FIRST(&g_spdk_nbd.disk_head);
|
||||
if (nbd_first) {
|
||||
/* Stop running spdk_nbd_disk */
|
||||
spdk_thread_send_msg(spdk_io_channel_get_thread(nbd_first->ch),
|
||||
_nbd_stop_async, nbd_first);
|
||||
} else {
|
||||
/* We can directly call final function here, because
|
||||
spdk_subsystem_fini_next handles the case: current thread does not equal
|
||||
to g_final_thread */
|
||||
/* Change all nbds into closing state */
|
||||
TAILQ_FOREACH_SAFE(nbd, &g_spdk_nbd.disk_head, tailq, nbd_tmp) {
|
||||
if (nbd->state != NBD_DISK_STATE_HARDDISC) {
|
||||
spdk_nbd_stop(nbd);
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if all nbds closed */
|
||||
if (!TAILQ_FIRST(&g_spdk_nbd.disk_head)) {
|
||||
g_fini_cb_fn(g_fini_cb_arg);
|
||||
} else {
|
||||
spdk_thread_send_msg(spdk_get_thread(),
|
||||
_nbd_fini, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user