Skip to content

Commit

Permalink
fix checking of SEEK_DATA
Browse files Browse the repository at this point in the history
  • Loading branch information
ahrens committed May 9, 2018
1 parent 6189c16 commit b3c797d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions tests/zfs-tests/cmd/getholes/getholes.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#define PRINT_HOLE 0x1
#define PRINT_DATA 0x2
#define PRINT_VERBOSE 0x4
#define NO_VERIFY 0x8

#ifdef SEEK_HOLE

Expand Down Expand Up @@ -74,7 +75,8 @@ print_list(list_t *seg_list, char *fname, int options)
uint64_t hole_blks_seen = 0, data_blks_seen = 0;
seg_t *seg;

if (zfs_get_hole_count(fname, &lz_holes, &bs) != 0) {
if (!(options & NO_VERIFY) &&
zfs_get_hole_count(fname, &lz_holes, &bs) != 0) {
perror("zfs_get_hole_count");
exit(1);
}
Expand All @@ -95,7 +97,7 @@ print_list(list_t *seg_list, char *fname, int options)
}

/* Verify libzfs sees the same number of hole blocks found manually. */
if (lz_holes != hole_blks_seen) {
if (!(options & NO_VERIFY) && lz_holes != hole_blks_seen) {
(void) fprintf(stderr, "Counted %llu holes, but libzfs found "
"%llu\n",
(long long)hole_blks_seen,
Expand Down Expand Up @@ -129,7 +131,7 @@ main(int argc, char *argv[])

list_create(&seg_list, sizeof (seg_t), offsetof(seg_t, seg_node));

while ((c = getopt(argc, argv, "dhv")) != -1) {
while ((c = getopt(argc, argv, "dhvn")) != -1) {
switch (c) {
case 'd':
options |= PRINT_DATA;
Expand All @@ -140,6 +142,9 @@ main(int argc, char *argv[])
case 'v':
options |= PRINT_VERBOSE;
break;
case 'n':
options |= NO_VERIFY;
break;
}
}
argc -= optind;
Expand Down
2 changes: 1 addition & 1 deletion tests/zfs-tests/tests/functional/holes/setup.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

. $STF_SUITE/include/libtest.shlib

if ! getholes /etc/hosts; then
if ! getholes -n /etc/hosts; then
log_unsupported "The kernel does not support SEEK_DATA / SEEK_HOLE"
fi

Expand Down

0 comments on commit b3c797d

Please sign in to comment.