From bc70abad8cddc344bef1378017d159139c89d4ba Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Wed, 2 Jul 2014 13:34:41 -0700 Subject: btrfs-progs: show extent state for a subvolume The qgroup verification code can trivially be extended to provide extended information on the extents which a subvolume root references. Along with qgroup-verify, I have found this tool to be invaluable when tracking down extent references. The patch adds a switch to the check subcommand '--subvol-extents' which takes as args a single subvolume id. When run with the switch, we'll print out each extent that the subvolume references. The extent printout gives standard extent info you would expect along with information on which other roots reference it. Sample output follows - this is a few lines from a run on a subvolume I've been testing qgroup changes on: Print extent state for subvolume 281 on /dev/vdb2 UUID: 8203ca66-9858-4e3f-b447-5bbaacf79c02 Offset Len Root Refs Roots 12582912 20480 12 257 279 280 281 282 283 284 285 286 287 288 289 12603392 8192 12 257 279 280 281 282 283 284 285 286 287 288 289 12611584 12288 12 257 279 280 281 282 283 284 285 286 287 288 289 124583936 16384 4 281 282 283 280 125075456 16384 4 280 281 282 283 126255104 16384 11 257 280 281 282 283 284 285 286 287 288 289 4763508736 4096 3 279 280 281 In case it wasn't clear, this applies on top of my qgroup verify patch: "btrfs-progs: add quota group verify code" A branch with all this can be found on github: https://github.com/markfasheh/btrfs-progs-patches/tree/qgroup-verify Please apply, Signed-off-by: Mark Fasheh Signed-off-by: David Sterba --- cmds-check.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'cmds-check.c') diff --git a/cmds-check.c b/cmds-check.c index b2e69672..e2060cba 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -6545,6 +6545,7 @@ static struct option long_options[] = { { "init-extent-tree", 0, NULL, 0 }, { "check-data-csum", 0, NULL, 0 }, { "backup", 0, NULL, 0 }, + { "subvol-extents", 1, NULL, 'E' }, { "qgroup-report", 0, NULL, 'Q' }, { NULL, 0, NULL, 0} }; @@ -6560,6 +6561,7 @@ const char * const cmd_check_usage[] = { "--init-extent-tree create a new extent tree", "--check-data-csum verify checkums of data blocks", "--qgroup-report print a report on qgroup consistency", + "--subvol-extents print subvolume extents and sharing state", NULL }; @@ -6569,6 +6571,7 @@ int cmd_check(int argc, char **argv) struct btrfs_root *root; struct btrfs_fs_info *info; u64 bytenr = 0; + u64 subvolid = 0; char uuidbuf[BTRFS_UUID_UNPARSED_SIZE]; int ret; u64 num; @@ -6604,6 +6607,9 @@ int cmd_check(int argc, char **argv) case 'Q': qgroup_report = 1; break; + case 'E': + subvolid = arg_strtou64(optarg); + break; case '?': case 'h': usage(cmd_check_usage); @@ -6660,6 +6666,12 @@ int cmd_check(int argc, char **argv) print_qgroup_report(1); goto close_out; } + if (subvolid) { + printf("Print extent state for subvolume %llu on %s\nUUID: %s\n", + subvolid, argv[optind], uuidbuf); + ret = print_extent_state(info, subvolid); + goto close_out; + } printf("Checking filesystem on %s\nUUID: %s\n", argv[optind], uuidbuf); if (!extent_buffer_uptodate(info->tree_root->node) || -- cgit v1.2.3