From: Li Lingfeng lilingfeng3@huawei.com
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I6HOKY CVE: NA
--------------------------------
commit 92567b1d6f5a ("block: split .sysfs_lock into two locks") introduce new member 'sysfs_dir_lock' in struct request_queue, thus move it to request_queue_wrapper to avoid kabi broken.
Fixes: 92567b1d6f5a ("block: split .sysfs_lock into two locks")
Signed-off-by: Li Lingfeng lilingfeng3@huawei.com Reviewed-by: Hou Tao houtao1@huawei.com Signed-off-by: Yongqiang Liu liuyongqiang13@huawei.com --- block/blk-core.c | 2 +- block/blk-mq-sysfs.c | 16 ++++++++-------- block/blk-sysfs.c | 10 +++++----- block/blk.h | 1 + include/linux/blkdev.h | 1 - 5 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c index dbfcf2dc735d..acf5585b0557 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1337,7 +1337,7 @@ struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id, mutex_init(&q->blk_trace_mutex); #endif mutex_init(&q->sysfs_lock); - mutex_init(&q->sysfs_dir_lock); + mutex_init(&q_wrapper->sysfs_dir_lock); spin_lock_init(&q->__queue_lock);
q->queue_lock = lock ? : &q->__queue_lock; diff --git a/block/blk-mq-sysfs.c b/block/blk-mq-sysfs.c index 87fe2708d188..cace619d7421 100644 --- a/block/blk-mq-sysfs.c +++ b/block/blk-mq-sysfs.c @@ -283,7 +283,7 @@ void blk_mq_unregister_dev(struct device *dev, struct request_queue *q) struct blk_mq_hw_ctx *hctx; int i;
- lockdep_assert_held(&q->sysfs_dir_lock); + lockdep_assert_held(&queue_to_wrapper(q)->sysfs_dir_lock);
queue_for_each_hw_ctx(q, hctx, i) blk_mq_unregister_hctx(hctx); @@ -333,7 +333,7 @@ int __blk_mq_register_dev(struct device *dev, struct request_queue *q) int ret, i;
WARN_ON_ONCE(!q->kobj.parent); - lockdep_assert_held(&q->sysfs_dir_lock); + lockdep_assert_held(&queue_to_wrapper(q)->sysfs_dir_lock);
ret = kobject_add(q->mq_kobj, kobject_get(&dev->kobj), "%s", "mq"); if (ret < 0) @@ -366,9 +366,9 @@ int blk_mq_register_dev(struct device *dev, struct request_queue *q) { int ret;
- mutex_lock(&q->sysfs_dir_lock); + mutex_lock(&queue_to_wrapper(q)->sysfs_dir_lock); ret = __blk_mq_register_dev(dev, q); - mutex_unlock(&q->sysfs_dir_lock); + mutex_unlock(&queue_to_wrapper(q)->sysfs_dir_lock);
return ret; } @@ -379,7 +379,7 @@ void blk_mq_sysfs_unregister(struct request_queue *q) struct blk_mq_hw_ctx *hctx; int i;
- mutex_lock(&q->sysfs_dir_lock); + mutex_lock(&queue_to_wrapper(q)->sysfs_dir_lock); if (!q->mq_sysfs_init_done) goto unlock;
@@ -387,7 +387,7 @@ void blk_mq_sysfs_unregister(struct request_queue *q) blk_mq_unregister_hctx(hctx);
unlock: - mutex_unlock(&q->sysfs_dir_lock); + mutex_unlock(&queue_to_wrapper(q)->sysfs_dir_lock); }
int blk_mq_sysfs_register(struct request_queue *q) @@ -395,7 +395,7 @@ int blk_mq_sysfs_register(struct request_queue *q) struct blk_mq_hw_ctx *hctx; int i, ret = 0;
- mutex_lock(&q->sysfs_dir_lock); + mutex_lock(&queue_to_wrapper(q)->sysfs_dir_lock); if (!q->mq_sysfs_init_done) goto unlock;
@@ -406,7 +406,7 @@ int blk_mq_sysfs_register(struct request_queue *q) }
unlock: - mutex_unlock(&q->sysfs_dir_lock); + mutex_unlock(&queue_to_wrapper(q)->sysfs_dir_lock);
return ret; } diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 711724a41fc7..1b00c8f5c9d6 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -946,7 +946,7 @@ int blk_register_queue(struct gendisk *disk) if (ret) return ret;
- mutex_lock(&q->sysfs_dir_lock); + mutex_lock(&queue_to_wrapper(q)->sysfs_dir_lock);
ret = kobject_add(&q->kobj, kobject_get(&dev->kobj), "%s", "queue"); if (ret < 0) { @@ -964,7 +964,7 @@ int blk_register_queue(struct gendisk *disk) ret = elv_register_queue(q, false); if (ret) { mutex_unlock(&q->sysfs_lock); - mutex_unlock(&q->sysfs_dir_lock); + mutex_unlock(&queue_to_wrapper(q)->sysfs_dir_lock); kobject_del(&q->kobj); blk_trace_remove_sysfs(dev); kobject_put(&dev->kobj); @@ -986,7 +986,7 @@ int blk_register_queue(struct gendisk *disk)
ret = 0; unlock: - mutex_unlock(&q->sysfs_dir_lock); + mutex_unlock(&queue_to_wrapper(q)->sysfs_dir_lock);
/* * SCSI probing may synchronously create and destroy a lot of @@ -1036,7 +1036,7 @@ void blk_unregister_queue(struct gendisk *disk) blk_queue_flag_clear(QUEUE_FLAG_REGISTERED, q); mutex_unlock(&q->sysfs_lock);
- mutex_lock(&q->sysfs_dir_lock); + mutex_lock(&queue_to_wrapper(q)->sysfs_dir_lock); /* * Remove the sysfs attributes before unregistering the queue data * structures that can be modified through sysfs. @@ -1050,7 +1050,7 @@ void blk_unregister_queue(struct gendisk *disk) if (q->request_fn || (q->mq_ops && q->elevator)) elv_unregister_queue(q); mutex_unlock(&q->sysfs_lock); - mutex_unlock(&q->sysfs_dir_lock); + mutex_unlock(&queue_to_wrapper(q)->sysfs_dir_lock);
/* Now that we've deleted all child objects, we can delete the queue. */ kobject_uevent(&q->kobj, KOBJ_REMOVE); diff --git a/block/blk.h b/block/blk.h index 2c73160dff6c..9269bb6b14f8 100644 --- a/block/blk.h +++ b/block/blk.h @@ -54,6 +54,7 @@ struct request_queue_wrapper { struct cpumask dispatch_async_cpus; int __percpu *last_dispatch_cpu; #endif + struct mutex sysfs_dir_lock; };
#define queue_to_wrapper(q) \ diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 0c8f2a28f163..41d235ee579a 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -655,7 +655,6 @@ struct request_queue { struct delayed_work requeue_work;
struct mutex sysfs_lock; - struct mutex sysfs_dir_lock;
/* * for reusing dead hctx instance in case of updating