[PATCH] Btrfs: fix crash of starting balance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We will crash on BUG_ON(ret == -EEXIST) when we do not resume the existing
balance but attempt to start a new one.

The steps can be:
1. start balance
2. pause balance
3. start balance

Signed-off-by: Liu Bo <bo.li.liu@xxxxxxxxxx>
---
 fs/btrfs/volumes.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 5cce6aa..3901654 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -3100,7 +3100,12 @@ int btrfs_balance(struct btrfs_balance_control *bctl,
 		goto out;
 
 	if (!(bctl->flags & BTRFS_BALANCE_RESUME)) {
-		BUG_ON(ret == -EEXIST);
+		/*
+		 * This can happen when we do not resume the existing balance
+		 * but try to start a new one instead.
+		 */
+		if (ret == -EEXIST)
+			goto out;
 		set_balance_control(bctl);
 	} else {
 		BUG_ON(ret != -EEXIST);
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux