linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs-progs: balance: fix some cases wrongly parsed as old syntax
@ 2022-09-14  5:58 Wang Yugui
  2022-09-14  7:11 ` Qu Wenruo
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Wang Yugui @ 2022-09-14  5:58 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Wang Yugui

Some cases of 'btrfs balance' are wrongly parsed as old syntax.

an example:
$ btrfs balance status
ERROR: cannot access 'status': No such file or directory

currently, only 'start' is successfully excluded in the check of old syntax.
fix it by adding others in the check of old syntax.

Signed-off-by: Wang Yugui <wangyugui@e16-tech.com>
---
 cmds/balance.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/cmds/balance.c b/cmds/balance.c
index c5e10f92..bafd1714 100644
--- a/cmds/balance.c
+++ b/cmds/balance.c
@@ -852,8 +852,23 @@ static const struct cmd_group balance_cmd_group = {
 
 static int cmd_balance(const struct cmd_struct *cmd, int argc, char **argv)
 {
-	if (argc == 2 && strcmp("start", argv[1]) != 0) {
-		/* old 'btrfs filesystem balance <path>' syntax */
+	bool old_syntax = true; /* old 'btrfs balance <path>' syntax */
+	if (argc >= 2)
+	{
+		int i;
+		for (i = 0; balance_cmd_group.commands[i] != NULL; i++)
+		{
+			if (strcmp(argv[1], balance_cmd_group.commands[i]->token) == 0)
+			{
+				old_syntax = false;
+				break;
+			}
+		}
+	} else {
+		old_syntax = false;
+	}
+	if (old_syntax)
+	{
 		struct btrfs_ioctl_balance_args args;
 
 		memset(&args, 0, sizeof(args));
-- 
2.36.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] btrfs-progs: balance: fix some cases wrongly parsed as old syntax
  2022-09-14  5:58 [PATCH] btrfs-progs: balance: fix some cases wrongly parsed as old syntax Wang Yugui
@ 2022-09-14  7:11 ` Qu Wenruo
  2022-09-21  8:24   ` David Sterba
  2022-09-21 15:34 ` [PATCH] btrfs-progs: balance: deprecate " Wang Yugui
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Qu Wenruo @ 2022-09-14  7:11 UTC (permalink / raw)
  To: Wang Yugui, linux-btrfs



On 2022/9/14 13:58, Wang Yugui wrote:
> Some cases of 'btrfs balance' are wrongly parsed as old syntax.
> 
> an example:
> $ btrfs balance status
> ERROR: cannot access 'status': No such file or directory
> 
> currently, only 'start' is successfully excluded in the check of old syntax.
> fix it by adding others in the check of old syntax.
> 
> Signed-off-by: Wang Yugui <wangyugui@e16-tech.com>

The old code is over 10 years.

Can we just remove it completely?

