linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] btrfs-progs: "sub get-default" doesn't work
@ 2016-03-18  1:26 Satoru Takeuchi
  2016-03-18  1:29 ` [PATCH 2/5] btrfs-progs: "qgroup create/destroy" don't work Satoru Takeuchi
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Satoru Takeuchi @ 2016-03-18  1:26 UTC (permalink / raw)
  To: dsterba, linux-btrfs, clm

On 2016/03/17 3:29, David Sterba wrote:
> Hi,
>
> btrfs-progs 4.5-rc1 have been released. The ETA for final release is this
> Friday, so please test and report if you find problems. Small fixes or
> documentation updates are welcome.

Please apply this patchset. Especially [1/5]~[4/5] fix
the regressions caused by the following commit.

commit 176aeca9a148 ("btrfs-progs: add getopt stubs where needed")

I read whole this commit carefully and probably fixed
all problems in this commit by 1a521af, c742deb,
and this patchset.

Satoru

---
"sub get-default" does't work from the following commit.

commit 176aeca9a148 ("btrfs-progs: add getopt stubs where needed")

* actual result

   ==================================================
   # ./btrfs sub get-default /btrfs
   btrfs subvolume get-default: too few arguments
   usage: btrfs subvolume get-default <path>

       Get the default subvolume of a filesystem
   ==================================================

* expected result

   ==================================================
   # btrfs sub get-default /btrfs
   ID 5 (FS_TREE)
   ==================================================

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
---
This patch can be applied to devel branch (commit: 40dc7c504cf0)
---
  cmds-subvolume.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index 32caaa5..3953d7c 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -790,7 +790,7 @@ static int cmd_subvol_get_default(int argc, char **argv)

  	clean_args_no_options(argc, argv, cmd_subvol_get_default_usage);

-	if (check_argc_exact(argc - optind, 2))
+	if (check_argc_exact(argc - optind, 1))
  		usage(cmd_subvol_get_default_usage);

  	subvol = argv[1];
-- 
2.7.0

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

* [PATCH 2/5] btrfs-progs: "qgroup create/destroy" don't work
  2016-03-18  1:26 [PATCH 1/5] btrfs-progs: "sub get-default" doesn't work Satoru Takeuchi
@ 2016-03-18  1:29 ` Satoru Takeuchi
  2016-03-18  1:31 ` [PATCH 3/5] btrfs-progs: "inspect-internal subvolid-resolve" doesn't work Satoru Takeuchi
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Satoru Takeuchi @ 2016-03-18  1:29 UTC (permalink / raw)
  To: dsterba, linux-btrfs, clm

"qgroup create/destroy" don't work from the following commit.

commit 176aeca9a148 ("btrfs-progs: add getopt stubs where needed")

* actual result

   ==================================================
   # ./btrfs qgroup create 1 /btrfs/sub
   btrfs qgroup create: too few arguments
   usage: btrfs qgroup create <qgroupid> <path>

       Create a subvolume quota group.
   ==================================================
   # btrfs qgroup create 1 /btrfs/sub
   # ./btrfs qgroup destroy 1 /btrfs/sub
   btrfs qgroup destroy: too few arguments
   usage: btrfs qgroup destroy <qgroupid> <path>

       Destroy a quota group.

   ==================================================

* expected result

   ==================================================
   # btrfs qgroup create 1 /btrfs/sub
   # btrfs qgroup destroy 1 /btrfs/sub/
   ==================================================

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
---
  cmds-qgroup.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmds-qgroup.c b/cmds-qgroup.c
index c4a0c6b..7ae2253 100644
--- a/cmds-qgroup.c
+++ b/cmds-qgroup.c
@@ -124,7 +124,7 @@ static int _cmd_qgroup_create(int create, int argc, char **argv)
  	struct btrfs_ioctl_qgroup_create_args args;
  	DIR *dirstream = NULL;

-	if (check_argc_exact(argc - optind, 3))
+	if (check_argc_exact(argc - optind, 2))
  		return -1;

  	memset(&args, 0, sizeof(args));
-- 
2.7.0

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

* [PATCH 3/5] btrfs-progs: "inspect-internal subvolid-resolve" doesn't work
  2016-03-18  1:26 [PATCH 1/5] btrfs-progs: "sub get-default" doesn't work Satoru Takeuchi
  2016-03-18  1:29 ` [PATCH 2/5] btrfs-progs: "qgroup create/destroy" don't work Satoru Takeuchi
