MFV r331695, 331700: 9166 zfs storage pool checkpoint
illumos/illumos-gate@8671400134 The idea of Storage Pool Checkpoint (aka zpool checkpoint) deals with exactly that. It can be thought of as a “pool-wide snapshot” (or a variation of extreme rewind that doesn’t corrupt your data). It remembers the entire state of the pool at the point that it was taken and the user can revert back to it later or discard it. Its generic use case is an administrator that is about to perform a set of destructive actions to ZFS as part of a critical procedure. She takes a checkpoint of the pool before performing the actions, then rewinds back to it if one of them fails or puts the pool into an unexpected state. Otherwise, she discards it. With the assumption that no one else is making modifications to ZFS, she basically wraps all these actions into a “high-level transaction”. Reviewed by: Matthew Ahrens <mahrens@delphix.com> Reviewed by: John Kennedy <john.kennedy@delphix.com> Reviewed by: Dan Kimmel <dan.kimmel@delphix.com> Approved by: Richard Lowe <richlowe@richlowe.net> Author: Serapheim Dimitropoulos <serapheim.dimitro@delphix.com>
This commit is contained in:
commit
0b0c76bc58
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=331701
@ -21,7 +21,7 @@
|
|||||||
.Nd display zpool debugging and consistency information
|
.Nd display zpool debugging and consistency information
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl AbcdDFGhiLMPsvX
|
.Op Fl AbcdDFGhikLMPsvX
|
||||||
.Op Fl e Oo Fl V Oc Op Fl p Ar path ...
|
.Op Fl e Oo Fl V Oc Op Fl p Ar path ...
|
||||||
.Op Fl I Ar inflight I/Os
|
.Op Fl I Ar inflight I/Os
|
||||||
.Oo Fl o Ar var Ns = Ns Ar value Oc Ns ...
|
.Oo Fl o Ar var Ns = Ns Ar value Oc Ns ...
|
||||||
@ -170,6 +170,9 @@ Display information about intent log
|
|||||||
.Pq ZIL
|
.Pq ZIL
|
||||||
entries relating to each dataset.
|
entries relating to each dataset.
|
||||||
If specified multiple times, display counts of each intent log transaction type.
|
If specified multiple times, display counts of each intent log transaction type.
|
||||||
|
.It Fl k
|
||||||
|
Examine the checkpointed state of the pool.
|
||||||
|
Note, the on disk format of the pool is not reverted to the checkpointed state.
|
||||||
.It Fl l Ar device
|
.It Fl l Ar device
|
||||||
Read the vdev labels from the specified device.
|
Read the vdev labels from the specified device.
|
||||||
.Nm Fl l
|
.Nm Fl l
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, 2016 by Delphix. All rights reserved.
|
* Copyright (c) 2013, 2017 by Delphix. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -41,6 +41,7 @@
|
|||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#include <sys/zil.h>
|
#include <sys/zil.h>
|
||||||
#include <sys/zil_impl.h>
|
#include <sys/zil_impl.h>
|
||||||
|
#include <sys/spa_impl.h>
|
||||||
#include <sys/abd.h>
|
#include <sys/abd.h>
|
||||||
|
|
||||||
#include "zdb.h"
|
#include "zdb.h"
|
||||||
@ -162,7 +163,7 @@ zil_prt_rec_write(zilog_t *zilog, int txtype, void *arg)
|
|||||||
if (lr->lr_common.lrc_reclen == sizeof (lr_write_t)) {
|
if (lr->lr_common.lrc_reclen == sizeof (lr_write_t)) {
|
||||||
(void) printf("%shas blkptr, %s\n", tab_prefix,
|
(void) printf("%shas blkptr, %s\n", tab_prefix,
|
||||||
!BP_IS_HOLE(bp) &&
|
!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");
|
"will claim" : "won't claim");
|
||||||
print_log_bp(bp, tab_prefix);
|
print_log_bp(bp, tab_prefix);
|
||||||
|
|
||||||
@ -352,7 +353,7 @@ print_log_block(zilog_t *zilog, blkptr_t *bp, void *arg, uint64_t claim_txg)
|
|||||||
|
|
||||||
if (claim_txg != 0)
|
if (claim_txg != 0)
|
||||||
claim = "already claimed";
|
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";
|
claim = "will claim";
|
||||||
else
|
else
|
||||||
claim = "won't claim";
|
claim = "won't claim";
|
||||||
@ -407,6 +408,11 @@ dump_intent_log(zilog_t *zilog)
|
|||||||
for (i = 0; i < TX_MAX_TYPE; i++)
|
for (i = 0; i < TX_MAX_TYPE; i++)
|
||||||
zil_rec_info[i].zri_count = 0;
|
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) {
|
if (verbose >= 2) {
|
||||||
(void) printf("\n");
|
(void) printf("\n");
|
||||||
(void) zil_parse(zilog, print_log_block, print_log_record, NULL,
|
(void) zil_parse(zilog, print_log_block, print_log_record, NULL,
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
.\" fields enclosed by brackets "[]" replaced with your own identifying
|
.\" fields enclosed by brackets "[]" replaced with your own identifying
|
||||||
.\" information: Portions Copyright [yyyy] [name of copyright owner]
|
.\" information: Portions Copyright [yyyy] [name of copyright owner]
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 2012 by Delphix. All rights reserved.
|
.\" Copyright (c) 2012, 2017 by Delphix. All rights reserved.
|
||||||
.\" Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
|
.\" Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
|
||||||
.\" Copyright (c) 2013, Joyent, Inc. All rights reserved.
|
.\" Copyright (c) 2013, Joyent, Inc. All rights reserved.
|
||||||
.\"
|
.\"
|
||||||
@ -431,6 +431,23 @@ This feature becomes
|
|||||||
as soon as it is enabled and will
|
as soon as it is enabled and will
|
||||||
never return to being
|
never return to being
|
||||||
.Sy enabled .
|
.Sy enabled .
|
||||||
|
.It Sy zpool_checkpoint
|
||||||
|
.Bl -column "READ\-ONLY COMPATIBLE" "com.delphix:zpool_checkpoint"
|
||||||
|
.It GUID Ta com.delphix:zpool_checkpoint
|
||||||
|
.It READ\-ONLY COMPATIBLE Ta yes
|
||||||
|
.It DEPENDENCIES Ta none
|
||||||
|
.El
|
||||||
|
.Pp
|
||||||
|
This feature enables the "zpool checkpoint" subcommand that can
|
||||||
|
checkpoint the state of the pool at the time it was issued and later
|
||||||
|
rewind back to it or discard it.
|
||||||
|
.Pp
|
||||||
|
This feature becomes
|
||||||
|
.Sy active
|
||||||
|
when the "zpool checkpoint" command is used to checkpoint the pool.
|
||||||
|
The feature will only return back to being
|
||||||
|
.Sy enabled
|
||||||
|
when the pool is rewound or the checkpoint has been discarded.
|
||||||
.It Sy large_blocks
|
.It Sy large_blocks
|
||||||
.Bl -column "READ\-ONLY COMPATIBLE" "org.open-zfs:large_block"
|
.Bl -column "READ\-ONLY COMPATIBLE" "org.open-zfs:large_block"
|
||||||
.It GUID Ta org.open-zfs:large_block
|
.It GUID Ta org.open-zfs:large_block
|
||||||
|
@ -45,6 +45,10 @@
|
|||||||
.Op Fl f
|
.Op Fl f
|
||||||
.Ar pool device new_device
|
.Ar pool device new_device
|
||||||
.Nm
|
.Nm
|
||||||
|
.Cm checkpoint
|
||||||
|
.Op Fl d, -discard
|
||||||
|
.Ar pool
|
||||||
|
.Nm
|
||||||
.Cm clear
|
.Cm clear
|
||||||
.Op Fl F Op Fl n
|
.Op Fl F Op Fl n
|
||||||
.Ar pool
|
.Ar pool
|
||||||
@ -90,6 +94,7 @@
|
|||||||
.Op Fl o Ar mntopts
|
.Op Fl o Ar mntopts
|
||||||
.Op Fl o Ar property Ns = Ns Ar value
|
.Op Fl o Ar property Ns = Ns Ar value
|
||||||
.Ar ...
|
.Ar ...
|
||||||
|
.Op Fl -rewind-to-checkpoint
|
||||||
.Op Fl d Ar dir | Fl c Ar cachefile
|
.Op Fl d Ar dir | Fl c Ar cachefile
|
||||||
.Op Fl D
|
.Op Fl D
|
||||||
.Op Fl f
|
.Op Fl f
|
||||||
@ -103,6 +108,7 @@
|
|||||||
.Op Fl o Ar mntopts
|
.Op Fl o Ar mntopts
|
||||||
.Op Fl o Ar property Ns = Ns Ar value
|
.Op Fl o Ar property Ns = Ns Ar value
|
||||||
.Ar ...
|
.Ar ...
|
||||||
|
.Op Fl -rewind-to-checkpoint
|
||||||
.Op Fl d Ar dir | Fl c Ar cachefile
|
.Op Fl d Ar dir | Fl c Ar cachefile
|
||||||
.Op Fl D
|
.Op Fl D
|
||||||
.Op Fl f
|
.Op Fl f
|
||||||
@ -532,6 +538,50 @@ configuration.
|
|||||||
.Pp
|
.Pp
|
||||||
The content of the cache devices is considered volatile, as is the case with
|
The content of the cache devices is considered volatile, as is the case with
|
||||||
other system caches.
|
other system caches.
|
||||||
|
.Ss Pool checkpoint
|
||||||
|
Before starting critical procedures that include destructive actions (e.g
|
||||||
|
.Nm zfs Cm destroy
|
||||||
|
), an administrator can checkpoint the pool's state and in the case of a
|
||||||
|
mistake or failure, rewind the entire pool back to the checkpoint.
|
||||||
|
Otherwise, the checkpoint can be discarded when the procedure has completed
|
||||||
|
successfully.
|
||||||
|
.Pp
|
||||||
|
A pool checkpoint can be thought of as a pool-wide snapshot and should be used
|
||||||
|
with care as it contains every part of the pool's state, from properties to vdev
|
||||||
|
configuration.
|
||||||
|
Thus, while a pool has a checkpoint certain operations are not allowed.
|
||||||
|
Specifically, vdev removal/attach/detach, mirror splitting, and
|
||||||
|
changing the pool's guid.
|
||||||
|
Adding a new vdev is supported but in the case of a rewind it will have to be
|
||||||
|
added again.
|
||||||
|
Finally, users of this feature should keep in mind that scrubs in a pool that
|
||||||
|
has a checkpoint do not repair checkpointed data.
|
||||||
|
.Pp
|
||||||
|
To create a checkpoint for a pool:
|
||||||
|
.Bd -literal
|
||||||
|
# zpool checkpoint pool
|
||||||
|
.Ed
|
||||||
|
.Pp
|
||||||
|
To later rewind to its checkpointed state, you need to first export it and
|
||||||
|
then rewind it during import:
|
||||||
|
.Bd -literal
|
||||||
|
# zpool export pool
|
||||||
|
# zpool import --rewind-to-checkpoint pool
|
||||||
|
.Ed
|
||||||
|
.Pp
|
||||||
|
To discard the checkpoint from a pool:
|
||||||
|
.Bd -literal
|
||||||
|
# zpool checkpoint -d pool
|
||||||
|
.Ed
|
||||||
|
.Pp
|
||||||
|
Dataset reservations (controlled by the
|
||||||
|
.Nm reservation
|
||||||
|
or
|
||||||
|
.Nm refreservation
|
||||||
|
zfs properties) may be unenforceable while a checkpoint exists, because the
|
||||||
|
checkpoint is allowed to consume the dataset's reservation.
|
||||||
|
Finally, data that is part of the checkpoint but has been freed in the
|
||||||
|
current state of the pool won't be scanned during a scrub.
|
||||||
.Ss Properties
|
.Ss Properties
|
||||||
Each pool has several properties associated with it. Some properties are
|
Each pool has several properties associated with it. Some properties are
|
||||||
read-only statistics while others are configurable and change the behavior of
|
read-only statistics while others are configurable and change the behavior of
|
||||||
@ -847,6 +897,39 @@ manner.
|
|||||||
.El
|
.El
|
||||||
.It Xo
|
.It Xo
|
||||||
.Nm
|
.Nm
|
||||||
|
.Cm checkpoint
|
||||||
|
.Op Fl d, -discard
|
||||||
|
.Ar pool
|
||||||
|
.Xc
|
||||||
|
Checkpoints the current state of
|
||||||
|
.Ar pool
|
||||||
|
, which can be later restored by
|
||||||
|
.Nm zpool Cm import --rewind-to-checkpoint .
|
||||||
|
The existence of a checkpoint in a pool prohibits the following
|
||||||
|
.Nm zpool
|
||||||
|
commands:
|
||||||
|
.Cm remove ,
|
||||||
|
.Cm attach ,
|
||||||
|
.Cm detach ,
|
||||||
|
.Cm split ,
|
||||||
|
and
|
||||||
|
.Cm reguid .
|
||||||
|
In addition, it may break reservation boundaries if the pool lacks free
|
||||||
|
space.
|
||||||
|
The
|
||||||
|
.Nm zpool Cm status
|
||||||
|
command indicates the existence of a checkpoint or the progress of discarding a
|
||||||
|
checkpoint from a pool.
|
||||||
|
The
|
||||||
|
.Nm zpool Cm list
|
||||||
|
command reports how much space the checkpoint takes from the pool.
|
||||||
|
.Bl -tag -width Ds
|
||||||
|
.It Fl d, -discard
|
||||||
|
Discards an existing checkpoint from
|
||||||
|
.Ar pool .
|
||||||
|
.El
|
||||||
|
.It Xo
|
||||||
|
.Nm
|
||||||
.Cm clear
|
.Cm clear
|
||||||
.Op Fl F Op Fl n
|
.Op Fl F Op Fl n
|
||||||
.Ar pool
|
.Ar pool
|
||||||
@ -1306,6 +1389,16 @@ importable again, but does not actually perform the pool recovery. For more
|
|||||||
details about pool recovery mode, see the
|
details about pool recovery mode, see the
|
||||||
.Fl F
|
.Fl F
|
||||||
option, above.
|
option, above.
|
||||||
|
.It Fl -rewind-to-checkpoint
|
||||||
|
Rewinds pool to the checkpointed state.
|
||||||
|
Once the pool is imported with this flag there is no way to undo the rewind.
|
||||||
|
All changes and data that were written after the checkpoint are lost!
|
||||||
|
The only exception is when the
|
||||||
|
.Sy readonly
|
||||||
|
mounting option is enabled.
|
||||||
|
In this case, the checkpointed state of the pool is opened and an
|
||||||
|
administrator can see how the pool would look like if they were
|
||||||
|
to fully rewind.
|
||||||
.El
|
.El
|
||||||
.It Xo
|
.It Xo
|
||||||
.Nm
|
.Nm
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <getopt.h>
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#include <libintl.h>
|
#include <libintl.h>
|
||||||
#include <libuutil.h>
|
#include <libuutil.h>
|
||||||
@ -68,6 +69,8 @@ static int zpool_do_add(int, char **);
|
|||||||
static int zpool_do_remove(int, char **);
|
static int zpool_do_remove(int, char **);
|
||||||
static int zpool_do_labelclear(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_list(int, char **);
|
||||||
static int zpool_do_iostat(int, char **);
|
static int zpool_do_iostat(int, char **);
|
||||||
static int zpool_do_status(int, char **);
|
static int zpool_do_status(int, char **);
|
||||||
@ -120,6 +123,7 @@ typedef enum {
|
|||||||
HELP_ATTACH,
|
HELP_ATTACH,
|
||||||
HELP_CLEAR,
|
HELP_CLEAR,
|
||||||
HELP_CREATE,
|
HELP_CREATE,
|
||||||
|
HELP_CHECKPOINT,
|
||||||
HELP_DESTROY,
|
HELP_DESTROY,
|
||||||
HELP_DETACH,
|
HELP_DETACH,
|
||||||
HELP_EXPORT,
|
HELP_EXPORT,
|
||||||
@ -167,6 +171,8 @@ static zpool_command_t command_table[] = {
|
|||||||
{ NULL },
|
{ NULL },
|
||||||
{ "labelclear", zpool_do_labelclear, HELP_LABELCLEAR },
|
{ "labelclear", zpool_do_labelclear, HELP_LABELCLEAR },
|
||||||
{ NULL },
|
{ NULL },
|
||||||
|
{ "checkpoint", zpool_do_checkpoint, HELP_CHECKPOINT },
|
||||||
|
{ NULL },
|
||||||
{ "list", zpool_do_list, HELP_LIST },
|
{ "list", zpool_do_list, HELP_LIST },
|
||||||
{ "iostat", zpool_do_iostat, HELP_IOSTAT },
|
{ "iostat", zpool_do_iostat, HELP_IOSTAT },
|
||||||
{ "status", zpool_do_status, HELP_STATUS },
|
{ "status", zpool_do_status, HELP_STATUS },
|
||||||
@ -216,6 +222,8 @@ get_usage(zpool_help_t idx)
|
|||||||
"[-o property=value] ... \n"
|
"[-o property=value] ... \n"
|
||||||
"\t [-O file-system-property=value] ... \n"
|
"\t [-O file-system-property=value] ... \n"
|
||||||
"\t [-m mountpoint] [-R root] <pool> <vdev> ...\n"));
|
"\t [-m mountpoint] [-R root] <pool> <vdev> ...\n"));
|
||||||
|
case HELP_CHECKPOINT:
|
||||||
|
return (gettext("\tcheckpoint [--discard] <pool> ...\n"));
|
||||||
case HELP_DESTROY:
|
case HELP_DESTROY:
|
||||||
return (gettext("\tdestroy [-f] <pool>\n"));
|
return (gettext("\tdestroy [-f] <pool>\n"));
|
||||||
case HELP_DETACH:
|
case HELP_DETACH:
|
||||||
@ -226,14 +234,13 @@ get_usage(zpool_help_t idx)
|
|||||||
return (gettext("\thistory [-il] [<pool>] ...\n"));
|
return (gettext("\thistory [-il] [<pool>] ...\n"));
|
||||||
case HELP_IMPORT:
|
case HELP_IMPORT:
|
||||||
return (gettext("\timport [-d dir] [-D]\n"
|
return (gettext("\timport [-d dir] [-D]\n"
|
||||||
"\timport [-d dir | -c cachefile] [-F [-n]] <pool | id>\n"
|
|
||||||
"\timport [-o mntopts] [-o property=value] ... \n"
|
"\timport [-o mntopts] [-o property=value] ... \n"
|
||||||
"\t [-d dir | -c cachefile] [-D] [-f] [-m] [-N] "
|
"\t [-d dir | -c cachefile] [-D] [-f] [-m] [-N] "
|
||||||
"[-R root] [-F [-n]] -a\n"
|
"[-R root] [-F [-n]] -a\n"
|
||||||
"\timport [-o mntopts] [-o property=value] ... \n"
|
"\timport [-o mntopts] [-o property=value] ... \n"
|
||||||
"\t [-d dir | -c cachefile] [-D] [-f] [-m] [-N] "
|
"\t [-d dir | -c cachefile] [-D] [-f] [-m] [-N] "
|
||||||
"[-R root] [-F [-n]]\n"
|
"[-R root] [-F [-n]]\n"
|
||||||
"\t <pool | id> [newpool]\n"));
|
"\t [--rewind-to-checkpoint] <pool | id> [newpool]\n"));
|
||||||
case HELP_IOSTAT:
|
case HELP_IOSTAT:
|
||||||
return (gettext("\tiostat [-v] [-T d|u] [pool] ... [interval "
|
return (gettext("\tiostat [-v] [-T d|u] [pool] ... [interval "
|
||||||
"[count]]\n"));
|
"[count]]\n"));
|
||||||
@ -2077,6 +2084,79 @@ do_import(nvlist_t *config, const char *newname, const char *mntopts,
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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]
|
* zpool import [-d dir] [-D]
|
||||||
* import [-o mntopts] [-o prop=value] ... [-R root] [-D]
|
* import [-o mntopts] [-o prop=value] ... [-R root] [-D]
|
||||||
@ -2118,6 +2198,9 @@ do_import(nvlist_t *config, const char *newname, const char *mntopts,
|
|||||||
*
|
*
|
||||||
* -o Set property=value and/or temporary mount options (without '=').
|
* -o Set property=value and/or temporary mount options (without '=').
|
||||||
*
|
*
|
||||||
|
* --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
|
* 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.
|
* name and GUID. The pool can also be renamed as part of the import process.
|
||||||
*/
|
*/
|
||||||
@ -2151,8 +2234,15 @@ zpool_do_import(int argc, char **argv)
|
|||||||
importargs_t idata = { 0 };
|
importargs_t idata = { 0 };
|
||||||
char *endptr;
|
char *endptr;
|
||||||
|
|
||||||
|
|
||||||
|
struct option long_options[] = {
|
||||||
|
{"rewind-to-checkpoint", no_argument, NULL, CHECKPOINT_OPT},
|
||||||
|
{0, 0, 0, 0}
|
||||||
|
};
|
||||||
|
|
||||||
/* check options */
|
/* check options */
|
||||||
while ((c = getopt(argc, argv, ":aCc:d:DEfFmnNo:R:T:VX")) != -1) {
|
while ((c = getopt_long(argc, argv, ":aCc:d:DEfFmnNo:rR:T:VX",
|
||||||
|
long_options, NULL)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'a':
|
case 'a':
|
||||||
do_all = B_TRUE;
|
do_all = B_TRUE;
|
||||||
@ -2230,6 +2320,9 @@ zpool_do_import(int argc, char **argv)
|
|||||||
case 'X':
|
case 'X':
|
||||||
xtreme_rewind = B_TRUE;
|
xtreme_rewind = B_TRUE;
|
||||||
break;
|
break;
|
||||||
|
case CHECKPOINT_OPT:
|
||||||
|
flags |= ZFS_IMPORT_CHECKPOINT;
|
||||||
|
break;
|
||||||
case ':':
|
case ':':
|
||||||
(void) fprintf(stderr, gettext("missing argument for "
|
(void) fprintf(stderr, gettext("missing argument for "
|
||||||
"'%c' option\n"), optopt);
|
"'%c' option\n"), optopt);
|
||||||
@ -3087,6 +3180,7 @@ print_one_column(zpool_prop_t prop, uint64_t value, boolean_t scripted,
|
|||||||
|
|
||||||
switch (prop) {
|
switch (prop) {
|
||||||
case ZPOOL_PROP_EXPANDSZ:
|
case ZPOOL_PROP_EXPANDSZ:
|
||||||
|
case ZPOOL_PROP_CHECKPOINT:
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
(void) strlcpy(propval, "-", sizeof (propval));
|
(void) strlcpy(propval, "-", sizeof (propval));
|
||||||
else
|
else
|
||||||
@ -3159,6 +3253,8 @@ print_list_stats(zpool_handle_t *zhp, const char *name, nvlist_t *nv,
|
|||||||
toplevel);
|
toplevel);
|
||||||
print_one_column(ZPOOL_PROP_FREE, vs->vs_space - vs->vs_alloc,
|
print_one_column(ZPOOL_PROP_FREE, vs->vs_space - vs->vs_alloc,
|
||||||
scripted, toplevel);
|
scripted, toplevel);
|
||||||
|
print_one_column(ZPOOL_PROP_CHECKPOINT,
|
||||||
|
vs->vs_checkpoint_space, scripted, toplevel);
|
||||||
print_one_column(ZPOOL_PROP_EXPANDSZ, vs->vs_esize, scripted,
|
print_one_column(ZPOOL_PROP_EXPANDSZ, vs->vs_esize, scripted,
|
||||||
B_TRUE);
|
B_TRUE);
|
||||||
print_one_column(ZPOOL_PROP_FRAGMENTATION,
|
print_one_column(ZPOOL_PROP_FRAGMENTATION,
|
||||||
@ -3273,8 +3369,8 @@ zpool_do_list(int argc, char **argv)
|
|||||||
int ret;
|
int ret;
|
||||||
list_cbdata_t cb = { 0 };
|
list_cbdata_t cb = { 0 };
|
||||||
static char default_props[] =
|
static char default_props[] =
|
||||||
"name,size,allocated,free,expandsize,fragmentation,capacity,"
|
"name,size,allocated,free,checkpoint,expandsize,fragmentation,"
|
||||||
"dedupratio,health,altroot";
|
"capacity,dedupratio,health,altroot";
|
||||||
char *props = default_props;
|
char *props = default_props;
|
||||||
unsigned long interval = 0, count = 0;
|
unsigned long interval = 0, count = 0;
|
||||||
zpool_list_t *list;
|
zpool_list_t *list;
|
||||||
@ -3994,6 +4090,32 @@ typedef struct scrub_cbdata {
|
|||||||
pool_scrub_cmd_t cb_scrub_cmd;
|
pool_scrub_cmd_t cb_scrub_cmd;
|
||||||
} scrub_cbdata_t;
|
} 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
|
int
|
||||||
scrub_callback(zpool_handle_t *zhp, void *data)
|
scrub_callback(zpool_handle_t *zhp, void *data)
|
||||||
{
|
{
|
||||||
@ -4011,6 +4133,13 @@ scrub_callback(zpool_handle_t *zhp, void *data)
|
|||||||
|
|
||||||
err = zpool_scan(zhp, cb->cb_type, cb->cb_scrub_cmd);
|
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);
|
return (err != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4203,6 +4332,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.
|
* Print out detailed removal status.
|
||||||
*/
|
*/
|
||||||
@ -4308,6 +4471,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"),
|
||||||
|
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
|
static void
|
||||||
print_error_log(zpool_handle_t *zhp)
|
print_error_log(zpool_handle_t *zhp)
|
||||||
{
|
{
|
||||||
@ -4689,16 +4885,21 @@ status_callback(zpool_handle_t *zhp, void *data)
|
|||||||
uint64_t nerr;
|
uint64_t nerr;
|
||||||
nvlist_t **spares, **l2cache;
|
nvlist_t **spares, **l2cache;
|
||||||
uint_t nspares, nl2cache;
|
uint_t nspares, nl2cache;
|
||||||
|
pool_checkpoint_stat_t *pcs = NULL;
|
||||||
pool_scan_stat_t *ps = NULL;
|
pool_scan_stat_t *ps = NULL;
|
||||||
pool_removal_stat_t *prs = 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,
|
(void) nvlist_lookup_uint64_array(nvroot,
|
||||||
ZPOOL_CONFIG_SCAN_STATS, (uint64_t **)&ps, &c);
|
ZPOOL_CONFIG_SCAN_STATS, (uint64_t **)&ps, &c);
|
||||||
print_scan_status(ps);
|
|
||||||
|
|
||||||
(void) nvlist_lookup_uint64_array(nvroot,
|
(void) nvlist_lookup_uint64_array(nvroot,
|
||||||
ZPOOL_CONFIG_REMOVAL_STATS, (uint64_t **)&prs, &c);
|
ZPOOL_CONFIG_REMOVAL_STATS, (uint64_t **)&prs, &c);
|
||||||
|
|
||||||
|
print_scan_status(ps);
|
||||||
|
print_checkpoint_scan_warning(ps, pcs);
|
||||||
print_removal_status(zhp, prs);
|
print_removal_status(zhp, prs);
|
||||||
|
print_checkpoint_status(pcs);
|
||||||
|
|
||||||
namewidth = max_width(zhp, nvroot, 0, 0);
|
namewidth = max_width(zhp, nvroot, 0, 0);
|
||||||
if (namewidth < 10)
|
if (namewidth < 10)
|
||||||
|
@ -346,6 +346,7 @@ ztest_func_t ztest_reguid;
|
|||||||
ztest_func_t ztest_spa_upgrade;
|
ztest_func_t ztest_spa_upgrade;
|
||||||
ztest_func_t ztest_device_removal;
|
ztest_func_t ztest_device_removal;
|
||||||
ztest_func_t ztest_remap_blocks;
|
ztest_func_t ztest_remap_blocks;
|
||||||
|
ztest_func_t ztest_spa_checkpoint_create_discard;
|
||||||
|
|
||||||
uint64_t zopt_always = 0ULL * NANOSEC; /* all the time */
|
uint64_t zopt_always = 0ULL * NANOSEC; /* all the time */
|
||||||
uint64_t zopt_incessant = 1ULL * NANOSEC / 10; /* every 1/10 second */
|
uint64_t zopt_incessant = 1ULL * NANOSEC / 10; /* every 1/10 second */
|
||||||
@ -388,7 +389,8 @@ ztest_info_t ztest_info[] = {
|
|||||||
{ ztest_vdev_aux_add_remove, 1,
|
{ ztest_vdev_aux_add_remove, 1,
|
||||||
&ztest_opts.zo_vdevtime },
|
&ztest_opts.zo_vdevtime },
|
||||||
{ ztest_device_removal, 1, &zopt_sometimes },
|
{ ztest_device_removal, 1, &zopt_sometimes },
|
||||||
{ ztest_remap_blocks, 1, &zopt_sometimes }
|
{ ztest_remap_blocks, 1, &zopt_sometimes },
|
||||||
|
{ ztest_spa_checkpoint_create_discard, 1, &zopt_rarely }
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ZTEST_FUNCS (sizeof (ztest_info) / sizeof (ztest_info_t))
|
#define ZTEST_FUNCS (sizeof (ztest_info) / sizeof (ztest_info_t))
|
||||||
@ -434,6 +436,7 @@ static spa_t *ztest_spa = NULL;
|
|||||||
static ztest_ds_t *ztest_ds;
|
static ztest_ds_t *ztest_ds;
|
||||||
|
|
||||||
static kmutex_t ztest_vdev_lock;
|
static kmutex_t ztest_vdev_lock;
|
||||||
|
static kmutex_t ztest_checkpoint_lock;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The ztest_name_lock protects the pool and dataset namespace used by
|
* The ztest_name_lock protects the pool and dataset namespace used by
|
||||||
@ -2478,6 +2481,62 @@ ztest_spa_upgrade(ztest_ds_t *zd, uint64_t id)
|
|||||||
mutex_exit(&ztest_vdev_lock);
|
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 *
|
static vdev_t *
|
||||||
vdev_lookup_by_path(vdev_t *vd, const char *path)
|
vdev_lookup_by_path(vdev_t *vd, const char *path)
|
||||||
{
|
{
|
||||||
@ -2558,8 +2617,15 @@ ztest_vdev_add_remove(ztest_ds_t *zd, uint64_t id)
|
|||||||
error = spa_vdev_remove(spa, guid, B_FALSE);
|
error = spa_vdev_remove(spa, guid, B_FALSE);
|
||||||
rw_exit(&ztest_name_lock);
|
rw_exit(&ztest_name_lock);
|
||||||
|
|
||||||
if (error && error != EEXIST)
|
switch (error) {
|
||||||
|
case 0:
|
||||||
|
case EEXIST:
|
||||||
|
case ZFS_ERR_CHECKPOINT_EXISTS:
|
||||||
|
case ZFS_ERR_DISCARDING_CHECKPOINT:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
fatal(0, "spa_vdev_remove() = %d", error);
|
fatal(0, "spa_vdev_remove() = %d", error);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
spa_config_exit(spa, SCL_VDEV, FTAG);
|
spa_config_exit(spa, SCL_VDEV, FTAG);
|
||||||
|
|
||||||
@ -2574,10 +2640,15 @@ ztest_vdev_add_remove(ztest_ds_t *zd, uint64_t id)
|
|||||||
error = spa_vdev_add(spa, nvroot);
|
error = spa_vdev_add(spa, nvroot);
|
||||||
nvlist_free(nvroot);
|
nvlist_free(nvroot);
|
||||||
|
|
||||||
if (error == ENOSPC)
|
switch (error) {
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
case ENOSPC:
|
||||||
ztest_record_enospc("spa_vdev_add");
|
ztest_record_enospc("spa_vdev_add");
|
||||||
else if (error != 0)
|
break;
|
||||||
|
default:
|
||||||
fatal(0, "spa_vdev_add() = %d", error);
|
fatal(0, "spa_vdev_add() = %d", error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_exit(&ztest_vdev_lock);
|
mutex_exit(&ztest_vdev_lock);
|
||||||
@ -2646,8 +2717,13 @@ ztest_vdev_aux_add_remove(ztest_ds_t *zd, uint64_t id)
|
|||||||
nvlist_t *nvroot = make_vdev_root(NULL, aux, NULL,
|
nvlist_t *nvroot = make_vdev_root(NULL, aux, NULL,
|
||||||
(ztest_opts.zo_vdev_size * 5) / 4, 0, 0, 0, 0, 1);
|
(ztest_opts.zo_vdev_size * 5) / 4, 0, 0, 0, 0, 1);
|
||||||
error = spa_vdev_add(spa, nvroot);
|
error = spa_vdev_add(spa, nvroot);
|
||||||
if (error != 0)
|
|
||||||
|
switch (error) {
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
fatal(0, "spa_vdev_add(%p) = %d", nvroot, error);
|
fatal(0, "spa_vdev_add(%p) = %d", nvroot, error);
|
||||||
|
}
|
||||||
nvlist_free(nvroot);
|
nvlist_free(nvroot);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
@ -2659,8 +2735,16 @@ ztest_vdev_aux_add_remove(ztest_ds_t *zd, uint64_t id)
|
|||||||
(void) vdev_online(spa, guid, 0, NULL);
|
(void) vdev_online(spa, guid, 0, NULL);
|
||||||
|
|
||||||
error = spa_vdev_remove(spa, guid, B_FALSE);
|
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);
|
fatal(0, "spa_vdev_remove(%llu) = %d", guid, error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_exit(&ztest_vdev_lock);
|
mutex_exit(&ztest_vdev_lock);
|
||||||
@ -2759,7 +2843,6 @@ ztest_split_pool(ztest_ds_t *zd, uint64_t id)
|
|||||||
--zs->zs_mirrors;
|
--zs->zs_mirrors;
|
||||||
}
|
}
|
||||||
mutex_exit(&ztest_vdev_lock);
|
mutex_exit(&ztest_vdev_lock);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2858,7 +2941,8 @@ ztest_vdev_attach_detach(ztest_ds_t *zd, uint64_t id)
|
|||||||
spa_config_exit(spa, SCL_ALL, FTAG);
|
spa_config_exit(spa, SCL_ALL, FTAG);
|
||||||
error = spa_vdev_detach(spa, oldguid, pguid, B_FALSE);
|
error = spa_vdev_detach(spa, oldguid, pguid, B_FALSE);
|
||||||
if (error != 0 && error != ENODEV && error != EBUSY &&
|
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);
|
fatal(0, "detach (%s) returned %d", oldpath, error);
|
||||||
mutex_exit(&ztest_vdev_lock);
|
mutex_exit(&ztest_vdev_lock);
|
||||||
return;
|
return;
|
||||||
@ -2950,6 +3034,10 @@ ztest_vdev_attach_detach(ztest_ds_t *zd, uint64_t id)
|
|||||||
if (error == EOVERFLOW || error == EBUSY)
|
if (error == EOVERFLOW || error == EBUSY)
|
||||||
expected_error = error;
|
expected_error = error;
|
||||||
|
|
||||||
|
if (error == ZFS_ERR_CHECKPOINT_EXISTS ||
|
||||||
|
error == ZFS_ERR_DISCARDING_CHECKPOINT)
|
||||||
|
expected_error = error;
|
||||||
|
|
||||||
/* XXX workaround 6690467 */
|
/* XXX workaround 6690467 */
|
||||||
if (error != expected_error && expected_error != EBUSY) {
|
if (error != expected_error && expected_error != EBUSY) {
|
||||||
fatal(0, "attach (%s %llu, %s %llu, %d) "
|
fatal(0, "attach (%s %llu, %s %llu, %d) "
|
||||||
@ -3106,6 +3194,7 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, uint64_t id)
|
|||||||
uint64_t top;
|
uint64_t top;
|
||||||
uint64_t old_class_space, new_class_space, old_ms_count, new_ms_count;
|
uint64_t old_class_space, new_class_space, old_ms_count, new_ms_count;
|
||||||
|
|
||||||
|
mutex_enter(&ztest_checkpoint_lock);
|
||||||
mutex_enter(&ztest_vdev_lock);
|
mutex_enter(&ztest_vdev_lock);
|
||||||
spa_config_enter(spa, SCL_STATE, spa, RW_READER);
|
spa_config_enter(spa, SCL_STATE, spa, RW_READER);
|
||||||
|
|
||||||
@ -3116,8 +3205,9 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, uint64_t id)
|
|||||||
* when the device removal completes).
|
* when the device removal completes).
|
||||||
*/
|
*/
|
||||||
if (spa->spa_vdev_removal != NULL) {
|
if (spa->spa_vdev_removal != NULL) {
|
||||||
spa_config_exit(spa, SCL_STATE, FTAG);
|
spa_config_exit(spa, SCL_STATE, spa);
|
||||||
mutex_exit(&ztest_vdev_lock);
|
mutex_exit(&ztest_vdev_lock);
|
||||||
|
mutex_exit(&ztest_checkpoint_lock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3147,6 +3237,7 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, uint64_t id)
|
|||||||
psize == 0 || psize >= 4 * ztest_opts.zo_vdev_size) {
|
psize == 0 || psize >= 4 * ztest_opts.zo_vdev_size) {
|
||||||
spa_config_exit(spa, SCL_STATE, spa);
|
spa_config_exit(spa, SCL_STATE, spa);
|
||||||
mutex_exit(&ztest_vdev_lock);
|
mutex_exit(&ztest_vdev_lock);
|
||||||
|
mutex_exit(&ztest_checkpoint_lock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ASSERT(psize > 0);
|
ASSERT(psize > 0);
|
||||||
@ -3172,6 +3263,7 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, uint64_t id)
|
|||||||
}
|
}
|
||||||
spa_config_exit(spa, SCL_STATE, spa);
|
spa_config_exit(spa, SCL_STATE, spa);
|
||||||
mutex_exit(&ztest_vdev_lock);
|
mutex_exit(&ztest_vdev_lock);
|
||||||
|
mutex_exit(&ztest_checkpoint_lock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3206,6 +3298,7 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, uint64_t id)
|
|||||||
}
|
}
|
||||||
spa_config_exit(spa, SCL_STATE, spa);
|
spa_config_exit(spa, SCL_STATE, spa);
|
||||||
mutex_exit(&ztest_vdev_lock);
|
mutex_exit(&ztest_vdev_lock);
|
||||||
|
mutex_exit(&ztest_checkpoint_lock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3236,6 +3329,7 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, uint64_t id)
|
|||||||
|
|
||||||
spa_config_exit(spa, SCL_STATE, spa);
|
spa_config_exit(spa, SCL_STATE, spa);
|
||||||
mutex_exit(&ztest_vdev_lock);
|
mutex_exit(&ztest_vdev_lock);
|
||||||
|
mutex_exit(&ztest_checkpoint_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -5040,7 +5134,7 @@ ztest_fault_inject(ztest_ds_t *zd, uint64_t id)
|
|||||||
*/
|
*/
|
||||||
fd = open(pathrand, O_RDWR);
|
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 */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fsize = lseek(fd, 0, SEEK_END);
|
fsize = lseek(fd, 0, SEEK_END);
|
||||||
@ -5750,6 +5844,7 @@ ztest_run(ztest_shared_t *zs)
|
|||||||
/*
|
/*
|
||||||
* Initialize parent/child shared state.
|
* Initialize parent/child shared state.
|
||||||
*/
|
*/
|
||||||
|
mutex_init(&ztest_checkpoint_lock, NULL, USYNC_THREAD, NULL);
|
||||||
mutex_init(&ztest_vdev_lock, NULL, USYNC_THREAD, NULL);
|
mutex_init(&ztest_vdev_lock, NULL, USYNC_THREAD, NULL);
|
||||||
rw_init(&ztest_name_lock, NULL, USYNC_THREAD, NULL);
|
rw_init(&ztest_name_lock, NULL, USYNC_THREAD, NULL);
|
||||||
|
|
||||||
@ -5811,7 +5906,7 @@ ztest_run(ztest_shared_t *zs)
|
|||||||
NULL) == 0);
|
NULL) == 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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,
|
* whether it's allocated or not. To make it interesting,
|
||||||
* we probe a 5-wide window around each power of two.
|
* we probe a 5-wide window around each power of two.
|
||||||
* This hits all edge cases, including zero and the max.
|
* This hits all edge cases, including zero and the max.
|
||||||
@ -5914,6 +6009,7 @@ ztest_run(ztest_shared_t *zs)
|
|||||||
|
|
||||||
rw_destroy(&ztest_name_lock);
|
rw_destroy(&ztest_name_lock);
|
||||||
mutex_destroy(&ztest_vdev_lock);
|
mutex_destroy(&ztest_vdev_lock);
|
||||||
|
mutex_destroy(&ztest_checkpoint_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -6058,6 +6154,7 @@ ztest_init(ztest_shared_t *zs)
|
|||||||
nvlist_t *nvroot, *props;
|
nvlist_t *nvroot, *props;
|
||||||
|
|
||||||
mutex_init(&ztest_vdev_lock, NULL, USYNC_THREAD, NULL);
|
mutex_init(&ztest_vdev_lock, NULL, USYNC_THREAD, NULL);
|
||||||
|
mutex_init(&ztest_checkpoint_lock, NULL, USYNC_THREAD, NULL);
|
||||||
rw_init(&ztest_name_lock, NULL, USYNC_THREAD, NULL);
|
rw_init(&ztest_name_lock, NULL, USYNC_THREAD, NULL);
|
||||||
|
|
||||||
kernel_init(FREAD | FWRITE);
|
kernel_init(FREAD | FWRITE);
|
||||||
@ -6098,6 +6195,7 @@ ztest_init(ztest_shared_t *zs)
|
|||||||
|
|
||||||
rw_destroy(&ztest_name_lock);
|
rw_destroy(&ztest_name_lock);
|
||||||
mutex_destroy(&ztest_vdev_lock);
|
mutex_destroy(&ztest_vdev_lock);
|
||||||
|
mutex_destroy(&ztest_checkpoint_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -132,6 +132,11 @@ typedef enum zfs_error {
|
|||||||
EZFS_POOLREADONLY, /* pool is in read-only mode */
|
EZFS_POOLREADONLY, /* pool is in read-only mode */
|
||||||
EZFS_SCRUB_PAUSED, /* scrub currently paused */
|
EZFS_SCRUB_PAUSED, /* scrub currently paused */
|
||||||
EZFS_NO_PENDING, /* cannot cancel, no operation is pending */
|
EZFS_NO_PENDING, /* cannot cancel, no operation is pending */
|
||||||
|
EZFS_CHECKPOINT_EXISTS, /* checkpoint exists */
|
||||||
|
EZFS_DISCARDING_CHECKPOINT, /* currently discarding a checkpoint */
|
||||||
|
EZFS_NO_CHECKPOINT, /* pool has no checkpoint */
|
||||||
|
EZFS_DEVRM_IN_PROGRESS, /* a device is currently being removed */
|
||||||
|
EZFS_VDEV_TOO_BIG, /* a device is too big to be used */
|
||||||
EZFS_UNKNOWN
|
EZFS_UNKNOWN
|
||||||
} zfs_error_t;
|
} zfs_error_t;
|
||||||
|
|
||||||
@ -420,6 +425,8 @@ extern int zfs_ioctl(libzfs_handle_t *, int request, struct zfs_cmd *);
|
|||||||
extern int zpool_get_physpath(zpool_handle_t *, char *, size_t);
|
extern int zpool_get_physpath(zpool_handle_t *, char *, size_t);
|
||||||
extern void zpool_explain_recover(libzfs_handle_t *, const char *, int,
|
extern void zpool_explain_recover(libzfs_handle_t *, const char *, int,
|
||||||
nvlist_t *);
|
nvlist_t *);
|
||||||
|
extern int zpool_checkpoint(zpool_handle_t *);
|
||||||
|
extern int zpool_discard_checkpoint(zpool_handle_t *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Basic handle manipulations. These functions do not create or destroy the
|
* Basic handle manipulations. These functions do not create or destroy the
|
||||||
|
@ -318,6 +318,7 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len,
|
|||||||
break;
|
break;
|
||||||
case ZPOOL_PROP_BOOTSIZE:
|
case ZPOOL_PROP_BOOTSIZE:
|
||||||
case ZPOOL_PROP_EXPANDSZ:
|
case ZPOOL_PROP_EXPANDSZ:
|
||||||
|
case ZPOOL_PROP_CHECKPOINT:
|
||||||
if (intval == 0) {
|
if (intval == 0) {
|
||||||
(void) strlcpy(buf, "-", len);
|
(void) strlcpy(buf, "-", len);
|
||||||
} else if (literal) {
|
} else if (literal) {
|
||||||
@ -1281,6 +1282,48 @@ zpool_destroy(zpool_handle_t *zhp, const char *log_str)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create a checkpoint in the given pool.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
zpool_checkpoint(zpool_handle_t *zhp)
|
||||||
|
{
|
||||||
|
libzfs_handle_t *hdl = zhp->zpool_hdl;
|
||||||
|
char msg[1024];
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = lzc_pool_checkpoint(zhp->zpool_name);
|
||||||
|
if (error != 0) {
|
||||||
|
(void) snprintf(msg, sizeof (msg), dgettext(TEXT_DOMAIN,
|
||||||
|
"cannot checkpoint '%s'"), zhp->zpool_name);
|
||||||
|
(void) zpool_standard_error(hdl, error, msg);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Discard the checkpoint from the given pool.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
zpool_discard_checkpoint(zpool_handle_t *zhp)
|
||||||
|
{
|
||||||
|
libzfs_handle_t *hdl = zhp->zpool_hdl;
|
||||||
|
char msg[1024];
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = lzc_pool_checkpoint_discard(zhp->zpool_name);
|
||||||
|
if (error != 0) {
|
||||||
|
(void) snprintf(msg, sizeof (msg), dgettext(TEXT_DOMAIN,
|
||||||
|
"cannot discard checkpoint in '%s'"), zhp->zpool_name);
|
||||||
|
(void) zpool_standard_error(hdl, error, msg);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add the given vdevs to the pool. The caller must have already performed the
|
* Add the given vdevs to the pool. The caller must have already performed the
|
||||||
* necessary verification to ensure that the vdev specification is well-formed.
|
* necessary verification to ensure that the vdev specification is well-formed.
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
|
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
|
||||||
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
|
* Copyright (c) 2011, 2017 by Delphix. All rights reserved.
|
||||||
* Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
|
* Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
|
||||||
* Copyright (c) 2017 Datto Inc.
|
* Copyright (c) 2017 Datto Inc.
|
||||||
*/
|
*/
|
||||||
@ -243,6 +243,17 @@ libzfs_error_description(libzfs_handle_t *hdl)
|
|||||||
case EZFS_NO_PENDING:
|
case EZFS_NO_PENDING:
|
||||||
return (dgettext(TEXT_DOMAIN, "operation is not "
|
return (dgettext(TEXT_DOMAIN, "operation is not "
|
||||||
"in progress"));
|
"in progress"));
|
||||||
|
case EZFS_CHECKPOINT_EXISTS:
|
||||||
|
return (dgettext(TEXT_DOMAIN, "checkpoint exists"));
|
||||||
|
case EZFS_DISCARDING_CHECKPOINT:
|
||||||
|
return (dgettext(TEXT_DOMAIN, "currently discarding "
|
||||||
|
"checkpoint"));
|
||||||
|
case EZFS_NO_CHECKPOINT:
|
||||||
|
return (dgettext(TEXT_DOMAIN, "checkpoint does not exist"));
|
||||||
|
case EZFS_DEVRM_IN_PROGRESS:
|
||||||
|
return (dgettext(TEXT_DOMAIN, "device removal in progress"));
|
||||||
|
case EZFS_VDEV_TOO_BIG:
|
||||||
|
return (dgettext(TEXT_DOMAIN, "device exceeds supported size"));
|
||||||
case EZFS_UNKNOWN:
|
case EZFS_UNKNOWN:
|
||||||
return (dgettext(TEXT_DOMAIN, "unknown error"));
|
return (dgettext(TEXT_DOMAIN, "unknown error"));
|
||||||
default:
|
default:
|
||||||
@ -494,7 +505,21 @@ zpool_standard_error_fmt(libzfs_handle_t *hdl, int error, const char *fmt, ...)
|
|||||||
case ESRCH:
|
case ESRCH:
|
||||||
zfs_verror(hdl, EZFS_NO_PENDING, fmt, ap);
|
zfs_verror(hdl, EZFS_NO_PENDING, fmt, ap);
|
||||||
break;
|
break;
|
||||||
|
case ZFS_ERR_CHECKPOINT_EXISTS:
|
||||||
|
zfs_verror(hdl, EZFS_CHECKPOINT_EXISTS, fmt, ap);
|
||||||
|
break;
|
||||||
|
case ZFS_ERR_DISCARDING_CHECKPOINT:
|
||||||
|
zfs_verror(hdl, EZFS_DISCARDING_CHECKPOINT, fmt, ap);
|
||||||
|
break;
|
||||||
|
case ZFS_ERR_NO_CHECKPOINT:
|
||||||
|
zfs_verror(hdl, EZFS_NO_CHECKPOINT, fmt, ap);
|
||||||
|
break;
|
||||||
|
case ZFS_ERR_DEVRM_IN_PROGRESS:
|
||||||
|
zfs_verror(hdl, EZFS_DEVRM_IN_PROGRESS, fmt, ap);
|
||||||
|
break;
|
||||||
|
case ZFS_ERR_VDEV_TOO_BIG:
|
||||||
|
zfs_verror(hdl, EZFS_VDEV_TOO_BIG, fmt, ap);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
zfs_error_aux(hdl, strerror(error));
|
zfs_error_aux(hdl, strerror(error));
|
||||||
zfs_verror(hdl, EZFS_UNKNOWN, fmt, ap);
|
zfs_verror(hdl, EZFS_UNKNOWN, fmt, ap);
|
||||||
|
@ -998,6 +998,74 @@ lzc_channel_program(const char *pool, const char *program, uint64_t instrlimit,
|
|||||||
memlimit, argnvl, outnvl));
|
memlimit, argnvl, outnvl));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Creates a checkpoint for the specified pool.
|
||||||
|
*
|
||||||
|
* If this function returns 0 the pool was successfully checkpointed.
|
||||||
|
*
|
||||||
|
* This method may also return:
|
||||||
|
*
|
||||||
|
* ZFS_ERR_CHECKPOINT_EXISTS
|
||||||
|
* The pool already has a checkpoint. A pools can only have one
|
||||||
|
* checkpoint at most, at any given time.
|
||||||
|
*
|
||||||
|
* ZFS_ERR_DISCARDING_CHECKPOINT
|
||||||
|
* ZFS is in the middle of discarding a checkpoint for this pool.
|
||||||
|
* The pool can be checkpointed again once the discard is done.
|
||||||
|
*
|
||||||
|
* ZFS_DEVRM_IN_PROGRESS
|
||||||
|
* A vdev is currently being removed. The pool cannot be
|
||||||
|
* checkpointed until the device removal is done.
|
||||||
|
*
|
||||||
|
* ZFS_VDEV_TOO_BIG
|
||||||
|
* One or more top-level vdevs exceed the maximum vdev size
|
||||||
|
* supported for this feature.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
lzc_pool_checkpoint(const char *pool)
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
|
||||||
|
nvlist_t *result = NULL;
|
||||||
|
nvlist_t *args = fnvlist_alloc();
|
||||||
|
|
||||||
|
error = lzc_ioctl(ZFS_IOC_POOL_CHECKPOINT, pool, args, &result);
|
||||||
|
|
||||||
|
fnvlist_free(args);
|
||||||
|
fnvlist_free(result);
|
||||||
|
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Discard the checkpoint from the specified pool.
|
||||||
|
*
|
||||||
|
* If this function returns 0 the checkpoint was successfully discarded.
|
||||||
|
*
|
||||||
|
* This method may also return:
|
||||||
|
*
|
||||||
|
* ZFS_ERR_NO_CHECKPOINT
|
||||||
|
* The pool does not have a checkpoint.
|
||||||
|
*
|
||||||
|
* ZFS_ERR_DISCARDING_CHECKPOINT
|
||||||
|
* ZFS is already in the middle of discarding the checkpoint.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
lzc_pool_checkpoint_discard(const char *pool)
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
|
||||||
|
nvlist_t *result = NULL;
|
||||||
|
nvlist_t *args = fnvlist_alloc();
|
||||||
|
|
||||||
|
error = lzc_ioctl(ZFS_IOC_POOL_DISCARD_CHECKPOINT, pool, args, &result);
|
||||||
|
|
||||||
|
fnvlist_free(args);
|
||||||
|
fnvlist_free(result);
|
||||||
|
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Executes a read-only channel program.
|
* Executes a read-only channel program.
|
||||||
*
|
*
|
||||||
|
@ -92,6 +92,9 @@ int lzc_channel_program(const char *, const char *, uint64_t,
|
|||||||
int lzc_channel_program_nosync(const char *, const char *, uint64_t,
|
int lzc_channel_program_nosync(const char *, const char *, uint64_t,
|
||||||
uint64_t, nvlist_t *, nvlist_t **);
|
uint64_t, nvlist_t *, nvlist_t **);
|
||||||
|
|
||||||
|
int lzc_pool_checkpoint(const char *);
|
||||||
|
int lzc_pool_checkpoint_discard(const char *);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
|
* Copyright (c) 2011, 2017 by Delphix. All rights reserved.
|
||||||
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
|
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
|
||||||
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
|
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
|
||||||
* Copyright (c) 2014, Nexenta Systems, Inc. All rights reserved.
|
* Copyright (c) 2014, Nexenta Systems, Inc. All rights reserved.
|
||||||
@ -224,6 +224,11 @@ zpool_feature_init(void)
|
|||||||
ZFEATURE_FLAG_MOS | ZFEATURE_FLAG_ACTIVATE_ON_ENABLE,
|
ZFEATURE_FLAG_MOS | ZFEATURE_FLAG_ACTIVATE_ON_ENABLE,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
zfeature_register(SPA_FEATURE_POOL_CHECKPOINT,
|
||||||
|
"com.delphix:zpool_checkpoint", "zpool_checkpoint",
|
||||||
|
"Pool state can be checkpointed, allowing rewind later.",
|
||||||
|
ZFEATURE_FLAG_READONLY_COMPAT, NULL);
|
||||||
|
|
||||||
static const spa_feature_t large_blocks_deps[] = {
|
static const spa_feature_t large_blocks_deps[] = {
|
||||||
SPA_FEATURE_EXTENSIBLE_DATASET,
|
SPA_FEATURE_EXTENSIBLE_DATASET,
|
||||||
SPA_FEATURE_NONE
|
SPA_FEATURE_NONE
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
|
* Copyright (c) 2011, 2017 by Delphix. All rights reserved.
|
||||||
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
|
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
|
||||||
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
|
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
|
||||||
* Copyright (c) 2014 Integros [integros.com]
|
* Copyright (c) 2014 Integros [integros.com]
|
||||||
@ -59,6 +59,7 @@ typedef enum spa_feature {
|
|||||||
#endif
|
#endif
|
||||||
SPA_FEATURE_DEVICE_REMOVAL,
|
SPA_FEATURE_DEVICE_REMOVAL,
|
||||||
SPA_FEATURE_OBSOLETE_COUNTS,
|
SPA_FEATURE_OBSOLETE_COUNTS,
|
||||||
|
SPA_FEATURE_POOL_CHECKPOINT,
|
||||||
SPA_FEATURES
|
SPA_FEATURES
|
||||||
} spa_feature_t;
|
} spa_feature_t;
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
|
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
|
||||||
* Copyright (c) 2012, 2014 by Delphix. All rights reserved.
|
* Copyright (c) 2012, 2017 by Delphix. All rights reserved.
|
||||||
* Copyright (c) 2014 Integros [integros.com]
|
* Copyright (c) 2014 Integros [integros.com]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -82,6 +82,8 @@ zpool_prop_init(void)
|
|||||||
ZFS_TYPE_POOL, "<size>", "FREE");
|
ZFS_TYPE_POOL, "<size>", "FREE");
|
||||||
zprop_register_number(ZPOOL_PROP_FREEING, "freeing", 0, PROP_READONLY,
|
zprop_register_number(ZPOOL_PROP_FREEING, "freeing", 0, PROP_READONLY,
|
||||||
ZFS_TYPE_POOL, "<size>", "FREEING");
|
ZFS_TYPE_POOL, "<size>", "FREEING");
|
||||||
|
zprop_register_number(ZPOOL_PROP_CHECKPOINT, "checkpoint", 0,
|
||||||
|
PROP_READONLY, ZFS_TYPE_POOL, "<size>", "CKPOINT");
|
||||||
zprop_register_number(ZPOOL_PROP_LEAKED, "leaked", 0, PROP_READONLY,
|
zprop_register_number(ZPOOL_PROP_LEAKED, "leaked", 0, PROP_READONLY,
|
||||||
ZFS_TYPE_POOL, "<size>", "LEAKED");
|
ZFS_TYPE_POOL, "<size>", "LEAKED");
|
||||||
zprop_register_number(ZPOOL_PROP_ALLOCATED, "allocated", 0,
|
zprop_register_number(ZPOOL_PROP_ALLOCATED, "allocated", 0,
|
||||||
|
@ -108,6 +108,7 @@ ZFS_COMMON_OBJS += \
|
|||||||
sha256.o \
|
sha256.o \
|
||||||
skein_zfs.o \
|
skein_zfs.o \
|
||||||
spa.o \
|
spa.o \
|
||||||
|
spa_checkpoint.o \
|
||||||
spa_config.o \
|
spa_config.o \
|
||||||
spa_errlog.o \
|
spa_errlog.o \
|
||||||
spa_history.o \
|
spa_history.o \
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
* Copyright (c) 2012, 2016 by Delphix. All rights reserved.
|
* Copyright (c) 2012, 2018 by Delphix. All rights reserved.
|
||||||
* Copyright (c) 2015 Chunwei Chen. All rights reserved.
|
* Copyright (c) 2015 Chunwei Chen. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -32,6 +32,7 @@
|
|||||||
#include <sys/dsl_pool.h>
|
#include <sys/dsl_pool.h>
|
||||||
#include <sys/dnode.h>
|
#include <sys/dnode.h>
|
||||||
#include <sys/spa.h>
|
#include <sys/spa.h>
|
||||||
|
#include <sys/spa_impl.h>
|
||||||
#include <sys/zio.h>
|
#include <sys/zio.h>
|
||||||
#include <sys/dmu_impl.h>
|
#include <sys/dmu_impl.h>
|
||||||
#include <sys/sa.h>
|
#include <sys/sa.h>
|
||||||
@ -87,8 +88,8 @@ traverse_zil_block(zilog_t *zilog, blkptr_t *bp, void *arg, uint64_t claim_txg)
|
|||||||
if (BP_IS_HOLE(bp))
|
if (BP_IS_HOLE(bp))
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
if (claim_txg == 0 && bp->blk_birth >= spa_first_txg(td->td_spa))
|
if (claim_txg == 0 && bp->blk_birth >= spa_min_claim_txg(td->td_spa))
|
||||||
return (0);
|
return (-1);
|
||||||
|
|
||||||
SET_BOOKMARK(&zb, td->td_objset, ZB_ZIL_OBJECT, ZB_ZIL_LEVEL,
|
SET_BOOKMARK(&zb, td->td_objset, ZB_ZIL_OBJECT, ZB_ZIL_LEVEL,
|
||||||
bp->blk_cksum.zc_word[ZIL_ZC_SEQ]);
|
bp->blk_cksum.zc_word[ZIL_ZC_SEQ]);
|
||||||
@ -127,20 +128,17 @@ static void
|
|||||||
traverse_zil(traverse_data_t *td, zil_header_t *zh)
|
traverse_zil(traverse_data_t *td, zil_header_t *zh)
|
||||||
{
|
{
|
||||||
uint64_t claim_txg = zh->zh_claim_txg;
|
uint64_t claim_txg = zh->zh_claim_txg;
|
||||||
zilog_t *zilog;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We only want to visit blocks that have been claimed but not yet
|
* We only want to visit blocks that have been claimed but not yet
|
||||||
* replayed; plus, in read-only mode, blocks that are already stable.
|
* replayed; plus blocks that are already stable in read-only mode.
|
||||||
*/
|
*/
|
||||||
if (claim_txg == 0 && spa_writeable(td->td_spa))
|
if (claim_txg == 0 && spa_writeable(td->td_spa))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
zilog = zil_alloc(spa_get_dsl(td->td_spa)->dp_meta_objset, zh);
|
zilog_t *zilog = zil_alloc(spa_get_dsl(td->td_spa)->dp_meta_objset, zh);
|
||||||
|
|
||||||
(void) zil_parse(zilog, traverse_zil_block, traverse_zil_record, td,
|
(void) zil_parse(zilog, traverse_zil_block, traverse_zil_record, td,
|
||||||
claim_txg);
|
claim_txg);
|
||||||
|
|
||||||
zil_free(zilog);
|
zil_free(zilog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1094,6 +1094,8 @@ dnode_hold_impl(objset_t *os, uint64_t object, int flag,
|
|||||||
(spa_is_root(os->os_spa) &&
|
(spa_is_root(os->os_spa) &&
|
||||||
spa_config_held(os->os_spa, SCL_STATE, RW_WRITER)));
|
spa_config_held(os->os_spa, SCL_STATE, RW_WRITER)));
|
||||||
|
|
||||||
|
ASSERT((flag & DNODE_MUST_BE_ALLOCATED) || (flag & DNODE_MUST_BE_FREE));
|
||||||
|
|
||||||
if (object == DMU_USERUSED_OBJECT || object == DMU_GROUPUSED_OBJECT) {
|
if (object == DMU_USERUSED_OBJECT || object == DMU_GROUPUSED_OBJECT) {
|
||||||
dn = (object == DMU_USERUSED_OBJECT) ?
|
dn = (object == DMU_USERUSED_OBJECT) ?
|
||||||
DMU_USERUSED_DNODE(os) : DMU_GROUPUSED_DNODE(os);
|
DMU_USERUSED_DNODE(os) : DMU_GROUPUSED_DNODE(os);
|
||||||
@ -1187,7 +1189,7 @@ dnode_hold_impl(objset_t *os, uint64_t object, int flag,
|
|||||||
mutex_exit(&dn->dn_mtx);
|
mutex_exit(&dn->dn_mtx);
|
||||||
zrl_remove(&dnh->dnh_zrlock);
|
zrl_remove(&dnh->dnh_zrlock);
|
||||||
dbuf_rele(db, FTAG);
|
dbuf_rele(db, FTAG);
|
||||||
return (type == DMU_OT_NONE ? ENOENT : EEXIST);
|
return ((flag & DNODE_MUST_BE_ALLOCATED) ? ENOENT : EEXIST);
|
||||||
}
|
}
|
||||||
if (refcount_add(&dn->dn_holds, tag) == 1)
|
if (refcount_add(&dn->dn_holds, tag) == 1)
|
||||||
dbuf_add_ref(db, dnh);
|
dbuf_add_ref(db, dnh);
|
||||||
|
@ -608,7 +608,7 @@ dnode_sync(dnode_t *dn, dmu_tx_t *tx)
|
|||||||
dn->dn_maxblkid == 0 || list_head(list) != NULL ||
|
dn->dn_maxblkid == 0 || list_head(list) != NULL ||
|
||||||
dn->dn_next_blksz[txgoff] >> SPA_MINBLOCKSHIFT ==
|
dn->dn_next_blksz[txgoff] >> SPA_MINBLOCKSHIFT ==
|
||||||
dnp->dn_datablkszsec ||
|
dnp->dn_datablkszsec ||
|
||||||
range_tree_space(dn->dn_free_ranges[txgoff]) != 0);
|
!range_tree_is_empty(dn->dn_free_ranges[txgoff]));
|
||||||
dnp->dn_datablkszsec =
|
dnp->dn_datablkszsec =
|
||||||
dn->dn_next_blksz[txgoff] >> SPA_MINBLOCKSHIFT;
|
dn->dn_next_blksz[txgoff] >> SPA_MINBLOCKSHIFT;
|
||||||
dn->dn_next_blksz[txgoff] = 0;
|
dn->dn_next_blksz[txgoff] = 0;
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
#include <sys/zfs_context.h>
|
#include <sys/zfs_context.h>
|
||||||
#include <sys/zfs_ioctl.h>
|
#include <sys/zfs_ioctl.h>
|
||||||
#include <sys/spa.h>
|
#include <sys/spa.h>
|
||||||
|
#include <sys/spa_impl.h>
|
||||||
#include <sys/vdev.h>
|
#include <sys/vdev.h>
|
||||||
#include <sys/zfs_znode.h>
|
#include <sys/zfs_znode.h>
|
||||||
#include <sys/zfs_onexit.h>
|
#include <sys/zfs_onexit.h>
|
||||||
@ -212,7 +213,9 @@ int
|
|||||||
dsl_dataset_block_kill(dsl_dataset_t *ds, const blkptr_t *bp, dmu_tx_t *tx,
|
dsl_dataset_block_kill(dsl_dataset_t *ds, const blkptr_t *bp, dmu_tx_t *tx,
|
||||||
boolean_t async)
|
boolean_t async)
|
||||||
{
|
{
|
||||||
int used = bp_get_dsize_sync(tx->tx_pool->dp_spa, bp);
|
spa_t *spa = dmu_tx_pool(tx)->dp_spa;
|
||||||
|
|
||||||
|
int used = bp_get_dsize_sync(spa, bp);
|
||||||
int compressed = BP_GET_PSIZE(bp);
|
int compressed = BP_GET_PSIZE(bp);
|
||||||
int uncompressed = BP_GET_UCSIZE(bp);
|
int uncompressed = BP_GET_UCSIZE(bp);
|
||||||
|
|
||||||
@ -3826,7 +3829,8 @@ dsl_dataset_set_refquota(const char *dsname, zprop_source_t source,
|
|||||||
ddsqra.ddsqra_value = refquota;
|
ddsqra.ddsqra_value = refquota;
|
||||||
|
|
||||||
return (dsl_sync_task(dsname, dsl_dataset_set_refquota_check,
|
return (dsl_sync_task(dsname, dsl_dataset_set_refquota_check,
|
||||||
dsl_dataset_set_refquota_sync, &ddsqra, 0, ZFS_SPACE_CHECK_NONE));
|
dsl_dataset_set_refquota_sync, &ddsqra, 0,
|
||||||
|
ZFS_SPACE_CHECK_EXTRA_RESERVED));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -3941,8 +3945,8 @@ dsl_dataset_set_refreservation(const char *dsname, zprop_source_t source,
|
|||||||
ddsqra.ddsqra_value = refreservation;
|
ddsqra.ddsqra_value = refreservation;
|
||||||
|
|
||||||
return (dsl_sync_task(dsname, dsl_dataset_set_refreservation_check,
|
return (dsl_sync_task(dsname, dsl_dataset_set_refreservation_check,
|
||||||
dsl_dataset_set_refreservation_sync, &ddsqra,
|
dsl_dataset_set_refreservation_sync, &ddsqra, 0,
|
||||||
0, ZFS_SPACE_CHECK_NONE));
|
ZFS_SPACE_CHECK_EXTRA_RESERVED));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1022,7 +1022,7 @@ dsl_destroy_head(const char *name)
|
|||||||
|
|
||||||
error = dsl_sync_task(name, dsl_destroy_head_check,
|
error = dsl_sync_task(name, dsl_destroy_head_check,
|
||||||
dsl_destroy_head_begin_sync, &ddha,
|
dsl_destroy_head_begin_sync, &ddha,
|
||||||
0, ZFS_SPACE_CHECK_NONE);
|
0, ZFS_SPACE_CHECK_DESTROY);
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
return (error);
|
return (error);
|
||||||
|
|
||||||
@ -1047,7 +1047,7 @@ dsl_destroy_head(const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (dsl_sync_task(name, dsl_destroy_head_check,
|
return (dsl_sync_task(name, dsl_destroy_head_check,
|
||||||
dsl_destroy_head_sync, &ddha, 0, ZFS_SPACE_CHECK_NONE));
|
dsl_destroy_head_sync, &ddha, 0, ZFS_SPACE_CHECK_DESTROY));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
* Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net>.
|
* Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net>.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
* Copyright (c) 2012, 2016 by Delphix. All rights reserved.
|
* Copyright (c) 2012, 2017 by Delphix. All rights reserved.
|
||||||
* Copyright (c) 2014 Joyent, Inc. All rights reserved.
|
* Copyright (c) 2014 Joyent, Inc. All rights reserved.
|
||||||
* Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
|
* Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
|
||||||
* Copyright 2015 Nexenta Systems, Inc. All rights reserved.
|
* Copyright 2015 Nexenta Systems, Inc. All rights reserved.
|
||||||
@ -930,14 +930,14 @@ dsl_dir_create_sync(dsl_pool_t *dp, dsl_dir_t *pds, const char *name,
|
|||||||
ddobj = dmu_object_alloc(mos, DMU_OT_DSL_DIR, 0,
|
ddobj = dmu_object_alloc(mos, DMU_OT_DSL_DIR, 0,
|
||||||
DMU_OT_DSL_DIR, sizeof (dsl_dir_phys_t), tx);
|
DMU_OT_DSL_DIR, sizeof (dsl_dir_phys_t), tx);
|
||||||
if (pds) {
|
if (pds) {
|
||||||
VERIFY(0 == zap_add(mos, dsl_dir_phys(pds)->dd_child_dir_zapobj,
|
VERIFY0(zap_add(mos, dsl_dir_phys(pds)->dd_child_dir_zapobj,
|
||||||
name, sizeof (uint64_t), 1, &ddobj, tx));
|
name, sizeof (uint64_t), 1, &ddobj, tx));
|
||||||
} else {
|
} else {
|
||||||
/* it's the root dir */
|
/* it's the root dir */
|
||||||
VERIFY(0 == zap_add(mos, DMU_POOL_DIRECTORY_OBJECT,
|
VERIFY0(zap_add(mos, DMU_POOL_DIRECTORY_OBJECT,
|
||||||
DMU_POOL_ROOT_DATASET, sizeof (uint64_t), 1, &ddobj, tx));
|
DMU_POOL_ROOT_DATASET, sizeof (uint64_t), 1, &ddobj, tx));
|
||||||
}
|
}
|
||||||
VERIFY(0 == dmu_bonus_hold(mos, ddobj, FTAG, &dbuf));
|
VERIFY0(dmu_bonus_hold(mos, ddobj, FTAG, &dbuf));
|
||||||
dmu_buf_will_dirty(dbuf, tx);
|
dmu_buf_will_dirty(dbuf, tx);
|
||||||
ddphys = dbuf->db_data;
|
ddphys = dbuf->db_data;
|
||||||
|
|
||||||
@ -975,6 +975,12 @@ dsl_dir_get_used(dsl_dir_t *dd)
|
|||||||
return (dsl_dir_phys(dd)->dd_used_bytes);
|
return (dsl_dir_phys(dd)->dd_used_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t
|
||||||
|
dsl_dir_get_compressed(dsl_dir_t *dd)
|
||||||
|
{
|
||||||
|
return (dsl_dir_phys(dd)->dd_compressed_bytes);
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
dsl_dir_get_quota(dsl_dir_t *dd)
|
dsl_dir_get_quota(dsl_dir_t *dd)
|
||||||
{
|
{
|
||||||
@ -1202,7 +1208,8 @@ dsl_dir_space_available(dsl_dir_t *dd,
|
|||||||
used += dsl_dir_space_towrite(dd);
|
used += dsl_dir_space_towrite(dd);
|
||||||
|
|
||||||
if (dd->dd_parent == NULL) {
|
if (dd->dd_parent == NULL) {
|
||||||
uint64_t poolsize = dsl_pool_adjustedsize(dd->dd_pool, FALSE);
|
uint64_t poolsize = dsl_pool_adjustedsize(dd->dd_pool,
|
||||||
|
ZFS_SPACE_CHECK_NORMAL);
|
||||||
quota = MIN(quota, poolsize);
|
quota = MIN(quota, poolsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1307,11 +1314,12 @@ dsl_dir_tempreserve_impl(dsl_dir_t *dd, uint64_t asize, boolean_t netfree,
|
|||||||
*/
|
*/
|
||||||
uint64_t deferred = 0;
|
uint64_t deferred = 0;
|
||||||
if (dd->dd_parent == NULL) {
|
if (dd->dd_parent == NULL) {
|
||||||
spa_t *spa = dd->dd_pool->dp_spa;
|
uint64_t avail = dsl_pool_unreserved_space(dd->dd_pool,
|
||||||
uint64_t poolsize = dsl_pool_adjustedsize(dd->dd_pool, netfree);
|
(netfree) ?
|
||||||
deferred = metaslab_class_get_deferred(spa_normal_class(spa));
|
ZFS_SPACE_CHECK_RESERVED : ZFS_SPACE_CHECK_NORMAL);
|
||||||
if (poolsize - deferred < quota) {
|
|
||||||
quota = poolsize - deferred;
|
if (avail < quota) {
|
||||||
|
quota = avail;
|
||||||
retval = ENOSPC;
|
retval = ENOSPC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1649,7 +1657,8 @@ dsl_dir_set_quota(const char *ddname, zprop_source_t source, uint64_t quota)
|
|||||||
ddsqra.ddsqra_value = quota;
|
ddsqra.ddsqra_value = quota;
|
||||||
|
|
||||||
return (dsl_sync_task(ddname, dsl_dir_set_quota_check,
|
return (dsl_sync_task(ddname, dsl_dir_set_quota_check,
|
||||||
dsl_dir_set_quota_sync, &ddsqra, 0, ZFS_SPACE_CHECK_NONE));
|
dsl_dir_set_quota_sync, &ddsqra, 0,
|
||||||
|
ZFS_SPACE_CHECK_EXTRA_RESERVED));
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -1692,7 +1701,8 @@ dsl_dir_set_reservation_check(void *arg, dmu_tx_t *tx)
|
|||||||
avail = dsl_dir_space_available(dd->dd_parent,
|
avail = dsl_dir_space_available(dd->dd_parent,
|
||||||
NULL, 0, FALSE);
|
NULL, 0, FALSE);
|
||||||
} else {
|
} else {
|
||||||
avail = dsl_pool_adjustedsize(dd->dd_pool, B_FALSE) - used;
|
avail = dsl_pool_adjustedsize(dd->dd_pool,
|
||||||
|
ZFS_SPACE_CHECK_NORMAL) - used;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MAX(used, newval) > MAX(used, dsl_dir_phys(dd)->dd_reserved)) {
|
if (MAX(used, newval) > MAX(used, dsl_dir_phys(dd)->dd_reserved)) {
|
||||||
@ -1770,7 +1780,8 @@ dsl_dir_set_reservation(const char *ddname, zprop_source_t source,
|
|||||||
ddsqra.ddsqra_value = reservation;
|
ddsqra.ddsqra_value = reservation;
|
||||||
|
|
||||||
return (dsl_sync_task(ddname, dsl_dir_set_reservation_check,
|
return (dsl_sync_task(ddname, dsl_dir_set_reservation_check,
|
||||||
dsl_dir_set_reservation_sync, &ddsqra, 0, ZFS_SPACE_CHECK_NONE));
|
dsl_dir_set_reservation_sync, &ddsqra, 0,
|
||||||
|
ZFS_SPACE_CHECK_EXTRA_RESERVED));
|
||||||
}
|
}
|
||||||
|
|
||||||
static dsl_dir_t *
|
static dsl_dir_t *
|
||||||
|
@ -44,6 +44,8 @@
|
|||||||
#include <sys/zfs_znode.h>
|
#include <sys/zfs_znode.h>
|
||||||
#include <sys/spa_impl.h>
|
#include <sys/spa_impl.h>
|
||||||
#include <sys/dsl_deadlist.h>
|
#include <sys/dsl_deadlist.h>
|
||||||
|
#include <sys/vdev_impl.h>
|
||||||
|
#include <sys/metaslab_impl.h>
|
||||||
#include <sys/bptree.h>
|
#include <sys/bptree.h>
|
||||||
#include <sys/zfeature.h>
|
#include <sys/zfeature.h>
|
||||||
#include <sys/zil_impl.h>
|
#include <sys/zil_impl.h>
|
||||||
@ -297,6 +299,8 @@ dsl_pool_open_impl(spa_t *spa, uint64_t txg)
|
|||||||
offsetof(dsl_dir_t, dd_dirty_link));
|
offsetof(dsl_dir_t, dd_dirty_link));
|
||||||
txg_list_create(&dp->dp_sync_tasks, spa,
|
txg_list_create(&dp->dp_sync_tasks, spa,
|
||||||
offsetof(dsl_sync_task_t, dst_node));
|
offsetof(dsl_sync_task_t, dst_node));
|
||||||
|
txg_list_create(&dp->dp_early_sync_tasks, spa,
|
||||||
|
offsetof(dsl_sync_task_t, dst_node));
|
||||||
|
|
||||||
dp->dp_sync_taskq = taskq_create("dp_sync_taskq",
|
dp->dp_sync_taskq = taskq_create("dp_sync_taskq",
|
||||||
zfs_sync_taskq_batch_pct, minclsyspri, 1, INT_MAX,
|
zfs_sync_taskq_batch_pct, minclsyspri, 1, INT_MAX,
|
||||||
@ -473,6 +477,7 @@ dsl_pool_close(dsl_pool_t *dp)
|
|||||||
txg_list_destroy(&dp->dp_dirty_datasets);
|
txg_list_destroy(&dp->dp_dirty_datasets);
|
||||||
txg_list_destroy(&dp->dp_dirty_zilogs);
|
txg_list_destroy(&dp->dp_dirty_zilogs);
|
||||||
txg_list_destroy(&dp->dp_sync_tasks);
|
txg_list_destroy(&dp->dp_sync_tasks);
|
||||||
|
txg_list_destroy(&dp->dp_early_sync_tasks);
|
||||||
txg_list_destroy(&dp->dp_dirty_dirs);
|
txg_list_destroy(&dp->dp_dirty_dirs);
|
||||||
|
|
||||||
taskq_destroy(dp->dp_zil_clean_taskq);
|
taskq_destroy(dp->dp_zil_clean_taskq);
|
||||||
@ -645,6 +650,27 @@ dsl_pool_dirty_delta(dsl_pool_t *dp, int64_t delta)
|
|||||||
cv_signal(&dp->dp_spaceavail_cv);
|
cv_signal(&dp->dp_spaceavail_cv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static boolean_t
|
||||||
|
dsl_early_sync_task_verify(dsl_pool_t *dp, uint64_t txg)
|
||||||
|
{
|
||||||
|
spa_t *spa = dp->dp_spa;
|
||||||
|
vdev_t *rvd = spa->spa_root_vdev;
|
||||||
|
|
||||||
|
for (uint64_t c = 0; c < rvd->vdev_children; c++) {
|
||||||
|
vdev_t *vd = rvd->vdev_child[c];
|
||||||
|
txg_list_t *tl = &vd->vdev_ms_list;
|
||||||
|
metaslab_t *ms;
|
||||||
|
|
||||||
|
for (ms = txg_list_head(tl, TXG_CLEAN(txg)); ms;
|
||||||
|
ms = txg_list_next(tl, ms, TXG_CLEAN(txg))) {
|
||||||
|
VERIFY(range_tree_is_empty(ms->ms_freeing));
|
||||||
|
VERIFY(range_tree_is_empty(ms->ms_checkpointing));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (B_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
dsl_pool_sync(dsl_pool_t *dp, uint64_t txg)
|
dsl_pool_sync(dsl_pool_t *dp, uint64_t txg)
|
||||||
{
|
{
|
||||||
@ -660,6 +686,23 @@ dsl_pool_sync(dsl_pool_t *dp, uint64_t txg)
|
|||||||
|
|
||||||
tx = dmu_tx_create_assigned(dp, txg);
|
tx = dmu_tx_create_assigned(dp, txg);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Run all early sync tasks before writing out any dirty blocks.
|
||||||
|
* For more info on early sync tasks see block comment in
|
||||||
|
* dsl_early_sync_task().
|
||||||
|
*/
|
||||||
|
if (!txg_list_empty(&dp->dp_early_sync_tasks, txg)) {
|
||||||
|
dsl_sync_task_t *dst;
|
||||||
|
|
||||||
|
ASSERT3U(spa_sync_pass(dp->dp_spa), ==, 1);
|
||||||
|
while ((dst =
|
||||||
|
txg_list_remove(&dp->dp_early_sync_tasks, txg)) != NULL) {
|
||||||
|
ASSERT(dsl_early_sync_task_verify(dp, txg));
|
||||||
|
dsl_sync_task_sync(dst, tx);
|
||||||
|
}
|
||||||
|
ASSERT(dsl_early_sync_task_verify(dp, txg));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Write out all dirty blocks of dirty datasets.
|
* Write out all dirty blocks of dirty datasets.
|
||||||
*/
|
*/
|
||||||
@ -814,22 +857,66 @@ dsl_pool_sync_context(dsl_pool_t *dp)
|
|||||||
taskq_member(dp->dp_sync_taskq, curthread));
|
taskq_member(dp->dp_sync_taskq, curthread));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function returns the amount of allocatable space in the pool
|
||||||
|
* minus whatever space is currently reserved by ZFS for specific
|
||||||
|
* purposes. Specifically:
|
||||||
|
*
|
||||||
|
* 1] Any reserved SLOP space
|
||||||
|
* 2] Any space used by the checkpoint
|
||||||
|
* 3] Any space used for deferred frees
|
||||||
|
*
|
||||||
|
* The latter 2 are especially important because they are needed to
|
||||||
|
* rectify the SPA's and DMU's different understanding of how much space
|
||||||
|
* is used. Now the DMU is aware of that extra space tracked by the SPA
|
||||||
|
* without having to maintain a separate special dir (e.g similar to
|
||||||
|
* $MOS, $FREEING, and $LEAKED).
|
||||||
|
*
|
||||||
|
* Note: By deferred frees here, we mean the frees that were deferred
|
||||||
|
* in spa_sync() after sync pass 1 (spa_deferred_bpobj), and not the
|
||||||
|
* segments placed in ms_defer trees during metaslab_sync_done().
|
||||||
|
*/
|
||||||
uint64_t
|
uint64_t
|
||||||
dsl_pool_adjustedsize(dsl_pool_t *dp, boolean_t netfree)
|
dsl_pool_adjustedsize(dsl_pool_t *dp, zfs_space_check_t slop_policy)
|
||||||
{
|
{
|
||||||
uint64_t space, resv;
|
spa_t *spa = dp->dp_spa;
|
||||||
|
uint64_t space, resv, adjustedsize;
|
||||||
|
uint64_t spa_deferred_frees =
|
||||||
|
spa->spa_deferred_bpobj.bpo_phys->bpo_bytes;
|
||||||
|
|
||||||
/*
|
space = spa_get_dspace(spa)
|
||||||
* If we're trying to assess whether it's OK to do a free,
|
- spa_get_checkpoint_space(spa) - spa_deferred_frees;
|
||||||
* cut the reservation in half to allow forward progress
|
resv = spa_get_slop_space(spa);
|
||||||
* (e.g. make it possible to rm(1) files from a full pool).
|
|
||||||
*/
|
switch (slop_policy) {
|
||||||
space = spa_get_dspace(dp->dp_spa);
|
case ZFS_SPACE_CHECK_NORMAL:
|
||||||
resv = spa_get_slop_space(dp->dp_spa);
|
break;
|
||||||
if (netfree)
|
case ZFS_SPACE_CHECK_RESERVED:
|
||||||
resv >>= 1;
|
resv >>= 1;
|
||||||
|
break;
|
||||||
|
case ZFS_SPACE_CHECK_EXTRA_RESERVED:
|
||||||
|
resv >>= 2;
|
||||||
|
break;
|
||||||
|
case ZFS_SPACE_CHECK_NONE:
|
||||||
|
resv = 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
panic("invalid slop policy value: %d", slop_policy);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
adjustedsize = (space >= resv) ? (space - resv) : 0;
|
||||||
|
|
||||||
return (space - resv);
|
return (adjustedsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t
|
||||||
|
dsl_pool_unreserved_space(dsl_pool_t *dp, zfs_space_check_t slop_policy)
|
||||||
|
{
|
||||||
|
uint64_t poolsize = dsl_pool_adjustedsize(dp, slop_policy);
|
||||||
|
uint64_t deferred =
|
||||||
|
metaslab_class_get_deferred(spa_normal_class(dp->dp_spa));
|
||||||
|
uint64_t quota = (poolsize >= deferred) ? (poolsize - deferred) : 0;
|
||||||
|
return (quota);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean_t
|
boolean_t
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* Copyright (c) 2011, 2017 by Delphix. All rights reserved.
|
||||||
* Copyright 2016 Gary Mills
|
* Copyright 2016 Gary Mills
|
||||||
* Copyright (c) 2011, 2017 by Delphix. All rights reserved.
|
* Copyright (c) 2011, 2017 by Delphix. All rights reserved.
|
||||||
* Copyright 2017 Joyent, Inc.
|
* Copyright 2017 Joyent, Inc.
|
||||||
@ -352,13 +353,23 @@ dsl_scan_done(dsl_scan_t *scn, boolean_t complete, dmu_tx_t *tx)
|
|||||||
* If the scrub/resilver completed, update all DTLs to
|
* If the scrub/resilver completed, update all DTLs to
|
||||||
* reflect this. Whether it succeeded or not, vacate
|
* reflect this. Whether it succeeded or not, vacate
|
||||||
* all temporary scrub DTLs.
|
* all temporary scrub DTLs.
|
||||||
|
*
|
||||||
|
* As the scrub does not currently support traversing
|
||||||
|
* data that have been freed but are part of a checkpoint,
|
||||||
|
* we don't mark the scrub as done in the DTLs as faults
|
||||||
|
* may still exist in those vdevs.
|
||||||
*/
|
*/
|
||||||
vdev_dtl_reassess(spa->spa_root_vdev, tx->tx_txg,
|
if (complete &&
|
||||||
complete ? scn->scn_phys.scn_max_txg : 0, B_TRUE);
|
!spa_feature_is_active(spa, SPA_FEATURE_POOL_CHECKPOINT)) {
|
||||||
if (complete) {
|
vdev_dtl_reassess(spa->spa_root_vdev, tx->tx_txg,
|
||||||
|
scn->scn_phys.scn_max_txg, B_TRUE);
|
||||||
|
|
||||||
spa_event_notify(spa, NULL, NULL,
|
spa_event_notify(spa, NULL, NULL,
|
||||||
scn->scn_phys.scn_min_txg ?
|
scn->scn_phys.scn_min_txg ?
|
||||||
ESC_ZFS_RESILVER_FINISH : ESC_ZFS_SCRUB_FINISH);
|
ESC_ZFS_RESILVER_FINISH : ESC_ZFS_SCRUB_FINISH);
|
||||||
|
} else {
|
||||||
|
vdev_dtl_reassess(spa->spa_root_vdev, tx->tx_txg,
|
||||||
|
0, B_TRUE);
|
||||||
}
|
}
|
||||||
spa_errlog_rotate(spa);
|
spa_errlog_rotate(spa);
|
||||||
|
|
||||||
@ -611,7 +622,7 @@ dsl_scan_zil_block(zilog_t *zilog, blkptr_t *bp, void *arg, uint64_t claim_txg)
|
|||||||
* (on-disk) even if it hasn't been claimed (even though for
|
* (on-disk) even if it hasn't been claimed (even though for
|
||||||
* scrub there's nothing to do to it).
|
* scrub there's nothing to do to it).
|
||||||
*/
|
*/
|
||||||
if (claim_txg == 0 && bp->blk_birth >= spa_first_txg(dp->dp_spa))
|
if (claim_txg == 0 && bp->blk_birth >= spa_min_claim_txg(dp->dp_spa))
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
SET_BOOKMARK(&zb, zh->zh_log.blk_cksum.zc_word[ZIL_ZC_OBJSET],
|
SET_BOOKMARK(&zb, zh->zh_log.blk_cksum.zc_word[ZIL_ZC_OBJSET],
|
||||||
@ -662,11 +673,13 @@ dsl_scan_zil(dsl_pool_t *dp, zil_header_t *zh)
|
|||||||
zil_scan_arg_t zsa = { dp, zh };
|
zil_scan_arg_t zsa = { dp, zh };
|
||||||
zilog_t *zilog;
|
zilog_t *zilog;
|
||||||
|
|
||||||
|
ASSERT(spa_writeable(dp->dp_spa));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We only want to visit blocks that have been claimed but not yet
|
* We only want to visit blocks that have been claimed
|
||||||
* replayed (or, in read-only mode, blocks that *would* be claimed).
|
* but not yet replayed.
|
||||||
*/
|
*/
|
||||||
if (claim_txg == 0 && spa_writeable(dp->dp_spa))
|
if (claim_txg == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
zilog = zil_alloc(dp->dp_meta_objset, zh);
|
zilog = zil_alloc(dp->dp_meta_objset, zh);
|
||||||
@ -1590,61 +1603,16 @@ dsl_scan_active(dsl_scan_t *scn)
|
|||||||
return (used != 0);
|
return (used != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called whenever a txg syncs. */
|
static int
|
||||||
void
|
dsl_process_async_destroys(dsl_pool_t *dp, dmu_tx_t *tx)
|
||||||
dsl_scan_sync(dsl_pool_t *dp, dmu_tx_t *tx)
|
|
||||||
{
|
{
|
||||||
dsl_scan_t *scn = dp->dp_scan;
|
dsl_scan_t *scn = dp->dp_scan;
|
||||||
spa_t *spa = dp->dp_spa;
|
spa_t *spa = dp->dp_spa;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
/*
|
if (spa_suspend_async_destroy(spa))
|
||||||
* Check for scn_restart_txg before checking spa_load_state, so
|
return (0);
|
||||||
* that we can restart an old-style scan while the pool is being
|
|
||||||
* imported (see dsl_scan_init).
|
|
||||||
*/
|
|
||||||
if (dsl_scan_restarting(scn, tx)) {
|
|
||||||
pool_scan_func_t func = POOL_SCAN_SCRUB;
|
|
||||||
dsl_scan_done(scn, B_FALSE, tx);
|
|
||||||
if (vdev_resilver_needed(spa->spa_root_vdev, NULL, NULL))
|
|
||||||
func = POOL_SCAN_RESILVER;
|
|
||||||
zfs_dbgmsg("restarting scan func=%u txg=%llu",
|
|
||||||
func, tx->tx_txg);
|
|
||||||
dsl_scan_setup_sync(&func, tx);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Only process scans in sync pass 1.
|
|
||||||
*/
|
|
||||||
if (spa_sync_pass(dp->dp_spa) > 1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the spa is shutting down, then stop scanning. This will
|
|
||||||
* ensure that the scan does not dirty any new data during the
|
|
||||||
* shutdown phase.
|
|
||||||
*/
|
|
||||||
if (spa_shutting_down(spa))
|
|
||||||
return;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the scan is inactive due to a stalled async destroy, try again.
|
|
||||||
*/
|
|
||||||
if (!scn->scn_async_stalled && !dsl_scan_active(scn))
|
|
||||||
return;
|
|
||||||
|
|
||||||
scn->scn_visited_this_txg = 0;
|
|
||||||
scn->scn_suspending = B_FALSE;
|
|
||||||
scn->scn_sync_start_time = gethrtime();
|
|
||||||
spa->spa_scrub_active = B_TRUE;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* First process the async destroys. If we suspend, don't do
|
|
||||||
* any scrubbing or resilvering. This ensures that there are no
|
|
||||||
* async destroys while we are scanning, so the scan code doesn't
|
|
||||||
* have to worry about traversing it. It is also faster to free the
|
|
||||||
* blocks than to scrub them.
|
|
||||||
*/
|
|
||||||
if (zfs_free_bpobj_enabled &&
|
if (zfs_free_bpobj_enabled &&
|
||||||
spa_version(dp->dp_spa) >= SPA_VERSION_DEADLISTS) {
|
spa_version(dp->dp_spa) >= SPA_VERSION_DEADLISTS) {
|
||||||
scn->scn_is_bptree = B_FALSE;
|
scn->scn_is_bptree = B_FALSE;
|
||||||
@ -1718,7 +1686,7 @@ dsl_scan_sync(dsl_pool_t *dp, dmu_tx_t *tx)
|
|||||||
ddt_sync(spa, tx->tx_txg);
|
ddt_sync(spa, tx->tx_txg);
|
||||||
}
|
}
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
return;
|
return (err);
|
||||||
if (dp->dp_free_dir != NULL && !scn->scn_async_destroying &&
|
if (dp->dp_free_dir != NULL && !scn->scn_async_destroying &&
|
||||||
zfs_free_leak_on_eio &&
|
zfs_free_leak_on_eio &&
|
||||||
(dsl_dir_phys(dp->dp_free_dir)->dd_used_bytes != 0 ||
|
(dsl_dir_phys(dp->dp_free_dir)->dd_used_bytes != 0 ||
|
||||||
@ -1772,6 +1740,67 @@ dsl_scan_sync(dsl_pool_t *dp, dmu_tx_t *tx)
|
|||||||
dsl_pool_destroy_obsolete_bpobj(dp, tx);
|
dsl_pool_destroy_obsolete_bpobj(dp, tx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dsl_scan_sync(dsl_pool_t *dp, dmu_tx_t *tx)
|
||||||
|
{
|
||||||
|
dsl_scan_t *scn = dp->dp_scan;
|
||||||
|
spa_t *spa = dp->dp_spa;
|
||||||
|
int err = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check for scn_restart_txg before checking spa_load_state, so
|
||||||
|
* that we can restart an old-style scan while the pool is being
|
||||||
|
* imported (see dsl_scan_init).
|
||||||
|
*/
|
||||||
|
if (dsl_scan_restarting(scn, tx)) {
|
||||||
|
pool_scan_func_t func = POOL_SCAN_SCRUB;
|
||||||
|
dsl_scan_done(scn, B_FALSE, tx);
|
||||||
|
if (vdev_resilver_needed(spa->spa_root_vdev, NULL, NULL))
|
||||||
|
func = POOL_SCAN_RESILVER;
|
||||||
|
zfs_dbgmsg("restarting scan func=%u txg=%llu",
|
||||||
|
func, tx->tx_txg);
|
||||||
|
dsl_scan_setup_sync(&func, tx);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Only process scans in sync pass 1.
|
||||||
|
*/
|
||||||
|
if (spa_sync_pass(dp->dp_spa) > 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the spa is shutting down, then stop scanning. This will
|
||||||
|
* ensure that the scan does not dirty any new data during the
|
||||||
|
* shutdown phase.
|
||||||
|
*/
|
||||||
|
if (spa_shutting_down(spa))
|
||||||
|
return;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the scan is inactive due to a stalled async destroy, try again.
|
||||||
|
*/
|
||||||
|
if (!scn->scn_async_stalled && !dsl_scan_active(scn))
|
||||||
|
return;
|
||||||
|
|
||||||
|
scn->scn_visited_this_txg = 0;
|
||||||
|
scn->scn_suspending = B_FALSE;
|
||||||
|
scn->scn_sync_start_time = gethrtime();
|
||||||
|
spa->spa_scrub_active = B_TRUE;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* First process the async destroys. If we pause, don't do
|
||||||
|
* any scrubbing or resilvering. This ensures that there are no
|
||||||
|
* async destroys while we are scanning, so the scan code doesn't
|
||||||
|
* have to worry about traversing it. It is also faster to free the
|
||||||
|
* blocks than to scrub them.
|
||||||
|
*/
|
||||||
|
err = dsl_process_async_destroys(dp, tx);
|
||||||
|
if (err != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
if (scn->scn_phys.scn_state != DSS_SCANNING)
|
if (scn->scn_phys.scn_state != DSS_SCANNING)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -2067,7 +2096,7 @@ dsl_scan(dsl_pool_t *dp, pool_scan_func_t func)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (dsl_sync_task(spa_name(spa), dsl_scan_setup_check,
|
return (dsl_sync_task(spa_name(spa), dsl_scan_setup_check,
|
||||||
dsl_scan_setup_sync, &func, 0, ZFS_SPACE_CHECK_NONE));
|
dsl_scan_setup_sync, &func, 0, ZFS_SPACE_CHECK_EXTRA_RESERVED));
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean_t
|
static boolean_t
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
* Copyright (c) 2012, 2014 by Delphix. All rights reserved.
|
* Copyright (c) 2012, 2017 by Delphix. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/dmu.h>
|
#include <sys/dmu.h>
|
||||||
@ -39,33 +39,10 @@ dsl_null_checkfunc(void *arg, dmu_tx_t *tx)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
static int
|
||||||
* Called from open context to perform a callback in syncing context. Waits
|
dsl_sync_task_common(const char *pool, dsl_checkfunc_t *checkfunc,
|
||||||
* for the operation to complete.
|
|
||||||
*
|
|
||||||
* The checkfunc will be called from open context as a preliminary check
|
|
||||||
* which can quickly fail. If it succeeds, it will be called again from
|
|
||||||
* syncing context. The checkfunc should generally be designed to work
|
|
||||||
* properly in either context, but if necessary it can check
|
|
||||||
* dmu_tx_is_syncing(tx).
|
|
||||||
*
|
|
||||||
* The synctask infrastructure enforces proper locking strategy with respect
|
|
||||||
* to the dp_config_rwlock -- the lock will always be held when the callbacks
|
|
||||||
* are called. It will be held for read during the open-context (preliminary)
|
|
||||||
* call to the checkfunc, and then held for write from syncing context during
|
|
||||||
* the calls to the check and sync funcs.
|
|
||||||
*
|
|
||||||
* A dataset or pool name can be passed as the first argument. Typically,
|
|
||||||
* the check func will hold, check the return value of the hold, and then
|
|
||||||
* release the dataset. The sync func will VERIFYO(hold()) the dataset.
|
|
||||||
* This is safe because no changes can be made between the check and sync funcs,
|
|
||||||
* and the sync func will only be called if the check func successfully opened
|
|
||||||
* the dataset.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
dsl_sync_task(const char *pool, dsl_checkfunc_t *checkfunc,
|
|
||||||
dsl_syncfunc_t *syncfunc, void *arg,
|
dsl_syncfunc_t *syncfunc, void *arg,
|
||||||
int blocks_modified, zfs_space_check_t space_check)
|
int blocks_modified, zfs_space_check_t space_check, boolean_t early)
|
||||||
{
|
{
|
||||||
spa_t *spa;
|
spa_t *spa;
|
||||||
dmu_tx_t *tx;
|
dmu_tx_t *tx;
|
||||||
@ -102,7 +79,9 @@ dsl_sync_task(const char *pool, dsl_checkfunc_t *checkfunc,
|
|||||||
return (err);
|
return (err);
|
||||||
}
|
}
|
||||||
|
|
||||||
VERIFY(txg_list_add_tail(&dp->dp_sync_tasks, &dst, dst.dst_txg));
|
txg_list_t *task_list = (early) ?
|
||||||
|
&dp->dp_early_sync_tasks : &dp->dp_sync_tasks;
|
||||||
|
VERIFY(txg_list_add_tail(task_list, &dst, dst.dst_txg));
|
||||||
|
|
||||||
dmu_tx_commit(tx);
|
dmu_tx_commit(tx);
|
||||||
|
|
||||||
@ -117,9 +96,64 @@ dsl_sync_task(const char *pool, dsl_checkfunc_t *checkfunc,
|
|||||||
return (dst.dst_error);
|
return (dst.dst_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
/*
|
||||||
dsl_sync_task_nowait(dsl_pool_t *dp, dsl_syncfunc_t *syncfunc, void *arg,
|
* Called from open context to perform a callback in syncing context. Waits
|
||||||
int blocks_modified, zfs_space_check_t space_check, dmu_tx_t *tx)
|
* for the operation to complete.
|
||||||
|
*
|
||||||
|
* The checkfunc will be called from open context as a preliminary check
|
||||||
|
* which can quickly fail. If it succeeds, it will be called again from
|
||||||
|
* syncing context. The checkfunc should generally be designed to work
|
||||||
|
* properly in either context, but if necessary it can check
|
||||||
|
* dmu_tx_is_syncing(tx).
|
||||||
|
*
|
||||||
|
* The synctask infrastructure enforces proper locking strategy with respect
|
||||||
|
* to the dp_config_rwlock -- the lock will always be held when the callbacks
|
||||||
|
* are called. It will be held for read during the open-context (preliminary)
|
||||||
|
* call to the checkfunc, and then held for write from syncing context during
|
||||||
|
* the calls to the check and sync funcs.
|
||||||
|
*
|
||||||
|
* A dataset or pool name can be passed as the first argument. Typically,
|
||||||
|
* the check func will hold, check the return value of the hold, and then
|
||||||
|
* release the dataset. The sync func will VERIFYO(hold()) the dataset.
|
||||||
|
* This is safe because no changes can be made between the check and sync funcs,
|
||||||
|
* and the sync func will only be called if the check func successfully opened
|
||||||
|
* the dataset.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
dsl_sync_task(const char *pool, dsl_checkfunc_t *checkfunc,
|
||||||
|
dsl_syncfunc_t *syncfunc, void *arg,
|
||||||
|
int blocks_modified, zfs_space_check_t space_check)
|
||||||
|
{
|
||||||
|
return (dsl_sync_task_common(pool, checkfunc, syncfunc, arg,
|
||||||
|
blocks_modified, space_check, B_FALSE));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* An early synctask works exactly as a standard synctask with one important
|
||||||
|
* difference on the way it is handled during syncing context. Standard
|
||||||
|
* synctasks run after we've written out all the dirty blocks of dirty
|
||||||
|
* datasets. Early synctasks are executed before writing out any dirty data,
|
||||||
|
* and thus before standard synctasks.
|
||||||
|
*
|
||||||
|
* For that reason, early synctasks can affect the process of writing dirty
|
||||||
|
* changes to disk for the txg that they run and should be used with caution.
|
||||||
|
* In addition, early synctasks should not dirty any metaslabs as this would
|
||||||
|
* invalidate the precodition/invariant for subsequent early synctasks.
|
||||||
|
* [see dsl_pool_sync() and dsl_early_sync_task_verify()]
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
dsl_early_sync_task(const char *pool, dsl_checkfunc_t *checkfunc,
|
||||||
|
dsl_syncfunc_t *syncfunc, void *arg,
|
||||||
|
int blocks_modified, zfs_space_check_t space_check)
|
||||||
|
{
|
||||||
|
return (dsl_sync_task_common(pool, checkfunc, syncfunc, arg,
|
||||||
|
blocks_modified, space_check, B_TRUE));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dsl_sync_task_nowait_common(dsl_pool_t *dp, dsl_syncfunc_t *syncfunc, void *arg,
|
||||||
|
int blocks_modified, zfs_space_check_t space_check, dmu_tx_t *tx,
|
||||||
|
boolean_t early)
|
||||||
{
|
{
|
||||||
dsl_sync_task_t *dst = kmem_zalloc(sizeof (*dst), KM_SLEEP);
|
dsl_sync_task_t *dst = kmem_zalloc(sizeof (*dst), KM_SLEEP);
|
||||||
|
|
||||||
@ -133,7 +167,25 @@ dsl_sync_task_nowait(dsl_pool_t *dp, dsl_syncfunc_t *syncfunc, void *arg,
|
|||||||
dst->dst_error = 0;
|
dst->dst_error = 0;
|
||||||
dst->dst_nowaiter = B_TRUE;
|
dst->dst_nowaiter = B_TRUE;
|
||||||
|
|
||||||
VERIFY(txg_list_add_tail(&dp->dp_sync_tasks, dst, dst->dst_txg));
|
txg_list_t *task_list = (early) ?
|
||||||
|
&dp->dp_early_sync_tasks : &dp->dp_sync_tasks;
|
||||||
|
VERIFY(txg_list_add_tail(task_list, dst, dst->dst_txg));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dsl_sync_task_nowait(dsl_pool_t *dp, dsl_syncfunc_t *syncfunc, void *arg,
|
||||||
|
int blocks_modified, zfs_space_check_t space_check, dmu_tx_t *tx)
|
||||||
|
{
|
||||||
|
dsl_sync_task_nowait_common(dp, syncfunc, arg,
|
||||||
|
blocks_modified, space_check, tx, B_FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dsl_early_sync_task_nowait(dsl_pool_t *dp, dsl_syncfunc_t *syncfunc, void *arg,
|
||||||
|
int blocks_modified, zfs_space_check_t space_check, dmu_tx_t *tx)
|
||||||
|
{
|
||||||
|
dsl_sync_task_nowait_common(dp, syncfunc, arg,
|
||||||
|
blocks_modified, space_check, tx, B_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -160,12 +212,12 @@ dsl_sync_task_sync(dsl_sync_task_t *dst, dmu_tx_t *tx)
|
|||||||
* (arc_tempreserve, dsl_pool_tempreserve).
|
* (arc_tempreserve, dsl_pool_tempreserve).
|
||||||
*/
|
*/
|
||||||
if (dst->dst_space_check != ZFS_SPACE_CHECK_NONE) {
|
if (dst->dst_space_check != ZFS_SPACE_CHECK_NONE) {
|
||||||
uint64_t quota = dsl_pool_adjustedsize(dp,
|
uint64_t quota = dsl_pool_unreserved_space(dp,
|
||||||
dst->dst_space_check == ZFS_SPACE_CHECK_RESERVED) -
|
dst->dst_space_check);
|
||||||
metaslab_class_get_deferred(spa_normal_class(dp->dp_spa));
|
|
||||||
uint64_t used = dsl_dir_phys(dp->dp_root_dir)->dd_used_bytes;
|
uint64_t used = dsl_dir_phys(dp->dp_root_dir)->dd_used_bytes;
|
||||||
|
|
||||||
/* MOS space is triple-dittoed, so we multiply by 3. */
|
/* MOS space is triple-dittoed, so we multiply by 3. */
|
||||||
if (dst->dst_space > 0 && used + dst->dst_space * 3 > quota) {
|
if (used + dst->dst_space * 3 > quota) {
|
||||||
dst->dst_error = SET_ERROR(ENOSPC);
|
dst->dst_error = SET_ERROR(ENOSPC);
|
||||||
if (dst->dst_nowaiter)
|
if (dst->dst_nowaiter)
|
||||||
kmem_free(dst, sizeof (*dst));
|
kmem_free(dst, sizeof (*dst));
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
* Copyright (c) 2012, 2015 by Delphix. All rights reserved.
|
* Copyright (c) 2012, 2017 by Delphix. All rights reserved.
|
||||||
* Copyright (c) 2013 Steven Hartland. All rights reserved.
|
* Copyright (c) 2013 Steven Hartland. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -602,7 +602,8 @@ dsl_dataset_user_release_impl(nvlist_t *holds, nvlist_t *errlist,
|
|||||||
ddura.ddura_chkholds = fnvlist_alloc();
|
ddura.ddura_chkholds = fnvlist_alloc();
|
||||||
|
|
||||||
error = dsl_sync_task(pool, dsl_dataset_user_release_check,
|
error = dsl_sync_task(pool, dsl_dataset_user_release_check,
|
||||||
dsl_dataset_user_release_sync, &ddura, 0, ZFS_SPACE_CHECK_NONE);
|
dsl_dataset_user_release_sync, &ddura, 0,
|
||||||
|
ZFS_SPACE_CHECK_EXTRA_RESERVED);
|
||||||
fnvlist_free(ddura.ddura_todelete);
|
fnvlist_free(ddura.ddura_todelete);
|
||||||
fnvlist_free(ddura.ddura_chkholds);
|
fnvlist_free(ddura.ddura_chkholds);
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include <sys/spa_impl.h>
|
#include <sys/spa_impl.h>
|
||||||
#include <sys/zfeature.h>
|
#include <sys/zfeature.h>
|
||||||
#include <sys/vdev_indirect_mapping.h>
|
#include <sys/vdev_indirect_mapping.h>
|
||||||
|
#include <sys/zap.h>
|
||||||
|
|
||||||
SYSCTL_DECL(_vfs_zfs);
|
SYSCTL_DECL(_vfs_zfs);
|
||||||
SYSCTL_NODE(_vfs_zfs, OID_AUTO, metaslab, CTLFLAG_RW, 0, "ZFS metaslab");
|
SYSCTL_NODE(_vfs_zfs, OID_AUTO, metaslab, CTLFLAG_RW, 0, "ZFS metaslab");
|
||||||
@ -48,6 +49,17 @@ SYSCTL_QUAD(_vfs_zfs_metaslab, OID_AUTO, gang_bang, CTLFLAG_RWTUN,
|
|||||||
&metaslab_gang_bang, 0,
|
&metaslab_gang_bang, 0,
|
||||||
"Force gang block allocation for blocks larger than or equal to this value");
|
"Force gang block allocation for blocks larger than or equal to this value");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Since we can touch multiple metaslabs (and their respective space maps)
|
||||||
|
* with each transaction group, we benefit from having a smaller space map
|
||||||
|
* block size since it allows us to issue more I/O operations scattered
|
||||||
|
* around the disk.
|
||||||
|
*/
|
||||||
|
int zfs_metaslab_sm_blksz = (1 << 12);
|
||||||
|
SYSCTL_INT(_vfs_zfs, OID_AUTO, metaslab_sm_blksz, CTLFLAG_RDTUN,
|
||||||
|
&zfs_metaslab_sm_blksz, 0,
|
||||||
|
"Block size for metaslab DTL space map. Power of 2 and greater than 4096.");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The in-core space map representation is more compact than its on-disk form.
|
* The in-core space map representation is more compact than its on-disk form.
|
||||||
* The zfs_condense_pct determines how much more compact the in-core
|
* The zfs_condense_pct determines how much more compact the in-core
|
||||||
@ -261,7 +273,7 @@ uint64_t metaslab_trace_max_entries = 5000;
|
|||||||
|
|
||||||
static uint64_t metaslab_weight(metaslab_t *);
|
static uint64_t metaslab_weight(metaslab_t *);
|
||||||
static void metaslab_set_fragmentation(metaslab_t *);
|
static void metaslab_set_fragmentation(metaslab_t *);
|
||||||
static void metaslab_free_impl(vdev_t *, uint64_t, uint64_t, uint64_t);
|
static void metaslab_free_impl(vdev_t *, uint64_t, uint64_t, boolean_t);
|
||||||
static void metaslab_check_free_impl(vdev_t *, uint64_t, uint64_t);
|
static void metaslab_check_free_impl(vdev_t *, uint64_t, uint64_t);
|
||||||
|
|
||||||
kmem_cache_t *metaslab_alloc_trace_cache;
|
kmem_cache_t *metaslab_alloc_trace_cache;
|
||||||
@ -573,11 +585,11 @@ metaslab_verify_space(metaslab_t *msp, uint64_t txg)
|
|||||||
*/
|
*/
|
||||||
for (int t = 0; t < TXG_CONCURRENT_STATES; t++) {
|
for (int t = 0; t < TXG_CONCURRENT_STATES; t++) {
|
||||||
allocated +=
|
allocated +=
|
||||||
range_tree_space(msp->ms_alloctree[(txg + t) & TXG_MASK]);
|
range_tree_space(msp->ms_allocating[(txg + t) & TXG_MASK]);
|
||||||
}
|
}
|
||||||
|
|
||||||
msp_free_space = range_tree_space(msp->ms_tree) + allocated +
|
msp_free_space = range_tree_space(msp->ms_allocatable) + allocated +
|
||||||
msp->ms_deferspace + range_tree_space(msp->ms_freedtree);
|
msp->ms_deferspace + range_tree_space(msp->ms_freed);
|
||||||
|
|
||||||
VERIFY3U(sm_free_space, ==, msp_free_space);
|
VERIFY3U(sm_free_space, ==, msp_free_space);
|
||||||
}
|
}
|
||||||
@ -1117,9 +1129,9 @@ metaslab_rt_create(range_tree_t *rt, void *arg)
|
|||||||
metaslab_t *msp = arg;
|
metaslab_t *msp = arg;
|
||||||
|
|
||||||
ASSERT3P(rt->rt_arg, ==, msp);
|
ASSERT3P(rt->rt_arg, ==, msp);
|
||||||
ASSERT(msp->ms_tree == NULL);
|
ASSERT(msp->ms_allocatable == NULL);
|
||||||
|
|
||||||
avl_create(&msp->ms_size_tree, metaslab_rangesize_compare,
|
avl_create(&msp->ms_allocatable_by_size, metaslab_rangesize_compare,
|
||||||
sizeof (range_seg_t), offsetof(range_seg_t, rs_pp_node));
|
sizeof (range_seg_t), offsetof(range_seg_t, rs_pp_node));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1132,10 +1144,10 @@ metaslab_rt_destroy(range_tree_t *rt, void *arg)
|
|||||||
metaslab_t *msp = arg;
|
metaslab_t *msp = arg;
|
||||||
|
|
||||||
ASSERT3P(rt->rt_arg, ==, msp);
|
ASSERT3P(rt->rt_arg, ==, msp);
|
||||||
ASSERT3P(msp->ms_tree, ==, rt);
|
ASSERT3P(msp->ms_allocatable, ==, rt);
|
||||||
ASSERT0(avl_numnodes(&msp->ms_size_tree));
|
ASSERT0(avl_numnodes(&msp->ms_allocatable_by_size));
|
||||||
|
|
||||||
avl_destroy(&msp->ms_size_tree);
|
avl_destroy(&msp->ms_allocatable_by_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1144,9 +1156,9 @@ metaslab_rt_add(range_tree_t *rt, range_seg_t *rs, void *arg)
|
|||||||
metaslab_t *msp = arg;
|
metaslab_t *msp = arg;
|
||||||
|
|
||||||
ASSERT3P(rt->rt_arg, ==, msp);
|
ASSERT3P(rt->rt_arg, ==, msp);
|
||||||
ASSERT3P(msp->ms_tree, ==, rt);
|
ASSERT3P(msp->ms_allocatable, ==, rt);
|
||||||
VERIFY(!msp->ms_condensing);
|
VERIFY(!msp->ms_condensing);
|
||||||
avl_add(&msp->ms_size_tree, rs);
|
avl_add(&msp->ms_allocatable_by_size, rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1155,9 +1167,9 @@ metaslab_rt_remove(range_tree_t *rt, range_seg_t *rs, void *arg)
|
|||||||
metaslab_t *msp = arg;
|
metaslab_t *msp = arg;
|
||||||
|
|
||||||
ASSERT3P(rt->rt_arg, ==, msp);
|
ASSERT3P(rt->rt_arg, ==, msp);
|
||||||
ASSERT3P(msp->ms_tree, ==, rt);
|
ASSERT3P(msp->ms_allocatable, ==, rt);
|
||||||
VERIFY(!msp->ms_condensing);
|
VERIFY(!msp->ms_condensing);
|
||||||
avl_remove(&msp->ms_size_tree, rs);
|
avl_remove(&msp->ms_allocatable_by_size, rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1166,7 +1178,7 @@ metaslab_rt_vacate(range_tree_t *rt, void *arg)
|
|||||||
metaslab_t *msp = arg;
|
metaslab_t *msp = arg;
|
||||||
|
|
||||||
ASSERT3P(rt->rt_arg, ==, msp);
|
ASSERT3P(rt->rt_arg, ==, msp);
|
||||||
ASSERT3P(msp->ms_tree, ==, rt);
|
ASSERT3P(msp->ms_allocatable, ==, rt);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Normally one would walk the tree freeing nodes along the way.
|
* Normally one would walk the tree freeing nodes along the way.
|
||||||
@ -1174,7 +1186,7 @@ metaslab_rt_vacate(range_tree_t *rt, void *arg)
|
|||||||
* walking all nodes and just reinitialize the avl tree. The nodes
|
* walking all nodes and just reinitialize the avl tree. The nodes
|
||||||
* will be freed by the range tree, so we don't want to free them here.
|
* will be freed by the range tree, so we don't want to free them here.
|
||||||
*/
|
*/
|
||||||
avl_create(&msp->ms_size_tree, metaslab_rangesize_compare,
|
avl_create(&msp->ms_allocatable_by_size, metaslab_rangesize_compare,
|
||||||
sizeof (range_seg_t), offsetof(range_seg_t, rs_pp_node));
|
sizeof (range_seg_t), offsetof(range_seg_t, rs_pp_node));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1198,7 +1210,7 @@ static range_tree_ops_t metaslab_rt_ops = {
|
|||||||
uint64_t
|
uint64_t
|
||||||
metaslab_block_maxsize(metaslab_t *msp)
|
metaslab_block_maxsize(metaslab_t *msp)
|
||||||
{
|
{
|
||||||
avl_tree_t *t = &msp->ms_size_tree;
|
avl_tree_t *t = &msp->ms_allocatable_by_size;
|
||||||
range_seg_t *rs;
|
range_seg_t *rs;
|
||||||
|
|
||||||
if (t == NULL || (rs = avl_last(t)) == NULL)
|
if (t == NULL || (rs = avl_last(t)) == NULL)
|
||||||
@ -1273,7 +1285,7 @@ metaslab_ff_alloc(metaslab_t *msp, uint64_t size)
|
|||||||
*/
|
*/
|
||||||
uint64_t align = size & -size;
|
uint64_t align = size & -size;
|
||||||
uint64_t *cursor = &msp->ms_lbas[highbit64(align) - 1];
|
uint64_t *cursor = &msp->ms_lbas[highbit64(align) - 1];
|
||||||
avl_tree_t *t = &msp->ms_tree->rt_root;
|
avl_tree_t *t = &msp->ms_allocatable->rt_root;
|
||||||
|
|
||||||
return (metaslab_block_picker(t, cursor, size, align));
|
return (metaslab_block_picker(t, cursor, size, align));
|
||||||
}
|
}
|
||||||
@ -1302,13 +1314,14 @@ metaslab_df_alloc(metaslab_t *msp, uint64_t size)
|
|||||||
*/
|
*/
|
||||||
uint64_t align = size & -size;
|
uint64_t align = size & -size;
|
||||||
uint64_t *cursor = &msp->ms_lbas[highbit64(align) - 1];
|
uint64_t *cursor = &msp->ms_lbas[highbit64(align) - 1];
|
||||||
range_tree_t *rt = msp->ms_tree;
|
range_tree_t *rt = msp->ms_allocatable;
|
||||||
avl_tree_t *t = &rt->rt_root;
|
avl_tree_t *t = &rt->rt_root;
|
||||||
uint64_t max_size = metaslab_block_maxsize(msp);
|
uint64_t max_size = metaslab_block_maxsize(msp);
|
||||||
int free_pct = range_tree_space(rt) * 100 / msp->ms_size;
|
int free_pct = range_tree_space(rt) * 100 / msp->ms_size;
|
||||||
|
|
||||||
ASSERT(MUTEX_HELD(&msp->ms_lock));
|
ASSERT(MUTEX_HELD(&msp->ms_lock));
|
||||||
ASSERT3U(avl_numnodes(t), ==, avl_numnodes(&msp->ms_size_tree));
|
ASSERT3U(avl_numnodes(t), ==,
|
||||||
|
avl_numnodes(&msp->ms_allocatable_by_size));
|
||||||
|
|
||||||
if (max_size < size)
|
if (max_size < size)
|
||||||
return (-1ULL);
|
return (-1ULL);
|
||||||
@ -1319,7 +1332,7 @@ metaslab_df_alloc(metaslab_t *msp, uint64_t size)
|
|||||||
*/
|
*/
|
||||||
if (max_size < metaslab_df_alloc_threshold ||
|
if (max_size < metaslab_df_alloc_threshold ||
|
||||||
free_pct < metaslab_df_free_pct) {
|
free_pct < metaslab_df_free_pct) {
|
||||||
t = &msp->ms_size_tree;
|
t = &msp->ms_allocatable_by_size;
|
||||||
*cursor = 0;
|
*cursor = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1342,8 +1355,8 @@ static metaslab_ops_t metaslab_df_ops = {
|
|||||||
static uint64_t
|
static uint64_t
|
||||||
metaslab_cf_alloc(metaslab_t *msp, uint64_t size)
|
metaslab_cf_alloc(metaslab_t *msp, uint64_t size)
|
||||||
{
|
{
|
||||||
range_tree_t *rt = msp->ms_tree;
|
range_tree_t *rt = msp->ms_allocatable;
|
||||||
avl_tree_t *t = &msp->ms_size_tree;
|
avl_tree_t *t = &msp->ms_allocatable_by_size;
|
||||||
uint64_t *cursor = &msp->ms_lbas[0];
|
uint64_t *cursor = &msp->ms_lbas[0];
|
||||||
uint64_t *cursor_end = &msp->ms_lbas[1];
|
uint64_t *cursor_end = &msp->ms_lbas[1];
|
||||||
uint64_t offset = 0;
|
uint64_t offset = 0;
|
||||||
@ -1356,7 +1369,7 @@ metaslab_cf_alloc(metaslab_t *msp, uint64_t size)
|
|||||||
if ((*cursor + size) > *cursor_end) {
|
if ((*cursor + size) > *cursor_end) {
|
||||||
range_seg_t *rs;
|
range_seg_t *rs;
|
||||||
|
|
||||||
rs = avl_last(&msp->ms_size_tree);
|
rs = avl_last(&msp->ms_allocatable_by_size);
|
||||||
if (rs == NULL || (rs->rs_end - rs->rs_start) < size)
|
if (rs == NULL || (rs->rs_end - rs->rs_start) < size)
|
||||||
return (-1ULL);
|
return (-1ULL);
|
||||||
|
|
||||||
@ -1392,7 +1405,7 @@ uint64_t metaslab_ndf_clump_shift = 4;
|
|||||||
static uint64_t
|
static uint64_t
|
||||||
metaslab_ndf_alloc(metaslab_t *msp, uint64_t size)
|
metaslab_ndf_alloc(metaslab_t *msp, uint64_t size)
|
||||||
{
|
{
|
||||||
avl_tree_t *t = &msp->ms_tree->rt_root;
|
avl_tree_t *t = &msp->ms_allocatable->rt_root;
|
||||||
avl_index_t where;
|
avl_index_t where;
|
||||||
range_seg_t *rs, rsearch;
|
range_seg_t *rs, rsearch;
|
||||||
uint64_t hbit = highbit64(size);
|
uint64_t hbit = highbit64(size);
|
||||||
@ -1400,7 +1413,8 @@ metaslab_ndf_alloc(metaslab_t *msp, uint64_t size)
|
|||||||
uint64_t max_size = metaslab_block_maxsize(msp);
|
uint64_t max_size = metaslab_block_maxsize(msp);
|
||||||
|
|
||||||
ASSERT(MUTEX_HELD(&msp->ms_lock));
|
ASSERT(MUTEX_HELD(&msp->ms_lock));
|
||||||
ASSERT3U(avl_numnodes(t), ==, avl_numnodes(&msp->ms_size_tree));
|
ASSERT3U(avl_numnodes(t), ==,
|
||||||
|
avl_numnodes(&msp->ms_allocatable_by_size));
|
||||||
|
|
||||||
if (max_size < size)
|
if (max_size < size)
|
||||||
return (-1ULL);
|
return (-1ULL);
|
||||||
@ -1410,7 +1424,7 @@ metaslab_ndf_alloc(metaslab_t *msp, uint64_t size)
|
|||||||
|
|
||||||
rs = avl_find(t, &rsearch, &where);
|
rs = avl_find(t, &rsearch, &where);
|
||||||
if (rs == NULL || (rs->rs_end - rs->rs_start) < size) {
|
if (rs == NULL || (rs->rs_end - rs->rs_start) < size) {
|
||||||
t = &msp->ms_size_tree;
|
t = &msp->ms_allocatable_by_size;
|
||||||
|
|
||||||
rsearch.rs_start = 0;
|
rsearch.rs_start = 0;
|
||||||
rsearch.rs_end = MIN(max_size,
|
rsearch.rs_end = MIN(max_size,
|
||||||
@ -1474,13 +1488,15 @@ metaslab_load(metaslab_t *msp)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* If the space map has not been allocated yet, then treat
|
* If the space map has not been allocated yet, then treat
|
||||||
* all the space in the metaslab as free and add it to the
|
* all the space in the metaslab as free and add it to ms_allocatable.
|
||||||
* ms_tree.
|
|
||||||
*/
|
*/
|
||||||
if (msp->ms_sm != NULL)
|
if (msp->ms_sm != NULL) {
|
||||||
error = space_map_load(msp->ms_sm, msp->ms_tree, SM_FREE);
|
error = space_map_load(msp->ms_sm, msp->ms_allocatable,
|
||||||
else
|
SM_FREE);
|
||||||
range_tree_add(msp->ms_tree, msp->ms_start, msp->ms_size);
|
} else {
|
||||||
|
range_tree_add(msp->ms_allocatable,
|
||||||
|
msp->ms_start, msp->ms_size);
|
||||||
|
}
|
||||||
|
|
||||||
success = (error == 0);
|
success = (error == 0);
|
||||||
|
|
||||||
@ -1491,9 +1507,16 @@ metaslab_load(metaslab_t *msp)
|
|||||||
ASSERT3P(msp->ms_group, !=, NULL);
|
ASSERT3P(msp->ms_group, !=, NULL);
|
||||||
msp->ms_loaded = B_TRUE;
|
msp->ms_loaded = B_TRUE;
|
||||||
|
|
||||||
for (int t = 0; t < TXG_DEFER_SIZE; t++) {
|
/*
|
||||||
range_tree_walk(msp->ms_defertree[t],
|
* If the metaslab already has a spacemap, then we need to
|
||||||
range_tree_remove, msp->ms_tree);
|
* remove all segments from the defer tree; otherwise, the
|
||||||
|
* metaslab is completely empty and we can skip this.
|
||||||
|
*/
|
||||||
|
if (msp->ms_sm != NULL) {
|
||||||
|
for (int t = 0; t < TXG_DEFER_SIZE; t++) {
|
||||||
|
range_tree_walk(msp->ms_defer[t],
|
||||||
|
range_tree_remove, msp->ms_allocatable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
msp->ms_max_size = metaslab_block_maxsize(msp);
|
msp->ms_max_size = metaslab_block_maxsize(msp);
|
||||||
}
|
}
|
||||||
@ -1505,7 +1528,7 @@ void
|
|||||||
metaslab_unload(metaslab_t *msp)
|
metaslab_unload(metaslab_t *msp)
|
||||||
{
|
{
|
||||||
ASSERT(MUTEX_HELD(&msp->ms_lock));
|
ASSERT(MUTEX_HELD(&msp->ms_lock));
|
||||||
range_tree_vacate(msp->ms_tree, NULL, NULL);
|
range_tree_vacate(msp->ms_allocatable, NULL, NULL);
|
||||||
msp->ms_loaded = B_FALSE;
|
msp->ms_loaded = B_FALSE;
|
||||||
msp->ms_weight &= ~METASLAB_ACTIVE_MASK;
|
msp->ms_weight &= ~METASLAB_ACTIVE_MASK;
|
||||||
msp->ms_max_size = 0;
|
msp->ms_max_size = 0;
|
||||||
@ -1551,7 +1574,7 @@ metaslab_init(metaslab_group_t *mg, uint64_t id, uint64_t object, uint64_t txg,
|
|||||||
* addition of new space; and for debugging, it ensures that we'd
|
* addition of new space; and for debugging, it ensures that we'd
|
||||||
* data fault on any attempt to use this metaslab before it's ready.
|
* data fault on any attempt to use this metaslab before it's ready.
|
||||||
*/
|
*/
|
||||||
ms->ms_tree = range_tree_create(&metaslab_rt_ops, ms);
|
ms->ms_allocatable = range_tree_create(&metaslab_rt_ops, ms);
|
||||||
metaslab_group_add(mg, ms);
|
metaslab_group_add(mg, ms);
|
||||||
|
|
||||||
metaslab_set_fragmentation(ms);
|
metaslab_set_fragmentation(ms);
|
||||||
@ -1603,20 +1626,21 @@ metaslab_fini(metaslab_t *msp)
|
|||||||
space_map_close(msp->ms_sm);
|
space_map_close(msp->ms_sm);
|
||||||
|
|
||||||
metaslab_unload(msp);
|
metaslab_unload(msp);
|
||||||
range_tree_destroy(msp->ms_tree);
|
range_tree_destroy(msp->ms_allocatable);
|
||||||
range_tree_destroy(msp->ms_freeingtree);
|
range_tree_destroy(msp->ms_freeing);
|
||||||
range_tree_destroy(msp->ms_freedtree);
|
range_tree_destroy(msp->ms_freed);
|
||||||
|
|
||||||
for (int t = 0; t < TXG_SIZE; t++) {
|
for (int t = 0; t < TXG_SIZE; t++) {
|
||||||
range_tree_destroy(msp->ms_alloctree[t]);
|
range_tree_destroy(msp->ms_allocating[t]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int t = 0; t < TXG_DEFER_SIZE; t++) {
|
for (int t = 0; t < TXG_DEFER_SIZE; t++) {
|
||||||
range_tree_destroy(msp->ms_defertree[t]);
|
range_tree_destroy(msp->ms_defer[t]);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT0(msp->ms_deferspace);
|
ASSERT0(msp->ms_deferspace);
|
||||||
|
|
||||||
|
range_tree_destroy(msp->ms_checkpointing);
|
||||||
|
|
||||||
mutex_exit(&msp->ms_lock);
|
mutex_exit(&msp->ms_lock);
|
||||||
cv_destroy(&msp->ms_load_cv);
|
cv_destroy(&msp->ms_load_cv);
|
||||||
mutex_destroy(&msp->ms_lock);
|
mutex_destroy(&msp->ms_lock);
|
||||||
@ -1836,7 +1860,7 @@ metaslab_weight_from_range_tree(metaslab_t *msp)
|
|||||||
int max_idx = SPACE_MAP_HISTOGRAM_SIZE + shift - 1;
|
int max_idx = SPACE_MAP_HISTOGRAM_SIZE + shift - 1;
|
||||||
|
|
||||||
segments <<= 1;
|
segments <<= 1;
|
||||||
segments += msp->ms_tree->rt_histogram[i];
|
segments += msp->ms_allocatable->rt_histogram[i];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The range tree provides more precision than the space map
|
* The range tree provides more precision than the space map
|
||||||
@ -2052,7 +2076,7 @@ metaslab_passivate(metaslab_t *msp, uint64_t weight)
|
|||||||
* or we would be leaving space on the table.
|
* or we would be leaving space on the table.
|
||||||
*/
|
*/
|
||||||
ASSERT(size >= SPA_MINBLOCKSIZE ||
|
ASSERT(size >= SPA_MINBLOCKSIZE ||
|
||||||
range_tree_space(msp->ms_tree) == 0);
|
range_tree_is_empty(msp->ms_allocatable));
|
||||||
ASSERT0(weight & METASLAB_ACTIVE_MASK);
|
ASSERT0(weight & METASLAB_ACTIVE_MASK);
|
||||||
|
|
||||||
msp->ms_activation_weight = 0;
|
msp->ms_activation_weight = 0;
|
||||||
@ -2183,18 +2207,37 @@ metaslab_should_condense(metaslab_t *msp)
|
|||||||
range_seg_t *rs;
|
range_seg_t *rs;
|
||||||
uint64_t size, entries, segsz, object_size, optimal_size, record_size;
|
uint64_t size, entries, segsz, object_size, optimal_size, record_size;
|
||||||
dmu_object_info_t doi;
|
dmu_object_info_t doi;
|
||||||
uint64_t vdev_blocksize = 1 << msp->ms_group->mg_vd->vdev_ashift;
|
vdev_t *vd = msp->ms_group->mg_vd;
|
||||||
|
uint64_t vdev_blocksize = 1 << vd->vdev_ashift;
|
||||||
|
uint64_t current_txg = spa_syncing_txg(vd->vdev_spa);
|
||||||
|
|
||||||
ASSERT(MUTEX_HELD(&msp->ms_lock));
|
ASSERT(MUTEX_HELD(&msp->ms_lock));
|
||||||
ASSERT(msp->ms_loaded);
|
ASSERT(msp->ms_loaded);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use the ms_size_tree range tree, which is ordered by size, to
|
* Allocations and frees in early passes are generally more space
|
||||||
* obtain the largest segment in the free tree. We always condense
|
* efficient (in terms of blocks described in space map entries)
|
||||||
* metaslabs that are empty and metaslabs for which a condense
|
* than the ones in later passes (e.g. we don't compress after
|
||||||
* request has been made.
|
* sync pass 5) and condensing a metaslab multiple times in a txg
|
||||||
|
* could degrade performance.
|
||||||
|
*
|
||||||
|
* Thus we prefer condensing each metaslab at most once every txg at
|
||||||
|
* the earliest sync pass possible. If a metaslab is eligible for
|
||||||
|
* condensing again after being considered for condensing within the
|
||||||
|
* same txg, it will hopefully be dirty in the next txg where it will
|
||||||
|
* be condensed at an earlier pass.
|
||||||
*/
|
*/
|
||||||
rs = avl_last(&msp->ms_size_tree);
|
if (msp->ms_condense_checked_txg == current_txg)
|
||||||
|
return (B_FALSE);
|
||||||
|
msp->ms_condense_checked_txg = current_txg;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Use the ms_allocatable_by_size range tree, which is ordered by
|
||||||
|
* size, to obtain the largest segment in the free tree. We always
|
||||||
|
* condense metaslabs that are empty and metaslabs for which a
|
||||||
|
* condense request has been made.
|
||||||
|
*/
|
||||||
|
rs = avl_last(&msp->ms_allocatable_by_size);
|
||||||
if (rs == NULL || msp->ms_condense_wanted)
|
if (rs == NULL || msp->ms_condense_wanted)
|
||||||
return (B_TRUE);
|
return (B_TRUE);
|
||||||
|
|
||||||
@ -2208,7 +2251,8 @@ metaslab_should_condense(metaslab_t *msp)
|
|||||||
entries = size / (MIN(size, SM_RUN_MAX));
|
entries = size / (MIN(size, SM_RUN_MAX));
|
||||||
segsz = entries * sizeof (uint64_t);
|
segsz = entries * sizeof (uint64_t);
|
||||||
|
|
||||||
optimal_size = sizeof (uint64_t) * avl_numnodes(&msp->ms_tree->rt_root);
|
optimal_size =
|
||||||
|
sizeof (uint64_t) * avl_numnodes(&msp->ms_allocatable->rt_root);
|
||||||
object_size = space_map_length(msp->ms_sm);
|
object_size = space_map_length(msp->ms_sm);
|
||||||
|
|
||||||
dmu_object_info_from_db(sm->sm_dbuf, &doi);
|
dmu_object_info_from_db(sm->sm_dbuf, &doi);
|
||||||
@ -2227,20 +2271,18 @@ metaslab_should_condense(metaslab_t *msp)
|
|||||||
static void
|
static void
|
||||||
metaslab_condense(metaslab_t *msp, uint64_t txg, dmu_tx_t *tx)
|
metaslab_condense(metaslab_t *msp, uint64_t txg, dmu_tx_t *tx)
|
||||||
{
|
{
|
||||||
spa_t *spa = msp->ms_group->mg_vd->vdev_spa;
|
|
||||||
range_tree_t *condense_tree;
|
range_tree_t *condense_tree;
|
||||||
space_map_t *sm = msp->ms_sm;
|
space_map_t *sm = msp->ms_sm;
|
||||||
|
|
||||||
ASSERT(MUTEX_HELD(&msp->ms_lock));
|
ASSERT(MUTEX_HELD(&msp->ms_lock));
|
||||||
ASSERT3U(spa_sync_pass(spa), ==, 1);
|
|
||||||
ASSERT(msp->ms_loaded);
|
ASSERT(msp->ms_loaded);
|
||||||
|
|
||||||
|
zfs_dbgmsg("condensing: txg %llu, msp[%llu] %p, vdev id %llu, "
|
||||||
spa_dbgmsg(spa, "condensing: txg %llu, msp[%llu] %p, vdev id %llu, "
|
|
||||||
"spa %s, smp size %llu, segments %lu, forcing condense=%s", txg,
|
"spa %s, smp size %llu, segments %lu, forcing condense=%s", txg,
|
||||||
msp->ms_id, msp, msp->ms_group->mg_vd->vdev_id,
|
msp->ms_id, msp, msp->ms_group->mg_vd->vdev_id,
|
||||||
msp->ms_group->mg_vd->vdev_spa->spa_name,
|
msp->ms_group->mg_vd->vdev_spa->spa_name,
|
||||||
space_map_length(msp->ms_sm), avl_numnodes(&msp->ms_tree->rt_root),
|
space_map_length(msp->ms_sm),
|
||||||
|
avl_numnodes(&msp->ms_allocatable->rt_root),
|
||||||
msp->ms_condense_wanted ? "TRUE" : "FALSE");
|
msp->ms_condense_wanted ? "TRUE" : "FALSE");
|
||||||
|
|
||||||
msp->ms_condense_wanted = B_FALSE;
|
msp->ms_condense_wanted = B_FALSE;
|
||||||
@ -2255,20 +2297,16 @@ metaslab_condense(metaslab_t *msp, uint64_t txg, dmu_tx_t *tx)
|
|||||||
condense_tree = range_tree_create(NULL, NULL);
|
condense_tree = range_tree_create(NULL, NULL);
|
||||||
range_tree_add(condense_tree, msp->ms_start, msp->ms_size);
|
range_tree_add(condense_tree, msp->ms_start, msp->ms_size);
|
||||||
|
|
||||||
/*
|
range_tree_walk(msp->ms_freeing, range_tree_remove, condense_tree);
|
||||||
* Remove what's been freed in this txg from the condense_tree.
|
range_tree_walk(msp->ms_freed, range_tree_remove, condense_tree);
|
||||||
* Since we're in sync_pass 1, we know that all the frees from
|
|
||||||
* this txg are in the freeingtree.
|
|
||||||
*/
|
|
||||||
range_tree_walk(msp->ms_freeingtree, range_tree_remove, condense_tree);
|
|
||||||
|
|
||||||
for (int t = 0; t < TXG_DEFER_SIZE; t++) {
|
for (int t = 0; t < TXG_DEFER_SIZE; t++) {
|
||||||
range_tree_walk(msp->ms_defertree[t],
|
range_tree_walk(msp->ms_defer[t],
|
||||||
range_tree_remove, condense_tree);
|
range_tree_remove, condense_tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int t = 1; t < TXG_CONCURRENT_STATES; t++) {
|
for (int t = 1; t < TXG_CONCURRENT_STATES; t++) {
|
||||||
range_tree_walk(msp->ms_alloctree[(txg + t) & TXG_MASK],
|
range_tree_walk(msp->ms_allocating[(txg + t) & TXG_MASK],
|
||||||
range_tree_remove, condense_tree);
|
range_tree_remove, condense_tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2278,13 +2316,13 @@ metaslab_condense(metaslab_t *msp, uint64_t txg, dmu_tx_t *tx)
|
|||||||
* metaslab's ms_condensing flag to ensure that
|
* metaslab's ms_condensing flag to ensure that
|
||||||
* allocations on this metaslab do not occur while we're
|
* allocations on this metaslab do not occur while we're
|
||||||
* in the middle of committing it to disk. This is only critical
|
* in the middle of committing it to disk. This is only critical
|
||||||
* for the ms_tree as all other range trees use per txg
|
* for ms_allocatable as all other range trees use per txg
|
||||||
* views of their content.
|
* views of their content.
|
||||||
*/
|
*/
|
||||||
msp->ms_condensing = B_TRUE;
|
msp->ms_condensing = B_TRUE;
|
||||||
|
|
||||||
mutex_exit(&msp->ms_lock);
|
mutex_exit(&msp->ms_lock);
|
||||||
space_map_truncate(sm, tx);
|
space_map_truncate(sm, zfs_metaslab_sm_blksz, tx);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* While we would ideally like to create a space map representation
|
* While we would ideally like to create a space map representation
|
||||||
@ -2300,7 +2338,7 @@ metaslab_condense(metaslab_t *msp, uint64_t txg, dmu_tx_t *tx)
|
|||||||
range_tree_vacate(condense_tree, NULL, NULL);
|
range_tree_vacate(condense_tree, NULL, NULL);
|
||||||
range_tree_destroy(condense_tree);
|
range_tree_destroy(condense_tree);
|
||||||
|
|
||||||
space_map_write(sm, msp->ms_tree, SM_FREE, tx);
|
space_map_write(sm, msp->ms_allocatable, SM_FREE, tx);
|
||||||
mutex_enter(&msp->ms_lock);
|
mutex_enter(&msp->ms_lock);
|
||||||
msp->ms_condensing = B_FALSE;
|
msp->ms_condensing = B_FALSE;
|
||||||
}
|
}
|
||||||
@ -2315,7 +2353,7 @@ metaslab_sync(metaslab_t *msp, uint64_t txg)
|
|||||||
vdev_t *vd = mg->mg_vd;
|
vdev_t *vd = mg->mg_vd;
|
||||||
spa_t *spa = vd->vdev_spa;
|
spa_t *spa = vd->vdev_spa;
|
||||||
objset_t *mos = spa_meta_objset(spa);
|
objset_t *mos = spa_meta_objset(spa);
|
||||||
range_tree_t *alloctree = msp->ms_alloctree[txg & TXG_MASK];
|
range_tree_t *alloctree = msp->ms_allocating[txg & TXG_MASK];
|
||||||
dmu_tx_t *tx;
|
dmu_tx_t *tx;
|
||||||
uint64_t object = space_map_object(msp->ms_sm);
|
uint64_t object = space_map_object(msp->ms_sm);
|
||||||
|
|
||||||
@ -2324,23 +2362,24 @@ metaslab_sync(metaslab_t *msp, uint64_t txg)
|
|||||||
/*
|
/*
|
||||||
* This metaslab has just been added so there's no work to do now.
|
* This metaslab has just been added so there's no work to do now.
|
||||||
*/
|
*/
|
||||||
if (msp->ms_freeingtree == NULL) {
|
if (msp->ms_freeing == NULL) {
|
||||||
ASSERT3P(alloctree, ==, NULL);
|
ASSERT3P(alloctree, ==, NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT3P(alloctree, !=, NULL);
|
ASSERT3P(alloctree, !=, NULL);
|
||||||
ASSERT3P(msp->ms_freeingtree, !=, NULL);
|
ASSERT3P(msp->ms_freeing, !=, NULL);
|
||||||
ASSERT3P(msp->ms_freedtree, !=, NULL);
|
ASSERT3P(msp->ms_freed, !=, NULL);
|
||||||
|
ASSERT3P(msp->ms_checkpointing, !=, NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Normally, we don't want to process a metaslab if there
|
* Normally, we don't want to process a metaslab if there are no
|
||||||
* are no allocations or frees to perform. However, if the metaslab
|
* allocations or frees to perform. However, if the metaslab is being
|
||||||
* is being forced to condense and it's loaded, we need to let it
|
* forced to condense and it's loaded, we need to let it through.
|
||||||
* through.
|
|
||||||
*/
|
*/
|
||||||
if (range_tree_space(alloctree) == 0 &&
|
if (range_tree_is_empty(alloctree) &&
|
||||||
range_tree_space(msp->ms_freeingtree) == 0 &&
|
range_tree_is_empty(msp->ms_freeing) &&
|
||||||
|
range_tree_is_empty(msp->ms_checkpointing) &&
|
||||||
!(msp->ms_loaded && msp->ms_condense_wanted))
|
!(msp->ms_loaded && msp->ms_condense_wanted))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -2349,10 +2388,10 @@ metaslab_sync(metaslab_t *msp, uint64_t txg)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* The only state that can actually be changing concurrently with
|
* The only state that can actually be changing concurrently with
|
||||||
* metaslab_sync() is the metaslab's ms_tree. No other thread can
|
* metaslab_sync() is the metaslab's ms_allocatable. No other
|
||||||
* be modifying this txg's alloctree, freeingtree, freedtree, or
|
* thread can be modifying this txg's alloc, freeing,
|
||||||
* space_map_phys_t. We drop ms_lock whenever we could call
|
* freed, or space_map_phys_t. We drop ms_lock whenever we
|
||||||
* into the DMU, because the DMU can call down to us
|
* could call into the DMU, because the DMU can call down to us
|
||||||
* (e.g. via zio_free()) at any time.
|
* (e.g. via zio_free()) at any time.
|
||||||
*
|
*
|
||||||
* The spa_vdev_remove_thread() can be reading metaslab state
|
* The spa_vdev_remove_thread() can be reading metaslab state
|
||||||
@ -2360,13 +2399,12 @@ metaslab_sync(metaslab_t *msp, uint64_t txg)
|
|||||||
* that the ms_lock is insufficient for this, because it is dropped
|
* that the ms_lock is insufficient for this, because it is dropped
|
||||||
* by space_map_write().
|
* by space_map_write().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
tx = dmu_tx_create_assigned(spa_get_dsl(spa), txg);
|
tx = dmu_tx_create_assigned(spa_get_dsl(spa), txg);
|
||||||
|
|
||||||
if (msp->ms_sm == NULL) {
|
if (msp->ms_sm == NULL) {
|
||||||
uint64_t new_object;
|
uint64_t new_object;
|
||||||
|
|
||||||
new_object = space_map_alloc(mos, tx);
|
new_object = space_map_alloc(mos, zfs_metaslab_sm_blksz, tx);
|
||||||
VERIFY3U(new_object, !=, 0);
|
VERIFY3U(new_object, !=, 0);
|
||||||
|
|
||||||
VERIFY0(space_map_open(&msp->ms_sm, mos, new_object,
|
VERIFY0(space_map_open(&msp->ms_sm, mos, new_object,
|
||||||
@ -2374,6 +2412,28 @@ metaslab_sync(metaslab_t *msp, uint64_t txg)
|
|||||||
ASSERT(msp->ms_sm != NULL);
|
ASSERT(msp->ms_sm != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!range_tree_is_empty(msp->ms_checkpointing) &&
|
||||||
|
vd->vdev_checkpoint_sm == NULL) {
|
||||||
|
ASSERT(spa_has_checkpoint(spa));
|
||||||
|
|
||||||
|
uint64_t new_object = space_map_alloc(mos,
|
||||||
|
vdev_standard_sm_blksz, tx);
|
||||||
|
VERIFY3U(new_object, !=, 0);
|
||||||
|
|
||||||
|
VERIFY0(space_map_open(&vd->vdev_checkpoint_sm,
|
||||||
|
mos, new_object, 0, vd->vdev_asize, vd->vdev_ashift));
|
||||||
|
ASSERT3P(vd->vdev_checkpoint_sm, !=, NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We save the space map object as an entry in vdev_top_zap
|
||||||
|
* so it can be retrieved when the pool is reopened after an
|
||||||
|
* export or through zdb.
|
||||||
|
*/
|
||||||
|
VERIFY0(zap_add(vd->vdev_spa->spa_meta_objset,
|
||||||
|
vd->vdev_top_zap, VDEV_TOP_ZAP_POOL_CHECKPOINT_SM,
|
||||||
|
sizeof (new_object), 1, &new_object, tx));
|
||||||
|
}
|
||||||
|
|
||||||
mutex_enter(&msp->ms_sync_lock);
|
mutex_enter(&msp->ms_sync_lock);
|
||||||
mutex_enter(&msp->ms_lock);
|
mutex_enter(&msp->ms_lock);
|
||||||
|
|
||||||
@ -2386,16 +2446,40 @@ metaslab_sync(metaslab_t *msp, uint64_t txg)
|
|||||||
metaslab_class_histogram_verify(mg->mg_class);
|
metaslab_class_histogram_verify(mg->mg_class);
|
||||||
metaslab_group_histogram_remove(mg, msp);
|
metaslab_group_histogram_remove(mg, msp);
|
||||||
|
|
||||||
if (msp->ms_loaded && spa_sync_pass(spa) == 1 &&
|
if (msp->ms_loaded && metaslab_should_condense(msp)) {
|
||||||
metaslab_should_condense(msp)) {
|
|
||||||
metaslab_condense(msp, txg, tx);
|
metaslab_condense(msp, txg, tx);
|
||||||
} else {
|
} else {
|
||||||
mutex_exit(&msp->ms_lock);
|
mutex_exit(&msp->ms_lock);
|
||||||
space_map_write(msp->ms_sm, alloctree, SM_ALLOC, tx);
|
space_map_write(msp->ms_sm, alloctree, SM_ALLOC, tx);
|
||||||
space_map_write(msp->ms_sm, msp->ms_freeingtree, SM_FREE, tx);
|
space_map_write(msp->ms_sm, msp->ms_freeing, SM_FREE, tx);
|
||||||
mutex_enter(&msp->ms_lock);
|
mutex_enter(&msp->ms_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!range_tree_is_empty(msp->ms_checkpointing)) {
|
||||||
|
ASSERT(spa_has_checkpoint(spa));
|
||||||
|
ASSERT3P(vd->vdev_checkpoint_sm, !=, NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Since we are doing writes to disk and the ms_checkpointing
|
||||||
|
* tree won't be changing during that time, we drop the
|
||||||
|
* ms_lock while writing to the checkpoint space map.
|
||||||
|
*/
|
||||||
|
mutex_exit(&msp->ms_lock);
|
||||||
|
space_map_write(vd->vdev_checkpoint_sm,
|
||||||
|
msp->ms_checkpointing, SM_FREE, tx);
|
||||||
|
mutex_enter(&msp->ms_lock);
|
||||||
|
space_map_update(vd->vdev_checkpoint_sm);
|
||||||
|
|
||||||
|
spa->spa_checkpoint_info.sci_dspace +=
|
||||||
|
range_tree_space(msp->ms_checkpointing);
|
||||||
|
vd->vdev_stat.vs_checkpoint_space +=
|
||||||
|
range_tree_space(msp->ms_checkpointing);
|
||||||
|
ASSERT3U(vd->vdev_stat.vs_checkpoint_space, ==,
|
||||||
|
-vd->vdev_checkpoint_sm->sm_alloc);
|
||||||
|
|
||||||
|
range_tree_vacate(msp->ms_checkpointing, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
if (msp->ms_loaded) {
|
if (msp->ms_loaded) {
|
||||||
/*
|
/*
|
||||||
* When the space map is loaded, we have an accurate
|
* When the space map is loaded, we have an accurate
|
||||||
@ -2404,7 +2488,7 @@ metaslab_sync(metaslab_t *msp, uint64_t txg)
|
|||||||
* it first before updating it.
|
* it first before updating it.
|
||||||
*/
|
*/
|
||||||
space_map_histogram_clear(msp->ms_sm);
|
space_map_histogram_clear(msp->ms_sm);
|
||||||
space_map_histogram_add(msp->ms_sm, msp->ms_tree, tx);
|
space_map_histogram_add(msp->ms_sm, msp->ms_allocatable, tx);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Since we've cleared the histogram we need to add back
|
* Since we've cleared the histogram we need to add back
|
||||||
@ -2413,7 +2497,7 @@ metaslab_sync(metaslab_t *msp, uint64_t txg)
|
|||||||
* to accurately reflect all free space even if some space
|
* to accurately reflect all free space even if some space
|
||||||
* is not yet available for allocation (i.e. deferred).
|
* is not yet available for allocation (i.e. deferred).
|
||||||
*/
|
*/
|
||||||
space_map_histogram_add(msp->ms_sm, msp->ms_freedtree, tx);
|
space_map_histogram_add(msp->ms_sm, msp->ms_freed, tx);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add back any deferred free space that has not been
|
* Add back any deferred free space that has not been
|
||||||
@ -2424,7 +2508,7 @@ metaslab_sync(metaslab_t *msp, uint64_t txg)
|
|||||||
*/
|
*/
|
||||||
for (int t = 0; t < TXG_DEFER_SIZE; t++) {
|
for (int t = 0; t < TXG_DEFER_SIZE; t++) {
|
||||||
space_map_histogram_add(msp->ms_sm,
|
space_map_histogram_add(msp->ms_sm,
|
||||||
msp->ms_defertree[t], tx);
|
msp->ms_defer[t], tx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2435,7 +2519,7 @@ metaslab_sync(metaslab_t *msp, uint64_t txg)
|
|||||||
* then we will lose some accuracy but will correct it the next
|
* then we will lose some accuracy but will correct it the next
|
||||||
* time we load the space map.
|
* time we load the space map.
|
||||||
*/
|
*/
|
||||||
space_map_histogram_add(msp->ms_sm, msp->ms_freeingtree, tx);
|
space_map_histogram_add(msp->ms_sm, msp->ms_freeing, tx);
|
||||||
|
|
||||||
metaslab_group_histogram_add(mg, msp);
|
metaslab_group_histogram_add(mg, msp);
|
||||||
metaslab_group_histogram_verify(mg);
|
metaslab_group_histogram_verify(mg);
|
||||||
@ -2443,21 +2527,23 @@ metaslab_sync(metaslab_t *msp, uint64_t txg)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* For sync pass 1, we avoid traversing this txg's free range tree
|
* For sync pass 1, we avoid traversing this txg's free range tree
|
||||||
* and instead will just swap the pointers for freeingtree and
|
* and instead will just swap the pointers for freeing and
|
||||||
* freedtree. We can safely do this since the freed_tree is
|
* freed. We can safely do this since the freed_tree is
|
||||||
* guaranteed to be empty on the initial pass.
|
* guaranteed to be empty on the initial pass.
|
||||||
*/
|
*/
|
||||||
if (spa_sync_pass(spa) == 1) {
|
if (spa_sync_pass(spa) == 1) {
|
||||||
range_tree_swap(&msp->ms_freeingtree, &msp->ms_freedtree);
|
range_tree_swap(&msp->ms_freeing, &msp->ms_freed);
|
||||||
} else {
|
} else {
|
||||||
range_tree_vacate(msp->ms_freeingtree,
|
range_tree_vacate(msp->ms_freeing,
|
||||||
range_tree_add, msp->ms_freedtree);
|
range_tree_add, msp->ms_freed);
|
||||||
}
|
}
|
||||||
range_tree_vacate(alloctree, NULL, NULL);
|
range_tree_vacate(alloctree, NULL, NULL);
|
||||||
|
|
||||||
ASSERT0(range_tree_space(msp->ms_alloctree[txg & TXG_MASK]));
|
ASSERT0(range_tree_space(msp->ms_allocating[txg & TXG_MASK]));
|
||||||
ASSERT0(range_tree_space(msp->ms_alloctree[TXG_CLEAN(txg) & TXG_MASK]));
|
ASSERT0(range_tree_space(msp->ms_allocating[TXG_CLEAN(txg)
|
||||||
ASSERT0(range_tree_space(msp->ms_freeingtree));
|
& TXG_MASK]));
|
||||||
|
ASSERT0(range_tree_space(msp->ms_freeing));
|
||||||
|
ASSERT0(range_tree_space(msp->ms_checkpointing));
|
||||||
|
|
||||||
mutex_exit(&msp->ms_lock);
|
mutex_exit(&msp->ms_lock);
|
||||||
|
|
||||||
@ -2492,29 +2578,34 @@ metaslab_sync_done(metaslab_t *msp, uint64_t txg)
|
|||||||
* If this metaslab is just becoming available, initialize its
|
* If this metaslab is just becoming available, initialize its
|
||||||
* range trees and add its capacity to the vdev.
|
* range trees and add its capacity to the vdev.
|
||||||
*/
|
*/
|
||||||
if (msp->ms_freedtree == NULL) {
|
if (msp->ms_freed == NULL) {
|
||||||
for (int t = 0; t < TXG_SIZE; t++) {
|
for (int t = 0; t < TXG_SIZE; t++) {
|
||||||
ASSERT(msp->ms_alloctree[t] == NULL);
|
ASSERT(msp->ms_allocating[t] == NULL);
|
||||||
|
|
||||||
msp->ms_alloctree[t] = range_tree_create(NULL, NULL);
|
msp->ms_allocating[t] = range_tree_create(NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT3P(msp->ms_freeingtree, ==, NULL);
|
ASSERT3P(msp->ms_freeing, ==, NULL);
|
||||||
msp->ms_freeingtree = range_tree_create(NULL, NULL);
|
msp->ms_freeing = range_tree_create(NULL, NULL);
|
||||||
|
|
||||||
ASSERT3P(msp->ms_freedtree, ==, NULL);
|
ASSERT3P(msp->ms_freed, ==, NULL);
|
||||||
msp->ms_freedtree = range_tree_create(NULL, NULL);
|
msp->ms_freed = range_tree_create(NULL, NULL);
|
||||||
|
|
||||||
for (int t = 0; t < TXG_DEFER_SIZE; t++) {
|
for (int t = 0; t < TXG_DEFER_SIZE; t++) {
|
||||||
ASSERT(msp->ms_defertree[t] == NULL);
|
ASSERT(msp->ms_defer[t] == NULL);
|
||||||
|
|
||||||
msp->ms_defertree[t] = range_tree_create(NULL, NULL);
|
msp->ms_defer[t] = range_tree_create(NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ASSERT3P(msp->ms_checkpointing, ==, NULL);
|
||||||
|
msp->ms_checkpointing = range_tree_create(NULL, NULL);
|
||||||
|
|
||||||
vdev_space_update(vd, 0, 0, msp->ms_size);
|
vdev_space_update(vd, 0, 0, msp->ms_size);
|
||||||
}
|
}
|
||||||
|
ASSERT0(range_tree_space(msp->ms_freeing));
|
||||||
|
ASSERT0(range_tree_space(msp->ms_checkpointing));
|
||||||
|
|
||||||
defer_tree = &msp->ms_defertree[txg % TXG_DEFER_SIZE];
|
defer_tree = &msp->ms_defer[txg % TXG_DEFER_SIZE];
|
||||||
|
|
||||||
uint64_t free_space = metaslab_class_get_space(spa_normal_class(spa)) -
|
uint64_t free_space = metaslab_class_get_space(spa_normal_class(spa)) -
|
||||||
metaslab_class_get_alloc(spa_normal_class(spa));
|
metaslab_class_get_alloc(spa_normal_class(spa));
|
||||||
@ -2525,7 +2616,7 @@ metaslab_sync_done(metaslab_t *msp, uint64_t txg)
|
|||||||
defer_delta = 0;
|
defer_delta = 0;
|
||||||
alloc_delta = space_map_alloc_delta(msp->ms_sm);
|
alloc_delta = space_map_alloc_delta(msp->ms_sm);
|
||||||
if (defer_allowed) {
|
if (defer_allowed) {
|
||||||
defer_delta = range_tree_space(msp->ms_freedtree) -
|
defer_delta = range_tree_space(msp->ms_freed) -
|
||||||
range_tree_space(*defer_tree);
|
range_tree_space(*defer_tree);
|
||||||
} else {
|
} else {
|
||||||
defer_delta -= range_tree_space(*defer_tree);
|
defer_delta -= range_tree_space(*defer_tree);
|
||||||
@ -2541,19 +2632,19 @@ metaslab_sync_done(metaslab_t *msp, uint64_t txg)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Move the frees from the defer_tree back to the free
|
* Move the frees from the defer_tree back to the free
|
||||||
* range tree (if it's loaded). Swap the freed_tree and the
|
* range tree (if it's loaded). Swap the freed_tree and
|
||||||
* defer_tree -- this is safe to do because we've just emptied out
|
* the defer_tree -- this is safe to do because we've
|
||||||
* the defer_tree.
|
* just emptied out the defer_tree.
|
||||||
*/
|
*/
|
||||||
range_tree_vacate(*defer_tree,
|
range_tree_vacate(*defer_tree,
|
||||||
msp->ms_loaded ? range_tree_add : NULL, msp->ms_tree);
|
msp->ms_loaded ? range_tree_add : NULL, msp->ms_allocatable);
|
||||||
if (defer_allowed) {
|
if (defer_allowed) {
|
||||||
range_tree_swap(&msp->ms_freedtree, defer_tree);
|
range_tree_swap(&msp->ms_freed, defer_tree);
|
||||||
} else {
|
} else {
|
||||||
range_tree_vacate(msp->ms_freedtree,
|
range_tree_vacate(msp->ms_freed,
|
||||||
msp->ms_loaded ? range_tree_add : NULL, msp->ms_tree);
|
msp->ms_loaded ? range_tree_add : NULL,
|
||||||
|
msp->ms_allocatable);
|
||||||
}
|
}
|
||||||
|
|
||||||
space_map_update(msp->ms_sm);
|
space_map_update(msp->ms_sm);
|
||||||
|
|
||||||
msp->ms_deferspace += defer_delta;
|
msp->ms_deferspace += defer_delta;
|
||||||
@ -2581,16 +2672,17 @@ metaslab_sync_done(metaslab_t *msp, uint64_t txg)
|
|||||||
msp->ms_selected_txg + metaslab_unload_delay < txg) {
|
msp->ms_selected_txg + metaslab_unload_delay < txg) {
|
||||||
for (int t = 1; t < TXG_CONCURRENT_STATES; t++) {
|
for (int t = 1; t < TXG_CONCURRENT_STATES; t++) {
|
||||||
VERIFY0(range_tree_space(
|
VERIFY0(range_tree_space(
|
||||||
msp->ms_alloctree[(txg + t) & TXG_MASK]));
|
msp->ms_allocating[(txg + t) & TXG_MASK]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!metaslab_debug_unload)
|
if (!metaslab_debug_unload)
|
||||||
metaslab_unload(msp);
|
metaslab_unload(msp);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT0(range_tree_space(msp->ms_alloctree[txg & TXG_MASK]));
|
ASSERT0(range_tree_space(msp->ms_allocating[txg & TXG_MASK]));
|
||||||
ASSERT0(range_tree_space(msp->ms_freeingtree));
|
ASSERT0(range_tree_space(msp->ms_freeing));
|
||||||
ASSERT0(range_tree_space(msp->ms_freedtree));
|
ASSERT0(range_tree_space(msp->ms_freed));
|
||||||
|
ASSERT0(range_tree_space(msp->ms_checkpointing));
|
||||||
|
|
||||||
mutex_exit(&msp->ms_lock);
|
mutex_exit(&msp->ms_lock);
|
||||||
}
|
}
|
||||||
@ -2794,7 +2886,7 @@ static uint64_t
|
|||||||
metaslab_block_alloc(metaslab_t *msp, uint64_t size, uint64_t txg)
|
metaslab_block_alloc(metaslab_t *msp, uint64_t size, uint64_t txg)
|
||||||
{
|
{
|
||||||
uint64_t start;
|
uint64_t start;
|
||||||
range_tree_t *rt = msp->ms_tree;
|
range_tree_t *rt = msp->ms_allocatable;
|
||||||
metaslab_class_t *mc = msp->ms_group->mg_class;
|
metaslab_class_t *mc = msp->ms_group->mg_class;
|
||||||
|
|
||||||
VERIFY(!msp->ms_condensing);
|
VERIFY(!msp->ms_condensing);
|
||||||
@ -2809,10 +2901,10 @@ metaslab_block_alloc(metaslab_t *msp, uint64_t size, uint64_t txg)
|
|||||||
VERIFY3U(range_tree_space(rt) - size, <=, msp->ms_size);
|
VERIFY3U(range_tree_space(rt) - size, <=, msp->ms_size);
|
||||||
range_tree_remove(rt, start, size);
|
range_tree_remove(rt, start, size);
|
||||||
|
|
||||||
if (range_tree_space(msp->ms_alloctree[txg & TXG_MASK]) == 0)
|
if (range_tree_is_empty(msp->ms_allocating[txg & TXG_MASK]))
|
||||||
vdev_dirty(mg->mg_vd, VDD_METASLAB, msp, txg);
|
vdev_dirty(mg->mg_vd, VDD_METASLAB, msp, txg);
|
||||||
|
|
||||||
range_tree_add(msp->ms_alloctree[txg & TXG_MASK], start, size);
|
range_tree_add(msp->ms_allocating[txg & TXG_MASK], start, size);
|
||||||
|
|
||||||
/* Track the last successful allocation */
|
/* Track the last successful allocation */
|
||||||
msp->ms_alloc_txg = txg;
|
msp->ms_alloc_txg = txg;
|
||||||
@ -3280,12 +3372,11 @@ metaslab_alloc_dva(spa_t *spa, metaslab_class_t *mc, uint64_t psize,
|
|||||||
|
|
||||||
void
|
void
|
||||||
metaslab_free_concrete(vdev_t *vd, uint64_t offset, uint64_t asize,
|
metaslab_free_concrete(vdev_t *vd, uint64_t offset, uint64_t asize,
|
||||||
uint64_t txg)
|
boolean_t checkpoint)
|
||||||
{
|
{
|
||||||
metaslab_t *msp;
|
metaslab_t *msp;
|
||||||
spa_t *spa = vd->vdev_spa;
|
spa_t *spa = vd->vdev_spa;
|
||||||
|
|
||||||
ASSERT3U(txg, ==, spa->spa_syncing_txg);
|
|
||||||
ASSERT(vdev_is_concrete(vd));
|
ASSERT(vdev_is_concrete(vd));
|
||||||
ASSERT3U(spa_config_held(spa, SCL_ALL, RW_READER), !=, 0);
|
ASSERT3U(spa_config_held(spa, SCL_ALL, RW_READER), !=, 0);
|
||||||
ASSERT3U(offset >> vd->vdev_ms_shift, <, vd->vdev_ms_count);
|
ASSERT3U(offset >> vd->vdev_ms_shift, <, vd->vdev_ms_count);
|
||||||
@ -3299,11 +3390,19 @@ metaslab_free_concrete(vdev_t *vd, uint64_t offset, uint64_t asize,
|
|||||||
VERIFY0(P2PHASE(asize, 1ULL << vd->vdev_ashift));
|
VERIFY0(P2PHASE(asize, 1ULL << vd->vdev_ashift));
|
||||||
|
|
||||||
metaslab_check_free_impl(vd, offset, asize);
|
metaslab_check_free_impl(vd, offset, asize);
|
||||||
|
|
||||||
mutex_enter(&msp->ms_lock);
|
mutex_enter(&msp->ms_lock);
|
||||||
if (range_tree_space(msp->ms_freeingtree) == 0) {
|
if (range_tree_is_empty(msp->ms_freeing) &&
|
||||||
vdev_dirty(vd, VDD_METASLAB, msp, txg);
|
range_tree_is_empty(msp->ms_checkpointing)) {
|
||||||
|
vdev_dirty(vd, VDD_METASLAB, msp, spa_syncing_txg(spa));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checkpoint) {
|
||||||
|
ASSERT(spa_has_checkpoint(spa));
|
||||||
|
range_tree_add(msp->ms_checkpointing, offset, asize);
|
||||||
|
} else {
|
||||||
|
range_tree_add(msp->ms_freeing, offset, asize);
|
||||||
}
|
}
|
||||||
range_tree_add(msp->ms_freeingtree, offset, asize);
|
|
||||||
mutex_exit(&msp->ms_lock);
|
mutex_exit(&msp->ms_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3312,23 +3411,25 @@ void
|
|||||||
metaslab_free_impl_cb(uint64_t inner_offset, vdev_t *vd, uint64_t offset,
|
metaslab_free_impl_cb(uint64_t inner_offset, vdev_t *vd, uint64_t offset,
|
||||||
uint64_t size, void *arg)
|
uint64_t size, void *arg)
|
||||||
{
|
{
|
||||||
uint64_t *txgp = arg;
|
boolean_t *checkpoint = arg;
|
||||||
|
|
||||||
|
ASSERT3P(checkpoint, !=, NULL);
|
||||||
|
|
||||||
if (vd->vdev_ops->vdev_op_remap != NULL)
|
if (vd->vdev_ops->vdev_op_remap != NULL)
|
||||||
vdev_indirect_mark_obsolete(vd, offset, size, *txgp);
|
vdev_indirect_mark_obsolete(vd, offset, size);
|
||||||
else
|
else
|
||||||
metaslab_free_impl(vd, offset, size, *txgp);
|
metaslab_free_impl(vd, offset, size, *checkpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
metaslab_free_impl(vdev_t *vd, uint64_t offset, uint64_t size,
|
metaslab_free_impl(vdev_t *vd, uint64_t offset, uint64_t size,
|
||||||
uint64_t txg)
|
boolean_t checkpoint)
|
||||||
{
|
{
|
||||||
spa_t *spa = vd->vdev_spa;
|
spa_t *spa = vd->vdev_spa;
|
||||||
|
|
||||||
ASSERT3U(spa_config_held(spa, SCL_ALL, RW_READER), !=, 0);
|
ASSERT3U(spa_config_held(spa, SCL_ALL, RW_READER), !=, 0);
|
||||||
|
|
||||||
if (txg > spa_freeze_txg(spa))
|
if (spa_syncing_txg(spa) > spa_freeze_txg(spa))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (spa->spa_vdev_removal != NULL &&
|
if (spa->spa_vdev_removal != NULL &&
|
||||||
@ -3340,13 +3441,13 @@ metaslab_free_impl(vdev_t *vd, uint64_t offset, uint64_t size,
|
|||||||
* an indirect vdev (in open context), and then (in syncing
|
* an indirect vdev (in open context), and then (in syncing
|
||||||
* context) clear spa_vdev_removal.
|
* context) clear spa_vdev_removal.
|
||||||
*/
|
*/
|
||||||
free_from_removing_vdev(vd, offset, size, txg);
|
free_from_removing_vdev(vd, offset, size);
|
||||||
} else if (vd->vdev_ops->vdev_op_remap != NULL) {
|
} else if (vd->vdev_ops->vdev_op_remap != NULL) {
|
||||||
vdev_indirect_mark_obsolete(vd, offset, size, txg);
|
vdev_indirect_mark_obsolete(vd, offset, size);
|
||||||
vd->vdev_ops->vdev_op_remap(vd, offset, size,
|
vd->vdev_ops->vdev_op_remap(vd, offset, size,
|
||||||
metaslab_free_impl_cb, &txg);
|
metaslab_free_impl_cb, &checkpoint);
|
||||||
} else {
|
} else {
|
||||||
metaslab_free_concrete(vd, offset, size, txg);
|
metaslab_free_concrete(vd, offset, size, checkpoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3523,26 +3624,25 @@ metaslab_unalloc_dva(spa_t *spa, const dva_t *dva, uint64_t txg)
|
|||||||
msp = vd->vdev_ms[offset >> vd->vdev_ms_shift];
|
msp = vd->vdev_ms[offset >> vd->vdev_ms_shift];
|
||||||
|
|
||||||
mutex_enter(&msp->ms_lock);
|
mutex_enter(&msp->ms_lock);
|
||||||
range_tree_remove(msp->ms_alloctree[txg & TXG_MASK],
|
range_tree_remove(msp->ms_allocating[txg & TXG_MASK],
|
||||||
offset, size);
|
offset, size);
|
||||||
|
|
||||||
VERIFY(!msp->ms_condensing);
|
VERIFY(!msp->ms_condensing);
|
||||||
VERIFY3U(offset, >=, msp->ms_start);
|
VERIFY3U(offset, >=, msp->ms_start);
|
||||||
VERIFY3U(offset + size, <=, msp->ms_start + msp->ms_size);
|
VERIFY3U(offset + size, <=, msp->ms_start + msp->ms_size);
|
||||||
VERIFY3U(range_tree_space(msp->ms_tree) + size, <=,
|
VERIFY3U(range_tree_space(msp->ms_allocatable) + size, <=,
|
||||||
msp->ms_size);
|
msp->ms_size);
|
||||||
VERIFY0(P2PHASE(offset, 1ULL << vd->vdev_ashift));
|
VERIFY0(P2PHASE(offset, 1ULL << vd->vdev_ashift));
|
||||||
VERIFY0(P2PHASE(size, 1ULL << vd->vdev_ashift));
|
VERIFY0(P2PHASE(size, 1ULL << vd->vdev_ashift));
|
||||||
range_tree_add(msp->ms_tree, offset, size);
|
range_tree_add(msp->ms_allocatable, offset, size);
|
||||||
mutex_exit(&msp->ms_lock);
|
mutex_exit(&msp->ms_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Free the block represented by DVA in the context of the specified
|
* Free the block represented by the given DVA.
|
||||||
* transaction group.
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
metaslab_free_dva(spa_t *spa, const dva_t *dva, uint64_t txg)
|
metaslab_free_dva(spa_t *spa, const dva_t *dva, boolean_t checkpoint)
|
||||||
{
|
{
|
||||||
uint64_t vdev = DVA_GET_VDEV(dva);
|
uint64_t vdev = DVA_GET_VDEV(dva);
|
||||||
uint64_t offset = DVA_GET_OFFSET(dva);
|
uint64_t offset = DVA_GET_OFFSET(dva);
|
||||||
@ -3556,7 +3656,7 @@ metaslab_free_dva(spa_t *spa, const dva_t *dva, uint64_t txg)
|
|||||||
size = vdev_psize_to_asize(vd, SPA_GANGBLOCKSIZE);
|
size = vdev_psize_to_asize(vd, SPA_GANGBLOCKSIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
metaslab_free_impl(vd, offset, size, txg);
|
metaslab_free_impl(vd, offset, size, checkpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -3626,7 +3726,8 @@ metaslab_claim_concrete(vdev_t *vd, uint64_t offset, uint64_t size,
|
|||||||
if ((txg != 0 && spa_writeable(spa)) || !msp->ms_loaded)
|
if ((txg != 0 && spa_writeable(spa)) || !msp->ms_loaded)
|
||||||
error = metaslab_activate(msp, METASLAB_WEIGHT_SECONDARY);
|
error = metaslab_activate(msp, METASLAB_WEIGHT_SECONDARY);
|
||||||
|
|
||||||
if (error == 0 && !range_tree_contains(msp->ms_tree, offset, size))
|
if (error == 0 &&
|
||||||
|
!range_tree_contains(msp->ms_allocatable, offset, size))
|
||||||
error = SET_ERROR(ENOENT);
|
error = SET_ERROR(ENOENT);
|
||||||
|
|
||||||
if (error || txg == 0) { /* txg == 0 indicates dry run */
|
if (error || txg == 0) { /* txg == 0 indicates dry run */
|
||||||
@ -3637,13 +3738,15 @@ metaslab_claim_concrete(vdev_t *vd, uint64_t offset, uint64_t size,
|
|||||||
VERIFY(!msp->ms_condensing);
|
VERIFY(!msp->ms_condensing);
|
||||||
VERIFY0(P2PHASE(offset, 1ULL << vd->vdev_ashift));
|
VERIFY0(P2PHASE(offset, 1ULL << vd->vdev_ashift));
|
||||||
VERIFY0(P2PHASE(size, 1ULL << vd->vdev_ashift));
|
VERIFY0(P2PHASE(size, 1ULL << vd->vdev_ashift));
|
||||||
VERIFY3U(range_tree_space(msp->ms_tree) - size, <=, msp->ms_size);
|
VERIFY3U(range_tree_space(msp->ms_allocatable) - size, <=,
|
||||||
range_tree_remove(msp->ms_tree, offset, size);
|
msp->ms_size);
|
||||||
|
range_tree_remove(msp->ms_allocatable, offset, size);
|
||||||
|
|
||||||
if (spa_writeable(spa)) { /* don't dirty if we're zdb(1M) */
|
if (spa_writeable(spa)) { /* don't dirty if we're zdb(1M) */
|
||||||
if (range_tree_space(msp->ms_alloctree[txg & TXG_MASK]) == 0)
|
if (range_tree_is_empty(msp->ms_allocating[txg & TXG_MASK]))
|
||||||
vdev_dirty(vd, VDD_METASLAB, msp, txg);
|
vdev_dirty(vd, VDD_METASLAB, msp, txg);
|
||||||
range_tree_add(msp->ms_alloctree[txg & TXG_MASK], offset, size);
|
range_tree_add(msp->ms_allocating[txg & TXG_MASK],
|
||||||
|
offset, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_exit(&msp->ms_lock);
|
mutex_exit(&msp->ms_lock);
|
||||||
@ -3788,13 +3891,41 @@ metaslab_free(spa_t *spa, const blkptr_t *bp, uint64_t txg, boolean_t now)
|
|||||||
ASSERT(!BP_IS_HOLE(bp));
|
ASSERT(!BP_IS_HOLE(bp));
|
||||||
ASSERT(!now || bp->blk_birth >= spa_syncing_txg(spa));
|
ASSERT(!now || bp->blk_birth >= spa_syncing_txg(spa));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we have a checkpoint for the pool we need to make sure that
|
||||||
|
* the blocks that we free that are part of the checkpoint won't be
|
||||||
|
* reused until the checkpoint is discarded or we revert to it.
|
||||||
|
*
|
||||||
|
* The checkpoint flag is passed down the metaslab_free code path
|
||||||
|
* and is set whenever we want to add a block to the checkpoint's
|
||||||
|
* accounting. That is, we "checkpoint" blocks that existed at the
|
||||||
|
* time the checkpoint was created and are therefore referenced by
|
||||||
|
* the checkpointed uberblock.
|
||||||
|
*
|
||||||
|
* Note that, we don't checkpoint any blocks if the current
|
||||||
|
* syncing txg <= spa_checkpoint_txg. We want these frees to sync
|
||||||
|
* normally as they will be referenced by the checkpointed uberblock.
|
||||||
|
*/
|
||||||
|
boolean_t checkpoint = B_FALSE;
|
||||||
|
if (bp->blk_birth <= spa->spa_checkpoint_txg &&
|
||||||
|
spa_syncing_txg(spa) > spa->spa_checkpoint_txg) {
|
||||||
|
/*
|
||||||
|
* At this point, if the block is part of the checkpoint
|
||||||
|
* there is no way it was created in the current txg.
|
||||||
|
*/
|
||||||
|
ASSERT(!now);
|
||||||
|
ASSERT3U(spa_syncing_txg(spa), ==, txg);
|
||||||
|
checkpoint = B_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
spa_config_enter(spa, SCL_FREE, FTAG, RW_READER);
|
spa_config_enter(spa, SCL_FREE, FTAG, RW_READER);
|
||||||
|
|
||||||
for (int d = 0; d < ndvas; d++) {
|
for (int d = 0; d < ndvas; d++) {
|
||||||
if (now) {
|
if (now) {
|
||||||
metaslab_unalloc_dva(spa, &dva[d], txg);
|
metaslab_unalloc_dva(spa, &dva[d], txg);
|
||||||
} else {
|
} else {
|
||||||
metaslab_free_dva(spa, &dva[d], txg);
|
ASSERT3U(txg, ==, spa_syncing_txg(spa));
|
||||||
|
metaslab_free_dva(spa, &dva[d], checkpoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3866,12 +3997,13 @@ metaslab_check_free_impl(vdev_t *vd, uint64_t offset, uint64_t size)
|
|||||||
|
|
||||||
mutex_enter(&msp->ms_lock);
|
mutex_enter(&msp->ms_lock);
|
||||||
if (msp->ms_loaded)
|
if (msp->ms_loaded)
|
||||||
range_tree_verify(msp->ms_tree, offset, size);
|
range_tree_verify(msp->ms_allocatable, offset, size);
|
||||||
|
|
||||||
range_tree_verify(msp->ms_freeingtree, offset, size);
|
range_tree_verify(msp->ms_freeing, offset, size);
|
||||||
range_tree_verify(msp->ms_freedtree, offset, size);
|
range_tree_verify(msp->ms_checkpointing, offset, size);
|
||||||
|
range_tree_verify(msp->ms_freed, offset, size);
|
||||||
for (int j = 0; j < TXG_DEFER_SIZE; j++)
|
for (int j = 0; j < TXG_DEFER_SIZE; j++)
|
||||||
range_tree_verify(msp->ms_defertree[j], offset, size);
|
range_tree_verify(msp->ms_defer[j], offset, size);
|
||||||
mutex_exit(&msp->ms_lock);
|
mutex_exit(&msp->ms_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
* Use is subject to license terms.
|
* Use is subject to license terms.
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, 2015 by Delphix. All rights reserved.
|
* Copyright (c) 2013, 2017 by Delphix. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/zfs_context.h>
|
#include <sys/zfs_context.h>
|
||||||
@ -391,7 +391,6 @@ range_tree_walk(range_tree_t *rt, range_tree_func_t *func, void *arg)
|
|||||||
{
|
{
|
||||||
range_seg_t *rs;
|
range_seg_t *rs;
|
||||||
|
|
||||||
|
|
||||||
for (rs = avl_first(&rt->rt_root); rs; rs = AVL_NEXT(&rt->rt_root, rs))
|
for (rs = avl_first(&rt->rt_root); rs; rs = AVL_NEXT(&rt->rt_root, rs))
|
||||||
func(arg, rs->rs_start, rs->rs_end - rs->rs_start);
|
func(arg, rs->rs_start, rs->rs_end - rs->rs_start);
|
||||||
}
|
}
|
||||||
@ -401,3 +400,10 @@ range_tree_space(range_tree_t *rt)
|
|||||||
{
|
{
|
||||||
return (rt->rt_space);
|
return (rt->rt_space);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean_t
|
||||||
|
range_tree_is_empty(range_tree_t *rt)
|
||||||
|
{
|
||||||
|
ASSERT(rt != NULL);
|
||||||
|
return (range_tree_space(rt) == 0);
|
||||||
|
}
|
||||||
|
@ -163,8 +163,7 @@ const zio_taskq_info_t zio_taskqs[ZIO_TYPES][ZIO_TASKQ_TYPES] = {
|
|||||||
static void spa_sync_version(void *arg, dmu_tx_t *tx);
|
static void spa_sync_version(void *arg, dmu_tx_t *tx);
|
||||||
static void spa_sync_props(void *arg, dmu_tx_t *tx);
|
static void spa_sync_props(void *arg, dmu_tx_t *tx);
|
||||||
static boolean_t spa_has_active_shared_spare(spa_t *spa);
|
static boolean_t spa_has_active_shared_spare(spa_t *spa);
|
||||||
static int spa_load_impl(spa_t *spa, spa_import_type_t type, char **ereport,
|
static int spa_load_impl(spa_t *spa, spa_import_type_t type, char **ereport);
|
||||||
boolean_t reloading);
|
|
||||||
static void spa_vdev_resilver_done(spa_t *spa);
|
static void spa_vdev_resilver_done(spa_t *spa);
|
||||||
|
|
||||||
uint_t zio_taskq_batch_pct = 75; /* 1 thread per cpu in pset */
|
uint_t zio_taskq_batch_pct = 75; /* 1 thread per cpu in pset */
|
||||||
@ -232,6 +231,7 @@ uint64_t zfs_max_missing_tvds = 0;
|
|||||||
* and we get a chance to retrieve the trusted config.
|
* and we get a chance to retrieve the trusted config.
|
||||||
*/
|
*/
|
||||||
uint64_t zfs_max_missing_tvds_cachefile = SPA_DVAS_PER_BP - 1;
|
uint64_t zfs_max_missing_tvds_cachefile = SPA_DVAS_PER_BP - 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In the case where config was assembled by scanning device paths (/dev/dsks
|
* In the case where config was assembled by scanning device paths (/dev/dsks
|
||||||
* by default) we are less tolerant since all the existing devices should have
|
* by default) we are less tolerant since all the existing devices should have
|
||||||
@ -253,6 +253,11 @@ SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, max_missing_tvds_scan, CTLFLAG_RWTUN,
|
|||||||
&zfs_max_missing_tvds_scan, 0,
|
&zfs_max_missing_tvds_scan, 0,
|
||||||
"allow importing pools with missing top-level vdevs during scan");
|
"allow importing pools with missing top-level vdevs during scan");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Debugging aid that pauses spa_sync() towards the end.
|
||||||
|
*/
|
||||||
|
boolean_t zfs_pause_spa_sync = B_FALSE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ==========================================================================
|
* ==========================================================================
|
||||||
* SPA properties routines
|
* SPA properties routines
|
||||||
@ -304,6 +309,8 @@ spa_prop_get_config(spa_t *spa, nvlist_t **nvp)
|
|||||||
spa_prop_add_list(*nvp, ZPOOL_PROP_ALLOCATED, NULL, alloc, src);
|
spa_prop_add_list(*nvp, ZPOOL_PROP_ALLOCATED, NULL, alloc, src);
|
||||||
spa_prop_add_list(*nvp, ZPOOL_PROP_FREE, NULL,
|
spa_prop_add_list(*nvp, ZPOOL_PROP_FREE, NULL,
|
||||||
size - alloc, src);
|
size - alloc, src);
|
||||||
|
spa_prop_add_list(*nvp, ZPOOL_PROP_CHECKPOINT, NULL,
|
||||||
|
spa->spa_checkpoint_info.sci_dspace, src);
|
||||||
|
|
||||||
spa_prop_add_list(*nvp, ZPOOL_PROP_FRAGMENTATION, NULL,
|
spa_prop_add_list(*nvp, ZPOOL_PROP_FRAGMENTATION, NULL,
|
||||||
metaslab_class_fragmentation(mc), src);
|
metaslab_class_fragmentation(mc), src);
|
||||||
@ -815,6 +822,12 @@ spa_change_guid_check(void *arg, dmu_tx_t *tx)
|
|||||||
vdev_t *rvd = spa->spa_root_vdev;
|
vdev_t *rvd = spa->spa_root_vdev;
|
||||||
uint64_t vdev_state;
|
uint64_t vdev_state;
|
||||||
|
|
||||||
|
if (spa_feature_is_active(spa, SPA_FEATURE_POOL_CHECKPOINT)) {
|
||||||
|
int error = (spa_has_checkpoint(spa)) ?
|
||||||
|
ZFS_ERR_CHECKPOINT_EXISTS : ZFS_ERR_DISCARDING_CHECKPOINT;
|
||||||
|
return (SET_ERROR(error));
|
||||||
|
}
|
||||||
|
|
||||||
spa_config_enter(spa, SCL_STATE, FTAG, RW_READER);
|
spa_config_enter(spa, SCL_STATE, FTAG, RW_READER);
|
||||||
vdev_state = rvd->vdev_state;
|
vdev_state = rvd->vdev_state;
|
||||||
spa_config_exit(spa, SCL_STATE, FTAG);
|
spa_config_exit(spa, SCL_STATE, FTAG);
|
||||||
@ -1417,6 +1430,12 @@ spa_unload(spa_t *spa)
|
|||||||
spa->spa_condense_zthr = NULL;
|
spa->spa_condense_zthr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (spa->spa_checkpoint_discard_zthr != NULL) {
|
||||||
|
ASSERT(!zthr_isrunning(spa->spa_checkpoint_discard_zthr));
|
||||||
|
zthr_destroy(spa->spa_checkpoint_discard_zthr);
|
||||||
|
spa->spa_checkpoint_discard_zthr = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
spa_condense_fini(spa);
|
spa_condense_fini(spa);
|
||||||
|
|
||||||
bpobj_close(&spa->spa_deferred_bpobj);
|
bpobj_close(&spa->spa_deferred_bpobj);
|
||||||
@ -1500,6 +1519,18 @@ spa_load_spares(spa_t *spa)
|
|||||||
int i;
|
int i;
|
||||||
vdev_t *vd, *tvd;
|
vdev_t *vd, *tvd;
|
||||||
|
|
||||||
|
#ifndef _KERNEL
|
||||||
|
/*
|
||||||
|
* zdb opens both the current state of the pool and the
|
||||||
|
* checkpointed state (if present), with a different spa_t.
|
||||||
|
*
|
||||||
|
* As spare vdevs are shared among open pools, we skip loading
|
||||||
|
* them when we load the checkpointed state of the pool.
|
||||||
|
*/
|
||||||
|
if (!spa_writeable(spa))
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
ASSERT(spa_config_held(spa, SCL_ALL, RW_WRITER) == SCL_ALL);
|
ASSERT(spa_config_held(spa, SCL_ALL, RW_WRITER) == SCL_ALL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1619,6 +1650,19 @@ spa_load_l2cache(spa_t *spa)
|
|||||||
vdev_t *vd, **oldvdevs, **newvdevs;
|
vdev_t *vd, **oldvdevs, **newvdevs;
|
||||||
spa_aux_vdev_t *sav = &spa->spa_l2cache;
|
spa_aux_vdev_t *sav = &spa->spa_l2cache;
|
||||||
|
|
||||||
|
#ifndef _KERNEL
|
||||||
|
/*
|
||||||
|
* zdb opens both the current state of the pool and the
|
||||||
|
* checkpointed state (if present), with a different spa_t.
|
||||||
|
*
|
||||||
|
* As L2 caches are part of the ARC which is shared among open
|
||||||
|
* pools, we skip loading them when we load the checkpointed
|
||||||
|
* state of the pool.
|
||||||
|
*/
|
||||||
|
if (!spa_writeable(spa))
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
ASSERT(spa_config_held(spa, SCL_ALL, RW_WRITER) == SCL_ALL);
|
ASSERT(spa_config_held(spa, SCL_ALL, RW_WRITER) == SCL_ALL);
|
||||||
|
|
||||||
if (sav->sav_config != NULL) {
|
if (sav->sav_config != NULL) {
|
||||||
@ -2181,6 +2225,11 @@ spa_spawn_aux_threads(spa_t *spa)
|
|||||||
ASSERT(MUTEX_HELD(&spa_namespace_lock));
|
ASSERT(MUTEX_HELD(&spa_namespace_lock));
|
||||||
|
|
||||||
spa_start_indirect_condensing_thread(spa);
|
spa_start_indirect_condensing_thread(spa);
|
||||||
|
|
||||||
|
ASSERT3P(spa->spa_checkpoint_discard_zthr, ==, NULL);
|
||||||
|
spa->spa_checkpoint_discard_zthr =
|
||||||
|
zthr_create(spa_checkpoint_discard_thread_check,
|
||||||
|
spa_checkpoint_discard_thread, spa);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2274,7 +2323,7 @@ spa_load(spa_t *spa, spa_load_state_t state, spa_import_type_t type)
|
|||||||
spa->spa_load_state = state;
|
spa->spa_load_state = state;
|
||||||
|
|
||||||
gethrestime(&spa->spa_loaded_ts);
|
gethrestime(&spa->spa_loaded_ts);
|
||||||
error = spa_load_impl(spa, type, &ereport, B_FALSE);
|
error = spa_load_impl(spa, type, &ereport);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Don't count references from objsets that are already closed
|
* Don't count references from objsets that are already closed
|
||||||
@ -2379,8 +2428,25 @@ spa_ld_parse_config(spa_t *spa, spa_import_type_t type)
|
|||||||
return (SET_ERROR(EINVAL));
|
return (SET_ERROR(EINVAL));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((spa->spa_load_state == SPA_LOAD_IMPORT || spa->spa_load_state ==
|
/*
|
||||||
SPA_LOAD_TRYIMPORT) && spa_guid_exists(pool_guid, 0)) {
|
* If we are doing an import, ensure that the pool is not already
|
||||||
|
* imported by checking if its pool guid already exists in the
|
||||||
|
* spa namespace.
|
||||||
|
*
|
||||||
|
* The only case that we allow an already imported pool to be
|
||||||
|
* imported again, is when the pool is checkpointed and we want to
|
||||||
|
* look at its checkpointed state from userland tools like zdb.
|
||||||
|
*/
|
||||||
|
#ifdef _KERNEL
|
||||||
|
if ((spa->spa_load_state == SPA_LOAD_IMPORT ||
|
||||||
|
spa->spa_load_state == SPA_LOAD_TRYIMPORT) &&
|
||||||
|
spa_guid_exists(pool_guid, 0)) {
|
||||||
|
#else
|
||||||
|
if ((spa->spa_load_state == SPA_LOAD_IMPORT ||
|
||||||
|
spa->spa_load_state == SPA_LOAD_TRYIMPORT) &&
|
||||||
|
spa_guid_exists(pool_guid, 0) &&
|
||||||
|
!spa_importing_readonly_checkpoint(spa)) {
|
||||||
|
#endif
|
||||||
spa_load_failed(spa, "a pool with guid %llu is already open",
|
spa_load_failed(spa, "a pool with guid %llu is already open",
|
||||||
(u_longlong_t)pool_guid);
|
(u_longlong_t)pool_guid);
|
||||||
return (SET_ERROR(EEXIST));
|
return (SET_ERROR(EEXIST));
|
||||||
@ -2539,6 +2605,19 @@ spa_ld_validate_vdevs(spa_t *spa)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
spa_ld_select_uberblock_done(spa_t *spa, uberblock_t *ub)
|
||||||
|
{
|
||||||
|
spa->spa_state = POOL_STATE_ACTIVE;
|
||||||
|
spa->spa_ubsync = spa->spa_uberblock;
|
||||||
|
spa->spa_verify_min_txg = spa->spa_extreme_rewind ?
|
||||||
|
TXG_INITIAL - 1 : spa_last_synced_txg(spa) - TXG_DEFER_SIZE - 1;
|
||||||
|
spa->spa_first_txg = spa->spa_last_ubsync_txg ?
|
||||||
|
spa->spa_last_ubsync_txg : spa_last_synced_txg(spa) + 1;
|
||||||
|
spa->spa_claim_max_txg = spa->spa_first_txg;
|
||||||
|
spa->spa_prev_software_version = ub->ub_software_version;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
spa_ld_select_uberblock(spa_t *spa, spa_import_type_t type)
|
spa_ld_select_uberblock(spa_t *spa, spa_import_type_t type)
|
||||||
{
|
{
|
||||||
@ -2546,6 +2625,29 @@ spa_ld_select_uberblock(spa_t *spa, spa_import_type_t type)
|
|||||||
nvlist_t *label;
|
nvlist_t *label;
|
||||||
uberblock_t *ub = &spa->spa_uberblock;
|
uberblock_t *ub = &spa->spa_uberblock;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we are opening the checkpointed state of the pool by
|
||||||
|
* rewinding to it, at this point we will have written the
|
||||||
|
* checkpointed uberblock to the vdev labels, so searching
|
||||||
|
* the labels will find the right uberblock. However, if
|
||||||
|
* we are opening the checkpointed state read-only, we have
|
||||||
|
* not modified the labels. Therefore, we must ignore the
|
||||||
|
* labels and continue using the spa_uberblock that was set
|
||||||
|
* by spa_ld_checkpoint_rewind.
|
||||||
|
*
|
||||||
|
* Note that it would be fine to ignore the labels when
|
||||||
|
* rewinding (opening writeable) as well. However, if we
|
||||||
|
* crash just after writing the labels, we will end up
|
||||||
|
* searching the labels. Doing so in the common case means
|
||||||
|
* that this code path gets exercised normally, rather than
|
||||||
|
* just in the edge case.
|
||||||
|
*/
|
||||||
|
if (ub->ub_checkpoint_txg != 0 &&
|
||||||
|
spa_importing_readonly_checkpoint(spa)) {
|
||||||
|
spa_ld_select_uberblock_done(spa, ub);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find the best uberblock.
|
* Find the best uberblock.
|
||||||
*/
|
*/
|
||||||
@ -2648,14 +2750,7 @@ spa_ld_select_uberblock(spa_t *spa, spa_import_type_t type)
|
|||||||
/*
|
/*
|
||||||
* Initialize internal SPA structures.
|
* Initialize internal SPA structures.
|
||||||
*/
|
*/
|
||||||
spa->spa_state = POOL_STATE_ACTIVE;
|
spa_ld_select_uberblock_done(spa, ub);
|
||||||
spa->spa_ubsync = spa->spa_uberblock;
|
|
||||||
spa->spa_verify_min_txg = spa->spa_extreme_rewind ?
|
|
||||||
TXG_INITIAL - 1 : spa_last_synced_txg(spa) - TXG_DEFER_SIZE - 1;
|
|
||||||
spa->spa_first_txg = spa->spa_last_ubsync_txg ?
|
|
||||||
spa->spa_last_ubsync_txg : spa_last_synced_txg(spa) + 1;
|
|
||||||
spa->spa_claim_max_txg = spa->spa_first_txg;
|
|
||||||
spa->spa_prev_software_version = ub->ub_software_version;
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -2678,7 +2773,7 @@ spa_ld_open_rootbp(spa_t *spa)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
spa_ld_load_trusted_config(spa_t *spa, spa_import_type_t type,
|
spa_ld_trusted_config(spa_t *spa, spa_import_type_t type,
|
||||||
boolean_t reloading)
|
boolean_t reloading)
|
||||||
{
|
{
|
||||||
vdev_t *mrvd, *rvd = spa->spa_root_vdev;
|
vdev_t *mrvd, *rvd = spa->spa_root_vdev;
|
||||||
@ -3339,7 +3434,7 @@ spa_ld_claim_log_blocks(spa_t *spa)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
spa_ld_check_for_config_update(spa_t *spa, uint64_t config_cache_txg,
|
spa_ld_check_for_config_update(spa_t *spa, uint64_t config_cache_txg,
|
||||||
boolean_t reloading)
|
boolean_t update_config_cache)
|
||||||
{
|
{
|
||||||
vdev_t *rvd = spa->spa_root_vdev;
|
vdev_t *rvd = spa->spa_root_vdev;
|
||||||
int need_update = B_FALSE;
|
int need_update = B_FALSE;
|
||||||
@ -3351,7 +3446,7 @@ spa_ld_check_for_config_update(spa_t *spa, uint64_t config_cache_txg,
|
|||||||
* If this is a verbatim import, trust the current
|
* If this is a verbatim import, trust the current
|
||||||
* in-core spa_config and update the disk labels.
|
* in-core spa_config and update the disk labels.
|
||||||
*/
|
*/
|
||||||
if (reloading || config_cache_txg != spa->spa_config_txg ||
|
if (update_config_cache || config_cache_txg != spa->spa_config_txg ||
|
||||||
spa->spa_load_state == SPA_LOAD_IMPORT ||
|
spa->spa_load_state == SPA_LOAD_IMPORT ||
|
||||||
spa->spa_load_state == SPA_LOAD_RECOVER ||
|
spa->spa_load_state == SPA_LOAD_RECOVER ||
|
||||||
(spa->spa_import_flags & ZFS_IMPORT_VERBATIM))
|
(spa->spa_import_flags & ZFS_IMPORT_VERBATIM))
|
||||||
@ -3387,18 +3482,38 @@ spa_ld_prepare_for_reload(spa_t *spa)
|
|||||||
spa->spa_async_suspended = async_suspended;
|
spa->spa_async_suspended = async_suspended;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Load an existing storage pool, using the config provided. This config
|
|
||||||
* describes which vdevs are part of the pool and is later validated against
|
|
||||||
* partial configs present in each vdev's label and an entire copy of the
|
|
||||||
* config stored in the MOS.
|
|
||||||
*/
|
|
||||||
static int
|
static int
|
||||||
spa_load_impl(spa_t *spa, spa_import_type_t type, char **ereport,
|
spa_ld_read_checkpoint_txg(spa_t *spa)
|
||||||
boolean_t reloading)
|
{
|
||||||
|
uberblock_t checkpoint;
|
||||||
|
int error = 0;
|
||||||
|
|
||||||
|
ASSERT0(spa->spa_checkpoint_txg);
|
||||||
|
ASSERT(MUTEX_HELD(&spa_namespace_lock));
|
||||||
|
|
||||||
|
error = zap_lookup(spa->spa_meta_objset, DMU_POOL_DIRECTORY_OBJECT,
|
||||||
|
DMU_POOL_ZPOOL_CHECKPOINT, sizeof (uint64_t),
|
||||||
|
sizeof (uberblock_t) / sizeof (uint64_t), &checkpoint);
|
||||||
|
|
||||||
|
if (error == ENOENT)
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
|
ASSERT3U(checkpoint.ub_txg, !=, 0);
|
||||||
|
ASSERT3U(checkpoint.ub_checkpoint_txg, !=, 0);
|
||||||
|
ASSERT3U(checkpoint.ub_timestamp, !=, 0);
|
||||||
|
spa->spa_checkpoint_txg = checkpoint.ub_txg;
|
||||||
|
spa->spa_checkpoint_info.sci_timestamp = checkpoint.ub_timestamp;
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
spa_ld_mos_init(spa_t *spa, spa_import_type_t type)
|
||||||
{
|
{
|
||||||
int error = 0;
|
int error = 0;
|
||||||
boolean_t missing_feat_write = B_FALSE;
|
|
||||||
|
|
||||||
ASSERT(MUTEX_HELD(&spa_namespace_lock));
|
ASSERT(MUTEX_HELD(&spa_namespace_lock));
|
||||||
ASSERT(spa->spa_config_source != SPA_CONFIG_SRC_NONE);
|
ASSERT(spa->spa_config_source != SPA_CONFIG_SRC_NONE);
|
||||||
@ -3414,11 +3529,6 @@ spa_load_impl(spa_t *spa, spa_import_type_t type, char **ereport,
|
|||||||
if (type != SPA_IMPORT_ASSEMBLE)
|
if (type != SPA_IMPORT_ASSEMBLE)
|
||||||
spa->spa_trust_config = B_FALSE;
|
spa->spa_trust_config = B_FALSE;
|
||||||
|
|
||||||
if (reloading)
|
|
||||||
spa_load_note(spa, "RELOADING");
|
|
||||||
else
|
|
||||||
spa_load_note(spa, "LOADING");
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse the config provided to create a vdev tree.
|
* Parse the config provided to create a vdev tree.
|
||||||
*/
|
*/
|
||||||
@ -3451,11 +3561,11 @@ spa_load_impl(spa_t *spa, spa_import_type_t type, char **ereport,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read vdev labels to find the best uberblock (i.e. latest, unless
|
* Read all vdev labels to find the best uberblock (i.e. latest,
|
||||||
* spa_load_max_txg is set) and store it in spa_uberblock. We get the
|
* unless spa_load_max_txg is set) and store it in spa_uberblock. We
|
||||||
* list of features required to read blkptrs in the MOS from the vdev
|
* get the list of features required to read blkptrs in the MOS from
|
||||||
* label with the best uberblock and verify that our version of zfs
|
* the vdev label with the best uberblock and verify that our version
|
||||||
* supports them all.
|
* of zfs supports them all.
|
||||||
*/
|
*/
|
||||||
error = spa_ld_select_uberblock(spa, type);
|
error = spa_ld_select_uberblock(spa, type);
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
@ -3470,23 +3580,211 @@ spa_load_impl(spa_t *spa, spa_import_type_t type, char **ereport,
|
|||||||
if (error != 0)
|
if (error != 0)
|
||||||
return (error);
|
return (error);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
spa_ld_checkpoint_rewind(spa_t *spa)
|
||||||
|
{
|
||||||
|
uberblock_t checkpoint;
|
||||||
|
int error = 0;
|
||||||
|
|
||||||
|
ASSERT(MUTEX_HELD(&spa_namespace_lock));
|
||||||
|
ASSERT(spa->spa_import_flags & ZFS_IMPORT_CHECKPOINT);
|
||||||
|
|
||||||
|
error = zap_lookup(spa->spa_meta_objset, DMU_POOL_DIRECTORY_OBJECT,
|
||||||
|
DMU_POOL_ZPOOL_CHECKPOINT, sizeof (uint64_t),
|
||||||
|
sizeof (uberblock_t) / sizeof (uint64_t), &checkpoint);
|
||||||
|
|
||||||
|
if (error != 0) {
|
||||||
|
spa_load_failed(spa, "unable to retrieve checkpointed "
|
||||||
|
"uberblock from the MOS config [error=%d]", error);
|
||||||
|
|
||||||
|
if (error == ENOENT)
|
||||||
|
error = ZFS_ERR_NO_CHECKPOINT;
|
||||||
|
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT3U(checkpoint.ub_txg, <, spa->spa_uberblock.ub_txg);
|
||||||
|
ASSERT3U(checkpoint.ub_txg, ==, checkpoint.ub_checkpoint_txg);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We need to update the txg and timestamp of the checkpointed
|
||||||
|
* uberblock to be higher than the latest one. This ensures that
|
||||||
|
* the checkpointed uberblock is selected if we were to close and
|
||||||
|
* reopen the pool right after we've written it in the vdev labels.
|
||||||
|
* (also see block comment in vdev_uberblock_compare)
|
||||||
|
*/
|
||||||
|
checkpoint.ub_txg = spa->spa_uberblock.ub_txg + 1;
|
||||||
|
checkpoint.ub_timestamp = gethrestime_sec();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set current uberblock to be the checkpointed uberblock.
|
||||||
|
*/
|
||||||
|
spa->spa_uberblock = checkpoint;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we are doing a normal rewind, then the pool is open for
|
||||||
|
* writing and we sync the "updated" checkpointed uberblock to
|
||||||
|
* disk. Once this is done, we've basically rewound the whole
|
||||||
|
* pool and there is no way back.
|
||||||
|
*
|
||||||
|
* There are cases when we don't want to attempt and sync the
|
||||||
|
* checkpointed uberblock to disk because we are opening a
|
||||||
|
* pool as read-only. Specifically, verifying the checkpointed
|
||||||
|
* state with zdb, and importing the checkpointed state to get
|
||||||
|
* a "preview" of its content.
|
||||||
|
*/
|
||||||
|
if (spa_writeable(spa)) {
|
||||||
|
vdev_t *rvd = spa->spa_root_vdev;
|
||||||
|
|
||||||
|
spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
|
||||||
|
vdev_t *svd[SPA_SYNC_MIN_VDEVS] = { NULL };
|
||||||
|
int svdcount = 0;
|
||||||
|
int children = rvd->vdev_children;
|
||||||
|
int c0 = spa_get_random(children);
|
||||||
|
|
||||||
|
for (int c = 0; c < children; c++) {
|
||||||
|
vdev_t *vd = rvd->vdev_child[(c0 + c) % children];
|
||||||
|
|
||||||
|
/* Stop when revisiting the first vdev */
|
||||||
|
if (c > 0 && svd[0] == vd)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (vd->vdev_ms_array == 0 || vd->vdev_islog ||
|
||||||
|
!vdev_is_concrete(vd))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
svd[svdcount++] = vd;
|
||||||
|
if (svdcount == SPA_SYNC_MIN_VDEVS)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
error = vdev_config_sync(svd, svdcount, spa->spa_first_txg);
|
||||||
|
if (error == 0)
|
||||||
|
spa->spa_last_synced_guid = rvd->vdev_guid;
|
||||||
|
spa_config_exit(spa, SCL_ALL, FTAG);
|
||||||
|
|
||||||
|
if (error != 0) {
|
||||||
|
spa_load_failed(spa, "failed to write checkpointed "
|
||||||
|
"uberblock to the vdev labels [error=%d]", error);
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
spa_ld_mos_with_trusted_config(spa_t *spa, spa_import_type_t type,
|
||||||
|
boolean_t *update_config_cache)
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Parse the config for pool, open and validate vdevs,
|
||||||
|
* select an uberblock, and use that uberblock to open
|
||||||
|
* the MOS.
|
||||||
|
*/
|
||||||
|
error = spa_ld_mos_init(spa, type);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Retrieve the trusted config stored in the MOS and use it to create
|
* Retrieve the trusted config stored in the MOS and use it to create
|
||||||
* a new, exact version of the vdev tree, then reopen all vdevs.
|
* a new, exact version of the vdev tree, then reopen all vdevs.
|
||||||
*/
|
*/
|
||||||
error = spa_ld_load_trusted_config(spa, type, reloading);
|
error = spa_ld_trusted_config(spa, type, B_FALSE);
|
||||||
if (error == EAGAIN) {
|
if (error == EAGAIN) {
|
||||||
VERIFY(!reloading);
|
if (update_config_cache != NULL)
|
||||||
|
*update_config_cache = B_TRUE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Redo the loading process with the trusted config if it is
|
* Redo the loading process with the trusted config if it is
|
||||||
* too different from the untrusted config.
|
* too different from the untrusted config.
|
||||||
*/
|
*/
|
||||||
spa_ld_prepare_for_reload(spa);
|
spa_ld_prepare_for_reload(spa);
|
||||||
return (spa_load_impl(spa, type, ereport, B_TRUE));
|
spa_load_note(spa, "RELOADING");
|
||||||
|
error = spa_ld_mos_init(spa, type);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
|
error = spa_ld_trusted_config(spa, type, B_TRUE);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
} else if (error != 0) {
|
} else if (error != 0) {
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load an existing storage pool, using the config provided. This config
|
||||||
|
* describes which vdevs are part of the pool and is later validated against
|
||||||
|
* partial configs present in each vdev's label and an entire copy of the
|
||||||
|
* config stored in the MOS.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
spa_load_impl(spa_t *spa, spa_import_type_t type, char **ereport)
|
||||||
|
{
|
||||||
|
int error = 0;
|
||||||
|
boolean_t missing_feat_write = B_FALSE;
|
||||||
|
boolean_t checkpoint_rewind =
|
||||||
|
(spa->spa_import_flags & ZFS_IMPORT_CHECKPOINT);
|
||||||
|
boolean_t update_config_cache = B_FALSE;
|
||||||
|
|
||||||
|
ASSERT(MUTEX_HELD(&spa_namespace_lock));
|
||||||
|
ASSERT(spa->spa_config_source != SPA_CONFIG_SRC_NONE);
|
||||||
|
|
||||||
|
spa_load_note(spa, "LOADING");
|
||||||
|
|
||||||
|
error = spa_ld_mos_with_trusted_config(spa, type, &update_config_cache);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we are rewinding to the checkpoint then we need to repeat
|
||||||
|
* everything we've done so far in this function but this time
|
||||||
|
* selecting the checkpointed uberblock and using that to open
|
||||||
|
* the MOS.
|
||||||
|
*/
|
||||||
|
if (checkpoint_rewind) {
|
||||||
|
/*
|
||||||
|
* If we are rewinding to the checkpoint update config cache
|
||||||
|
* anyway.
|
||||||
|
*/
|
||||||
|
update_config_cache = B_TRUE;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Extract the checkpointed uberblock from the current MOS
|
||||||
|
* and use this as the pool's uberblock from now on. If the
|
||||||
|
* pool is imported as writeable we also write the checkpoint
|
||||||
|
* uberblock to the labels, making the rewind permanent.
|
||||||
|
*/
|
||||||
|
error = spa_ld_checkpoint_rewind(spa);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Redo the loading process process again with the
|
||||||
|
* checkpointed uberblock.
|
||||||
|
*/
|
||||||
|
spa_ld_prepare_for_reload(spa);
|
||||||
|
spa_load_note(spa, "LOADING checkpointed uberblock");
|
||||||
|
error = spa_ld_mos_with_trusted_config(spa, type, NULL);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieve the checkpoint txg if the pool has a checkpoint.
|
||||||
|
*/
|
||||||
|
error = spa_ld_read_checkpoint_txg(spa);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Retrieve the mapping of indirect vdevs. Those vdevs were removed
|
* Retrieve the mapping of indirect vdevs. Those vdevs were removed
|
||||||
* from the pool and their contents were re-mapped to other vdevs. Note
|
* from the pool and their contents were re-mapped to other vdevs. Note
|
||||||
@ -3589,6 +3887,16 @@ spa_load_impl(spa_t *spa, spa_import_type_t type, char **ereport,
|
|||||||
|
|
||||||
ASSERT(spa->spa_load_state != SPA_LOAD_TRYIMPORT);
|
ASSERT(spa->spa_load_state != SPA_LOAD_TRYIMPORT);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* In case of a checkpoint rewind, log the original txg
|
||||||
|
* of the checkpointed uberblock.
|
||||||
|
*/
|
||||||
|
if (checkpoint_rewind) {
|
||||||
|
spa_history_log_internal(spa, "checkpoint rewind",
|
||||||
|
NULL, "rewound state to txg=%llu",
|
||||||
|
(u_longlong_t)spa->spa_uberblock.ub_checkpoint_txg);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Traverse the ZIL and claim all blocks.
|
* Traverse the ZIL and claim all blocks.
|
||||||
*/
|
*/
|
||||||
@ -3615,7 +3923,7 @@ spa_load_impl(spa_t *spa, spa_import_type_t type, char **ereport,
|
|||||||
* and the cachefile (by default /etc/zfs/zpool.cache).
|
* and the cachefile (by default /etc/zfs/zpool.cache).
|
||||||
*/
|
*/
|
||||||
spa_ld_check_for_config_update(spa, config_cache_txg,
|
spa_ld_check_for_config_update(spa, config_cache_txg,
|
||||||
reloading);
|
update_config_cache);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check all DTLs to see if anything needs resilvering.
|
* Check all DTLs to see if anything needs resilvering.
|
||||||
@ -3699,6 +4007,15 @@ spa_load_best(spa_t *spa, spa_load_state_t state, uint64_t max_request,
|
|||||||
load_error = rewind_error = spa_load(spa, state, SPA_IMPORT_EXISTING);
|
load_error = rewind_error = spa_load(spa, state, SPA_IMPORT_EXISTING);
|
||||||
if (load_error == 0)
|
if (load_error == 0)
|
||||||
return (0);
|
return (0);
|
||||||
|
if (load_error == ZFS_ERR_NO_CHECKPOINT) {
|
||||||
|
/*
|
||||||
|
* When attempting checkpoint-rewind on a pool with no
|
||||||
|
* checkpoint, we should not attempt to load uberblocks
|
||||||
|
* from previous txgs when spa_load fails.
|
||||||
|
*/
|
||||||
|
ASSERT(spa->spa_import_flags & ZFS_IMPORT_CHECKPOINT);
|
||||||
|
return (load_error);
|
||||||
|
}
|
||||||
|
|
||||||
if (spa->spa_root_vdev != NULL)
|
if (spa->spa_root_vdev != NULL)
|
||||||
config = spa_config_generate(spa, NULL, -1ULL, B_TRUE);
|
config = spa_config_generate(spa, NULL, -1ULL, B_TRUE);
|
||||||
@ -5615,6 +5932,13 @@ spa_vdev_attach(spa_t *spa, uint64_t guid, nvlist_t *nvroot, int replacing)
|
|||||||
|
|
||||||
oldvd = spa_lookup_by_guid(spa, guid, B_FALSE);
|
oldvd = spa_lookup_by_guid(spa, guid, B_FALSE);
|
||||||
|
|
||||||
|
ASSERT(MUTEX_HELD(&spa_namespace_lock));
|
||||||
|
if (spa_feature_is_active(spa, SPA_FEATURE_POOL_CHECKPOINT)) {
|
||||||
|
error = (spa_has_checkpoint(spa)) ?
|
||||||
|
ZFS_ERR_CHECKPOINT_EXISTS : ZFS_ERR_DISCARDING_CHECKPOINT;
|
||||||
|
return (spa_vdev_exit(spa, NULL, txg, error));
|
||||||
|
}
|
||||||
|
|
||||||
if (spa->spa_vdev_removal != NULL ||
|
if (spa->spa_vdev_removal != NULL ||
|
||||||
spa->spa_removing_phys.sr_prev_indirect_vdev != -1) {
|
spa->spa_removing_phys.sr_prev_indirect_vdev != -1) {
|
||||||
return (spa_vdev_exit(spa, NULL, txg, EBUSY));
|
return (spa_vdev_exit(spa, NULL, txg, EBUSY));
|
||||||
@ -5824,6 +6148,27 @@ spa_vdev_detach(spa_t *spa, uint64_t guid, uint64_t pguid, int replace_done)
|
|||||||
|
|
||||||
vd = spa_lookup_by_guid(spa, guid, B_FALSE);
|
vd = spa_lookup_by_guid(spa, guid, B_FALSE);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Besides being called directly from the userland through the
|
||||||
|
* ioctl interface, spa_vdev_detach() can be potentially called
|
||||||
|
* at the end of spa_vdev_resilver_done().
|
||||||
|
*
|
||||||
|
* In the regular case, when we have a checkpoint this shouldn't
|
||||||
|
* happen as we never empty the DTLs of a vdev during the scrub
|
||||||
|
* [see comment in dsl_scan_done()]. Thus spa_vdev_resilvering_done()
|
||||||
|
* should never get here when we have a checkpoint.
|
||||||
|
*
|
||||||
|
* That said, even in a case when we checkpoint the pool exactly
|
||||||
|
* as spa_vdev_resilver_done() calls this function everything
|
||||||
|
* should be fine as the resilver will return right away.
|
||||||
|
*/
|
||||||
|
ASSERT(MUTEX_HELD(&spa_namespace_lock));
|
||||||
|
if (spa_feature_is_active(spa, SPA_FEATURE_POOL_CHECKPOINT)) {
|
||||||
|
error = (spa_has_checkpoint(spa)) ?
|
||||||
|
ZFS_ERR_CHECKPOINT_EXISTS : ZFS_ERR_DISCARDING_CHECKPOINT;
|
||||||
|
return (spa_vdev_exit(spa, NULL, txg, error));
|
||||||
|
}
|
||||||
|
|
||||||
if (vd == NULL)
|
if (vd == NULL)
|
||||||
return (spa_vdev_exit(spa, NULL, txg, ENODEV));
|
return (spa_vdev_exit(spa, NULL, txg, ENODEV));
|
||||||
|
|
||||||
@ -6062,6 +6407,13 @@ spa_vdev_split_mirror(spa_t *spa, char *newname, nvlist_t *config,
|
|||||||
|
|
||||||
txg = spa_vdev_enter(spa);
|
txg = spa_vdev_enter(spa);
|
||||||
|
|
||||||
|
ASSERT(MUTEX_HELD(&spa_namespace_lock));
|
||||||
|
if (spa_feature_is_active(spa, SPA_FEATURE_POOL_CHECKPOINT)) {
|
||||||
|
error = (spa_has_checkpoint(spa)) ?
|
||||||
|
ZFS_ERR_CHECKPOINT_EXISTS : ZFS_ERR_DISCARDING_CHECKPOINT;
|
||||||
|
return (spa_vdev_exit(spa, NULL, txg, error));
|
||||||
|
}
|
||||||
|
|
||||||
/* clear the log and flush everything up to now */
|
/* clear the log and flush everything up to now */
|
||||||
activate_slog = spa_passivate_log(spa);
|
activate_slog = spa_passivate_log(spa);
|
||||||
(void) spa_vdev_config_exit(spa, NULL, txg, 0, FTAG);
|
(void) spa_vdev_config_exit(spa, NULL, txg, 0, FTAG);
|
||||||
@ -6762,6 +7114,10 @@ spa_async_suspend(spa_t *spa)
|
|||||||
zthr_t *condense_thread = spa->spa_condense_zthr;
|
zthr_t *condense_thread = spa->spa_condense_zthr;
|
||||||
if (condense_thread != NULL && zthr_isrunning(condense_thread))
|
if (condense_thread != NULL && zthr_isrunning(condense_thread))
|
||||||
VERIFY0(zthr_cancel(condense_thread));
|
VERIFY0(zthr_cancel(condense_thread));
|
||||||
|
|
||||||
|
zthr_t *discard_thread = spa->spa_checkpoint_discard_zthr;
|
||||||
|
if (discard_thread != NULL && zthr_isrunning(discard_thread))
|
||||||
|
VERIFY0(zthr_cancel(discard_thread));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -6776,6 +7132,10 @@ spa_async_resume(spa_t *spa)
|
|||||||
zthr_t *condense_thread = spa->spa_condense_zthr;
|
zthr_t *condense_thread = spa->spa_condense_zthr;
|
||||||
if (condense_thread != NULL && !zthr_isrunning(condense_thread))
|
if (condense_thread != NULL && !zthr_isrunning(condense_thread))
|
||||||
zthr_resume(condense_thread);
|
zthr_resume(condense_thread);
|
||||||
|
|
||||||
|
zthr_t *discard_thread = spa->spa_checkpoint_discard_zthr;
|
||||||
|
if (discard_thread != NULL && !zthr_isrunning(discard_thread))
|
||||||
|
zthr_resume(discard_thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean_t
|
static boolean_t
|
||||||
@ -7568,6 +7928,8 @@ spa_sync(spa_t *spa, uint64_t txg)
|
|||||||
txg));
|
txg));
|
||||||
ASSERT(txg_list_empty(&dp->dp_dirty_dirs, txg));
|
ASSERT(txg_list_empty(&dp->dp_dirty_dirs, txg));
|
||||||
ASSERT(txg_list_empty(&dp->dp_sync_tasks, txg));
|
ASSERT(txg_list_empty(&dp->dp_sync_tasks, txg));
|
||||||
|
ASSERT(txg_list_empty(&dp->dp_early_sync_tasks,
|
||||||
|
txg));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
spa_sync_deferred_frees(spa, tx);
|
spa_sync_deferred_frees(spa, tx);
|
||||||
@ -7611,16 +7973,22 @@ spa_sync(spa_t *spa, uint64_t txg)
|
|||||||
spa_config_enter(spa, SCL_STATE, FTAG, RW_READER);
|
spa_config_enter(spa, SCL_STATE, FTAG, RW_READER);
|
||||||
|
|
||||||
if (list_is_empty(&spa->spa_config_dirty_list)) {
|
if (list_is_empty(&spa->spa_config_dirty_list)) {
|
||||||
vdev_t *svd[SPA_SYNC_MIN_VDEVS];
|
vdev_t *svd[SPA_SYNC_MIN_VDEVS] = { NULL };
|
||||||
int svdcount = 0;
|
int svdcount = 0;
|
||||||
int children = rvd->vdev_children;
|
int children = rvd->vdev_children;
|
||||||
int c0 = spa_get_random(children);
|
int c0 = spa_get_random(children);
|
||||||
|
|
||||||
for (int c = 0; c < children; c++) {
|
for (int c = 0; c < children; c++) {
|
||||||
vd = rvd->vdev_child[(c0 + c) % children];
|
vd = rvd->vdev_child[(c0 + c) % children];
|
||||||
|
|
||||||
|
/* Stop when revisiting the first vdev */
|
||||||
|
if (c > 0 && svd[0] == vd)
|
||||||
|
break;
|
||||||
|
|
||||||
if (vd->vdev_ms_array == 0 || vd->vdev_islog ||
|
if (vd->vdev_ms_array == 0 || vd->vdev_islog ||
|
||||||
!vdev_is_concrete(vd))
|
!vdev_is_concrete(vd))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
svd[svdcount++] = vd;
|
svd[svdcount++] = vd;
|
||||||
if (svdcount == SPA_SYNC_MIN_VDEVS)
|
if (svdcount == SPA_SYNC_MIN_VDEVS)
|
||||||
break;
|
break;
|
||||||
@ -7689,6 +8057,9 @@ spa_sync(spa_t *spa, uint64_t txg)
|
|||||||
ASSERT(txg_list_empty(&dp->dp_dirty_dirs, txg));
|
ASSERT(txg_list_empty(&dp->dp_dirty_dirs, txg));
|
||||||
ASSERT(txg_list_empty(&spa->spa_vdev_txg_list, txg));
|
ASSERT(txg_list_empty(&spa->spa_vdev_txg_list, txg));
|
||||||
|
|
||||||
|
while (zfs_pause_spa_sync)
|
||||||
|
delay(1);
|
||||||
|
|
||||||
spa->spa_sync_pass = 0;
|
spa->spa_sync_pass = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
623
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_checkpoint.c
Normal file
623
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_checkpoint.c
Normal file
@ -0,0 +1,623 @@
|
|||||||
|
/*
|
||||||
|
* CDDL HEADER START
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the terms of the
|
||||||
|
* Common Development and Distribution License (the "License").
|
||||||
|
* You may not use this file except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||||
|
* or http://www.opensolaris.org/os/licensing.
|
||||||
|
* See the License for the specific language governing permissions
|
||||||
|
* and limitations under the License.
|
||||||
|
*
|
||||||
|
* When distributing Covered Code, include this CDDL HEADER in each
|
||||||
|
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
||||||
|
* If applicable, add the following below this CDDL HEADER, with the
|
||||||
|
* fields enclosed by brackets "[]" replaced with your own identifying
|
||||||
|
* information: Portions Copyright [yyyy] [name of copyright owner]
|
||||||
|
*
|
||||||
|
* CDDL HEADER END
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2017 by Delphix. All rights reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Storage Pool Checkpoint
|
||||||
|
*
|
||||||
|
* A storage pool checkpoint can be thought of as a pool-wide snapshot or
|
||||||
|
* a stable version of extreme rewind that guarantees no blocks from the
|
||||||
|
* checkpointed state will have been overwritten. It remembers the entire
|
||||||
|
* state of the storage pool (e.g. snapshots, dataset names, etc..) from the
|
||||||
|
* point that it was taken and the user can rewind back to that point even if
|
||||||
|
* they applied destructive operations on their datasets or even enabled new
|
||||||
|
* zpool on-disk features. If a pool has a checkpoint that is no longer
|
||||||
|
* needed, the user can discard it.
|
||||||
|
*
|
||||||
|
* == On disk data structures used ==
|
||||||
|
*
|
||||||
|
* - The pool has a new feature flag and a new entry in the MOS. The feature
|
||||||
|
* flag is set to active when we create the checkpoint and remains active
|
||||||
|
* until the checkpoint is fully discarded. The entry in the MOS config
|
||||||
|
* (DMU_POOL_ZPOOL_CHECKPOINT) is populated with the uberblock that
|
||||||
|
* references the state of the pool when we take the checkpoint. The entry
|
||||||
|
* remains populated until we start discarding the checkpoint or we rewind
|
||||||
|
* back to it.
|
||||||
|
*
|
||||||
|
* - Each vdev contains a vdev-wide space map while the pool has a checkpoint,
|
||||||
|
* which persists until the checkpoint is fully discarded. The space map
|
||||||
|
* contains entries that have been freed in the current state of the pool
|
||||||
|
* but we want to keep around in case we decide to rewind to the checkpoint.
|
||||||
|
* [see vdev_checkpoint_sm]
|
||||||
|
*
|
||||||
|
* - Each metaslab's ms_sm space map behaves the same as without the
|
||||||
|
* checkpoint, with the only exception being the scenario when we free
|
||||||
|
* blocks that belong to the checkpoint. In this case, these blocks remain
|
||||||
|
* ALLOCATED in the metaslab's space map and they are added as FREE in the
|
||||||
|
* vdev's checkpoint space map.
|
||||||
|
*
|
||||||
|
* - Each uberblock has a field (ub_checkpoint_txg) which holds the txg that
|
||||||
|
* the uberblock was checkpointed. For normal uberblocks this field is 0.
|
||||||
|
*
|
||||||
|
* == Overview of operations ==
|
||||||
|
*
|
||||||
|
* - To create a checkpoint, we first wait for the current TXG to be synced,
|
||||||
|
* so we can use the most recently synced uberblock (spa_ubsync) as the
|
||||||
|
* checkpointed uberblock. Then we use an early synctask to place that
|
||||||
|
* uberblock in MOS config, increment the feature flag for the checkpoint
|
||||||
|
* (marking it active), and setting spa_checkpoint_txg (see its use below)
|
||||||
|
* to the TXG of the checkpointed uberblock. We use an early synctask for
|
||||||
|
* the aforementioned operations to ensure that no blocks were dirtied
|
||||||
|
* between the current TXG and the TXG of the checkpointed uberblock
|
||||||
|
* (e.g the previous txg).
|
||||||
|
*
|
||||||
|
* - When a checkpoint exists, we need to ensure that the blocks that
|
||||||
|
* belong to the checkpoint are freed but never reused. This means that
|
||||||
|
* these blocks should never end up in the ms_allocatable or the ms_freeing
|
||||||
|
* trees of a metaslab. Therefore, whenever there is a checkpoint the new
|
||||||
|
* ms_checkpointing tree is used in addition to the aforementioned ones.
|
||||||
|
*
|
||||||
|
* Whenever a block is freed and we find out that it is referenced by the
|
||||||
|
* checkpoint (we find out by comparing its birth to spa_checkpoint_txg),
|
||||||
|
* we place it in the ms_checkpointing tree instead of the ms_freeingtree.
|
||||||
|
* This way, we divide the blocks that are being freed into checkpointed
|
||||||
|
* and not-checkpointed blocks.
|
||||||
|
*
|
||||||
|
* In order to persist these frees, we write the extents from the
|
||||||
|
* ms_freeingtree to the ms_sm as usual, and the extents from the
|
||||||
|
* ms_checkpointing tree to the vdev_checkpoint_sm. This way, these
|
||||||
|
* checkpointed extents will remain allocated in the metaslab's ms_sm space
|
||||||
|
* map, and therefore won't be reused [see metaslab_sync()]. In addition,
|
||||||
|
* when we discard the checkpoint, we can find the entries that have
|
||||||
|
* actually been freed in vdev_checkpoint_sm.
|
||||||
|
* [see spa_checkpoint_discard_thread_sync()]
|
||||||
|
*
|
||||||
|
* - To discard the checkpoint we use an early synctask to delete the
|
||||||
|
* checkpointed uberblock from the MOS config, set spa_checkpoint_txg to 0,
|
||||||
|
* and wakeup the discarding zthr thread (an open-context async thread).
|
||||||
|
* We use an early synctask to ensure that the operation happens before any
|
||||||
|
* new data end up in the checkpoint's data structures.
|
||||||
|
*
|
||||||
|
* Once the synctask is done and the discarding zthr is awake, we discard
|
||||||
|
* the checkpointed data over multiple TXGs by having the zthr prefetching
|
||||||
|
* entries from vdev_checkpoint_sm and then starting a synctask that places
|
||||||
|
* them as free blocks in to their respective ms_allocatable and ms_sm
|
||||||
|
* structures.
|
||||||
|
* [see spa_checkpoint_discard_thread()]
|
||||||
|
*
|
||||||
|
* When there are no entries left in the vdev_checkpoint_sm of all
|
||||||
|
* top-level vdevs, a final synctask runs that decrements the feature flag.
|
||||||
|
*
|
||||||
|
* - To rewind to the checkpoint, we first use the current uberblock and
|
||||||
|
* open the MOS so we can access the checkpointed uberblock from the MOS
|
||||||
|
* config. After we retrieve the checkpointed uberblock, we use it as the
|
||||||
|
* current uberblock for the pool by writing it to disk with an updated
|
||||||
|
* TXG, opening its version of the MOS, and moving on as usual from there.
|
||||||
|
* [see spa_ld_checkpoint_rewind()]
|
||||||
|
*
|
||||||
|
* An important note on rewinding to the checkpoint has to do with how we
|
||||||
|
* handle ZIL blocks. In the scenario of a rewind, we clear out any ZIL
|
||||||
|
* blocks that have not been claimed by the time we took the checkpoint
|
||||||
|
* as they should no longer be valid.
|
||||||
|
* [see comment in zil_claim()]
|
||||||
|
*
|
||||||
|
* == Miscellaneous information ==
|
||||||
|
*
|
||||||
|
* - In the hypothetical event that we take a checkpoint, remove a vdev,
|
||||||
|
* and attempt to rewind, the rewind would fail as the checkpointed
|
||||||
|
* uberblock would reference data in the removed device. For this reason
|
||||||
|
* and others of similar nature, we disallow the following operations that
|
||||||
|
* can change the config:
|
||||||
|
* vdev removal and attach/detach, mirror splitting, and pool reguid.
|
||||||
|
*
|
||||||
|
* - As most of the checkpoint logic is implemented in the SPA and doesn't
|
||||||
|
* distinguish datasets when it comes to space accounting, having a
|
||||||
|
* checkpoint can potentially break the boundaries set by dataset
|
||||||
|
* reservations.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/dmu_tx.h>
|
||||||
|
#include <sys/dsl_dir.h>
|
||||||
|
#include <sys/dsl_synctask.h>
|
||||||
|
#include <sys/metaslab_impl.h>
|
||||||
|
#include <sys/spa.h>
|
||||||
|
#include <sys/spa_impl.h>
|
||||||
|
#include <sys/spa_checkpoint.h>
|
||||||
|
#include <sys/vdev_impl.h>
|
||||||
|
#include <sys/zap.h>
|
||||||
|
#include <sys/zfeature.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following parameter limits the amount of memory to be used for the
|
||||||
|
* prefetching of the checkpoint space map done on each vdev while
|
||||||
|
* discarding the checkpoint.
|
||||||
|
*
|
||||||
|
* The reason it exists is because top-level vdevs with long checkpoint
|
||||||
|
* space maps can potentially take up a lot of memory depending on the
|
||||||
|
* amount of checkpointed data that has been freed within them while
|
||||||
|
* the pool had a checkpoint.
|
||||||
|
*/
|
||||||
|
uint64_t zfs_spa_discard_memory_limit = 16 * 1024 * 1024;
|
||||||
|
|
||||||
|
int
|
||||||
|
spa_checkpoint_get_stats(spa_t *spa, pool_checkpoint_stat_t *pcs)
|
||||||
|
{
|
||||||
|
if (!spa_feature_is_active(spa, SPA_FEATURE_POOL_CHECKPOINT))
|
||||||
|
return (SET_ERROR(ZFS_ERR_NO_CHECKPOINT));
|
||||||
|
|
||||||
|
bzero(pcs, sizeof (pool_checkpoint_stat_t));
|
||||||
|
|
||||||
|
int error = zap_contains(spa_meta_objset(spa),
|
||||||
|
DMU_POOL_DIRECTORY_OBJECT, DMU_POOL_ZPOOL_CHECKPOINT);
|
||||||
|
ASSERT(error == 0 || error == ENOENT);
|
||||||
|
|
||||||
|
if (error == ENOENT)
|
||||||
|
pcs->pcs_state = CS_CHECKPOINT_DISCARDING;
|
||||||
|
else
|
||||||
|
pcs->pcs_state = CS_CHECKPOINT_EXISTS;
|
||||||
|
|
||||||
|
pcs->pcs_space = spa->spa_checkpoint_info.sci_dspace;
|
||||||
|
pcs->pcs_start_time = spa->spa_checkpoint_info.sci_timestamp;
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
spa_checkpoint_discard_complete_sync(void *arg, dmu_tx_t *tx)
|
||||||
|
{
|
||||||
|
spa_t *spa = arg;
|
||||||
|
|
||||||
|
spa->spa_checkpoint_info.sci_timestamp = 0;
|
||||||
|
|
||||||
|
spa_feature_decr(spa, SPA_FEATURE_POOL_CHECKPOINT, tx);
|
||||||
|
|
||||||
|
spa_history_log_internal(spa, "spa discard checkpoint", tx,
|
||||||
|
"finished discarding checkpointed state from the pool");
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct spa_checkpoint_discard_sync_callback_arg {
|
||||||
|
vdev_t *sdc_vd;
|
||||||
|
uint64_t sdc_txg;
|
||||||
|
uint64_t sdc_entry_limit;
|
||||||
|
} spa_checkpoint_discard_sync_callback_arg_t;
|
||||||
|
|
||||||
|
static int
|
||||||
|
spa_checkpoint_discard_sync_callback(maptype_t type, uint64_t offset,
|
||||||
|
uint64_t size, void *arg)
|
||||||
|
{
|
||||||
|
spa_checkpoint_discard_sync_callback_arg_t *sdc = arg;
|
||||||
|
vdev_t *vd = sdc->sdc_vd;
|
||||||
|
metaslab_t *ms = vd->vdev_ms[offset >> vd->vdev_ms_shift];
|
||||||
|
uint64_t end = offset + size;
|
||||||
|
|
||||||
|
if (sdc->sdc_entry_limit == 0)
|
||||||
|
return (EINTR);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Since the space map is not condensed, we know that
|
||||||
|
* none of its entries is crossing the boundaries of
|
||||||
|
* its respective metaslab.
|
||||||
|
*
|
||||||
|
* That said, there is no fundamental requirement that
|
||||||
|
* the checkpoint's space map entries should not cross
|
||||||
|
* metaslab boundaries. So if needed we could add code
|
||||||
|
* that handles metaslab-crossing segments in the future.
|
||||||
|
*/
|
||||||
|
VERIFY3U(type, ==, SM_FREE);
|
||||||
|
VERIFY3U(offset, >=, ms->ms_start);
|
||||||
|
VERIFY3U(end, <=, ms->ms_start + ms->ms_size);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* At this point we should not be processing any
|
||||||
|
* other frees concurrently, so the lock is technically
|
||||||
|
* unnecessary. We use the lock anyway though to
|
||||||
|
* potentially save ourselves from future headaches.
|
||||||
|
*/
|
||||||
|
mutex_enter(&ms->ms_lock);
|
||||||
|
if (range_tree_is_empty(ms->ms_freeing))
|
||||||
|
vdev_dirty(vd, VDD_METASLAB, ms, sdc->sdc_txg);
|
||||||
|
range_tree_add(ms->ms_freeing, offset, size);
|
||||||
|
mutex_exit(&ms->ms_lock);
|
||||||
|
|
||||||
|
ASSERT3U(vd->vdev_spa->spa_checkpoint_info.sci_dspace, >=, size);
|
||||||
|
ASSERT3U(vd->vdev_stat.vs_checkpoint_space, >=, size);
|
||||||
|
|
||||||
|
vd->vdev_spa->spa_checkpoint_info.sci_dspace -= size;
|
||||||
|
vd->vdev_stat.vs_checkpoint_space -= size;
|
||||||
|
sdc->sdc_entry_limit--;
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
spa_checkpoint_accounting_verify(spa_t *spa)
|
||||||
|
{
|
||||||
|
vdev_t *rvd = spa->spa_root_vdev;
|
||||||
|
uint64_t ckpoint_sm_space_sum = 0;
|
||||||
|
uint64_t vs_ckpoint_space_sum = 0;
|
||||||
|
|
||||||
|
for (uint64_t c = 0; c < rvd->vdev_children; c++) {
|
||||||
|
vdev_t *vd = rvd->vdev_child[c];
|
||||||
|
|
||||||
|
if (vd->vdev_checkpoint_sm != NULL) {
|
||||||
|
ckpoint_sm_space_sum +=
|
||||||
|
-vd->vdev_checkpoint_sm->sm_alloc;
|
||||||
|
vs_ckpoint_space_sum +=
|
||||||
|
vd->vdev_stat.vs_checkpoint_space;
|
||||||
|
ASSERT3U(ckpoint_sm_space_sum, ==,
|
||||||
|
vs_ckpoint_space_sum);
|
||||||
|
} else {
|
||||||
|
ASSERT0(vd->vdev_stat.vs_checkpoint_space);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ASSERT3U(spa->spa_checkpoint_info.sci_dspace, ==, ckpoint_sm_space_sum);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
spa_checkpoint_discard_thread_sync(void *arg, dmu_tx_t *tx)
|
||||||
|
{
|
||||||
|
vdev_t *vd = arg;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The space map callback is applied only to non-debug entries.
|
||||||
|
* Because the number of debug entries is less or equal to the
|
||||||
|
* number of non-debug entries, we want to ensure that we only
|
||||||
|
* read what we prefetched from open-context.
|
||||||
|
*
|
||||||
|
* Thus, we set the maximum entries that the space map callback
|
||||||
|
* will be applied to be half the entries that could fit in the
|
||||||
|
* imposed memory limit.
|
||||||
|
*/
|
||||||
|
uint64_t max_entry_limit =
|
||||||
|
(zfs_spa_discard_memory_limit / sizeof (uint64_t)) >> 1;
|
||||||
|
|
||||||
|
uint64_t entries_in_sm =
|
||||||
|
space_map_length(vd->vdev_checkpoint_sm) / sizeof (uint64_t);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Iterate from the end of the space map towards the beginning,
|
||||||
|
* placing its entries on ms_freeing and removing them from the
|
||||||
|
* space map. The iteration stops if one of the following
|
||||||
|
* conditions is true:
|
||||||
|
*
|
||||||
|
* 1] We reached the beginning of the space map. At this point
|
||||||
|
* the space map should be completely empty and
|
||||||
|
* space_map_incremental_destroy should have returned 0.
|
||||||
|
* The next step would be to free and close the space map
|
||||||
|
* and remove its entry from its vdev's top zap. This allows
|
||||||
|
* spa_checkpoint_discard_thread() to move on to the next vdev.
|
||||||
|
*
|
||||||
|
* 2] We reached the memory limit (amount of memory used to hold
|
||||||
|
* space map entries in memory) and space_map_incremental_destroy
|
||||||
|
* returned EINTR. This means that there are entries remaining
|
||||||
|
* in the space map that will be cleared in a future invocation
|
||||||
|
* of this function by spa_checkpoint_discard_thread().
|
||||||
|
*/
|
||||||
|
spa_checkpoint_discard_sync_callback_arg_t sdc;
|
||||||
|
sdc.sdc_vd = vd;
|
||||||
|
sdc.sdc_txg = tx->tx_txg;
|
||||||
|
sdc.sdc_entry_limit = MIN(entries_in_sm, max_entry_limit);
|
||||||
|
|
||||||
|
uint64_t entries_before = entries_in_sm;
|
||||||
|
|
||||||
|
error = space_map_incremental_destroy(vd->vdev_checkpoint_sm,
|
||||||
|
spa_checkpoint_discard_sync_callback, &sdc, tx);
|
||||||
|
|
||||||
|
uint64_t entries_after =
|
||||||
|
space_map_length(vd->vdev_checkpoint_sm) / sizeof (uint64_t);
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
spa_checkpoint_accounting_verify(vd->vdev_spa);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
zfs_dbgmsg("discarding checkpoint: txg %llu, vdev id %d, "
|
||||||
|
"deleted %llu entries - %llu entries are left",
|
||||||
|
tx->tx_txg, vd->vdev_id, (entries_before - entries_after),
|
||||||
|
entries_after);
|
||||||
|
|
||||||
|
if (error != EINTR) {
|
||||||
|
if (error != 0) {
|
||||||
|
zfs_panic_recover("zfs: error %d was returned "
|
||||||
|
"while incrementally destroying the checkpoint "
|
||||||
|
"space map of vdev %llu\n",
|
||||||
|
error, vd->vdev_id);
|
||||||
|
}
|
||||||
|
ASSERT0(entries_after);
|
||||||
|
ASSERT0(vd->vdev_checkpoint_sm->sm_alloc);
|
||||||
|
ASSERT0(vd->vdev_checkpoint_sm->sm_length);
|
||||||
|
|
||||||
|
space_map_free(vd->vdev_checkpoint_sm, tx);
|
||||||
|
space_map_close(vd->vdev_checkpoint_sm);
|
||||||
|
vd->vdev_checkpoint_sm = NULL;
|
||||||
|
|
||||||
|
VERIFY0(zap_remove(vd->vdev_spa->spa_meta_objset,
|
||||||
|
vd->vdev_top_zap, VDEV_TOP_ZAP_POOL_CHECKPOINT_SM, tx));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean_t
|
||||||
|
spa_checkpoint_discard_is_done(spa_t *spa)
|
||||||
|
{
|
||||||
|
vdev_t *rvd = spa->spa_root_vdev;
|
||||||
|
|
||||||
|
ASSERT(!spa_has_checkpoint(spa));
|
||||||
|
ASSERT(spa_feature_is_active(spa, SPA_FEATURE_POOL_CHECKPOINT));
|
||||||
|
|
||||||
|
for (uint64_t c = 0; c < rvd->vdev_children; c++) {
|
||||||
|
if (rvd->vdev_child[c]->vdev_checkpoint_sm != NULL)
|
||||||
|
return (B_FALSE);
|
||||||
|
ASSERT0(rvd->vdev_child[c]->vdev_stat.vs_checkpoint_space);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (B_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
|
boolean_t
|
||||||
|
spa_checkpoint_discard_thread_check(void *arg, zthr_t *zthr)
|
||||||
|
{
|
||||||
|
spa_t *spa = arg;
|
||||||
|
|
||||||
|
if (!spa_feature_is_active(spa, SPA_FEATURE_POOL_CHECKPOINT))
|
||||||
|
return (B_FALSE);
|
||||||
|
|
||||||
|
if (spa_has_checkpoint(spa))
|
||||||
|
return (B_FALSE);
|
||||||
|
|
||||||
|
return (B_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
spa_checkpoint_discard_thread(void *arg, zthr_t *zthr)
|
||||||
|
{
|
||||||
|
spa_t *spa = arg;
|
||||||
|
vdev_t *rvd = spa->spa_root_vdev;
|
||||||
|
|
||||||
|
for (uint64_t c = 0; c < rvd->vdev_children; c++) {
|
||||||
|
vdev_t *vd = rvd->vdev_child[c];
|
||||||
|
|
||||||
|
while (vd->vdev_checkpoint_sm != NULL) {
|
||||||
|
space_map_t *checkpoint_sm = vd->vdev_checkpoint_sm;
|
||||||
|
int numbufs;
|
||||||
|
dmu_buf_t **dbp;
|
||||||
|
|
||||||
|
if (zthr_iscancelled(zthr))
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
ASSERT3P(vd->vdev_ops, !=, &vdev_indirect_ops);
|
||||||
|
|
||||||
|
uint64_t size = MIN(space_map_length(checkpoint_sm),
|
||||||
|
zfs_spa_discard_memory_limit);
|
||||||
|
uint64_t offset =
|
||||||
|
space_map_length(checkpoint_sm) - size;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ensure that the part of the space map that will
|
||||||
|
* be destroyed by the synctask, is prefetched in
|
||||||
|
* memory before the synctask runs.
|
||||||
|
*/
|
||||||
|
int error = dmu_buf_hold_array_by_bonus(
|
||||||
|
checkpoint_sm->sm_dbuf, offset, size,
|
||||||
|
B_TRUE, FTAG, &numbufs, &dbp);
|
||||||
|
if (error != 0) {
|
||||||
|
zfs_panic_recover("zfs: error %d was returned "
|
||||||
|
"while prefetching checkpoint space map "
|
||||||
|
"entries of vdev %llu\n",
|
||||||
|
error, vd->vdev_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
VERIFY0(dsl_sync_task(spa->spa_name, NULL,
|
||||||
|
spa_checkpoint_discard_thread_sync, vd,
|
||||||
|
0, ZFS_SPACE_CHECK_NONE));
|
||||||
|
|
||||||
|
dmu_buf_rele_array(dbp, numbufs, FTAG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VERIFY(spa_checkpoint_discard_is_done(spa));
|
||||||
|
VERIFY0(spa->spa_checkpoint_info.sci_dspace);
|
||||||
|
VERIFY0(dsl_sync_task(spa->spa_name, NULL,
|
||||||
|
spa_checkpoint_discard_complete_sync, spa,
|
||||||
|
0, ZFS_SPACE_CHECK_NONE));
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
|
static int
|
||||||
|
spa_checkpoint_check(void *arg, dmu_tx_t *tx)
|
||||||
|
{
|
||||||
|
spa_t *spa = dmu_tx_pool(tx)->dp_spa;
|
||||||
|
|
||||||
|
if (!spa_feature_is_enabled(spa, SPA_FEATURE_POOL_CHECKPOINT))
|
||||||
|
return (SET_ERROR(ENOTSUP));
|
||||||
|
|
||||||
|
if (!spa_top_vdevs_spacemap_addressable(spa))
|
||||||
|
return (SET_ERROR(ZFS_ERR_VDEV_TOO_BIG));
|
||||||
|
|
||||||
|
if (spa->spa_vdev_removal != NULL)
|
||||||
|
return (SET_ERROR(ZFS_ERR_DEVRM_IN_PROGRESS));
|
||||||
|
|
||||||
|
if (spa->spa_checkpoint_txg != 0)
|
||||||
|
return (SET_ERROR(ZFS_ERR_CHECKPOINT_EXISTS));
|
||||||
|
|
||||||
|
if (spa_feature_is_active(spa, SPA_FEATURE_POOL_CHECKPOINT))
|
||||||
|
return (SET_ERROR(ZFS_ERR_DISCARDING_CHECKPOINT));
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
|
static void
|
||||||
|
spa_checkpoint_sync(void *arg, dmu_tx_t *tx)
|
||||||
|
{
|
||||||
|
dsl_pool_t *dp = dmu_tx_pool(tx);
|
||||||
|
spa_t *spa = dp->dp_spa;
|
||||||
|
uberblock_t checkpoint = spa->spa_ubsync;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* At this point, there should not be a checkpoint in the MOS.
|
||||||
|
*/
|
||||||
|
ASSERT3U(zap_contains(spa_meta_objset(spa), DMU_POOL_DIRECTORY_OBJECT,
|
||||||
|
DMU_POOL_ZPOOL_CHECKPOINT), ==, ENOENT);
|
||||||
|
|
||||||
|
ASSERT0(spa->spa_checkpoint_info.sci_timestamp);
|
||||||
|
ASSERT0(spa->spa_checkpoint_info.sci_dspace);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Since the checkpointed uberblock is the one that just got synced
|
||||||
|
* (we use spa_ubsync), its txg must be equal to the txg number of
|
||||||
|
* the txg we are syncing, minus 1.
|
||||||
|
*/
|
||||||
|
ASSERT3U(checkpoint.ub_txg, ==, spa->spa_syncing_txg - 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Once the checkpoint is in place, we need to ensure that none of
|
||||||
|
* its blocks will be marked for reuse after it has been freed.
|
||||||
|
* When there is a checkpoint and a block is freed, we compare its
|
||||||
|
* birth txg to the txg of the checkpointed uberblock to see if the
|
||||||
|
* block is part of the checkpoint or not. Therefore, we have to set
|
||||||
|
* spa_checkpoint_txg before any frees happen in this txg (which is
|
||||||
|
* why this is done as an early_synctask as explained in the comment
|
||||||
|
* in spa_checkpoint()).
|
||||||
|
*/
|
||||||
|
spa->spa_checkpoint_txg = checkpoint.ub_txg;
|
||||||
|
spa->spa_checkpoint_info.sci_timestamp = checkpoint.ub_timestamp;
|
||||||
|
|
||||||
|
checkpoint.ub_checkpoint_txg = checkpoint.ub_txg;
|
||||||
|
VERIFY0(zap_add(spa->spa_dsl_pool->dp_meta_objset,
|
||||||
|
DMU_POOL_DIRECTORY_OBJECT, DMU_POOL_ZPOOL_CHECKPOINT,
|
||||||
|
sizeof (uint64_t), sizeof (uberblock_t) / sizeof (uint64_t),
|
||||||
|
&checkpoint, tx));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Increment the feature refcount and thus activate the feature.
|
||||||
|
* Note that the feature will be deactivated when we've
|
||||||
|
* completely discarded all checkpointed state (both vdev
|
||||||
|
* space maps and uberblock).
|
||||||
|
*/
|
||||||
|
spa_feature_incr(spa, SPA_FEATURE_POOL_CHECKPOINT, tx);
|
||||||
|
|
||||||
|
spa_history_log_internal(spa, "spa checkpoint", tx,
|
||||||
|
"checkpointed uberblock txg=%llu", checkpoint.ub_txg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create a checkpoint for the pool.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
spa_checkpoint(const char *pool)
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
spa_t *spa;
|
||||||
|
|
||||||
|
error = spa_open(pool, &spa, FTAG);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
|
mutex_enter(&spa->spa_vdev_top_lock);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Wait for current syncing txg to finish so the latest synced
|
||||||
|
* uberblock (spa_ubsync) has all the changes that we expect
|
||||||
|
* to see if we were to revert later to the checkpoint. In other
|
||||||
|
* words we want the checkpointed uberblock to include/reference
|
||||||
|
* all the changes that were pending at the time that we issued
|
||||||
|
* the checkpoint command.
|
||||||
|
*/
|
||||||
|
txg_wait_synced(spa_get_dsl(spa), 0);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* As the checkpointed uberblock references blocks from the previous
|
||||||
|
* txg (spa_ubsync) we want to ensure that are not freeing any of
|
||||||
|
* these blocks in the same txg that the following synctask will
|
||||||
|
* run. Thus, we run it as an early synctask, so the dirty changes
|
||||||
|
* that are synced to disk afterwards during zios and other synctasks
|
||||||
|
* do not reuse checkpointed blocks.
|
||||||
|
*/
|
||||||
|
error = dsl_early_sync_task(pool, spa_checkpoint_check,
|
||||||
|
spa_checkpoint_sync, NULL, 0, ZFS_SPACE_CHECK_NORMAL);
|
||||||
|
|
||||||
|
mutex_exit(&spa->spa_vdev_top_lock);
|
||||||
|
|
||||||
|
spa_close(spa, FTAG);
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
|
static int
|
||||||
|
spa_checkpoint_discard_check(void *arg, dmu_tx_t *tx)
|
||||||
|
{
|
||||||
|
spa_t *spa = dmu_tx_pool(tx)->dp_spa;
|
||||||
|
|
||||||
|
if (!spa_feature_is_active(spa, SPA_FEATURE_POOL_CHECKPOINT))
|
||||||
|
return (SET_ERROR(ZFS_ERR_NO_CHECKPOINT));
|
||||||
|
|
||||||
|
if (spa->spa_checkpoint_txg == 0)
|
||||||
|
return (SET_ERROR(ZFS_ERR_DISCARDING_CHECKPOINT));
|
||||||
|
|
||||||
|
VERIFY0(zap_contains(spa_meta_objset(spa),
|
||||||
|
DMU_POOL_DIRECTORY_OBJECT, DMU_POOL_ZPOOL_CHECKPOINT));
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
|
static void
|
||||||
|
spa_checkpoint_discard_sync(void *arg, dmu_tx_t *tx)
|
||||||
|
{
|
||||||
|
spa_t *spa = dmu_tx_pool(tx)->dp_spa;
|
||||||
|
|
||||||
|
VERIFY0(zap_remove(spa_meta_objset(spa), DMU_POOL_DIRECTORY_OBJECT,
|
||||||
|
DMU_POOL_ZPOOL_CHECKPOINT, tx));
|
||||||
|
|
||||||
|
spa->spa_checkpoint_txg = 0;
|
||||||
|
|
||||||
|
zthr_wakeup(spa->spa_checkpoint_discard_zthr);
|
||||||
|
|
||||||
|
spa_history_log_internal(spa, "spa discard checkpoint", tx,
|
||||||
|
"started discarding checkpointed state from the pool");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Discard the checkpoint from a pool.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
spa_checkpoint_discard(const char *pool)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Similarly to spa_checkpoint(), we want our synctask to run
|
||||||
|
* before any pending dirty data are written to disk so they
|
||||||
|
* won't end up in the checkpoint's data structures (e.g.
|
||||||
|
* ms_checkpointing and vdev_checkpoint_sm) and re-create any
|
||||||
|
* space maps that the discarding open-context thread has
|
||||||
|
* deleted.
|
||||||
|
* [see spa_discard_checkpoint_sync and spa_discard_checkpoint_thread]
|
||||||
|
*/
|
||||||
|
return (dsl_early_sync_task(pool, spa_checkpoint_discard_check,
|
||||||
|
spa_checkpoint_discard_sync, NULL, 0,
|
||||||
|
ZFS_SPACE_CHECK_DISCARD_CHECKPOINT));
|
||||||
|
}
|
@ -409,12 +409,15 @@ zfs_deadman_init()
|
|||||||
* These are the operations that call dsl_pool_adjustedsize() with the netfree
|
* These are the operations that call dsl_pool_adjustedsize() with the netfree
|
||||||
* argument set to TRUE.
|
* argument set to TRUE.
|
||||||
*
|
*
|
||||||
|
* Operations that are almost guaranteed to free up space in the absence of
|
||||||
|
* a pool checkpoint can use up to three quarters of the slop space
|
||||||
|
* (e.g zfs destroy).
|
||||||
|
*
|
||||||
* A very restricted set of operations are always permitted, regardless of
|
* A very restricted set of operations are always permitted, regardless of
|
||||||
* the amount of free space. These are the operations that call
|
* the amount of free space. These are the operations that call
|
||||||
* dsl_sync_task(ZFS_SPACE_CHECK_NONE), e.g. "zfs destroy". If these
|
* dsl_sync_task(ZFS_SPACE_CHECK_NONE). If these operations result in a net
|
||||||
* operations result in a net increase in the amount of space used,
|
* increase in the amount of space used, it is possible to run the pool
|
||||||
* it is possible to run the pool completely out of space, causing it to
|
* completely out of space, causing it to be permanently read-only.
|
||||||
* be permanently read-only.
|
|
||||||
*
|
*
|
||||||
* Note that on very small pools, the slop space will be larger than
|
* Note that on very small pools, the slop space will be larger than
|
||||||
* 3.2%, in an effort to have it be at least spa_min_slop (128MB),
|
* 3.2%, in an effort to have it be at least spa_min_slop (128MB),
|
||||||
@ -1834,6 +1837,12 @@ spa_get_dspace(spa_t *spa)
|
|||||||
return (spa->spa_dspace);
|
return (spa->spa_dspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t
|
||||||
|
spa_get_checkpoint_space(spa_t *spa)
|
||||||
|
{
|
||||||
|
return (spa->spa_checkpoint_info.sci_dspace);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
spa_update_dspace(spa_t *spa)
|
spa_update_dspace(spa_t *spa)
|
||||||
{
|
{
|
||||||
@ -2163,7 +2172,8 @@ spa_writeable(spa_t *spa)
|
|||||||
boolean_t
|
boolean_t
|
||||||
spa_has_pending_synctask(spa_t *spa)
|
spa_has_pending_synctask(spa_t *spa)
|
||||||
{
|
{
|
||||||
return (!txg_all_lists_empty(&spa->spa_dsl_pool->dp_sync_tasks));
|
return (!txg_all_lists_empty(&spa->spa_dsl_pool->dp_sync_tasks) ||
|
||||||
|
!txg_all_lists_empty(&spa->spa_dsl_pool->dp_early_sync_tasks));
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -2319,3 +2329,60 @@ spa_set_missing_tvds(spa_t *spa, uint64_t missing)
|
|||||||
{
|
{
|
||||||
spa->spa_missing_tvds = missing;
|
spa->spa_missing_tvds = missing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean_t
|
||||||
|
spa_top_vdevs_spacemap_addressable(spa_t *spa)
|
||||||
|
{
|
||||||
|
vdev_t *rvd = spa->spa_root_vdev;
|
||||||
|
for (uint64_t c = 0; c < rvd->vdev_children; c++) {
|
||||||
|
if (!vdev_is_spacemap_addressable(rvd->vdev_child[c]))
|
||||||
|
return (B_FALSE);
|
||||||
|
}
|
||||||
|
return (B_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean_t
|
||||||
|
spa_has_checkpoint(spa_t *spa)
|
||||||
|
{
|
||||||
|
return (spa->spa_checkpoint_txg != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean_t
|
||||||
|
spa_importing_readonly_checkpoint(spa_t *spa)
|
||||||
|
{
|
||||||
|
return ((spa->spa_import_flags & ZFS_IMPORT_CHECKPOINT) &&
|
||||||
|
spa->spa_mode == FREAD);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t
|
||||||
|
spa_min_claim_txg(spa_t *spa)
|
||||||
|
{
|
||||||
|
uint64_t checkpoint_txg = spa->spa_uberblock.ub_checkpoint_txg;
|
||||||
|
|
||||||
|
if (checkpoint_txg != 0)
|
||||||
|
return (checkpoint_txg + 1);
|
||||||
|
|
||||||
|
return (spa->spa_first_txg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If there is a checkpoint, async destroys may consume more space from
|
||||||
|
* the pool instead of freeing it. In an attempt to save the pool from
|
||||||
|
* getting suspended when it is about to run out of space, we stop
|
||||||
|
* processing async destroys.
|
||||||
|
*/
|
||||||
|
boolean_t
|
||||||
|
spa_suspend_async_destroy(spa_t *spa)
|
||||||
|
{
|
||||||
|
dsl_pool_t *dp = spa_get_dsl(spa);
|
||||||
|
|
||||||
|
uint64_t unreserved = dsl_pool_unreserved_space(dp,
|
||||||
|
ZFS_SPACE_CHECK_EXTRA_RESERVED);
|
||||||
|
uint64_t used = dsl_dir_phys(dp->dp_root_dir)->dd_used_bytes;
|
||||||
|
uint64_t avail = (unreserved > used) ? (unreserved - used) : 0;
|
||||||
|
|
||||||
|
if (spa_has_checkpoint(spa) && avail == 0)
|
||||||
|
return (B_TRUE);
|
||||||
|
|
||||||
|
return (B_FALSE);
|
||||||
|
}
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
* Use is subject to license terms.
|
* Use is subject to license terms.
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2016 by Delphix. All rights reserved.
|
* Copyright (c) 2012, 2017 by Delphix. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/zfs_context.h>
|
#include <sys/zfs_context.h>
|
||||||
@ -40,14 +40,13 @@
|
|||||||
SYSCTL_DECL(_vfs_zfs);
|
SYSCTL_DECL(_vfs_zfs);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
* Note on space map block size:
|
||||||
|
*
|
||||||
* The data for a given space map can be kept on blocks of any size.
|
* The data for a given space map can be kept on blocks of any size.
|
||||||
* Larger blocks entail fewer i/o operations, but they also cause the
|
* Larger blocks entail fewer i/o operations, but they also cause the
|
||||||
* DMU to keep more data in-core, and also to waste more i/o bandwidth
|
* DMU to keep more data in-core, and also to waste more i/o bandwidth
|
||||||
* when only a few blocks have changed since the last transaction group.
|
* when only a few blocks have changed since the last transaction group.
|
||||||
*/
|
*/
|
||||||
int space_map_blksz = (1 << 12);
|
|
||||||
SYSCTL_INT(_vfs_zfs, OID_AUTO, space_map_blksz, CTLFLAG_RDTUN, &space_map_blksz, 0,
|
|
||||||
"Maximum block size for space map. Must be power of 2 and greater than 4096.");
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Iterate through the space map, invoking the callback on each (non-debug)
|
* Iterate through the space map, invoking the callback on each (non-debug)
|
||||||
@ -109,6 +108,137 @@ space_map_iterate(space_map_t *sm, sm_cb_t callback, void *arg)
|
|||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Note: This function performs destructive actions - specifically
|
||||||
|
* it deletes entries from the end of the space map. Thus, callers
|
||||||
|
* should ensure that they are holding the appropriate locks for
|
||||||
|
* the space map that they provide.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
space_map_incremental_destroy(space_map_t *sm, sm_cb_t callback, void *arg,
|
||||||
|
dmu_tx_t *tx)
|
||||||
|
{
|
||||||
|
uint64_t bufsize, len;
|
||||||
|
uint64_t *entry_map;
|
||||||
|
int error = 0;
|
||||||
|
|
||||||
|
len = space_map_length(sm);
|
||||||
|
bufsize = MAX(sm->sm_blksz, SPA_MINBLOCKSIZE);
|
||||||
|
entry_map = zio_buf_alloc(bufsize);
|
||||||
|
|
||||||
|
dmu_buf_will_dirty(sm->sm_dbuf, tx);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Since we can't move the starting offset of the space map
|
||||||
|
* (e.g there are reference on-disk pointing to it), we destroy
|
||||||
|
* its entries incrementally starting from the end.
|
||||||
|
*
|
||||||
|
* The logic that follows is basically the same as the one used
|
||||||
|
* in space_map_iterate() but it traverses the space map
|
||||||
|
* backwards:
|
||||||
|
*
|
||||||
|
* 1] We figure out the size of the buffer that we want to use
|
||||||
|
* to read the on-disk space map entries.
|
||||||
|
* 2] We figure out the offset at the end of the space map where
|
||||||
|
* we will start reading entries into our buffer.
|
||||||
|
* 3] We read the on-disk entries into the buffer.
|
||||||
|
* 4] We iterate over the entries from end to beginning calling
|
||||||
|
* the callback function on each one. As we move from entry
|
||||||
|
* to entry we decrease the size of the space map, deleting
|
||||||
|
* effectively each entry.
|
||||||
|
* 5] If there are no more entries in the space map or the
|
||||||
|
* callback returns a value other than 0, we stop iterating
|
||||||
|
* over the space map. If there are entries remaining and
|
||||||
|
* the callback returned zero we go back to step [1].
|
||||||
|
*/
|
||||||
|
uint64_t offset = 0, size = 0;
|
||||||
|
while (len > 0 && error == 0) {
|
||||||
|
size = MIN(bufsize, len);
|
||||||
|
|
||||||
|
VERIFY(P2PHASE(size, sizeof (uint64_t)) == 0);
|
||||||
|
VERIFY3U(size, >, 0);
|
||||||
|
ASSERT3U(sm->sm_blksz, !=, 0);
|
||||||
|
|
||||||
|
offset = len - size;
|
||||||
|
|
||||||
|
IMPLY(bufsize > len, offset == 0);
|
||||||
|
IMPLY(bufsize == len, offset == 0);
|
||||||
|
IMPLY(bufsize < len, offset > 0);
|
||||||
|
|
||||||
|
|
||||||
|
EQUIV(size == len, offset == 0);
|
||||||
|
IMPLY(size < len, bufsize < len);
|
||||||
|
|
||||||
|
dprintf("object=%llu offset=%llx size=%llx\n",
|
||||||
|
space_map_object(sm), offset, size);
|
||||||
|
|
||||||
|
error = dmu_read(sm->sm_os, space_map_object(sm),
|
||||||
|
offset, size, entry_map, DMU_READ_PREFETCH);
|
||||||
|
if (error != 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
uint64_t num_entries = size / sizeof (uint64_t);
|
||||||
|
|
||||||
|
ASSERT3U(num_entries, >, 0);
|
||||||
|
|
||||||
|
while (num_entries > 0) {
|
||||||
|
uint64_t e, entry_offset, entry_size;
|
||||||
|
maptype_t type;
|
||||||
|
|
||||||
|
e = entry_map[num_entries - 1];
|
||||||
|
|
||||||
|
ASSERT3U(num_entries, >, 0);
|
||||||
|
ASSERT0(error);
|
||||||
|
|
||||||
|
if (SM_DEBUG_DECODE(e)) {
|
||||||
|
sm->sm_phys->smp_objsize -= sizeof (uint64_t);
|
||||||
|
space_map_update(sm);
|
||||||
|
len -= sizeof (uint64_t);
|
||||||
|
num_entries--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
type = SM_TYPE_DECODE(e);
|
||||||
|
entry_offset = (SM_OFFSET_DECODE(e) << sm->sm_shift) +
|
||||||
|
sm->sm_start;
|
||||||
|
entry_size = SM_RUN_DECODE(e) << sm->sm_shift;
|
||||||
|
|
||||||
|
VERIFY0(P2PHASE(entry_offset, 1ULL << sm->sm_shift));
|
||||||
|
VERIFY0(P2PHASE(entry_size, 1ULL << sm->sm_shift));
|
||||||
|
VERIFY3U(entry_offset, >=, sm->sm_start);
|
||||||
|
VERIFY3U(entry_offset + entry_size, <=,
|
||||||
|
sm->sm_start + sm->sm_size);
|
||||||
|
|
||||||
|
error = callback(type, entry_offset, entry_size, arg);
|
||||||
|
if (error != 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (type == SM_ALLOC)
|
||||||
|
sm->sm_phys->smp_alloc -= entry_size;
|
||||||
|
else
|
||||||
|
sm->sm_phys->smp_alloc += entry_size;
|
||||||
|
|
||||||
|
sm->sm_phys->smp_objsize -= sizeof (uint64_t);
|
||||||
|
space_map_update(sm);
|
||||||
|
len -= sizeof (uint64_t);
|
||||||
|
num_entries--;
|
||||||
|
}
|
||||||
|
IMPLY(error == 0, num_entries == 0);
|
||||||
|
EQUIV(offset == 0 && error == 0, len == 0 && num_entries == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len == 0) {
|
||||||
|
ASSERT0(error);
|
||||||
|
ASSERT0(offset);
|
||||||
|
ASSERT0(sm->sm_length);
|
||||||
|
ASSERT0(sm->sm_phys->smp_objsize);
|
||||||
|
ASSERT0(sm->sm_alloc);
|
||||||
|
}
|
||||||
|
|
||||||
|
zio_buf_free(entry_map, bufsize);
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
|
||||||
typedef struct space_map_load_arg {
|
typedef struct space_map_load_arg {
|
||||||
space_map_t *smla_sm;
|
space_map_t *smla_sm;
|
||||||
range_tree_t *smla_rt;
|
range_tree_t *smla_rt;
|
||||||
@ -283,7 +413,7 @@ space_map_write(space_map_t *sm, range_tree_t *rt, maptype_t maptype,
|
|||||||
*/
|
*/
|
||||||
sm->sm_phys->smp_object = sm->sm_object;
|
sm->sm_phys->smp_object = sm->sm_object;
|
||||||
|
|
||||||
if (range_tree_space(rt) == 0) {
|
if (range_tree_is_empty(rt)) {
|
||||||
VERIFY3U(sm->sm_object, ==, sm->sm_phys->smp_object);
|
VERIFY3U(sm->sm_object, ==, sm->sm_phys->smp_object);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -417,7 +547,7 @@ space_map_close(space_map_t *sm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
space_map_truncate(space_map_t *sm, dmu_tx_t *tx)
|
space_map_truncate(space_map_t *sm, int blocksize, dmu_tx_t *tx)
|
||||||
{
|
{
|
||||||
objset_t *os = sm->sm_os;
|
objset_t *os = sm->sm_os;
|
||||||
spa_t *spa = dmu_objset_spa(os);
|
spa_t *spa = dmu_objset_spa(os);
|
||||||
@ -439,7 +569,7 @@ space_map_truncate(space_map_t *sm, dmu_tx_t *tx)
|
|||||||
*/
|
*/
|
||||||
if ((spa_feature_is_enabled(spa, SPA_FEATURE_SPACEMAP_HISTOGRAM) &&
|
if ((spa_feature_is_enabled(spa, SPA_FEATURE_SPACEMAP_HISTOGRAM) &&
|
||||||
doi.doi_bonus_size != sizeof (space_map_phys_t)) ||
|
doi.doi_bonus_size != sizeof (space_map_phys_t)) ||
|
||||||
doi.doi_data_block_size != space_map_blksz) {
|
doi.doi_data_block_size != blocksize) {
|
||||||
zfs_dbgmsg("txg %llu, spa %s, sm %p, reallocating "
|
zfs_dbgmsg("txg %llu, spa %s, sm %p, reallocating "
|
||||||
"object[%llu]: old bonus %u, old blocksz %u",
|
"object[%llu]: old bonus %u, old blocksz %u",
|
||||||
dmu_tx_get_txg(tx), spa_name(spa), sm, sm->sm_object,
|
dmu_tx_get_txg(tx), spa_name(spa), sm, sm->sm_object,
|
||||||
@ -448,7 +578,7 @@ space_map_truncate(space_map_t *sm, dmu_tx_t *tx)
|
|||||||
space_map_free(sm, tx);
|
space_map_free(sm, tx);
|
||||||
dmu_buf_rele(sm->sm_dbuf, sm);
|
dmu_buf_rele(sm->sm_dbuf, sm);
|
||||||
|
|
||||||
sm->sm_object = space_map_alloc(sm->sm_os, tx);
|
sm->sm_object = space_map_alloc(sm->sm_os, blocksize, tx);
|
||||||
VERIFY0(space_map_open_impl(sm));
|
VERIFY0(space_map_open_impl(sm));
|
||||||
} else {
|
} else {
|
||||||
VERIFY0(dmu_free_range(os, space_map_object(sm), 0, -1ULL, tx));
|
VERIFY0(dmu_free_range(os, space_map_object(sm), 0, -1ULL, tx));
|
||||||
@ -481,7 +611,7 @@ space_map_update(space_map_t *sm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
space_map_alloc(objset_t *os, dmu_tx_t *tx)
|
space_map_alloc(objset_t *os, int blocksize, dmu_tx_t *tx)
|
||||||
{
|
{
|
||||||
spa_t *spa = dmu_objset_spa(os);
|
spa_t *spa = dmu_objset_spa(os);
|
||||||
uint64_t object;
|
uint64_t object;
|
||||||
@ -495,8 +625,7 @@ space_map_alloc(objset_t *os, dmu_tx_t *tx)
|
|||||||
bonuslen = SPACE_MAP_SIZE_V0;
|
bonuslen = SPACE_MAP_SIZE_V0;
|
||||||
}
|
}
|
||||||
|
|
||||||
object = dmu_object_alloc(os,
|
object = dmu_object_alloc(os, DMU_OT_SPACE_MAP, blocksize,
|
||||||
DMU_OT_SPACE_MAP, space_map_blksz,
|
|
||||||
DMU_OT_SPACE_MAP_HEADER, bonuslen, tx);
|
DMU_OT_SPACE_MAP_HEADER, bonuslen, tx);
|
||||||
|
|
||||||
return (object);
|
return (object);
|
||||||
|
@ -333,6 +333,7 @@ typedef struct dmu_buf {
|
|||||||
#define DMU_POOL_REMOVING "com.delphix:removing"
|
#define DMU_POOL_REMOVING "com.delphix:removing"
|
||||||
#define DMU_POOL_OBSOLETE_BPOBJ "com.delphix:obsolete_bpobj"
|
#define DMU_POOL_OBSOLETE_BPOBJ "com.delphix:obsolete_bpobj"
|
||||||
#define DMU_POOL_CONDENSING_INDIRECT "com.delphix:condensing_indirect"
|
#define DMU_POOL_CONDENSING_INDIRECT "com.delphix:condensing_indirect"
|
||||||
|
#define DMU_POOL_ZPOOL_CHECKPOINT "com.delphix:zpool_checkpoint"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate an object from this objset. The range of object numbers
|
* Allocate an object from this objset. The range of object numbers
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
* Copyright (c) 2012, 2016 by Delphix. All rights reserved.
|
* Copyright (c) 2012, 2017 by Delphix. All rights reserved.
|
||||||
* Copyright (c) 2014, Joyent, Inc. All rights reserved.
|
* Copyright (c) 2014, Joyent, Inc. All rights reserved.
|
||||||
* Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
|
* Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
|
||||||
*/
|
*/
|
||||||
@ -134,6 +134,7 @@ uint64_t dsl_dir_create_sync(dsl_pool_t *dp, dsl_dir_t *pds,
|
|||||||
const char *name, dmu_tx_t *tx);
|
const char *name, dmu_tx_t *tx);
|
||||||
|
|
||||||
uint64_t dsl_dir_get_used(dsl_dir_t *dd);
|
uint64_t dsl_dir_get_used(dsl_dir_t *dd);
|
||||||
|
uint64_t dsl_dir_get_compressed(dsl_dir_t *dd);
|
||||||
uint64_t dsl_dir_get_quota(dsl_dir_t *dd);
|
uint64_t dsl_dir_get_quota(dsl_dir_t *dd);
|
||||||
uint64_t dsl_dir_get_reservation(dsl_dir_t *dd);
|
uint64_t dsl_dir_get_reservation(dsl_dir_t *dd);
|
||||||
uint64_t dsl_dir_get_compressratio(dsl_dir_t *dd);
|
uint64_t dsl_dir_get_compressratio(dsl_dir_t *dd);
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include <sys/bpobj.h>
|
#include <sys/bpobj.h>
|
||||||
#include <sys/bptree.h>
|
#include <sys/bptree.h>
|
||||||
#include <sys/rrwlock.h>
|
#include <sys/rrwlock.h>
|
||||||
|
#include <sys/dsl_synctask.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -122,6 +123,7 @@ typedef struct dsl_pool {
|
|||||||
txg_list_t dp_dirty_zilogs;
|
txg_list_t dp_dirty_zilogs;
|
||||||
txg_list_t dp_dirty_dirs;
|
txg_list_t dp_dirty_dirs;
|
||||||
txg_list_t dp_sync_tasks;
|
txg_list_t dp_sync_tasks;
|
||||||
|
txg_list_t dp_early_sync_tasks;
|
||||||
taskq_t *dp_sync_taskq;
|
taskq_t *dp_sync_taskq;
|
||||||
taskq_t *dp_zil_clean_taskq;
|
taskq_t *dp_zil_clean_taskq;
|
||||||
|
|
||||||
@ -144,7 +146,9 @@ dsl_pool_t *dsl_pool_create(spa_t *spa, nvlist_t *zplprops, uint64_t txg);
|
|||||||
void dsl_pool_sync(dsl_pool_t *dp, uint64_t txg);
|
void dsl_pool_sync(dsl_pool_t *dp, uint64_t txg);
|
||||||
void dsl_pool_sync_done(dsl_pool_t *dp, uint64_t txg);
|
void dsl_pool_sync_done(dsl_pool_t *dp, uint64_t txg);
|
||||||
int dsl_pool_sync_context(dsl_pool_t *dp);
|
int dsl_pool_sync_context(dsl_pool_t *dp);
|
||||||
uint64_t dsl_pool_adjustedsize(dsl_pool_t *dp, boolean_t netfree);
|
uint64_t dsl_pool_adjustedsize(dsl_pool_t *dp, zfs_space_check_t slop_policy);
|
||||||
|
uint64_t dsl_pool_unreserved_space(dsl_pool_t *dp,
|
||||||
|
zfs_space_check_t slop_policy);
|
||||||
void dsl_pool_dirty_space(dsl_pool_t *dp, int64_t space, dmu_tx_t *tx);
|
void dsl_pool_dirty_space(dsl_pool_t *dp, int64_t space, dmu_tx_t *tx);
|
||||||
void dsl_pool_undirty_space(dsl_pool_t *dp, int64_t space, uint64_t txg);
|
void dsl_pool_undirty_space(dsl_pool_t *dp, int64_t space, uint64_t txg);
|
||||||
void dsl_free(dsl_pool_t *dp, uint64_t txg, const blkptr_t *bpp);
|
void dsl_free(dsl_pool_t *dp, uint64_t txg, const blkptr_t *bpp);
|
||||||
@ -155,6 +159,8 @@ void dsl_pool_upgrade_clones(dsl_pool_t *dp, dmu_tx_t *tx);
|
|||||||
void dsl_pool_upgrade_dir_clones(dsl_pool_t *dp, dmu_tx_t *tx);
|
void dsl_pool_upgrade_dir_clones(dsl_pool_t *dp, dmu_tx_t *tx);
|
||||||
void dsl_pool_mos_diduse_space(dsl_pool_t *dp,
|
void dsl_pool_mos_diduse_space(dsl_pool_t *dp,
|
||||||
int64_t used, int64_t comp, int64_t uncomp);
|
int64_t used, int64_t comp, int64_t uncomp);
|
||||||
|
void dsl_pool_ckpoint_diduse_space(dsl_pool_t *dp,
|
||||||
|
int64_t used, int64_t comp, int64_t uncomp);
|
||||||
void dsl_pool_config_enter(dsl_pool_t *dp, void *tag);
|
void dsl_pool_config_enter(dsl_pool_t *dp, void *tag);
|
||||||
void dsl_pool_config_enter_prio(dsl_pool_t *dp, void *tag);
|
void dsl_pool_config_enter_prio(dsl_pool_t *dp, void *tag);
|
||||||
void dsl_pool_config_exit(dsl_pool_t *dp, void *tag);
|
void dsl_pool_config_exit(dsl_pool_t *dp, void *tag);
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
* Copyright (c) 2012, 2014 by Delphix. All rights reserved.
|
* Copyright (c) 2012, 2017 by Delphix. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _SYS_DSL_SYNCTASK_H
|
#ifndef _SYS_DSL_SYNCTASK_H
|
||||||
@ -57,14 +57,41 @@ typedef enum zfs_space_check {
|
|||||||
ZFS_SPACE_CHECK_RESERVED,
|
ZFS_SPACE_CHECK_RESERVED,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* No space check is performed. Only operations which we expect to
|
* Space check allows use of three quarters of the slop space.
|
||||||
* result in a net reduction in space should use this
|
* If there is less than 0.8% free space, the operation will
|
||||||
* (e.g. "zfs destroy". Setting quotas & reservations also uses
|
* fail.
|
||||||
* this because it needs to circumvent the quota/reservation checks).
|
*/
|
||||||
|
ZFS_SPACE_CHECK_EXTRA_RESERVED,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* In all cases "zfs destroy" is expected to result in an net
|
||||||
|
* reduction of space, except one. When the pool has a
|
||||||
|
* checkpoint, space freed by "zfs destroy" will not actually
|
||||||
|
* free anything internally. Thus, it starts failing after
|
||||||
|
* three quarters of the slop space is exceeded.
|
||||||
|
*/
|
||||||
|
ZFS_SPACE_CHECK_DESTROY = ZFS_SPACE_CHECK_EXTRA_RESERVED,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A channel program can run a "zfs destroy" as part of its
|
||||||
|
* script and therefore has the same space_check policy when
|
||||||
|
* being evaluated.
|
||||||
|
*/
|
||||||
|
ZFS_SPACE_CHECK_ZCP_EVAL = ZFS_SPACE_CHECK_DESTROY,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* No space check is performed. This level of space check should
|
||||||
|
* be used cautiously as operations that use it can even run when
|
||||||
|
* 0.8% capacity is left for use. In this scenario, if there is a
|
||||||
|
* checkpoint, async destroys are suspended and any kind of freeing
|
||||||
|
* can potentially add space instead of freeing it.
|
||||||
*
|
*
|
||||||
* See also the comments above spa_slop_shift.
|
* See also the comments above spa_slop_shift.
|
||||||
*/
|
*/
|
||||||
ZFS_SPACE_CHECK_NONE,
|
ZFS_SPACE_CHECK_NONE,
|
||||||
|
|
||||||
|
ZFS_SPACE_CHECK_DISCARD_CHECKPOINT = ZFS_SPACE_CHECK_NONE,
|
||||||
|
|
||||||
} zfs_space_check_t;
|
} zfs_space_check_t;
|
||||||
|
|
||||||
typedef struct dsl_sync_task {
|
typedef struct dsl_sync_task {
|
||||||
@ -85,6 +112,10 @@ int dsl_sync_task(const char *, dsl_checkfunc_t *,
|
|||||||
dsl_syncfunc_t *, void *, int, zfs_space_check_t);
|
dsl_syncfunc_t *, void *, int, zfs_space_check_t);
|
||||||
void dsl_sync_task_nowait(struct dsl_pool *, dsl_syncfunc_t *,
|
void dsl_sync_task_nowait(struct dsl_pool *, dsl_syncfunc_t *,
|
||||||
void *, int, zfs_space_check_t, dmu_tx_t *);
|
void *, int, zfs_space_check_t, dmu_tx_t *);
|
||||||
|
int dsl_early_sync_task(const char *, dsl_checkfunc_t *,
|
||||||
|
dsl_syncfunc_t *, void *, int, zfs_space_check_t);
|
||||||
|
void dsl_early_sync_task_nowait(struct dsl_pool *, dsl_syncfunc_t *,
|
||||||
|
void *, int, zfs_space_check_t, dmu_tx_t *);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
* Copyright (c) 2011, 2016 by Delphix. All rights reserved.
|
* Copyright (c) 2011, 2017 by Delphix. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _SYS_METASLAB_H
|
#ifndef _SYS_METASLAB_H
|
||||||
@ -69,8 +69,8 @@ int metaslab_alloc(spa_t *, metaslab_class_t *, uint64_t,
|
|||||||
int metaslab_alloc_dva(spa_t *, metaslab_class_t *, uint64_t,
|
int metaslab_alloc_dva(spa_t *, metaslab_class_t *, uint64_t,
|
||||||
dva_t *, int, dva_t *, uint64_t, int, zio_alloc_list_t *);
|
dva_t *, int, dva_t *, uint64_t, int, zio_alloc_list_t *);
|
||||||
void metaslab_free(spa_t *, const blkptr_t *, uint64_t, boolean_t);
|
void metaslab_free(spa_t *, const blkptr_t *, uint64_t, boolean_t);
|
||||||
void metaslab_free_concrete(vdev_t *, uint64_t, uint64_t, uint64_t);
|
void metaslab_free_concrete(vdev_t *, uint64_t, uint64_t, boolean_t);
|
||||||
void metaslab_free_dva(spa_t *, const dva_t *, uint64_t);
|
void metaslab_free_dva(spa_t *, const dva_t *, boolean_t);
|
||||||
void metaslab_free_impl_cb(uint64_t, vdev_t *, uint64_t, uint64_t, void *);
|
void metaslab_free_impl_cb(uint64_t, vdev_t *, uint64_t, uint64_t, void *);
|
||||||
void metaslab_unalloc_dva(spa_t *, const dva_t *, uint64_t);
|
void metaslab_unalloc_dva(spa_t *, const dva_t *, uint64_t);
|
||||||
int metaslab_claim(spa_t *, const blkptr_t *, uint64_t);
|
int metaslab_claim(spa_t *, const blkptr_t *, uint64_t);
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
|
* Copyright (c) 2011, 2017 by Delphix. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _SYS_METASLAB_IMPL_H
|
#ifndef _SYS_METASLAB_IMPL_H
|
||||||
@ -256,16 +256,16 @@ struct metaslab_group {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Each metaslab maintains a set of in-core trees to track metaslab
|
* Each metaslab maintains a set of in-core trees to track metaslab
|
||||||
* operations. The in-core free tree (ms_tree) contains the list of
|
* operations. The in-core free tree (ms_allocatable) contains the list of
|
||||||
* free segments which are eligible for allocation. As blocks are
|
* free segments which are eligible for allocation. As blocks are
|
||||||
* allocated, the allocated segment are removed from the ms_tree and
|
* allocated, the allocated segment are removed from the ms_allocatable and
|
||||||
* added to a per txg allocation tree (ms_alloctree). As blocks are
|
* added to a per txg allocation tree (ms_allocating). As blocks are
|
||||||
* freed, they are added to the free tree (ms_freeingtree). These trees
|
* freed, they are added to the free tree (ms_freeing). These trees
|
||||||
* allow us to process all allocations and frees in syncing context
|
* allow us to process all allocations and frees in syncing context
|
||||||
* where it is safe to update the on-disk space maps. An additional set
|
* where it is safe to update the on-disk space maps. An additional set
|
||||||
* of in-core trees is maintained to track deferred frees
|
* of in-core trees is maintained to track deferred frees
|
||||||
* (ms_defertree). Once a block is freed it will move from the
|
* (ms_defer). Once a block is freed it will move from the
|
||||||
* ms_freedtree to the ms_defertree. A deferred free means that a block
|
* ms_freed to the ms_defer tree. A deferred free means that a block
|
||||||
* has been freed but cannot be used by the pool until TXG_DEFER_SIZE
|
* has been freed but cannot be used by the pool until TXG_DEFER_SIZE
|
||||||
* transactions groups later. For example, a block that is freed in txg
|
* transactions groups later. For example, a block that is freed in txg
|
||||||
* 50 will not be available for reallocation until txg 52 (50 +
|
* 50 will not be available for reallocation until txg 52 (50 +
|
||||||
@ -279,14 +279,14 @@ struct metaslab_group {
|
|||||||
* ALLOCATE
|
* ALLOCATE
|
||||||
* |
|
* |
|
||||||
* V
|
* V
|
||||||
* free segment (ms_tree) -----> ms_alloctree[4] ----> (write to space map)
|
* free segment (ms_allocatable) -> ms_allocating[4] -> (write to space map)
|
||||||
* ^
|
* ^
|
||||||
* | ms_freeingtree <--- FREE
|
* | ms_freeing <--- FREE
|
||||||
* | |
|
* | |
|
||||||
* | v
|
* | v
|
||||||
* | ms_freedtree
|
* | ms_freed
|
||||||
* | |
|
* | |
|
||||||
* +-------- ms_defertree[2] <-------+---------> (write to space map)
|
* +-------- ms_defer[2] <-------+-------> (write to space map)
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Each metaslab's space is tracked in a single space map in the MOS,
|
* Each metaslab's space is tracked in a single space map in the MOS,
|
||||||
@ -297,8 +297,8 @@ struct metaslab_group {
|
|||||||
* To load the in-core free tree we read the space map from disk. This
|
* To load the in-core free tree we read the space map from disk. This
|
||||||
* object contains a series of alloc and free records that are combined
|
* object contains a series of alloc and free records that are combined
|
||||||
* to make up the list of all free segments in this metaslab. These
|
* to make up the list of all free segments in this metaslab. These
|
||||||
* segments are represented in-core by the ms_tree and are stored in an
|
* segments are represented in-core by the ms_allocatable and are stored
|
||||||
* AVL tree.
|
* in an AVL tree.
|
||||||
*
|
*
|
||||||
* As the space map grows (as a result of the appends) it will
|
* As the space map grows (as a result of the appends) it will
|
||||||
* eventually become space-inefficient. When the metaslab's in-core
|
* eventually become space-inefficient. When the metaslab's in-core
|
||||||
@ -318,20 +318,22 @@ struct metaslab {
|
|||||||
uint64_t ms_size;
|
uint64_t ms_size;
|
||||||
uint64_t ms_fragmentation;
|
uint64_t ms_fragmentation;
|
||||||
|
|
||||||
range_tree_t *ms_alloctree[TXG_SIZE];
|
range_tree_t *ms_allocating[TXG_SIZE];
|
||||||
range_tree_t *ms_tree;
|
range_tree_t *ms_allocatable;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The following range trees are accessed only from syncing context.
|
* The following range trees are accessed only from syncing context.
|
||||||
* ms_free*tree only have entries while syncing, and are empty
|
* ms_free*tree only have entries while syncing, and are empty
|
||||||
* between syncs.
|
* between syncs.
|
||||||
*/
|
*/
|
||||||
range_tree_t *ms_freeingtree; /* to free this syncing txg */
|
range_tree_t *ms_freeing; /* to free this syncing txg */
|
||||||
range_tree_t *ms_freedtree; /* already freed this syncing txg */
|
range_tree_t *ms_freed; /* already freed this syncing txg */
|
||||||
range_tree_t *ms_defertree[TXG_DEFER_SIZE];
|
range_tree_t *ms_defer[TXG_DEFER_SIZE];
|
||||||
|
range_tree_t *ms_checkpointing; /* to add to the checkpoint */
|
||||||
|
|
||||||
boolean_t ms_condensing; /* condensing? */
|
boolean_t ms_condensing; /* condensing? */
|
||||||
boolean_t ms_condense_wanted;
|
boolean_t ms_condense_wanted;
|
||||||
|
uint64_t ms_condense_checked_txg;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We must hold both ms_lock and ms_group->mg_lock in order to
|
* We must hold both ms_lock and ms_group->mg_lock in order to
|
||||||
@ -357,11 +359,12 @@ struct metaslab {
|
|||||||
/*
|
/*
|
||||||
* The metaslab block allocators can optionally use a size-ordered
|
* The metaslab block allocators can optionally use a size-ordered
|
||||||
* range tree and/or an array of LBAs. Not all allocators use
|
* range tree and/or an array of LBAs. Not all allocators use
|
||||||
* this functionality. The ms_size_tree should always contain the
|
* this functionality. The ms_allocatable_by_size should always
|
||||||
* same number of segments as the ms_tree. The only difference
|
* contain the same number of segments as the ms_allocatable. The
|
||||||
* is that the ms_size_tree is ordered by segment sizes.
|
* only difference is that the ms_allocatable_by_size is ordered by
|
||||||
|
* segment sizes.
|
||||||
*/
|
*/
|
||||||
avl_tree_t ms_size_tree;
|
avl_tree_t ms_allocatable_by_size;
|
||||||
uint64_t ms_lbas[MAX_LBAS];
|
uint64_t ms_lbas[MAX_LBAS];
|
||||||
|
|
||||||
metaslab_group_t *ms_group; /* metaslab group */
|
metaslab_group_t *ms_group; /* metaslab group */
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, 2015 by Delphix. All rights reserved.
|
* Copyright (c) 2013, 2017 by Delphix. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _SYS_RANGE_TREE_H
|
#ifndef _SYS_RANGE_TREE_H
|
||||||
@ -82,6 +82,7 @@ range_tree_t *range_tree_create(range_tree_ops_t *ops, void *arg);
|
|||||||
void range_tree_destroy(range_tree_t *rt);
|
void range_tree_destroy(range_tree_t *rt);
|
||||||
boolean_t range_tree_contains(range_tree_t *rt, uint64_t start, uint64_t size);
|
boolean_t range_tree_contains(range_tree_t *rt, uint64_t start, uint64_t size);
|
||||||
uint64_t range_tree_space(range_tree_t *rt);
|
uint64_t range_tree_space(range_tree_t *rt);
|
||||||
|
boolean_t range_tree_is_empty(range_tree_t *rt);
|
||||||
void range_tree_verify(range_tree_t *rt, uint64_t start, uint64_t size);
|
void range_tree_verify(range_tree_t *rt, uint64_t start, uint64_t size);
|
||||||
void range_tree_swap(range_tree_t **rtsrc, range_tree_t **rtdst);
|
void range_tree_swap(range_tree_t **rtsrc, range_tree_t **rtdst);
|
||||||
void range_tree_stat_verify(range_tree_t *rt);
|
void range_tree_stat_verify(range_tree_t *rt);
|
||||||
|
@ -646,6 +646,8 @@ extern int spa_import(const char *pool, nvlist_t *config, nvlist_t *props,
|
|||||||
uint64_t flags);
|
uint64_t flags);
|
||||||
extern nvlist_t *spa_tryimport(nvlist_t *tryconfig);
|
extern nvlist_t *spa_tryimport(nvlist_t *tryconfig);
|
||||||
extern int spa_destroy(char *pool);
|
extern int spa_destroy(char *pool);
|
||||||
|
extern int spa_checkpoint(const char *pool);
|
||||||
|
extern int spa_checkpoint_discard(const char *pool);
|
||||||
extern int spa_export(char *pool, nvlist_t **oldconfig, boolean_t force,
|
extern int spa_export(char *pool, nvlist_t **oldconfig, boolean_t force,
|
||||||
boolean_t hardforce);
|
boolean_t hardforce);
|
||||||
extern int spa_reset(char *pool);
|
extern int spa_reset(char *pool);
|
||||||
@ -808,6 +810,7 @@ extern spa_load_state_t spa_load_state(spa_t *spa);
|
|||||||
extern uint64_t spa_freeze_txg(spa_t *spa);
|
extern uint64_t spa_freeze_txg(spa_t *spa);
|
||||||
extern uint64_t spa_get_worst_case_asize(spa_t *spa, uint64_t lsize);
|
extern uint64_t spa_get_worst_case_asize(spa_t *spa, uint64_t lsize);
|
||||||
extern uint64_t spa_get_dspace(spa_t *spa);
|
extern uint64_t spa_get_dspace(spa_t *spa);
|
||||||
|
extern uint64_t spa_get_checkpoint_space(spa_t *spa);
|
||||||
extern uint64_t spa_get_slop_space(spa_t *spa);
|
extern uint64_t spa_get_slop_space(spa_t *spa);
|
||||||
extern void spa_update_dspace(spa_t *spa);
|
extern void spa_update_dspace(spa_t *spa);
|
||||||
extern uint64_t spa_version(spa_t *spa);
|
extern uint64_t spa_version(spa_t *spa);
|
||||||
@ -856,6 +859,10 @@ extern boolean_t spa_is_root(spa_t *spa);
|
|||||||
extern boolean_t spa_writeable(spa_t *spa);
|
extern boolean_t spa_writeable(spa_t *spa);
|
||||||
extern boolean_t spa_has_pending_synctask(spa_t *spa);
|
extern boolean_t spa_has_pending_synctask(spa_t *spa);
|
||||||
extern int spa_maxblocksize(spa_t *spa);
|
extern int spa_maxblocksize(spa_t *spa);
|
||||||
|
extern boolean_t spa_has_checkpoint(spa_t *spa);
|
||||||
|
extern boolean_t spa_importing_readonly_checkpoint(spa_t *spa);
|
||||||
|
extern boolean_t spa_suspend_async_destroy(spa_t *spa);
|
||||||
|
extern uint64_t spa_min_claim_txg(spa_t *spa);
|
||||||
extern void zfs_blkptr_verify(spa_t *spa, const blkptr_t *bp);
|
extern void zfs_blkptr_verify(spa_t *spa, const blkptr_t *bp);
|
||||||
extern boolean_t zfs_dva_valid(spa_t *spa, const dva_t *dva,
|
extern boolean_t zfs_dva_valid(spa_t *spa, const dva_t *dva,
|
||||||
const blkptr_t *bp);
|
const blkptr_t *bp);
|
||||||
@ -867,6 +874,7 @@ extern uint64_t spa_get_last_removal_txg(spa_t *spa);
|
|||||||
extern boolean_t spa_trust_config(spa_t *spa);
|
extern boolean_t spa_trust_config(spa_t *spa);
|
||||||
extern uint64_t spa_missing_tvds_allowed(spa_t *spa);
|
extern uint64_t spa_missing_tvds_allowed(spa_t *spa);
|
||||||
extern void spa_set_missing_tvds(spa_t *spa, uint64_t missing);
|
extern void spa_set_missing_tvds(spa_t *spa, uint64_t missing);
|
||||||
|
extern boolean_t spa_top_vdevs_spacemap_addressable(spa_t *spa);
|
||||||
|
|
||||||
extern int spa_mode(spa_t *spa);
|
extern int spa_mode(spa_t *spa);
|
||||||
extern uint64_t zfs_strtonum(const char *str, char **nptr);
|
extern uint64_t zfs_strtonum(const char *str, char **nptr);
|
||||||
|
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* CDDL HEADER START
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the terms of the
|
||||||
|
* Common Development and Distribution License (the "License").
|
||||||
|
* You may not use this file except in compliance with the License.
|
||||||
|
*
|
||||||
|
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||||
|
* or http://www.opensolaris.org/os/licensing.
|
||||||
|
* See the License for the specific language governing permissions
|
||||||
|
* and limitations under the License.
|
||||||
|
*
|
||||||
|
* When distributing Covered Code, include this CDDL HEADER in each
|
||||||
|
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
||||||
|
* If applicable, add the following below this CDDL HEADER, with the
|
||||||
|
* fields enclosed by brackets "[]" replaced with your own identifying
|
||||||
|
* information: Portions Copyright [yyyy] [name of copyright owner]
|
||||||
|
*
|
||||||
|
* CDDL HEADER END
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2017 by Delphix. All rights reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SYS_SPA_CHECKPOINT_H
|
||||||
|
#define _SYS_SPA_CHECKPOINT_H
|
||||||
|
|
||||||
|
#include <sys/zthr.h>
|
||||||
|
|
||||||
|
typedef struct spa_checkpoint_info {
|
||||||
|
uint64_t sci_timestamp; /* when checkpointed uberblock was synced */
|
||||||
|
uint64_t sci_dspace; /* disk space used by checkpoint in bytes */
|
||||||
|
} spa_checkpoint_info_t;
|
||||||
|
|
||||||
|
int spa_checkpoint(const char *);
|
||||||
|
int spa_checkpoint_discard(const char *);
|
||||||
|
|
||||||
|
boolean_t spa_checkpoint_discard_thread_check(void *, zthr_t *);
|
||||||
|
int spa_checkpoint_discard_thread(void *, zthr_t *);
|
||||||
|
|
||||||
|
int spa_checkpoint_get_stats(spa_t *, pool_checkpoint_stat_t *);
|
||||||
|
|
||||||
|
#endif /* _SYS_SPA_CHECKPOINT_H */
|
@ -32,6 +32,7 @@
|
|||||||
#define _SYS_SPA_IMPL_H
|
#define _SYS_SPA_IMPL_H
|
||||||
|
|
||||||
#include <sys/spa.h>
|
#include <sys/spa.h>
|
||||||
|
#include <sys/spa_checkpoint.h>
|
||||||
#include <sys/vdev.h>
|
#include <sys/vdev.h>
|
||||||
#include <sys/vdev_removal.h>
|
#include <sys/vdev_removal.h>
|
||||||
#include <sys/metaslab.h>
|
#include <sys/metaslab.h>
|
||||||
@ -283,6 +284,10 @@ struct spa {
|
|||||||
spa_condensing_indirect_t *spa_condensing_indirect;
|
spa_condensing_indirect_t *spa_condensing_indirect;
|
||||||
zthr_t *spa_condense_zthr; /* zthr doing condense. */
|
zthr_t *spa_condense_zthr; /* zthr doing condense. */
|
||||||
|
|
||||||
|
uint64_t spa_checkpoint_txg; /* the txg of the checkpoint */
|
||||||
|
spa_checkpoint_info_t spa_checkpoint_info; /* checkpoint accounting */
|
||||||
|
zthr_t *spa_checkpoint_discard_zthr;
|
||||||
|
|
||||||
char *spa_root; /* alternate root directory */
|
char *spa_root; /* alternate root directory */
|
||||||
uint64_t spa_ena; /* spa-wide ereport ENA */
|
uint64_t spa_ena; /* spa-wide ereport ENA */
|
||||||
int spa_last_open_failed; /* error if last open failed */
|
int spa_last_open_failed; /* error if last open failed */
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2015 by Delphix. All rights reserved.
|
* Copyright (c) 2012, 2017 by Delphix. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _SYS_SPACE_MAP_H
|
#ifndef _SYS_SPACE_MAP_H
|
||||||
@ -57,7 +57,7 @@ extern "C" {
|
|||||||
typedef struct space_map_phys {
|
typedef struct space_map_phys {
|
||||||
uint64_t smp_object; /* on-disk space map object */
|
uint64_t smp_object; /* on-disk space map object */
|
||||||
uint64_t smp_objsize; /* size of the object */
|
uint64_t smp_objsize; /* size of the object */
|
||||||
uint64_t smp_alloc; /* space allocated from the map */
|
int64_t smp_alloc; /* space allocated from the map */
|
||||||
uint64_t smp_pad[5]; /* reserved */
|
uint64_t smp_pad[5]; /* reserved */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -82,7 +82,7 @@ typedef struct space_map {
|
|||||||
uint64_t sm_size; /* size of map */
|
uint64_t sm_size; /* size of map */
|
||||||
uint8_t sm_shift; /* unit shift */
|
uint8_t sm_shift; /* unit shift */
|
||||||
uint64_t sm_length; /* synced length */
|
uint64_t sm_length; /* synced length */
|
||||||
uint64_t sm_alloc; /* synced space allocated */
|
int64_t sm_alloc; /* synced space allocated */
|
||||||
objset_t *sm_os; /* objset for this map */
|
objset_t *sm_os; /* objset for this map */
|
||||||
uint64_t sm_object; /* object id for this map */
|
uint64_t sm_object; /* object id for this map */
|
||||||
uint32_t sm_blksz; /* block size for space map */
|
uint32_t sm_blksz; /* block size for space map */
|
||||||
@ -140,6 +140,8 @@ typedef int (*sm_cb_t)(maptype_t type, uint64_t offset, uint64_t size,
|
|||||||
|
|
||||||
int space_map_load(space_map_t *sm, range_tree_t *rt, maptype_t maptype);
|
int space_map_load(space_map_t *sm, range_tree_t *rt, maptype_t maptype);
|
||||||
int space_map_iterate(space_map_t *sm, sm_cb_t callback, void *arg);
|
int space_map_iterate(space_map_t *sm, sm_cb_t callback, void *arg);
|
||||||
|
int space_map_incremental_destroy(space_map_t *sm, sm_cb_t callback, void *arg,
|
||||||
|
dmu_tx_t *tx);
|
||||||
|
|
||||||
void space_map_histogram_clear(space_map_t *sm);
|
void space_map_histogram_clear(space_map_t *sm);
|
||||||
void space_map_histogram_add(space_map_t *sm, range_tree_t *rt,
|
void space_map_histogram_add(space_map_t *sm, range_tree_t *rt,
|
||||||
@ -153,8 +155,8 @@ uint64_t space_map_length(space_map_t *sm);
|
|||||||
|
|
||||||
void space_map_write(space_map_t *sm, range_tree_t *rt, maptype_t maptype,
|
void space_map_write(space_map_t *sm, range_tree_t *rt, maptype_t maptype,
|
||||||
dmu_tx_t *tx);
|
dmu_tx_t *tx);
|
||||||
void space_map_truncate(space_map_t *sm, dmu_tx_t *tx);
|
void space_map_truncate(space_map_t *sm, int blocksize, dmu_tx_t *tx);
|
||||||
uint64_t space_map_alloc(objset_t *os, dmu_tx_t *tx);
|
uint64_t space_map_alloc(objset_t *os, int blocksize, dmu_tx_t *tx);
|
||||||
void space_map_free(space_map_t *sm, dmu_tx_t *tx);
|
void space_map_free(space_map_t *sm, dmu_tx_t *tx);
|
||||||
void space_map_free_obj(objset_t *os, uint64_t smobj, dmu_tx_t *tx);
|
void space_map_free_obj(objset_t *os, uint64_t smobj, dmu_tx_t *tx);
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
* Copyright (c) 2017 by Delphix. All rights reserved.
|
* Copyright (c) 2016, 2017 by Delphix. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _SYS_UBERBLOCK_IMPL_H
|
#ifndef _SYS_UBERBLOCK_IMPL_H
|
||||||
@ -60,6 +60,28 @@ struct uberblock {
|
|||||||
uint64_t ub_mmp_magic;
|
uint64_t ub_mmp_magic;
|
||||||
uint64_t ub_mmp_delay;
|
uint64_t ub_mmp_delay;
|
||||||
uint64_t ub_mmp_seq;
|
uint64_t ub_mmp_seq;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ub_checkpoint_txg indicates two things about the current uberblock:
|
||||||
|
*
|
||||||
|
* 1] If it is not zero then this uberblock is a checkpoint. If it is
|
||||||
|
* zero, then this uberblock is not a checkpoint.
|
||||||
|
*
|
||||||
|
* 2] On checkpointed uberblocks, the value of ub_checkpoint_txg is
|
||||||
|
* the ub_txg that the uberblock had at the time we moved it to
|
||||||
|
* the MOS config.
|
||||||
|
*
|
||||||
|
* The field is set when we checkpoint the uberblock and continues to
|
||||||
|
* hold that value even after we've rewound (unlike the ub_txg that
|
||||||
|
* is reset to a higher value).
|
||||||
|
*
|
||||||
|
* Besides checks used to determine whether we are reopening the
|
||||||
|
* pool from a checkpointed uberblock [see spa_ld_select_uberblock()],
|
||||||
|
* the value of the field is used to determine which ZIL blocks have
|
||||||
|
* been allocated according to the ms_sm when we are rewinding to a
|
||||||
|
* checkpoint. Specifically, if blk_birth > ub_checkpoint_txg, then
|
||||||
|
* the ZIL block is not allocated [see uses of spa_min_claim_txg()].
|
||||||
|
*/
|
||||||
uint64_t ub_checkpoint_txg;
|
uint64_t ub_checkpoint_txg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
* Copyright (c) 2011, 2016 by Delphix. All rights reserved.
|
* Copyright (c) 2011, 2017 by Delphix. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _SYS_VDEV_H
|
#ifndef _SYS_VDEV_H
|
||||||
@ -82,7 +82,7 @@ extern uint64_t vdev_create_link_zap(vdev_t *vd, dmu_tx_t *tx);
|
|||||||
extern void vdev_construct_zaps(vdev_t *vd, dmu_tx_t *tx);
|
extern void vdev_construct_zaps(vdev_t *vd, dmu_tx_t *tx);
|
||||||
extern void vdev_destroy_spacemaps(vdev_t *vd, dmu_tx_t *tx);
|
extern void vdev_destroy_spacemaps(vdev_t *vd, dmu_tx_t *tx);
|
||||||
extern void vdev_indirect_mark_obsolete(vdev_t *vd, uint64_t offset,
|
extern void vdev_indirect_mark_obsolete(vdev_t *vd, uint64_t offset,
|
||||||
uint64_t size, uint64_t txg);
|
uint64_t size);
|
||||||
extern void spa_vdev_indirect_mark_obsolete(spa_t *spa, uint64_t vdev,
|
extern void spa_vdev_indirect_mark_obsolete(spa_t *spa, uint64_t vdev,
|
||||||
uint64_t offset, uint64_t size, dmu_tx_t *tx);
|
uint64_t offset, uint64_t size, dmu_tx_t *tx);
|
||||||
|
|
||||||
@ -123,6 +123,7 @@ extern boolean_t vdev_readable(vdev_t *vd);
|
|||||||
extern boolean_t vdev_writeable(vdev_t *vd);
|
extern boolean_t vdev_writeable(vdev_t *vd);
|
||||||
extern boolean_t vdev_allocatable(vdev_t *vd);
|
extern boolean_t vdev_allocatable(vdev_t *vd);
|
||||||
extern boolean_t vdev_accessible(vdev_t *vd, zio_t *zio);
|
extern boolean_t vdev_accessible(vdev_t *vd, zio_t *zio);
|
||||||
|
extern boolean_t vdev_is_spacemap_addressable(vdev_t *vd);
|
||||||
|
|
||||||
extern void vdev_cache_init(vdev_t *vd);
|
extern void vdev_cache_init(vdev_t *vd);
|
||||||
extern void vdev_cache_fini(vdev_t *vd);
|
extern void vdev_cache_fini(vdev_t *vd);
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
|
* Copyright (c) 2011, 2017 by Delphix. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _SYS_VDEV_IMPL_H
|
#ifndef _SYS_VDEV_IMPL_H
|
||||||
@ -247,6 +247,9 @@ struct vdev {
|
|||||||
kmutex_t vdev_queue_lock; /* protects vdev_queue_depth */
|
kmutex_t vdev_queue_lock; /* protects vdev_queue_depth */
|
||||||
uint64_t vdev_top_zap;
|
uint64_t vdev_top_zap;
|
||||||
|
|
||||||
|
/* pool checkpoint related */
|
||||||
|
space_map_t *vdev_checkpoint_sm; /* contains reserved blocks */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Values stored in the config for an indirect or removing vdev.
|
* Values stored in the config for an indirect or removing vdev.
|
||||||
*/
|
*/
|
||||||
@ -465,6 +468,7 @@ extern void vdev_set_min_asize(vdev_t *vd);
|
|||||||
/*
|
/*
|
||||||
* Global variables
|
* Global variables
|
||||||
*/
|
*/
|
||||||
|
extern int vdev_standard_sm_blksz;
|
||||||
/* zdb uses this tunable, so it must be declared here to make lint happy. */
|
/* zdb uses this tunable, so it must be declared here to make lint happy. */
|
||||||
extern int zfs_vdev_cache_size;
|
extern int zfs_vdev_cache_size;
|
||||||
extern uint_t zfs_geom_probe_vdev_key;
|
extern uint_t zfs_geom_probe_vdev_key;
|
||||||
@ -479,6 +483,11 @@ extern int vdev_obsolete_sm_object(vdev_t *vd);
|
|||||||
extern boolean_t vdev_obsolete_counts_are_precise(vdev_t *vd);
|
extern boolean_t vdev_obsolete_counts_are_precise(vdev_t *vd);
|
||||||
|
|
||||||
#ifdef illumos
|
#ifdef illumos
|
||||||
|
/*
|
||||||
|
* Other miscellaneous functions
|
||||||
|
*/
|
||||||
|
int vdev_checkpoint_sm_object(vdev_t *vd);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The vdev_buf_t is used to translate between zio_t and buf_t, and back again.
|
* The vdev_buf_t is used to translate between zio_t and buf_t, and back again.
|
||||||
*/
|
*/
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, 2015 by Delphix. All rights reserved.
|
* Copyright (c) 2014, 2017 by Delphix. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _SYS_VDEV_REMOVAL_H
|
#ifndef _SYS_VDEV_REMOVAL_H
|
||||||
@ -79,7 +79,7 @@ extern void spa_condense_fini(spa_t *);
|
|||||||
extern void spa_start_indirect_condensing_thread(spa_t *);
|
extern void spa_start_indirect_condensing_thread(spa_t *);
|
||||||
extern void spa_vdev_condense_suspend(spa_t *);
|
extern void spa_vdev_condense_suspend(spa_t *);
|
||||||
extern int spa_vdev_remove(spa_t *, uint64_t, boolean_t);
|
extern int spa_vdev_remove(spa_t *, uint64_t, boolean_t);
|
||||||
extern void free_from_removing_vdev(vdev_t *, uint64_t, uint64_t, uint64_t);
|
extern void free_from_removing_vdev(vdev_t *, uint64_t, uint64_t);
|
||||||
extern int spa_removal_get_stats(spa_t *, pool_removal_stat_t *);
|
extern int spa_removal_get_stats(spa_t *, pool_removal_stat_t *);
|
||||||
extern void svr_sync(spa_t *spa, dmu_tx_t *tx);
|
extern void svr_sync(spa_t *spa, dmu_tx_t *tx);
|
||||||
extern void spa_vdev_remove_suspend(spa_t *);
|
extern void spa_vdev_remove_suspend(spa_t *);
|
||||||
|
@ -552,7 +552,6 @@ extern zio_t *zio_free_sync(zio_t *pio, spa_t *spa, uint64_t txg,
|
|||||||
|
|
||||||
extern int zio_alloc_zil(spa_t *spa, uint64_t txg, blkptr_t *new_bp,
|
extern int zio_alloc_zil(spa_t *spa, uint64_t txg, blkptr_t *new_bp,
|
||||||
blkptr_t *old_bp, uint64_t size, boolean_t *slog);
|
blkptr_t *old_bp, uint64_t size, boolean_t *slog);
|
||||||
extern void zio_free_zil(spa_t *spa, uint64_t txg, blkptr_t *bp);
|
|
||||||
extern void zio_flush(zio_t *zio, vdev_t *vd);
|
extern void zio_flush(zio_t *zio, vdev_t *vd);
|
||||||
extern zio_t *zio_trim(zio_t *zio, spa_t *spa, vdev_t *vd, uint64_t offset,
|
extern zio_t *zio_trim(zio_t *zio, spa_t *spa, vdev_t *vd, uint64_t offset,
|
||||||
uint64_t size);
|
uint64_t size);
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
* CDDL HEADER END
|
* CDDL HEADER END
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2017 by Delphix. All rights reserved.
|
* Copyright (c) 2017 by Delphix. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
* Copyright (c) 2013, 2014 by Delphix. All rights reserved.
|
* Copyright (c) 2013, 2017 by Delphix. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/zfs_context.h>
|
#include <sys/zfs_context.h>
|
||||||
@ -57,6 +57,7 @@ uberblock_update(uberblock_t *ub, vdev_t *rvd, uint64_t txg)
|
|||||||
ub->ub_guid_sum = rvd->vdev_guid_sum;
|
ub->ub_guid_sum = rvd->vdev_guid_sum;
|
||||||
ub->ub_timestamp = gethrestime_sec();
|
ub->ub_timestamp = gethrestime_sec();
|
||||||
ub->ub_software_version = SPA_VERSION;
|
ub->ub_software_version = SPA_VERSION;
|
||||||
|
ub->ub_checkpoint_txg = 0;
|
||||||
|
|
||||||
return (ub->ub_rootbp.blk_birth == txg);
|
return (ub->ub_rootbp.blk_birth == txg);
|
||||||
}
|
}
|
||||||
|
@ -162,17 +162,45 @@ static vdev_ops_t *vdev_ops_table[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/* maximum number of metaslabs per top-level vdev */
|
||||||
* When a vdev is added, it will be divided into approximately (but no
|
int vdev_max_ms_count = 200;
|
||||||
* more than) this number of metaslabs.
|
SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, max_ms_count, CTLFLAG_RDTUN,
|
||||||
*/
|
&vdev_max_ms_count, 0,
|
||||||
int metaslabs_per_vdev = 200;
|
"Maximum number of metaslabs per top-level vdev");
|
||||||
SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, metaslabs_per_vdev, CTLFLAG_RDTUN,
|
|
||||||
&metaslabs_per_vdev, 0,
|
/* minimum amount of metaslabs per top-level vdev */
|
||||||
"When a vdev is added, how many metaslabs the vdev should be divided into");
|
int vdev_min_ms_count = 16;
|
||||||
|
SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, min_ms_count, CTLFLAG_RDTUN,
|
||||||
|
&vdev_min_ms_count, 0,
|
||||||
|
"Minimum number of metaslabs per top-level vdev");
|
||||||
|
|
||||||
|
/* see comment in vdev_metaslab_set_size() */
|
||||||
|
int vdev_default_ms_shift = 29;
|
||||||
|
SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, default_ms_shift, CTLFLAG_RDTUN,
|
||||||
|
&vdev_default_ms_shift, 0,
|
||||||
|
"Shift between vdev size and number of metaslabs");
|
||||||
|
|
||||||
boolean_t vdev_validate_skip = B_FALSE;
|
boolean_t vdev_validate_skip = B_FALSE;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Since the DTL space map of a vdev is not expected to have a lot of
|
||||||
|
* entries, we default its block size to 4K.
|
||||||
|
*/
|
||||||
|
int vdev_dtl_sm_blksz = (1 << 12);
|
||||||
|
SYSCTL_INT(_vfs_zfs, OID_AUTO, dtl_sm_blksz, CTLFLAG_RDTUN,
|
||||||
|
&vdev_dtl_sm_blksz, 0,
|
||||||
|
"Block size for DTL space map. Power of 2 and greater than 4096.");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* vdev-wide space maps that have lots of entries written to them at
|
||||||
|
* the end of each transaction can benefit from a higher I/O bandwidth
|
||||||
|
* (e.g. vdev_obsolete_sm), thus we default their block size to 128K.
|
||||||
|
*/
|
||||||
|
int vdev_standard_sm_blksz = (1 << 17);
|
||||||
|
SYSCTL_INT(_vfs_zfs, OID_AUTO, standard_sm_blksz, CTLFLAG_RDTUN,
|
||||||
|
&vdev_standard_sm_blksz, 0,
|
||||||
|
"Block size for standard space map. Power of 2 and greater than 4096.");
|
||||||
|
|
||||||
/*PRINTFLIKE2*/
|
/*PRINTFLIKE2*/
|
||||||
void
|
void
|
||||||
vdev_dbgmsg(vdev_t *vd, const char *fmt, ...)
|
vdev_dbgmsg(vdev_t *vd, const char *fmt, ...)
|
||||||
@ -933,6 +961,9 @@ vdev_top_transfer(vdev_t *svd, vdev_t *tvd)
|
|||||||
if (tvd->vdev_mg != NULL)
|
if (tvd->vdev_mg != NULL)
|
||||||
tvd->vdev_mg->mg_vd = tvd;
|
tvd->vdev_mg->mg_vd = tvd;
|
||||||
|
|
||||||
|
tvd->vdev_checkpoint_sm = svd->vdev_checkpoint_sm;
|
||||||
|
svd->vdev_checkpoint_sm = NULL;
|
||||||
|
|
||||||
tvd->vdev_stat.vs_alloc = svd->vdev_stat.vs_alloc;
|
tvd->vdev_stat.vs_alloc = svd->vdev_stat.vs_alloc;
|
||||||
tvd->vdev_stat.vs_space = svd->vdev_stat.vs_space;
|
tvd->vdev_stat.vs_space = svd->vdev_stat.vs_space;
|
||||||
tvd->vdev_stat.vs_dspace = svd->vdev_stat.vs_dspace;
|
tvd->vdev_stat.vs_dspace = svd->vdev_stat.vs_dspace;
|
||||||
@ -1141,6 +1172,21 @@ vdev_metaslab_init(vdev_t *vd, uint64_t txg)
|
|||||||
void
|
void
|
||||||
vdev_metaslab_fini(vdev_t *vd)
|
vdev_metaslab_fini(vdev_t *vd)
|
||||||
{
|
{
|
||||||
|
if (vd->vdev_checkpoint_sm != NULL) {
|
||||||
|
ASSERT(spa_feature_is_active(vd->vdev_spa,
|
||||||
|
SPA_FEATURE_POOL_CHECKPOINT));
|
||||||
|
space_map_close(vd->vdev_checkpoint_sm);
|
||||||
|
/*
|
||||||
|
* Even though we close the space map, we need to set its
|
||||||
|
* pointer to NULL. The reason is that vdev_metaslab_fini()
|
||||||
|
* may be called multiple times for certain operations
|
||||||
|
* (i.e. when destroying a pool) so we need to ensure that
|
||||||
|
* this clause never executes twice. This logic is similar
|
||||||
|
* to the one used for the vdev_ms clause below.
|
||||||
|
*/
|
||||||
|
vd->vdev_checkpoint_sm = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (vd->vdev_ms != NULL) {
|
if (vd->vdev_ms != NULL) {
|
||||||
uint64_t count = vd->vdev_ms_count;
|
uint64_t count = vd->vdev_ms_count;
|
||||||
|
|
||||||
@ -2054,11 +2100,39 @@ vdev_create(vdev_t *vd, uint64_t txg, boolean_t isreplacing)
|
|||||||
void
|
void
|
||||||
vdev_metaslab_set_size(vdev_t *vd)
|
vdev_metaslab_set_size(vdev_t *vd)
|
||||||
{
|
{
|
||||||
|
uint64_t asize = vd->vdev_asize;
|
||||||
|
uint64_t ms_shift = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Aim for roughly metaslabs_per_vdev (default 200) metaslabs per vdev.
|
* For vdevs that are bigger than 8G the metaslab size varies in
|
||||||
|
* a way that the number of metaslabs increases in powers of two,
|
||||||
|
* linearly in terms of vdev_asize, starting from 16 metaslabs.
|
||||||
|
* So for vdev_asize of 8G we get 16 metaslabs, for 16G, we get 32,
|
||||||
|
* and so on, until we hit the maximum metaslab count limit
|
||||||
|
* [vdev_max_ms_count] from which point the metaslab count stays
|
||||||
|
* the same.
|
||||||
*/
|
*/
|
||||||
vd->vdev_ms_shift = highbit64(vd->vdev_asize / metaslabs_per_vdev);
|
ms_shift = vdev_default_ms_shift;
|
||||||
vd->vdev_ms_shift = MAX(vd->vdev_ms_shift, SPA_MAXBLOCKSHIFT);
|
|
||||||
|
if ((asize >> ms_shift) < vdev_min_ms_count) {
|
||||||
|
/*
|
||||||
|
* For devices that are less than 8G we want to have
|
||||||
|
* exactly 16 metaslabs. We don't want less as integer
|
||||||
|
* division rounds down, so less metaslabs mean more
|
||||||
|
* wasted space. We don't want more as these vdevs are
|
||||||
|
* small and in the likely event that we are running
|
||||||
|
* out of space, the SPA will have a hard time finding
|
||||||
|
* space due to fragmentation.
|
||||||
|
*/
|
||||||
|
ms_shift = highbit64(asize / vdev_min_ms_count);
|
||||||
|
ms_shift = MAX(ms_shift, SPA_MAXBLOCKSHIFT);
|
||||||
|
|
||||||
|
} else if ((asize >> ms_shift) > vdev_max_ms_count) {
|
||||||
|
ms_shift = highbit64(asize / vdev_max_ms_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
vd->vdev_ms_shift = ms_shift;
|
||||||
|
ASSERT3U(vd->vdev_ms_shift, >=, SPA_MAXBLOCKSHIFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2191,7 +2265,7 @@ vdev_dtl_contains(vdev_t *vd, vdev_dtl_type_t t, uint64_t txg, uint64_t size)
|
|||||||
return (B_FALSE);
|
return (B_FALSE);
|
||||||
|
|
||||||
mutex_enter(&vd->vdev_dtl_lock);
|
mutex_enter(&vd->vdev_dtl_lock);
|
||||||
if (range_tree_space(rt) != 0)
|
if (!range_tree_is_empty(rt))
|
||||||
dirty = range_tree_contains(rt, txg, size);
|
dirty = range_tree_contains(rt, txg, size);
|
||||||
mutex_exit(&vd->vdev_dtl_lock);
|
mutex_exit(&vd->vdev_dtl_lock);
|
||||||
|
|
||||||
@ -2205,7 +2279,7 @@ vdev_dtl_empty(vdev_t *vd, vdev_dtl_type_t t)
|
|||||||
boolean_t empty;
|
boolean_t empty;
|
||||||
|
|
||||||
mutex_enter(&vd->vdev_dtl_lock);
|
mutex_enter(&vd->vdev_dtl_lock);
|
||||||
empty = (range_tree_space(rt) == 0);
|
empty = range_tree_is_empty(rt);
|
||||||
mutex_exit(&vd->vdev_dtl_lock);
|
mutex_exit(&vd->vdev_dtl_lock);
|
||||||
|
|
||||||
return (empty);
|
return (empty);
|
||||||
@ -2264,7 +2338,7 @@ vdev_dtl_should_excise(vdev_t *vd)
|
|||||||
return (B_FALSE);
|
return (B_FALSE);
|
||||||
|
|
||||||
if (vd->vdev_resilver_txg == 0 ||
|
if (vd->vdev_resilver_txg == 0 ||
|
||||||
range_tree_space(vd->vdev_dtl[DTL_MISSING]) == 0)
|
range_tree_is_empty(vd->vdev_dtl[DTL_MISSING]))
|
||||||
return (B_TRUE);
|
return (B_TRUE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2362,8 +2436,8 @@ vdev_dtl_reassess(vdev_t *vd, uint64_t txg, uint64_t scrub_txg, int scrub_done)
|
|||||||
* the top level so that we persist the change.
|
* the top level so that we persist the change.
|
||||||
*/
|
*/
|
||||||
if (vd->vdev_resilver_txg != 0 &&
|
if (vd->vdev_resilver_txg != 0 &&
|
||||||
range_tree_space(vd->vdev_dtl[DTL_MISSING]) == 0 &&
|
range_tree_is_empty(vd->vdev_dtl[DTL_MISSING]) &&
|
||||||
range_tree_space(vd->vdev_dtl[DTL_OUTAGE]) == 0) {
|
range_tree_is_empty(vd->vdev_dtl[DTL_OUTAGE])) {
|
||||||
vd->vdev_resilver_txg = 0;
|
vd->vdev_resilver_txg = 0;
|
||||||
vdev_config_dirty(vd->vdev_top);
|
vdev_config_dirty(vd->vdev_top);
|
||||||
}
|
}
|
||||||
@ -2523,7 +2597,7 @@ vdev_dtl_sync(vdev_t *vd, uint64_t txg)
|
|||||||
if (vd->vdev_dtl_sm == NULL) {
|
if (vd->vdev_dtl_sm == NULL) {
|
||||||
uint64_t new_object;
|
uint64_t new_object;
|
||||||
|
|
||||||
new_object = space_map_alloc(mos, tx);
|
new_object = space_map_alloc(mos, vdev_dtl_sm_blksz, tx);
|
||||||
VERIFY3U(new_object, !=, 0);
|
VERIFY3U(new_object, !=, 0);
|
||||||
|
|
||||||
VERIFY0(space_map_open(&vd->vdev_dtl_sm, mos, new_object,
|
VERIFY0(space_map_open(&vd->vdev_dtl_sm, mos, new_object,
|
||||||
@ -2537,7 +2611,7 @@ vdev_dtl_sync(vdev_t *vd, uint64_t txg)
|
|||||||
range_tree_walk(rt, range_tree_add, rtsync);
|
range_tree_walk(rt, range_tree_add, rtsync);
|
||||||
mutex_exit(&vd->vdev_dtl_lock);
|
mutex_exit(&vd->vdev_dtl_lock);
|
||||||
|
|
||||||
space_map_truncate(vd->vdev_dtl_sm, tx);
|
space_map_truncate(vd->vdev_dtl_sm, vdev_dtl_sm_blksz, tx);
|
||||||
space_map_write(vd->vdev_dtl_sm, rtsync, SM_ALLOC, tx);
|
space_map_write(vd->vdev_dtl_sm, rtsync, SM_ALLOC, tx);
|
||||||
range_tree_vacate(rtsync, NULL, NULL);
|
range_tree_vacate(rtsync, NULL, NULL);
|
||||||
|
|
||||||
@ -2608,7 +2682,7 @@ vdev_resilver_needed(vdev_t *vd, uint64_t *minp, uint64_t *maxp)
|
|||||||
|
|
||||||
if (vd->vdev_children == 0) {
|
if (vd->vdev_children == 0) {
|
||||||
mutex_enter(&vd->vdev_dtl_lock);
|
mutex_enter(&vd->vdev_dtl_lock);
|
||||||
if (range_tree_space(vd->vdev_dtl[DTL_MISSING]) != 0 &&
|
if (!range_tree_is_empty(vd->vdev_dtl[DTL_MISSING]) &&
|
||||||
vdev_writeable(vd)) {
|
vdev_writeable(vd)) {
|
||||||
|
|
||||||
thismin = vdev_dtl_min(vd);
|
thismin = vdev_dtl_min(vd);
|
||||||
@ -2636,6 +2710,28 @@ vdev_resilver_needed(vdev_t *vd, uint64_t *minp, uint64_t *maxp)
|
|||||||
return (needed);
|
return (needed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Gets the checkpoint space map object from the vdev's ZAP.
|
||||||
|
* Returns the spacemap object, or 0 if it wasn't in the ZAP
|
||||||
|
* or the ZAP doesn't exist yet.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
vdev_checkpoint_sm_object(vdev_t *vd)
|
||||||
|
{
|
||||||
|
ASSERT0(spa_config_held(vd->vdev_spa, SCL_ALL, RW_WRITER));
|
||||||
|
if (vd->vdev_top_zap == 0) {
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t sm_obj = 0;
|
||||||
|
int err = zap_lookup(spa_meta_objset(vd->vdev_spa), vd->vdev_top_zap,
|
||||||
|
VDEV_TOP_ZAP_POOL_CHECKPOINT_SM, sizeof (uint64_t), 1, &sm_obj);
|
||||||
|
|
||||||
|
ASSERT(err == 0 || err == ENOENT);
|
||||||
|
|
||||||
|
return (sm_obj);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vdev_load(vdev_t *vd)
|
vdev_load(vdev_t *vd)
|
||||||
{
|
{
|
||||||
@ -2670,6 +2766,35 @@ vdev_load(vdev_t *vd)
|
|||||||
VDEV_AUX_CORRUPT_DATA);
|
VDEV_AUX_CORRUPT_DATA);
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t checkpoint_sm_obj = vdev_checkpoint_sm_object(vd);
|
||||||
|
if (checkpoint_sm_obj != 0) {
|
||||||
|
objset_t *mos = spa_meta_objset(vd->vdev_spa);
|
||||||
|
ASSERT(vd->vdev_asize != 0);
|
||||||
|
ASSERT3P(vd->vdev_checkpoint_sm, ==, NULL);
|
||||||
|
|
||||||
|
if ((error = space_map_open(&vd->vdev_checkpoint_sm,
|
||||||
|
mos, checkpoint_sm_obj, 0, vd->vdev_asize,
|
||||||
|
vd->vdev_ashift))) {
|
||||||
|
vdev_dbgmsg(vd, "vdev_load: space_map_open "
|
||||||
|
"failed for checkpoint spacemap (obj %llu) "
|
||||||
|
"[error=%d]",
|
||||||
|
(u_longlong_t)checkpoint_sm_obj, error);
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
ASSERT3P(vd->vdev_checkpoint_sm, !=, NULL);
|
||||||
|
space_map_update(vd->vdev_checkpoint_sm);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Since the checkpoint_sm contains free entries
|
||||||
|
* exclusively we can use sm_alloc to indicate the
|
||||||
|
* culmulative checkpointed space that has been freed.
|
||||||
|
*/
|
||||||
|
vd->vdev_stat.vs_checkpoint_space =
|
||||||
|
-vd->vdev_checkpoint_sm->sm_alloc;
|
||||||
|
vd->vdev_spa->spa_checkpoint_info.sci_dspace +=
|
||||||
|
vd->vdev_stat.vs_checkpoint_space;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2687,7 +2812,7 @@ vdev_load(vdev_t *vd)
|
|||||||
if (obsolete_sm_object != 0) {
|
if (obsolete_sm_object != 0) {
|
||||||
objset_t *mos = vd->vdev_spa->spa_meta_objset;
|
objset_t *mos = vd->vdev_spa->spa_meta_objset;
|
||||||
ASSERT(vd->vdev_asize != 0);
|
ASSERT(vd->vdev_asize != 0);
|
||||||
ASSERT(vd->vdev_obsolete_sm == NULL);
|
ASSERT3P(vd->vdev_obsolete_sm, ==, NULL);
|
||||||
|
|
||||||
if ((error = space_map_open(&vd->vdev_obsolete_sm, mos,
|
if ((error = space_map_open(&vd->vdev_obsolete_sm, mos,
|
||||||
obsolete_sm_object, 0, vd->vdev_asize, 0))) {
|
obsolete_sm_object, 0, vd->vdev_asize, 0))) {
|
||||||
@ -2813,6 +2938,12 @@ vdev_remove_empty(vdev_t *vd, uint64_t txg)
|
|||||||
mutex_exit(&msp->ms_lock);
|
mutex_exit(&msp->ms_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (vd->vdev_checkpoint_sm != NULL) {
|
||||||
|
ASSERT(spa_has_checkpoint(spa));
|
||||||
|
space_map_close(vd->vdev_checkpoint_sm);
|
||||||
|
vd->vdev_checkpoint_sm = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
metaslab_group_histogram_verify(mg);
|
metaslab_group_histogram_verify(mg);
|
||||||
metaslab_class_histogram_verify(mg->mg_class);
|
metaslab_class_histogram_verify(mg->mg_class);
|
||||||
for (int i = 0; i < RANGE_TREE_HISTOGRAM_SIZE; i++)
|
for (int i = 0; i < RANGE_TREE_HISTOGRAM_SIZE; i++)
|
||||||
@ -3120,6 +3251,17 @@ vdev_offline_locked(spa_t *spa, uint64_t guid, uint64_t flags)
|
|||||||
|
|
||||||
error = spa_reset_logs(spa);
|
error = spa_reset_logs(spa);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the log device was successfully reset but has
|
||||||
|
* checkpointed data, do not offline it.
|
||||||
|
*/
|
||||||
|
if (error == 0 &&
|
||||||
|
tvd->vdev_checkpoint_sm != NULL) {
|
||||||
|
ASSERT3U(tvd->vdev_checkpoint_sm->sm_alloc,
|
||||||
|
!=, 0);
|
||||||
|
error = ZFS_ERR_CHECKPOINT_EXISTS;
|
||||||
|
}
|
||||||
|
|
||||||
spa_vdev_state_enter(spa, SCL_ALLOC);
|
spa_vdev_state_enter(spa, SCL_ALLOC);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -3320,6 +3462,23 @@ vdev_accessible(vdev_t *vd, zio_t *zio)
|
|||||||
return (B_TRUE);
|
return (B_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean_t
|
||||||
|
vdev_is_spacemap_addressable(vdev_t *vd)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Assuming 47 bits of the space map entry dedicated for the entry's
|
||||||
|
* offset (see description in space_map.h), we calculate the maximum
|
||||||
|
* address that can be described by a space map entry for the given
|
||||||
|
* device.
|
||||||
|
*/
|
||||||
|
uint64_t shift = vd->vdev_ashift + 47;
|
||||||
|
|
||||||
|
if (shift >= 63) /* detect potential overflow */
|
||||||
|
return (B_TRUE);
|
||||||
|
|
||||||
|
return (vd->vdev_asize < (1ULL << shift));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get statistics for the given vdev.
|
* Get statistics for the given vdev.
|
||||||
*/
|
*/
|
||||||
|
@ -204,14 +204,13 @@ uint64_t zfs_condense_min_mapping_bytes = 128 * 1024;
|
|||||||
int zfs_condense_indirect_commit_entry_delay_ticks = 0;
|
int zfs_condense_indirect_commit_entry_delay_ticks = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mark the given offset and size as being obsolete in the given txg.
|
* Mark the given offset and size as being obsolete.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
vdev_indirect_mark_obsolete(vdev_t *vd, uint64_t offset, uint64_t size,
|
vdev_indirect_mark_obsolete(vdev_t *vd, uint64_t offset, uint64_t size)
|
||||||
uint64_t txg)
|
|
||||||
{
|
{
|
||||||
spa_t *spa = vd->vdev_spa;
|
spa_t *spa = vd->vdev_spa;
|
||||||
ASSERT3U(spa_syncing_txg(spa), ==, txg);
|
|
||||||
ASSERT3U(vd->vdev_indirect_config.vic_mapping_object, !=, 0);
|
ASSERT3U(vd->vdev_indirect_config.vic_mapping_object, !=, 0);
|
||||||
ASSERT(vd->vdev_removing || vd->vdev_ops == &vdev_indirect_ops);
|
ASSERT(vd->vdev_removing || vd->vdev_ops == &vdev_indirect_ops);
|
||||||
ASSERT(size > 0);
|
ASSERT(size > 0);
|
||||||
@ -222,7 +221,7 @@ vdev_indirect_mark_obsolete(vdev_t *vd, uint64_t offset, uint64_t size,
|
|||||||
mutex_enter(&vd->vdev_obsolete_lock);
|
mutex_enter(&vd->vdev_obsolete_lock);
|
||||||
range_tree_add(vd->vdev_obsolete_segments, offset, size);
|
range_tree_add(vd->vdev_obsolete_segments, offset, size);
|
||||||
mutex_exit(&vd->vdev_obsolete_lock);
|
mutex_exit(&vd->vdev_obsolete_lock);
|
||||||
vdev_dirty(vd, 0, NULL, txg);
|
vdev_dirty(vd, 0, NULL, spa_syncing_txg(spa));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,7 +239,7 @@ spa_vdev_indirect_mark_obsolete(spa_t *spa, uint64_t vdev_id, uint64_t offset,
|
|||||||
|
|
||||||
/* The DMU can only remap indirect vdevs. */
|
/* The DMU can only remap indirect vdevs. */
|
||||||
ASSERT3P(vd->vdev_ops, ==, &vdev_indirect_ops);
|
ASSERT3P(vd->vdev_ops, ==, &vdev_indirect_ops);
|
||||||
vdev_indirect_mark_obsolete(vd, offset, size, dmu_tx_get_txg(tx));
|
vdev_indirect_mark_obsolete(vd, offset, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static spa_condensing_indirect_t *
|
static spa_condensing_indirect_t *
|
||||||
@ -630,7 +629,8 @@ spa_condense_indirect_thread(void *arg, zthr_t *zthr)
|
|||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
VERIFY0(dsl_sync_task(spa_name(spa), NULL,
|
VERIFY0(dsl_sync_task(spa_name(spa), NULL,
|
||||||
spa_condense_indirect_complete_sync, sci, 0, ZFS_SPACE_CHECK_NONE));
|
spa_condense_indirect_complete_sync, sci, 0,
|
||||||
|
ZFS_SPACE_CHECK_EXTRA_RESERVED));
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
thread_exit();
|
thread_exit();
|
||||||
@ -708,7 +708,8 @@ vdev_indirect_sync_obsolete(vdev_t *vd, dmu_tx_t *tx)
|
|||||||
|
|
||||||
if (vdev_obsolete_sm_object(vd) == 0) {
|
if (vdev_obsolete_sm_object(vd) == 0) {
|
||||||
uint64_t obsolete_sm_object =
|
uint64_t obsolete_sm_object =
|
||||||
space_map_alloc(spa->spa_meta_objset, tx);
|
space_map_alloc(spa->spa_meta_objset,
|
||||||
|
vdev_standard_sm_blksz, tx);
|
||||||
|
|
||||||
ASSERT(vd->vdev_top_zap != 0);
|
ASSERT(vd->vdev_top_zap != 0);
|
||||||
VERIFY0(zap_add(vd->vdev_spa->spa_meta_objset, vd->vdev_top_zap,
|
VERIFY0(zap_add(vd->vdev_spa->spa_meta_objset, vd->vdev_top_zap,
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
* Copyright (c) 2012, 2016 by Delphix. All rights reserved.
|
* Copyright (c) 2012, 2018 by Delphix. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -215,6 +215,37 @@ vdev_label_write(zio_t *zio, vdev_t *vd, int l, abd_t *buf, uint64_t offset,
|
|||||||
ZIO_PRIORITY_SYNC_WRITE, flags, B_TRUE));
|
ZIO_PRIORITY_SYNC_WRITE, flags, B_TRUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
root_vdev_actions_getprogress(vdev_t *vd, nvlist_t *nvl)
|
||||||
|
{
|
||||||
|
spa_t *spa = vd->vdev_spa;
|
||||||
|
|
||||||
|
if (vd != spa->spa_root_vdev)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* provide either current or previous scan information */
|
||||||
|
pool_scan_stat_t ps;
|
||||||
|
if (spa_scan_get_stats(spa, &ps) == 0) {
|
||||||
|
fnvlist_add_uint64_array(nvl,
|
||||||
|
ZPOOL_CONFIG_SCAN_STATS, (uint64_t *)&ps,
|
||||||
|
sizeof (pool_scan_stat_t) / sizeof (uint64_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
pool_removal_stat_t prs;
|
||||||
|
if (spa_removal_get_stats(spa, &prs) == 0) {
|
||||||
|
fnvlist_add_uint64_array(nvl,
|
||||||
|
ZPOOL_CONFIG_REMOVAL_STATS, (uint64_t *)&prs,
|
||||||
|
sizeof (prs) / sizeof (uint64_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
pool_checkpoint_stat_t pcs;
|
||||||
|
if (spa_checkpoint_get_stats(spa, &pcs) == 0) {
|
||||||
|
fnvlist_add_uint64_array(nvl,
|
||||||
|
ZPOOL_CONFIG_CHECKPOINT_STATS, (uint64_t *)&pcs,
|
||||||
|
sizeof (pcs) / sizeof (uint64_t));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generate the nvlist representing this vdev's config.
|
* Generate the nvlist representing this vdev's config.
|
||||||
*/
|
*/
|
||||||
@ -337,20 +368,7 @@ vdev_config_generate(spa_t *spa, vdev_t *vd, boolean_t getstats,
|
|||||||
fnvlist_add_uint64_array(nv, ZPOOL_CONFIG_VDEV_STATS,
|
fnvlist_add_uint64_array(nv, ZPOOL_CONFIG_VDEV_STATS,
|
||||||
(uint64_t *)&vs, sizeof (vs) / sizeof (uint64_t));
|
(uint64_t *)&vs, sizeof (vs) / sizeof (uint64_t));
|
||||||
|
|
||||||
/* provide either current or previous scan information */
|
root_vdev_actions_getprogress(vd, nv);
|
||||||
pool_scan_stat_t ps;
|
|
||||||
if (spa_scan_get_stats(spa, &ps) == 0) {
|
|
||||||
fnvlist_add_uint64_array(nv,
|
|
||||||
ZPOOL_CONFIG_SCAN_STATS, (uint64_t *)&ps,
|
|
||||||
sizeof (pool_scan_stat_t) / sizeof (uint64_t));
|
|
||||||
}
|
|
||||||
|
|
||||||
pool_removal_stat_t prs;
|
|
||||||
if (spa_removal_get_stats(spa, &prs) == 0) {
|
|
||||||
fnvlist_add_uint64_array(nv,
|
|
||||||
ZPOOL_CONFIG_REMOVAL_STATS, (uint64_t *)&prs,
|
|
||||||
sizeof (prs) / sizeof (uint64_t));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note: this can be called from open context
|
* Note: this can be called from open context
|
||||||
@ -1349,11 +1367,10 @@ vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg)
|
|||||||
{
|
{
|
||||||
spa_t *spa = svd[0]->vdev_spa;
|
spa_t *spa = svd[0]->vdev_spa;
|
||||||
uberblock_t *ub = &spa->spa_uberblock;
|
uberblock_t *ub = &spa->spa_uberblock;
|
||||||
vdev_t *vd;
|
|
||||||
zio_t *zio;
|
|
||||||
int error = 0;
|
int error = 0;
|
||||||
int flags = ZIO_FLAG_CONFIG_WRITER | ZIO_FLAG_CANFAIL;
|
int flags = ZIO_FLAG_CONFIG_WRITER | ZIO_FLAG_CANFAIL;
|
||||||
|
|
||||||
|
ASSERT(svdcount != 0);
|
||||||
retry:
|
retry:
|
||||||
/*
|
/*
|
||||||
* Normally, we don't want to try too hard to write every label and
|
* Normally, we don't want to try too hard to write every label and
|
||||||
@ -1392,9 +1409,10 @@ vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg)
|
|||||||
* written in this txg will be committed to stable storage
|
* written in this txg will be committed to stable storage
|
||||||
* before any uberblock that references them.
|
* before any uberblock that references them.
|
||||||
*/
|
*/
|
||||||
zio = zio_root(spa, NULL, NULL, flags);
|
zio_t *zio = zio_root(spa, NULL, NULL, flags);
|
||||||
|
|
||||||
for (vd = txg_list_head(&spa->spa_vdev_txg_list, TXG_CLEAN(txg)); vd;
|
for (vdev_t *vd =
|
||||||
|
txg_list_head(&spa->spa_vdev_txg_list, TXG_CLEAN(txg)); vd != NULL;
|
||||||
vd = txg_list_next(&spa->spa_vdev_txg_list, vd, TXG_CLEAN(txg)))
|
vd = txg_list_next(&spa->spa_vdev_txg_list, vd, TXG_CLEAN(txg)))
|
||||||
zio_flush(zio, vd);
|
zio_flush(zio, vd);
|
||||||
|
|
||||||
@ -1409,8 +1427,14 @@ vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg)
|
|||||||
* the new labels to disk to ensure that all even-label updates
|
* the new labels to disk to ensure that all even-label updates
|
||||||
* are committed to stable storage before the uberblock update.
|
* are committed to stable storage before the uberblock update.
|
||||||
*/
|
*/
|
||||||
if ((error = vdev_label_sync_list(spa, 0, txg, flags)) != 0)
|
if ((error = vdev_label_sync_list(spa, 0, txg, flags)) != 0) {
|
||||||
|
if ((flags & ZIO_FLAG_TRYHARD) != 0) {
|
||||||
|
zfs_dbgmsg("vdev_label_sync_list() returned error %d "
|
||||||
|
"for pool '%s' when syncing out the even labels "
|
||||||
|
"of dirty vdevs", error, spa_name(spa));
|
||||||
|
}
|
||||||
goto retry;
|
goto retry;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sync the uberblocks to all vdevs in svd[].
|
* Sync the uberblocks to all vdevs in svd[].
|
||||||
@ -1427,8 +1451,13 @@ vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg)
|
|||||||
* been successfully committed) will be valid with respect
|
* been successfully committed) will be valid with respect
|
||||||
* to the new uberblocks.
|
* to the new uberblocks.
|
||||||
*/
|
*/
|
||||||
if ((error = vdev_uberblock_sync_list(svd, svdcount, ub, flags)) != 0)
|
if ((error = vdev_uberblock_sync_list(svd, svdcount, ub, flags)) != 0) {
|
||||||
|
if ((flags & ZIO_FLAG_TRYHARD) != 0) {
|
||||||
|
zfs_dbgmsg("vdev_uberblock_sync_list() returned error "
|
||||||
|
"%d for pool '%s'", error, spa_name(spa));
|
||||||
|
}
|
||||||
goto retry;
|
goto retry;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sync out odd labels for every dirty vdev. If the system dies
|
* Sync out odd labels for every dirty vdev. If the system dies
|
||||||
@ -1440,8 +1469,14 @@ vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg)
|
|||||||
* to disk to ensure that all odd-label updates are committed to
|
* to disk to ensure that all odd-label updates are committed to
|
||||||
* stable storage before the next transaction group begins.
|
* stable storage before the next transaction group begins.
|
||||||
*/
|
*/
|
||||||
if ((error = vdev_label_sync_list(spa, 1, txg, flags)) != 0)
|
if ((error = vdev_label_sync_list(spa, 1, txg, flags)) != 0) {
|
||||||
|
if ((flags & ZIO_FLAG_TRYHARD) != 0) {
|
||||||
|
zfs_dbgmsg("vdev_label_sync_list() returned error %d "
|
||||||
|
"for pool '%s' when syncing out the odd labels of "
|
||||||
|
"dirty vdevs", error, spa_name(spa));
|
||||||
|
}
|
||||||
goto retry;;
|
goto retry;;
|
||||||
|
}
|
||||||
|
|
||||||
trim_thread_wakeup(spa);
|
trim_thread_wakeup(spa);
|
||||||
|
|
||||||
|
@ -110,6 +110,12 @@ int zfs_remove_max_copy_bytes = 8 * 1024 * 1024;
|
|||||||
*/
|
*/
|
||||||
int zfs_remove_max_segment = 1024 * 1024;
|
int zfs_remove_max_segment = 1024 * 1024;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is used by the test suite so that it can ensure that certain
|
||||||
|
* actions happen while in the middle of a removal.
|
||||||
|
*/
|
||||||
|
uint64_t zfs_remove_max_bytes_pause = UINT64_MAX;
|
||||||
|
|
||||||
#define VDEV_REMOVAL_ZAP_OBJS "lzap"
|
#define VDEV_REMOVAL_ZAP_OBJS "lzap"
|
||||||
|
|
||||||
static void spa_vdev_remove_thread(void *arg);
|
static void spa_vdev_remove_thread(void *arg);
|
||||||
@ -278,11 +284,11 @@ vdev_remove_initiate_sync(void *arg, dmu_tx_t *tx)
|
|||||||
* be copied.
|
* be copied.
|
||||||
*/
|
*/
|
||||||
spa->spa_removing_phys.sr_to_copy -=
|
spa->spa_removing_phys.sr_to_copy -=
|
||||||
range_tree_space(ms->ms_freeingtree);
|
range_tree_space(ms->ms_freeing);
|
||||||
|
|
||||||
ASSERT0(range_tree_space(ms->ms_freedtree));
|
ASSERT0(range_tree_space(ms->ms_freed));
|
||||||
for (int t = 0; t < TXG_SIZE; t++)
|
for (int t = 0; t < TXG_SIZE; t++)
|
||||||
ASSERT0(range_tree_space(ms->ms_alloctree[t]));
|
ASSERT0(range_tree_space(ms->ms_allocating[t]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -462,19 +468,18 @@ spa_restart_removal(spa_t *spa)
|
|||||||
* and we correctly free already-copied data.
|
* and we correctly free already-copied data.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
free_from_removing_vdev(vdev_t *vd, uint64_t offset, uint64_t size,
|
free_from_removing_vdev(vdev_t *vd, uint64_t offset, uint64_t size)
|
||||||
uint64_t txg)
|
|
||||||
{
|
{
|
||||||
spa_t *spa = vd->vdev_spa;
|
spa_t *spa = vd->vdev_spa;
|
||||||
spa_vdev_removal_t *svr = spa->spa_vdev_removal;
|
spa_vdev_removal_t *svr = spa->spa_vdev_removal;
|
||||||
vdev_indirect_mapping_t *vim = vd->vdev_indirect_mapping;
|
vdev_indirect_mapping_t *vim = vd->vdev_indirect_mapping;
|
||||||
|
uint64_t txg = spa_syncing_txg(spa);
|
||||||
uint64_t max_offset_yet = 0;
|
uint64_t max_offset_yet = 0;
|
||||||
|
|
||||||
ASSERT(vd->vdev_indirect_config.vic_mapping_object != 0);
|
ASSERT(vd->vdev_indirect_config.vic_mapping_object != 0);
|
||||||
ASSERT3U(vd->vdev_indirect_config.vic_mapping_object, ==,
|
ASSERT3U(vd->vdev_indirect_config.vic_mapping_object, ==,
|
||||||
vdev_indirect_mapping_object(vim));
|
vdev_indirect_mapping_object(vim));
|
||||||
ASSERT3P(vd, ==, svr->svr_vdev);
|
ASSERT3P(vd, ==, svr->svr_vdev);
|
||||||
ASSERT3U(spa_syncing_txg(spa), ==, txg);
|
|
||||||
|
|
||||||
mutex_enter(&svr->svr_lock);
|
mutex_enter(&svr->svr_lock);
|
||||||
|
|
||||||
@ -489,8 +494,13 @@ free_from_removing_vdev(vdev_t *vd, uint64_t offset, uint64_t size,
|
|||||||
* held, so that the remove_thread can not load this metaslab and then
|
* held, so that the remove_thread can not load this metaslab and then
|
||||||
* visit this offset between the time that we metaslab_free_concrete()
|
* visit this offset between the time that we metaslab_free_concrete()
|
||||||
* and when we check to see if it has been visited.
|
* and when we check to see if it has been visited.
|
||||||
|
*
|
||||||
|
* Note: The checkpoint flag is set to false as having/taking
|
||||||
|
* a checkpoint and removing a device can't happen at the same
|
||||||
|
* time.
|
||||||
*/
|
*/
|
||||||
metaslab_free_concrete(vd, offset, size, txg);
|
ASSERT(!spa_has_checkpoint(spa));
|
||||||
|
metaslab_free_concrete(vd, offset, size, B_FALSE);
|
||||||
|
|
||||||
uint64_t synced_size = 0;
|
uint64_t synced_size = 0;
|
||||||
uint64_t synced_offset = 0;
|
uint64_t synced_offset = 0;
|
||||||
@ -622,16 +632,17 @@ free_from_removing_vdev(vdev_t *vd, uint64_t offset, uint64_t size,
|
|||||||
* of this free.
|
* of this free.
|
||||||
*/
|
*/
|
||||||
if (synced_size > 0) {
|
if (synced_size > 0) {
|
||||||
vdev_indirect_mark_obsolete(vd, synced_offset, synced_size,
|
vdev_indirect_mark_obsolete(vd, synced_offset, synced_size);
|
||||||
txg);
|
|
||||||
/*
|
/*
|
||||||
* Note: this can only be called from syncing context,
|
* Note: this can only be called from syncing context,
|
||||||
* and the vdev_indirect_mapping is only changed from the
|
* and the vdev_indirect_mapping is only changed from the
|
||||||
* sync thread, so we don't need svr_lock while doing
|
* sync thread, so we don't need svr_lock while doing
|
||||||
* metaslab_free_impl_cb.
|
* metaslab_free_impl_cb.
|
||||||
*/
|
*/
|
||||||
|
boolean_t checkpoint = B_FALSE;
|
||||||
vdev_indirect_ops.vdev_op_remap(vd, synced_offset, synced_size,
|
vdev_indirect_ops.vdev_op_remap(vd, synced_offset, synced_size,
|
||||||
metaslab_free_impl_cb, &txg);
|
metaslab_free_impl_cb, &checkpoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -678,10 +689,10 @@ static void
|
|||||||
free_mapped_segment_cb(void *arg, uint64_t offset, uint64_t size)
|
free_mapped_segment_cb(void *arg, uint64_t offset, uint64_t size)
|
||||||
{
|
{
|
||||||
vdev_t *vd = arg;
|
vdev_t *vd = arg;
|
||||||
vdev_indirect_mark_obsolete(vd, offset, size,
|
vdev_indirect_mark_obsolete(vd, offset, size);
|
||||||
vd->vdev_spa->spa_syncing_txg);
|
boolean_t checkpoint = B_FALSE;
|
||||||
vdev_indirect_ops.vdev_op_remap(vd, offset, size,
|
vdev_indirect_ops.vdev_op_remap(vd, offset, size,
|
||||||
metaslab_free_impl_cb, &vd->vdev_spa->spa_syncing_txg);
|
metaslab_free_impl_cb, &checkpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1198,7 +1209,7 @@ spa_vdev_remove_thread(void *arg)
|
|||||||
* Assert nothing in flight -- ms_*tree is empty.
|
* Assert nothing in flight -- ms_*tree is empty.
|
||||||
*/
|
*/
|
||||||
for (int i = 0; i < TXG_SIZE; i++) {
|
for (int i = 0; i < TXG_SIZE; i++) {
|
||||||
ASSERT0(range_tree_space(msp->ms_alloctree[i]));
|
ASSERT0(range_tree_space(msp->ms_allocating[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1228,7 +1239,7 @@ spa_vdev_remove_thread(void *arg)
|
|||||||
SM_ALLOC));
|
SM_ALLOC));
|
||||||
space_map_close(sm);
|
space_map_close(sm);
|
||||||
|
|
||||||
range_tree_walk(msp->ms_freeingtree,
|
range_tree_walk(msp->ms_freeing,
|
||||||
range_tree_remove, svr->svr_allocd_segs);
|
range_tree_remove, svr->svr_allocd_segs);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1247,10 +1258,23 @@ spa_vdev_remove_thread(void *arg)
|
|||||||
msp->ms_id);
|
msp->ms_id);
|
||||||
|
|
||||||
while (!svr->svr_thread_exit &&
|
while (!svr->svr_thread_exit &&
|
||||||
range_tree_space(svr->svr_allocd_segs) != 0) {
|
!range_tree_is_empty(svr->svr_allocd_segs)) {
|
||||||
|
|
||||||
mutex_exit(&svr->svr_lock);
|
mutex_exit(&svr->svr_lock);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This delay will pause the removal around the point
|
||||||
|
* specified by zfs_remove_max_bytes_pause. We do this
|
||||||
|
* solely from the test suite or during debugging.
|
||||||
|
*/
|
||||||
|
uint64_t bytes_copied =
|
||||||
|
spa->spa_removing_phys.sr_copied;
|
||||||
|
for (int i = 0; i < TXG_SIZE; i++)
|
||||||
|
bytes_copied += svr->svr_bytes_done[i];
|
||||||
|
while (zfs_remove_max_bytes_pause <= bytes_copied &&
|
||||||
|
!svr->svr_thread_exit)
|
||||||
|
delay(hz);
|
||||||
|
|
||||||
mutex_enter(&vca.vca_lock);
|
mutex_enter(&vca.vca_lock);
|
||||||
while (vca.vca_outstanding_bytes >
|
while (vca.vca_outstanding_bytes >
|
||||||
zfs_remove_max_copy_bytes) {
|
zfs_remove_max_copy_bytes) {
|
||||||
@ -1381,10 +1405,10 @@ spa_vdev_remove_cancel_sync(void *arg, dmu_tx_t *tx)
|
|||||||
* Assert nothing in flight -- ms_*tree is empty.
|
* Assert nothing in flight -- ms_*tree is empty.
|
||||||
*/
|
*/
|
||||||
for (int i = 0; i < TXG_SIZE; i++)
|
for (int i = 0; i < TXG_SIZE; i++)
|
||||||
ASSERT0(range_tree_space(msp->ms_alloctree[i]));
|
ASSERT0(range_tree_space(msp->ms_allocating[i]));
|
||||||
for (int i = 0; i < TXG_DEFER_SIZE; i++)
|
for (int i = 0; i < TXG_DEFER_SIZE; i++)
|
||||||
ASSERT0(range_tree_space(msp->ms_defertree[i]));
|
ASSERT0(range_tree_space(msp->ms_defer[i]));
|
||||||
ASSERT0(range_tree_space(msp->ms_freedtree));
|
ASSERT0(range_tree_space(msp->ms_freed));
|
||||||
|
|
||||||
if (msp->ms_sm != NULL) {
|
if (msp->ms_sm != NULL) {
|
||||||
/*
|
/*
|
||||||
@ -1400,7 +1424,7 @@ spa_vdev_remove_cancel_sync(void *arg, dmu_tx_t *tx)
|
|||||||
mutex_enter(&svr->svr_lock);
|
mutex_enter(&svr->svr_lock);
|
||||||
VERIFY0(space_map_load(msp->ms_sm,
|
VERIFY0(space_map_load(msp->ms_sm,
|
||||||
svr->svr_allocd_segs, SM_ALLOC));
|
svr->svr_allocd_segs, SM_ALLOC));
|
||||||
range_tree_walk(msp->ms_freeingtree,
|
range_tree_walk(msp->ms_freeing,
|
||||||
range_tree_remove, svr->svr_allocd_segs);
|
range_tree_remove, svr->svr_allocd_segs);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1473,7 +1497,8 @@ spa_vdev_remove_cancel(spa_t *spa)
|
|||||||
uint64_t vdid = spa->spa_vdev_removal->svr_vdev->vdev_id;
|
uint64_t vdid = spa->spa_vdev_removal->svr_vdev->vdev_id;
|
||||||
|
|
||||||
int error = dsl_sync_task(spa->spa_name, spa_vdev_remove_cancel_check,
|
int error = dsl_sync_task(spa->spa_name, spa_vdev_remove_cancel_check,
|
||||||
spa_vdev_remove_cancel_sync, NULL, 0, ZFS_SPACE_CHECK_NONE);
|
spa_vdev_remove_cancel_sync, NULL, 0,
|
||||||
|
ZFS_SPACE_CHECK_EXTRA_RESERVED);
|
||||||
|
|
||||||
if (error == 0) {
|
if (error == 0) {
|
||||||
spa_config_enter(spa, SCL_ALLOC | SCL_VDEV, FTAG, RW_WRITER);
|
spa_config_enter(spa, SCL_ALLOC | SCL_VDEV, FTAG, RW_WRITER);
|
||||||
@ -1811,6 +1836,17 @@ spa_vdev_remove(spa_t *spa, uint64_t guid, boolean_t unspare)
|
|||||||
if (!locked)
|
if (!locked)
|
||||||
txg = spa_vdev_enter(spa);
|
txg = spa_vdev_enter(spa);
|
||||||
|
|
||||||
|
ASSERT(MUTEX_HELD(&spa_namespace_lock));
|
||||||
|
if (spa_feature_is_active(spa, SPA_FEATURE_POOL_CHECKPOINT)) {
|
||||||
|
error = (spa_has_checkpoint(spa)) ?
|
||||||
|
ZFS_ERR_CHECKPOINT_EXISTS : ZFS_ERR_DISCARDING_CHECKPOINT;
|
||||||
|
|
||||||
|
if (!locked)
|
||||||
|
return (spa_vdev_exit(spa, NULL, txg, error));
|
||||||
|
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
|
||||||
vd = spa_lookup_by_guid(spa, guid, B_FALSE);
|
vd = spa_lookup_by_guid(spa, guid, B_FALSE);
|
||||||
|
|
||||||
if (spa->spa_spares.sav_vdevs != NULL &&
|
if (spa->spa_spares.sav_vdevs != NULL &&
|
||||||
|
@ -1140,7 +1140,7 @@ zcp_eval(const char *poolname, const char *program, boolean_t sync,
|
|||||||
|
|
||||||
if (sync) {
|
if (sync) {
|
||||||
err = dsl_sync_task(poolname, NULL,
|
err = dsl_sync_task(poolname, NULL,
|
||||||
zcp_eval_sync, &evalargs, 0, ZFS_SPACE_CHECK_NONE);
|
zcp_eval_sync, &evalargs, 0, ZFS_SPACE_CHECK_ZCP_EVAL);
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
zcp_pool_error(&evalargs, poolname);
|
zcp_pool_error(&evalargs, poolname);
|
||||||
} else {
|
} else {
|
||||||
|
@ -110,7 +110,7 @@ static zcp_synctask_info_t zcp_synctask_destroy_info = {
|
|||||||
{.za_name = "defer", .za_lua_type = LUA_TBOOLEAN},
|
{.za_name = "defer", .za_lua_type = LUA_TBOOLEAN},
|
||||||
{NULL, 0}
|
{NULL, 0}
|
||||||
},
|
},
|
||||||
.space_check = ZFS_SPACE_CHECK_NONE,
|
.space_check = ZFS_SPACE_CHECK_DESTROY,
|
||||||
.blocks_modified = 0
|
.blocks_modified = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -302,10 +302,9 @@ zcp_synctask_wrapper(lua_State *state)
|
|||||||
zcp_parse_args(state, info->name, info->pargs, info->kwargs);
|
zcp_parse_args(state, info->name, info->pargs, info->kwargs);
|
||||||
|
|
||||||
err = 0;
|
err = 0;
|
||||||
if (info->space_check != ZFS_SPACE_CHECK_NONE && funcspace > 0) {
|
if (info->space_check != ZFS_SPACE_CHECK_NONE) {
|
||||||
uint64_t quota = dsl_pool_adjustedsize(dp,
|
uint64_t quota = dsl_pool_unreserved_space(dp,
|
||||||
info->space_check == ZFS_SPACE_CHECK_RESERVED) -
|
info->space_check);
|
||||||
metaslab_class_get_deferred(spa_normal_class(dp->dp_spa));
|
|
||||||
uint64_t used = dsl_dir_phys(dp->dp_root_dir)->dd_used_bytes +
|
uint64_t used = dsl_dir_phys(dp->dp_root_dir)->dd_used_bytes +
|
||||||
ri->zri_space_used;
|
ri->zri_space_used;
|
||||||
|
|
||||||
|
@ -3806,6 +3806,29 @@ zfs_ioc_channel_program(const char *poolname, nvlist_t *innvl,
|
|||||||
nvarg, outnvl));
|
nvarg, outnvl));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* innvl: unused
|
||||||
|
* outnvl: empty
|
||||||
|
*/
|
||||||
|
/* ARGSUSED */
|
||||||
|
static int
|
||||||
|
zfs_ioc_pool_checkpoint(const char *poolname, nvlist_t *innvl, nvlist_t *outnvl)
|
||||||
|
{
|
||||||
|
return (spa_checkpoint(poolname));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* innvl: unused
|
||||||
|
* outnvl: empty
|
||||||
|
*/
|
||||||
|
/* ARGSUSED */
|
||||||
|
static int
|
||||||
|
zfs_ioc_pool_discard_checkpoint(const char *poolname, nvlist_t *innvl,
|
||||||
|
nvlist_t *outnvl)
|
||||||
|
{
|
||||||
|
return (spa_checkpoint_discard(poolname));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* inputs:
|
* inputs:
|
||||||
* zc_name name of dataset to destroy
|
* zc_name name of dataset to destroy
|
||||||
@ -6086,6 +6109,15 @@ zfs_ioctl_init(void)
|
|||||||
POOL_NAME, POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY, B_TRUE,
|
POOL_NAME, POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY, B_TRUE,
|
||||||
B_TRUE);
|
B_TRUE);
|
||||||
|
|
||||||
|
zfs_ioctl_register("zpool_checkpoint", ZFS_IOC_POOL_CHECKPOINT,
|
||||||
|
zfs_ioc_pool_checkpoint, zfs_secpolicy_config, POOL_NAME,
|
||||||
|
POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY, B_TRUE, B_TRUE);
|
||||||
|
|
||||||
|
zfs_ioctl_register("zpool_discard_checkpoint",
|
||||||
|
ZFS_IOC_POOL_DISCARD_CHECKPOINT, zfs_ioc_pool_discard_checkpoint,
|
||||||
|
zfs_secpolicy_config, POOL_NAME,
|
||||||
|
POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY, B_TRUE, B_TRUE);
|
||||||
|
|
||||||
/* IOCTLS that use the legacy function signature */
|
/* IOCTLS that use the legacy function signature */
|
||||||
|
|
||||||
zfs_ioctl_register_legacy(ZFS_IOC_POOL_FREEZE, zfs_ioc_pool_freeze,
|
zfs_ioctl_register_legacy(ZFS_IOC_POOL_FREEZE, zfs_ioc_pool_freeze,
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#include <sys/zfs_context.h>
|
#include <sys/zfs_context.h>
|
||||||
#include <sys/spa.h>
|
#include <sys/spa.h>
|
||||||
|
#include <sys/spa_impl.h>
|
||||||
#include <sys/dmu.h>
|
#include <sys/dmu.h>
|
||||||
#include <sys/zap.h>
|
#include <sys/zap.h>
|
||||||
#include <sys/arc.h>
|
#include <sys/arc.h>
|
||||||
@ -402,6 +403,35 @@ zil_parse(zilog_t *zilog, zil_parse_blk_func_t *parse_blk_func,
|
|||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
|
static int
|
||||||
|
zil_clear_log_block(zilog_t *zilog, blkptr_t *bp, void *tx, uint64_t first_txg)
|
||||||
|
{
|
||||||
|
ASSERT(!BP_IS_HOLE(bp));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* As we call this function from the context of a rewind to a
|
||||||
|
* checkpoint, each ZIL block whose txg is later than the txg
|
||||||
|
* that we rewind to is invalid. Thus, we return -1 so
|
||||||
|
* zil_parse() doesn't attempt to read it.
|
||||||
|
*/
|
||||||
|
if (bp->blk_birth >= first_txg)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
if (zil_bp_tree_add(zilog, bp) != 0)
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
zio_free(zilog->zl_spa, first_txg, bp);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
|
static int
|
||||||
|
zil_noop_log_record(zilog_t *zilog, lr_t *lrc, void *tx, uint64_t first_txg)
|
||||||
|
{
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
zil_claim_log_block(zilog_t *zilog, blkptr_t *bp, void *tx, uint64_t first_txg)
|
zil_claim_log_block(zilog_t *zilog, blkptr_t *bp, void *tx, uint64_t first_txg)
|
||||||
{
|
{
|
||||||
@ -445,7 +475,7 @@ zil_claim_log_record(zilog_t *zilog, lr_t *lrc, void *tx, uint64_t first_txg)
|
|||||||
static int
|
static int
|
||||||
zil_free_log_block(zilog_t *zilog, blkptr_t *bp, void *tx, uint64_t claim_txg)
|
zil_free_log_block(zilog_t *zilog, blkptr_t *bp, void *tx, uint64_t claim_txg)
|
||||||
{
|
{
|
||||||
zio_free_zil(zilog->zl_spa, dmu_tx_get_txg(tx), bp);
|
zio_free(zilog->zl_spa, dmu_tx_get_txg(tx), bp);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -631,7 +661,7 @@ zil_create(zilog_t *zilog)
|
|||||||
txg = dmu_tx_get_txg(tx);
|
txg = dmu_tx_get_txg(tx);
|
||||||
|
|
||||||
if (!BP_IS_HOLE(&blk)) {
|
if (!BP_IS_HOLE(&blk)) {
|
||||||
zio_free_zil(zilog->zl_spa, txg, &blk);
|
zio_free(zilog->zl_spa, txg, &blk);
|
||||||
BP_ZERO(&blk);
|
BP_ZERO(&blk);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -731,8 +761,8 @@ int
|
|||||||
zil_claim(dsl_pool_t *dp, dsl_dataset_t *ds, void *txarg)
|
zil_claim(dsl_pool_t *dp, dsl_dataset_t *ds, void *txarg)
|
||||||
{
|
{
|
||||||
dmu_tx_t *tx = txarg;
|
dmu_tx_t *tx = txarg;
|
||||||
uint64_t first_txg = dmu_tx_get_txg(tx);
|
|
||||||
zilog_t *zilog;
|
zilog_t *zilog;
|
||||||
|
uint64_t first_txg;
|
||||||
zil_header_t *zh;
|
zil_header_t *zh;
|
||||||
objset_t *os;
|
objset_t *os;
|
||||||
int error;
|
int error;
|
||||||
@ -753,16 +783,55 @@ zil_claim(dsl_pool_t *dp, dsl_dataset_t *ds, void *txarg)
|
|||||||
|
|
||||||
zilog = dmu_objset_zil(os);
|
zilog = dmu_objset_zil(os);
|
||||||
zh = zil_header_in_syncing_context(zilog);
|
zh = zil_header_in_syncing_context(zilog);
|
||||||
|
ASSERT3U(tx->tx_txg, ==, spa_first_txg(zilog->zl_spa));
|
||||||
|
first_txg = spa_min_claim_txg(zilog->zl_spa);
|
||||||
|
|
||||||
if (spa_get_log_state(zilog->zl_spa) == SPA_LOG_CLEAR) {
|
/*
|
||||||
if (!BP_IS_HOLE(&zh->zh_log))
|
* If the spa_log_state is not set to be cleared, check whether
|
||||||
zio_free_zil(zilog->zl_spa, first_txg, &zh->zh_log);
|
* the current uberblock is a checkpoint one and if the current
|
||||||
|
* header has been claimed before moving on.
|
||||||
|
*
|
||||||
|
* If the current uberblock is a checkpointed uberblock then
|
||||||
|
* one of the following scenarios took place:
|
||||||
|
*
|
||||||
|
* 1] We are currently rewinding to the checkpoint of the pool.
|
||||||
|
* 2] We crashed in the middle of a checkpoint rewind but we
|
||||||
|
* did manage to write the checkpointed uberblock to the
|
||||||
|
* vdev labels, so when we tried to import the pool again
|
||||||
|
* the checkpointed uberblock was selected from the import
|
||||||
|
* procedure.
|
||||||
|
*
|
||||||
|
* In both cases we want to zero out all the ZIL blocks, except
|
||||||
|
* the ones that have been claimed at the time of the checkpoint
|
||||||
|
* (their zh_claim_txg != 0). The reason is that these blocks
|
||||||
|
* may be corrupted since we may have reused their locations on
|
||||||
|
* disk after we took the checkpoint.
|
||||||
|
*
|
||||||
|
* We could try to set spa_log_state to SPA_LOG_CLEAR earlier
|
||||||
|
* when we first figure out whether the current uberblock is
|
||||||
|
* checkpointed or not. Unfortunately, that would discard all
|
||||||
|
* the logs, including the ones that are claimed, and we would
|
||||||
|
* leak space.
|
||||||
|
*/
|
||||||
|
if (spa_get_log_state(zilog->zl_spa) == SPA_LOG_CLEAR ||
|
||||||
|
(zilog->zl_spa->spa_uberblock.ub_checkpoint_txg != 0 &&
|
||||||
|
zh->zh_claim_txg == 0)) {
|
||||||
|
if (!BP_IS_HOLE(&zh->zh_log)) {
|
||||||
|
(void) zil_parse(zilog, zil_clear_log_block,
|
||||||
|
zil_noop_log_record, tx, first_txg);
|
||||||
|
}
|
||||||
BP_ZERO(&zh->zh_log);
|
BP_ZERO(&zh->zh_log);
|
||||||
dsl_dataset_dirty(dmu_objset_ds(os), tx);
|
dsl_dataset_dirty(dmu_objset_ds(os), tx);
|
||||||
dmu_objset_disown(os, FTAG);
|
dmu_objset_disown(os, FTAG);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we are not rewinding and opening the pool normally, then
|
||||||
|
* the min_claim_txg should be equal to the first txg of the pool.
|
||||||
|
*/
|
||||||
|
ASSERT3U(first_txg, ==, spa_first_txg(zilog->zl_spa));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Claim all log blocks if we haven't already done so, and remember
|
* Claim all log blocks if we haven't already done so, and remember
|
||||||
* the highest claimed sequence number. This ensures that if we can
|
* the highest claimed sequence number. This ensures that if we can
|
||||||
@ -814,16 +883,17 @@ zil_check_log_chain(dsl_pool_t *dp, dsl_dataset_t *ds, void *tx)
|
|||||||
zilog = dmu_objset_zil(os);
|
zilog = dmu_objset_zil(os);
|
||||||
bp = (blkptr_t *)&zilog->zl_header->zh_log;
|
bp = (blkptr_t *)&zilog->zl_header->zh_log;
|
||||||
|
|
||||||
/*
|
|
||||||
* Check the first block and determine if it's on a log device
|
|
||||||
* which may have been removed or faulted prior to loading this
|
|
||||||
* pool. If so, there's no point in checking the rest of the log
|
|
||||||
* as its content should have already been synced to the pool.
|
|
||||||
*/
|
|
||||||
if (!BP_IS_HOLE(bp)) {
|
if (!BP_IS_HOLE(bp)) {
|
||||||
vdev_t *vd;
|
vdev_t *vd;
|
||||||
boolean_t valid = B_TRUE;
|
boolean_t valid = B_TRUE;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check the first block and determine if it's on a log device
|
||||||
|
* which may have been removed or faulted prior to loading this
|
||||||
|
* pool. If so, there's no point in checking the rest of the
|
||||||
|
* log as its content should have already been synced to the
|
||||||
|
* pool.
|
||||||
|
*/
|
||||||
spa_config_enter(os->os_spa, SCL_STATE, FTAG, RW_READER);
|
spa_config_enter(os->os_spa, SCL_STATE, FTAG, RW_READER);
|
||||||
vd = vdev_lookup_top(os->os_spa, DVA_GET_VDEV(&bp->blk_dva[0]));
|
vd = vdev_lookup_top(os->os_spa, DVA_GET_VDEV(&bp->blk_dva[0]));
|
||||||
if (vd->vdev_islog && vdev_is_dead(vd))
|
if (vd->vdev_islog && vdev_is_dead(vd))
|
||||||
@ -832,6 +902,18 @@ zil_check_log_chain(dsl_pool_t *dp, dsl_dataset_t *ds, void *tx)
|
|||||||
|
|
||||||
if (!valid)
|
if (!valid)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check whether the current uberblock is checkpointed (e.g.
|
||||||
|
* we are rewinding) and whether the current header has been
|
||||||
|
* claimed or not. If it hasn't then skip verifying it. We
|
||||||
|
* do this because its ZIL blocks may be part of the pool's
|
||||||
|
* state before the rewind, which is no longer valid.
|
||||||
|
*/
|
||||||
|
zil_header_t *zh = zil_header_in_syncing_context(zilog);
|
||||||
|
if (zilog->zl_spa->spa_uberblock.ub_checkpoint_txg != 0 &&
|
||||||
|
zh->zh_claim_txg == 0)
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -842,7 +924,8 @@ zil_check_log_chain(dsl_pool_t *dp, dsl_dataset_t *ds, void *tx)
|
|||||||
* which will update spa_max_claim_txg. See spa_load() for details.
|
* which will update spa_max_claim_txg. See spa_load() for details.
|
||||||
*/
|
*/
|
||||||
error = zil_parse(zilog, zil_claim_log_block, zil_claim_log_record, tx,
|
error = zil_parse(zilog, zil_claim_log_block, zil_claim_log_record, tx,
|
||||||
zilog->zl_header->zh_claim_txg ? -1ULL : spa_first_txg(os->os_spa));
|
zilog->zl_header->zh_claim_txg ? -1ULL :
|
||||||
|
spa_min_claim_txg(os->os_spa));
|
||||||
|
|
||||||
return ((error == ECKSUM || error == ENOENT) ? 0 : error);
|
return ((error == ECKSUM || error == ENOENT) ? 0 : error);
|
||||||
}
|
}
|
||||||
|
@ -1032,8 +1032,9 @@ zio_claim(zio_t *pio, spa_t *spa, uint64_t txg, const blkptr_t *bp,
|
|||||||
* starts allocating blocks -- so that nothing is allocated twice.
|
* starts allocating blocks -- so that nothing is allocated twice.
|
||||||
* If txg == 0 we just verify that the block is claimable.
|
* If txg == 0 we just verify that the block is claimable.
|
||||||
*/
|
*/
|
||||||
ASSERT3U(spa->spa_uberblock.ub_rootbp.blk_birth, <, spa_first_txg(spa));
|
ASSERT3U(spa->spa_uberblock.ub_rootbp.blk_birth, <,
|
||||||
ASSERT(txg == spa_first_txg(spa) || txg == 0);
|
spa_min_claim_txg(spa));
|
||||||
|
ASSERT(txg == spa_min_claim_txg(spa) || txg == 0);
|
||||||
ASSERT(!BP_GET_DEDUP(bp) || !spa_writeable(spa)); /* zdb(1M) */
|
ASSERT(!BP_GET_DEDUP(bp) || !spa_writeable(spa)); /* zdb(1M) */
|
||||||
|
|
||||||
zio = zio_create(pio, spa, txg, bp, NULL, BP_GET_PSIZE(bp),
|
zio = zio_create(pio, spa, txg, bp, NULL, BP_GET_PSIZE(bp),
|
||||||
@ -3127,18 +3128,6 @@ zio_alloc_zil(spa_t *spa, uint64_t txg, blkptr_t *new_bp, blkptr_t *old_bp,
|
|||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Free an intent log block.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
zio_free_zil(spa_t *spa, uint64_t txg, blkptr_t *bp)
|
|
||||||
{
|
|
||||||
ASSERT(BP_GET_TYPE(bp) == DMU_OT_INTENT_LOG);
|
|
||||||
ASSERT(!BP_IS_GANG(bp));
|
|
||||||
|
|
||||||
zio_free(spa, txg, bp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ==========================================================================
|
* ==========================================================================
|
||||||
* Read, write and delete to physical devices
|
* Read, write and delete to physical devices
|
||||||
|
@ -235,8 +235,6 @@ zthr_destroy(zthr_t *t)
|
|||||||
void
|
void
|
||||||
zthr_wakeup(zthr_t *t)
|
zthr_wakeup(zthr_t *t)
|
||||||
{
|
{
|
||||||
ASSERT3P(t->zthr_thread, !=, NULL);
|
|
||||||
|
|
||||||
mutex_enter(&t->zthr_lock);
|
mutex_enter(&t->zthr_lock);
|
||||||
cv_broadcast(&t->zthr_cv);
|
cv_broadcast(&t->zthr_cv);
|
||||||
mutex_exit(&t->zthr_lock);
|
mutex_exit(&t->zthr_lock);
|
||||||
|
@ -213,6 +213,7 @@ typedef enum {
|
|||||||
ZPOOL_PROP_LEAKED,
|
ZPOOL_PROP_LEAKED,
|
||||||
ZPOOL_PROP_MAXBLOCKSIZE,
|
ZPOOL_PROP_MAXBLOCKSIZE,
|
||||||
ZPOOL_PROP_BOOTSIZE,
|
ZPOOL_PROP_BOOTSIZE,
|
||||||
|
ZPOOL_PROP_CHECKPOINT,
|
||||||
ZPOOL_NUM_PROPS
|
ZPOOL_NUM_PROPS
|
||||||
} zpool_prop_t;
|
} zpool_prop_t;
|
||||||
|
|
||||||
@ -546,6 +547,7 @@ typedef struct zpool_rewind_policy {
|
|||||||
#define ZPOOL_CONFIG_DTL "DTL"
|
#define ZPOOL_CONFIG_DTL "DTL"
|
||||||
#define ZPOOL_CONFIG_SCAN_STATS "scan_stats" /* not stored on disk */
|
#define ZPOOL_CONFIG_SCAN_STATS "scan_stats" /* not stored on disk */
|
||||||
#define ZPOOL_CONFIG_REMOVAL_STATS "removal_stats" /* not stored on disk */
|
#define ZPOOL_CONFIG_REMOVAL_STATS "removal_stats" /* not stored on disk */
|
||||||
|
#define ZPOOL_CONFIG_CHECKPOINT_STATS "checkpoint_stats" /* not on disk */
|
||||||
#define ZPOOL_CONFIG_VDEV_STATS "vdev_stats" /* not stored on disk */
|
#define ZPOOL_CONFIG_VDEV_STATS "vdev_stats" /* not stored on disk */
|
||||||
#define ZPOOL_CONFIG_INDIRECT_SIZE "indirect_size" /* not stored on disk */
|
#define ZPOOL_CONFIG_INDIRECT_SIZE "indirect_size" /* not stored on disk */
|
||||||
#define ZPOOL_CONFIG_WHOLE_DISK "whole_disk"
|
#define ZPOOL_CONFIG_WHOLE_DISK "whole_disk"
|
||||||
@ -631,6 +633,8 @@ typedef struct zpool_rewind_policy {
|
|||||||
"com.delphix:indirect_obsolete_sm"
|
"com.delphix:indirect_obsolete_sm"
|
||||||
#define VDEV_TOP_ZAP_OBSOLETE_COUNTS_ARE_PRECISE \
|
#define VDEV_TOP_ZAP_OBSOLETE_COUNTS_ARE_PRECISE \
|
||||||
"com.delphix:obsolete_counts_are_precise"
|
"com.delphix:obsolete_counts_are_precise"
|
||||||
|
#define VDEV_TOP_ZAP_POOL_CHECKPOINT_SM \
|
||||||
|
"com.delphix:pool_checkpoint_sm"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is needed in userland to report the minimum necessary device size.
|
* This is needed in userland to report the minimum necessary device size.
|
||||||
@ -790,6 +794,18 @@ typedef enum dsl_scan_state {
|
|||||||
DSS_NUM_STATES
|
DSS_NUM_STATES
|
||||||
} dsl_scan_state_t;
|
} dsl_scan_state_t;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
CS_NONE,
|
||||||
|
CS_CHECKPOINT_EXISTS,
|
||||||
|
CS_CHECKPOINT_DISCARDING,
|
||||||
|
CS_NUM_STATES
|
||||||
|
} checkpoint_state_t;
|
||||||
|
|
||||||
|
typedef struct pool_checkpoint_stat {
|
||||||
|
uint64_t pcs_state; /* checkpoint_state_t */
|
||||||
|
uint64_t pcs_start_time; /* time checkpoint/discard started */
|
||||||
|
uint64_t pcs_space; /* checkpointed space */
|
||||||
|
} pool_checkpoint_stat_t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Vdev statistics. Note: all fields should be 64-bit because this
|
* Vdev statistics. Note: all fields should be 64-bit because this
|
||||||
@ -816,6 +832,7 @@ typedef struct vdev_stat {
|
|||||||
uint64_t vs_logical_ashift; /* vdev_logical_ashift */
|
uint64_t vs_logical_ashift; /* vdev_logical_ashift */
|
||||||
uint64_t vs_physical_ashift; /* vdev_physical_ashift */
|
uint64_t vs_physical_ashift; /* vdev_physical_ashift */
|
||||||
uint64_t vs_fragmentation; /* device fragmentation */
|
uint64_t vs_fragmentation; /* device fragmentation */
|
||||||
|
uint64_t vs_checkpoint_space; /* checkpoint-consumed space */
|
||||||
} vdev_stat_t;
|
} vdev_stat_t;
|
||||||
#define VDEV_STAT_VALID(field, uint64_t_field_count) \
|
#define VDEV_STAT_VALID(field, uint64_t_field_count) \
|
||||||
((uint64_t_field_count * sizeof(uint64_t)) >= \
|
((uint64_t_field_count * sizeof(uint64_t)) >= \
|
||||||
@ -948,9 +965,27 @@ typedef enum zfs_ioc {
|
|||||||
#endif
|
#endif
|
||||||
ZFS_IOC_CHANNEL_PROGRAM,
|
ZFS_IOC_CHANNEL_PROGRAM,
|
||||||
ZFS_IOC_REMAP,
|
ZFS_IOC_REMAP,
|
||||||
|
ZFS_IOC_POOL_CHECKPOINT,
|
||||||
|
ZFS_IOC_POOL_DISCARD_CHECKPOINT,
|
||||||
ZFS_IOC_LAST
|
ZFS_IOC_LAST
|
||||||
} zfs_ioc_t;
|
} zfs_ioc_t;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ZFS-specific error codes used for returning descriptive errors
|
||||||
|
* to the userland through zfs ioctls.
|
||||||
|
*
|
||||||
|
* The enum implicitly includes all the error codes from errno.h.
|
||||||
|
* New code should use and extend this enum for errors that are
|
||||||
|
* not described precisely by generic errno codes.
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
ZFS_ERR_CHECKPOINT_EXISTS = 1024,
|
||||||
|
ZFS_ERR_DISCARDING_CHECKPOINT,
|
||||||
|
ZFS_ERR_NO_CHECKPOINT,
|
||||||
|
ZFS_ERR_DEVRM_IN_PROGRESS,
|
||||||
|
ZFS_ERR_VDEV_TOO_BIG
|
||||||
|
} zfs_errno_t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Internal SPA load state. Used by FMA diagnosis engine.
|
* Internal SPA load state. Used by FMA diagnosis engine.
|
||||||
*/
|
*/
|
||||||
@ -1011,6 +1046,7 @@ typedef enum {
|
|||||||
#define ZFS_IMPORT_ANY_HOST 0x2
|
#define ZFS_IMPORT_ANY_HOST 0x2
|
||||||
#define ZFS_IMPORT_MISSING_LOG 0x4
|
#define ZFS_IMPORT_MISSING_LOG 0x4
|
||||||
#define ZFS_IMPORT_ONLY 0x8
|
#define ZFS_IMPORT_ONLY 0x8
|
||||||
|
#define ZFS_IMPORT_CHECKPOINT 0x10
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Channel program argument/return nvlist keys and defaults.
|
* Channel program argument/return nvlist keys and defaults.
|
||||||
|
@ -207,6 +207,7 @@ cddl/contrib/opensolaris/uts/common/fs/zfs/sa.c optional zfs compile-with "${
|
|||||||
cddl/contrib/opensolaris/uts/common/fs/zfs/sha256.c optional zfs compile-with "${ZFS_C}"
|
cddl/contrib/opensolaris/uts/common/fs/zfs/sha256.c optional zfs compile-with "${ZFS_C}"
|
||||||
cddl/contrib/opensolaris/uts/common/fs/zfs/skein_zfs.c optional zfs compile-with "${ZFS_C}"
|
cddl/contrib/opensolaris/uts/common/fs/zfs/skein_zfs.c optional zfs compile-with "${ZFS_C}"
|
||||||
cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c optional zfs compile-with "${ZFS_C}"
|
cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c optional zfs compile-with "${ZFS_C}"
|
||||||
|
cddl/contrib/opensolaris/uts/common/fs/zfs/spa_checkpoint.c optional zfs compile-with "${ZFS_C}"
|
||||||
cddl/contrib/opensolaris/uts/common/fs/zfs/spa_config.c optional zfs compile-with "${ZFS_C}"
|
cddl/contrib/opensolaris/uts/common/fs/zfs/spa_config.c optional zfs compile-with "${ZFS_C}"
|
||||||
cddl/contrib/opensolaris/uts/common/fs/zfs/spa_errlog.c optional zfs compile-with "${ZFS_C}"
|
cddl/contrib/opensolaris/uts/common/fs/zfs/spa_errlog.c optional zfs compile-with "${ZFS_C}"
|
||||||
cddl/contrib/opensolaris/uts/common/fs/zfs/spa_history.c optional zfs compile-with "${ZFS_C}"
|
cddl/contrib/opensolaris/uts/common/fs/zfs/spa_history.c optional zfs compile-with "${ZFS_C}"
|
||||||
|
Loading…
Reference in New Issue
Block a user