Bdev/QoS: add a specific bdev_start_qos function
Change-Id: I93f930faf88703e22e156f4fe0c22e162f030894 Signed-off-by: GangCao <gang.cao@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1030 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
70cc99bccf
commit
af561c1a4a
@ -5180,11 +5180,32 @@ bdev_dummy_event_cb(void *remove_ctx)
|
|||||||
SPDK_DEBUGLOG(SPDK_LOG_BDEV, "Bdev remove event received with no remove callback specified");
|
SPDK_DEBUGLOG(SPDK_LOG_BDEV, "Bdev remove event received with no remove callback specified");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
bdev_start_qos(struct spdk_bdev *bdev)
|
||||||
|
{
|
||||||
|
struct set_qos_limit_ctx *ctx;
|
||||||
|
|
||||||
|
/* Enable QoS */
|
||||||
|
if (bdev->internal.qos && bdev->internal.qos->thread == NULL) {
|
||||||
|
ctx = calloc(1, sizeof(*ctx));
|
||||||
|
if (ctx == NULL) {
|
||||||
|
SPDK_ERRLOG("Failed to allocate memory for QoS context\n");
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
ctx->bdev = bdev;
|
||||||
|
spdk_for_each_channel(__bdev_to_io_dev(bdev),
|
||||||
|
bdev_enable_qos_msg, ctx,
|
||||||
|
bdev_enable_qos_done);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
bdev_open(struct spdk_bdev *bdev, bool write, struct spdk_bdev_desc *desc)
|
bdev_open(struct spdk_bdev *bdev, bool write, struct spdk_bdev_desc *desc)
|
||||||
{
|
{
|
||||||
struct spdk_thread *thread;
|
struct spdk_thread *thread;
|
||||||
struct set_qos_limit_ctx *ctx;
|
int rc = 0;
|
||||||
|
|
||||||
thread = spdk_get_thread();
|
thread = spdk_get_thread();
|
||||||
if (!thread) {
|
if (!thread) {
|
||||||
@ -5212,18 +5233,11 @@ bdev_open(struct spdk_bdev *bdev, bool write, struct spdk_bdev_desc *desc)
|
|||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enable QoS */
|
rc = bdev_start_qos(bdev);
|
||||||
if (bdev->internal.qos && bdev->internal.qos->thread == NULL) {
|
if (rc != 0) {
|
||||||
ctx = calloc(1, sizeof(*ctx));
|
SPDK_ERRLOG("Failed to start QoS on bdev %s\n", bdev->name);
|
||||||
if (ctx == NULL) {
|
pthread_mutex_unlock(&bdev->internal.mutex);
|
||||||
SPDK_ERRLOG("Failed to allocate memory for QoS context\n");
|
return rc;
|
||||||
pthread_mutex_unlock(&bdev->internal.mutex);
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
ctx->bdev = bdev;
|
|
||||||
spdk_for_each_channel(__bdev_to_io_dev(bdev),
|
|
||||||
bdev_enable_qos_msg, ctx,
|
|
||||||
bdev_enable_qos_done);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TAILQ_INSERT_TAIL(&bdev->internal.open_descs, desc, link);
|
TAILQ_INSERT_TAIL(&bdev->internal.open_descs, desc, link);
|
||||||
|
Loading…
Reference in New Issue
Block a user