diff options
author | Brian Behlendorf <[email protected]> | 2023-05-18 10:02:20 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2023-05-18 10:02:20 -0700 |
commit | e34e15ed6d1882d29e314321b7642305d99f1b78 (patch) | |
tree | 8600f5bff9f383090a15901f50fb22aacca2282b /cmd | |
parent | e0d5007bcf7e4425d43ba2ad56489c7db5c4a4c5 (diff) |
Add the ability to uninitialize
zpool initialize functions well for touching every free byte...once.
But if we want to do it again, we're currently out of luck.
So let's add zpool initialize -u to clear it.
Co-authored-by: Rich Ercolani <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Signed-off-by: Rich Ercolani <[email protected]>
Closes #12451
Closes #14873
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/zpool/zpool_main.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index 301c5f4bf..3e08e0314 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -398,7 +398,7 @@ get_usage(zpool_help_t idx) case HELP_REOPEN: return (gettext("\treopen [-n] <pool>\n")); case HELP_INITIALIZE: - return (gettext("\tinitialize [-c | -s] [-w] <pool> " + return (gettext("\tinitialize [-c | -s | -u] [-w] <pool> " "[<device> ...]\n")); case HELP_SCRUB: return (gettext("\tscrub [-s | -p] [-w] <pool> ...\n")); @@ -585,12 +585,13 @@ usage(boolean_t requested) } /* - * zpool initialize [-c | -s] [-w] <pool> [<vdev> ...] + * zpool initialize [-c | -s | -u] [-w] <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. + * -u Uninitialize. Clears initialization state. * -w Wait. Blocks until initializing has completed. */ int @@ -606,12 +607,14 @@ zpool_do_initialize(int argc, char **argv) struct option long_options[] = { {"cancel", no_argument, NULL, 'c'}, {"suspend", no_argument, NULL, 's'}, + {"uninit", no_argument, NULL, 'u'}, {"wait", no_argument, NULL, 'w'}, {0, 0, 0, 0} }; pool_initialize_func_t cmd_type = POOL_INITIALIZE_START; - while ((c = getopt_long(argc, argv, "csw", long_options, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "csuw", long_options, + NULL)) != -1) { switch (c) { case 'c': if (cmd_type != POOL_INITIALIZE_START && @@ -631,6 +634,15 @@ zpool_do_initialize(int argc, char **argv) } cmd_type = POOL_INITIALIZE_SUSPEND; break; + case 'u': + if (cmd_type != POOL_INITIALIZE_START && + cmd_type != POOL_INITIALIZE_UNINIT) { + (void) fprintf(stderr, gettext("-u cannot be " + "combined with other options\n")); + usage(B_FALSE); + } + cmd_type = POOL_INITIALIZE_UNINIT; + break; case 'w': wait = B_TRUE; break; @@ -657,8 +669,8 @@ zpool_do_initialize(int argc, char **argv) } if (wait && (cmd_type != POOL_INITIALIZE_START)) { - (void) fprintf(stderr, gettext("-w cannot be used with -c or " - "-s\n")); + (void) fprintf(stderr, gettext("-w cannot be used with -c, -s" + "or -u\n")); usage(B_FALSE); } |