Skip to content

Instantly share code, notes, and snippets.

@fcicq
Last active August 11, 2016 08:40
Show Gist options
  • Save fcicq/6492438c211d597fc87e to your computer and use it in GitHub Desktop.
Save fcicq/6492438c211d597fc87e to your computer and use it in GitHub Desktop.
--- a/block/blk-throttle.c 2016-08-09 15:48:03.242986929 +0800
+++ b/block/blk-throttle.c 2016-08-09 15:53:33.060446303 +0800
@@ -735,7 +735,8 @@
}
/* Calc approx time to dispatch */
- extra_bytes = tg->bytes_disp[rw] + bio->bi_iter.bi_size - bytes_allowed;
+ /* fcicq: iops limit not checked and allow smaller request, use the correct wait time here */
+ extra_bytes = tg->bytes_disp[rw] + max(bio->bi_iter.bi_size, 32768U) - bytes_allowed;
jiffy_wait = div64_u64(extra_bytes * HZ, tg->bps[rw]);
if (!jiffy_wait)
@@ -812,8 +812,9 @@
bool rw = bio_data_dir(bio);
/* Charge the bio to the group */
- tg->bytes_disp[rw] += bio->bi_iter.bi_size;
- tg->io_disp[rw]++;
+ /* fcicq: the actual limit is min(iops * 32k, read/write_bps_device) */
+ tg->bytes_disp[rw] += max(bio->bi_iter.bi_size, 32768U);
+ tg->io_disp[rw] += max(bio->bi_iter.bi_size >> 15, 1U);
/*
* REQ_THROTTLED is used to prevent the same bio to be throttled
--- a/include/linux/blk-cgroup.h 2016-08-09 15:54:40.916743140 +0800
+++ b/include/linux/blk-cgroup.h 2016-08-09 15:55:22.228923943 +0800
@@ -715,8 +715,8 @@
if (!throtl) {
blkg = blkg ?: q->root_blkg;
blkg_rwstat_add(&blkg->stat_bytes, bio_op(bio), bio->bi_opf,
- bio->bi_iter.bi_size);
- blkg_rwstat_add(&blkg->stat_ios, bio_op(bio), bio->bi_opf, 1);
+ max(bio->bi_iter.bi_size, 32768U));
+ blkg_rwstat_add(&blkg->stat_ios, bio_op(bio), bio->bi_opf, max(bio->bi_iter.bi_size >> 15, 1U));
}
rcu_read_unlock();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment