linux-stable/block
Tejun Heo 0b80f9866e iocost: protect iocg->abs_vdebt with iocg->waitq.lock
abs_vdebt is an atomic_64 which tracks how much over budget a given cgroup
is and controls the activation of use_delay mechanism. Once a cgroup goes
over budget from forced IOs, it has to pay it back with its future budget.
The progress guarantee on debt paying comes from the iocg being active -
active iocgs are processed by the periodic timer, which ensures that as time
passes the debts dissipate and the iocg returns to normal operation.

However, both iocg activation and vdebt handling are asynchronous and a
sequence like the following may happen.

1. The iocg is in the process of being deactivated by the periodic timer.

2. A bio enters ioc_rqos_throttle(), calls iocg_activate() which returns
   without anything because it still sees that the iocg is already active.

3. The iocg is deactivated.

4. The bio from #2 is over budget but needs to be forced. It increases
   abs_vdebt and goes over the threshold and enables use_delay.

5. IO control is enabled for the iocg's subtree and now IOs are attributed
   to the descendant cgroups and the iocg itself no longer issues IOs.

This leaves the iocg with stuck abs_vdebt - it has debt but inactive and no
further IOs which can activate it. This can end up unduly punishing all the
descendants cgroups.

The usual throttling path has the same issue - the iocg must be active while
throttled to ensure that future event will wake it up - and solves the
problem by synchronizing the throttling path with a spinlock. abs_vdebt
handling is another form of overage handling and shares a lot of
characteristics including the fact that it isn't in the hottest path.

This patch fixes the above and other possible races by strictly
synchronizing abs_vdebt and use_delay handling with iocg->waitq.lock.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Vlad Dmitriev <vvd@fb.com>
Cc: stable@vger.kernel.org # v5.4+
Fixes: e1518f63f2 ("blk-iocost: Don't let merges push vtime into the future")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2020-05-05 09:23:18 -06:00
..
partitions block: remove the bd_openers checks in blk_drop_partitions 2020-04-30 10:25:43 -06:00
badblocks.c
bfq-cgroup.c block, bfq: invoke flush_idle_tree after reparent_active_queues in pd_offline 2020-03-21 14:31:03 -06:00
bfq-iosched.c block, bfq: turn put_queue into release_process_ref in __bfq_bic_change_cgroup 2020-03-21 14:31:00 -06:00
bfq-iosched.h block, bfq: turn put_queue into release_process_ref in __bfq_bic_change_cgroup 2020-03-21 14:31:00 -06:00
bfq-wf2q.c block, bfq: get a ref to a group when adding it to a service tree 2020-02-03 06:58:15 -07:00
bio-integrity.c
bio.c block: move bio_map_* to blk-map.c 2020-03-27 12:04:34 -06:00
blk-cgroup-rwstat.c
blk-cgroup-rwstat.h
blk-cgroup.c blkcg: don't offline parent blkcg first 2020-04-01 14:56:44 -06:00
blk-core.c block: return NULL in blk_alloc_queue() on error 2020-03-29 10:08:26 -06:00
blk-exec.c
blk-flush.c Revert "blkdev: check for valid request queue before issuing flush" 2020-03-27 10:23:44 -06:00
blk-integrity.c
blk-ioc.c block: Fix use-after-free issue accessing struct io_cq 2020-03-12 07:07:38 -06:00
blk-iocost.c iocost: protect iocg->abs_vdebt with iocg->waitq.lock 2020-05-05 09:23:18 -06:00
blk-iolatency.c
blk-lib.c
blk-map.c block: move bio_map_* to blk-map.c 2020-03-27 12:04:34 -06:00
blk-merge.c block: fix get_max_segment_size() overflow on 32bit arch 2020-01-14 13:37:40 -07:00
blk-mq-cpumap.c
blk-mq-debugfs-zoned.c
blk-mq-debugfs.c
blk-mq-debugfs.h
blk-mq-pci.c
blk-mq-rdma.c
blk-mq-sched.c blk-mq: insert flush request to the front of dispatch queue 2020-03-12 07:26:12 -06:00
blk-mq-sched.h
blk-mq-sysfs.c
blk-mq-tag.c blk-mq: Remove some unused function arguments 2020-02-26 10:34:41 -07:00
blk-mq-tag.h blk-mq: Remove some unused function arguments 2020-02-26 10:34:41 -07:00
blk-mq-virtio.c blk-mq: Fix typo in comment 2020-03-17 20:55:21 +01:00
blk-mq.c blk-mq: Put driver tag in blk_mq_dispatch_rq_list() when no budget 2020-04-16 09:27:03 -06:00
blk-mq.h blk-mq: Remove some unused function arguments 2020-02-26 10:34:41 -07:00
blk-pm.c
blk-pm.h
blk-rq-qos.c
blk-rq-qos.h
blk-settings.c for-5.7/drivers-2020-03-29 2020-03-30 11:43:51 -07:00
blk-softirq.c
blk-stat.c
blk-stat.h
blk-sysfs.c
blk-throttle.c
blk-timeout.c
blk-wbt.c blk-wbt: Use tracepoint_string() for wbt_step tracepoint string literals 2020-04-17 08:21:44 -06:00
blk-wbt.h
blk-zoned.c for-5.7/drivers-2020-03-29 2020-03-30 11:43:51 -07:00
blk.h block: move bio_map_* to blk-map.c 2020-03-27 12:04:34 -06:00
bounce.c
bsg-lib.c block: Fix the type of 'sts' in bsg_queue_rq() 2019-12-20 11:52:01 -07:00
bsg.c compat_ioctl: bsg: add handler 2020-01-03 09:33:21 +01:00
cmdline-parser.c
elevator.c
genhd.c for-5.7/block-2020-03-29 2020-03-30 11:20:13 -07:00
ioctl.c block: move block layer internals out of include/linux/genhd.h 2020-03-25 09:50:08 -06:00
ioprio.c
Kconfig block: Allow t10-pi to be modular 2020-01-06 20:59:04 -07:00
Kconfig.iosched
kyber-iosched.c
Makefile block: merge partition-generic.c and check.c 2020-03-24 07:57:08 -06:00
mq-deadline.c
opal_proto.h block: sed-opal: Change the check condition for regular session validity 2020-03-12 08:00:10 -06:00
scsi_ioctl.c scsi: core: Allow non-root users to perform ZBC commands 2020-03-16 18:26:31 -04:00
sed-opal.c block: sed-opal: Change the check condition for regular session validity 2020-03-12 08:00:10 -06:00
t10-pi.c block: Allow t10-pi to be modular 2020-01-06 20:59:04 -07:00