Skip to content
Snippets Groups Projects
Commit 2c555598 authored by Jan Kara's avatar Jan Kara Committed by Jens Axboe
Browse files

bcache: Fix bcache device claiming


Commit 2736e8ee ("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 29499ab0
("bcache: don't pass a stack address to blkdev_get_by_path").

Fixes: 2736e8ee ("block: use the holder as indication for exclusive opens")
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Reviewed-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
Acked-by: default avatarColy Li <colyli@suse.de>
Link: https://lore.kernel.org/r/20230622164658.12861-2-jack@suse.cz


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent abcc0cbd
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment