bdev/qos: Factor out check for QoS limits into a helper function

Signed-off-by: Evgeniy Kochetov <evgeniik@nvidia.com>
Change-Id: I139f78bb6fc2ccfce871c1f6a81dd1e25c51a826
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13766
Community-CI: Mellanox Build Bot
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Evgeniy Kochetov 2022-07-21 11:01:51 +03:00 committed by Konrad Sztyber
parent c682c78992
commit f79af9ab19

View File

@ -2164,31 +2164,43 @@ bdev_io_do_submit(struct spdk_bdev_channel *bdev_ch, struct spdk_bdev_io *bdev_i
} }
} }
static bool
bdev_qos_queue_io(struct spdk_bdev_qos *qos, struct spdk_bdev_io *bdev_io)
{
int i;
if (bdev_qos_io_to_limit(bdev_io) == true) {
for (i = 0; i < SPDK_BDEV_QOS_NUM_RATE_LIMIT_TYPES; i++) {
if (!qos->rate_limits[i].queue_io) {
continue;
}
if (qos->rate_limits[i].queue_io(&qos->rate_limits[i],
bdev_io) == true) {
return true;
}
}
for (i = 0; i < SPDK_BDEV_QOS_NUM_RATE_LIMIT_TYPES; i++) {
if (!qos->rate_limits[i].update_quota) {
continue;
}
qos->rate_limits[i].update_quota(&qos->rate_limits[i], bdev_io);
}
}
return false;
}
static int static int
bdev_qos_io_submit(struct spdk_bdev_channel *ch, struct spdk_bdev_qos *qos) bdev_qos_io_submit(struct spdk_bdev_channel *ch, struct spdk_bdev_qos *qos)
{ {
struct spdk_bdev_io *bdev_io = NULL, *tmp = NULL; struct spdk_bdev_io *bdev_io = NULL, *tmp = NULL;
int i, submitted_ios = 0; int submitted_ios = 0;
TAILQ_FOREACH_SAFE(bdev_io, &qos->queued, internal.link, tmp) { TAILQ_FOREACH_SAFE(bdev_io, &qos->queued, internal.link, tmp) {
if (bdev_qos_io_to_limit(bdev_io) == true) { if (bdev_qos_queue_io(qos, bdev_io)) {
for (i = 0; i < SPDK_BDEV_QOS_NUM_RATE_LIMIT_TYPES; i++) { return submitted_ios;
if (!qos->rate_limits[i].queue_io) {
continue;
}
if (qos->rate_limits[i].queue_io(&qos->rate_limits[i],
bdev_io) == true) {
return submitted_ios;
}
}
for (i = 0; i < SPDK_BDEV_QOS_NUM_RATE_LIMIT_TYPES; i++) {
if (!qos->rate_limits[i].update_quota) {
continue;
}
qos->rate_limits[i].update_quota(&qos->rate_limits[i], bdev_io);
}
} }
TAILQ_REMOVE(&qos->queued, bdev_io, internal.link); TAILQ_REMOVE(&qos->queued, bdev_io, internal.link);