- rate = (td->this_io_bytes[ddir] - td->rate_bytes) / spent;
- if (rate < td->ratemin) {
- fprintf(f_out, "%s: min rate %u not met, got %luKiB/sec\n", td->name, td->ratemin, rate);
- return 1;
+ if (td->o.rate) {
+ /*
+ * check bandwidth specified rate
+ */
+ if (bytes < td->rate_bytes) {
+ log_err("%s: min rate %u not met\n", td->o.name, td->o.ratemin);
+ return 1;
+ } else {
+ rate = (bytes - td->rate_bytes) / spent;
+ if (rate < td->o.ratemin || bytes < td->rate_bytes) {
+ log_err("%s: min rate %u not met, got %luKiB/sec\n", td->o.name, td->o.ratemin, rate);
+ return 1;
+ }
+ }
+ } else {
+ /*
+ * checks iops specified rate
+ */
+ if (iops < td->o.rate_iops) {
+ log_err("%s: min iops rate %u not met\n", td->o.name, td->o.rate_iops);
+ return 1;
+ } else {
+ rate = (iops - td->rate_blocks) / spent;
+ if (rate < td->o.rate_iops_min || iops < td->rate_blocks) {
+ log_err("%s: min iops rate %u not met, got %lu\n", td->o.name, td->o.rate_iops_min, rate);
+ }
+ }