mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
RAID-Z expansion feature
This feature allows disks to be added one at a time to a RAID-Z group, expanding its capacity incrementally. This feature is especially useful for small pools (typically with only one RAID-Z group), where there isn't sufficient hardware to add capacity by adding a whole new RAID-Z group (typically doubling the number of disks). == Initiating expansion == A new device (disk) can be attached to an existing RAIDZ vdev, by running `zpool attach POOL raidzP-N NEW_DEVICE`, e.g. `zpool attach tank raidz2-0 sda`. The new device will become part of the RAIDZ group. A "raidz expansion" will be initiated, and the new device will contribute additional space to the RAIDZ group once the expansion completes. The `feature@raidz_expansion` on-disk feature flag must be `enabled` to initiate an expansion, and it remains `active` for the life of the pool. In other words, pools with expanded RAIDZ vdevs can not be imported by older releases of the ZFS software. == During expansion == The expansion entails reading all allocated space from existing disks in the RAIDZ group, and rewriting it to the new disks in the RAIDZ group (including the newly added device). The expansion progress can be monitored with `zpool status`. Data redundancy is maintained during (and after) the expansion. If a disk fails while the expansion is in progress, the expansion pauses until the health of the RAIDZ vdev is restored (e.g. by replacing the failed disk and waiting for reconstruction to complete). The pool remains accessible during expansion. Following a reboot or export/import, the expansion resumes where it left off. == After expansion == When the expansion completes, the additional space is available for use, and is reflected in the `available` zfs property (as seen in `zfs list`, `df`, etc). Expansion does not change the number of failures that can be tolerated without data loss (e.g. a RAIDZ2 is still a RAIDZ2 even after expansion). A RAIDZ vdev can be expanded multiple times. After the expansion completes, old blocks remain with their old data-to-parity ratio (e.g. 5-wide RAIDZ2, has 3 data to 2 parity), but distributed among the larger set of disks. New blocks will be written with the new data-to-parity ratio (e.g. a 5-wide RAIDZ2 which has been expanded once to 6-wide, has 4 data to 2 parity). However, the RAIDZ vdev's "assumed parity ratio" does not change, so slightly less space than is expected may be reported for newly-written blocks, according to `zfs list`, `df`, `ls -s`, and similar tools. Sponsored-by: The FreeBSD Foundation Sponsored-by: iXsystems, Inc. Sponsored-by: vStack Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Mark Maybee <mark.maybee@delphix.com> Authored-by: Matthew Ahrens <mahrens@delphix.com> Contributions-by: Fedor Uporov <fuporov.vstack@gmail.com> Contributions-by: Stuart Maybee <stuart.maybee@comcast.net> Contributions-by: Thorsten Behrens <tbehrens@outlook.com> Contributions-by: Fmstrat <nospam@nowsci.com> Contributions-by: Don Brady <dev.fs.zfs@gmail.com> Signed-off-by: Don Brady <dev.fs.zfs@gmail.com> Closes #15022
This commit is contained in:
@@ -445,6 +445,7 @@ ZFS_OBJS_OS := \
|
||||
trace.o \
|
||||
vdev_disk.o \
|
||||
vdev_file.o \
|
||||
vdev_label_os.o \
|
||||
zfs_acl.o \
|
||||
zfs_ctldir.o \
|
||||
zfs_debug.o \
|
||||
|
||||
@@ -72,3 +72,62 @@ retry:
|
||||
abd_free(pad2);
|
||||
return (error);
|
||||
}
|
||||
|
||||
static void
|
||||
vdev_child_done(zio_t *zio)
|
||||
{
|
||||
zio_t *pio = zio->io_private;
|
||||
|
||||
mutex_enter(&pio->io_lock);
|
||||
pio->io_error = zio_worst_error(pio->io_error, zio->io_error);
|
||||
mutex_exit(&pio->io_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if the reserved boot area is in-use.
|
||||
*
|
||||
* When booting FreeBSD with an MBR partition with ZFS, the zfsboot file
|
||||
* (which understands the ZFS file system) is written to the ZFS BOOT
|
||||
* reserve area (at offset 512K). We check for that here before attaching
|
||||
* a disk to raidz which would then corrupt this boot data.
|
||||
*/
|
||||
int
|
||||
vdev_check_boot_reserve(spa_t *spa, vdev_t *childvd)
|
||||
{
|
||||
ASSERT(childvd->vdev_ops->vdev_op_leaf);
|
||||
|
||||
size_t size = SPA_MINBLOCKSIZE;
|
||||
abd_t *abd = abd_alloc_linear(size, B_FALSE);
|
||||
|
||||
zio_t *pio = zio_root(spa, NULL, NULL, 0);
|
||||
/*
|
||||
* Note: zio_vdev_child_io() adds VDEV_LABEL_START_SIZE to the offset
|
||||
* to calculate the physical offset to write to. Passing in a negative
|
||||
* offset lets us access the boot area.
|
||||
*/
|
||||
zio_nowait(zio_vdev_child_io(pio, NULL, childvd,
|
||||
VDEV_BOOT_OFFSET - VDEV_LABEL_START_SIZE, abd, size, ZIO_TYPE_READ,
|
||||
ZIO_PRIORITY_ASYNC_READ, 0, vdev_child_done, pio));
|
||||
zio_wait(pio);
|
||||
|
||||
unsigned char *buf = abd_to_buf(abd);
|
||||
|
||||
/*
|
||||
* The BTX server has a special header at the begining.
|
||||
*
|
||||
* btx_hdr: .byte 0xeb # Machine ID
|
||||
* .byte 0xe # Header size
|
||||
* .ascii "BTX" # Magic
|
||||
* .byte 0x1 # Major version
|
||||
* .byte 0x2 # Minor version
|
||||
* .byte BTX_FLAGS # Flags
|
||||
*/
|
||||
if (buf[0] == 0xeb && buf[1] == 0x0e &&
|
||||
buf[2] == 'B' && buf[3] == 'T' && buf[4] == 'X') {
|
||||
abd_free(abd);
|
||||
return (EBUSY);
|
||||
}
|
||||
|
||||
abd_free(abd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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 https://opensource.org/licenses/CDDL-1.0.
|
||||
* 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) 2023 by iXsystems, Inc.
|
||||
*/
|
||||
|
||||
#include <sys/zfs_context.h>
|
||||
#include <sys/spa.h>
|
||||
#include <sys/spa_impl.h>
|
||||
#include <sys/vdev.h>
|
||||
#include <sys/vdev_impl.h>
|
||||
|
||||
/*
|
||||
* Check if the reserved boot area is in-use.
|
||||
*
|
||||
* This function always returns 0, as there are no known external uses
|
||||
* of the reserved area on Linux.
|
||||
*/
|
||||
int
|
||||
vdev_check_boot_reserve(spa_t *spa, vdev_t *childvd)
|
||||
{
|
||||
(void) spa;
|
||||
(void) childvd;
|
||||
|
||||
return (0);
|
||||
}
|
||||
@@ -175,7 +175,8 @@ __dprintf(boolean_t dprint, const char *file, const char *func,
|
||||
newfile = file;
|
||||
}
|
||||
|
||||
i = snprintf(buf, size, "%s%s:%d:%s(): ", prefix, newfile, line, func);
|
||||
i = snprintf(buf, size, "%px %s%s:%d:%s(): ",
|
||||
curthread, prefix, newfile, line, func);
|
||||
|
||||
if (i < size) {
|
||||
va_start(adx, fmt);
|
||||
|
||||
@@ -749,6 +749,11 @@ zpool_feature_init(void)
|
||||
redact_list_spill_deps, sfeatures);
|
||||
}
|
||||
|
||||
zfeature_register(SPA_FEATURE_RAIDZ_EXPANSION,
|
||||
"org.openzfs:raidz_expansion", "raidz_expansion",
|
||||
"Support for raidz expansion",
|
||||
ZFEATURE_FLAG_MOS, ZFEATURE_TYPE_BOOLEAN, NULL, sfeatures);
|
||||
|
||||
zfs_mod_list_supported_free(sfeatures);
|
||||
}
|
||||
|
||||
|
||||
@@ -439,6 +439,9 @@ vdev_prop_init(void)
|
||||
zprop_register_index(VDEV_PROP_ALLOCATING, "allocating", 1,
|
||||
PROP_DEFAULT, ZFS_TYPE_VDEV, "on | off", "ALLOCATING",
|
||||
boolean_na_table, sfeatures);
|
||||
zprop_register_index(VDEV_PROP_RAIDZ_EXPANDING, "raidz_expanding", 0,
|
||||
PROP_READONLY, ZFS_TYPE_VDEV, "on | off", "RAIDZ_EXPANDING",
|
||||
boolean_table, sfeatures);
|
||||
|
||||
/* default index properties */
|
||||
zprop_register_index(VDEV_PROP_FAILFAST, "failfast", B_TRUE,
|
||||
|
||||
+6
-2
@@ -4518,7 +4518,7 @@ arc_evict_cb_check(void *arg, zthr_t *zthr)
|
||||
static void
|
||||
arc_evict_cb(void *arg, zthr_t *zthr)
|
||||
{
|
||||
(void) arg, (void) zthr;
|
||||
(void) arg;
|
||||
|
||||
uint64_t evicted = 0;
|
||||
fstrans_cookie_t cookie = spl_fstrans_mark();
|
||||
@@ -4542,9 +4542,13 @@ arc_evict_cb(void *arg, zthr_t *zthr)
|
||||
* infinite loop. Additionally, zthr_iscancelled() is
|
||||
* checked here so that if the arc is shutting down, the
|
||||
* broadcast will wake any remaining arc evict waiters.
|
||||
*
|
||||
* Note we cancel using zthr instead of arc_evict_zthr
|
||||
* because the latter may not yet be initializd when the
|
||||
* callback is first invoked.
|
||||
*/
|
||||
mutex_enter(&arc_evict_lock);
|
||||
arc_evict_needed = !zthr_iscancelled(arc_evict_zthr) &&
|
||||
arc_evict_needed = !zthr_iscancelled(zthr) &&
|
||||
evicted > 0 && aggsum_compare(&arc_sums.arcstat_size, arc_c) > 0;
|
||||
if (!arc_evict_needed) {
|
||||
/*
|
||||
|
||||
@@ -3066,7 +3066,6 @@ dsl_scan_visit(dsl_scan_t *scn, dmu_tx_t *tx)
|
||||
scn->scn_phys.scn_cur_max_txg = scn->scn_phys.scn_max_txg;
|
||||
dsl_scan_visit_rootbp(scn, NULL,
|
||||
&dp->dp_meta_rootbp, tx);
|
||||
spa_set_rootblkptr(dp->dp_spa, &dp->dp_meta_rootbp);
|
||||
if (scn->scn_suspending)
|
||||
return;
|
||||
|
||||
|
||||
@@ -4342,7 +4342,8 @@ metaslab_sync_done(metaslab_t *msp, uint64_t txg)
|
||||
|
||||
uint64_t free_space = metaslab_class_get_space(spa_normal_class(spa)) -
|
||||
metaslab_class_get_alloc(spa_normal_class(spa));
|
||||
if (free_space <= spa_get_slop_space(spa) || vd->vdev_removing) {
|
||||
if (free_space <= spa_get_slop_space(spa) || vd->vdev_removing ||
|
||||
vd->vdev_rz_expanding) {
|
||||
defer_allowed = B_FALSE;
|
||||
}
|
||||
|
||||
@@ -4650,6 +4651,7 @@ metaslab_block_alloc(metaslab_t *msp, uint64_t size, uint64_t txg)
|
||||
ASSERT(MUTEX_HELD(&msp->ms_lock));
|
||||
VERIFY(!msp->ms_condensing);
|
||||
VERIFY0(msp->ms_disabled);
|
||||
VERIFY0(msp->ms_new);
|
||||
|
||||
start = mc->mc_ops->msop_alloc(msp, size);
|
||||
if (start != -1ULL) {
|
||||
@@ -4721,10 +4723,10 @@ find_valid_metaslab(metaslab_group_t *mg, uint64_t activation_weight,
|
||||
}
|
||||
|
||||
/*
|
||||
* If the selected metaslab is condensing or disabled,
|
||||
* skip it.
|
||||
* If the selected metaslab is condensing or disabled, or
|
||||
* hasn't gone through a metaslab_sync_done(), then skip it.
|
||||
*/
|
||||
if (msp->ms_condensing || msp->ms_disabled > 0)
|
||||
if (msp->ms_condensing || msp->ms_disabled > 0 || msp->ms_new)
|
||||
continue;
|
||||
|
||||
*was_active = msp->ms_allocator != -1;
|
||||
@@ -5270,7 +5272,7 @@ top:
|
||||
|
||||
ASSERT(mg->mg_class == mc);
|
||||
|
||||
uint64_t asize = vdev_psize_to_asize(vd, psize);
|
||||
uint64_t asize = vdev_psize_to_asize_txg(vd, psize, txg);
|
||||
ASSERT(P2PHASE(asize, 1ULL << vd->vdev_ashift) == 0);
|
||||
|
||||
/*
|
||||
|
||||
+195
-47
@@ -63,6 +63,7 @@
|
||||
#include <sys/vdev_rebuild.h>
|
||||
#include <sys/vdev_trim.h>
|
||||
#include <sys/vdev_disk.h>
|
||||
#include <sys/vdev_raidz.h>
|
||||
#include <sys/vdev_draid.h>
|
||||
#include <sys/metaslab.h>
|
||||
#include <sys/metaslab_impl.h>
|
||||
@@ -1709,6 +1710,10 @@ spa_destroy_aux_threads(spa_t *spa)
|
||||
zthr_destroy(spa->spa_livelist_condense_zthr);
|
||||
spa->spa_livelist_condense_zthr = NULL;
|
||||
}
|
||||
if (spa->spa_raidz_expand_zthr != NULL) {
|
||||
zthr_destroy(spa->spa_raidz_expand_zthr);
|
||||
spa->spa_raidz_expand_zthr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1861,6 +1866,8 @@ spa_unload(spa_t *spa)
|
||||
spa->spa_compatibility = NULL;
|
||||
}
|
||||
|
||||
spa->spa_raidz_expand = NULL;
|
||||
|
||||
spa_config_exit(spa, SCL_ALL, spa);
|
||||
}
|
||||
|
||||
@@ -2999,6 +3006,7 @@ spa_spawn_aux_threads(spa_t *spa)
|
||||
|
||||
ASSERT(MUTEX_HELD(&spa_namespace_lock));
|
||||
|
||||
spa_start_raidz_expansion_thread(spa);
|
||||
spa_start_indirect_condensing_thread(spa);
|
||||
spa_start_livelist_destroy_thread(spa);
|
||||
spa_start_livelist_condensing_thread(spa);
|
||||
@@ -3753,6 +3761,12 @@ spa_ld_select_uberblock(spa_t *spa, spa_import_type_t type)
|
||||
}
|
||||
spa_load_note(spa, "using uberblock with txg=%llu",
|
||||
(u_longlong_t)ub->ub_txg);
|
||||
if (ub->ub_raidz_reflow_info != 0) {
|
||||
spa_load_note(spa, "uberblock raidz_reflow_info: "
|
||||
"state=%u offset=%llu",
|
||||
(int)RRSS_GET_STATE(ub),
|
||||
(u_longlong_t)RRSS_GET_OFFSET(ub));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@@ -5091,6 +5105,13 @@ spa_load_impl(spa_t *spa, spa_import_type_t type, const char **ereport)
|
||||
|
||||
ASSERT(spa->spa_load_state != SPA_LOAD_TRYIMPORT);
|
||||
|
||||
/*
|
||||
* Before we do any zio_write's, complete the raidz expansion
|
||||
* scratch space copying, if necessary.
|
||||
*/
|
||||
if (RRSS_GET_STATE(&spa->spa_uberblock) == RRSS_SCRATCH_VALID)
|
||||
vdev_raidz_reflow_copy_scratch(spa);
|
||||
|
||||
/*
|
||||
* In case of a checkpoint rewind, log the original txg
|
||||
* of the checkpointed uberblock.
|
||||
@@ -6905,9 +6926,10 @@ spa_vdev_add(spa_t *spa, nvlist_t *nvroot)
|
||||
}
|
||||
|
||||
/*
|
||||
* Attach a device to a mirror. The arguments are the path to any device
|
||||
* in the mirror, and the nvroot for the new device. If the path specifies
|
||||
* a device that is not mirrored, we automatically insert the mirror vdev.
|
||||
* Attach a device to a vdev specified by its guid. The vdev type can be
|
||||
* a mirror, a raidz, or a leaf device that is also a top-level (e.g. a
|
||||
* single device). When the vdev is a single device, a mirror vdev will be
|
||||
* automatically inserted.
|
||||
*
|
||||
* If 'replacing' is specified, the new device is intended to replace the
|
||||
* existing device; in this case the two devices are made into their own
|
||||
@@ -6930,7 +6952,7 @@ spa_vdev_attach(spa_t *spa, uint64_t guid, nvlist_t *nvroot, int replacing,
|
||||
vdev_t *oldvd, *newvd, *newrootvd, *pvd, *tvd;
|
||||
vdev_ops_t *pvops;
|
||||
char *oldvdpath, *newvdpath;
|
||||
int newvd_isspare;
|
||||
int newvd_isspare = B_FALSE;
|
||||
int error;
|
||||
|
||||
ASSERT(spa_writeable(spa));
|
||||
@@ -6961,16 +6983,35 @@ spa_vdev_attach(spa_t *spa, uint64_t guid, nvlist_t *nvroot, int replacing,
|
||||
ZFS_ERR_REBUILD_IN_PROGRESS));
|
||||
}
|
||||
|
||||
if (spa->spa_vdev_removal != NULL)
|
||||
return (spa_vdev_exit(spa, NULL, txg, EBUSY));
|
||||
if (spa->spa_vdev_removal != NULL) {
|
||||
return (spa_vdev_exit(spa, NULL, txg,
|
||||
ZFS_ERR_DEVRM_IN_PROGRESS));
|
||||
}
|
||||
|
||||
if (oldvd == NULL)
|
||||
return (spa_vdev_exit(spa, NULL, txg, ENODEV));
|
||||
|
||||
if (!oldvd->vdev_ops->vdev_op_leaf)
|
||||
return (spa_vdev_exit(spa, NULL, txg, ENOTSUP));
|
||||
boolean_t raidz = oldvd->vdev_ops == &vdev_raidz_ops;
|
||||
|
||||
pvd = oldvd->vdev_parent;
|
||||
if (raidz) {
|
||||
if (!spa_feature_is_enabled(spa, SPA_FEATURE_RAIDZ_EXPANSION))
|
||||
return (spa_vdev_exit(spa, NULL, txg, ENOTSUP));
|
||||
|
||||
/*
|
||||
* Can't expand a raidz while prior expand is in progress.
|
||||
*/
|
||||
if (spa->spa_raidz_expand != NULL) {
|
||||
return (spa_vdev_exit(spa, NULL, txg,
|
||||
ZFS_ERR_RAIDZ_EXPAND_IN_PROGRESS));
|
||||
}
|
||||
} else if (!oldvd->vdev_ops->vdev_op_leaf) {
|
||||
return (spa_vdev_exit(spa, NULL, txg, ENOTSUP));
|
||||
}
|
||||
|
||||
if (raidz)
|
||||
pvd = oldvd;
|
||||
else
|
||||
pvd = oldvd->vdev_parent;
|
||||
|
||||
if (spa_config_parse(spa, &newrootvd, nvroot, NULL, 0,
|
||||
VDEV_ALLOC_ATTACH) != 0)
|
||||
@@ -7026,6 +7067,7 @@ spa_vdev_attach(spa_t *spa, uint64_t guid, nvlist_t *nvroot, int replacing,
|
||||
* vdev.
|
||||
*/
|
||||
if (pvd->vdev_ops != &vdev_mirror_ops &&
|
||||
pvd->vdev_ops != &vdev_raidz_ops &&
|
||||
pvd->vdev_ops != &vdev_root_ops)
|
||||
return (spa_vdev_exit(spa, newrootvd, txg, ENOTSUP));
|
||||
|
||||
@@ -7065,7 +7107,8 @@ spa_vdev_attach(spa_t *spa, uint64_t guid, nvlist_t *nvroot, int replacing,
|
||||
/*
|
||||
* Make sure the new device is big enough.
|
||||
*/
|
||||
if (newvd->vdev_asize < vdev_get_min_asize(oldvd))
|
||||
vdev_t *min_vdev = raidz ? oldvd->vdev_child[0] : oldvd;
|
||||
if (newvd->vdev_asize < vdev_get_min_asize(min_vdev))
|
||||
return (spa_vdev_exit(spa, newrootvd, txg, EOVERFLOW));
|
||||
|
||||
/*
|
||||
@@ -7075,32 +7118,75 @@ spa_vdev_attach(spa_t *spa, uint64_t guid, nvlist_t *nvroot, int replacing,
|
||||
if (newvd->vdev_ashift > oldvd->vdev_top->vdev_ashift)
|
||||
return (spa_vdev_exit(spa, newrootvd, txg, ENOTSUP));
|
||||
|
||||
/*
|
||||
* RAIDZ-expansion-specific checks.
|
||||
*/
|
||||
if (raidz) {
|
||||
if (vdev_raidz_attach_check(newvd) != 0)
|
||||
return (spa_vdev_exit(spa, newrootvd, txg, ENOTSUP));
|
||||
|
||||
/*
|
||||
* Fail early if a child is not healthy or being replaced
|
||||
*/
|
||||
for (int i = 0; i < oldvd->vdev_children; i++) {
|
||||
if (vdev_is_dead(oldvd->vdev_child[i]) ||
|
||||
!oldvd->vdev_child[i]->vdev_ops->vdev_op_leaf) {
|
||||
return (spa_vdev_exit(spa, newrootvd, txg,
|
||||
ENXIO));
|
||||
}
|
||||
/* Also fail if reserved boot area is in-use */
|
||||
if (vdev_check_boot_reserve(spa, oldvd->vdev_child[i])
|
||||
!= 0) {
|
||||
return (spa_vdev_exit(spa, newrootvd, txg,
|
||||
EADDRINUSE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (raidz) {
|
||||
/*
|
||||
* Note: oldvdpath is freed by spa_strfree(), but
|
||||
* kmem_asprintf() is freed by kmem_strfree(), so we have to
|
||||
* move it to a spa_strdup-ed string.
|
||||
*/
|
||||
char *tmp = kmem_asprintf("raidz%u-%u",
|
||||
(uint_t)vdev_get_nparity(oldvd), (uint_t)oldvd->vdev_id);
|
||||
oldvdpath = spa_strdup(tmp);
|
||||
kmem_strfree(tmp);
|
||||
} else {
|
||||
oldvdpath = spa_strdup(oldvd->vdev_path);
|
||||
}
|
||||
newvdpath = spa_strdup(newvd->vdev_path);
|
||||
|
||||
/*
|
||||
* If this is an in-place replacement, update oldvd's path and devid
|
||||
* to make it distinguishable from newvd, and unopenable from now on.
|
||||
*/
|
||||
if (strcmp(oldvd->vdev_path, newvd->vdev_path) == 0) {
|
||||
if (strcmp(oldvdpath, newvdpath) == 0) {
|
||||
spa_strfree(oldvd->vdev_path);
|
||||
oldvd->vdev_path = kmem_alloc(strlen(newvd->vdev_path) + 5,
|
||||
oldvd->vdev_path = kmem_alloc(strlen(newvdpath) + 5,
|
||||
KM_SLEEP);
|
||||
(void) snprintf(oldvd->vdev_path, strlen(newvd->vdev_path) + 5,
|
||||
"%s/%s", newvd->vdev_path, "old");
|
||||
(void) sprintf(oldvd->vdev_path, "%s/old",
|
||||
newvdpath);
|
||||
if (oldvd->vdev_devid != NULL) {
|
||||
spa_strfree(oldvd->vdev_devid);
|
||||
oldvd->vdev_devid = NULL;
|
||||
}
|
||||
spa_strfree(oldvdpath);
|
||||
oldvdpath = spa_strdup(oldvd->vdev_path);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the parent is not a mirror, or if we're replacing, insert the new
|
||||
* mirror/replacing/spare vdev above oldvd.
|
||||
*/
|
||||
if (pvd->vdev_ops != pvops)
|
||||
if (!raidz && pvd->vdev_ops != pvops) {
|
||||
pvd = vdev_add_parent(oldvd, pvops);
|
||||
ASSERT(pvd->vdev_ops == pvops);
|
||||
ASSERT(oldvd->vdev_parent == pvd);
|
||||
}
|
||||
|
||||
ASSERT(pvd->vdev_top->vdev_parent == rvd);
|
||||
ASSERT(pvd->vdev_ops == pvops);
|
||||
ASSERT(oldvd->vdev_parent == pvd);
|
||||
|
||||
/*
|
||||
* Extract the new device from its root and add it to pvd.
|
||||
@@ -7128,41 +7214,66 @@ spa_vdev_attach(spa_t *spa, uint64_t guid, nvlist_t *nvroot, int replacing,
|
||||
*/
|
||||
dtl_max_txg = txg + TXG_CONCURRENT_STATES;
|
||||
|
||||
vdev_dtl_dirty(newvd, DTL_MISSING,
|
||||
TXG_INITIAL, dtl_max_txg - TXG_INITIAL);
|
||||
if (raidz) {
|
||||
/*
|
||||
* Wait for the youngest allocations and frees to sync,
|
||||
* and then wait for the deferral of those frees to finish.
|
||||
*/
|
||||
spa_vdev_config_exit(spa, NULL,
|
||||
txg + TXG_CONCURRENT_STATES + TXG_DEFER_SIZE, 0, FTAG);
|
||||
|
||||
if (newvd->vdev_isspare) {
|
||||
spa_spare_activate(newvd);
|
||||
spa_event_notify(spa, newvd, NULL, ESC_ZFS_VDEV_SPARE);
|
||||
}
|
||||
vdev_initialize_stop_all(tvd, VDEV_INITIALIZE_ACTIVE);
|
||||
vdev_trim_stop_all(tvd, VDEV_TRIM_ACTIVE);
|
||||
vdev_autotrim_stop_wait(tvd);
|
||||
|
||||
oldvdpath = spa_strdup(oldvd->vdev_path);
|
||||
newvdpath = spa_strdup(newvd->vdev_path);
|
||||
newvd_isspare = newvd->vdev_isspare;
|
||||
dtl_max_txg = spa_vdev_config_enter(spa);
|
||||
|
||||
/*
|
||||
* Mark newvd's DTL dirty in this txg.
|
||||
*/
|
||||
vdev_dirty(tvd, VDD_DTL, newvd, txg);
|
||||
tvd->vdev_rz_expanding = B_TRUE;
|
||||
|
||||
/*
|
||||
* Schedule the resilver or rebuild to restart in the future. We do
|
||||
* this to ensure that dmu_sync-ed blocks have been stitched into the
|
||||
* respective datasets.
|
||||
*/
|
||||
if (rebuild) {
|
||||
newvd->vdev_rebuild_txg = txg;
|
||||
vdev_dirty_leaves(tvd, VDD_DTL, dtl_max_txg);
|
||||
vdev_config_dirty(tvd);
|
||||
|
||||
vdev_rebuild(tvd);
|
||||
dmu_tx_t *tx = dmu_tx_create_assigned(spa->spa_dsl_pool,
|
||||
dtl_max_txg);
|
||||
dsl_sync_task_nowait(spa->spa_dsl_pool, vdev_raidz_attach_sync,
|
||||
newvd, tx);
|
||||
dmu_tx_commit(tx);
|
||||
} else {
|
||||
newvd->vdev_resilver_txg = txg;
|
||||
vdev_dtl_dirty(newvd, DTL_MISSING, TXG_INITIAL,
|
||||
dtl_max_txg - TXG_INITIAL);
|
||||
|
||||
if (dsl_scan_resilvering(spa_get_dsl(spa)) &&
|
||||
spa_feature_is_enabled(spa, SPA_FEATURE_RESILVER_DEFER)) {
|
||||
vdev_defer_resilver(newvd);
|
||||
if (newvd->vdev_isspare) {
|
||||
spa_spare_activate(newvd);
|
||||
spa_event_notify(spa, newvd, NULL, ESC_ZFS_VDEV_SPARE);
|
||||
}
|
||||
|
||||
newvd_isspare = newvd->vdev_isspare;
|
||||
|
||||
/*
|
||||
* Mark newvd's DTL dirty in this txg.
|
||||
*/
|
||||
vdev_dirty(tvd, VDD_DTL, newvd, txg);
|
||||
|
||||
/*
|
||||
* Schedule the resilver or rebuild to restart in the future.
|
||||
* We do this to ensure that dmu_sync-ed blocks have been
|
||||
* stitched into the respective datasets.
|
||||
*/
|
||||
if (rebuild) {
|
||||
newvd->vdev_rebuild_txg = txg;
|
||||
|
||||
vdev_rebuild(tvd);
|
||||
} else {
|
||||
dsl_scan_restart_resilver(spa->spa_dsl_pool,
|
||||
dtl_max_txg);
|
||||
newvd->vdev_resilver_txg = txg;
|
||||
|
||||
if (dsl_scan_resilvering(spa_get_dsl(spa)) &&
|
||||
spa_feature_is_enabled(spa,
|
||||
SPA_FEATURE_RESILVER_DEFER)) {
|
||||
vdev_defer_resilver(newvd);
|
||||
} else {
|
||||
dsl_scan_restart_resilver(spa->spa_dsl_pool,
|
||||
dtl_max_txg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7487,7 +7598,7 @@ spa_vdev_initialize_impl(spa_t *spa, uint64_t guid, uint64_t cmd_type,
|
||||
*/
|
||||
if (cmd_type == POOL_INITIALIZE_START &&
|
||||
(vd->vdev_initialize_thread != NULL ||
|
||||
vd->vdev_top->vdev_removing)) {
|
||||
vd->vdev_top->vdev_removing || vd->vdev_top->vdev_rz_expanding)) {
|
||||
mutex_exit(&vd->vdev_initialize_lock);
|
||||
return (SET_ERROR(EBUSY));
|
||||
} else if (cmd_type == POOL_INITIALIZE_CANCEL &&
|
||||
@@ -7609,7 +7720,8 @@ spa_vdev_trim_impl(spa_t *spa, uint64_t guid, uint64_t cmd_type,
|
||||
* which has completed but the thread is not exited.
|
||||
*/
|
||||
if (cmd_type == POOL_TRIM_START &&
|
||||
(vd->vdev_trim_thread != NULL || vd->vdev_top->vdev_removing)) {
|
||||
(vd->vdev_trim_thread != NULL || vd->vdev_top->vdev_removing ||
|
||||
vd->vdev_top->vdev_rz_expanding)) {
|
||||
mutex_exit(&vd->vdev_trim_lock);
|
||||
return (SET_ERROR(EBUSY));
|
||||
} else if (cmd_type == POOL_TRIM_CANCEL &&
|
||||
@@ -8512,6 +8624,10 @@ spa_async_suspend(spa_t *spa)
|
||||
if (condense_thread != NULL)
|
||||
zthr_cancel(condense_thread);
|
||||
|
||||
zthr_t *raidz_expand_thread = spa->spa_raidz_expand_zthr;
|
||||
if (raidz_expand_thread != NULL)
|
||||
zthr_cancel(raidz_expand_thread);
|
||||
|
||||
zthr_t *discard_thread = spa->spa_checkpoint_discard_zthr;
|
||||
if (discard_thread != NULL)
|
||||
zthr_cancel(discard_thread);
|
||||
@@ -8538,6 +8654,10 @@ spa_async_resume(spa_t *spa)
|
||||
if (condense_thread != NULL)
|
||||
zthr_resume(condense_thread);
|
||||
|
||||
zthr_t *raidz_expand_thread = spa->spa_raidz_expand_zthr;
|
||||
if (raidz_expand_thread != NULL)
|
||||
zthr_resume(raidz_expand_thread);
|
||||
|
||||
zthr_t *discard_thread = spa->spa_checkpoint_discard_zthr;
|
||||
if (discard_thread != NULL)
|
||||
zthr_resume(discard_thread);
|
||||
@@ -9343,6 +9463,27 @@ spa_sync_iterate_to_convergence(spa_t *spa, dmu_tx_t *tx)
|
||||
!= NULL)
|
||||
vdev_sync(vd, txg);
|
||||
|
||||
if (pass == 1) {
|
||||
/*
|
||||
* dsl_pool_sync() -> dp_sync_tasks may have dirtied
|
||||
* the config. If that happens, this txg should not
|
||||
* be a no-op. So we must sync the config to the MOS
|
||||
* before checking for no-op.
|
||||
*
|
||||
* Note that when the config is dirty, it will
|
||||
* be written to the MOS (i.e. the MOS will be
|
||||
* dirtied) every time we call spa_sync_config_object()
|
||||
* in this txg. Therefore we can't call this after
|
||||
* dsl_pool_sync() every pass, because it would
|
||||
* prevent us from converging, since we'd dirty
|
||||
* the MOS every pass.
|
||||
*
|
||||
* Sync tasks can only be processed in pass 1, so
|
||||
* there's no need to do this in later passes.
|
||||
*/
|
||||
spa_sync_config_object(spa, tx);
|
||||
}
|
||||
|
||||
/*
|
||||
* Note: We need to check if the MOS is dirty because we could
|
||||
* have marked the MOS dirty without updating the uberblock
|
||||
@@ -10100,7 +10241,8 @@ spa_activity_in_progress(spa_t *spa, zpool_wait_activity_t activity,
|
||||
DSS_SCANNING);
|
||||
break;
|
||||
case ZPOOL_WAIT_RESILVER:
|
||||
if ((*in_progress = vdev_rebuild_active(spa->spa_root_vdev)))
|
||||
*in_progress = vdev_rebuild_active(spa->spa_root_vdev);
|
||||
if (*in_progress)
|
||||
break;
|
||||
zfs_fallthrough;
|
||||
case ZPOOL_WAIT_SCRUB:
|
||||
@@ -10115,6 +10257,12 @@ spa_activity_in_progress(spa_t *spa, zpool_wait_activity_t activity,
|
||||
is_scrub == (activity == ZPOOL_WAIT_SCRUB));
|
||||
break;
|
||||
}
|
||||
case ZPOOL_WAIT_RAIDZ_EXPAND:
|
||||
{
|
||||
vdev_raidz_expand_t *vre = spa->spa_raidz_expand;
|
||||
*in_progress = (vre != NULL && vre->vre_state == DSS_SCANNING);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
panic("unrecognized value for activity %d", activity);
|
||||
}
|
||||
|
||||
@@ -465,6 +465,9 @@ spa_checkpoint_check(void *arg, dmu_tx_t *tx)
|
||||
if (spa->spa_removing_phys.sr_state == DSS_SCANNING)
|
||||
return (SET_ERROR(ZFS_ERR_DEVRM_IN_PROGRESS));
|
||||
|
||||
if (spa->spa_raidz_expand != NULL)
|
||||
return (SET_ERROR(ZFS_ERR_RAIDZ_EXPAND_IN_PROGRESS));
|
||||
|
||||
if (spa->spa_checkpoint_txg != 0)
|
||||
return (SET_ERROR(ZFS_ERR_CHECKPOINT_EXISTS));
|
||||
|
||||
|
||||
+79
-35
@@ -58,6 +58,7 @@
|
||||
#include <sys/abd.h>
|
||||
#include <sys/vdev_initialize.h>
|
||||
#include <sys/vdev_trim.h>
|
||||
#include <sys/vdev_raidz.h>
|
||||
#include <sys/zvol.h>
|
||||
#include <sys/zfs_ratelimit.h>
|
||||
#include "zfs_prop.h"
|
||||
@@ -305,13 +306,13 @@ vdev_derive_alloc_bias(const char *bias)
|
||||
* all children. This is what's used by anything other than RAID-Z.
|
||||
*/
|
||||
uint64_t
|
||||
vdev_default_asize(vdev_t *vd, uint64_t psize)
|
||||
vdev_default_asize(vdev_t *vd, uint64_t psize, uint64_t txg)
|
||||
{
|
||||
uint64_t asize = P2ROUNDUP(psize, 1ULL << vd->vdev_top->vdev_ashift);
|
||||
uint64_t csize;
|
||||
|
||||
for (int c = 0; c < vd->vdev_children; c++) {
|
||||
csize = vdev_psize_to_asize(vd->vdev_child[c], psize);
|
||||
csize = vdev_psize_to_asize_txg(vd->vdev_child[c], psize, txg);
|
||||
asize = MAX(asize, csize);
|
||||
}
|
||||
|
||||
@@ -930,6 +931,8 @@ vdev_alloc(spa_t *spa, vdev_t **vdp, nvlist_t *nv, vdev_t *parent, uint_t id,
|
||||
&vd->vdev_removing);
|
||||
(void) nvlist_lookup_uint64(nv, ZPOOL_CONFIG_VDEV_TOP_ZAP,
|
||||
&vd->vdev_top_zap);
|
||||
vd->vdev_rz_expanding = nvlist_exists(nv,
|
||||
ZPOOL_CONFIG_RAIDZ_EXPANDING);
|
||||
} else {
|
||||
ASSERT0(vd->vdev_top_zap);
|
||||
}
|
||||
@@ -1692,6 +1695,8 @@ vdev_probe_done(zio_t *zio)
|
||||
|
||||
vd->vdev_cant_read |= !vps->vps_readable;
|
||||
vd->vdev_cant_write |= !vps->vps_writeable;
|
||||
vdev_dbgmsg(vd, "probe done, cant_read=%u cant_write=%u",
|
||||
vd->vdev_cant_read, vd->vdev_cant_write);
|
||||
|
||||
if (vdev_readable(vd) &&
|
||||
(vdev_writeable(vd) || !spa_writeable(spa))) {
|
||||
@@ -1913,17 +1918,20 @@ vdev_open_children_subset(vdev_t *vd, vdev_open_children_func_t *open_func)
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute the raidz-deflation ratio. Note, we hard-code
|
||||
* in 128k (1 << 17) because it is the "typical" blocksize.
|
||||
* Even though SPA_MAXBLOCKSIZE changed, this algorithm can not change,
|
||||
* otherwise it would inconsistently account for existing bp's.
|
||||
* Compute the raidz-deflation ratio. Note, we hard-code 128k (1 << 17)
|
||||
* because it is the "typical" blocksize. Even though SPA_MAXBLOCKSIZE
|
||||
* changed, this algorithm can not change, otherwise it would inconsistently
|
||||
* account for existing bp's. We also hard-code txg 0 for the same reason
|
||||
* since expanded RAIDZ vdevs can use a different asize for different birth
|
||||
* txg's.
|
||||
*/
|
||||
static void
|
||||
vdev_set_deflate_ratio(vdev_t *vd)
|
||||
{
|
||||
if (vd == vd->vdev_top && !vd->vdev_ishole && vd->vdev_ashift != 0) {
|
||||
vd->vdev_deflate_ratio = (1 << 17) /
|
||||
(vdev_psize_to_asize(vd, 1 << 17) >> SPA_MINBLOCKSHIFT);
|
||||
(vdev_psize_to_asize_txg(vd, 1 << 17, 0) >>
|
||||
SPA_MINBLOCKSHIFT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3228,32 +3236,43 @@ vdev_dtl_reassess(vdev_t *vd, uint64_t txg, uint64_t scrub_txg,
|
||||
|
||||
if (txg != 0)
|
||||
vdev_dirty(vd->vdev_top, VDD_DTL, vd, txg);
|
||||
return;
|
||||
} else {
|
||||
mutex_enter(&vd->vdev_dtl_lock);
|
||||
for (int t = 0; t < DTL_TYPES; t++) {
|
||||
/* account for child's outage in parent's missing map */
|
||||
int s = (t == DTL_MISSING) ? DTL_OUTAGE: t;
|
||||
if (t == DTL_SCRUB) {
|
||||
/* leaf vdevs only */
|
||||
continue;
|
||||
}
|
||||
if (t == DTL_PARTIAL) {
|
||||
/* i.e. non-zero */
|
||||
minref = 1;
|
||||
} else if (vdev_get_nparity(vd) != 0) {
|
||||
/* RAIDZ, DRAID */
|
||||
minref = vdev_get_nparity(vd) + 1;
|
||||
} else {
|
||||
/* any kind of mirror */
|
||||
minref = vd->vdev_children;
|
||||
}
|
||||
space_reftree_create(&reftree);
|
||||
for (int c = 0; c < vd->vdev_children; c++) {
|
||||
vdev_t *cvd = vd->vdev_child[c];
|
||||
mutex_enter(&cvd->vdev_dtl_lock);
|
||||
space_reftree_add_map(&reftree,
|
||||
cvd->vdev_dtl[s], 1);
|
||||
mutex_exit(&cvd->vdev_dtl_lock);
|
||||
}
|
||||
space_reftree_generate_map(&reftree,
|
||||
vd->vdev_dtl[t], minref);
|
||||
space_reftree_destroy(&reftree);
|
||||
}
|
||||
mutex_exit(&vd->vdev_dtl_lock);
|
||||
}
|
||||
|
||||
mutex_enter(&vd->vdev_dtl_lock);
|
||||
for (int t = 0; t < DTL_TYPES; t++) {
|
||||
/* account for child's outage in parent's missing map */
|
||||
int s = (t == DTL_MISSING) ? DTL_OUTAGE: t;
|
||||
if (t == DTL_SCRUB)
|
||||
continue; /* leaf vdevs only */
|
||||
if (t == DTL_PARTIAL)
|
||||
minref = 1; /* i.e. non-zero */
|
||||
else if (vdev_get_nparity(vd) != 0)
|
||||
minref = vdev_get_nparity(vd) + 1; /* RAID-Z, dRAID */
|
||||
else
|
||||
minref = vd->vdev_children; /* any kind of mirror */
|
||||
space_reftree_create(&reftree);
|
||||
for (int c = 0; c < vd->vdev_children; c++) {
|
||||
vdev_t *cvd = vd->vdev_child[c];
|
||||
mutex_enter(&cvd->vdev_dtl_lock);
|
||||
space_reftree_add_map(&reftree, cvd->vdev_dtl[s], 1);
|
||||
mutex_exit(&cvd->vdev_dtl_lock);
|
||||
}
|
||||
space_reftree_generate_map(&reftree, vd->vdev_dtl[t], minref);
|
||||
space_reftree_destroy(&reftree);
|
||||
if (vd->vdev_top->vdev_ops == &vdev_raidz_ops) {
|
||||
raidz_dtl_reassessed(vd);
|
||||
}
|
||||
mutex_exit(&vd->vdev_dtl_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3628,6 +3647,12 @@ vdev_load(vdev_t *vd)
|
||||
|
||||
vdev_set_deflate_ratio(vd);
|
||||
|
||||
if (vd->vdev_ops == &vdev_raidz_ops) {
|
||||
error = vdev_raidz_load(vd);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* On spa_load path, grab the allocation bias from our zap
|
||||
*/
|
||||
@@ -4005,10 +4030,22 @@ vdev_sync(vdev_t *vd, uint64_t txg)
|
||||
dmu_tx_commit(tx);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the amount of space that should be (or was) allocated for the given
|
||||
* psize (compressed block size) in the given TXG. Note that for expanded
|
||||
* RAIDZ vdevs, the size allocated for older BP's may be larger. See
|
||||
* vdev_raidz_asize().
|
||||
*/
|
||||
uint64_t
|
||||
vdev_psize_to_asize_txg(vdev_t *vd, uint64_t psize, uint64_t txg)
|
||||
{
|
||||
return (vd->vdev_ops->vdev_op_asize(vd, psize, txg));
|
||||
}
|
||||
|
||||
uint64_t
|
||||
vdev_psize_to_asize(vdev_t *vd, uint64_t psize)
|
||||
{
|
||||
return (vd->vdev_ops->vdev_op_asize(vd, psize));
|
||||
return (vdev_psize_to_asize_txg(vd, psize, 0));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4174,9 +4211,6 @@ vdev_online(spa_t *spa, uint64_t guid, uint64_t flags, vdev_state_t *newstate)
|
||||
if ((vd = spa_lookup_by_guid(spa, guid, B_TRUE)) == NULL)
|
||||
return (spa_vdev_state_exit(spa, NULL, SET_ERROR(ENODEV)));
|
||||
|
||||
if (!vd->vdev_ops->vdev_op_leaf)
|
||||
return (spa_vdev_state_exit(spa, NULL, SET_ERROR(ENOTSUP)));
|
||||
|
||||
wasoffline = (vd->vdev_offline || vd->vdev_tmpoffline);
|
||||
oldstate = vd->vdev_state;
|
||||
|
||||
@@ -5457,7 +5491,9 @@ vdev_expand(vdev_t *vd, uint64_t txg)
|
||||
|
||||
vdev_set_deflate_ratio(vd);
|
||||
|
||||
if ((vd->vdev_asize >> vd->vdev_ms_shift) > vd->vdev_ms_count &&
|
||||
if ((vd->vdev_spa->spa_raidz_expand == NULL ||
|
||||
vd->vdev_spa->spa_raidz_expand->vre_vdev_id != vd->vdev_id) &&
|
||||
(vd->vdev_asize >> vd->vdev_ms_shift) > vd->vdev_ms_count &&
|
||||
vdev_is_concrete(vd)) {
|
||||
vdev_metaslab_group_create(vd);
|
||||
VERIFY(vdev_metaslab_init(vd, txg) == 0);
|
||||
@@ -6209,6 +6245,14 @@ vdev_prop_get(vdev_t *vd, nvlist_t *innvl, nvlist_t *outnvl)
|
||||
vdev_prop_add_list(outnvl, propname, NULL,
|
||||
vd->vdev_removing, ZPROP_SRC_NONE);
|
||||
continue;
|
||||
case VDEV_PROP_RAIDZ_EXPANDING:
|
||||
/* Only expose this for raidz */
|
||||
if (vd->vdev_ops == &vdev_raidz_ops) {
|
||||
vdev_prop_add_list(outnvl, propname,
|
||||
NULL, vd->vdev_rz_expanding,
|
||||
ZPROP_SRC_NONE);
|
||||
}
|
||||
continue;
|
||||
/* Numeric Properites */
|
||||
case VDEV_PROP_ALLOCATING:
|
||||
/* Leaf vdevs cannot have this property */
|
||||
|
||||
+7
-21
@@ -577,8 +577,9 @@ vdev_draid_permute_id(vdev_draid_config_t *vdc,
|
||||
* i.e. vdev_draid_psize_to_asize().
|
||||
*/
|
||||
static uint64_t
|
||||
vdev_draid_asize(vdev_t *vd, uint64_t psize)
|
||||
vdev_draid_asize(vdev_t *vd, uint64_t psize, uint64_t txg)
|
||||
{
|
||||
(void) txg;
|
||||
vdev_draid_config_t *vdc = vd->vdev_tsd;
|
||||
uint64_t ashift = vd->vdev_ashift;
|
||||
|
||||
@@ -960,7 +961,7 @@ vdev_draid_map_alloc_row(zio_t *zio, raidz_row_t **rrp, uint64_t io_offset,
|
||||
vdev_draid_config_t *vdc = vd->vdev_tsd;
|
||||
uint64_t ashift = vd->vdev_top->vdev_ashift;
|
||||
uint64_t io_size = abd_size;
|
||||
uint64_t io_asize = vdev_draid_asize(vd, io_size);
|
||||
uint64_t io_asize = vdev_draid_asize(vd, io_size, 0);
|
||||
uint64_t group = vdev_draid_offset_to_group(vd, io_offset);
|
||||
uint64_t start_offset = vdev_draid_group_to_offset(vd, group + 1);
|
||||
|
||||
@@ -1025,15 +1026,9 @@ vdev_draid_map_alloc_row(zio_t *zio, raidz_row_t **rrp, uint64_t io_offset,
|
||||
|
||||
ASSERT3U(vdc->vdc_nparity, >, 0);
|
||||
|
||||
raidz_row_t *rr;
|
||||
rr = kmem_alloc(offsetof(raidz_row_t, rr_col[groupwidth]), KM_SLEEP);
|
||||
rr->rr_cols = groupwidth;
|
||||
rr->rr_scols = groupwidth;
|
||||
raidz_row_t *rr = vdev_raidz_row_alloc(groupwidth);
|
||||
rr->rr_bigcols = bc;
|
||||
rr->rr_missingdata = 0;
|
||||
rr->rr_missingparity = 0;
|
||||
rr->rr_firstdatacol = vdc->vdc_nparity;
|
||||
rr->rr_abd_empty = NULL;
|
||||
#ifdef ZFS_DEBUG
|
||||
rr->rr_offset = io_offset;
|
||||
rr->rr_size = io_size;
|
||||
@@ -1053,14 +1048,6 @@ vdev_draid_map_alloc_row(zio_t *zio, raidz_row_t **rrp, uint64_t io_offset,
|
||||
|
||||
rc->rc_devidx = vdev_draid_permute_id(vdc, base, iter, c);
|
||||
rc->rc_offset = physical_offset;
|
||||
rc->rc_abd = NULL;
|
||||
rc->rc_orig_data = NULL;
|
||||
rc->rc_error = 0;
|
||||
rc->rc_tried = 0;
|
||||
rc->rc_skipped = 0;
|
||||
rc->rc_force_repair = 0;
|
||||
rc->rc_allow_repair = 1;
|
||||
rc->rc_need_orig_restore = B_FALSE;
|
||||
|
||||
if (q == 0 && i >= bc)
|
||||
rc->rc_size = 0;
|
||||
@@ -1129,7 +1116,7 @@ vdev_draid_map_alloc(zio_t *zio)
|
||||
if (size < abd_size) {
|
||||
vdev_t *vd = zio->io_vd;
|
||||
|
||||
io_offset += vdev_draid_asize(vd, size);
|
||||
io_offset += vdev_draid_asize(vd, size, 0);
|
||||
abd_offset += size;
|
||||
abd_size -= size;
|
||||
nrows++;
|
||||
@@ -1151,7 +1138,6 @@ vdev_draid_map_alloc(zio_t *zio)
|
||||
rm->rm_row[0] = rr[0];
|
||||
if (nrows == 2)
|
||||
rm->rm_row[1] = rr[1];
|
||||
|
||||
return (rm);
|
||||
}
|
||||
|
||||
@@ -1783,7 +1769,7 @@ vdev_draid_need_resilver(vdev_t *vd, const dva_t *dva, size_t psize,
|
||||
uint64_t phys_birth)
|
||||
{
|
||||
uint64_t offset = DVA_GET_OFFSET(dva);
|
||||
uint64_t asize = vdev_draid_asize(vd, psize);
|
||||
uint64_t asize = vdev_draid_asize(vd, psize, 0);
|
||||
|
||||
if (phys_birth == TXG_UNKNOWN) {
|
||||
/*
|
||||
@@ -1840,7 +1826,7 @@ vdev_draid_io_verify(vdev_t *vd, raidz_row_t *rr, int col)
|
||||
range_seg64_t logical_rs, physical_rs, remain_rs;
|
||||
logical_rs.rs_start = rr->rr_offset;
|
||||
logical_rs.rs_end = logical_rs.rs_start +
|
||||
vdev_draid_asize(vd, rr->rr_size);
|
||||
vdev_draid_asize(vd, rr->rr_size, 0);
|
||||
|
||||
raidz_col_t *rc = &rr->rr_col[col];
|
||||
vdev_t *cvd = vd->vdev_child[rc->rc_devidx];
|
||||
|
||||
@@ -48,7 +48,8 @@ static boolean_t
|
||||
vdev_initialize_should_stop(vdev_t *vd)
|
||||
{
|
||||
return (vd->vdev_initialize_exit_wanted || !vdev_writeable(vd) ||
|
||||
vd->vdev_detached || vd->vdev_top->vdev_removing);
|
||||
vd->vdev_detached || vd->vdev_top->vdev_removing ||
|
||||
vd->vdev_top->vdev_rz_expanding);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -67,7 +68,8 @@ vdev_initialize_zap_update_sync(void *arg, dmu_tx_t *tx)
|
||||
kmem_free(arg, sizeof (uint64_t));
|
||||
|
||||
vdev_t *vd = spa_lookup_by_guid(tx->tx_pool->dp_spa, guid, B_FALSE);
|
||||
if (vd == NULL || vd->vdev_top->vdev_removing || !vdev_is_concrete(vd))
|
||||
if (vd == NULL || vd->vdev_top->vdev_removing ||
|
||||
!vdev_is_concrete(vd) || vd->vdev_top->vdev_rz_expanding)
|
||||
return;
|
||||
|
||||
uint64_t last_offset = vd->vdev_initialize_offset[txg & TXG_MASK];
|
||||
@@ -631,6 +633,7 @@ vdev_initialize(vdev_t *vd)
|
||||
ASSERT(!vd->vdev_detached);
|
||||
ASSERT(!vd->vdev_initialize_exit_wanted);
|
||||
ASSERT(!vd->vdev_top->vdev_removing);
|
||||
ASSERT(!vd->vdev_top->vdev_rz_expanding);
|
||||
|
||||
vdev_initialize_change_state(vd, VDEV_INITIALIZE_ACTIVE);
|
||||
vd->vdev_initialize_thread = thread_create(NULL, 0,
|
||||
@@ -791,13 +794,14 @@ vdev_initialize_restart(vdev_t *vd)
|
||||
ASSERT(err == 0 || err == ENOENT);
|
||||
vd->vdev_initialize_action_time = timestamp;
|
||||
|
||||
if (vd->vdev_initialize_state == VDEV_INITIALIZE_SUSPENDED ||
|
||||
vd->vdev_offline) {
|
||||
if ((vd->vdev_initialize_state == VDEV_INITIALIZE_SUSPENDED ||
|
||||
vd->vdev_offline) && !vd->vdev_top->vdev_rz_expanding) {
|
||||
/* load progress for reporting, but don't resume */
|
||||
VERIFY0(vdev_initialize_load(vd));
|
||||
} else if (vd->vdev_initialize_state ==
|
||||
VDEV_INITIALIZE_ACTIVE && vdev_writeable(vd) &&
|
||||
!vd->vdev_top->vdev_removing &&
|
||||
!vd->vdev_top->vdev_rz_expanding &&
|
||||
vd->vdev_initialize_thread == NULL) {
|
||||
vdev_initialize(vd);
|
||||
}
|
||||
|
||||
+47
-4
@@ -142,6 +142,7 @@
|
||||
#include <sys/zap.h>
|
||||
#include <sys/vdev.h>
|
||||
#include <sys/vdev_impl.h>
|
||||
#include <sys/vdev_raidz.h>
|
||||
#include <sys/vdev_draid.h>
|
||||
#include <sys/uberblock_impl.h>
|
||||
#include <sys/metaslab.h>
|
||||
@@ -423,6 +424,13 @@ root_vdev_actions_getprogress(vdev_t *vd, nvlist_t *nvl)
|
||||
ZPOOL_CONFIG_CHECKPOINT_STATS, (uint64_t *)&pcs,
|
||||
sizeof (pcs) / sizeof (uint64_t));
|
||||
}
|
||||
|
||||
pool_raidz_expand_stat_t pres;
|
||||
if (spa_raidz_expand_get_stats(spa, &pres) == 0) {
|
||||
fnvlist_add_uint64_array(nvl,
|
||||
ZPOOL_CONFIG_RAIDZ_EXPAND_STATS, (uint64_t *)&pres,
|
||||
sizeof (pres) / sizeof (uint64_t));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1504,7 +1512,8 @@ vdev_uberblock_compare(const uberblock_t *ub1, const uberblock_t *ub2)
|
||||
}
|
||||
|
||||
struct ubl_cbdata {
|
||||
uberblock_t *ubl_ubbest; /* Best uberblock */
|
||||
uberblock_t ubl_latest; /* Most recent uberblock */
|
||||
uberblock_t *ubl_ubbest; /* Best uberblock (w/r/t max_txg) */
|
||||
vdev_t *ubl_vd; /* vdev associated with the above */
|
||||
};
|
||||
|
||||
@@ -1521,6 +1530,9 @@ vdev_uberblock_load_done(zio_t *zio)
|
||||
|
||||
if (zio->io_error == 0 && uberblock_verify(ub) == 0) {
|
||||
mutex_enter(&rio->io_lock);
|
||||
if (vdev_uberblock_compare(ub, &cbp->ubl_latest) > 0) {
|
||||
cbp->ubl_latest = *ub;
|
||||
}
|
||||
if (ub->ub_txg <= spa->spa_load_max_txg &&
|
||||
vdev_uberblock_compare(ub, cbp->ubl_ubbest) > 0) {
|
||||
/*
|
||||
@@ -1578,10 +1590,10 @@ vdev_uberblock_load(vdev_t *rvd, uberblock_t *ub, nvlist_t **config)
|
||||
ASSERT(config);
|
||||
|
||||
memset(ub, 0, sizeof (uberblock_t));
|
||||
memset(&cb, 0, sizeof (cb));
|
||||
*config = NULL;
|
||||
|
||||
cb.ubl_ubbest = ub;
|
||||
cb.ubl_vd = NULL;
|
||||
|
||||
spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
|
||||
zio = zio_root(spa, NULL, &cb, flags);
|
||||
@@ -1598,6 +1610,22 @@ vdev_uberblock_load(vdev_t *rvd, uberblock_t *ub, nvlist_t **config)
|
||||
vdev_dbgmsg(cb.ubl_vd, "best uberblock found for spa %s. "
|
||||
"txg %llu", spa->spa_name, (u_longlong_t)ub->ub_txg);
|
||||
|
||||
if (ub->ub_raidz_reflow_info !=
|
||||
cb.ubl_latest.ub_raidz_reflow_info) {
|
||||
vdev_dbgmsg(cb.ubl_vd,
|
||||
"spa=%s best uberblock (txg=%llu info=0x%llx) "
|
||||
"has different raidz_reflow_info than latest "
|
||||
"uberblock (txg=%llu info=0x%llx)",
|
||||
spa->spa_name,
|
||||
(u_longlong_t)ub->ub_txg,
|
||||
(u_longlong_t)ub->ub_raidz_reflow_info,
|
||||
(u_longlong_t)cb.ubl_latest.ub_txg,
|
||||
(u_longlong_t)cb.ubl_latest.ub_raidz_reflow_info);
|
||||
memset(ub, 0, sizeof (uberblock_t));
|
||||
spa_config_exit(spa, SCL_ALL, FTAG);
|
||||
return;
|
||||
}
|
||||
|
||||
*config = vdev_label_read_config(cb.ubl_vd, ub->ub_txg);
|
||||
if (*config == NULL && spa->spa_extreme_rewind) {
|
||||
vdev_dbgmsg(cb.ubl_vd, "failed to read label config. "
|
||||
@@ -1719,8 +1747,23 @@ vdev_uberblock_sync(zio_t *zio, uint64_t *good_writes,
|
||||
vd->vdev_copy_uberblocks = B_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* We chose a slot based on the txg. If this uberblock has a special
|
||||
* RAIDZ expansion state, then it is essentially an update of the
|
||||
* current uberblock (it has the same txg). However, the current
|
||||
* state is committed, so we want to write it to a different slot. If
|
||||
* we overwrote the same slot, and we lose power during the uberblock
|
||||
* write, and the disk does not do single-sector overwrites
|
||||
* atomically (even though it is required to - i.e. we should see
|
||||
* either the old or the new uberblock), then we could lose this
|
||||
* txg's uberblock. Rewinding to the previous txg's uberblock may not
|
||||
* be possible because RAIDZ expansion may have already overwritten
|
||||
* some of the data, so we need the progress indicator in the
|
||||
* uberblock.
|
||||
*/
|
||||
int m = spa_multihost(vd->vdev_spa) ? MMP_BLOCKS_PER_LABEL : 0;
|
||||
int n = ub->ub_txg % (VDEV_UBERBLOCK_COUNT(vd) - m);
|
||||
int n = (ub->ub_txg - (RRSS_GET_STATE(ub) == RRSS_SCRATCH_VALID)) %
|
||||
(VDEV_UBERBLOCK_COUNT(vd) - m);
|
||||
|
||||
/* Copy the uberblock_t into the ABD */
|
||||
abd_t *ub_abd = abd_alloc_for_io(VDEV_UBERBLOCK_SIZE(vd), B_TRUE);
|
||||
@@ -1737,7 +1780,7 @@ vdev_uberblock_sync(zio_t *zio, uint64_t *good_writes,
|
||||
}
|
||||
|
||||
/* Sync the uberblocks to all vdevs in svd[] */
|
||||
static int
|
||||
int
|
||||
vdev_uberblock_sync_list(vdev_t **svd, int svdcount, uberblock_t *ub, int flags)
|
||||
{
|
||||
spa_t *spa = svd[0]->vdev_spa;
|
||||
|
||||
+2452
-104
File diff suppressed because it is too large
Load Diff
+12
-5
@@ -169,7 +169,8 @@ static boolean_t
|
||||
vdev_trim_should_stop(vdev_t *vd)
|
||||
{
|
||||
return (vd->vdev_trim_exit_wanted || !vdev_writeable(vd) ||
|
||||
vd->vdev_detached || vd->vdev_top->vdev_removing);
|
||||
vd->vdev_detached || vd->vdev_top->vdev_removing ||
|
||||
vd->vdev_top->vdev_rz_expanding);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -180,6 +181,7 @@ vdev_autotrim_should_stop(vdev_t *tvd)
|
||||
{
|
||||
return (tvd->vdev_autotrim_exit_wanted ||
|
||||
!vdev_writeable(tvd) || tvd->vdev_removing ||
|
||||
tvd->vdev_rz_expanding ||
|
||||
spa_get_autotrim(tvd->vdev_spa) == SPA_AUTOTRIM_OFF);
|
||||
}
|
||||
|
||||
@@ -222,7 +224,8 @@ vdev_trim_zap_update_sync(void *arg, dmu_tx_t *tx)
|
||||
kmem_free(arg, sizeof (uint64_t));
|
||||
|
||||
vdev_t *vd = spa_lookup_by_guid(tx->tx_pool->dp_spa, guid, B_FALSE);
|
||||
if (vd == NULL || vd->vdev_top->vdev_removing || !vdev_is_concrete(vd))
|
||||
if (vd == NULL || vd->vdev_top->vdev_removing ||
|
||||
!vdev_is_concrete(vd) || vd->vdev_top->vdev_rz_expanding)
|
||||
return;
|
||||
|
||||
uint64_t last_offset = vd->vdev_trim_offset[txg & TXG_MASK];
|
||||
@@ -1005,6 +1008,7 @@ vdev_trim(vdev_t *vd, uint64_t rate, boolean_t partial, boolean_t secure)
|
||||
ASSERT(!vd->vdev_detached);
|
||||
ASSERT(!vd->vdev_trim_exit_wanted);
|
||||
ASSERT(!vd->vdev_top->vdev_removing);
|
||||
ASSERT(!vd->vdev_rz_expanding);
|
||||
|
||||
vdev_trim_change_state(vd, VDEV_TRIM_ACTIVE, rate, partial, secure);
|
||||
vd->vdev_trim_thread = thread_create(NULL, 0,
|
||||
@@ -1162,12 +1166,13 @@ vdev_trim_restart(vdev_t *vd)
|
||||
ASSERT(err == 0 || err == ENOENT);
|
||||
vd->vdev_trim_action_time = timestamp;
|
||||
|
||||
if (vd->vdev_trim_state == VDEV_TRIM_SUSPENDED ||
|
||||
vd->vdev_offline) {
|
||||
if ((vd->vdev_trim_state == VDEV_TRIM_SUSPENDED ||
|
||||
vd->vdev_offline) && !vd->vdev_top->vdev_rz_expanding) {
|
||||
/* load progress for reporting, but don't resume */
|
||||
VERIFY0(vdev_trim_load(vd));
|
||||
} else if (vd->vdev_trim_state == VDEV_TRIM_ACTIVE &&
|
||||
vdev_writeable(vd) && !vd->vdev_top->vdev_removing &&
|
||||
!vd->vdev_top->vdev_rz_expanding &&
|
||||
vd->vdev_trim_thread == NULL) {
|
||||
VERIFY0(vdev_trim_load(vd));
|
||||
vdev_trim(vd, vd->vdev_trim_rate,
|
||||
@@ -1492,7 +1497,8 @@ vdev_autotrim(spa_t *spa)
|
||||
|
||||
mutex_enter(&tvd->vdev_autotrim_lock);
|
||||
if (vdev_writeable(tvd) && !tvd->vdev_removing &&
|
||||
tvd->vdev_autotrim_thread == NULL) {
|
||||
tvd->vdev_autotrim_thread == NULL &&
|
||||
!tvd->vdev_rz_expanding) {
|
||||
ASSERT3P(tvd->vdev_top, ==, tvd);
|
||||
|
||||
tvd->vdev_autotrim_thread = thread_create(NULL, 0,
|
||||
@@ -1717,6 +1723,7 @@ vdev_trim_simple(vdev_t *vd, uint64_t start, uint64_t size)
|
||||
ASSERT(vd->vdev_ops->vdev_op_leaf);
|
||||
ASSERT(!vd->vdev_detached);
|
||||
ASSERT(!vd->vdev_top->vdev_removing);
|
||||
ASSERT(!vd->vdev_top->vdev_rz_expanding);
|
||||
|
||||
ta.trim_vdev = vd;
|
||||
ta.trim_tree = range_tree_create(NULL, RANGE_SEG64, NULL, 0, 0);
|
||||
|
||||
Reference in New Issue
Block a user