@@ -1095,6 +1095,26 @@ static int btrfs_unfreeze(struct super_block *sb)
return 0;
}
+static int btrfs_contains_bdev(struct super_block *sb,
+ struct block_device *bdev)
+{
+ struct btrfs_root *root = btrfs_sb(sb);
+ struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices;
+ struct btrfs_device *device;
+ int ret = 0;
+
+ mutex_lock(&fs_devices->device_list_mutex);
+ list_for_each_entry(device, &fs_devices->devices, dev_list) {
+ if (device->bdev == bdev) {
+ ret = 1;
+ break;
+ }
+ }
+ mutex_unlock(&fs_devices->device_list_mutex);
+
+ return ret;
+}
+
static const struct super_operations btrfs_super_ops = {
.drop_inode = btrfs_drop_inode,
.evict_inode = btrfs_evict_inode,
@@ -1109,6 +1129,7 @@ static const struct super_operations btrfs_super_ops = {
.remount_fs = btrfs_remount,
.freeze_fs = btrfs_freeze,
.unfreeze_fs = btrfs_unfreeze,
+ .contains_bdev = btrfs_contains_bdev,
};
static const struct file_operations btrfs_ctl_fops = {