Commit c6b0b77f authored by Jim Harris's avatar Jim Harris
Browse files

ublk: combine ublk_ios_fini and ublk_free_dev



Next patch will be adding iobuf support, which will
require freeing buffers on the queue's thread, not
the app thread.

So combine these two functions into one (ublk_free_dev)
and have it do all of the queue work first before
anything else.  The reasons will be more obvious in the
next patch.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I749c500e3ea0e20fc71cb0286740584a083ede4f
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17878


Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarXiaodong Liu <xiaodong.liu@intel.com>
parent cbf4a03b
Loading
Loading
Loading
Loading
+14 −20
Original line number Diff line number Diff line
@@ -48,7 +48,6 @@ static void ublk_submit_bdev_io(struct ublk_queue *q, uint16_t tag);
static void ublk_dev_queue_fini(struct ublk_queue *q);
static int ublk_poll(void *arg);
static int ublk_ctrl_cmd(struct spdk_ublk_dev *ublk, uint32_t cmd_op);
static void ublk_ios_fini(struct spdk_ublk_dev *ublk);

typedef void (*ublk_next_state_fn)(struct spdk_ublk_dev *ublk);
static void ublk_set_params(struct spdk_ublk_dev *ublk);
@@ -690,24 +689,6 @@ ublk_delete_dev(void *arg)
	}
}

static void
ublk_free_dev(struct spdk_ublk_dev *ublk)
{
	if (ublk->bdev_desc) {
		spdk_bdev_close(ublk->bdev_desc);
		ublk->bdev_desc = NULL;
	}

	ublk_ios_fini(ublk);
	ublk_dev_list_unregister(ublk);

	if (ublk->del_cb) {
		ublk->del_cb(ublk->cb_arg);
	}
	SPDK_NOTICELOG("ublk dev %d stopped\n", ublk->ublk_id);
	free(ublk);
}

static int
_ublk_close_dev_retry(void *arg)
{
@@ -1304,7 +1285,7 @@ ublk_info_param_init(struct spdk_ublk_dev *ublk)
}

static void
ublk_ios_fini(struct spdk_ublk_dev *ublk)
ublk_free_dev(struct spdk_ublk_dev *ublk)
{
	struct ublk_queue *q;
	uint32_t i, q_idx;
@@ -1323,6 +1304,19 @@ ublk_ios_fini(struct spdk_ublk_dev *ublk)
		free(q->ios);
		q->ios = NULL;
	}

	if (ublk->bdev_desc) {
		spdk_bdev_close(ublk->bdev_desc);
		ublk->bdev_desc = NULL;
	}

	ublk_dev_list_unregister(ublk);

	if (ublk->del_cb) {
		ublk->del_cb(ublk->cb_arg);
	}
	SPDK_NOTICELOG("ublk dev %d stopped\n", ublk->ublk_id);
	free(ublk);
}

static int