All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] btrfs-progs: handle balance and replace concurrency
Date: Wed, 19 Dec 2018 00:01:44 +0800	[thread overview]
Message-ID: <1545148904-32714-1-git-send-email-anand.jain@oracle.com> (raw)

Test case:
Run replace
 btrfs repl start -B -f /dev/sdd /dev/sdb /btrfs;
while replace is still running, from another terminal try to start
balance
 btrfs bal start  --full-balance /btrfs; echo ...:$?
 Done, had to relocate 0 out of 0 chunks
 ...:0

which fails to report that balance failed to relocate because another
exclusive operation is running.
In fact kernel ioctl BTRFS_IOC_BALANCE(_V2) does return error code 8,
but progs recast it to 0. Fix it by checking for the error code > 0.

After:
 btrfs bal start --full-balance /btrfs; echo ...:$?
 ERROR: balance: add/delete/balance/replace/resize operation in progress
 ...:8

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 cmds-balance.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/cmds-balance.c b/cmds-balance.c
index 6cc26c358f95..77402ef62d85 100644
--- a/cmds-balance.c
+++ b/cmds-balance.c
@@ -481,11 +481,12 @@ static int do_balance(const char *path, struct btrfs_ioctl_balance_args *args,
 			"There may be more info in syslog - try dmesg | tail\n");
 			ret = 1;
 		}
+	} else if (ret > 0) {
+		error("balance: %s", btrfs_err_str(ret));
 	} else {
 		printf("Done, had to relocate %llu out of %llu chunks\n",
 		       (unsigned long long)args->stat.completed,
 		       (unsigned long long)args->stat.considered);
-		ret = 0;
 	}
 
 out:
-- 
1.8.3.1


             reply	other threads:[~2018-12-18 16:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-18 16:01 Anand Jain [this message]
2019-01-15 17:32 ` [PATCH] btrfs-progs: handle balance and replace concurrency David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1545148904-32714-1-git-send-email-anand.jain@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.