From: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>
Cc: Fan Chengniang <fancn.fnst@cn.fujitsu.com>
Subject: [PATCH 4/4] btrfs-progs:show qgroup type
Date: Tue, 10 Feb 2015 18:24:18 +0800 [thread overview]
Message-ID: <1423563862-9151-8-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>
make 'btrfs qgroup show' command show qgroup type.
Signed-off-by: Fan Chengniang <fancn.fnst@cn.fujitsu.com>
---
qgroup.c | 42 +++++++++++++++++++++++++++++++++++++++---
qgroup.h | 1 +
2 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/qgroup.c b/qgroup.c
index a647925..d359659 100644
--- a/qgroup.c
+++ b/qgroup.c
@@ -135,6 +135,13 @@ static struct {
.max_len = 5,
},
{
+ .name = "type",
+ .column_name = "Type",
+ .need_print = 1,
+ .unit_mode = 0,
+ .max_len = 8,
+ },
+ {
.name = NULL,
.column_name = NULL,
.need_print = 0,
@@ -201,6 +208,20 @@ static int print_child_column(struct btrfs_qgroup *qgroup)
return len;
}
+static int print_type_column(struct btrfs_qgroup *qgroup)
+{
+ __u8 type = qgroup->type;
+ int len = 0;
+
+ if (type == BTRFS_QGROUP_TYPE_DATA)
+ len = printf("data");
+ if (type == BTRFS_QGROUP_TYPE_METADATA)
+ len = printf("metadata");
+ if (type == BTRFS_QGROUP_TYPE_MIXED)
+ len = printf("metadata,data");
+ return len;
+}
+
static void print_qgroup_column_add_blank(enum btrfs_qgroup_column_enum column,
int len)
{
@@ -244,6 +265,10 @@ static void print_qgroup_column(struct btrfs_qgroup *qgroup,
len = print_child_column(qgroup);
print_qgroup_column_add_blank(BTRFS_QGROUP_CHILD, len);
break;
+ case BTRFS_QGROUP_TYPE:
+ len = print_type_column(qgroup);
+ print_qgroup_column_add_blank(BTRFS_QGROUP_TYPE, len);
+ break;
default:
break;
}
@@ -258,7 +283,7 @@ static void print_single_qgroup_table(struct btrfs_qgroup *qgroup)
continue;
print_qgroup_column(qgroup, i);
- if (i != BTRFS_QGROUP_CHILD)
+ if (i != BTRFS_QGROUP_ALL - 1)
printf(" ");
}
printf("\n");
@@ -275,7 +300,7 @@ static void print_table_head()
if (!btrfs_qgroup_columns[i].need_print)
continue;
if ((i == BTRFS_QGROUP_QGROUPID) | (i == BTRFS_QGROUP_PARENT) |
- (i == BTRFS_QGROUP_CHILD))
+ (i == BTRFS_QGROUP_CHILD) | (i == BTRFS_QGROUP_TYPE))
printf("%-*s", max_len, btrfs_qgroup_columns[i].name);
else
printf("%*s", max_len, btrfs_qgroup_columns[i].name);
@@ -287,7 +312,7 @@ static void print_table_head()
if (!btrfs_qgroup_columns[i].need_print)
continue;
if ((i == BTRFS_QGROUP_QGROUPID) | (i == BTRFS_QGROUP_PARENT) |
- (i == BTRFS_QGROUP_CHILD)) {
+ (i == BTRFS_QGROUP_CHILD) | (i == BTRFS_QGROUP_TYPE)) {
len = strlen(btrfs_qgroup_columns[i].name);
while (len--)
printf("-");
@@ -976,6 +1001,17 @@ static void __update_columns_max_len(struct btrfs_qgroup *bq,
if (btrfs_qgroup_columns[column].max_len < len)
btrfs_qgroup_columns[column].max_len = len;
break;
+ case BTRFS_QGROUP_TYPE:
+ len = 0;
+ if (bq->type == BTRFS_QGROUP_TYPE_DATA)
+ len = strlen("data");
+ if (bq->type == BTRFS_QGROUP_TYPE_METADATA)
+ len = strlen("metadata");
+ if (bq->type == BTRFS_QGROUP_TYPE_MIXED)
+ len = strlen("metadata,data");
+ if (btrfs_qgroup_columns[column].max_len < len)
+ btrfs_qgroup_columns[column].max_len = len;
+ break;
default:
break;
}
diff --git a/qgroup.h b/qgroup.h
index 8423fdf..cc61477 100644
--- a/qgroup.h
+++ b/qgroup.h
@@ -75,6 +75,7 @@ enum btrfs_qgroup_column_enum {
BTRFS_QGROUP_MAX_EXCL,
BTRFS_QGROUP_PARENT,
BTRFS_QGROUP_CHILD,
+ BTRFS_QGROUP_TYPE,
BTRFS_QGROUP_ALL,
};
--
1.8.4.2
next prev 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 ` [PATCH 3/4] btrfs-progs:specify qgroup type when creating qgroup Dongsheng Yang
2015-02-10 10:24 ` [PATCH 3/7] btrfs: qgroup: Apply type to btrfs_qgroup_inherit() Dongsheng Yang
2015-02-10 10:24 ` Dongsheng Yang [this message]
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-8-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).