mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
Added no_scrub_restart flag to zpool reopen
Added -n flag to zpool reopen that allows a running scrub operation to continue if there is a device with Dirty Time Log. By default if a component device has a DTL and zpool reopen is executed all running scan operations will be restarted. Added functional tests for `zpool reopen` Tests covers following scenarios: * `zpool reopen` without arguments, * `zpool reopen` with pool name as argument, * `zpool reopen` while scrubbing, * `zpool reopen -n` while scrubbing, * `zpool reopen -n` while resilvering, * `zpool reopen` with bad arguments. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Tom Caputi <tcaputi@datto.com> Signed-off-by: Arkadiusz Bubała <arkadiusz.bubala@open-e.com> Closes #6076 Closes #6746
This commit is contained in:
committed by
Brian Behlendorf
parent
3ad59c015d
commit
d3f2cd7e3b
@@ -23,6 +23,7 @@
|
||||
* Copyright (c) 2012 by Delphix. All rights reserved.
|
||||
* Copyright 2014 Nexenta Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2016, 2017, Intel Corporation.
|
||||
* Copyright (c) 2017 Open-E, Inc. All Rights Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -722,6 +723,8 @@ zfsdle_vdev_online(zpool_handle_t *zhp, void *data)
|
||||
(void) strlcpy(fullpath, path, sizeof (fullpath));
|
||||
if (wholedisk) {
|
||||
char *spath = zfs_strip_partition(fullpath);
|
||||
boolean_t scrub_restart = B_TRUE;
|
||||
|
||||
if (!spath) {
|
||||
zed_log_msg(LOG_INFO, "%s: Can't alloc",
|
||||
__func__);
|
||||
@@ -736,7 +739,7 @@ zfsdle_vdev_online(zpool_handle_t *zhp, void *data)
|
||||
* device so that the kernel can update the size
|
||||
* of the expanded device.
|
||||
*/
|
||||
(void) zpool_reopen(zhp);
|
||||
(void) zpool_reopen_one(zhp, &scrub_restart);
|
||||
}
|
||||
|
||||
if (zpool_get_prop_int(zhp, ZPOOL_PROP_AUTOEXPAND, NULL)) {
|
||||
|
||||
+12
-21
@@ -28,6 +28,7 @@
|
||||
* Copyright (c) 2013 by Prasad Joshi (sTec). All rights reserved.
|
||||
* Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>.
|
||||
* Copyright (c) 2017 Datto Inc.
|
||||
* Copyright (c) 2017 Open-E, Inc. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
@@ -342,7 +343,7 @@ get_usage(zpool_help_t idx)
|
||||
case HELP_REMOVE:
|
||||
return (gettext("\tremove <pool> <device> ...\n"));
|
||||
case HELP_REOPEN:
|
||||
return (gettext("\treopen <pool>\n"));
|
||||
return (gettext("\treopen [-n] <pool>\n"));
|
||||
case HELP_SCRUB:
|
||||
return (gettext("\tscrub [-s | -p] <pool> ...\n"));
|
||||
case HELP_STATUS:
|
||||
@@ -5855,12 +5856,14 @@ zpool_do_reopen(int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
int ret = 0;
|
||||
zpool_handle_t *zhp;
|
||||
char *pool;
|
||||
boolean_t scrub_restart = B_TRUE;
|
||||
|
||||
/* check options */
|
||||
while ((c = getopt(argc, argv, "")) != -1) {
|
||||
while ((c = getopt(argc, argv, "n")) != -1) {
|
||||
switch (c) {
|
||||
case 'n':
|
||||
scrub_restart = B_FALSE;
|
||||
break;
|
||||
case '?':
|
||||
(void) fprintf(stderr, gettext("invalid option '%c'\n"),
|
||||
optopt);
|
||||
@@ -5868,25 +5871,13 @@ zpool_do_reopen(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (argc < 1) {
|
||||
(void) fprintf(stderr, gettext("missing pool name\n"));
|
||||
usage(B_FALSE);
|
||||
}
|
||||
/* if argc == 0 we will execute zpool_reopen_one on all pools */
|
||||
ret = for_each_pool(argc, argv, B_TRUE, NULL, zpool_reopen_one,
|
||||
&scrub_restart);
|
||||
|
||||
if (argc > 1) {
|
||||
(void) fprintf(stderr, gettext("too many arguments\n"));
|
||||
usage(B_FALSE);
|
||||
}
|
||||
|
||||
pool = argv[0];
|
||||
if ((zhp = zpool_open_canfail(g_zfs, pool)) == NULL)
|
||||
return (1);
|
||||
|
||||
ret = zpool_reopen(zhp);
|
||||
zpool_close(zhp);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user