From ae45af7a929f673f25cfbcdfe4d07ba59fbe28ca Mon Sep 17 00:00:00 2001 From: Anand Jain Date: Thu, 31 Jan 2019 18:05:41 +0800 Subject: [PATCH] btrfs-progs: dev replace: gracefully handle the exclusive operation report Replace start fails to report the appropriate error if balance is already running, as below: $ btrfs rep start -B -f /dev/sdb /dev/sde /btrfs ERROR: ioctl(DEV_REPLACE_START) on '/btrfs' returns error: Translate the positive values, the exclusive operation is reported as BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS when balance is running. Reviewed-by: Nikolay Borisov Signed-off-by: Anand Jain Signed-off-by: David Sterba --- cmds-replace.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmds-replace.c b/cmds-replace.c index 802261d3..5add39a3 100644 --- a/cmds-replace.c +++ b/cmds-replace.c @@ -295,6 +295,10 @@ static int cmd_replace_start(int argc, char **argv) goto leave_with_error; } + if (ret > 0) + error("ioctl(DEV_REPLACE_START) '%s': %s", path, + btrfs_err_str(ret)); + if (start_args.result != BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_RESULT && start_args.result != BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR) { error("ioctl(DEV_REPLACE_START) on '%s' returns error: %s",