bdev/qos: No operation for zero QoS setting on not enabled bdev

In below case that bdev is not QoS iops rate limiting enabled,
just report an error and return.

set_bdev_qos_limit_iops Malloc0 0

Change-Id: I1514dfd80f417a94d8c5147d7c4e891fc91a29fd
Signed-off-by: GangCao <gang.cao@intel.com>
Reviewed-on: https://review.gerrithub.io/409243
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
GangCao 2018-04-26 02:01:22 -04:00 committed by Daniel Verkamp
parent 5557a572f5
commit 409353a23e
2 changed files with 12 additions and 2 deletions

View File

@ -3013,10 +3013,19 @@ spdk_bdev_set_qos_limit_iops(struct spdk_bdev *bdev, uint64_t ios_per_sec,
cb_fn(cb_arg, -EAGAIN);
return;
}
thread = bdev->qos.thread;
/* QoS not enabled on this bdev */
if (!thread && ios_per_sec == 0) {
pthread_mutex_unlock(&bdev->mutex);
SPDK_ERRLOG("Requested ios_per_sec limit %" PRIu64 " is not a multiple of %u\n",
ios_per_sec, SPDK_BDEV_QOS_MIN_IOS_PER_SEC);
free(ctx);
cb_fn(cb_arg, -EINVAL);
return;
}
bdev->qos.enabled = true;
bdev->qos.mod_in_progress = true;
bdev->qos.rate_limit = ios_per_sec;
thread = bdev->qos.thread;
pthread_mutex_unlock(&bdev->mutex);
if (thread) {

View File

@ -214,7 +214,8 @@ if __name__ == "__main__":
p = subparsers.add_parser('set_bdev_qos_limit_iops', help='Set QoS IOPS limit on a blockdev')
p.add_argument('name', help='Blockdev name to set QoS. Example: Malloc0')
p.add_argument('ios_per_sec', help='IOs per second limit (>=10000). Example: 20000', type=int)
p.add_argument('ios_per_sec',
help='IOs per second limit (>=10000, example: 20000). 0 means unlimited.', type=int)
p.set_defaults(func=set_bdev_qos_limit_iops)
@call_cmd