This patch implements the super op contains_bdev. We just loop through the fs_devices on this super looking for the block device that was requested. Thanks, Signed-off-by: Josef Bacik <josef@xxxxxxxxxx> --- fs/btrfs/super.c | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index d39a989..1487bef 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -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 = { -- 1.7.2.3 -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html