ublk: change where new dev's ublk file gets opened
Upcoming patches will submit ctrl cmds and wait for them to complete asynchronously. So we will want to first send the ADD_DEV and SET_PARAMS commands, wait for them to complete, and only then open the ublk device file. So to prepare for that sequencing, move the open() from _ublk_start_disk to ublk_start_disk. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: I9fdf19ce9b51bd552faa917e1e842f9ddfb111a1 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16402 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Xiaodong Liu <xiaodong.liu@intel.com> Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
f08743e9eb
commit
5f1b5f18ae
@ -1179,7 +1179,6 @@ static int
|
||||
_ublk_start_disk(struct spdk_ublk_dev *ublk)
|
||||
{
|
||||
int rc;
|
||||
char buf[64];
|
||||
|
||||
rc = ublk_ctrl_cmd(ublk, UBLK_CMD_ADD_DEV, &ublk->dev_info);
|
||||
if (rc < 0) {
|
||||
@ -1193,13 +1192,6 @@ _ublk_start_disk(struct spdk_ublk_dev *ublk)
|
||||
SPDK_ERRLOG("UBLK can't set params for dev %d, rc %s\n", ublk->ublk_id, spdk_strerror(-rc));
|
||||
goto err;
|
||||
}
|
||||
snprintf(buf, 64, "%s%d", UBLK_BLK_CDEV, ublk->ublk_id);
|
||||
ublk->cdev_fd = open(buf, O_RDWR);
|
||||
if (ublk->cdev_fd < 0) {
|
||||
rc = ublk->cdev_fd;
|
||||
SPDK_ERRLOG("can't open %s, rc %d\n", buf, rc);
|
||||
goto err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@ -1333,6 +1325,7 @@ ublk_start_disk(const char *bdev_name, uint32_t ublk_id,
|
||||
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");
|
||||
@ -1395,6 +1388,14 @@ ublk_start_disk(const char *bdev_name, uint32_t ublk_id,
|
||||
goto err;
|
||||
}
|
||||
|
||||
snprintf(buf, 64, "%s%d", UBLK_BLK_CDEV, ublk->ublk_id);
|
||||
ublk->cdev_fd = open(buf, O_RDWR);
|
||||
if (ublk->cdev_fd < 0) {
|
||||
rc = ublk->cdev_fd;
|
||||
SPDK_ERRLOG("can't open %s, rc %d\n", buf, rc);
|
||||
goto err;
|
||||
}
|
||||
|
||||
for (q_id = 0; q_id < ublk->num_queues; q_id++) {
|
||||
rc = ublk_dev_queue_init(&ublk->queues[q_id]);
|
||||
if (rc) {
|
||||
|
Loading…
Reference in New Issue
Block a user