@@ -2183,14 +2183,14 @@ bool __blk_throtl_bio(struct bio *bio)
* Splited bios can be re-entered because iops limit should be
* counted again, however, bps limit should not. Since bps limit
* will be counted again while dispatching it, compensate the
- * over-accounting here. Noted that compensation can fail if
- * new slice is started.
+ * over-accounting here. Since decrement of 'bytes_disp' can't
+ * handle the case that new slice is started, increase
+ * 'bytes_skipped' instead.
*/
if (bio_flagged(bio, BIO_THROTTLED)) {
unsigned int bio_size = throtl_bio_data_size(bio);
- if (tg->bytes_disp[rw] >= bio_size)
- tg->bytes_disp[rw] -= bio_size;
+ tg->bytes_skipped[rw] += bio_size;
if (tg->last_bytes_disp[rw] >= bio_size)
tg->last_bytes_disp[rw] -= bio_size;
}
@@ -121,7 +121,9 @@ struct throtl_grp {
* bytes/io are waited already in previous configuration, and they will
* be used to calculate wait time under new configuration.
*
- * Number of bytes will be skipped in current slice
+ * Number of bytes will be skipped in current slice. In addition, this
+ * field will help to handle re-entered bio for bps limit, see details
+ * in __blk_throtl_bio().
*/
uint64_t bytes_skipped[2];
/* Number of bio will be skipped in current slice */