Patch "blk-mq: initialize mq kobjects in blk_mq_init_allocated_queue()" has been added to the 4.9-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
blk-mq: initialize mq kobjects in blk_mq_init_allocated_queue()
to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
blk-mq-initialize-mq-kobjects-in-blk_mq_init_allocated_queue.patch
and it can be found in the queue-4.9 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From foo@baz Tue Dec 12 13:26:17 CET 2017
From: Ming Lei <[email protected]>
Date: Wed, 22 Feb 2017 18:13:59 +0800
Subject: blk-mq: initialize mq kobjects in blk_mq_init_allocated_queue()
From: Ming Lei <[email protected]>
[ Upstream commit 737f98cfe7de8df7433a4d846850aa8efa44bd48 ]
Both q->mq_kobj and sw queues' kobjects should have been initialized once, instead of doing that each add_disk context.
Also this patch removes clearing of ctx in blk_mq_init_cpu_queues() because percpu allocator fills zero to allocated variable.
This patch fixes one issue[1] reported from Omar.
[1] kernel wearning when doing unbind/bind on one scsi-mq device
[ 19.347924] kobject (ffff8800791ea0b8): tried to init an initialized object, something is seriously wrong. [ 19.349781] CPU: 1 PID: 84 Comm: kworker/u8:1 Not tainted 4.10.0-rc7-00210-g53f39eeaa263 #34 [ 19.350686] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.1-20161122_114906-anatol 04/01/2014 [ 19.350920] Workqueue: events_unbound async_run_entry_fn [ 19.350920] Call Trace: [ 19.350920] dump_stack+0x63/0x83 [ 19.350920] kobject_init+0x77/0x90 [ 19.350920] blk_mq_register_dev+0x40/0x130 [ 19.350920] blk_register_queue+0xb6/0x190 [ 19.350920] device_add_disk+0x1ec/0x4b0 [ 19.350920] sd_probe_async+0x10d/0x1c0 [sd_mod] [ 19.350920] async_run_entry_fn+0x48/0x150 [ 19.350920] process_one_work+0x1d0/0x480 [ 19.350920] worker_thread+0x48/0x4e0 [ 19.350920] kthread+0x101/0x140 [ 19.350920] ? process_one_work+0x480/0x480 [ 19.350920] ? kthread_create_on_node+0x60/0x60 [ 19.350920] ret_from_fork+0x2c/0x40
--- block/blk-mq-sysfs.c | 4 +--- block/blk-mq.c | 4 +++- block/blk-mq.h | 1 + 3 files changed, 5 insertions(+), 4 deletions(-)
block/blk-mq-sysfs.c +1 -3
@@ -429,7 +429,7 @@ void blk_mq_hctx_kobj_init(struct blk_mqkobject_init (&hctx->kobj, &blk_mq_hw_ktype); } -static void blk_mq_sysfs_init (struct request_queue *q) +void blk_mq_sysfs_init (struct request_queue *q) {struct blk_mq_ctx *ctx;int cpu;
@@ -449,8 +449,6 @@ int blk_mq_register_dev(struct device *dblk_mq_disable_hotplug (); -blk_mq_sysfs_init (q); - ret =kobject_add (&q->mq_kobj,kobject_get (&dev->kobj),"%s" ,"mq" );if (ret <0 ) goto out;
block/blk-mq.c +3 -1
@@ -1707,7 +1707,6 @@ static void blk_mq_init_cpu_queues(strucstruct blk_mq_ctx *__ctx =per_cpu_ptr (q->queue_ctx, i);struct blk_mq_hw_ctx *hctx; -memset (__ctx,0 ,sizeof (*__ctx)); __ctx->cpu = i;spin_lock_init (&__ctx->lock);INIT_LIST_HEAD (&__ctx->rq_list);
@@ -1970,6 +1969,9 @@ struct request_queue *blk_mq_init_allocaif (!q->queue_ctx) goto err_exit; +/* init q->mq_kobj and sw queues' kobjects */ +blk_mq_sysfs_init (q); + q->queue_hw_ctx =kzalloc_node (nr_cpu_ids *sizeof (*(q->queue_hw_ctx)),GFP_KERNEL , set->numa_node);if (!q->queue_hw_ctx)
block/blk-mq.h +1 -0
@@ -50,6 +50,7 @@ static inline struct blk_mq_hw_ctx *blk_/* * sysfs helpers */ +extern void blk_mq_sysfs_init (struct request_queue *q);extern int blk_mq_sysfs_register (struct request_queue *q);extern void blk_mq_sysfs_unregister (struct request_queue *q);extern void blk_mq_hctx_kobj_init (struct blk_mq_hw_ctx *hctx);
Patches currently in stable-queue which might be from [email protected] are
queue-4.9/blk-mq-initialize-mq-kobjects-in-blk_mq_init_allocated_queue.patch