Skip to contentSkip to conversation

btrfs: don't remove device on a raid0 array when device number is 2

PATCH New Li Dongyang 1 participant 1 message Dec 5, 2009 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: don't remove device on a raid0 array when device number is 2

we should not make a raid0 array go below 2 devices.

---
 fs/btrfs/volumes.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
fs/btrfs/volumes.c +8 -0
index 20cbd2e..801b8d0 100644
@@ -1150,6 +1150,14 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
 		goto out;
 	}
 
+	if ((all_avail & BTRFS_BLOCK_GROUP_RAID0) &&
+	    root->fs_info->fs_devices->rw_devices <= 2) {
+		printk(KERN_ERR "btrfs: unable to go below two "
+		       "devices on raid0\n");
+		ret = -EINVAL;
+		goto out;
+	}
+
 	if (strcmp(device_path, "missing") == 0) {
 		struct list_head *devices;
 		struct btrfs_device *tmp;
Signature · 1 line
1.6.5.4