Skip to content

Commit 5a93b60

Browse files
Ming Leiaxboe
authored andcommitted
block: don't try to throttle split bio if iops limit isn't set
We need to throttle split bio in case of IOPS limit even though the split bio has been marked as BIO_THROTTLED since block layer accounts split bio actually. If only throughput throttle is setup, no need to throttle any more if BIO_THROTTLED is set since we have accounted & considered the whole bio bytes already. Add one flag of THROTL_TG_HAS_IOPS_LIMIT for serving this purpose. Acked-by: Tejun Heo <tj@kernel.org> Signed-off-by: Ming Lei <ming.lei@redhat.com> Link: https://lore.kernel.org/r/20220216044514.2903784-8-ming.lei@redhat.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 9f5ede3 commit 5a93b60

2 files changed

Lines changed: 25 additions & 7 deletions

File tree

block/blk-throttle.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@
4141
/* A workqueue to queue throttle related work */
4242
static struct workqueue_struct *kthrotld_workqueue;
4343

44-
enum tg_state_flags {
45-
THROTL_TG_PENDING = 1 << 0, /* on parent's pending tree */
46-
THROTL_TG_WAS_EMPTY = 1 << 1, /* bio_lists[] became non-empty */
47-
};
48-
4944
#define rb_entry_tg(node) rb_entry((node), struct throtl_grp, rb_node)
5045

5146
/* We measure latency for request size from <= 4k to >= 1M */
@@ -425,12 +420,24 @@ static void tg_update_has_rules(struct throtl_grp *tg)
425420
struct throtl_grp *parent_tg = sq_to_tg(tg->service_queue.parent_sq);
426421
struct throtl_data *td = tg->td;
427422
int rw;
423+
int has_iops_limit = 0;
424+
425+
for (rw = READ; rw <= WRITE; rw++) {
426+
unsigned int iops_limit = tg_iops_limit(tg, rw);
428427

429-
for (rw = READ; rw <= WRITE; rw++)
430428
tg->has_rules[rw] = (parent_tg && parent_tg->has_rules[rw]) ||
431429
(td->limit_valid[td->limit_index] &&
432430
(tg_bps_limit(tg, rw) != U64_MAX ||
433-
tg_iops_limit(tg, rw) != UINT_MAX));
431+
iops_limit != UINT_MAX));
432+
433+
if (iops_limit != UINT_MAX)
434+
has_iops_limit = 1;
435+
}
436+
437+
if (has_iops_limit)
438+
tg->flags |= THROTL_TG_HAS_IOPS_LIMIT;
439+
else
440+
tg->flags &= ~THROTL_TG_HAS_IOPS_LIMIT;
434441
}
435442

436443
static void throtl_pd_online(struct blkg_policy_data *pd)

block/blk-throttle.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ struct throtl_service_queue {
5252
struct timer_list pending_timer; /* fires on first_pending_disptime */
5353
};
5454

55+
enum tg_state_flags {
56+
THROTL_TG_PENDING = 1 << 0, /* on parent's pending tree */
57+
THROTL_TG_WAS_EMPTY = 1 << 1, /* bio_lists[] became non-empty */
58+
THROTL_TG_HAS_IOPS_LIMIT = 1 << 2, /* tg has iops limit */
59+
};
60+
5561
enum {
5662
LIMIT_LOW,
5763
LIMIT_MAX,
@@ -170,6 +176,11 @@ static inline bool blk_throtl_bio(struct bio *bio)
170176
{
171177
struct throtl_grp *tg = blkg_to_tg(bio->bi_blkg);
172178

179+
/* no need to throttle bps any more if the bio has been throttled */
180+
if (bio_flagged(bio, BIO_THROTTLED) &&
181+
!(tg->flags & THROTL_TG_HAS_IOPS_LIMIT))
182+
return false;
183+
173184
if (!tg->has_rules[bio_data_dir(bio)])
174185
return false;
175186

0 commit comments

Comments
 (0)