mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
OpenZFS 9166 - zfs storage pool checkpoint
Details about the motivation of this feature and its usage can
be found in this blogpost:
https://sdimitro.github.io/post/zpool-checkpoint/
A lightning talk of this feature can be found here:
https://www.youtube.com/watch?v=fPQA8K40jAM
Implementation details can be found in big block comment of
spa_checkpoint.c
Side-changes that are relevant to this commit but not explained
elsewhere:
* renames members of "struct metaslab trees to be shorter without
losing meaning
* space_map_{alloc,truncate}() accept a block size as a
parameter. The reason is that in the current state all space
maps that we allocate through the DMU use a global tunable
(space_map_blksz) which defauls to 4KB. This is ok for metaslab
space maps in terms of bandwirdth since they are scattered all
over the disk. But for other space maps this default is probably
not what we want. Examples are device removal's vdev_obsolete_sm
or vdev_chedkpoint_sm from this review. Both of these have a
1:1 relationship with each vdev and could benefit from a bigger
block size.
Porting notes:
* The part of dsl_scan_sync() which handles async destroys has
been moved into the new dsl_process_async_destroys() function.
* Remove "VERIFY(!(flags & FWRITE))" in "kernel.c" so zhack can write
to block device backed pools.
* ZTS:
* Fix get_txg() in zpool_sync_001_pos due to "checkpoint_txg".
* Don't use large dd block sizes on /dev/urandom under Linux in
checkpoint_capacity.
* Adopt Delphix-OS's setting of 4 (spa_asize_inflation =
SPA_DVAS_PER_BP + 1) for the checkpoint_capacity test to speed
its attempts to fill the pool
* Create the base and nested pools with sync=disabled to speed up
the "setup" phase.
* Clear labels in test pool between checkpoint tests to avoid
duplicate pool issues.
* The import_rewind_device_replaced test has been marked as "known
to fail" for the reasons listed in its DISCLAIMER.
* New module parameters:
zfs_spa_discard_memory_limit,
zfs_remove_max_bytes_pause (not documented - debugging only)
vdev_max_ms_count (formerly metaslabs_per_vdev)
vdev_min_ms_count
Authored by: Serapheim Dimitropoulos <serapheim.dimitro@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: John Kennedy <john.kennedy@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Approved by: Richard Lowe <richlowe@richlowe.net>
Ported-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Tim Chase <tim@chase2k.com>
OpenZFS-issue: https://illumos.org/issues/9166
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/7159fdb8
Closes #7570
This commit is contained in:
committed by
Brian Behlendorf
parent
88eaf610d9
commit
d2734cce68
+733
-120
File diff suppressed because it is too large
Load Diff
+9
-3
@@ -25,7 +25,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2013, 2016 by Delphix. All rights reserved.
|
||||
* Copyright (c) 2013, 2017 by Delphix. All rights reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <sys/resource.h>
|
||||
#include <sys/zil.h>
|
||||
#include <sys/zil_impl.h>
|
||||
#include <sys/spa_impl.h>
|
||||
#include <sys/abd.h>
|
||||
|
||||
#include "zdb.h"
|
||||
@@ -166,7 +167,7 @@ zil_prt_rec_write(zilog_t *zilog, int txtype, void *arg)
|
||||
if (lr->lr_common.lrc_reclen == sizeof (lr_write_t)) {
|
||||
(void) printf("%shas blkptr, %s\n", tab_prefix,
|
||||
!BP_IS_HOLE(bp) &&
|
||||
bp->blk_birth >= spa_first_txg(zilog->zl_spa) ?
|
||||
bp->blk_birth >= spa_min_claim_txg(zilog->zl_spa) ?
|
||||
"will claim" : "won't claim");
|
||||
print_log_bp(bp, tab_prefix);
|
||||
|
||||
@@ -361,7 +362,7 @@ print_log_block(zilog_t *zilog, blkptr_t *bp, void *arg, uint64_t claim_txg)
|
||||
|
||||
if (claim_txg != 0)
|
||||
claim = "already claimed";
|
||||
else if (bp->blk_birth >= spa_first_txg(zilog->zl_spa))
|
||||
else if (bp->blk_birth >= spa_min_claim_txg(zilog->zl_spa))
|
||||
claim = "will claim";
|
||||
else
|
||||
claim = "won't claim";
|
||||
@@ -416,6 +417,11 @@ dump_intent_log(zilog_t *zilog)
|
||||
for (i = 0; i < TX_MAX_TYPE; i++)
|
||||
zil_rec_info[i].zri_count = 0;
|
||||
|
||||
/* see comment in zil_claim() or zil_check_log_chain() */
|
||||
if (zilog->zl_spa->spa_uberblock.ub_checkpoint_txg != 0 &&
|
||||
zh->zh_claim_txg == 0)
|
||||
return;
|
||||
|
||||
if (verbose >= 2) {
|
||||
(void) printf("\n");
|
||||
(void) zil_parse(zilog, print_log_block, print_log_record, NULL,
|
||||
|
||||
+207
-8
@@ -36,6 +36,7 @@
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
#include <libgen.h>
|
||||
#include <libintl.h>
|
||||
#include <libuutil.h>
|
||||
@@ -76,6 +77,8 @@ static int zpool_do_add(int, char **);
|
||||
static int zpool_do_remove(int, char **);
|
||||
static int zpool_do_labelclear(int, char **);
|
||||
|
||||
static int zpool_do_checkpoint(int, char **);
|
||||
|
||||
static int zpool_do_list(int, char **);
|
||||
static int zpool_do_iostat(int, char **);
|
||||
static int zpool_do_status(int, char **);
|
||||
@@ -131,6 +134,7 @@ typedef enum {
|
||||
HELP_ATTACH,
|
||||
HELP_CLEAR,
|
||||
HELP_CREATE,
|
||||
HELP_CHECKPOINT,
|
||||
HELP_DESTROY,
|
||||
HELP_DETACH,
|
||||
HELP_EXPORT,
|
||||
@@ -254,6 +258,8 @@ static zpool_command_t command_table[] = {
|
||||
{ NULL },
|
||||
{ "labelclear", zpool_do_labelclear, HELP_LABELCLEAR },
|
||||
{ NULL },
|
||||
{ "checkpoint", zpool_do_checkpoint, HELP_CHECKPOINT },
|
||||
{ NULL },
|
||||
{ "list", zpool_do_list, HELP_LIST },
|
||||
{ "iostat", zpool_do_iostat, HELP_IOSTAT },
|
||||
{ "status", zpool_do_status, HELP_STATUS },
|
||||
@@ -306,6 +312,8 @@ get_usage(zpool_help_t idx)
|
||||
return (gettext("\tcreate [-fnd] [-o property=value] ... \n"
|
||||
"\t [-O file-system-property=value] ... \n"
|
||||
"\t [-m mountpoint] [-R root] <pool> <vdev> ...\n"));
|
||||
case HELP_CHECKPOINT:
|
||||
return (gettext("\tcheckpoint [--discard] <pool> ...\n"));
|
||||
case HELP_DESTROY:
|
||||
return (gettext("\tdestroy [-f] <pool>\n"));
|
||||
case HELP_DETACH:
|
||||
@@ -316,15 +324,13 @@ get_usage(zpool_help_t idx)
|
||||
return (gettext("\thistory [-il] [<pool>] ...\n"));
|
||||
case HELP_IMPORT:
|
||||
return (gettext("\timport [-d dir] [-D]\n"
|
||||
"\timport [-d dir | -c cachefile] [-F [-n]] [-l] "
|
||||
"<pool | id>\n"
|
||||
"\timport [-o mntopts] [-o property=value] ... \n"
|
||||
"\t [-d dir | -c cachefile] [-D] [-l] [-f] [-m] [-N] "
|
||||
"[-R root] [-F [-n]] -a\n"
|
||||
"\timport [-o mntopts] [-o property=value] ... \n"
|
||||
"\t [-d dir | -c cachefile] [-D] [-l] [-f] [-m] [-N] "
|
||||
"[-R root] [-F [-n]]\n"
|
||||
"\t <pool | id> [newpool]\n"));
|
||||
"\t [--rewind-to-checkpoint] <pool | id> [newpool]\n"));
|
||||
case HELP_IOSTAT:
|
||||
return (gettext("\tiostat [[[-c [script1,script2,...]"
|
||||
"[-lq]]|[-rw]] [-T d | u] [-ghHLpPvy]\n"
|
||||
@@ -2453,6 +2459,79 @@ do_import(nvlist_t *config, const char *newname, const char *mntopts,
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* zpool checkpoint <pool>
|
||||
* checkpoint --discard <pool>
|
||||
*
|
||||
* -d Discard the checkpoint from a checkpointed
|
||||
* --discard pool.
|
||||
*
|
||||
* Checkpoints the specified pool, by taking a "snapshot" of its
|
||||
* current state. A pool can only have one checkpoint at a time.
|
||||
*/
|
||||
int
|
||||
zpool_do_checkpoint(int argc, char **argv)
|
||||
{
|
||||
boolean_t discard;
|
||||
char *pool;
|
||||
zpool_handle_t *zhp;
|
||||
int c, err;
|
||||
|
||||
struct option long_options[] = {
|
||||
{"discard", no_argument, NULL, 'd'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
discard = B_FALSE;
|
||||
while ((c = getopt_long(argc, argv, ":d", long_options, NULL)) != -1) {
|
||||
switch (c) {
|
||||
case 'd':
|
||||
discard = B_TRUE;
|
||||
break;
|
||||
case '?':
|
||||
(void) fprintf(stderr, gettext("invalid option '%c'\n"),
|
||||
optopt);
|
||||
usage(B_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (argc < 1) {
|
||||
(void) fprintf(stderr, gettext("missing pool argument\n"));
|
||||
usage(B_FALSE);
|
||||
}
|
||||
|
||||
if (argc > 1) {
|
||||
(void) fprintf(stderr, gettext("too many arguments\n"));
|
||||
usage(B_FALSE);
|
||||
}
|
||||
|
||||
pool = argv[0];
|
||||
|
||||
if ((zhp = zpool_open(g_zfs, pool)) == NULL) {
|
||||
/* As a special case, check for use of '/' in the name */
|
||||
if (strchr(pool, '/') != NULL)
|
||||
(void) fprintf(stderr, gettext("'zpool checkpoint' "
|
||||
"doesn't work on datasets. To save the state "
|
||||
"of a dataset from a specific point in time "
|
||||
"please use 'zfs snapshot'\n"));
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (discard)
|
||||
err = (zpool_discard_checkpoint(zhp) != 0);
|
||||
else
|
||||
err = (zpool_checkpoint(zhp) != 0);
|
||||
|
||||
zpool_close(zhp);
|
||||
|
||||
return (err);
|
||||
}
|
||||
|
||||
#define CHECKPOINT_OPT 1024
|
||||
|
||||
/*
|
||||
* zpool import [-d dir] [-D]
|
||||
* import [-o mntopts] [-o prop=value] ... [-R root] [-D] [-l]
|
||||
@@ -2499,6 +2578,9 @@ do_import(nvlist_t *config, const char *newname, const char *mntopts,
|
||||
* -s Scan using the default search path, the libblkid cache will
|
||||
* not be consulted.
|
||||
*
|
||||
* --rewind-to-checkpoint
|
||||
* Import the pool and revert back to the checkpoint.
|
||||
*
|
||||
* The import command scans for pools to import, and import pools based on pool
|
||||
* name and GUID. The pool can also be renamed as part of the import process.
|
||||
*/
|
||||
@@ -2534,8 +2616,14 @@ zpool_do_import(int argc, char **argv)
|
||||
importargs_t idata = { 0 };
|
||||
char *endptr;
|
||||
|
||||
struct option long_options[] = {
|
||||
{"rewind-to-checkpoint", no_argument, NULL, CHECKPOINT_OPT},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
/* check options */
|
||||
while ((c = getopt(argc, argv, ":aCc:d:DEfFlmnNo:R:stT:VX")) != -1) {
|
||||
while ((c = getopt_long(argc, argv, ":aCc:d:DEfFlmnNo:R:stT:VX",
|
||||
long_options, NULL)) != -1) {
|
||||
switch (c) {
|
||||
case 'a':
|
||||
do_all = B_TRUE;
|
||||
@@ -2622,6 +2710,9 @@ zpool_do_import(int argc, char **argv)
|
||||
case 'X':
|
||||
xtreme_rewind = B_TRUE;
|
||||
break;
|
||||
case CHECKPOINT_OPT:
|
||||
flags |= ZFS_IMPORT_CHECKPOINT;
|
||||
break;
|
||||
case ':':
|
||||
(void) fprintf(stderr, gettext("missing argument for "
|
||||
"'%c' option\n"), optopt);
|
||||
@@ -4977,6 +5068,7 @@ print_one_column(zpool_prop_t prop, uint64_t value, boolean_t scripted,
|
||||
|
||||
switch (prop) {
|
||||
case ZPOOL_PROP_EXPANDSZ:
|
||||
case ZPOOL_PROP_CHECKPOINT:
|
||||
if (value == 0)
|
||||
(void) strlcpy(propval, "-", sizeof (propval));
|
||||
else
|
||||
@@ -5064,6 +5156,8 @@ print_list_stats(zpool_handle_t *zhp, const char *name, nvlist_t *nv,
|
||||
toplevel, format);
|
||||
print_one_column(ZPOOL_PROP_FREE, vs->vs_space - vs->vs_alloc,
|
||||
scripted, toplevel, format);
|
||||
print_one_column(ZPOOL_PROP_CHECKPOINT,
|
||||
vs->vs_checkpoint_space, scripted, toplevel, format);
|
||||
print_one_column(ZPOOL_PROP_EXPANDSZ, vs->vs_esize, scripted,
|
||||
B_TRUE, format);
|
||||
print_one_column(ZPOOL_PROP_FRAGMENTATION,
|
||||
@@ -5187,8 +5281,8 @@ zpool_do_list(int argc, char **argv)
|
||||
int ret = 0;
|
||||
list_cbdata_t cb = { 0 };
|
||||
static char default_props[] =
|
||||
"name,size,allocated,free,expandsize,fragmentation,capacity,"
|
||||
"dedupratio,health,altroot";
|
||||
"name,size,allocated,free,checkpoint,expandsize,fragmentation,"
|
||||
"capacity,dedupratio,health,altroot";
|
||||
char *props = default_props;
|
||||
float interval = 0;
|
||||
unsigned long count = 0;
|
||||
@@ -5990,6 +6084,32 @@ typedef struct scrub_cbdata {
|
||||
pool_scrub_cmd_t cb_scrub_cmd;
|
||||
} scrub_cbdata_t;
|
||||
|
||||
static boolean_t
|
||||
zpool_has_checkpoint(zpool_handle_t *zhp)
|
||||
{
|
||||
nvlist_t *config, *nvroot;
|
||||
|
||||
config = zpool_get_config(zhp, NULL);
|
||||
|
||||
if (config != NULL) {
|
||||
pool_checkpoint_stat_t *pcs = NULL;
|
||||
uint_t c;
|
||||
|
||||
nvroot = fnvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE);
|
||||
(void) nvlist_lookup_uint64_array(nvroot,
|
||||
ZPOOL_CONFIG_CHECKPOINT_STATS, (uint64_t **)&pcs, &c);
|
||||
|
||||
if (pcs == NULL || pcs->pcs_state == CS_NONE)
|
||||
return (B_FALSE);
|
||||
|
||||
assert(pcs->pcs_state == CS_CHECKPOINT_EXISTS ||
|
||||
pcs->pcs_state == CS_CHECKPOINT_DISCARDING);
|
||||
return (B_TRUE);
|
||||
}
|
||||
|
||||
return (B_FALSE);
|
||||
}
|
||||
|
||||
int
|
||||
scrub_callback(zpool_handle_t *zhp, void *data)
|
||||
{
|
||||
@@ -6007,6 +6127,13 @@ scrub_callback(zpool_handle_t *zhp, void *data)
|
||||
|
||||
err = zpool_scan(zhp, cb->cb_type, cb->cb_scrub_cmd);
|
||||
|
||||
if (err == 0 && zpool_has_checkpoint(zhp) &&
|
||||
cb->cb_type == POOL_SCAN_SCRUB) {
|
||||
(void) printf(gettext("warning: will not scrub state that "
|
||||
"belongs to the checkpoint of pool '%s'\n"),
|
||||
zpool_get_name(zhp));
|
||||
}
|
||||
|
||||
return (err != 0);
|
||||
}
|
||||
|
||||
@@ -6211,6 +6338,40 @@ print_scan_status(pool_scan_stat_t *ps)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* As we don't scrub checkpointed blocks, we want to warn the
|
||||
* user that we skipped scanning some blocks if a checkpoint exists
|
||||
* or existed at any time during the scan.
|
||||
*/
|
||||
static void
|
||||
print_checkpoint_scan_warning(pool_scan_stat_t *ps, pool_checkpoint_stat_t *pcs)
|
||||
{
|
||||
if (ps == NULL || pcs == NULL)
|
||||
return;
|
||||
|
||||
if (pcs->pcs_state == CS_NONE ||
|
||||
pcs->pcs_state == CS_CHECKPOINT_DISCARDING)
|
||||
return;
|
||||
|
||||
assert(pcs->pcs_state == CS_CHECKPOINT_EXISTS);
|
||||
|
||||
if (ps->pss_state == DSS_NONE)
|
||||
return;
|
||||
|
||||
if ((ps->pss_state == DSS_FINISHED || ps->pss_state == DSS_CANCELED) &&
|
||||
ps->pss_end_time < pcs->pcs_start_time)
|
||||
return;
|
||||
|
||||
if (ps->pss_state == DSS_FINISHED || ps->pss_state == DSS_CANCELED) {
|
||||
(void) printf(gettext(" scan warning: skipped blocks "
|
||||
"that are only referenced by the checkpoint.\n"));
|
||||
} else {
|
||||
assert(ps->pss_state == DSS_SCANNING);
|
||||
(void) printf(gettext(" scan warning: skipping blocks "
|
||||
"that are only referenced by the checkpoint.\n"));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Print out detailed removal status.
|
||||
*/
|
||||
@@ -6316,6 +6477,39 @@ print_removal_status(zpool_handle_t *zhp, pool_removal_stat_t *prs)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_checkpoint_status(pool_checkpoint_stat_t *pcs)
|
||||
{
|
||||
time_t start;
|
||||
char space_buf[7];
|
||||
|
||||
if (pcs == NULL || pcs->pcs_state == CS_NONE)
|
||||
return;
|
||||
|
||||
(void) printf(gettext("checkpoint: "));
|
||||
|
||||
start = pcs->pcs_start_time;
|
||||
zfs_nicenum(pcs->pcs_space, space_buf, sizeof (space_buf));
|
||||
|
||||
if (pcs->pcs_state == CS_CHECKPOINT_EXISTS) {
|
||||
char *date = ctime(&start);
|
||||
|
||||
/*
|
||||
* ctime() adds a newline at the end of the generated
|
||||
* string, thus the weird format specifier and the
|
||||
* strlen() call used to chop it off from the output.
|
||||
*/
|
||||
(void) printf(gettext("created %.*s, consumes %s\n"),
|
||||
(int)(strlen(date) - 1), date, space_buf);
|
||||
return;
|
||||
}
|
||||
|
||||
assert(pcs->pcs_state == CS_CHECKPOINT_DISCARDING);
|
||||
|
||||
(void) printf(gettext("discarding, %s remaining.\n"),
|
||||
space_buf);
|
||||
}
|
||||
|
||||
static void
|
||||
print_error_log(zpool_handle_t *zhp)
|
||||
{
|
||||
@@ -6741,16 +6935,21 @@ status_callback(zpool_handle_t *zhp, void *data)
|
||||
uint64_t nerr;
|
||||
nvlist_t **spares, **l2cache;
|
||||
uint_t nspares, nl2cache;
|
||||
pool_checkpoint_stat_t *pcs = NULL;
|
||||
pool_scan_stat_t *ps = NULL;
|
||||
pool_removal_stat_t *prs = NULL;
|
||||
|
||||
(void) nvlist_lookup_uint64_array(nvroot,
|
||||
ZPOOL_CONFIG_CHECKPOINT_STATS, (uint64_t **)&pcs, &c);
|
||||
(void) nvlist_lookup_uint64_array(nvroot,
|
||||
ZPOOL_CONFIG_SCAN_STATS, (uint64_t **)&ps, &c);
|
||||
print_scan_status(ps);
|
||||
|
||||
(void) nvlist_lookup_uint64_array(nvroot,
|
||||
ZPOOL_CONFIG_REMOVAL_STATS, (uint64_t **)&prs, &c);
|
||||
|
||||
print_scan_status(ps);
|
||||
print_checkpoint_scan_warning(ps, pcs);
|
||||
print_removal_status(zhp, prs);
|
||||
print_checkpoint_status(pcs);
|
||||
|
||||
cbp->cb_namewidth = max_width(zhp, nvroot, 0, 0,
|
||||
cbp->cb_name_flags | VDEV_NAME_TYPE_ID);
|
||||
|
||||
+104
-9
@@ -345,6 +345,7 @@ ztest_func_t ztest_reguid;
|
||||
ztest_func_t ztest_spa_upgrade;
|
||||
ztest_func_t ztest_device_removal;
|
||||
ztest_func_t ztest_remap_blocks;
|
||||
ztest_func_t ztest_spa_checkpoint_create_discard;
|
||||
ztest_func_t ztest_fletcher;
|
||||
ztest_func_t ztest_fletcher_incr;
|
||||
ztest_func_t ztest_verify_dnode_bt;
|
||||
@@ -397,6 +398,7 @@ ztest_info_t ztest_info[] = {
|
||||
ZTI_INIT(ztest_vdev_aux_add_remove, 1, &ztest_opts.zo_vdevtime),
|
||||
ZTI_INIT(ztest_device_removal, 1, &zopt_sometimes),
|
||||
ZTI_INIT(ztest_remap_blocks, 1, &zopt_sometimes),
|
||||
ZTI_INIT(ztest_spa_checkpoint_create_discard, 1, &zopt_rarely),
|
||||
ZTI_INIT(ztest_fletcher, 1, &zopt_rarely),
|
||||
ZTI_INIT(ztest_fletcher_incr, 1, &zopt_rarely),
|
||||
ZTI_INIT(ztest_verify_dnode_bt, 1, &zopt_sometimes),
|
||||
@@ -446,6 +448,7 @@ static ztest_ds_t *ztest_ds;
|
||||
|
||||
static kmutex_t ztest_vdev_lock;
|
||||
static boolean_t ztest_device_removal_active = B_FALSE;
|
||||
static kmutex_t ztest_checkpoint_lock;
|
||||
|
||||
/*
|
||||
* The ztest_name_lock protects the pool and dataset namespace used by
|
||||
@@ -2864,6 +2867,62 @@ ztest_spa_upgrade(ztest_ds_t *zd, uint64_t id)
|
||||
mutex_exit(&ztest_vdev_lock);
|
||||
}
|
||||
|
||||
static void
|
||||
ztest_spa_checkpoint(spa_t *spa)
|
||||
{
|
||||
ASSERT(MUTEX_HELD(&ztest_checkpoint_lock));
|
||||
|
||||
int error = spa_checkpoint(spa->spa_name);
|
||||
|
||||
switch (error) {
|
||||
case 0:
|
||||
case ZFS_ERR_DEVRM_IN_PROGRESS:
|
||||
case ZFS_ERR_DISCARDING_CHECKPOINT:
|
||||
case ZFS_ERR_CHECKPOINT_EXISTS:
|
||||
break;
|
||||
case ENOSPC:
|
||||
ztest_record_enospc(FTAG);
|
||||
break;
|
||||
default:
|
||||
fatal(0, "spa_checkpoint(%s) = %d", spa->spa_name, error);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ztest_spa_discard_checkpoint(spa_t *spa)
|
||||
{
|
||||
ASSERT(MUTEX_HELD(&ztest_checkpoint_lock));
|
||||
|
||||
int error = spa_checkpoint_discard(spa->spa_name);
|
||||
|
||||
switch (error) {
|
||||
case 0:
|
||||
case ZFS_ERR_DISCARDING_CHECKPOINT:
|
||||
case ZFS_ERR_NO_CHECKPOINT:
|
||||
break;
|
||||
default:
|
||||
fatal(0, "spa_discard_checkpoint(%s) = %d",
|
||||
spa->spa_name, error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
void
|
||||
ztest_spa_checkpoint_create_discard(ztest_ds_t *zd, uint64_t id)
|
||||
{
|
||||
spa_t *spa = ztest_spa;
|
||||
|
||||
mutex_enter(&ztest_checkpoint_lock);
|
||||
if (ztest_random(2) == 0) {
|
||||
ztest_spa_checkpoint(spa);
|
||||
} else {
|
||||
ztest_spa_discard_checkpoint(spa);
|
||||
}
|
||||
mutex_exit(&ztest_checkpoint_lock);
|
||||
}
|
||||
|
||||
|
||||
static vdev_t *
|
||||
vdev_lookup_by_path(vdev_t *vd, const char *path)
|
||||
{
|
||||
@@ -2953,6 +3012,8 @@ ztest_vdev_add_remove(ztest_ds_t *zd, uint64_t id)
|
||||
case EEXIST: /* Generic zil_reset() error */
|
||||
case EBUSY: /* Replay required */
|
||||
case EACCES: /* Crypto key not loaded */
|
||||
case ZFS_ERR_CHECKPOINT_EXISTS:
|
||||
case ZFS_ERR_DISCARDING_CHECKPOINT:
|
||||
break;
|
||||
default:
|
||||
fatal(0, "spa_vdev_remove() = %d", error);
|
||||
@@ -2971,10 +3032,15 @@ ztest_vdev_add_remove(ztest_ds_t *zd, uint64_t id)
|
||||
error = spa_vdev_add(spa, nvroot);
|
||||
nvlist_free(nvroot);
|
||||
|
||||
if (error == ENOSPC)
|
||||
switch (error) {
|
||||
case 0:
|
||||
break;
|
||||
case ENOSPC:
|
||||
ztest_record_enospc("spa_vdev_add");
|
||||
else if (error != 0)
|
||||
break;
|
||||
default:
|
||||
fatal(0, "spa_vdev_add() = %d", error);
|
||||
}
|
||||
}
|
||||
|
||||
mutex_exit(&ztest_vdev_lock);
|
||||
@@ -3048,8 +3114,13 @@ ztest_vdev_aux_add_remove(ztest_ds_t *zd, uint64_t id)
|
||||
nvlist_t *nvroot = make_vdev_root(NULL, aux, NULL,
|
||||
(ztest_opts.zo_vdev_size * 5) / 4, 0, 0, 0, 0, 1);
|
||||
error = spa_vdev_add(spa, nvroot);
|
||||
if (error != 0)
|
||||
|
||||
switch (error) {
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
fatal(0, "spa_vdev_add(%p) = %d", nvroot, error);
|
||||
}
|
||||
nvlist_free(nvroot);
|
||||
} else {
|
||||
/*
|
||||
@@ -3061,8 +3132,16 @@ ztest_vdev_aux_add_remove(ztest_ds_t *zd, uint64_t id)
|
||||
(void) vdev_online(spa, guid, 0, NULL);
|
||||
|
||||
error = spa_vdev_remove(spa, guid, B_FALSE);
|
||||
if (error != 0 && error != EBUSY)
|
||||
|
||||
switch (error) {
|
||||
case 0:
|
||||
case EBUSY:
|
||||
case ZFS_ERR_CHECKPOINT_EXISTS:
|
||||
case ZFS_ERR_DISCARDING_CHECKPOINT:
|
||||
break;
|
||||
default:
|
||||
fatal(0, "spa_vdev_remove(%llu) = %d", guid, error);
|
||||
}
|
||||
}
|
||||
|
||||
mutex_exit(&ztest_vdev_lock);
|
||||
@@ -3166,7 +3245,6 @@ ztest_split_pool(ztest_ds_t *zd, uint64_t id)
|
||||
--zs->zs_mirrors;
|
||||
}
|
||||
mutex_exit(&ztest_vdev_lock);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3271,7 +3349,8 @@ ztest_vdev_attach_detach(ztest_ds_t *zd, uint64_t id)
|
||||
spa_config_exit(spa, SCL_ALL, FTAG);
|
||||
error = spa_vdev_detach(spa, oldguid, pguid, B_FALSE);
|
||||
if (error != 0 && error != ENODEV && error != EBUSY &&
|
||||
error != ENOTSUP)
|
||||
error != ENOTSUP && error != ZFS_ERR_CHECKPOINT_EXISTS &&
|
||||
error != ZFS_ERR_DISCARDING_CHECKPOINT)
|
||||
fatal(0, "detach (%s) returned %d", oldpath, error);
|
||||
goto out;
|
||||
}
|
||||
@@ -3362,6 +3441,10 @@ ztest_vdev_attach_detach(ztest_ds_t *zd, uint64_t id)
|
||||
if (error == EOVERFLOW || error == EBUSY)
|
||||
expected_error = error;
|
||||
|
||||
if (error == ZFS_ERR_CHECKPOINT_EXISTS ||
|
||||
error == ZFS_ERR_DISCARDING_CHECKPOINT)
|
||||
expected_error = error;
|
||||
|
||||
/* XXX workaround 6690467 */
|
||||
if (error != expected_error && expected_error != EBUSY) {
|
||||
fatal(0, "attach (%s %llu, %s %llu, %d) "
|
||||
@@ -3556,6 +3639,7 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, uint64_t id)
|
||||
uint64_t top;
|
||||
uint64_t old_class_space, new_class_space, old_ms_count, new_ms_count;
|
||||
|
||||
mutex_enter(&ztest_checkpoint_lock);
|
||||
mutex_enter(&ztest_vdev_lock);
|
||||
spa_config_enter(spa, SCL_STATE, spa, RW_READER);
|
||||
|
||||
@@ -3566,8 +3650,9 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, uint64_t id)
|
||||
* when the device removal completes).
|
||||
*/
|
||||
if (ztest_device_removal_active) {
|
||||
spa_config_exit(spa, SCL_STATE, FTAG);
|
||||
spa_config_exit(spa, SCL_STATE, spa);
|
||||
mutex_exit(&ztest_vdev_lock);
|
||||
mutex_exit(&ztest_checkpoint_lock);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3597,6 +3682,7 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, uint64_t id)
|
||||
psize == 0 || psize >= 4 * ztest_opts.zo_vdev_size) {
|
||||
spa_config_exit(spa, SCL_STATE, spa);
|
||||
mutex_exit(&ztest_vdev_lock);
|
||||
mutex_exit(&ztest_checkpoint_lock);
|
||||
return;
|
||||
}
|
||||
ASSERT(psize > 0);
|
||||
@@ -3622,6 +3708,7 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, uint64_t id)
|
||||
}
|
||||
spa_config_exit(spa, SCL_STATE, spa);
|
||||
mutex_exit(&ztest_vdev_lock);
|
||||
mutex_exit(&ztest_checkpoint_lock);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3656,6 +3743,7 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, uint64_t id)
|
||||
}
|
||||
spa_config_exit(spa, SCL_STATE, spa);
|
||||
mutex_exit(&ztest_vdev_lock);
|
||||
mutex_exit(&ztest_checkpoint_lock);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3686,6 +3774,7 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, uint64_t id)
|
||||
|
||||
spa_config_exit(spa, SCL_STATE, spa);
|
||||
mutex_exit(&ztest_vdev_lock);
|
||||
mutex_exit(&ztest_checkpoint_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -5722,7 +5811,7 @@ ztest_fault_inject(ztest_ds_t *zd, uint64_t id)
|
||||
*/
|
||||
fd = open(pathrand, O_RDWR);
|
||||
|
||||
if (fd == -1) /* we hit a gap in the device namespace */
|
||||
if (fd == -1) /* we hit a gap in the device namespace */
|
||||
goto out;
|
||||
|
||||
fsize = lseek(fd, 0, SEEK_END);
|
||||
@@ -6645,6 +6734,7 @@ ztest_run(ztest_shared_t *zs)
|
||||
* Initialize parent/child shared state.
|
||||
*/
|
||||
mutex_init(&ztest_vdev_lock, NULL, MUTEX_DEFAULT, NULL);
|
||||
mutex_init(&ztest_checkpoint_lock, NULL, MUTEX_DEFAULT, NULL);
|
||||
VERIFY0(pthread_rwlock_init(&ztest_name_lock, NULL));
|
||||
|
||||
zs->zs_thread_start = gethrtime();
|
||||
@@ -6696,7 +6786,7 @@ ztest_run(ztest_shared_t *zs)
|
||||
spa->spa_deadman_failmode = ZIO_FAILURE_MODE_PANIC;
|
||||
|
||||
/*
|
||||
* Verify that we can safely inquire about about any object,
|
||||
* Verify that we can safely inquire about any object,
|
||||
* whether it's allocated or not. To make it interesting,
|
||||
* we probe a 5-wide window around each power of two.
|
||||
* This hits all edge cases, including zero and the max.
|
||||
@@ -6804,6 +6894,7 @@ ztest_run(ztest_shared_t *zs)
|
||||
mutex_destroy(&zcl.zcl_callbacks_lock);
|
||||
(void) pthread_rwlock_destroy(&ztest_name_lock);
|
||||
mutex_destroy(&ztest_vdev_lock);
|
||||
mutex_destroy(&ztest_checkpoint_lock);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -6953,6 +7044,7 @@ ztest_import(ztest_shared_t *zs)
|
||||
int error;
|
||||
|
||||
mutex_init(&ztest_vdev_lock, NULL, MUTEX_DEFAULT, NULL);
|
||||
mutex_init(&ztest_checkpoint_lock, NULL, MUTEX_DEFAULT, NULL);
|
||||
VERIFY0(pthread_rwlock_init(&ztest_name_lock, NULL));
|
||||
|
||||
kernel_init(FREAD | FWRITE);
|
||||
@@ -6984,6 +7076,7 @@ ztest_import(ztest_shared_t *zs)
|
||||
|
||||
(void) pthread_rwlock_destroy(&ztest_name_lock);
|
||||
mutex_destroy(&ztest_vdev_lock);
|
||||
mutex_destroy(&ztest_checkpoint_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -6998,6 +7091,7 @@ ztest_init(ztest_shared_t *zs)
|
||||
int i;
|
||||
|
||||
mutex_init(&ztest_vdev_lock, NULL, MUTEX_DEFAULT, NULL);
|
||||
mutex_init(&ztest_checkpoint_lock, NULL, MUTEX_DEFAULT, NULL);
|
||||
VERIFY0(pthread_rwlock_init(&ztest_name_lock, NULL));
|
||||
|
||||
kernel_init(FREAD | FWRITE);
|
||||
@@ -7049,6 +7143,7 @@ ztest_init(ztest_shared_t *zs)
|
||||
|
||||
(void) pthread_rwlock_destroy(&ztest_name_lock);
|
||||
mutex_destroy(&ztest_vdev_lock);
|
||||
mutex_destroy(&ztest_checkpoint_lock);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user