From aa2789e9263334a4317e46a1cac02960627ddc8f Mon Sep 17 00:00:00 2001 From: GangCao Date: Tue, 3 Jul 2018 21:43:39 -0400 Subject: [PATCH] QoS/Bdev: update the Byte rate limit timeslice control Considering the I/O size is variant from small in byte to large in megabyte, need to consider the compensation of less allowed bytes in next timeslice if the current timeslice sends more bytes down. Change-Id: I885f0bb21001bd90879aa8622e2b34e3bf78cf6e Signed-off-by: GangCao Reviewed-on: https://review.gerrithub.io/417829 Tested-by: SPDK Automated Test System Chandler-Test-Pool: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Changpeng Liu --- lib/bdev/bdev.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/bdev/bdev.c b/lib/bdev/bdev.c index 4b5e7fabc..d67992897 100644 --- a/lib/bdev/bdev.c +++ b/lib/bdev/bdev.c @@ -1222,7 +1222,13 @@ spdk_bdev_channel_poll_qos(void *arg) /* Reset for next round of rate limiting */ qos->io_submitted_this_timeslice = 0; - qos->byte_submitted_this_timeslice = 0; + + /* More bytes sent in the last timeslice, allow less in this timeslice */ + if (qos->byte_submitted_this_timeslice > qos->max_byte_per_timeslice) { + qos->byte_submitted_this_timeslice -= qos->max_byte_per_timeslice; + } else { + qos->byte_submitted_this_timeslice = 0; + } _spdk_bdev_qos_io_submit(qos->ch);