mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
block: use the holder as indication for exclusive opens
The current interface for exclusive opens is rather confusing as it requires both the FMODE_EXCL flag and a holder. Remove the need to pass FMODE_EXCL and just key off the exclusive open off a non-NULL holder. For blkdev_put this requires adding the holder argument, which provides better debug checking that only the holder actually releases the hold, but at the same time allows removing the now superfluous mode argument. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Acked-by: Christian Brauner <brauner@kernel.org> Acked-by: David Sterba <dsterba@suse.com> [btrfs] Acked-by: Jack Wang <jinpu.wang@ionos.com> [rnbd] Link: https://lore.kernel.org/r/20230608110258.189493-16-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
2ef789288a
commit
2736e8eeb0
37 changed files with 183 additions and 192 deletions
|
@ -257,7 +257,7 @@ static int btrfs_init_dev_replace_tgtdev(struct btrfs_fs_info *fs_info,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
bdev = blkdev_get_by_path(device_path, FMODE_WRITE | FMODE_EXCL,
|
||||
bdev = blkdev_get_by_path(device_path, FMODE_WRITE,
|
||||
fs_info->bdev_holder, NULL);
|
||||
if (IS_ERR(bdev)) {
|
||||
btrfs_err(fs_info, "target device %s is invalid!", device_path);
|
||||
|
@ -315,7 +315,7 @@ static int btrfs_init_dev_replace_tgtdev(struct btrfs_fs_info *fs_info,
|
|||
device->bdev = bdev;
|
||||
set_bit(BTRFS_DEV_STATE_IN_FS_METADATA, &device->dev_state);
|
||||
set_bit(BTRFS_DEV_STATE_REPLACE_TGT, &device->dev_state);
|
||||
device->mode = FMODE_EXCL;
|
||||
device->holder = fs_info->bdev_holder;
|
||||
device->dev_stats_valid = 1;
|
||||
set_blocksize(device->bdev, BTRFS_BDEV_BLOCKSIZE);
|
||||
device->fs_devices = fs_devices;
|
||||
|
@ -334,7 +334,7 @@ static int btrfs_init_dev_replace_tgtdev(struct btrfs_fs_info *fs_info,
|
|||
return 0;
|
||||
|
||||
error:
|
||||
blkdev_put(bdev, FMODE_EXCL);
|
||||
blkdev_put(bdev, fs_info->bdev_holder);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue