Skip to contentSkip to conversation

btrfs-progs: "sub get-default" doesn't work

PATCH In review Satoru Takeuchi 2 participants 6 messages Mar 18, 2016 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 btrfs-progs: "sub get-default" doesn't work

Quoted 5 lines · David Sterba

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)
  ==================================================

---
This patch can be applied to devel branch (commit: 40dc7c504cf0)

---
 cmds-subvolume.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cmds-subvolume.c +1 -1
index 32caaa5..3953d7c 100644
@@ -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];
Signature · 1 line
2.7.0
#1 lore raw

PATCH 2/5 btrfs-progs: "qgroup create/destroy" don't work

"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/
  ==================================================
---
 cmds-qgroup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cmds-qgroup.c +1 -1
index c4a0c6b..7ae2253 100644
@@ -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));
Signature · 1 line
2.7.0
#2 lore raw

PATCH 3/5 btrfs-progs: "inspect-internal subvolid-resolve" doesn't work

In reply to Satoru Takeuchi

"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
  ==================================================
---
 cmds-inspect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cmds-inspect.c +1 -1
index 04e1ae8..6045985 100644
@@ -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;
Signature · 1 line
2.7.0
#3 lore raw

PATCH 4/5 btrfs-progs: "qgroup assign" can't handle options

In reply to Satoru Takeuchi

"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
  #
  ==================================================
---
 cmds-qgroup.c | 62 ++++++++++++++++++++++++-----------------------------------
 1 file changed, 25 insertions(+), 37 deletions(-)
cmds-qgroup.c +25 -37
index 7ae2253..ebd66ef 100644
@@ -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[] = {
Signature · 1 line
2.7.0
#4 lore raw

PATCH 5/5 btrfs-progs: qgroup assign can't handle --no-rescan option

In reply to Satoru Takeuchi

* 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
  #
  ==================================================
---
 cmds-qgroup.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
cmds-qgroup.c +9 -2
index ebd66ef..4b4149d 100644
@@ -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
 };
 
Signature · 1 line
2.7.0
#5 lore raw
In reply to Satoru Takeuchi
Quoted 5 lines · Satoru Takeuchi
Quoted 3 lines · David Sterba

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.

Quoted 8 lines

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.