@ 2016-03-18  1:31 ` Satoru Takeuchi
  2016-03-18  1:35 ` [PATCH 4/5] btrfs-progs: "qgroup assign" can't handle options Satoru Takeuchi
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Satoru Takeuchi @ 2016-03-18  1:31 UTC (permalink / raw)
  To: dsterba, linux-btrfs, clm

"inspect-internal subvolid-resolve" doesn't work from the following commit.

commit 176aeca9a148 ("btrfs-progs: add getopt stubs where needed")

It's because 1st argument, subvolid, is also used for the pathname of
filesystem. 2nd argument should be used for this purpose instead.

* actual result

   ==================================================
   # ./btrfs inspect-internal subvolid-resolve 260 /btrfs
   ERROR: cannot access '260': No such file or directory
   ==================================================

* expected result

   ==================================================
   # btrfs inspect-internal subvolid-resolve 260 /btrfs
   snap
   ==================================================

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
---
  cmds-inspect.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmds-inspect.c b/cmds-inspect.c
index 04e1ae8..6045985 100644
--- a/cmds-inspect.c
+++ b/cmds-inspect.c
@@ -273,7 +273,7 @@ static int cmd_inspect_subvolid_resolve(int argc, char **argv)
  	if (check_argc_exact(argc - optind, 2))
  		usage(cmd_inspect_subvolid_resolve_usage);

