Skip to contentSkip to conversation

Btrfs: don't panic if we get an error while balancing

PATCH New Josef Bacik 1 participant 2 messages Jul 1, 2011 – Jul 2, 2011 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Btrfs: don't panic if we get an error while balancing

A user reported an error where if we try to balance an fs after a device has been removed it will blow up. This is because we get an EIO back and this is where BUG_ON(ret) bites us in the ass. To fix we just exit. Thanks,

---
 fs/btrfs/volumes.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
fs/btrfs/volumes.c +2 -1
index 1efa56e..685bc0f 100644
@@ -2098,7 +2098,8 @@ int btrfs_balance(struct btrfs_root *dev_root)
 					   chunk_root->root_key.objectid,
 					   found_key.objectid,
 					   found_key.offset);
-		BUG_ON(ret && ret != -ENOSPC);
+		if (ret != -ENOSPC)
+			goto error;
 		key.offset = found_key.offset - 1;
 	}
 	ret = 0;
Signature · 1 line
1.7.5.2
#1 lore raw

PATCH 1/1 Btrfs: don't panic if we get an error while balancing V2

A user reported an error where if we try to balance an fs after a device has been removed it will blow up. This is because we get an EIO back and this is where BUG_ON(ret) bites us in the ass. To fix we just exit. Thanks,

---
V1->V2: only break if ret is actually set, I always screw this up.

 fs/btrfs/volumes.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
fs/btrfs/volumes.c +2 -1
index 1efa56e..19450bc 100644
@@ -2098,7 +2098,8 @@ int btrfs_balance(struct btrfs_root *dev_root)
 					   chunk_root->root_key.objectid,
 					   found_key.objectid,
 					   found_key.offset);
-		BUG_ON(ret && ret != -ENOSPC);
+		if (ret && ret != -ENOSPC)
+			goto error;
 		key.offset = found_key.offset - 1;
 	}
 	ret = 0;
Signature · 1 line
1.7.5.2