block: Make blk_cleanup_queue() wait until request_fn finished
authorBart Van Assche <bvanassche@acm.org>
Wed, 28 Nov 2012 12:46:45 +0000 (13:46 +0100)
committerJens Axboe <axboe@kernel.dk>
Thu, 6 Dec 2012 13:33:00 +0000 (14:33 +0100)
commit24faf6f604efe18236bded4303009fc252913bf0
treebc4d35a38c44a37ffd718089729ae59b23d50d99
parent704605711ef048a7c6ad2ec599f15d2e0baf86b2
block: Make blk_cleanup_queue() wait until request_fn finished

Some request_fn implementations, e.g. scsi_request_fn(), unlock
the queue lock internally. This may result in multiple threads
executing request_fn for the same queue simultaneously. Keep
track of the number of active request_fn calls and make sure that
blk_cleanup_queue() waits until all active request_fn invocations
have finished. A block driver may start cleaning up resources
needed by its request_fn as soon as blk_cleanup_queue() finished,
so blk_cleanup_queue() must wait for all outstanding request_fn
invocations to finish.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reported-by: Chanho Min <chanho.min@lge.com>
Cc: James Bottomley <JBottomley@Parallels.com>
Cc: Mike Christie <michaelc@cs.wisc.edu>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-core.c
include/linux/blkdev.h