Thanks,
Qu
> ---
>   cmds/balance.c | 19 +++++++++++++++++--
>   1 file changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/cmds/balance.c b/cmds/balance.c
> index c5e10f92..bafd1714 100644
> --- a/cmds/balance.c
> +++ b/cmds/balance.c
> @@ -852,8 +852,23 @@ static const struct cmd_group balance_cmd_group = {
>   
>   static int cmd_balance(const struct cmd_struct *cmd, int argc, char **argv)
>   {
> -	if (argc == 2 && strcmp("start", argv[1]) != 0) {
> -		/* old 'btrfs filesystem balance <path>' syntax */
> +	bool old_syntax = true; /* old 'btrfs balance <path>' syntax */
> +	if (argc >= 2)
> +	{
> +		int i;
> +		for (i = 0; balance_cmd_group.commands[i] != NULL; i++)
> +		{
> +			if (strcmp(argv[1], balance_cmd_group.commands[i]->token) == 0)
> +			{
> +				old_syntax = false;
> +				break;
> +			}
> +		}
> +	} else {
> +		old_syntax = false;
> +	}
> +	if (old_syntax)
> +	{
>   		struct btrfs_ioctl_balance_args args;
>   
>   		memset(&args, 0, sizeof(args));

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] btrfs-progs: balance: fix some cases wrongly parsed as old syntax
  2022-09-14  7:11 ` Qu Wenruo
@ 2022-09-21  8:24   ` David Sterba
  0 siblings, 0 replies; 6+ messages in thread
From: David Sterba @ 2022-09-21  8:24 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: Wang Yugui, linux-btrfs

On Wed, Sep 14, 2022 at 03:11:04PM +0800, Qu Wenruo wrote:
> 
> 
> On 2022/9/14 13:58, Wang Yugui wrote:
> > Some cases of 'btrfs balance' are wrongly parsed as old syntax.
> > 
> > an example:
> > $ btrfs balance status
> > ERROR: cannot access 'status': No such file or directory
> > 
> > currently, only 'start' is successfully excluded in the check of old syntax.
> > fix it by adding others in the check of old syntax.
> > 
> > Signed-off-by: Wang Yugui <wangyugui@e16-tech.com>
> 
> The old code is over 10 years.
> 
> Can we just remove it completely?

I hope everybody uses the new syntax so it's time to remove support for
the old one, but we should still leave some warning in place suggesting
what's the preferred way and then remove it completely in a few
releases.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] btrfs-progs: balance: deprecate old syntax
  2022-09-14  5:58 [PATCH] btrfs-progs: balance: fix some cases wrongly parsed as old syntax Wang Yugui
  2022-09-14  7:11 ` Qu Wenruo
@ 2022-09-21 15:34 ` Wang Yugui
  2022-09-21 21:54 ` [PATCH v2] " Wang Yugui
  2023-03-16 15:47 ` [PATCH] btrfs-progs: balance: fix some cases wrongly parsed as " David Sterba
  3 siblings, 0 replies; 6+ messages in thread
From: Wang Yugui @ 2022-09-21 15:34 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Wang Yugui

deprecate btrfs blanace old syntax since new syntax is already introduced in
2012.

we will remove the old syntax completely in a few releases.

Signed-off-by: Wang Yugui <wangyugui@e16-tech.com>
---
 cmds/balance.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/cmds/balance.c b/cmds/balance.c
index d1e66d42..3cb6334a 100644
--- a/cmds/balance.c
+++ b/cmds/balance.c
@@ -37,7 +37,7 @@
 
 static const char * const balance_cmd_group_usage[] = {
 	"btrfs balance <command> [options] <path>",
-	"btrfs balance <path>",
+	"btrfs balance <path>        deprecated by 'btrfs balance replace'",
 	NULL
 };
 
@@ -882,6 +882,8 @@ static int cmd_balance(const struct cmd_struct *cmd, int argc, char **argv)
 		/* old 'btrfs filesystem balance <path>' syntax */
 		struct btrfs_ioctl_balance_args args;
 
+		warning("deprecated by 'btrfs balance replace'");
+
 		memset(&args, 0, sizeof(args));
 		args.flags |= BTRFS_BALANCE_TYPE_MASK;
 
-- 
2.36.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2] btrfs-progs: balance: deprecate old syntax
  2022-09-14  5:58 [PATCH] btrfs-progs: balance: fix some cases wrongly parsed as old syntax Wang Yugui
  2022-09-14  7:11 ` Qu Wenruo
  2022-09-21 15:34 ` [PATCH] btrfs-progs: balance: deprecate " Wang Yugui
@ 2022-09-21 21:54 ` Wang Yugui
  2023-03-16 15:47 ` [PATCH] btrfs-progs: balance: fix some cases wrongly parsed as " David Sterba
  3 siblings, 0 replies; 6+ messages in thread
From: Wang Yugui @ 2022-09-21 21:54 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Wang Yugui

deprecate btrfs blanace old syntax since new syntax is already introduced in
2012.

we will remove the old syntax completely in a few releases.

Signed-off-by: Wang Yugui <wangyugui@e16-tech.com>
---
changes since v1:
	fix typo(btrfs balance replace -> btrfs balance start)

 cmds/balance.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/cmds/balance.c b/cmds/balance.c
index d1e66d42..3cb6334a 100644
--- a/cmds/balance.c
+++ b/cmds/balance.c
@@ -37,7 +37,7 @@
 
 static const char * const balance_cmd_group_usage[] = {
 	"btrfs balance <command> [options] <path>",
-	"btrfs balance <path>",
+	"btrfs balance <path>        deprecated by 'btrfs balance start'",
 	NULL
 };
 
@@ -882,6 +882,8 @@ static int cmd_balance(const struct cmd_struct *cmd, int argc, char **argv)
 		/* old 'btrfs filesystem balance <path>' syntax */
 		struct btrfs_ioctl_balance_args args;
 
+		warning("deprecated by 'btrfs balance start'");
+
 		memset(&args, 0, sizeof(args));
 		args.flags |= BTRFS_BALANCE_TYPE_MASK;
 
-- 
2.36.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] btrfs-progs: balance: fix some cases wrongly parsed as old syntax
  2022-09-14  5:58 [PATCH] btrfs-progs: balance: fix some cases wrongly parsed as old syntax Wang Yugui
                   ` (2 preceding siblings ...)
  2022-09-21 21:54 ` [PATCH v2] " Wang Yugui
@ 2023-03-16 15:47 ` David Sterba
  3 siblings, 0 replies; 6+ messages in thread
From: David Sterba @ 2023-03-16 15:47 UTC (permalink / raw)
  To: Wang Yugui; +Cc: linux-btrfs

On Wed, Sep 14, 2022 at 01:58:46PM +0800, Wang Yugui wrote:
> Some cases of 'btrfs balance' are wrongly parsed as old syntax.
> 
> an example:
> $ btrfs balance status
> ERROR: cannot access 'status': No such file or directory
> 
> currently, only 'start' is successfully excluded in the check of old syntax.
> fix it by adding others in the check of old syntax.
> 
> Signed-off-by: Wang Yugui <wangyugui@e16-tech.com>

Added to devel with some minor updates, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-03-16 15:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-14  5:58 [PATCH] btrfs-progs: balance: fix some cases wrongly parsed as old syntax Wang Yugui
2022-09-14  7:11 ` Qu Wenruo
2022-09-21  8:24   ` David Sterba
2022-09-21 15:34 ` [PATCH] btrfs-progs: balance: deprecate " Wang Yugui
2022-09-21 21:54 ` [PATCH v2] " Wang Yugui
2023-03-16 15:47 ` [PATCH] btrfs-progs: balance: fix some cases wrongly parsed as " David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).