]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit - drivers/block/virtio_blk.c
blk-mq: add ->init_request and ->exit_request methods
authorChristoph Hellwig <hch@lst.de>
Tue, 15 Apr 2014 19:59:10 +0000 (13:59 -0600)
committerJens Axboe <axboe@fb.com>
Tue, 15 Apr 2014 20:03:03 +0000 (14:03 -0600)
commite9b267d91f6ddbc694cb40aa962b0b2cec03971d
tree6b9fac74ad40dfc7b57f701a8ae0454c42a71554
parent8727af4b9d45c7503042e3fbd926c1a173876e9c
blk-mq: add ->init_request and ->exit_request methods

The current blk_mq_init_commands/blk_mq_free_commands interface has a
two problems:

 1) Because only the constructor is passed to blk_mq_init_commands there
    is no easy way to clean up when a comman initialization failed.  The
    current code simply leaks the allocations done in the constructor.

 2) There is no good place to call blk_mq_free_commands: before
    blk_cleanup_queue there is no guarantee that all outstanding
    commands have completed, so we can't free them yet.  After
    blk_cleanup_queue the queue has usually been freed.  This can be
    worked around by grabbing an unconditional reference before calling
    blk_cleanup_queue and dropping it after blk_mq_free_commands is
    done, although that's not exatly pretty and driver writers are
    guaranteed to get it wrong sooner or later.

Both issues are easily fixed by making the request constructor and
destructor normal blk_mq_ops methods.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
block/blk-mq.c
drivers/block/virtio_blk.c
include/linux/blk-mq.h