]> git.baikalelectronics.ru Git - kernel.git/commit
block: fix race between switching elevator and removing queues
authorMing Lei <ming.lei@redhat.com>
Thu, 12 Sep 2019 04:02:24 +0000 (12:02 +0800)
committerJens Axboe <axboe@kernel.dk>
Thu, 12 Sep 2019 13:13:22 +0000 (07:13 -0600)
commitcbfcf09dfd9e751909a42fb204b2f6f16408c537
tree46b1761c8dc89e466d14e20abd659a3e76a1ca24
parent10dca924345572d2d35cba40ddc2af5b5fd985c5
block: fix race between switching elevator and removing queues

e2fc0270e742 ("block: split .sysfs_lock into two locks") starts to
release & actuire sysfs_lock again during switching elevator. So it
isn't enough to prevent switching elevator from happening by simply
clearing QUEUE_FLAG_REGISTERED with holding sysfs_lock, because
in-progress switch still can move on after re-acquiring the lock,
meantime the flag of QUEUE_FLAG_REGISTERED won't get checked.

Fixes this issue by checking 'q->elevator' directly & locklessly after
q->kobj is removed in blk_unregister_queue(), this way is safe because
q->elevator can't be changed at that time.

Fixes: e2fc0270e742 ("block: split .sysfs_lock into two locks")
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: Mike Snitzer <snitzer@redhat.com>
Cc: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-sysfs.c