linux-stable/block
Jinke Han 08ef66e800 block: don't allow the same type rq_qos add more than once
[ Upstream commit 14a6e2eb7d ]

In our test of iocost, we encountered some list add/del corruptions of
inner_walk list in ioc_timer_fn.

The reason can be described as follows:

cpu 0					cpu 1
ioc_qos_write				ioc_qos_write

ioc = q_to_ioc(queue);
if (!ioc) {
        ioc = kzalloc();
					ioc = q_to_ioc(queue);
					if (!ioc) {
						ioc = kzalloc();
						...
						rq_qos_add(q, rqos);
					}
        ...
        rq_qos_add(q, rqos);
        ...
}

When the io.cost.qos file is written by two cpus concurrently, rq_qos may
be added to one disk twice. In that case, there will be two iocs enabled
and running on one disk. They own different iocgs on their active list. In
the ioc_timer_fn function, because of the iocgs from two iocs have the
same root iocg, the root iocg's walk_list may be overwritten by each other
and this leads to list add/del corruptions in building or destroying the
inner_walk list.

And so far, the blk-rq-qos framework works in case that one instance for
one type rq_qos per queue by default. This patch make this explicit and
also fix the crash above.

Signed-off-by: Jinke Han <hanjinke.666@bytedance.com>
Reviewed-by: Muchun Song <songmuchun@bytedance.com>
Acked-by: Tejun Heo <tj@kernel.org>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20220720093616.70584-1-hanjinke.666@bytedance.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-08-17 14:42:24 +02:00
..
partitions block: remove genhd.h 2022-02-02 07:49:59 -07:00
Kconfig block: add pi for extended integrity 2022-03-07 12:48:35 -07:00
Kconfig.iosched block: only build the icq tracking code when needed 2021-12-16 10:59:02 -07:00
Makefile blk-crypto: show crypto capabilities in sysfs 2022-02-28 06:40:23 -07:00
badblocks.c
bdev.c Merge branch 'akpm' (patches from Andrew) 2022-03-22 16:11:53 -07:00
bfq-cgroup.c bfq: Make sure bfqg for which we are queueing requests is online 2022-06-09 10:30:42 +02:00
bfq-iosched.c bfq: Get rid of __bio_blkcg() usage 2022-06-09 10:30:42 +02:00
bfq-iosched.h bfq: Get rid of __bio_blkcg() usage 2022-06-09 10:30:42 +02:00
bfq-wf2q.c block, bfq: cleanup bfq_bfqq_to_bfqg() 2022-02-18 06:13:00 -07:00
bio-integrity.c for-5.18/block-2022-03-18 2022-03-21 16:48:55 -07:00
bio.c block: ensure iov_iter advances for added pages 2022-08-17 14:41:57 +02:00
blk-cgroup-rwstat.c
blk-cgroup-rwstat.h block: partition include/linux/blk-cgroup.h 2022-02-11 10:02:41 -07:00
blk-cgroup.c block: fix bio_clone_blkg_association() to associate with proper blkcg_gq 2022-06-09 10:30:57 +02:00
blk-cgroup.h blk-cgroup: always terminate io.stat lines 2022-06-09 10:30:15 +02:00
blk-core.c block: disable the elevator int del_gendisk 2022-06-29 09:04:30 +02:00
blk-crypto-fallback.c block: remove the per-bio/request write hint 2022-03-07 12:45:57 -07:00
blk-crypto-internal.h blk-crypto: show crypto capabilities in sysfs 2022-02-28 06:40:23 -07:00
blk-crypto-profile.c blk-crypto: remove blk_crypto_unregister() 2021-11-29 06:38:51 -07:00
blk-crypto-sysfs.c blk-crypto: show crypto capabilities in sysfs 2022-02-28 06:40:23 -07:00
blk-crypto.c blk-crypto: show crypto capabilities in sysfs 2022-02-28 06:40:23 -07:00
blk-flush.c block: pass a block_device and opf to bio_init 2022-02-02 07:49:59 -07:00
blk-ia-ranges.c block: Fix potential deadlock in blk_ia_range_sysfs_show() 2022-06-09 10:30:44 +02:00
blk-integrity.c blk-crypto: remove blk_crypto_unregister() 2021-11-29 06:38:51 -07:00
blk-ioc.c block: fix default IO priority handling again 2022-08-11 13:20:39 +02:00
blk-iocost.c block: don't allow the same type rq_qos add more than once 2022-08-17 14:42:24 +02:00
blk-iolatency.c block: don't allow the same type rq_qos add more than once 2022-08-17 14:42:24 +02:00
blk-ioprio.c block: partition include/linux/blk-cgroup.h 2022-02-11 10:02:41 -07:00
blk-ioprio.h block: Introduce the ioprio rq-qos policy 2021-06-21 15:03:40 -06:00
blk-lib.c SCSI misc on 20220324 2022-03-24 19:37:53 -07:00
blk-map.c block-map: add __GFP_ZERO flag for alloc_page in function bio_copy_kern 2022-02-17 07:54:03 -07:00
blk-merge.c for-5.18/write-streams-2022-03-18 2022-03-26 11:51:46 -07:00
blk-mq-cpumap.c
blk-mq-debugfs-zoned.c
blk-mq-debugfs.c block: serialize all debugfs operations using q->debugfs_mutex 2022-08-17 14:42:24 +02:00
blk-mq-debugfs.h block: serialize all debugfs operations using q->debugfs_mutex 2022-08-17 14:42:24 +02:00
blk-mq-pci.c
blk-mq-rdma.c
blk-mq-sched.c block: serialize all debugfs operations using q->debugfs_mutex 2022-08-17 14:42:24 +02:00
blk-mq-sched.h block: move blk_mq_sched_assign_ioc to blk-ioc.c 2021-11-29 06:41:29 -07:00
blk-mq-sysfs.c blk-mq: prepare for implementing hctx table via xarray 2022-03-08 17:57:19 -07:00
blk-mq-tag.c blk-mq: manage hctx map via xarray 2022-03-08 19:39:38 -07:00
blk-mq-tag.h blk-mq: Delete busy_iter_fn 2021-12-06 13:18:47 -07:00
blk-mq-virtio.c
blk-mq.c block: pop cached rq before potentially blocking rq_qos_throttle() 2022-06-29 09:04:33 +02:00
blk-mq.h blk-mq: manage hctx map via xarray 2022-03-08 19:39:38 -07:00
blk-pm.c scsi: block: pm: Always set request queue runtime active in blk_post_runtime_resume() 2021-12-22 23:38:29 -05:00
blk-pm.h
blk-rq-qos.c block: serialize all debugfs operations using q->debugfs_mutex 2022-08-17 14:42:24 +02:00
blk-rq-qos.h block: don't allow the same type rq_qos add more than once 2022-08-17 14:42:24 +02:00
blk-settings.c scsi: block: Remove REQ_OP_WRITE_SAME support 2022-02-22 21:11:08 -05:00
blk-stat.c block: make queue stat accounting a reference 2021-12-14 17:23:05 -07:00
blk-stat.h block: make queue stat accounting a reference 2021-12-14 17:23:05 -07:00
blk-sysfs.c block: serialize all debugfs operations using q->debugfs_mutex 2022-08-17 14:42:24 +02:00
blk-throttle.c blk-throttle: Set BIO_THROTTLED when bio has been throttled 2022-06-09 10:29:45 +02:00
blk-throttle.h block: cancel all throttled bios in del_gendisk() 2022-03-18 09:57:56 -06:00
blk-timeout.c
blk-wbt.c block: don't allow the same type rq_qos add more than once 2022-08-17 14:42:24 +02:00
blk-wbt.h blk-wbt: remove wbt_track stub 2022-03-31 12:58:38 -06:00
blk-zoned.c SCSI misc on 20220324 2022-03-24 19:37:53 -07:00
blk.h SCSI misc on 20220324 2022-03-24 19:37:53 -07:00
bounce.c for-5.18/write-streams-2022-03-18 2022-03-26 11:51:46 -07:00
bsg-lib.c block: remove the gendisk argument to blk_execute_rq 2021-11-29 06:41:29 -07:00
bsg.c scsi: bsg: Fix device unregistration 2021-09-14 00:22:15 -04:00
disk-events.c block: remove genhd.h 2022-02-02 07:49:59 -07:00
elevator.c for-5.18/block-2022-03-18 2022-03-21 16:48:55 -07:00
elevator.h block: move elevator.h to block/ 2021-10-18 06:17:01 -06:00
fops.c for-5.18/write-streams-2022-03-18 2022-03-26 11:51:46 -07:00
genhd.c block: disable the elevator int del_gendisk 2022-06-29 09:04:30 +02:00
holder.c block: remove genhd.h 2022-02-02 07:49:59 -07:00
ioctl.c block/compat_ioctl: fix range check in BLKGETSIZE 2022-04-15 06:32:40 -06:00
ioprio.c block: fix default IO priority handling again 2022-08-11 13:20:39 +02:00
kyber-iosched.c block: make queue stat accounting a reference 2021-12-14 17:23:05 -07:00
mq-deadline.c block/mq-deadline: Set the fifo_time member also if inserting at head 2022-05-13 17:02:46 -06:00
opal_proto.h
sed-opal.c block: remove genhd.h 2022-02-02 07:49:59 -07:00
t10-pi.c block: add pi for extended integrity 2022-03-07 12:48:35 -07:00