btrfs-progs: check for no result before using results
PATCH RESEND 1/2 btrfs-progs: check for no result before using results
User space understands the ioctl BTRFS_IOC_DEV_REPLACE command status using the struct btrfs_ioctl_dev_replace_args::result, and so userspace initializes this to BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_RESULT, so exclude this value in checking for the error.
--- cmds-replace.c | 2 ++ 1 file changed, 2 insertions(+)
cmds-replace.c +2 -0
@@ -296,6 +296,8 @@ static int cmd_replace_start(int argc, char **argv) }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", path,
Signature · 1 line
1.8.3.1
PATCH RESEND 2/2 btrfs-progs: 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>
Fix it by checking if the return is > 0, as the kernel returns BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS for the above cli, if the balance is running.
--- cmds-replace.c | 4 ++++ 1 file changed, 4 insertions(+)
cmds-replace.c +4 -0
@@ -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 !=
Signature · 1 line
1.8.3.1
Ping?
Thanks, Anand
Quoted 24 lines · Anand Jain
User space understands the ioctl
BTRFS_IOC_DEV_REPLACEcommand status using the structbtrfs_ioctl_dev_replace_args::result, and so userspace initializes this toBTRFS_IOCTL_DEV_REPLACE_RESULT_NO_RESULT, so exclude this value in checking for the error.Signed-off-by Anand Jain <[email protected]>--- cmds-replace.c | 2 ++ 1 file changed, 2 insertions(+)cmds-replace.c +2
-0@@ -296,6 +296,8 @@ static int cmd_replace_start(int argc, char **argv) }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", path,
Quoted 6 lines · Anand Jain
User space understands the ioctl
BTRFS_IOC_DEV_REPLACEcommand status using the structbtrfs_ioctl_dev_replace_args::result, and so userspace initializes this toBTRFS_IOCTL_DEV_REPLACE_RESULT_NO_RESULT, so exclude this value in checking for the error.Signed-off-by Anand Jain <[email protected]>
1 and 2 applied, thanks.
Quoted 10 lines · David Sterba
Quoted 6 lines · Anand Jain
User space understands the ioctl
BTRFS_IOC_DEV_REPLACEcommand status using the structbtrfs_ioctl_dev_replace_args::result, and so userspace initializes this toBTRFS_IOCTL_DEV_REPLACE_RESULT_NO_RESULT, so exclude this value in checking for the error.Signed-off-by Anand Jain <[email protected]>1 and 2 applied, thanks.
Thanks.
While at btrfs-progs you could include [1] as well.
[1]
[PATCH v4] btrfs-progs: dump-tree: add noscan option
https://patchwork.kernel.org/patch/10832585/
-Anand