-	fd = btrfs_open_dir(argv[optind], &dirstream, 1);
+	fd = btrfs_open_dir(argv[optind + 1], &dirstream, 1);
  	if (fd < 0) {
  		ret = -ENOENT;
  		goto out;
-- 
2.7.0

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

* [PATCH 4/5] btrfs-progs: "qgroup assign" can't handle options
  2016-03-18  1:26 [PATCH 1/5] btrfs-progs: "sub get-default" doesn't work Satoru Takeuchi
  2016-03-18  1:29 ` [PATCH 2/5] btrfs-progs: "qgroup create/destroy" don't work Satoru Takeuchi
  2016-03-18  1:31 ` [PATCH 3/5] btrfs-progs: "inspect-internal subvolid-resolve" doesn't work Satoru Takeuchi
@ 2016-03-18  1:35 ` Satoru Takeuchi
  2016-03-18  1:36 ` [PATCH 5/5] btrfs-progs: qgroup assign can't handle --no-rescan option Satoru Takeuchi
  2016-03-18 13:26 ` [PATCH 1/5] btrfs-progs: "sub get-default" doesn't work David Sterba
  4 siblings, 0 replies; 6+ messages in thread
From: Satoru Takeuchi @ 2016-03-18  1:35 UTC (permalink / raw)
  To: dsterba, linux-btrfs, clm

"qgroup assign" is considered as working without any options
from the following commit.

commit 176aeca9a148 ("btrfs-progs: add getopt stubs where needed")

However, we can pass options to this command.

* actual result

   ==================================================
   # ./btrfs qgroup assign --rescan 0/260 1/261 /btrfs
   btrfs qgroup assign: unrecognized option '--rescan'
   usage: btrfs qgroup assign [options] <src> <dst> <path>

       Assign SRC as the child qgroup of DST

       --rescan       schedule qutoa rescan if needed
       --no-rescan

   ==================================================

* expected result

   ==================================================
   # ./btrfs qgroup assign --rescan 0/260 1/261 /btrfs
   #
   ==================================================

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
---
  cmds-qgroup.c | 62 ++++++++++++++++++++++++-----------------------------------
  1 file changed, 25 insertions(+), 37 deletions(-)

diff --git a/cmds-qgroup.c b/cmds-qgroup.c
index 7ae2253..ebd66ef 100644
--- a/cmds-qgroup.c
+++ b/cmds-qgroup.c
@@ -32,7 +32,8 @@ static const char * const qgroup_cmd_group_usage[] = {
  	NULL
  };

-static int _cmd_qgroup_assign(int assign, int argc, char **argv)
+static int _cmd_qgroup_assign(int assign, int argc, char **argv,
+			      const char * const *usage_str)
  {
  	int ret = 0;
  	int fd;
@@ -41,28 +42,31 @@ static int _cmd_qgroup_assign(int assign, int argc, char **argv)
  	struct btrfs_ioctl_qgroup_assign_args args;
  	DIR *dirstream = NULL;

-	while (1) {
-		enum { GETOPT_VAL_RESCAN = 256 };
-		static const struct option long_options[] = {
-			{ "rescan", no_argument, NULL, GETOPT_VAL_RESCAN },
-			{ NULL, 0, NULL, 0 }
-		};
-		int c = getopt_long(argc, argv, "", long_options, NULL);
-
-		if (c < 0)
-			break;
-		switch (c) {
-		case GETOPT_VAL_RESCAN:
-			rescan = 1;
-			break;
-		default:
-			/* Usage printed by the caller */
-			return -1;
+	if (assign) {
+		while (1) {
+			enum { GETOPT_VAL_RESCAN = 256 };
+			static const struct option long_options[] = {
+				{ "rescan", no_argument, NULL, GETOPT_VAL_RESCAN },
+				{ NULL, 0, NULL, 0 }
+			};
+			int c = getopt_long(argc, argv, "", long_options, NULL);
+
+			if (c < 0)
+				break;
+			switch (c) {
+			case GETOPT_VAL_RESCAN:
+				rescan = 1;
+				break;
+			default:
+				usage(usage_str);
+			}
  		}
+	} else {
+		clean_args_no_options(argc, argv, usage_str);
  	}

  	if (check_argc_exact(argc - optind, 3))
-		return -1;
+		usage(usage_str);

  	memset(&args, 0, sizeof(args));
  	args.assign = assign;
@@ -208,15 +212,7 @@ static const char * const cmd_qgroup_assign_usage[] = {

  static int cmd_qgroup_assign(int argc, char **argv)
  {
-	int ret;
-
-	clean_args_no_options(argc, argv, cmd_qgroup_assign_usage);
-
-	ret = _cmd_qgroup_assign(1, argc, argv);
-
-	if (ret < 0)
-		usage(cmd_qgroup_assign_usage);
-	return ret;
+	return _cmd_qgroup_assign(1, argc, argv, cmd_qgroup_assign_usage);
  }

  static const char * const cmd_qgroup_remove_usage[] = {
@@ -227,15 +223,7 @@ static const char * const cmd_qgroup_remove_usage[] = {

  static int cmd_qgroup_remove(int argc, char **argv)
  {
-	int ret;
-
-	clean_args_no_options(argc, argv, cmd_qgroup_remove_usage);
-
-	ret = _cmd_qgroup_assign(0, argc, argv);
-
-	if (ret < 0)
-		usage(cmd_qgroup_remove_usage);
-	return ret;
+	return _cmd_qgroup_assign(0, argc, argv, cmd_qgroup_remove_usage);
  }

  static const char * const cmd_qgroup_create_usage[] = {
-- 
2.7.0

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

* [PATCH 5/5] btrfs-progs: qgroup assign can't handle --no-rescan option
  2016-03-18  1:26 [PATCH 1/5] btrfs-progs: "sub get-default" doesn't work Satoru Takeuchi
                   ` (2 preceding siblings ...)
  2016-03-18  1:35 ` [PATCH 4/5] btrfs-progs: "qgroup assign" can't handle options Satoru Takeuchi
@ 2016-03-18  1:36 ` Satoru Takeuchi
  2016-03-18 13:26 ` [PATCH 1/5] btrfs-progs: "sub get-default" doesn't work David Sterba
  4 siblings, 0 replies; 6+ messages in thread
From: Satoru Takeuchi @ 2016-03-18  1:36 UTC (permalink / raw)
  To: dsterba, linux-btrfs, clm

* actual result

   ==================================================
   # btrfs qgroup assign --no-rescan 0/260 1/261 /btrfs
   btrfs qgroup assign: unrecognized option '--no-rescan'
   usage: btrfs qgroup assign [options] <src> <dst> <path>

       Assign SRC as the child qgroup of DST

       --rescan       schedule qutoa rescan if needed
       --no-rescan

   ==================================================

* expected result

   ==================================================
   # ./btrfs qgroup assign --no-rescan 0/260 1/261 /btrfs
   #
   ==================================================

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
---
  cmds-qgroup.c | 11 +++++++++--
  1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/cmds-qgroup.c b/cmds-qgroup.c
index ebd66ef..4b4149d 100644
--- a/cmds-qgroup.c
+++ b/cmds-qgroup.c
@@ -44,9 +44,13 @@ static int _cmd_qgroup_assign(int assign, int argc, char **argv,

  	if (assign) {
  		while (1) {
-			enum { GETOPT_VAL_RESCAN = 256 };
+			enum {
+				GETOPT_VAL_RESCAN = 256,
+				GETOPT_VAL_NO_RESCAN = 257,
+			};
  			static const struct option long_options[] = {
  				{ "rescan", no_argument, NULL, GETOPT_VAL_RESCAN },
+				{ "no-rescan", no_argument, NULL, GETOPT_VAL_NO_RESCAN },
  				{ NULL, 0, NULL, 0 }
  			};
  			int c = getopt_long(argc, argv, "", long_options, NULL);
@@ -57,6 +61,9 @@ static int _cmd_qgroup_assign(int assign, int argc, char **argv,
  			case GETOPT_VAL_RESCAN:
  				rescan = 1;
  				break;
+			case GETOPT_VAL_NO_RESCAN:
+				rescan = 0;
+				break;
  			default:
  				usage(usage_str);
  			}
@@ -206,7 +213,7 @@ static const char * const cmd_qgroup_assign_usage[] = {
  	"Assign SRC as the child qgroup of DST",
  	"",
  	"--rescan       schedule qutoa rescan if needed",
-	"--no-rescan    ",
+	"--no-rescan    don't schedule quota rescan",
  	NULL
  };

-- 
2.7.0

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

* Re: [PATCH 1/5] btrfs-progs: "sub get-default" doesn't work
  2016-03-18  1:26 [PATCH 1/5] btrfs-progs: "sub get-default" doesn't work Satoru Takeuchi
                   ` (3 preceding siblings ...)
  2016-03-18  1:36 ` [PATCH 5/5] btrfs-progs: qgroup assign can't handle --no-rescan option Satoru Takeuchi
@ 2016-03-18 13:26 ` David Sterba
  4 siblings, 0 replies; 6+ messages in thread
From: David Sterba @ 2016-03-18 13:26 UTC (permalink / raw)
  To: Satoru Takeuchi; +Cc: dsterba, linux-btrfs, clm

On Fri, Mar 18, 2016 at 10:26:15AM +0900, Satoru Takeuchi wrote:
> On 2016/03/17 3:29, David Sterba wrote:
> > btrfs-progs 4.5-rc1 have been released. The ETA for final release is this
> > Friday, so please test and report if you find problems. Small fixes or
> > documentation updates are welcome.
> 
> Please apply this patchset. Especially [1/5]~[4/5] fix
> the regressions caused by the following commit.
> 
> commit 176aeca9a148 ("btrfs-progs: add getopt stubs where needed")
> 
> I read whole this commit carefully and probably fixed
> all problems in this commit by 1a521af, c742deb,
> and this patchset.

All applied, thanks. I've updated the subject lines and did minor code
reformatting.  And thanks for fixing the mess after 176aeca9a148, we
need more ui coverage tests.

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

end of thread, other threads:[~2016-03-18 13:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-18  1:26 [PATCH 1/5] btrfs-progs: "sub get-default" doesn't work Satoru Takeuchi
2016-03-18  1:29 ` [PATCH 2/5] btrfs-progs: "qgroup create/destroy" don't work Satoru Takeuchi
2016-03-18  1:31 ` [PATCH 3/5] btrfs-progs: "inspect-internal subvolid-resolve" doesn't work Satoru Takeuchi
2016-03-18  1:35 ` [PATCH 4/5] btrfs-progs: "qgroup assign" can't handle options Satoru Takeuchi
2016-03-18  1:36 ` [PATCH 5/5] btrfs-progs: qgroup assign can't handle --no-rescan option Satoru Takeuchi
2016-03-18 13:26 ` [PATCH 1/5] btrfs-progs: "sub get-default" doesn't work 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).