Commit 3b03420f authored by Jim Harris's avatar Jim Harris
Browse files

ublk: break ublk_start_disk into two parts



For now, we will still execute the two parts
consecutively and synchronously.  Follow-up patches
will do the second part asynchronously, after the
ublk cmds associated with the first part have
completed.

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

 (master)

(cherry picked from commit 69d4ec07)
Change-Id: I814d885a8a113c3367207d11ae09dd536eb63460
Signed-off-by: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16469


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent ceef759f
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ struct ublk_thread_ctx;
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 finish_start(struct spdk_ublk_dev *ublk);

struct ublk_io {
	void			*payload;
@@ -1321,11 +1322,8 @@ ublk_start_disk(const char *bdev_name, uint32_t ublk_id,
		uint32_t num_queues, uint32_t queue_depth)
{
	int			rc;
	uint32_t		q_id, i;
	struct spdk_bdev	*bdev;
	struct spdk_ublk_dev	*ublk = NULL;
	struct spdk_thread	*ublk_thread;
	char			buf[64];

	if (g_ublk_tgt.active == false) {
		SPDK_ERRLOG("NO ublk target exist\n");
@@ -1388,6 +1386,21 @@ ublk_start_disk(const char *bdev_name, uint32_t ublk_id,
		goto err;
	}

	return finish_start(ublk);

err:
	_ublk_try_close_dev(ublk);
	return rc;
}

static int
finish_start(struct spdk_ublk_dev *ublk)
{
	int			rc;
	uint32_t		q_id, i;
	struct spdk_thread	*ublk_thread;
	char			buf[64];

	snprintf(buf, 64, "%s%d", UBLK_BLK_CDEV, ublk->ublk_id);
	ublk->cdev_fd = open(buf, O_RDWR);
	if (ublk->cdev_fd < 0) {