Skip to content
Permalink
Browse files

5767 fix several problems with zfs test suite

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Approved by: Gordon Ross <gwr@nexenta.com>
  • Loading branch information...
jwk404 authored and ahrens committed Apr 26, 2015
1 parent 8430278 commit 52244c0958bdf281ca42932b449f644b4decfdc2
Showing with 1,003 additions and 586 deletions.
  1. +36 −10 usr/src/cmd/zpool/zpool_main.c
  2. +8 −2 usr/src/pkg/manifests/system-test-zfstest.mf
  3. +3 −1 usr/src/test/zfs-tests/cmd/Makefile
  4. +4 −6 usr/src/test/zfs-tests/cmd/file_trunc/file_trunc.c
  5. +22 −0 usr/src/test/zfs-tests/cmd/getholes/Makefile
  6. +194 −0 usr/src/test/zfs-tests/cmd/getholes/getholes.c
  7. +22 −0 usr/src/test/zfs-tests/cmd/mkholes/Makefile
  8. +212 −0 usr/src/test/zfs-tests/cmd/mkholes/mkholes.c
  9. +2 −1 usr/src/test/zfs-tests/include/commands.cfg
  10. +3 −1 usr/src/test/zfs-tests/include/default.cfg
  11. +35 −2 usr/src/test/zfs-tests/include/libtest.shlib
  12. +4 −1 usr/src/test/zfs-tests/runfiles/delphix.run
  13. +4 −1 usr/src/test/zfs-tests/runfiles/omnios.run
  14. +4 −1 usr/src/test/zfs-tests/runfiles/openindiana.run
  15. +2 −1 usr/src/test/zfs-tests/tests/functional/Makefile
  16. +11 −5 usr/src/test/zfs-tests/tests/functional/cli_root/zfs_set/readonly_001_pos.ksh
  17. +7 −0 usr/src/test/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib
  18. +2 −22 usr/src/test/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.cfg
  19. +1 −39 usr/src/test/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.kshlib
  20. +8 −3 usr/src/test/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_001_pos.ksh
  21. +6 −2 usr/src/test/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_002_pos.ksh
  22. +6 −1 usr/src/test/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_003_pos.ksh
  23. +6 −1 usr/src/test/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_004_pos.ksh
  24. +22 −97 usr/src/test/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_006_pos.ksh
  25. +2 −9 usr/src/test/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.cfg
  26. +20 −121 usr/src/test/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_004_pos.ksh
  27. +43 −0 usr/src/test/zfs-tests/tests/functional/holes/Makefile
  28. +20 −0 usr/src/test/zfs-tests/tests/functional/holes/cleanup.ksh
  29. +39 −0 usr/src/test/zfs-tests/tests/functional/holes/holes.shlib
  30. +85 −0 usr/src/test/zfs-tests/tests/functional/holes/holes_sanity.ksh
  31. +21 −0 usr/src/test/zfs-tests/tests/functional/holes/setup.ksh
  32. +2 −4 usr/src/test/zfs-tests/tests/functional/online_offline/Makefile
  33. +0 −38 usr/src/test/zfs-tests/tests/functional/online_offline/online_offline.cfg
  34. +12 −62 usr/src/test/zfs-tests/tests/functional/online_offline/online_offline_001_pos.ksh
  35. +59 −68 usr/src/test/zfs-tests/tests/functional/online_offline/online_offline_002_neg.ksh
  36. +16 −68 usr/src/test/zfs-tests/tests/functional/online_offline/online_offline_003_neg.ksh
  37. +2 −1 usr/src/test/zfs-tests/tests/functional/rsend/Makefile
  38. +1 −9 usr/src/test/zfs-tests/tests/functional/rsend/cleanup.ksh
  39. +56 −0 usr/src/test/zfs-tests/tests/functional/rsend/rsend_014_pos.ksh
  40. +1 −9 usr/src/test/zfs-tests/tests/functional/rsend/setup.ksh
@@ -2792,6 +2792,9 @@ print_list_stats(zpool_handle_t *zhp, const char *name, nvlist_t *nv,
uint_t c, children;
char *vname;
boolean_t scripted = cb->cb_scripted;
uint64_t islog = B_FALSE;
boolean_t haslog = B_FALSE;
char *dashes = "%-*s - - - - - -\n";

verify(nvlist_lookup_uint64_array(nv, ZPOOL_CONFIG_VDEV_STATS,
(uint64_t **)&vs, &c) == 0);
@@ -2842,24 +2845,47 @@ print_list_stats(zpool_handle_t *zhp, const char *name, nvlist_t *nv,
ZPOOL_CONFIG_IS_HOLE, &ishole) == 0 && ishole)
continue;

