diff options
author | Eric Biggers <ebiggers@google.com> | 2022-01-24 13:59:36 -0800 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2022-02-28 06:40:23 -0700 |
commit | f5ec592dd3bcf7c91f7c262a7f5011e001d269cd (patch) | |
tree | 4907b114a9e1fd2a3e4c05855fffc75ca2010d7e /block/elevator.c | |
parent | 483546c11d702fd6f74c8c3f8123b7672def10b2 (diff) | |
download | lwn-f5ec592dd3bcf7c91f7c262a7f5011e001d269cd.tar.gz lwn-f5ec592dd3bcf7c91f7c262a7f5011e001d269cd.zip |
block: simplify calling convention of elv_unregister_queue()
Make elv_unregister_queue() a no-op if q->elevator is NULL or is not
registered.
This simplifies the existing callers, as well as the future caller in
the error path of blk_register_queue().
Also don't bother checking whether q is NULL, since it never is.
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20220124215938.2769-2-ebiggers@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/elevator.c')
-rw-r--r-- | block/elevator.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/block/elevator.c b/block/elevator.c index 6847ab6e7aa5..a842e4b8ebc6 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -516,9 +516,11 @@ int elv_register_queue(struct request_queue *q, bool uevent) void elv_unregister_queue(struct request_queue *q) { + struct elevator_queue *e = q->elevator; + lockdep_assert_held(&q->sysfs_lock); - if (q) { + if (e && e->registered) { struct elevator_queue *e = q->elevator; kobject_uevent(&e->kobj, KOBJ_REMOVE); @@ -593,9 +595,7 @@ int elevator_switch_mq(struct request_queue *q, lockdep_assert_held(&q->sysfs_lock); if (q->elevator) { - if (q->elevator->registered) - elv_unregister_queue(q); - + elv_unregister_queue(q); ioc_clear_queue(q); blk_mq_sched_free_rqs(q); elevator_exit(q); |