]> git.itanic.dy.fi Git - linux-stable/commit
bcache: Fix bcache device claiming
authorJan Kara <jack@suse.cz>
Thu, 22 Jun 2023 16:46:55 +0000 (18:46 +0200)
committerJens Axboe <axboe@kernel.dk>
Fri, 23 Jun 2023 22:10:04 +0000 (16:10 -0600)
commit2c5555983bd27d24162534b682b10654639a5576
tree5a533d92605c6cb6610b363fb293858d044ca783
parentabcc0cbd49283fccd20420e86416b2475b00819c
bcache: Fix bcache device claiming

Commit 2736e8eeb0cc ("block: use the holder as indication for exclusive
opens") introduced a change that blkdev_put() has to get exclusive
holder of the bdev as an argument. However it overlooked that
register_bdev() and register_cache() overwrite the bdev->bd_holder field
in the block device to point to the real owning object which was not
available at the time we called blkdev_get_by_path(). Messing with bdev
internals like this is a layering violation and it also causes
blkdev_put() to issue warning about mismatching holders.

Fix bcache to reopen the block device with appropriate holder once it is
available which also restores the behavior that multiple bcache caches
cannot claim the same device which was broken by commit 29499ab060fe
("bcache: don't pass a stack address to blkdev_get_by_path").

Fixes: 2736e8eeb0cc ("block: use the holder as indication for exclusive opens")
Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Kent Overstreet <kent.overstreet@linux.dev>
Acked-by: Coly Li <colyli@suse.de>
Link: https://lore.kernel.org/r/20230622164658.12861-2-jack@suse.cz
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/md/bcache/super.c