summaryrefslogtreecommitdiffstats
path: root/block/elevator.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2018-05-31 19:11:39 +0200
committerJens Axboe <axboe@kernel.dk>2018-06-01 07:38:19 -0600
commitacddf3b308f6b6e23653de02e1abf98f402f1f12 (patch)
tree296aa44427ee604597d22412d212ae9744f7dd92 /block/elevator.c
parentddb7253254fee6922764043101f8b28b6a00595d (diff)
downloadlinux-stable-acddf3b308f6b6e23653de02e1abf98f402f1f12.tar.gz
linux-stable-acddf3b308f6b6e23653de02e1abf98f402f1f12.tar.bz2
linux-stable-acddf3b308f6b6e23653de02e1abf98f402f1f12.zip
block: move sysfs_lock into elevator_init
Both callers take just around so function call, so move it in. Also remove the now pointless blk_mq_sched_init wrapper. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com> Tested-by: Damien Le Moal <damien.lemoal@wdc.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/elevator.c')
-rw-r--r--block/elevator.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/block/elevator.c b/block/elevator.c
index 9276540af2a1..d6480e70816e 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -202,16 +202,15 @@ static void elevator_release(struct kobject *kobj)
int elevator_init(struct request_queue *q)
{
struct elevator_type *e = NULL;
- int err;
+ int err = 0;
/*
* q->sysfs_lock must be held to provide mutual exclusion between
* elevator_switch() and here.
*/
- lockdep_assert_held(&q->sysfs_lock);
-
+ mutex_lock(&q->sysfs_lock);
if (unlikely(q->elevator))
- return 0;
+ goto out_unlock;
/*
* Use the default elevator specified by config boot param for
@@ -237,7 +236,7 @@ int elevator_init(struct request_queue *q)
if (q->nr_hw_queues == 1)
e = elevator_get(q, "mq-deadline", false);
if (!e)
- return 0;
+ goto out_unlock;
} else
e = elevator_get(q, CONFIG_DEFAULT_IOSCHED, false);
@@ -255,6 +254,8 @@ int elevator_init(struct request_queue *q)
err = e->ops.sq.elevator_init_fn(q, e);
if (err)
elevator_put(e);
+out_unlock:
+ mutex_unlock(&q->sysfs_lock);
return err;
}