linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>
Cc: Fan Chengniang <fancn.fnst@cn.fujitsu.com>,
	Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Subject: [PATCH 3/4] btrfs-progs:specify qgroup type when creating qgroup
Date: Tue, 10 Feb 2015 18:24:16 +0800	[thread overview]
Message-ID: <1423563862-9151-6-git-send-email-yangds.fnst@cn.fujitsu.com> (raw)
In-Reply-To: <1423563862-9151-1-git-send-email-yangds.fnst@cn.fujitsu.com>

From: Fan Chengniang <fancn.fnst@cn.fujitsu.com>

add --qgroup-type option to specify qgroup type. Type
can be metadata, data or mixed.

Signed-off-by: Fan Chengniang <fancn.fnst@cn.fujitsu.com>
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
---
 Documentation/btrfs-qgroup.txt |  5 +++++
 cmds-qgroup.c                  | 37 ++++++++++++++++++++++++++++++++++---
 2 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/Documentation/btrfs-qgroup.txt b/Documentation/btrfs-qgroup.txt
index eadfe1c..7b07e97 100644
--- a/Documentation/btrfs-qgroup.txt
+++ b/Documentation/btrfs-qgroup.txt
@@ -45,6 +45,11 @@ Create a subvolume quota group.
 +
 For the '0/<subvolume id>' qgroup, a qgroup can be created even before the
 subvolume created.
++
+--qgroup-type=<type>::::
+specify the <type> of qgroup to set qgroup limit.
++
+<attr> can be one of metadata, data, mixed.
 
 *destroy* <qgroupid> <path>::
 Destroy a qgroup.
diff --git a/cmds-qgroup.c b/cmds-qgroup.c
index 30f0851..23accdf 100644
--- a/cmds-qgroup.c
+++ b/cmds-qgroup.c
@@ -78,16 +78,45 @@ static int qgroup_create(int create, int argc, char **argv)
 	int ret = 0;
 	int fd;
 	int e;
-	char *path = argv[2];
+	char *path = argv[argc - 1];
 	struct btrfs_ioctl_qgroup_create_args args;
 	DIR *dirstream = NULL;
+	__u8 qgroup_type = 0;
+	__u64 create_type;
 
-	if (check_argc_exact(argc, 3))
+	optind = 1;
+	while (1) {
+		int c;
+		static const struct option long_options[] = {
+			{"qgroup-type", required_argument, NULL, 'q'},
+			{NULL, 0, NULL, 0}
+		};
+
+		c = getopt_long(argc, argv, "", long_options, NULL);
+		if (c < 0)
+			break;
+
+		switch (c) {
+		case 'q':
+			ret = btrfs_qgroup_set_qgroup_type(&qgroup_type, optarg);
+			if (ret)
+				return -1;
+			break;
+		default:
+			return -1;
+		}
+	}
+
+	if (check_argc_exact(argc - optind, 2))
 		return -1;
 
 	memset(&args, 0, sizeof(args));
 	args.create = create;
-	args.qgroupid = parse_qgroupid(argv[1]);
+	if (create && qgroup_type) {
+		create_type = qgroup_type;
+		args.create |= (create_type << BTRFS_QGROUP_TYPE_SHIFT);
+	}
+	args.qgroupid = parse_qgroupid(argv[argc - 2]);
 
 	fd = open_file_or_dir(path, &dirstream);
 	if (fd < 0) {
@@ -137,6 +166,8 @@ static int cmd_qgroup_remove(int argc, char **argv)
 static const char * const cmd_qgroup_create_usage[] = {
 	"btrfs qgroup create <qgroupid> <path>",
 	"Create a subvolume quota group.",
+	"--qgroup-type=metadata,data,mixed",
+	"               specify which qgroup type to set qgroup limit",
 	NULL
 };
 
-- 
1.8.4.2


  parent reply	other threads:[~2015-02-10 10:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-10 10:24 [RFC PATCH 0/7] Btrfs: qgroup: part-4: Add type to btrfs qgroup Dongsheng Yang
2015-02-10 10:24 ` [PATCH 1/4] btrfs-progs: Add type to qgroup Dongsheng Yang
2015-02-10 10:24 ` [PATCH 1/7] Btrfs: qgroup: Add type to btrfs_qgroup Dongsheng Yang
2015-02-10 10:24 ` [PATCH 2/4] btrfs-progs: specify qgroup type when creating subvolume Dongsheng Yang
2015-02-10 10:24 ` [PATCH 2/7] btrfs: qgroup: apply type to the recording and accounting Dongsheng Yang
2015-02-10 10:24 ` Dongsheng Yang [this message]
2015-02-10 10:24 ` [PATCH 3/7] btrfs: qgroup: Apply type to btrfs_qgroup_inherit() Dongsheng Yang
2015-02-10 10:24 ` [PATCH 4/4] btrfs-progs:show qgroup type Dongsheng Yang
2015-02-10 10:24 ` [PATCH 4/7] btrfs: qgroup: Apply qgroup type to qgroup creating Dongsheng Yang
2015-02-10 10:24 ` [PATCH 5/7] btrfs: qgroup: Apply qgroup type to subvol creating Dongsheng Yang
2015-02-10 10:24 ` [PATCH 6/7] btrfs: qgroup: apply type to quota rescan Dongsheng Yang
2015-02-10 10:24 ` [PATCH 7/7] btrfs: qgroup: fix a bug when type of parent is different with child's Dongsheng Yang
2015-03-04  1:49 ` [RFC PATCH 0/7] Btrfs: qgroup: part-4: Add type to btrfs qgroup Dongsheng Yang
2015-03-17 10:08 ` Dongsheng Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1423563862-9151-6-git-send-email-yangds.fnst@cn.fujitsu.com \
    --to=yangds.fnst@cn.fujitsu.com \
    --cc=fancn.fnst@cn.fujitsu.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).