throttle.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  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. * @direction: throttle direction
  123. * @ret: time to wait
  124. */
  125. static int64_t throttle_compute_wait_for(ThrottleState *ts,
  126. ThrottleDirection direction)
  127. {
  128. static const BucketType to_check[THROTTLE_MAX][4] = {
  129. {THROTTLE_BPS_TOTAL,
  130. THROTTLE_OPS_TOTAL,
  131. THROTTLE_BPS_READ,
  132. THROTTLE_OPS_READ},
  133. {THROTTLE_BPS_TOTAL,
  134. THROTTLE_OPS_TOTAL,
  135. THROTTLE_BPS_WRITE,
  136. THROTTLE_OPS_WRITE}, };
  137. int64_t wait, max_wait = 0;
  138. int i;
  139. for (i = 0; i < ARRAY_SIZE(to_check[THROTTLE_READ]); i++) {
  140. BucketType index = to_check[direction][i];
  141. wait = throttle_compute_wait(&ts->cfg.buckets[index]);
  142. if (wait > max_wait) {
  143. max_wait = wait;
  144. }
  145. }
  146. return max_wait;
  147. }
  148. /* compute the timer for this type of operation
  149. *
  150. * @direction: throttle direction
  151. * @now: the current clock timestamp
  152. * @next_timestamp: the resulting timer
  153. * @ret: true if a timer must be set
  154. */
  155. static bool throttle_compute_timer(ThrottleState *ts,
  156. ThrottleDirection direction,
  157. int64_t now,
  158. int64_t *next_timestamp)
  159. {
  160. int64_t wait;
  161. /* leak proportionally to the time elapsed */
  162. throttle_do_leak(ts, now);
  163. /* compute the wait time if any */
  164. wait = throttle_compute_wait_for(ts, direction);
  165. /* if the code must wait compute when the next timer should fire */
  166. if (wait) {
  167. *next_timestamp = now + wait;
  168. return true;
  169. }
  170. /* else no need to wait at all */
  171. *next_timestamp = now;
  172. return false;
  173. }
  174. /* Add timers to event loop */
  175. void throttle_timers_attach_aio_context(ThrottleTimers *tt,
  176. AioContext *new_context)
  177. {
  178. ThrottleDirection dir;
  179. for (dir = THROTTLE_READ; dir < THROTTLE_MAX; dir++) {
  180. if (tt->timer_cb[dir]) {
  181. tt->timers[dir] =
  182. aio_timer_new(new_context, tt->clock_type, SCALE_NS,
  183. tt->timer_cb[dir], tt->timer_opaque);
  184. }
  185. }
  186. }
  187. /*
  188. * Initialize the ThrottleConfig structure to a valid state
  189. * @cfg: the config to initialize
  190. */
  191. void throttle_config_init(ThrottleConfig *cfg)
  192. {
  193. unsigned i;
  194. memset(cfg, 0, sizeof(*cfg));
  195. for (i = 0; i < BUCKETS_COUNT; i++) {
  196. cfg->buckets[i].burst_length = 1;
  197. }
  198. }
  199. /* To be called first on the ThrottleState */
  200. void throttle_init(ThrottleState *ts)
  201. {
  202. memset(ts, 0, sizeof(ThrottleState));
  203. throttle_config_init(&ts->cfg);
  204. }
  205. /* To be called first on the ThrottleTimers */
  206. void throttle_timers_init(ThrottleTimers *tt,
  207. AioContext *aio_context,
  208. QEMUClockType clock_type,
  209. QEMUTimerCB *read_timer_cb,
  210. QEMUTimerCB *write_timer_cb,
  211. void *timer_opaque)
  212. {
  213. assert(read_timer_cb || write_timer_cb);
  214. memset(tt, 0, sizeof(ThrottleTimers));
  215. tt->clock_type = clock_type;
  216. tt->timer_cb[THROTTLE_READ] = read_timer_cb;
  217. tt->timer_cb[THROTTLE_WRITE] = write_timer_cb;
  218. tt->timer_opaque = timer_opaque;
  219. throttle_timers_attach_aio_context(tt, aio_context);
  220. }
  221. /* destroy a timer */
  222. static void throttle_timer_destroy(QEMUTimer **timer)
  223. {
  224. if (*timer == NULL) {
  225. return;
  226. }
  227. timer_free(*timer);
  228. *timer = NULL;
  229. }
  230. /* Remove timers from event loop */
  231. void throttle_timers_detach_aio_context(ThrottleTimers *tt)
  232. {
  233. ThrottleDirection dir;
  234. for (dir = THROTTLE_READ; dir < THROTTLE_MAX; dir++) {
  235. throttle_timer_destroy(&tt->timers[dir]);
  236. }
  237. }
  238. /* To be called last on the ThrottleTimers */
  239. void throttle_timers_destroy(ThrottleTimers *tt)
  240. {
  241. throttle_timers_detach_aio_context(tt);
  242. }
  243. /* is any throttling timer configured */
  244. bool throttle_timers_are_initialized(ThrottleTimers *tt)
  245. {
  246. ThrottleDirection dir;
  247. for (dir = THROTTLE_READ; dir < THROTTLE_MAX; dir++) {
  248. if (tt->timers[dir]) {
  249. return true;
  250. }
  251. }
  252. return false;
  253. }
  254. /* Does any throttling must be done
  255. *
  256. * @cfg: the throttling configuration to inspect
  257. * @ret: true if throttling must be done else false
  258. */
  259. bool throttle_enabled(ThrottleConfig *cfg)
  260. {
  261. int i;
  262. for (i = 0; i < BUCKETS_COUNT; i++) {
  263. if (cfg->buckets[i].avg > 0) {
  264. return true;
  265. }
  266. }
  267. return false;
  268. }
  269. /* check if a throttling configuration is valid
  270. * @cfg: the throttling configuration to inspect
  271. * @ret: true if valid else false
  272. * @errp: error object
  273. */
  274. bool throttle_is_valid(ThrottleConfig *cfg, Error **errp)
  275. {
  276. int i;
  277. bool bps_flag, ops_flag;
  278. bool bps_max_flag, ops_max_flag;
  279. bps_flag = cfg->buckets[THROTTLE_BPS_TOTAL].avg &&
  280. (cfg->buckets[THROTTLE_BPS_READ].avg ||
  281. cfg->buckets[THROTTLE_BPS_WRITE].avg);
  282. ops_flag = cfg->buckets[THROTTLE_OPS_TOTAL].avg &&
  283. (cfg->buckets[THROTTLE_OPS_READ].avg ||
  284. cfg->buckets[THROTTLE_OPS_WRITE].avg);
  285. bps_max_flag = cfg->buckets[THROTTLE_BPS_TOTAL].max &&
  286. (cfg->buckets[THROTTLE_BPS_READ].max ||
  287. cfg->buckets[THROTTLE_BPS_WRITE].max);
  288. ops_max_flag = cfg->buckets[THROTTLE_OPS_TOTAL].max &&
  289. (cfg->buckets[THROTTLE_OPS_READ].max ||
  290. cfg->buckets[THROTTLE_OPS_WRITE].max);
  291. if (bps_flag || ops_flag || bps_max_flag || ops_max_flag) {
  292. error_setg(errp, "bps/iops/max total values and read/write values"
  293. " cannot be used at the same time");
  294. return false;
  295. }
  296. if (cfg->op_size &&
  297. !cfg->buckets[THROTTLE_OPS_TOTAL].avg &&
  298. !cfg->buckets[THROTTLE_OPS_READ].avg &&
  299. !cfg->buckets[THROTTLE_OPS_WRITE].avg) {
  300. error_setg(errp, "iops size requires an iops value to be set");
  301. return false;
  302. }
  303. for (i = 0; i < BUCKETS_COUNT; i++) {
  304. LeakyBucket *bkt = &cfg->buckets[i];
  305. if (bkt->avg > THROTTLE_VALUE_MAX || bkt->max > THROTTLE_VALUE_MAX) {
  306. error_setg(errp, "bps/iops/max values must be within [0, %lld]",
  307. THROTTLE_VALUE_MAX);
  308. return false;
  309. }
  310. if (!bkt->burst_length) {
  311. error_setg(errp, "the burst length cannot be 0");
  312. return false;
  313. }
  314. if (bkt->burst_length > 1 && !bkt->max) {
  315. error_setg(errp, "burst length set without burst rate");
  316. return false;
  317. }
  318. if (bkt->max && bkt->burst_length > THROTTLE_VALUE_MAX / bkt->max) {
  319. error_setg(errp, "burst length too high for this burst rate");
  320. return false;
  321. }
  322. if (bkt->max && !bkt->avg) {
  323. error_setg(errp, "bps_max/iops_max require corresponding"
  324. " bps/iops values");
  325. return false;
  326. }
  327. if (bkt->max && bkt->max < bkt->avg) {
  328. error_setg(errp, "bps_max/iops_max cannot be lower than bps/iops");
  329. return false;
  330. }
  331. }
  332. return true;
  333. }
  334. /* Used to configure the throttle
  335. *
  336. * @ts: the throttle state we are working on
  337. * @clock_type: the group's clock_type
  338. * @cfg: the config to set
  339. */
  340. void throttle_config(ThrottleState *ts,
  341. QEMUClockType clock_type,
  342. ThrottleConfig *cfg)
  343. {
  344. int i;
  345. ts->cfg = *cfg;
  346. /* Zero bucket level */
  347. for (i = 0; i < BUCKETS_COUNT; i++) {
  348. ts->cfg.buckets[i].level = 0;
  349. ts->cfg.buckets[i].burst_level = 0;
  350. }
  351. ts->previous_leak = qemu_clock_get_ns(clock_type);
  352. }
  353. /* used to get config
  354. *
  355. * @ts: the throttle state we are working on
  356. * @cfg: the config to write
  357. */
  358. void throttle_get_config(ThrottleState *ts, ThrottleConfig *cfg)
  359. {
  360. *cfg = ts->cfg;
  361. }
  362. /* Schedule the read or write timer if needed
  363. *
  364. * NOTE: this function is not unit tested due to it's usage of timer_mod
  365. *
  366. * @tt: the timers structure
  367. * @direction: throttle direction
  368. * @ret: true if the timer has been scheduled else false
  369. */
  370. bool throttle_schedule_timer(ThrottleState *ts,
  371. ThrottleTimers *tt,
  372. ThrottleDirection direction)
  373. {
  374. int64_t now = qemu_clock_get_ns(tt->clock_type);
  375. int64_t next_timestamp;
  376. QEMUTimer *timer;
  377. bool must_wait;
  378. assert(direction < THROTTLE_MAX);
  379. timer = tt->timers[direction];
  380. assert(timer);
  381. must_wait = throttle_compute_timer(ts,
  382. direction,
  383. now,
  384. &next_timestamp);
  385. /* request not throttled */
  386. if (!must_wait) {
  387. return false;
  388. }
  389. /* request throttled and timer pending -> do nothing */
  390. if (timer_pending(timer)) {
  391. return true;
  392. }
  393. /* request throttled and timer not pending -> arm timer */
  394. timer_mod(timer, next_timestamp);
  395. return true;
  396. }
  397. /* do the accounting for this operation
  398. *
  399. * @direction: throttle direction
  400. * @size: the size of the operation
  401. */
  402. void throttle_account(ThrottleState *ts, ThrottleDirection direction,
  403. uint64_t size)
  404. {
  405. static const BucketType bucket_types_size[THROTTLE_MAX][2] = {
  406. { THROTTLE_BPS_TOTAL, THROTTLE_BPS_READ },
  407. { THROTTLE_BPS_TOTAL, THROTTLE_BPS_WRITE }
  408. };
  409. static const BucketType bucket_types_units[THROTTLE_MAX][2] = {
  410. { THROTTLE_OPS_TOTAL, THROTTLE_OPS_READ },
  411. { THROTTLE_OPS_TOTAL, THROTTLE_OPS_WRITE }
  412. };
  413. double units = 1.0;
  414. unsigned i;
  415. assert(direction < THROTTLE_MAX);
  416. /* if cfg.op_size is defined and smaller than size we compute unit count */
  417. if (ts->cfg.op_size && size > ts->cfg.op_size) {
  418. units = (double) size / ts->cfg.op_size;
  419. }
  420. for (i = 0; i < ARRAY_SIZE(bucket_types_size[THROTTLE_READ]); i++) {
  421. LeakyBucket *bkt;
  422. bkt = &ts->cfg.buckets[bucket_types_size[direction][i]];
  423. bkt->level += size;
  424. if (bkt->burst_length > 1) {
  425. bkt->burst_level += size;
  426. }
  427. bkt = &ts->cfg.buckets[bucket_types_units[direction][i]];
  428. bkt->level += units;
  429. if (bkt->burst_length > 1) {
  430. bkt->burst_level += units;
  431. }
  432. }
  433. }
  434. /* return a ThrottleConfig based on the options in a ThrottleLimits
  435. *
  436. * @arg: the ThrottleLimits object to read from
  437. * @cfg: the ThrottleConfig to edit
  438. * @errp: error object
  439. */
  440. void throttle_limits_to_config(ThrottleLimits *arg, ThrottleConfig *cfg,
  441. Error **errp)
  442. {
  443. if (arg->has_bps_total) {
  444. cfg->buckets[THROTTLE_BPS_TOTAL].avg = arg->bps_total;
  445. }
  446. if (arg->has_bps_read) {
  447. cfg->buckets[THROTTLE_BPS_READ].avg = arg->bps_read;
  448. }
  449. if (arg->has_bps_write) {
  450. cfg->buckets[THROTTLE_BPS_WRITE].avg = arg->bps_write;
  451. }
  452. if (arg->has_iops_total) {
  453. cfg->buckets[THROTTLE_OPS_TOTAL].avg = arg->iops_total;
  454. }
  455. if (arg->has_iops_read) {
  456. cfg->buckets[THROTTLE_OPS_READ].avg = arg->iops_read;
  457. }
  458. if (arg->has_iops_write) {
  459. cfg->buckets[THROTTLE_OPS_WRITE].avg = arg->iops_write;
  460. }
  461. if (arg->has_bps_total_max) {
  462. cfg->buckets[THROTTLE_BPS_TOTAL].max = arg->bps_total_max;
  463. }
  464. if (arg->has_bps_read_max) {
  465. cfg->buckets[THROTTLE_BPS_READ].max = arg->bps_read_max;
  466. }
  467. if (arg->has_bps_write_max) {
  468. cfg->buckets[THROTTLE_BPS_WRITE].max = arg->bps_write_max;
  469. }
  470. if (arg->has_iops_total_max) {
  471. cfg->buckets[THROTTLE_OPS_TOTAL].max = arg->iops_total_max;
  472. }
  473. if (arg->has_iops_read_max) {
  474. cfg->buckets[THROTTLE_OPS_READ].max = arg->iops_read_max;
  475. }
  476. if (arg->has_iops_write_max) {
  477. cfg->buckets[THROTTLE_OPS_WRITE].max = arg->iops_write_max;
  478. }
  479. if (arg->has_bps_total_max_length) {
  480. if (arg->bps_total_max_length > UINT_MAX) {
  481. error_setg(errp, "bps-total-max-length value must be in"
  482. " the range [0, %u]", UINT_MAX);
  483. return;
  484. }
  485. cfg->buckets[THROTTLE_BPS_TOTAL].burst_length = arg->bps_total_max_length;
  486. }
  487. if (arg->has_bps_read_max_length) {
  488. if (arg->bps_read_max_length > UINT_MAX) {
  489. error_setg(errp, "bps-read-max-length value must be in"
  490. " the range [0, %u]", UINT_MAX);
  491. return;
  492. }
  493. cfg->buckets[THROTTLE_BPS_READ].burst_length = arg->bps_read_max_length;
  494. }
  495. if (arg->has_bps_write_max_length) {
  496. if (arg->bps_write_max_length > UINT_MAX) {
  497. error_setg(errp, "bps-write-max-length value must be in"
  498. " the range [0, %u]", UINT_MAX);
  499. return;
  500. }
  501. cfg->buckets[THROTTLE_BPS_WRITE].burst_length = arg->bps_write_max_length;
  502. }
  503. if (arg->has_iops_total_max_length) {
  504. if (arg->iops_total_max_length > UINT_MAX) {
  505. error_setg(errp, "iops-total-max-length value must be in"
  506. " the range [0, %u]", UINT_MAX);
  507. return;
  508. }
  509. cfg->buckets[THROTTLE_OPS_TOTAL].burst_length = arg->iops_total_max_length;
  510. }
  511. if (arg->has_iops_read_max_length) {
  512. if (arg->iops_read_max_length > UINT_MAX) {
  513. error_setg(errp, "iops-read-max-length value must be in"
  514. " the range [0, %u]", UINT_MAX);
  515. return;
  516. }
  517. cfg->buckets[THROTTLE_OPS_READ].burst_length = arg->iops_read_max_length;
  518. }
  519. if (arg->has_iops_write_max_length) {
  520. if (arg->iops_write_max_length > UINT_MAX) {
  521. error_setg(errp, "iops-write-max-length value must be in"
  522. " the range [0, %u]", UINT_MAX);
  523. return;
  524. }
  525. cfg->buckets[THROTTLE_OPS_WRITE].burst_length = arg->iops_write_max_length;
  526. }
  527. if (arg->has_iops_size) {
  528. cfg->op_size = arg->iops_size;
  529. }
  530. throttle_is_valid(cfg, errp);
  531. }
  532. /* write the options of a ThrottleConfig to a ThrottleLimits
  533. *
  534. * @cfg: the ThrottleConfig to read from
  535. * @var: the ThrottleLimits to write to
  536. */
  537. void throttle_config_to_limits(ThrottleConfig *cfg, ThrottleLimits *var)
  538. {
  539. var->bps_total = cfg->buckets[THROTTLE_BPS_TOTAL].avg;
  540. var->bps_read = cfg->buckets[THROTTLE_BPS_READ].avg;
  541. var->bps_write = cfg->buckets[THROTTLE_BPS_WRITE].avg;
  542. var->iops_total = cfg->buckets[THROTTLE_OPS_TOTAL].avg;
  543. var->iops_read = cfg->buckets[THROTTLE_OPS_READ].avg;
  544. var->iops_write = cfg->buckets[THROTTLE_OPS_WRITE].avg;
  545. var->bps_total_max = cfg->buckets[THROTTLE_BPS_TOTAL].max;
  546. var->bps_read_max = cfg->buckets[THROTTLE_BPS_READ].max;
  547. var->bps_write_max = cfg->buckets[THROTTLE_BPS_WRITE].max;
  548. var->iops_total_max = cfg->buckets[THROTTLE_OPS_TOTAL].max;
  549. var->iops_read_max = cfg->buckets[THROTTLE_OPS_READ].max;
  550. var->iops_write_max = cfg->buckets[THROTTLE_OPS_WRITE].max;
  551. var->bps_total_max_length = cfg->buckets[THROTTLE_BPS_TOTAL].burst_length;
  552. var->bps_read_max_length = cfg->buckets[THROTTLE_BPS_READ].burst_length;
  553. var->bps_write_max_length = cfg->buckets[THROTTLE_BPS_WRITE].burst_length;
  554. var->iops_total_max_length = cfg->buckets[THROTTLE_OPS_TOTAL].burst_length;
  555. var->iops_read_max_length = cfg->buckets[THROTTLE_OPS_READ].burst_length;
  556. var->iops_write_max_length = cfg->buckets[THROTTLE_OPS_WRITE].burst_length;
  557. var->iops_size = cfg->op_size;
  558. var->has_bps_total = true;
  559. var->has_bps_read = true;
  560. var->has_bps_write = true;
  561. var->has_iops_total = true;
  562. var->has_iops_read = true;
  563. var->has_iops_write = true;
  564. var->has_bps_total_max = true;
  565. var->has_bps_read_max = true;
  566. var->has_bps_write_max = true;
  567. var->has_iops_total_max = true;
  568. var->has_iops_read_max = true;
  569. var->has_iops_write_max = true;
  570. var->has_bps_read_max_length = true;
  571. var->has_bps_total_max_length = true;
  572. var->has_bps_write_max_length = true;
  573. var->has_iops_total_max_length = true;
  574. var->has_iops_read_max_length = true;
  575. var->has_iops_write_max_length = true;
  576. var->has_iops_size = true;
  577. }