* [PATCH v2 18/20] Btrfs-progs: fix magic return value in cmds-balance.c
@ 2013-09-10 2:28 Wang Shilong
2013-09-10 7:47 ` Ilya Dryomov
0 siblings, 1 reply; 2+ messages in thread
From: Wang Shilong @ 2013-09-10 2:28 UTC (permalink / raw
To: linux-btrfs; +Cc: dsterba, sandeen, idryomov
If there is no balance in progress, resume/pause/cancel
will return 2. Usage or syntax errors will return 1.
And 0 means operations return successfully.
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
---
v1->v2:
Address comments from Ilya Dryomov.
---
cmds-balance.c | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/cmds-balance.c b/cmds-balance.c
index b7382ef..a151475 100644
--- a/cmds-balance.c
+++ b/cmds-balance.c
@@ -299,7 +299,7 @@ static int do_balance(const char *path, struct btrfs_ioctl_balance_args *args,
fd = open_file_or_dir(path, &dirstream);
if (fd < 0) {
fprintf(stderr, "ERROR: can't access to '%s'\n", path);
- return 12;
+ return 1;
}
ret = ioctl(fd, BTRFS_IOC_BALANCE_V2, args);
@@ -330,7 +330,7 @@ static int do_balance(const char *path, struct btrfs_ioctl_balance_args *args,
if (e != EINPROGRESS)
fprintf(stderr, "There may be more info in "
"syslog - try dmesg | tail\n");
- ret = 19;
+ ret = 1;
}
} else {
printf("Done, had to relocate %llu out of %llu chunks\n",
@@ -498,7 +498,7 @@ static int cmd_balance_pause(int argc, char **argv)
fd = open_file_or_dir(path, &dirstream);
if (fd < 0) {
fprintf(stderr, "ERROR: can't access to '%s'\n", path);
- return 12;
+ return 1;
}
ret = ioctl(fd, BTRFS_IOC_BALANCE_CTL, BTRFS_BALANCE_CTL_PAUSE);
@@ -508,7 +508,10 @@ static int cmd_balance_pause(int argc, char **argv)
if (ret < 0) {
fprintf(stderr, "ERROR: balance pause on '%s' failed - %s\n",
path, (e == ENOTCONN) ? "Not running" : strerror(e));
- return 19;
+ if (e == ENOTCONN)
+ return 2;
+ else
+ return 1;
}
return 0;
@@ -536,7 +539,7 @@ static int cmd_balance_cancel(int argc, char **argv)
fd = open_file_or_dir(path, &dirstream);
if (fd < 0) {
fprintf(stderr, "ERROR: can't access to '%s'\n", path);
- return 12;
+ return 1;
}
ret = ioctl(fd, BTRFS_IOC_BALANCE_CTL, BTRFS_BALANCE_CTL_CANCEL);
@@ -546,7 +549,10 @@ static int cmd_balance_cancel(int argc, char **argv)
if (ret < 0) {
fprintf(stderr, "ERROR: balance cancel on '%s' failed - %s\n",
path, (e == ENOTCONN) ? "Not in progress" : strerror(e));
- return 19;
+ if (e == ENOTCONN)
+ return 2;
+ else
+ return 1;
}
return 0;
@@ -575,7 +581,7 @@ static int cmd_balance_resume(int argc, char **argv)
fd = open_file_or_dir(path, &dirstream);
if (fd < 0) {
fprintf(stderr, "ERROR: can't access to '%s'\n", path);
- return 12;
+ return 1;
}
memset(&args, 0, sizeof(args));
@@ -596,12 +602,15 @@ static int cmd_balance_resume(int argc, char **argv)
"failed - %s\n", path,
(e == ENOTCONN) ? "Not in progress" :
"Already running");
- return 19;
+ if (e == ENOTCONN)
+ return 2;
+ else
+ return 1;
} else {
fprintf(stderr,
"ERROR: error during balancing '%s' - %s\n"
"There may be more info in syslog - try dmesg | tail\n", path, strerror(e));
- return 19;
+ return 1;
}
} else {
printf("Done, had to relocate %llu out of %llu chunks\n",
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2 18/20] Btrfs-progs: fix magic return value in cmds-balance.c
2013-09-10 2:28 [PATCH v2 18/20] Btrfs-progs: fix magic return value in cmds-balance.c Wang Shilong
@ 2013-09-10 7:47 ` Ilya Dryomov
0 siblings, 0 replies; 2+ messages in thread
From: Ilya Dryomov @ 2013-09-10 7:47 UTC (permalink / raw
To: Wang Shilong; +Cc: linux-btrfs, dsterba, sandeen
On Tue, Sep 10, 2013 at 5:28 AM, Wang Shilong
<wangsl.fnst@cn.fujitsu.com> wrote:
> If there is no balance in progress, resume/pause/cancel
> will return 2. Usage or syntax errors will return 1.
> And 0 means operations return successfully.
>
> Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
> ---
> v1->v2:
> Address comments from Ilya Dryomov.
Reviewed-by: Ilya Dryomov <idryomov@gmail.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-09-10 7:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-10 2:28 [PATCH v2 18/20] Btrfs-progs: fix magic return value in cmds-balance.c Wang Shilong
2013-09-10 7:47 ` Ilya Dryomov
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.