- if (has_r) {
- l += snprintf(p + l, left - l, "[r=%s", rate_str[DDIR_READ]);
- if (!has_w)
- l += snprintf(p + l, left - l, "]");
- }
- if (has_w) {
- if (has_r)
- l += snprintf(p + l, left - l, ",");
- else
- l += snprintf(p + l, left - l, "[");
- l += snprintf(p + l, left - l, "w=%s", rate_str[DDIR_WRITE]);
- if (!has_t)
- l += snprintf(p + l, left - l, "]");
- }
- if (has_t) {
- if (has_r || has_w)
- l += snprintf(p + l, left - l, ",");
- else if (!has_r && !has_w)
- l += snprintf(p + l, left - l, "[");
- l += snprintf(p + l, left - l, "t=%s]", rate_str[DDIR_TRIM]);
- }
- if (has_r) {
- l += snprintf(p + l, left - l, "[r=%s", iops_str[DDIR_READ]);
- if (!has_w)
- l += snprintf(p + l, left - l, " IOPS]");
- }
- if (has_w) {
- if (has_r)
- l += snprintf(p + l, left - l, ",");
- else
- l += snprintf(p + l, left - l, "[");
- l += snprintf(p + l, left - l, "w=%s", iops_str[DDIR_WRITE]);
- if (!has_t)
- l += snprintf(p + l, left - l, " IOPS]");
+ l += snprintf(p + l, left - l, "[");
+ sep = "";
+ for_each_rw_ddir(ddir) {
+ if (has[ddir]) {
+ l += snprintf(p + l, left - l, "%s%c=%s",
+ sep, c[ddir], rate_str[ddir]);
+ sep = ",";
+ }