if (nvlist_lookup_uint64(child[c],
ZPOOL_CONFIG_IS_LOG, &islog) == 0 && islog) {
haslog = B_TRUE;
continue;
}

vname = zpool_vdev_name(g_zfs, zhp, child[c], B_FALSE);
print_list_stats(zhp, vname, child[c], cb, depth + 2);
free(vname);
}

/*
* Include level 2 ARC devices in iostat output
*/
if (haslog == B_TRUE) {
/* LINTED E_SEC_PRINTF_VAR_FMT */
(void) printf(dashes, cb->cb_namewidth, "log");
for (c = 0; c < children; c++) {
if (nvlist_lookup_uint64(child[c], ZPOOL_CONFIG_IS_LOG,
&islog) != 0 || !islog)
continue;
vname = zpool_vdev_name(g_zfs, zhp, child[c], B_FALSE);
print_list_stats(zhp, vname, child[c], cb, depth + 2);
free(vname);
}
}

if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_L2CACHE,
&child, &children) != 0)
return;
&child, &children) == 0 && children > 0) {
/* LINTED E_SEC_PRINTF_VAR_FMT */
(void) printf(dashes, cb->cb_namewidth, "cache");
for (c = 0; c < children; c++) {
vname = zpool_vdev_name(g_zfs, zhp, child[c], B_FALSE);
print_list_stats(zhp, vname, child[c], cb, depth + 2);
free(vname);
}
}

