diff mbox

[2/2] btrfs: implement super op contains_bdev

Message ID 1300117060-13613-3-git-send-email-josef@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Josef Bacik March 14, 2011, 3:37 p.m. UTC
None
diff mbox

Patch

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 = {