Skip to content

Commit

Permalink
CA-90801: add option to skip block overlap check
Browse files Browse the repository at this point in the history
Checking for block overlap is O(n^2) in the number of VHD blocks and can take
minutes for very large VHDs, which cannot be afforded during leaf-coalesce
while the tapdisk is paused.
  • Loading branch information
andreil committed Nov 12, 2012
1 parent 6fc1f96 commit f6be386
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion vhd/lib/vhd-util-check.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ struct vhd_util_check_options {
char ignore_parent_uuid;
char ignore_timestamps;
char check_data;
char no_check_bat;
char collect_stats;
};

Expand Down Expand Up @@ -826,6 +827,9 @@ vhd_util_check_bat(struct vhd_util_check_ctx *ctx, vhd_context_t *vhd)
}
}

if (ctx->opts.no_check_bat)
continue;

for (j = 0; j < vhd_blks; j++) {
uint32_t joff = vhd->bat.bat[j];

Expand Down Expand Up @@ -1203,7 +1207,7 @@ vhd_util_check(int argc, char **argv)
vhd_util_check_stats_init(&ctx);

optind = 0;
while ((c = getopt(argc, argv, "n:iItpbsh")) != -1) {
while ((c = getopt(argc, argv, "n:iItpbBsh")) != -1) {
switch (c) {
case 'n':
name = optarg;
Expand All @@ -1223,6 +1227,9 @@ vhd_util_check(int argc, char **argv)
case 'b':
ctx.opts.check_data = 1;
break;
case 'B':
ctx.opts.no_check_bat = 1;
break;
case 's':
ctx.opts.collect_stats = 1;
break;
Expand All @@ -1240,6 +1247,12 @@ vhd_util_check(int argc, char **argv)
goto usage;
}

if ((ctx.opts.collect_stats || ctx.opts.check_data) &&
ctx.opts.no_check_bat) {
err = -EINVAL;
goto usage;
}

err = vhd_util_check_vhd(&ctx, name);
if (err)
goto out;
Expand All @@ -1258,6 +1271,7 @@ vhd_util_check(int argc, char **argv)
usage:
printf("options: -n <file> [-i ignore missing primary footers] "
"[-I ignore parent uuids] [-t ignore timestamps] "
"[-B do not check BAT for overlapping (precludes -s, -b)] "
"[-p check parents] [-b check bitmaps] [-s stats] [-h help]\n");
return err;
}

0 comments on commit f6be386

Please sign in to comment.