summaryrefslogtreecommitdiff
path: root/cmds-check.c
diff options
context:
space:
mode:
authorMark Fasheh <mfasheh@suse.de>2014-05-07 13:07:17 -0700
committerDavid Sterba <dsterba@suse.cz>2014-08-22 14:39:33 +0200
commit96ec888aad41969d728ba62c1778d6e8ebe6bd4e (patch)
tree413ea722f864ba14714ad47a57e479e29ce6d848 /cmds-check.c
parent2ab405af95d43972b57c7806981220a6949df643 (diff)
btrfs-progs: add quota group verify code
This patch adds functionality (in qgroup-verify.c) to compute bytecounts in subvolume quota groups. The original groups are read in and stored in memory so that after we compute our own bytecounts, we can compare them with those on disk. A print function is provided to do this comparison and show the results on the console. A 'qgroup check' pass is added to btrfsck. If any subvolume quota groups differ from what we compute, the differences for them are printed. We also provide an option '--qgroup-report' which will run only the quota check code and print a report on all quota groups. Other than making it possible to verify that our qgroup changes work correctly, this mode can also be used in xfstests for automated checking after qgroup tests. This patch does not address the following: - compressed counts are identical to non compressed, because kernel doesn't make the distinction yet. Adding the code to verify compressed counts shouldn't be hard at all though once kernel can do this. - It is only concerned with subvolume quota groups (like most of btrfs-progs). Signed-off-by: Mark Fasheh <mfasheh@suse.de> Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'cmds-check.c')
-rw-r--r--cmds-check.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/cmds-check.c b/cmds-check.c
index a290fe36..978ceeec 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -38,6 +38,7 @@
#include "commands.h"
#include "free-space-cache.h"
#include "btrfsck.h"
+#include "qgroup-verify.h"
static u64 bytes_used = 0;
static u64 total_csum_bytes = 0;
@@ -6428,6 +6429,7 @@ static struct option long_options[] = {
{ "init-csum-tree", 0, NULL, 0 },
{ "init-extent-tree", 0, NULL, 0 },
{ "backup", 0, NULL, 0 },
+ { "qgroup-report", 0, NULL, 'Q' },
{ NULL, 0, NULL, 0}
};
@@ -6440,6 +6442,7 @@ const char * const cmd_check_usage[] = {
"--repair try to repair the filesystem",
"--init-csum-tree create a new CRC tree",
"--init-extent-tree create a new extent tree",
+ "--qgroup-report print a report on qgroup consistency",
NULL
};
@@ -6454,6 +6457,7 @@ int cmd_check(int argc, char **argv)
u64 num;
int option_index = 0;
int init_csum_tree = 0;
+ int qgroup_report = 0;
enum btrfs_open_ctree_flags ctree_flags =
OPEN_CTREE_PARTIAL | OPEN_CTREE_EXCLUSIVE;
@@ -6480,6 +6484,9 @@ int cmd_check(int argc, char **argv)
printf("using SB copy %llu, bytenr %llu\n", num,
(unsigned long long)bytenr);
break;
+ case 'Q':
+ qgroup_report = 1;
+ break;
case '?':
case 'h':
usage(cmd_check_usage);
@@ -6527,6 +6534,14 @@ int cmd_check(int argc, char **argv)
root = info->fs_root;
uuid_unparse(info->super_copy->fsid, uuidbuf);
+ if (qgroup_report) {
+ printf("Print quota groups for %s\nUUID: %s\n", argv[optind],
+ uuidbuf);
+ ret = qgroup_verify_all(info);
+ if (ret == 0)
+ print_qgroup_report(1);
+ goto close_out;
+ }
printf("Checking filesystem on %s\nUUID: %s\n", argv[optind], uuidbuf);
if (!extent_buffer_uptodate(info->tree_root->node) ||
@@ -6630,11 +6645,20 @@ int cmd_check(int argc, char **argv)
free(bad);
}
+ if (info->quota_enabled) {
+ int err;
+ fprintf(stderr, "checking quota groups\n");
+ err = qgroup_verify_all(info);
+ if (err)
+ goto out;
+ }
+
if (!list_empty(&root->fs_info->recow_ebs)) {
fprintf(stderr, "Transid errors in file system\n");
ret = 1;
}
out:
+ print_qgroup_report(0);
if (found_old_backref) { /*
* there was a disk format change when mixed
* backref was in testing tree. The old format