2
0

throttle.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. /*
  2. * QEMU throttling infrastructure
  3. *
  4. * Copyright (C) Nodalink, EURL. 2013-2014
  5. * Copyright (C) Igalia, S.L. 2015
  6. *
  7. * Authors:
  8. * Benoît Canet <benoit.canet@nodalink.com>
  9. * Alberto Garcia <berto@igalia.com>
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 or
  14. * (at your option) version 3 of the License.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, see <http://www.gnu.org/licenses/>.
  23. */
  24. #include "qemu/osdep.h"
  25. #include "qapi/error.h"
  26. #include "qemu/throttle.h"
  27. #include "qemu/timer.h"
  28. #include "block/aio.h"
  29. /* This function make a bucket leak
  30. *
  31. * @bkt: the bucket to make leak
  32. * @delta_ns: the time delta
  33. */
  34. void throttle_leak_bucket(LeakyBucket *bkt, int64_t delta_ns)
  35. {
  36. double leak;
  37. /* compute how much to leak */
  38. leak = (bkt->avg * (double) delta_ns) / NANOSECONDS_PER_SECOND;
  39. /* make the bucket leak */
  40. bkt->level = MAX(bkt->level - leak, 0);
  41. /* if we allow bursts for more than one second we also need to
  42. * keep track of bkt->burst_level so the bkt->max goal per second
  43. * is attained */
  44. if (bkt->burst_length > 1) {
  45. leak = (bkt->max * (double) delta_ns) / NANOSECONDS_PER_SECOND;
  46. bkt->burst_level = MAX(bkt->burst_level - leak, 0);
  47. }
  48. }
  49. /* Calculate the time delta since last leak and make proportionals leaks
  50. *
  51. * @now: the current timestamp in ns
  52. */
  53. static void throttle_do_leak(ThrottleState *ts, int64_t now)
  54. {
  55. /* compute the time elapsed since the last leak */
  56. int64_t delta_ns = now - ts->previous_leak;
  57. int i;
  58. ts->previous_leak = now;
  59. if (delta_ns <= 0) {
  60. return;
  61. }
  62. /* make each bucket leak */
  63. for (i = 0; i < BUCKETS_COUNT; i++) {
  64. throttle_leak_bucket(&ts->cfg.buckets[i], delta_ns);
  65. }
  66. }
  67. /* do the real job of computing the time to wait
  68. *
  69. * @limit: the throttling limit
  70. * @extra: the number of operation to delay
  71. * @ret: the time to wait in ns
  72. */
  73. static int64_t throttle_do_compute_wait(double limit, double extra)
  74. {
  75. double wait = extra * NANOSECONDS_PER_SECOND;
  76. wait /= limit;
  77. return wait;
  78. }
  79. /* This function compute the wait time in ns that a leaky bucket should trigger
  80. *
  81. * @bkt: the leaky bucket we operate on
  82. * @ret: the resulting wait time in ns or 0 if the operation can go through
  83. */
  84. int64_t throttle_compute_wait(LeakyBucket *bkt)
  85. {
  86. double extra; /* the number of extra units blocking the io */
  87. double bucket_size; /* I/O before throttling to bkt->avg */
  88. double burst_bucket_size; /* Before throttling to bkt->max */
  89. if (!bkt->avg) {
  90. return 0;
  91. }
  92. if (!bkt->max) {
  93. /* If bkt->max is 0 we still want to allow short bursts of I/O
  94. * from the guest, otherwise every other request will be throttled
  95. * and performance will suffer considerably. */
  96. bucket_size = (double) bkt->avg / 10;
  97. burst_bucket_size = 0;
  98. } else {
  99. /* If we have a burst limit then we have to wait until all I/O
  100. * at burst rate has finished before throttling to bkt->avg */
  101. bucket_size = bkt->max * bkt->burst_length;
  102. burst_bucket_size = (double) bkt->max / 10;
  103. }
  104. /* If the main bucket is full then we have to wait */
  105. extra = bkt->level - bucket_size;
  106. if (extra > 0) {
  107. return throttle_do_compute_wait(bkt->avg, extra);
  108. }
  109. /* If the main bucket is not full yet we still have to check the
  110. * burst bucket in order to enforce the burst limit */
  111. if (bkt->burst_length > 1) {
  112. assert(bkt->max > 0); /* see throttle_is_valid() */
  113. extra = bkt->burst_level - burst_bucket_size;
  114. if (extra > 0) {
  115. return throttle_do_compute_wait(bkt->max, extra);
  116. }
  117. }
  118. return 0;
  119. }
  120. /* This function compute the time that must be waited while this IO
  121. *
  122. * @is_write: true if the current IO is a write, false if it's a read
  123. * @ret: time to wait
  124. */
  125. static int64_t throttle_compute_wait_for(ThrottleState *ts,
  126. bool is_write)
  127. {
  128. BucketType to_check[2][4] = { {THROTTLE_BPS_TOTAL,
  129. THROTTLE_OPS_TOTAL,
  130. THROTTLE_BPS_READ,
  131. THROTTLE_OPS_READ},
  132. {THROTTLE_BPS_TOTAL,
  133. THROTTLE_OPS_TOTAL,
  134. THROTTLE_BPS_WRITE,
  135. THROTTLE_OPS_WRITE}, };
  136. int64_t wait, max_wait = 0;
  137. int i;
  138. for (i = 0; i < 4; i++) {
  139. BucketType index = to_check[is_write][i];
  140. wait = throttle_compute_wait(&ts->cfg.buckets[index]);
  141. if (wait > max_wait) {
  142. max_wait = wait;
  143. }
  144. }
  145. return max_wait;
  146. }
  147. /* compute the timer for this type of operation
  148. *
  149. * @is_write: the type of operation
  150. * @now: the current clock timestamp
  151. * @next_timestamp: the resulting timer
  152. * @ret: true if a timer must be set
  153. */
  154. static bool throttle_compute_timer(ThrottleState *ts,
  155. bool is_write,
  156. int64_t now,
  157. int64_t *next_timestamp)
  158. {
  159. int64_t wait;
  160. /* leak proportionally to the time elapsed */
  161. throttle_do_leak(ts, now);
  162. /* compute the wait time if any */
  163. wait = throttle_compute_wait_for(ts, is_write);
  164. /* if the code must wait compute when the next timer should fire */
  165. if (wait) {
  166. *next_timestamp = now + wait;
  167. return true;
  168. }
  169. /* else no need to wait at all */
  170. *next_timestamp = now;
  171. return false;
  172. }
  173. /* Add timers to event loop */
  174. void throttle_timers_attach_aio_context(ThrottleTimers *tt,
  175. AioContext *new_context)
  176. {
  177. tt->timers[0] = aio_timer_new(new_context, tt->clock_type, SCALE_NS,
  178. tt->read_timer_cb, tt->timer_opaque);
  179. tt->timers[1] = aio_timer_new(new_context, tt->clock_type, SCALE_NS,
  180. tt->write_timer_cb, tt->timer_opaque);
  181. }
  182. /*
  183. * Initialize the ThrottleConfig structure to a valid state
  184. * @cfg: the config to initialize
  185. */
  186. void throttle_config_init(ThrottleConfig *cfg)
  187. {
  188. unsigned i;
  189. memset(cfg, 0, sizeof(*cfg));
  190. for (i = 0; i < BUCKETS_COUNT; i++) {
  191. cfg->buckets[i].burst_length = 1;
  192. }
  193. }
  194. /* To be called first on the ThrottleState */
  195. void throttle_init(ThrottleState *ts)
  196. {
  197. memset(ts, 0, sizeof(ThrottleState));
  198. throttle_config_init(&ts->cfg);
  199. }
  200. /* To be called first on the ThrottleTimers */
  201. void throttle_timers_init(ThrottleTimers *tt,
  202. AioContext *aio_context,
  203. QEMUClockType clock_type,
  204. QEMUTimerCB *read_timer_cb,
  205. QEMUTimerCB *write_timer_cb,
  206. void *timer_opaque)
  207. {
  208. memset(tt, 0, sizeof(ThrottleTimers));
  209. tt->clock_type = clock_type;
  210. tt->read_timer_cb = read_timer_cb;
  211. tt->write_timer_cb = write_timer_cb;
  212. tt->timer_opaque = timer_opaque;
  213. throttle_timers_attach_aio_context(tt, aio_context);
  214. }
  215. /* destroy a timer */
  216. static void throttle_timer_destroy(QEMUTimer **timer)
  217. {
  218. assert(*timer != NULL);
  219. timer_del(*timer);
  220. timer_free(*timer);
  221. *timer = NULL;
  222. }
  223. /* Remove timers from event loop */
  224. void throttle_timers_detach_aio_context(ThrottleTimers *tt)
  225. {
  226. int i;
  227. for (i = 0; i < 2; i++) {
  228. throttle_timer_destroy(&tt->timers[i]);
  229. }
  230. }
  231. /* To be called last on the ThrottleTimers */
  232. void throttle_timers_destroy(ThrottleTimers *tt)
  233. {
  234. throttle_timers_detach_aio_context(tt);
  235. }
  236. /* is any throttling timer configured */
  237. bool throttle_timers_are_initialized(ThrottleTimers *tt)
  238. {
  239. if (tt->timers[0]) {
  240. return true;
  241. }
  242. return false;
  243. }
  244. /* Does any throttling must be done
  245. *
  246. * @cfg: the throttling configuration to inspect
  247. * @ret: true if throttling must be done else false
  248. */
  249. bool throttle_enabled(ThrottleConfig *cfg)
  250. {
  251. int i;
  252. for (i = 0; i < BUCKETS_COUNT; i++) {
  253. if (cfg->buckets[i].avg > 0) {
  254. return true;
  255. }
  256. }
  257. return false;
  258. }
  259. /* check if a throttling configuration is valid
  260. * @cfg: the throttling configuration to inspect
  261. * @ret: true if valid else false
  262. * @errp: error object
  263. */
  264. bool throttle_is_valid(ThrottleConfig *cfg, Error **errp)
  265. {
  266. int i;
  267. bool bps_flag, ops_flag;
  268. bool bps_max_flag, ops_max_flag;
  269. bps_flag = cfg->buckets[THROTTLE_BPS_TOTAL].avg &&
  270. (cfg->buckets[THROTTLE_BPS_READ].avg ||
  271. cfg->buckets[THROTTLE_BPS_WRITE].avg);
  272. ops_flag = cfg->buckets[THROTTLE_OPS_TOTAL].avg &&
  273. (cfg->buckets[THROTTLE_OPS_READ].avg ||
  274. cfg->buckets[THROTTLE_OPS_WRITE].avg);
  275. bps_max_flag = cfg->buckets[THROTTLE_BPS_TOTAL].max &&
  276. (cfg->buckets[THROTTLE_BPS_READ].max ||
  277. cfg->buckets[THROTTLE_BPS_WRITE].max);
  278. ops_max_flag = cfg->buckets[THROTTLE_OPS_TOTAL].max &&
  279. (cfg->buckets[THROTTLE_OPS_READ].max ||
  280. cfg->buckets[THROTTLE_OPS_WRITE].max);
  281. if (bps_flag || ops_flag || bps_max_flag || ops_max_flag) {
  282. error_setg(errp, "bps/iops/max total values and read/write values"
  283. " cannot be used at the same time");
  284. return false;
  285. }
  286. if (cfg->op_size &&
  287. !cfg->buckets[THROTTLE_OPS_TOTAL].avg &&
  288. !cfg->buckets[THROTTLE_OPS_READ].avg &&
  289. !cfg->buckets[THROTTLE_OPS_WRITE].avg) {
  290. error_setg(errp, "iops size requires an iops value to be set");
  291. return false;
  292. }
  293. for (i = 0; i < BUCKETS_COUNT; i++) {
  294. LeakyBucket *bkt = &cfg->buckets[i];
  295. if (bkt->avg > THROTTLE_VALUE_MAX || bkt->max > THROTTLE_VALUE_MAX) {
  296. error_setg(errp, "bps/iops/max values must be within [0, %lld]",
  297. THROTTLE_VALUE_MAX);
  298. return false;
  299. }
  300. if (!bkt->burst_length) {
  301. error_setg(errp, "the burst length cannot be 0");
  302. return false;
  303. }
  304. if (bkt->burst_length > 1 && !bkt->max) {
  305. error_setg(errp, "burst length set without burst rate");
  306. return false;
  307. }
  308. if (bkt->max && bkt->burst_length > THROTTLE_VALUE_MAX / bkt->max) {
  309. error_setg(errp, "burst length too high for this burst rate");
  310. return false;
  311. }
  312. if (bkt->max && !bkt->avg) {
  313. error_setg(errp, "bps_max/iops_max require corresponding"
  314. " bps/iops values");
  315. return false;
  316. }
  317. if (bkt->max && bkt->max < bkt->avg) {
  318. error_setg(errp, "bps_max/iops_max cannot be lower than bps/iops");
  319. return false;
  320. }
  321. }
  322. return true;
  323. }
  324. /* Used to configure the throttle
  325. *
  326. * @ts: the throttle state we are working on
  327. * @clock_type: the group's clock_type
  328. * @cfg: the config to set
  329. */
  330. void throttle_config(ThrottleState *ts,
  331. QEMUClockType clock_type,
  332. ThrottleConfig *cfg)
  333. {
  334. int i;
  335. ts->cfg = *cfg;
  336. /* Zero bucket level */
  337. for (i = 0; i < BUCKETS_COUNT; i++) {
  338. ts->cfg.buckets[i].level = 0;
  339. ts->cfg.buckets[i].burst_level = 0;
  340. }
  341. ts->previous_leak = qemu_clock_get_ns(clock_type);
  342. }
  343. /* used to get config
  344. *
  345. * @ts: the throttle state we are working on
  346. * @cfg: the config to write
  347. */
  348. void throttle_get_config(ThrottleState *ts, ThrottleConfig *cfg)
  349. {
  350. *cfg = ts->cfg;
  351. }
  352. /* Schedule the read or write timer if needed
  353. *
  354. * NOTE: this function is not unit tested due to it's usage of timer_mod
  355. *
  356. * @tt: the timers structure
  357. * @is_write: the type of operation (read/write)
  358. * @ret: true if the timer has been scheduled else false
  359. */
  360. bool throttle_schedule_timer(ThrottleState *ts,
  361. ThrottleTimers *tt,
  362. bool is_write)
  363. {
  364. int64_t now = qemu_clock_get_ns(tt->clock_type);
  365. int64_t next_timestamp;
  366. bool must_wait;
  367. must_wait = throttle_compute_timer(ts,
  368. is_write,
  369. now,
  370. &next_timestamp);
  371. /* request not throttled */
  372. if (!must_wait) {
  373. return false;
  374. }
  375. /* request throttled and timer pending -> do nothing */
  376. if (timer_pending(tt->timers[is_write])) {
  377. return true;
  378. }
  379. /* request throttled and timer not pending -> arm timer */
  380. timer_mod(tt->timers[is_write], next_timestamp);
  381. return true;
  382. }
  383. /* do the accounting for this operation
  384. *
  385. * @is_write: the type of operation (read/write)
  386. * @size: the size of the operation
  387. */
  388. void throttle_account(ThrottleState *ts, bool is_write, uint64_t size)
  389. {
  390. const BucketType bucket_types_size[2][2] = {
  391. { THROTTLE_BPS_TOTAL, THROTTLE_BPS_READ },
  392. { THROTTLE_BPS_TOTAL, THROTTLE_BPS_WRITE }
  393. };
  394. const BucketType bucket_types_units[2][2] = {
  395. { THROTTLE_OPS_TOTAL, THROTTLE_OPS_READ },
  396. { THROTTLE_OPS_TOTAL, THROTTLE_OPS_WRITE }
  397. };
  398. double units = 1.0;
  399. unsigned i;
  400. /* if cfg.op_size is defined and smaller than size we compute unit count */
  401. if (ts->cfg.op_size && size > ts->cfg.op_size) {
  402. units = (double) size / ts->cfg.op_size;
  403. }
  404. for (i = 0; i < 2; i++) {
  405. LeakyBucket *bkt;
  406. bkt = &ts->cfg.buckets[bucket_types_size[is_write][i]];
  407. bkt->level += size;
  408. if (bkt->burst_length > 1) {
  409. bkt->burst_level += size;
  410. }
  411. bkt = &ts->cfg.buckets[bucket_types_units[is_write][i]];
  412. bkt->level += units;
  413. if (bkt->burst_length > 1) {
  414. bkt->burst_level += units;
  415. }
  416. }
  417. }
  418. /* return a ThrottleConfig based on the options in a ThrottleLimits
  419. *
  420. * @arg: the ThrottleLimits object to read from
  421. * @cfg: the ThrottleConfig to edit
  422. * @errp: error object
  423. */
  424. void throttle_limits_to_config(ThrottleLimits *arg, ThrottleConfig *cfg,
  425. Error **errp)
  426. {
  427. if (arg->has_bps_total) {
  428. cfg->buckets[THROTTLE_BPS_TOTAL].avg = arg->bps_total;
  429. }
  430. if (arg->has_bps_read) {
  431. cfg->buckets[THROTTLE_BPS_READ].avg = arg->bps_read;
  432. }
  433. if (arg->has_bps_write) {
  434. cfg->buckets[THROTTLE_BPS_WRITE].avg = arg->bps_write;
  435. }
  436. if (arg->has_iops_total) {
  437. cfg->buckets[THROTTLE_OPS_TOTAL].avg = arg->iops_total;
  438. }
  439. if (arg->has_iops_read) {
  440. cfg->buckets[THROTTLE_OPS_READ].avg = arg->iops_read;
  441. }
  442. if (arg->has_iops_write) {
  443. cfg->buckets[THROTTLE_OPS_WRITE].avg = arg->iops_write;
  444. }
  445. if (arg->has_bps_total_max) {
  446. cfg->buckets[THROTTLE_BPS_TOTAL].max = arg->bps_total_max;
  447. }
  448. if (arg->has_bps_read_max) {
  449. cfg->buckets[THROTTLE_BPS_READ].max = arg->bps_read_max;
  450. }
  451. if (arg->has_bps_write_max) {
  452. cfg->buckets[THROTTLE_BPS_WRITE].max = arg->bps_write_max;
  453. }
  454. if (arg->has_iops_total_max) {
  455. cfg->buckets[THROTTLE_OPS_TOTAL].max = arg->iops_total_max;
  456. }
  457. if (arg->has_iops_read_max) {
  458. cfg->buckets[THROTTLE_OPS_READ].max = arg->iops_read_max;
  459. }
  460. if (arg->has_iops_write_max) {
  461. cfg->buckets[THROTTLE_OPS_WRITE].max = arg->iops_write_max;
  462. }
  463. if (arg->has_bps_total_max_length) {
  464. if (arg->bps_total_max_length > UINT_MAX) {
  465. error_setg(errp, "bps-total-max-length value must be in"
  466. " the range [0, %u]", UINT_MAX);
  467. return;
  468. }
  469. cfg->buckets[THROTTLE_BPS_TOTAL].burst_length = arg->bps_total_max_length;
  470. }
  471. if (arg->has_bps_read_max_length) {
  472. if (arg->bps_read_max_length > UINT_MAX) {
  473. error_setg(errp, "bps-read-max-length value must be in"
  474. " the range [0, %u]", UINT_MAX);
  475. return;
  476. }
  477. cfg->buckets[THROTTLE_BPS_READ].burst_length = arg->bps_read_max_length;
  478. }
  479. if (arg->has_bps_write_max_length) {
  480. if (arg->bps_write_max_length > UINT_MAX) {
  481. error_setg(errp, "bps-write-max-length value must be in"
  482. " the range [0, %u]", UINT_MAX);
  483. return;
  484. }
  485. cfg->buckets[THROTTLE_BPS_WRITE].burst_length = arg->bps_write_max_length;
  486. }
  487. if (arg->has_iops_total_max_length) {
  488. if (arg->iops_total_max_length > UINT_MAX) {
  489. error_setg(errp, "iops-total-max-length value must be in"
  490. " the range [0, %u]", UINT_MAX);
  491. return;
  492. }
  493. cfg->buckets[THROTTLE_OPS_TOTAL].burst_length = arg->iops_total_max_length;
  494. }
  495. if (arg->has_iops_read_max_length) {
  496. if (arg->iops_read_max_length > UINT_MAX) {
  497. error_setg(errp, "iops-read-max-length value must be in"
  498. " the range [0, %u]", UINT_MAX);
  499. return;
  500. }
  501. cfg->buckets[THROTTLE_OPS_READ].burst_length = arg->iops_read_max_length;
  502. }
  503. if (arg->has_iops_write_max_length) {
  504. if (arg->iops_write_max_length > UINT_MAX) {
  505. error_setg(errp, "iops-write-max-length value must be in"
  506. " the range [0, %u]", UINT_MAX);
  507. return;
  508. }
  509. cfg->buckets[THROTTLE_OPS_WRITE].burst_length = arg->iops_write_max_length;
  510. }
  511. if (arg->has_iops_size) {
  512. cfg->op_size = arg->iops_size;
  513. }
  514. throttle_is_valid(cfg, errp);
  515. }
  516. /* write the options of a ThrottleConfig to a ThrottleLimits
  517. *
  518. * @cfg: the ThrottleConfig to read from
  519. * @var: the ThrottleLimits to write to
  520. */
  521. void throttle_config_to_limits(ThrottleConfig *cfg, ThrottleLimits *var)
  522. {
  523. var->bps_total = cfg->buckets[THROTTLE_BPS_TOTAL].avg;
  524. var->bps_read = cfg->buckets[THROTTLE_BPS_READ].avg;
  525. var->bps_write = cfg->buckets[THROTTLE_BPS_WRITE].avg;
  526. var->iops_total = cfg->buckets[THROTTLE_OPS_TOTAL].avg;
  527. var->iops_read = cfg->buckets[THROTTLE_OPS_READ].avg;
  528. var->iops_write = cfg->buckets[THROTTLE_OPS_WRITE].avg;
  529. var->bps_total_max = cfg->buckets[THROTTLE_BPS_TOTAL].max;
  530. var->bps_read_max = cfg->buckets[THROTTLE_BPS_READ].max;
  531. var->bps_write_max = cfg->buckets[THROTTLE_BPS_WRITE].max;
  532. var->iops_total_max = cfg->buckets[THROTTLE_OPS_TOTAL].max;
  533. var->iops_read_max = cfg->buckets[THROTTLE_OPS_READ].max;
  534. var->iops_write_max = cfg->buckets[THROTTLE_OPS_WRITE].max;
  535. var->bps_total_max_length = cfg->buckets[THROTTLE_BPS_TOTAL].burst_length;
  536. var->bps_read_max_length = cfg->buckets[THROTTLE_BPS_READ].burst_length;
  537. var->bps_write_max_length = cfg->buckets[THROTTLE_BPS_WRITE].burst_length;
  538. var->iops_total_max_length = cfg->buckets[THROTTLE_OPS_TOTAL].burst_length;
  539. var->iops_read_max_length = cfg->buckets[THROTTLE_OPS_READ].burst_length;
  540. var->iops_write_max_length = cfg->buckets[THROTTLE_OPS_WRITE].burst_length;
  541. var->iops_size = cfg->op_size;
  542. var->has_bps_total = true;
  543. var->has_bps_read = true;
  544. var->has_bps_write = true;
  545. var->has_iops_total = true;
  546. var->has_iops_read = true;
  547. var->has_iops_write = true;
  548. var->has_bps_total_max = true;
  549. var->has_bps_read_max = true;
  550. var->has_bps_write_max = true;
  551. var->has_iops_total_max = true;
  552. var->has_iops_read_max = true;
  553. var->has_iops_write_max = true;
  554. var->has_bps_read_max_length = true;
  555. var->has_bps_total_max_length = true;
  556. var->has_bps_write_max_length = true;
  557. var->has_iops_total_max_length = true;
  558. var->has_iops_read_max_length = true;
  559. var->has_iops_write_max_length = true;
  560. var->has_iops_size = true;
  561. }