ublk: remove some unneeded breakout functions
Some functions such as ublk_start_kernel, ublk_stop_kernel and _ublk_start_disk were only calling ublk_ctrl_cmd. Just call ublk_ctrl_cmd directly and avoid the extra function indirections. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: Ic7d211b9b730af816f7747e031bdaef865ece433 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16453 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: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
parent
4fd4f6367f
commit
5b81c4bb9f
@ -443,45 +443,22 @@ ublk_thread_exit(void *args)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
ublk_start_kernel(void *arg)
|
|
||||||
{
|
|
||||||
struct spdk_ublk_dev *ublk = arg;
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
assert(ublk->dev_info.ublksrv_pid == getpid());
|
|
||||||
rc = ublk_ctrl_cmd(ublk, UBLK_CMD_START_DEV);
|
|
||||||
if (rc < 0) {
|
|
||||||
SPDK_ERRLOG("start dev %d failed, rc %s\n", ublk->ublk_id,
|
|
||||||
spdk_strerror(-rc));
|
|
||||||
}
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
ublk_stop_kernel(struct spdk_ublk_dev *ublk)
|
|
||||||
{
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
rc = ublk_ctrl_cmd(ublk, UBLK_CMD_STOP_DEV);
|
|
||||||
if (rc < 0) {
|
|
||||||
SPDK_ERRLOG("stop dev %d failed\n", ublk->ublk_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ublk_close_dev(struct spdk_ublk_dev *ublk)
|
ublk_close_dev(struct spdk_ublk_dev *ublk)
|
||||||
{
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
/* set is_closing */
|
/* set is_closing */
|
||||||
if (ublk->is_closing) {
|
if (ublk->is_closing) {
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
ublk->is_closing = true;
|
ublk->is_closing = true;
|
||||||
|
|
||||||
return ublk_stop_kernel(ublk);
|
rc = ublk_ctrl_cmd(ublk, UBLK_CMD_STOP_DEV);
|
||||||
|
if (rc < 0) {
|
||||||
|
SPDK_ERRLOG("stop dev %d failed\n", ublk->ublk_id);
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1166,19 +1143,6 @@ ublk_dev_queue_io_init(struct ublk_queue *q)
|
|||||||
assert(rc == (int)q->q_depth);
|
assert(rc == (int)q->q_depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
_ublk_start_disk(struct spdk_ublk_dev *ublk)
|
|
||||||
{
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
rc = ublk_ctrl_cmd(ublk, UBLK_CMD_ADD_DEV);
|
|
||||||
if (rc < 0) {
|
|
||||||
SPDK_ERRLOG("UBLK can't add dev %d, rc %s\n", ublk->ublk_id, spdk_strerror(-rc));
|
|
||||||
}
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ublk_set_params(struct spdk_ublk_dev *ublk)
|
ublk_set_params(struct spdk_ublk_dev *ublk)
|
||||||
{
|
{
|
||||||
@ -1373,8 +1337,9 @@ ublk_start_disk(const char *bdev_name, uint32_t ublk_id,
|
|||||||
|
|
||||||
SPDK_INFOLOG(ublk, "Enabling kernel access to bdev %s via ublk %d\n",
|
SPDK_INFOLOG(ublk, "Enabling kernel access to bdev %s via ublk %d\n",
|
||||||
bdev_name, ublk_id);
|
bdev_name, ublk_id);
|
||||||
rc = _ublk_start_disk(ublk);
|
rc = ublk_ctrl_cmd(ublk, UBLK_CMD_ADD_DEV);
|
||||||
if (rc != 0) {
|
if (rc < 0) {
|
||||||
|
SPDK_ERRLOG("UBLK can't add dev %d, rc %s\n", ublk->ublk_id, spdk_strerror(-rc));
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1411,7 +1376,10 @@ ublk_finish_start(struct spdk_ublk_dev *ublk)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ublk_start_kernel(ublk) != 0) {
|
rc = ublk_ctrl_cmd(ublk, UBLK_CMD_START_DEV);
|
||||||
|
if (rc < 0) {
|
||||||
|
SPDK_ERRLOG("start dev %d failed, rc %s\n", ublk->ublk_id,
|
||||||
|
spdk_strerror(-rc));
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user