]> git.baikalelectronics.ru Git - kernel.git/commitdiff
block: simplify calling convention of elv_unregister_queue()
authorEric Biggers <ebiggers@google.com>
Mon, 24 Jan 2022 21:59:36 +0000 (13:59 -0800)
committerJens Axboe <axboe@kernel.dk>
Mon, 28 Feb 2022 13:40:23 +0000 (06:40 -0700)
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>
block/blk-sysfs.c
block/elevator.c

index 4c6b7dff71e5bf5d9af6892f16d4aa7e68e856ac..49854c7ea29b08541f83f4858411374b3af4e035 100644 (file)
@@ -960,8 +960,7 @@ void blk_unregister_queue(struct gendisk *disk)
        blk_trace_remove_sysfs(disk_to_dev(disk));
 
        mutex_lock(&q->sysfs_lock);
-       if (q->elevator)
-               elv_unregister_queue(q);
+       elv_unregister_queue(q);
        disk_unregister_independent_access_ranges(disk);
        mutex_unlock(&q->sysfs_lock);
        mutex_unlock(&q->sysfs_dir_lock);
index 6847ab6e7aa5060ad6507e6fb2638087efcf5f7a..a842e4b8ebc6603c60dd7083e62133c9b820dd64 100644 (file)
@@ -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);