• Jan Kara's avatar
    bcache: Fix bcache device claiming · 2c555598
    Jan Kara authored
    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.czSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
    2c555598
super.c 71.2 KB