Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions tools/testing/selftests/ublk/kublk.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ static int ublk_thread_is_idle(struct ublk_thread *t)

static int ublk_thread_is_done(struct ublk_thread *t)
{
return (t->state & UBLKS_T_STOPPING) && ublk_thread_is_idle(t);
return (t->state & UBLKS_T_STOPPING) && ublk_thread_is_idle(t) && !t->cmd_inflight;
}

static inline void ublksrv_handle_tgt_cqe(struct ublk_thread *t,
Expand Down Expand Up @@ -1054,15 +1054,17 @@ static int ublk_start_daemon(const struct dev_ctx *ctx, struct ublk_dev *dev)
}
if (ret < 0) {
ublk_err("%s: ublk_ctrl_start_dev failed: %d\n", __func__, ret);
goto fail;
/* stop device so that inflight uring_cmd can be cancelled */
ublk_ctrl_stop_dev(dev);
goto fail_start;
}

ublk_ctrl_get_info(dev);
if (ctx->fg)
ublk_ctrl_dump(dev);
else
ublk_send_dev_event(ctx, dev, dev->dev_info.dev_id);

fail_start:
/* wait until we are terminated */
for (i = 0; i < dev->nthreads; i++)
pthread_join(tinfo[i].thread, &thread_ret);
Expand Down Expand Up @@ -1272,7 +1274,7 @@ static int __cmd_dev_add(const struct dev_ctx *ctx)
}

ret = ublk_start_daemon(ctx, dev);
ublk_dbg(UBLK_DBG_DEV, "%s: daemon exit %d\b", ret);
ublk_dbg(UBLK_DBG_DEV, "%s: daemon exit %d\n", __func__, ret);
if (ret < 0)
ublk_ctrl_del_dev(dev);

Expand Down Expand Up @@ -1618,6 +1620,7 @@ int main(int argc, char *argv[])
int option_idx, opt;
const char *cmd = argv[1];
struct dev_ctx ctx = {
._evtfd = -1,
.queue_depth = 128,
.nr_hw_queues = 2,
.dev_id = -1,
Expand Down