summaryrefslogtreecommitdiffstats
path: root/block/blk-throttle.c
diff options
context:
space:
mode:
authorShaohua Li <shli@fb.com>2017-03-27 13:51:29 -0400
committerJens Axboe <axboe@fb.com>2017-03-28 10:02:20 -0400
commit2ab5492de5009aabb584fd910dd4c7c4de1bea1a (patch)
tree045c2af2a0250832b325acd22d7c33d6f6b771bb /block/blk-throttle.c
parent869ab90f0ae0002ce6e9d3a5c75156ae8de48ffc (diff)
blk-throttle: use U64_MAX/UINT_MAX to replace -1
clean up the code to avoid using -1 Signed-off-by: Shaohua Li <shli@fb.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block/blk-throttle.c')
-rw-r--r--block/blk-throttle.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 8fab716e4059..0d5d85ba25ea 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -334,10 +334,10 @@ static struct blkg_policy_data *throtl_pd_alloc(gfp_t gfp, int node)
334 } 334 }
335 335
336 RB_CLEAR_NODE(&tg->rb_node); 336 RB_CLEAR_NODE(&tg->rb_node);
337 tg->bps[READ] = -1; 337 tg->bps[READ] = U64_MAX;
338 tg->bps[WRITE] = -1; 338 tg->bps[WRITE] = U64_MAX;
339 tg->iops[READ] = -1; 339 tg->iops[READ] = UINT_MAX;
340 tg->iops[WRITE] = -1; 340 tg->iops[WRITE] = UINT_MAX;
341 341
342 return &tg->pd; 342 return &tg->pd;
343} 343}
@@ -380,7 +380,7 @@ static void tg_update_has_rules(struct throtl_grp *tg)
380 380
381 for (rw = READ; rw <= WRITE; rw++) 381 for (rw = READ; rw <= WRITE; rw++)
382 tg->has_rules[rw] = (parent_tg && parent_tg->has_rules[rw]) || 382 tg->has_rules[rw] = (parent_tg && parent_tg->has_rules[rw]) ||
383 (tg->bps[rw] != -1 || tg->iops[rw] != -1); 383 (tg->bps[rw] != U64_MAX || tg->iops[rw] != UINT_MAX);
384} 384}
385 385
386static void throtl_pd_online(struct blkg_policy_data *pd) 386static void throtl_pd_online(struct blkg_policy_data *pd)
@@ -771,7 +771,7 @@ static bool tg_may_dispatch(struct throtl_grp *tg, struct bio *bio,
771 bio != throtl_peek_queued(&tg->service_queue.queued[rw])); 771 bio != throtl_peek_queued(&tg->service_queue.queued[rw]));
772 772
773 /* If tg->bps = -1, then BW is unlimited */ 773 /* If tg->bps = -1, then BW is unlimited */
774 if (tg->bps[rw] == -1 && tg->iops[rw] == -1) { 774 if (tg->bps[rw] == U64_MAX && tg->iops[rw] == UINT_MAX) {
775 if (wait) 775 if (wait)
776 *wait = 0; 776 *wait = 0;
777 return true; 777 return true;
@@ -1112,7 +1112,7 @@ static u64 tg_prfill_conf_u64(struct seq_file *sf, struct blkg_policy_data *pd,
1112 struct throtl_grp *tg = pd_to_tg(pd); 1112 struct throtl_grp *tg = pd_to_tg(pd);
1113 u64 v = *(u64 *)((void *)tg + off); 1113 u64 v = *(u64 *)((void *)tg + off);
1114 1114
1115 if (v == -1) 1115 if (v == U64_MAX)
1116 return 0; 1116 return 0;
1117 return __blkg_prfill_u64(sf, pd, v); 1117 return __blkg_prfill_u64(sf, pd, v);
1118} 1118}
@@ -1123,7 +1123,7 @@ static u64 tg_prfill_conf_uint(struct seq_file *sf, struct blkg_policy_data *pd,
1123 struct throtl_grp *tg = pd_to_tg(pd); 1123 struct throtl_grp *tg = pd_to_tg(pd);
1124 unsigned int v = *(unsigned int *)((void *)tg + off); 1124 unsigned int v = *(unsigned int *)((void *)tg + off);
1125 1125
1126 if (v == -1) 1126 if (v == UINT_MAX)
1127 return 0; 1127 return 0;
1128 return __blkg_prfill_u64(sf, pd, v); 1128 return __blkg_prfill_u64(sf, pd, v);
1129} 1129}
@@ -1197,7 +1197,7 @@ static ssize_t tg_set_conf(struct kernfs_open_file *of,
1197 if (sscanf(ctx.body, "%llu", &v) != 1) 1197 if (sscanf(ctx.body, "%llu", &v) != 1)
1198 goto out_finish; 1198 goto out_finish;
1199 if (!v) 1199 if (!v)
1200 v = -1; 1200 v = U64_MAX;
1201 1201
1202 tg = blkg_to_tg(ctx.blkg); 1202 tg = blkg_to_tg(ctx.blkg);
1203 1203
@@ -1272,17 +1272,17 @@ static u64 tg_prfill_max(struct seq_file *sf, struct blkg_policy_data *pd,
1272 1272
1273 if (!dname) 1273 if (!dname)
1274 return 0; 1274 return 0;
1275 if (tg->bps[READ] == -1 && tg->bps[WRITE] == -1 && 1275 if (tg->bps[READ] == U64_MAX && tg->bps[WRITE] == U64_MAX &&
1276 tg->iops[READ] == -1 && tg->iops[WRITE] == -1) 1276 tg->iops[READ] == UINT_MAX && tg->iops[WRITE] == UINT_MAX)
1277 return 0; 1277 return 0;
1278 1278
1279 if (tg->bps[READ] != -1) 1279 if (tg->bps[READ] != U64_MAX)
1280 snprintf(bufs[0], sizeof(bufs[0]), "%llu", tg->bps[READ]); 1280 snprintf(bufs[0], sizeof(bufs[0]), "%llu", tg->bps[READ]);
1281 if (tg->bps[WRITE] != -1) 1281 if (tg->bps[WRITE] != U64_MAX)
1282 snprintf(bufs[1], sizeof(bufs[1]), "%llu", tg->bps[WRITE]); 1282 snprintf(bufs[1], sizeof(bufs[1]), "%llu", tg->bps[WRITE]);
1283 if (tg->iops[READ] != -1) 1283 if (tg->iops[READ] != UINT_MAX)
1284 snprintf(bufs[2], sizeof(bufs[2]), "%u", tg->iops[READ]); 1284 snprintf(bufs[2], sizeof(bufs[2]), "%u", tg->iops[READ]);
1285 if (tg->iops[WRITE] != -1) 1285 if (tg->iops[WRITE] != UINT_MAX)
1286 snprintf(bufs[3], sizeof(bufs[3]), "%u", tg->iops[WRITE]); 1286 snprintf(bufs[3], sizeof(bufs[3]), "%u", tg->iops[WRITE]);
1287 1287
1288 seq_printf(sf, "%s rbps=%s wbps=%s riops=%s wiops=%s\n", 1288 seq_printf(sf, "%s rbps=%s wbps=%s riops=%s wiops=%s\n",
@@ -1320,7 +1320,7 @@ static ssize_t tg_set_max(struct kernfs_open_file *of,
1320 while (true) { 1320 while (true) {
1321 char tok[27]; /* wiops=18446744073709551616 */ 1321 char tok[27]; /* wiops=18446744073709551616 */
1322 char *p; 1322 char *p;
1323 u64 val = -1; 1323 u64 val = U64_MAX;
1324 int len; 1324 int len;
1325 1325
1326 if (sscanf(ctx.body, "%26s%n", tok, &len) != 1) 1326 if (sscanf(ctx.body, "%26s%n", tok, &len) != 1)