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: <illegal result value>

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 <nborisov@suse.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
master
Anand Jain 2019-01-31 18:05:41 +08:00 committed by David Sterba
parent f79fb2cf3e
commit ae45af7a92
1 changed files with 4 additions and 0 deletions

View File

@ -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",