if (children > 0) {
(void) printf("%-*s - - - - - "
"-\n", cb->cb_namewidth, "cache");
if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_SPARES, &child,
&children) == 0 && children > 0) {
/* LINTED E_SEC_PRINTF_VAR_FMT */
(void) printf(dashes, cb->cb_namewidth, "spare");
for (c = 0; c < children; c++) {
vname = zpool_vdev_name(g_zfs, zhp, child[c],
B_FALSE);
vname = zpool_vdev_name(g_zfs, zhp, child[c], B_FALSE);
print_list_stats(zhp, vname, child[c], cb, depth + 2);
free(vname);
}
@@ -96,6 +96,7 @@ dir path=opt/zfs-tests/tests/functional/features/async_destroy
dir path=opt/zfs-tests/tests/functional/grow_pool
dir path=opt/zfs-tests/tests/functional/grow_replicas
dir path=opt/zfs-tests/tests/functional/history
dir path=opt/zfs-tests/tests/functional/holes
dir path=opt/zfs-tests/tests/functional/inheritance
dir path=opt/zfs-tests/tests/functional/interop
dir path=opt/zfs-tests/tests/functional/inuse
@@ -147,8 +148,10 @@ file path=opt/zfs-tests/bin/dir_rd_update mode=0555
file path=opt/zfs-tests/bin/file_check mode=0555
file path=opt/zfs-tests/bin/file_trunc mode=0555
file path=opt/zfs-tests/bin/file_write mode=0555
file path=opt/zfs-tests/bin/getholes mode=0555
file path=opt/zfs-tests/bin/largest_file mode=0555
file path=opt/zfs-tests/bin/mkbusy mode=0555
file path=opt/zfs-tests/bin/mkholes mode=0555
file path=opt/zfs-tests/bin/mktree mode=0555
file path=opt/zfs-tests/bin/mmapwrite mode=0555
file path=opt/zfs-tests/bin/randfree_file mode=0555
@@ -1702,6 +1705,10 @@ file path=opt/zfs-tests/tests/functional/history/sparc.migratedpool.DAT.Z \
file path=opt/zfs-tests/tests/functional/history/sparc.orig_history.txt \
mode=0444
file path=opt/zfs-tests/tests/functional/history/zfs-pool-v4.dat.Z mode=0444
file path=opt/zfs-tests/tests/functional/holes/cleanup mode=0555
file path=opt/zfs-tests/tests/functional/holes/holes.shlib mode=0555
file path=opt/zfs-tests/tests/functional/holes/holes_sanity mode=0555
file path=opt/zfs-tests/tests/functional/holes/setup mode=0555
file path=opt/zfs-tests/tests/functional/inheritance/cleanup mode=0555
file path=opt/zfs-tests/tests/functional/inheritance/config001.cfg mode=0555
file path=opt/zfs-tests/tests/functional/inheritance/config002.cfg mode=0555
@@ -1836,8 +1843,6 @@ file path=opt/zfs-tests/tests/functional/nopwrite/nopwrite_varying_compression \
file path=opt/zfs-tests/tests/functional/nopwrite/nopwrite_volume mode=0555
file path=opt/zfs-tests/tests/functional/nopwrite/setup mode=0555
file path=opt/zfs-tests/tests/functional/online_offline/cleanup mode=0555
file path=opt/zfs-tests/tests/functional/online_offline/online_offline.cfg \
mode=0555
file path=opt/zfs-tests/tests/functional/online_offline/online_offline_001_pos \
mode=0555
file path=opt/zfs-tests/tests/functional/online_offline/online_offline_002_neg \
@@ -1973,6 +1978,7 @@ file path=opt/zfs-tests/tests/functional/rsend/rsend_010_pos mode=0555
file path=opt/zfs-tests/tests/functional/rsend/rsend_011_pos mode=0555
file path=opt/zfs-tests/tests/functional/rsend/rsend_012_pos mode=0555
file path=opt/zfs-tests/tests/functional/rsend/rsend_013_pos mode=0555
file path=opt/zfs-tests/tests/functional/rsend/rsend_014_pos mode=0555
file path=opt/zfs-tests/tests/functional/rsend/setup mode=0555
file path=opt/zfs-tests/tests/functional/scrub_mirror/cleanup mode=0555
file path=opt/zfs-tests/tests/functional/scrub_mirror/default.cfg mode=0555
@@ -10,7 +10,7 @@
#

#
# Copyright (c) 2012 by Delphix. All rights reserved.
# Copyright (c) 2012, 2014 by Delphix. All rights reserved.
#

.PARALLEL: $(SUBDIRS)
@@ -21,8 +21,10 @@ SUBDIRS = chg_usr_exec \
file_check \
file_trunc \
file_write \
getholes \
largest_file \
mkbusy \
mkholes \
mktree \
mmapwrite \
randfree_file \
@@ -25,7 +25,7 @@
*/

/*
* Copyright (c) 2012 by Delphix. All rights reserved.
* Copyright (c) 2012, 2014 by Delphix. All rights reserved.
*/

#include <stdio.h>
@@ -76,7 +76,7 @@ usage(char *execname)
int
main(int argc, char *argv[])
{
int i = 0;
int i;
int fd = -1;

parse_options(argc, argv);
@@ -87,11 +87,9 @@ main(int argc, char *argv[])
exit(3);
}

while (i < count) {
for (i = 0; count == 0 || i < count; i++) {
(void) do_write(fd);
(void) do_trunc(fd);

i++;
}

(void) close(fd);
@@ -188,7 +186,7 @@ do_write(int fd)
exit(5);
}

buf = "ZFS Test Suite Truncation Test";
(void) strcpy(buf, "ZFS Test Suite Truncation Test");
if (write(fd, buf, bsize) < bsize) {
perror("write");
exit(6);
@@ -0,0 +1,22 @@
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#

#
# Copyright (c) 2014 by Delphix. All rights reserved.
#

PROG = getholes

include $(SRC)/cmd/Makefile.cmd

LDLIBS += -lcmdutils -lumem -lzfs

include ../Makefile.subdirs
@@ -0,0 +1,194 @@
/*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
* http://www.illumos.org/license/CDDL.
*/

/*
* Copyright (c) 2014 by Delphix. All rights reserved.
*/

#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <libzfs.h>
#include <umem.h>
#include <stdlib.h>
#include <stddef.h>
#include <sys/types.h>
#include <sys/list.h>
#include <sys/stat.h>
#include <sys/errno.h>

#define PRINT_HOLE 0x1
#define PRINT_DATA 0x2
#define PRINT_VERBOSE 0x4

extern int errno;

static void
usage(char *msg, int exit_value)
{
(void) fprintf(stderr, "getholes [-dhv] filename\n");
(void) fprintf(stderr, "%s\n", msg);
exit(exit_value);
}

typedef struct segment {
list_node_t seg_node;
int seg_type;
off_t seg_offset;
off_t seg_len;
} seg_t;

/*
* Return an appropriate whence value, depending on whether the file begins
* with a holes or data.
*/
static int
starts_with_hole(int fd)
{
off_t off;

if ((off = lseek(fd, 0, SEEK_HOLE)) == -1) {
/* ENXIO means no holes were found */
if (errno == ENXIO)
return (SEEK_DATA);
perror("lseek failed");
exit(1);
}

return (off == 0 ? SEEK_HOLE : SEEK_DATA);
}

static void
print_list(list_t *seg_list, char *fname, int options)
{
uint64_t lz_holes, bs = 0;
uint64_t hole_blks_seen = 0, data_blks_seen = 0;
seg_t *seg;

if (0 == bs)
if (zfs_get_hole_count(fname, &lz_holes, &bs) != 0) {
perror("zfs_get_hole_count");
exit(1);
}

while ((seg = list_remove_head(seg_list)) != NULL) {
if (options & PRINT_VERBOSE)
(void) fprintf(stdout, "%c %llu:%llu\n",
seg->seg_type == SEEK_HOLE ? 'h' : 'd',
seg->seg_offset, seg->seg_len);

if (seg->seg_type == SEEK_HOLE) {
hole_blks_seen += seg->seg_len / bs;
} else {
data_blks_seen += seg->seg_len / bs;
}
umem_free(seg, sizeof (seg_t));
}

/* Verify libzfs sees the same number of hole blocks found manually. */
if (lz_holes != hole_blks_seen) {
(void) fprintf(stderr, "Counted %llu holes, but libzfs found "
"%llu\n", hole_blks_seen, lz_holes);
exit(1);
}

if (options & PRINT_HOLE && options & PRINT_DATA) {
(void) fprintf(stdout, "datablks: %llu\n", data_blks_seen);
(void) fprintf(stdout, "holeblks: %llu\n", hole_blks_seen);
return;
}

if (options & PRINT_DATA)
(void) fprintf(stdout, "%llu\n", data_blks_seen);
if (options & PRINT_HOLE)
(void) fprintf(stdout, "%llu\n", hole_blks_seen);
}

int
main(int argc, char *argv[])
{
off_t len, off = 0;
int c, fd, options = 0, whence = SEEK_DATA;
struct stat statbuf;
char *fname;
list_t seg_list;
seg_t *seg = NULL;

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

while ((c = getopt(argc, argv, "dhv")) != -1) {
switch (c) {
case 'd':
options |= PRINT_DATA;
break;
case 'h':
options |= PRINT_HOLE;
break;
case 'v':
options |= PRINT_VERBOSE;
break;
}
}
argc -= optind;
argv += optind;

if (argc != 1)
usage("Incorrect number of arguments.", 1);

if ((fname = argv[0]) == NULL)
usage("No filename provided.", 1);

if ((fd = open(fname, O_LARGEFILE | O_RDONLY)) < 0) {
perror("open failed");
exit(1);
}

if (fstat(fd, &statbuf) != 0) {
perror("fstat failed");
exit(1);
}
len = statbuf.st_size;

whence = starts_with_hole(fd);
while ((off = lseek(fd, off, whence)) != -1) {
seg_t *s;

seg = umem_alloc(sizeof (seg_t), UMEM_DEFAULT);
seg->seg_type = whence;
seg->seg_offset = off;

list_insert_tail(&seg_list, seg);
if ((s = list_prev(&seg_list, seg)) != NULL)
s->seg_len = seg->seg_offset - s->seg_offset;

whence = whence == SEEK_HOLE ? SEEK_DATA : SEEK_HOLE;
}
if (errno != ENXIO) {
perror("lseek failed");
exit(1);
}
(void) close(fd);

/*
* If this file ends with a hole block, then populate the length of
* the last segment, otherwise this is the end of the file, so
* discard the remaining zero length segment.
*/
if (seg && seg->seg_offset != len) {
seg->seg_len = len - seg->seg_offset;
} else {
(void) list_remove_tail(&seg_list);
}

print_list(&seg_list, fname, options);
list_destroy(&seg_list);
return (0);
}

0 comments on commit 52244c0

Please sign in to comment.
You can’t perform that action at this time.