Permalink
Browse files

Merge branch 'master' of https://github.com/zfsonlinux/zfs

  • Loading branch information...
madwizard committed Jan 9, 2019
2 parents d081b79 + 8bd2a28 commit d8d813943c6d49f778aba6c0fd53d1c0e9e8e0b2
Showing with 3,409 additions and 68 deletions.
  1. +1 −1 .github/CONTRIBUTING.md
  2. +7 −0 Makefile.am
  3. +176 −3 cmd/zpool/zpool_main.c
  4. +101 −0 cmd/ztest/ztest.c
  5. +3 −0 configure.ac
  6. +0 −6 contrib/dracut/README.dracut.markdown
  7. +1 −1 contrib/pyzfs/Makefile.am
  8. +0 −1 contrib/pyzfs/requirements.txt
  9. +1 −1 contrib/pyzfs/{setup.py → setup.py.in}
  10. +5 −0 include/libzfs.h
  11. +2 −0 include/libzfs_core.h
  12. +1 −0 include/sys/Makefile.am
  13. +37 −1 include/sys/fs/zfs.h
  14. +9 −1 include/sys/metaslab_impl.h
  15. +3 −0 include/sys/spa.h
  16. +32 −0 include/sys/vdev_impl.h
  17. +49 −0 include/sys/vdev_initialize.h
  18. +2 −1 include/sys/zio_priority.h
  19. +3 −0 lib/libzfs/Makefile.am
  20. +94 −0 lib/libzfs/libzfs_pool.c
  21. +7 −0 lib/libzfs/libzfs_util.c
  22. +37 −0 lib/libzfs_core/libzfs_core.c
  23. +1 −0 lib/libzpool/Makefile.am
  24. +59 −0 man/man5/zfs-module-parameters.5
  25. +4 −4 man/man8/zfs.8
  26. +35 −2 man/man8/zpool.8
  27. +1 −0 module/zfs/Makefile.in
  28. +2 −8 module/zfs/dsl_destroy.c
  29. +20 −3 module/zfs/metaslab.c
  30. +181 −12 module/zfs/spa.c
  31. +8 −0 module/zfs/spa_misc.c
  32. +45 −2 module/zfs/vdev.c
  33. +1 −0 module/zfs/vdev_disk.c
  34. +3 −1 module/zfs/vdev_file.c
  35. +1 −0 module/zfs/vdev_indirect.c
  36. +868 −0 module/zfs/vdev_initialize.c
  37. +44 −8 module/zfs/vdev_mirror.c
  38. +3 −1 module/zfs/vdev_missing.c
  39. +32 −6 module/zfs/vdev_queue.c
  40. +75 −0 module/zfs/vdev_raidz.c
  41. +13 −0 module/zfs/vdev_removal.c
  42. +2 −1 module/zfs/vdev_root.c
  43. +81 −0 module/zfs/zfs_ioctl.c
  44. +1 −0 module/zfs/zfs_sysfs.c
  45. +18 −0 rpm/generic/zfs-dkms.spec.in
  46. +3 −3 scripts/commitcheck.sh
  47. +20 −0 tests/runfiles/linux.run
  48. +19 −0 tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c
  49. +1 −0 tests/zfs-tests/include/commands.cfg
  50. +1 −0 tests/zfs-tests/tests/functional/Makefile.am
  51. +1 −0 tests/zfs-tests/tests/functional/cli_root/Makefile.am
  52. +1 −1 tests/zfs-tests/tests/functional/cli_root/zpool_clear/zpool_clear_001_pos.ksh
  53. +18 −0 tests/zfs-tests/tests/functional/cli_root/zpool_initialize/Makefile.am
  54. +31 −0 tests/zfs-tests/tests/functional/cli_root/zpool_initialize/cleanup.ksh
  55. +43 −0 tests/zfs-tests/tests/functional/cli_root/zpool_initialize/zpool_initialize.kshlib
  56. +68 −0 ...fs-tests/tests/functional/cli_root/zpool_initialize/zpool_initialize_attach_detach_add_remove.ksh
  57. +78 −0 tests/zfs-tests/tests/functional/cli_root/zpool_initialize/zpool_initialize_import_export.ksh
  58. +66 −0 ...ests/tests/functional/cli_root/zpool_initialize/zpool_initialize_offline_export_import_online.ksh
  59. +74 −0 tests/zfs-tests/tests/functional/cli_root/zpool_initialize/zpool_initialize_online_offline.ksh
  60. +64 −0 tests/zfs-tests/tests/functional/cli_root/zpool_initialize/zpool_initialize_split.ksh
  61. +60 −0 tests/zfs-tests/tests/functional/cli_root/zpool_initialize/zpool_initialize_start_and_cancel_neg.ksh
  62. +52 −0 tests/zfs-tests/tests/functional/cli_root/zpool_initialize/zpool_initialize_start_and_cancel_pos.ksh
  63. +63 −0 tests/zfs-tests/tests/functional/cli_root/zpool_initialize/zpool_initialize_suspend_resume.ksh
  64. +74 −0 tests/zfs-tests/tests/functional/cli_root/zpool_initialize/zpool_initialize_unsupported_vdevs.ksh
  65. +59 −0 tests/zfs-tests/tests/functional/cli_root/zpool_initialize/zpool_initialize_verify_checksums.ksh
  66. +89 −0 tests/zfs-tests/tests/functional/cli_root/zpool_initialize/zpool_initialize_verify_initialized.ksh
  67. +9 −0 tests/zfs-tests/tests/functional/limits/Makefile.am
  68. +19 −0 tests/zfs-tests/tests/functional/limits/cleanup.ksh
  69. +123 −0 tests/zfs-tests/tests/functional/limits/filesystem_count.ksh
  70. +84 −0 tests/zfs-tests/tests/functional/limits/filesystem_limit.ksh
  71. +21 −0 tests/zfs-tests/tests/functional/limits/setup.ksh
  72. +100 −0 tests/zfs-tests/tests/functional/limits/snapshot_count.ksh
  73. +99 −0 tests/zfs-tests/tests/functional/limits/snapshot_limit.ksh
