nbd: refactor device search and allocation in nbd_genl_connect
authorChristoph Hellwig <hch@lst.de>
Wed, 11 Aug 2021 12:44:27 +0000 (14:44 +0200)
committerJens Axboe <axboe@kernel.dk>
Fri, 13 Aug 2021 20:17:39 +0000 (14:17 -0600)
commit6177b56c96ff3b5e23d47f6b6c8630f31145da93
tree37aa161a899ba695984ca13a3fc8d4ec0cc8382e
parent7bdc00cf7e369b3be17f26e5643da28de98d9d6d
nbd: refactor device search and allocation in nbd_genl_connect

Use idr_for_each_entry instead of the awkward callback to find an
existing device for the index == -1 case, and de-duplicate the device
allocation if no existing device was found.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20210811124428.2368491-6-hch@lst.de
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/nbd.c