@@ -164,7 +164,7 @@ coding convention.
### Commit Message Formats
#### New Changes
Commit messages for new changes must meet the following guidelines:
* In 50 characters or less, provide a summary of the change as the
* In 72 characters or less, provide a summary of the change as the
first line in the commit message.
* A body which provides a description of the change. If necessary,
please summarize important information such as why the proposed
@@ -23,6 +23,13 @@ EXTRA_DIST = autogen.sh copy-builtin
EXTRA_DIST += config/config.awk config/rpm.am config/deb.am config/tgz.am
EXTRA_DIST += META AUTHORS COPYRIGHT LICENSE NEWS NOTICE README.md

# Include all the extra licensing information for modules
EXTRA_DIST += module/icp/algs/skein/THIRDPARTYLICENSE module/icp/algs/skein/THIRDPARTYLICENSE.descrip
EXTRA_DIST += module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.gladman module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.gladman.descrip
EXTRA_DIST += module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.openssl module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.openssl.descrip
EXTRA_DIST += module/spl/THIRDPARTYLICENSE.gplv2 module/spl/THIRDPARTYLICENSE.gplv2.descrip
EXTRA_DIST += module/zfs/THIRDPARTYLICENSE.cityhash module/zfs/THIRDPARTYLICENSE.cityhash.descrip

@CODE_COVERAGE_RULES@

.PHONY: gitrev
@@ -97,6 +97,7 @@ static int zpool_do_detach(int, char **);
static int zpool_do_replace(int, char **);
static int zpool_do_split(int, char **);

static int zpool_do_initialize(int, char **);
static int zpool_do_scrub(int, char **);
static int zpool_do_resilver(int, char **);

@@ -150,6 +151,7 @@ typedef enum {
HELP_ONLINE,
HELP_REPLACE,
HELP_REMOVE,
HELP_INITIALIZE,
HELP_SCRUB,
HELP_RESILVER,
HELP_STATUS,
@@ -278,6 +280,7 @@ static zpool_command_t command_table[] = {
{ "replace", zpool_do_replace, HELP_REPLACE },
{ "split", zpool_do_split, HELP_SPLIT },
{ NULL },
{ "initialize", zpool_do_initialize, HELP_INITIALIZE },
{ "scrub", zpool_do_scrub, HELP_SCRUB },
{ "resilver", zpool_do_resilver, HELP_RESILVER },
{ NULL },
@@ -360,13 +363,16 @@ get_usage(zpool_help_t idx)
return (gettext("\tremove [-nps] <pool> <device> ...\n"));
case HELP_REOPEN:
return (gettext("\treopen [-n] <pool>\n"));
case HELP_INITIALIZE:
return (gettext("\tinitialize [-c | -s] <pool> "
"[<device> ...]\n"));
case HELP_SCRUB:
return (gettext("\tscrub [-s | -p] <pool> ...\n"));
case HELP_RESILVER:
return (gettext("\tresilver <pool> ...\n"));
case HELP_STATUS:
return (gettext("\tstatus [-c [script1,script2,...]] "
"[-gLpPsvxD] [-T d|u] [pool] ... \n"
"[-igLpPsvxD] [-T d|u] [pool] ... \n"
"\t [interval [count]]\n"));
case HELP_UPGRADE:
return (gettext("\tupgrade\n"
@@ -393,6 +399,27 @@ get_usage(zpool_help_t idx)
/* NOTREACHED */
}

static void
zpool_collect_leaves(zpool_handle_t *zhp, nvlist_t *nvroot, nvlist_t *res)
{
uint_t children = 0;
nvlist_t **child;
uint_t i;

(void) nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_CHILDREN,
&child, &children);

if (children == 0) {
char *path = zpool_vdev_name(g_zfs, zhp, nvroot, B_FALSE);
fnvlist_add_boolean(res, path);
free(path);
return;
}

for (i = 0; i < children; i++) {
zpool_collect_leaves(zhp, child[i], res);
}
}

/*
* Callback routine that will print out a pool property value.
@@ -479,6 +506,99 @@ usage(boolean_t requested)
exit(requested ? 0 : 2);
}

/*
* zpool initialize [-c | -s] <pool> [<vdev> ...]
* Initialize all unused blocks in the specified vdevs, or all vdevs in the pool
* if none specified.
*
* -c Cancel. Ends active initializing.
* -s Suspend. Initializing can then be restarted with no flags.
*/
int
zpool_do_initialize(int argc, char **argv)
{
int c;
char *poolname;
zpool_handle_t *zhp;
nvlist_t *vdevs;
int err = 0;

struct option long_options[] = {
{"cancel", no_argument, NULL, 'c'},
{"suspend", no_argument, NULL, 's'},
{0, 0, 0, 0}
};

pool_initialize_func_t cmd_type = POOL_INITIALIZE_DO;
while ((c = getopt_long(argc, argv, "cs", long_options, NULL)) != -1) {
switch (c) {
case 'c':
if (cmd_type != POOL_INITIALIZE_DO &&
cmd_type != POOL_INITIALIZE_CANCEL) {
(void) fprintf(stderr, gettext("-c cannot be "
"combined with other options\n"));
usage(B_FALSE);
}
cmd_type = POOL_INITIALIZE_CANCEL;
break;
case 's':
if (cmd_type != POOL_INITIALIZE_DO &&
cmd_type != POOL_INITIALIZE_SUSPEND) {
(void) fprintf(stderr, gettext("-s cannot be "
"combined with other options\n"));
usage(B_FALSE);
}
cmd_type = POOL_INITIALIZE_SUSPEND;
break;
case '?':
if (optopt != 0) {
(void) fprintf(stderr,
gettext("invalid option '%c'\n"), optopt);
} else {
(void) fprintf(stderr,
gettext("invalid option '%s'\n"),
argv[optind - 1]);
}
usage(B_FALSE);
}
}

argc -= optind;
argv += optind;

if (argc < 1) {
(void) fprintf(stderr, gettext("missing pool name argument\n"));
usage(B_FALSE);
return (-1);
}

poolname = argv[0];
zhp = zpool_open(g_zfs, poolname);
if (zhp == NULL)
return (-1);

vdevs = fnvlist_alloc();
if (argc == 1) {
/* no individual leaf vdevs specified, so add them all */
nvlist_t *config = zpool_get_config(zhp, NULL);
nvlist_t *nvroot = fnvlist_lookup_nvlist(config,
ZPOOL_CONFIG_VDEV_TREE);
zpool_collect_leaves(zhp, nvroot, vdevs);
} else {
int i;
for (i = 1; i < argc; i++) {
fnvlist_add_boolean(vdevs, argv[i]);
}
}

err = zpool_initialize(zhp, cmd_type, vdevs);

fnvlist_free(vdevs);
zpool_close(zhp);

return (err);
}

/*
* print a pool vdev config for dry runs
*/
@@ -1675,6 +1795,7 @@ typedef struct status_cbdata {
boolean_t cb_dedup_stats;
boolean_t cb_print_status;
boolean_t cb_print_slow_ios;
boolean_t cb_print_vdev_init;
vdev_cmd_data_list_t *vcdl;
} status_cbdata_t;

@@ -1923,6 +2044,54 @@ print_status_config(zpool_handle_t *zhp, status_cbdata_t *cb, const char *name,
}
}

/* Optionally display vdev initialization status for leaves */
if (cb->cb_print_vdev_init && children == 0) {
if ((vs->vs_initialize_state == VDEV_INITIALIZE_ACTIVE ||
vs->vs_initialize_state == VDEV_INITIALIZE_SUSPENDED ||
vs->vs_initialize_state == VDEV_INITIALIZE_COMPLETE) &&
!vs->vs_scan_removing) {
char zbuf[1024];
char tbuf[256];
struct tm zaction_ts;

time_t t = vs->vs_initialize_action_time;
int initialize_pct = 100;
if (vs->vs_initialize_state !=
VDEV_INITIALIZE_COMPLETE) {
initialize_pct = (vs->vs_initialize_bytes_done *
100 / (vs->vs_initialize_bytes_est + 1));
}

(void) localtime_r(&t, &zaction_ts);
(void) strftime(tbuf, sizeof (tbuf), "%c", &zaction_ts);

switch (vs->vs_initialize_state) {
case VDEV_INITIALIZE_SUSPENDED:
(void) snprintf(zbuf, sizeof (zbuf),
", suspended, started at %s", tbuf);
break;
case VDEV_INITIALIZE_ACTIVE:
(void) snprintf(zbuf, sizeof (zbuf),
", started at %s", tbuf);
break;
case VDEV_INITIALIZE_COMPLETE:
(void) snprintf(zbuf, sizeof (zbuf),
", completed at %s", tbuf);
break;
}

(void) printf(gettext(" (%d%% initialized%s)"),
initialize_pct, zbuf);
} else {
(void) printf(gettext(" (uninitialized)"));
}
} else {
if (vs->vs_initialize_state == VDEV_INITIALIZE_ACTIVE &&
children == 0) {
(void) printf(gettext(" (initializing)"));
}
}

(void) printf("\n");

for (c = 0; c < children; c++) {
@@ -7335,10 +7504,11 @@ status_callback(zpool_handle_t *zhp, void *data)
}

/*
* zpool status [-c [script1,script2,...]] [-gLpPsvx] [-T d|u] [pool] ...
* zpool status [-c [script1,script2,...]] [-igLpPsvx] [-T d|u] [pool] ...
* [interval [count]]
*
* -c CMD For each vdev, run command CMD
* -i Display vdev initialization status.
* -g Display guid for individual vdev name.
* -L Follow links when resolving vdev path name.
* -p Display values in parsable (exact) format.
@@ -7362,7 +7532,7 @@ zpool_do_status(int argc, char **argv)
char *cmd = NULL;

/* check options */
while ((c = getopt(argc, argv, "c:gLpPsvxDT:")) != -1) {
while ((c = getopt(argc, argv, "c:igLpPsvxDT:")) != -1) {
switch (c) {
case 'c':
if (cmd != NULL) {
@@ -7388,6 +7558,9 @@ zpool_do_status(int argc, char **argv)
}
cmd = optarg;
break;
case 'i':
cb.cb_print_vdev_init = B_TRUE;
break;
case 'g':
cb.cb_name_flags |= VDEV_NAME_GUID;
break;
Oops, something went wrong.

0 comments on commit d8d8139

Please sign in to comment.