2010-05-29 00:45:14 +04:00
|
|
|
/*
|
|
|
|
* 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) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
2019-07-26 20:54:14 +03:00
|
|
|
* Copyright (c) 2011, 2018 by Delphix. All rights reserved.
|
2017-05-26 21:42:10 +03:00
|
|
|
* Copyright (c) 2017 Datto Inc.
|
2010-05-29 00:45:14 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/bpobj.h>
|
|
|
|
#include <sys/zfs_context.h>
|
2020-07-30 02:35:33 +03:00
|
|
|
#include <sys/zfs_refcount.h>
|
2011-11-17 22:14:36 +04:00
|
|
|
#include <sys/dsl_pool.h>
|
2012-12-24 03:57:14 +04:00
|
|
|
#include <sys/zfeature.h>
|
|
|
|
#include <sys/zap.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return an empty bpobj, preferably the empty dummy one (dp_empty_bpobj).
|
|
|
|
*/
|
|
|
|
uint64_t
|
|
|
|
bpobj_alloc_empty(objset_t *os, int blocksize, dmu_tx_t *tx)
|
|
|
|
{
|
|
|
|
spa_t *spa = dmu_objset_spa(os);
|
|
|
|
dsl_pool_t *dp = dmu_objset_pool(os);
|
|
|
|
|
2013-10-08 21:13:05 +04:00
|
|
|
if (spa_feature_is_enabled(spa, SPA_FEATURE_EMPTY_BPOBJ)) {
|
|
|
|
if (!spa_feature_is_active(spa, SPA_FEATURE_EMPTY_BPOBJ)) {
|
2013-05-11 01:17:03 +04:00
|
|
|
ASSERT0(dp->dp_empty_bpobj);
|
2012-12-24 03:57:14 +04:00
|
|
|
dp->dp_empty_bpobj =
|
2014-11-03 23:15:08 +03:00
|
|
|
bpobj_alloc(os, SPA_OLD_MAXBLOCKSIZE, tx);
|
2012-12-24 03:57:14 +04:00
|
|
|
VERIFY(zap_add(os,
|
|
|
|
DMU_POOL_DIRECTORY_OBJECT,
|
|
|
|
DMU_POOL_EMPTY_BPOBJ, sizeof (uint64_t), 1,
|
|
|
|
&dp->dp_empty_bpobj, tx) == 0);
|
|
|
|
}
|
2013-10-08 21:13:05 +04:00
|
|
|
spa_feature_incr(spa, SPA_FEATURE_EMPTY_BPOBJ, tx);
|
2012-12-24 03:57:14 +04:00
|
|
|
ASSERT(dp->dp_empty_bpobj != 0);
|
|
|
|
return (dp->dp_empty_bpobj);
|
|
|
|
} else {
|
|
|
|
return (bpobj_alloc(os, blocksize, tx));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
bpobj_decr_empty(objset_t *os, dmu_tx_t *tx)
|
|
|
|
{
|
|
|
|
dsl_pool_t *dp = dmu_objset_pool(os);
|
|
|
|
|
2013-10-08 21:13:05 +04:00
|
|
|
spa_feature_decr(dmu_objset_spa(os), SPA_FEATURE_EMPTY_BPOBJ, tx);
|
|
|
|
if (!spa_feature_is_active(dmu_objset_spa(os),
|
|
|
|
SPA_FEATURE_EMPTY_BPOBJ)) {
|
2012-12-24 03:57:14 +04:00
|
|
|
VERIFY3U(0, ==, zap_remove(dp->dp_meta_objset,
|
|
|
|
DMU_POOL_DIRECTORY_OBJECT,
|
|
|
|
DMU_POOL_EMPTY_BPOBJ, tx));
|
|
|
|
VERIFY3U(0, ==, dmu_object_free(os, dp->dp_empty_bpobj, tx));
|
|
|
|
dp->dp_empty_bpobj = 0;
|
|
|
|
}
|
|
|
|
}
|
2010-05-29 00:45:14 +04:00
|
|
|
|
|
|
|
uint64_t
|
|
|
|
bpobj_alloc(objset_t *os, int blocksize, dmu_tx_t *tx)
|
|
|
|
{
|
|
|
|
int size;
|
|
|
|
|
|
|
|
if (spa_version(dmu_objset_spa(os)) < SPA_VERSION_BPOBJ_ACCOUNT)
|
|
|
|
size = BPOBJ_SIZE_V0;
|
|
|
|
else if (spa_version(dmu_objset_spa(os)) < SPA_VERSION_DEADLISTS)
|
|
|
|
size = BPOBJ_SIZE_V1;
|
2019-07-26 20:54:14 +03:00
|
|
|
else if (!spa_feature_is_active(dmu_objset_spa(os),
|
|
|
|
SPA_FEATURE_LIVELIST))
|
|
|
|
size = BPOBJ_SIZE_V2;
|
2010-05-29 00:45:14 +04:00
|
|
|
else
|
|
|
|
size = sizeof (bpobj_phys_t);
|
|
|
|
|
|
|
|
return (dmu_object_alloc(os, DMU_OT_BPOBJ, blocksize,
|
|
|
|
DMU_OT_BPOBJ_HDR, size, tx));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
bpobj_free(objset_t *os, uint64_t obj, dmu_tx_t *tx)
|
|
|
|
{
|
|
|
|
int64_t i;
|
|
|
|
bpobj_t bpo;
|
|
|
|
dmu_object_info_t doi;
|
|
|
|
int epb;
|
|
|
|
dmu_buf_t *dbuf = NULL;
|
|
|
|
|
2012-12-24 03:57:14 +04:00
|
|
|
ASSERT(obj != dmu_objset_pool(os)->dp_empty_bpobj);
|
2010-05-29 00:45:14 +04:00
|
|
|
VERIFY3U(0, ==, bpobj_open(&bpo, os, obj));
|
|
|
|
|
|
|
|
mutex_enter(&bpo.bpo_lock);
|
|
|
|
|
|
|
|
if (!bpo.bpo_havesubobj || bpo.bpo_phys->bpo_subobjs == 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
VERIFY3U(0, ==, dmu_object_info(os, bpo.bpo_phys->bpo_subobjs, &doi));
|
|
|
|
epb = doi.doi_data_block_size / sizeof (uint64_t);
|
|
|
|
|
|
|
|
for (i = bpo.bpo_phys->bpo_num_subobjs - 1; i >= 0; i--) {
|
|
|
|
uint64_t *objarray;
|
|
|
|
uint64_t offset, blkoff;
|
|
|
|
|
|
|
|
offset = i * sizeof (uint64_t);
|
|
|
|
blkoff = P2PHASE(i, epb);
|
|
|
|
|
|
|
|
if (dbuf == NULL || dbuf->db_offset > offset) {
|
|
|
|
if (dbuf)
|
|
|
|
dmu_buf_rele(dbuf, FTAG);
|
|
|
|
VERIFY3U(0, ==, dmu_buf_hold(os,
|
|
|
|
bpo.bpo_phys->bpo_subobjs, offset, FTAG, &dbuf, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
ASSERT3U(offset, >=, dbuf->db_offset);
|
|
|
|
ASSERT3U(offset, <, dbuf->db_offset + dbuf->db_size);
|
|
|
|
|
|
|
|
objarray = dbuf->db_data;
|
|
|
|
bpobj_free(os, objarray[blkoff], tx);
|
|
|
|
}
|
|
|
|
if (dbuf) {
|
|
|
|
dmu_buf_rele(dbuf, FTAG);
|
|
|
|
dbuf = NULL;
|
|
|
|
}
|
|
|
|
VERIFY3U(0, ==, dmu_object_free(os, bpo.bpo_phys->bpo_subobjs, tx));
|
|
|
|
|
|
|
|
out:
|
|
|
|
mutex_exit(&bpo.bpo_lock);
|
|
|
|
bpobj_close(&bpo);
|
|
|
|
|
|
|
|
VERIFY3U(0, ==, dmu_object_free(os, obj, tx));
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
bpobj_open(bpobj_t *bpo, objset_t *os, uint64_t object)
|
|
|
|
{
|
|
|
|
dmu_object_info_t doi;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = dmu_object_info(os, object, &doi);
|
|
|
|
if (err)
|
|
|
|
return (err);
|
|
|
|
|
|
|
|
bzero(bpo, sizeof (*bpo));
|
|
|
|
mutex_init(&bpo->bpo_lock, NULL, MUTEX_DEFAULT, NULL);
|
|
|
|
|
|
|
|
ASSERT(bpo->bpo_dbuf == NULL);
|
|
|
|
ASSERT(bpo->bpo_phys == NULL);
|
|
|
|
ASSERT(object != 0);
|
|
|
|
ASSERT3U(doi.doi_type, ==, DMU_OT_BPOBJ);
|
|
|
|
ASSERT3U(doi.doi_bonus_type, ==, DMU_OT_BPOBJ_HDR);
|
|
|
|
|
2010-08-27 01:24:34 +04:00
|
|
|
err = dmu_bonus_hold(os, object, bpo, &bpo->bpo_dbuf);
|
|
|
|
if (err)
|
|
|
|
return (err);
|
|
|
|
|
2010-05-29 00:45:14 +04:00
|
|
|
bpo->bpo_os = os;
|
|
|
|
bpo->bpo_object = object;
|
|
|
|
bpo->bpo_epb = doi.doi_data_block_size >> SPA_BLKPTRSHIFT;
|
|
|
|
bpo->bpo_havecomp = (doi.doi_bonus_size > BPOBJ_SIZE_V0);
|
|
|
|
bpo->bpo_havesubobj = (doi.doi_bonus_size > BPOBJ_SIZE_V1);
|
2019-07-26 20:54:14 +03:00
|
|
|
bpo->bpo_havefreed = (doi.doi_bonus_size > BPOBJ_SIZE_V2);
|
2010-05-29 00:45:14 +04:00
|
|
|
bpo->bpo_phys = bpo->bpo_dbuf->db_data;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
OpenZFS 7614, 9064 - zfs device evacuation/removal
OpenZFS 7614 - zfs device evacuation/removal
OpenZFS 9064 - remove_mirror should wait for device removal to complete
This project allows top-level vdevs to be removed from the storage pool
with "zpool remove", reducing the total amount of storage in the pool.
This operation copies all allocated regions of the device to be removed
onto other devices, recording the mapping from old to new location.
After the removal is complete, read and free operations to the removed
(now "indirect") vdev must be remapped and performed at the new location
on disk. The indirect mapping table is kept in memory whenever the pool
is loaded, so there is minimal performance overhead when doing operations
on the indirect vdev.
The size of the in-memory mapping table will be reduced when its entries
become "obsolete" because they are no longer used by any block pointers
in the pool. An entry becomes obsolete when all the blocks that use
it are freed. An entry can also become obsolete when all the snapshots
that reference it are deleted, and the block pointers that reference it
have been "remapped" in all filesystems/zvols (and clones). Whenever an
indirect block is written, all the block pointers in it will be "remapped"
to their new (concrete) locations if possible. This process can be
accelerated by using the "zfs remap" command to proactively rewrite all
indirect blocks that reference indirect (removed) vdevs.
Note that when a device is removed, we do not verify the checksum of
the data that is copied. This makes the process much faster, but if it
were used on redundant vdevs (i.e. mirror or raidz vdevs), it would be
possible to copy the wrong data, when we have the correct data on e.g.
the other side of the mirror.
At the moment, only mirrors and simple top-level vdevs can be removed
and no removal is allowed if any of the top-level vdevs are raidz.
Porting Notes:
* Avoid zero-sized kmem_alloc() in vdev_compact_children().
The device evacuation code adds a dependency that
vdev_compact_children() be able to properly empty the vdev_child
array by setting it to NULL and zeroing vdev_children. Under Linux,
kmem_alloc() and related functions return a sentinel pointer rather
than NULL for zero-sized allocations.
* Remove comment regarding "mpt" driver where zfs_remove_max_segment
is initialized to SPA_MAXBLOCKSIZE.
Change zfs_condense_indirect_commit_entry_delay_ticks to
zfs_condense_indirect_commit_entry_delay_ms for consistency with
most other tunables in which delays are specified in ms.
* ZTS changes:
Use set_tunable rather than mdb
Use zpool sync as appropriate
Use sync_pool instead of sync
Kill jobs during test_removal_with_operation to allow unmount/export
Don't add non-disk names such as "mirror" or "raidz" to $DISKS
Use $TEST_BASE_DIR instead of /tmp
Increase HZ from 100 to 1000 which is more common on Linux
removal_multiple_indirection.ksh
Reduce iterations in order to not time out on the code
coverage builders.
removal_resume_export:
Functionally, the test case is correct but there exists a race
where the kernel thread hasn't been fully started yet and is
not visible. Wait for up to 1 second for the removal thread
to be started before giving up on it. Also, increase the
amount of data copied in order that the removal not finish
before the export has a chance to fail.
* MMP compatibility, the concept of concrete versus non-concrete devices
has slightly changed the semantics of vdev_writeable(). Update
mmp_random_leaf_impl() accordingly.
* Updated dbuf_remap() to handle the org.zfsonlinux:large_dnode pool
feature which is not supported by OpenZFS.
* Added support for new vdev removal tracepoints.
* Test cases removal_with_zdb and removal_condense_export have been
intentionally disabled. When run manually they pass as intended,
but when running in the automated test environment they produce
unreliable results on the latest Fedora release.
They may work better once the upstream pool import refectoring is
merged into ZoL at which point they will be re-enabled.
Authored by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Alex Reece <alex@delphix.com>
Reviewed-by: George Wilson <george.wilson@delphix.com>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Richard Laager <rlaager@wiktel.com>
Reviewed by: Tim Chase <tim@chase2k.com>
Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Approved by: Garrett D'Amore <garrett@damore.org>
Ported-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Tim Chase <tim@chase2k.com>
OpenZFS-issue: https://www.illumos.org/issues/7614
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/f539f1eb
Closes #6900
2016-09-22 19:30:13 +03:00
|
|
|
boolean_t
|
|
|
|
bpobj_is_open(const bpobj_t *bpo)
|
|
|
|
{
|
|
|
|
return (bpo->bpo_object != 0);
|
|
|
|
}
|
|
|
|
|
2010-05-29 00:45:14 +04:00
|
|
|
void
|
|
|
|
bpobj_close(bpobj_t *bpo)
|
|
|
|
{
|
|
|
|
/* Lame workaround for closing a bpobj that was never opened. */
|
|
|
|
if (bpo->bpo_object == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
dmu_buf_rele(bpo->bpo_dbuf, bpo);
|
|
|
|
if (bpo->bpo_cached_dbuf != NULL)
|
|
|
|
dmu_buf_rele(bpo->bpo_cached_dbuf, bpo);
|
|
|
|
bpo->bpo_dbuf = NULL;
|
|
|
|
bpo->bpo_phys = NULL;
|
|
|
|
bpo->bpo_cached_dbuf = NULL;
|
2010-08-27 01:24:34 +04:00
|
|
|
bpo->bpo_object = 0;
|
2010-05-29 00:45:14 +04:00
|
|
|
|
|
|
|
mutex_destroy(&bpo->bpo_lock);
|
|
|
|
}
|
|
|
|
|
Add subcommand to wait for background zfs activity to complete
Currently the best way to wait for the completion of a long-running
operation in a pool, like a scrub or device removal, is to poll 'zpool
status' and parse its output, which is neither efficient nor convenient.
This change adds a 'wait' subcommand to the zpool command. When invoked,
'zpool wait' will block until a specified type of background activity
completes. Currently, this subcommand can wait for any of the following:
- Scrubs or resilvers to complete
- Devices to initialized
- Devices to be replaced
- Devices to be removed
- Checkpoints to be discarded
- Background freeing to complete
For example, a scrub that is in progress could be waited for by running
zpool wait -t scrub <pool>
This also adds a -w flag to the attach, checkpoint, initialize, replace,
remove, and scrub subcommands. When used, this flag makes the operations
kicked off by these subcommands synchronous instead of asynchronous.
This functionality is implemented using a new ioctl. The type of
activity to wait for is provided as input to the ioctl, and the ioctl
blocks until all activity of that type has completed. An ioctl was used
over other methods of kernel-userspace communiction primarily for the
sake of portability.
Porting Notes:
This is ported from Delphix OS change DLPX-44432. The following changes
were made while porting:
- Added ZoL-style ioctl input declaration.
- Reorganized error handling in zpool_initialize in libzfs to integrate
better with changes made for TRIM support.
- Fixed check for whether a checkpoint discard is in progress.
Previously it also waited if the pool had a checkpoint, instead of
just if a checkpoint was being discarded.
- Exposed zfs_initialize_chunk_size as a ZoL-style tunable.
- Updated more existing tests to make use of new 'zpool wait'
functionality, tests that don't exist in Delphix OS.
- Used existing ZoL tunable zfs_scan_suspend_progress, together with
zinject, in place of a new tunable zfs_scan_max_blks_per_txg.
- Added support for a non-integral interval argument to zpool wait.
Future work:
ZoL has support for trimming devices, which Delphix OS does not. In the
future, 'zpool wait' could be extended to add the ability to wait for
trim operations to complete.
Reviewed-by: Matt Ahrens <matt@delphix.com>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: John Gallagher <john.gallagher@delphix.com>
Closes #9162
2019-09-14 04:09:06 +03:00
|
|
|
static boolean_t
|
|
|
|
bpobj_is_empty_impl(bpobj_t *bpo)
|
2014-06-06 01:19:08 +04:00
|
|
|
{
|
Add subcommand to wait for background zfs activity to complete
Currently the best way to wait for the completion of a long-running
operation in a pool, like a scrub or device removal, is to poll 'zpool
status' and parse its output, which is neither efficient nor convenient.
This change adds a 'wait' subcommand to the zpool command. When invoked,
'zpool wait' will block until a specified type of background activity
completes. Currently, this subcommand can wait for any of the following:
- Scrubs or resilvers to complete
- Devices to initialized
- Devices to be replaced
- Devices to be removed
- Checkpoints to be discarded
- Background freeing to complete
For example, a scrub that is in progress could be waited for by running
zpool wait -t scrub <pool>
This also adds a -w flag to the attach, checkpoint, initialize, replace,
remove, and scrub subcommands. When used, this flag makes the operations
kicked off by these subcommands synchronous instead of asynchronous.
This functionality is implemented using a new ioctl. The type of
activity to wait for is provided as input to the ioctl, and the ioctl
blocks until all activity of that type has completed. An ioctl was used
over other methods of kernel-userspace communiction primarily for the
sake of portability.
Porting Notes:
This is ported from Delphix OS change DLPX-44432. The following changes
were made while porting:
- Added ZoL-style ioctl input declaration.
- Reorganized error handling in zpool_initialize in libzfs to integrate
better with changes made for TRIM support.
- Fixed check for whether a checkpoint discard is in progress.
Previously it also waited if the pool had a checkpoint, instead of
just if a checkpoint was being discarded.
- Exposed zfs_initialize_chunk_size as a ZoL-style tunable.
- Updated more existing tests to make use of new 'zpool wait'
functionality, tests that don't exist in Delphix OS.
- Used existing ZoL tunable zfs_scan_suspend_progress, together with
zinject, in place of a new tunable zfs_scan_max_blks_per_txg.
- Added support for a non-integral interval argument to zpool wait.
Future work:
ZoL has support for trimming devices, which Delphix OS does not. In the
future, 'zpool wait' could be extended to add the ability to wait for
trim operations to complete.
Reviewed-by: Matt Ahrens <matt@delphix.com>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: John Gallagher <john.gallagher@delphix.com>
Closes #9162
2019-09-14 04:09:06 +03:00
|
|
|
ASSERT(MUTEX_HELD(&bpo->bpo_lock));
|
OpenZFS 7614, 9064 - zfs device evacuation/removal
OpenZFS 7614 - zfs device evacuation/removal
OpenZFS 9064 - remove_mirror should wait for device removal to complete
This project allows top-level vdevs to be removed from the storage pool
with "zpool remove", reducing the total amount of storage in the pool.
This operation copies all allocated regions of the device to be removed
onto other devices, recording the mapping from old to new location.
After the removal is complete, read and free operations to the removed
(now "indirect") vdev must be remapped and performed at the new location
on disk. The indirect mapping table is kept in memory whenever the pool
is loaded, so there is minimal performance overhead when doing operations
on the indirect vdev.
The size of the in-memory mapping table will be reduced when its entries
become "obsolete" because they are no longer used by any block pointers
in the pool. An entry becomes obsolete when all the blocks that use
it are freed. An entry can also become obsolete when all the snapshots
that reference it are deleted, and the block pointers that reference it
have been "remapped" in all filesystems/zvols (and clones). Whenever an
indirect block is written, all the block pointers in it will be "remapped"
to their new (concrete) locations if possible. This process can be
accelerated by using the "zfs remap" command to proactively rewrite all
indirect blocks that reference indirect (removed) vdevs.
Note that when a device is removed, we do not verify the checksum of
the data that is copied. This makes the process much faster, but if it
were used on redundant vdevs (i.e. mirror or raidz vdevs), it would be
possible to copy the wrong data, when we have the correct data on e.g.
the other side of the mirror.
At the moment, only mirrors and simple top-level vdevs can be removed
and no removal is allowed if any of the top-level vdevs are raidz.
Porting Notes:
* Avoid zero-sized kmem_alloc() in vdev_compact_children().
The device evacuation code adds a dependency that
vdev_compact_children() be able to properly empty the vdev_child
array by setting it to NULL and zeroing vdev_children. Under Linux,
kmem_alloc() and related functions return a sentinel pointer rather
than NULL for zero-sized allocations.
* Remove comment regarding "mpt" driver where zfs_remove_max_segment
is initialized to SPA_MAXBLOCKSIZE.
Change zfs_condense_indirect_commit_entry_delay_ticks to
zfs_condense_indirect_commit_entry_delay_ms for consistency with
most other tunables in which delays are specified in ms.
* ZTS changes:
Use set_tunable rather than mdb
Use zpool sync as appropriate
Use sync_pool instead of sync
Kill jobs during test_removal_with_operation to allow unmount/export
Don't add non-disk names such as "mirror" or "raidz" to $DISKS
Use $TEST_BASE_DIR instead of /tmp
Increase HZ from 100 to 1000 which is more common on Linux
removal_multiple_indirection.ksh
Reduce iterations in order to not time out on the code
coverage builders.
removal_resume_export:
Functionally, the test case is correct but there exists a race
where the kernel thread hasn't been fully started yet and is
not visible. Wait for up to 1 second for the removal thread
to be started before giving up on it. Also, increase the
amount of data copied in order that the removal not finish
before the export has a chance to fail.
* MMP compatibility, the concept of concrete versus non-concrete devices
has slightly changed the semantics of vdev_writeable(). Update
mmp_random_leaf_impl() accordingly.
* Updated dbuf_remap() to handle the org.zfsonlinux:large_dnode pool
feature which is not supported by OpenZFS.
* Added support for new vdev removal tracepoints.
* Test cases removal_with_zdb and removal_condense_export have been
intentionally disabled. When run manually they pass as intended,
but when running in the automated test environment they produce
unreliable results on the latest Fedora release.
They may work better once the upstream pool import refectoring is
merged into ZoL at which point they will be re-enabled.
Authored by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Alex Reece <alex@delphix.com>
Reviewed-by: George Wilson <george.wilson@delphix.com>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Richard Laager <rlaager@wiktel.com>
Reviewed by: Tim Chase <tim@chase2k.com>
Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Approved by: Garrett D'Amore <garrett@damore.org>
Ported-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Tim Chase <tim@chase2k.com>
OpenZFS-issue: https://www.illumos.org/issues/7614
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/f539f1eb
Closes #6900
2016-09-22 19:30:13 +03:00
|
|
|
return (bpo->bpo_phys->bpo_num_blkptrs == 0 &&
|
|
|
|
(!bpo->bpo_havesubobj || bpo->bpo_phys->bpo_num_subobjs == 0));
|
2014-06-06 01:19:08 +04:00
|
|
|
}
|
|
|
|
|
Add subcommand to wait for background zfs activity to complete
Currently the best way to wait for the completion of a long-running
operation in a pool, like a scrub or device removal, is to poll 'zpool
status' and parse its output, which is neither efficient nor convenient.
This change adds a 'wait' subcommand to the zpool command. When invoked,
'zpool wait' will block until a specified type of background activity
completes. Currently, this subcommand can wait for any of the following:
- Scrubs or resilvers to complete
- Devices to initialized
- Devices to be replaced
- Devices to be removed
- Checkpoints to be discarded
- Background freeing to complete
For example, a scrub that is in progress could be waited for by running
zpool wait -t scrub <pool>
This also adds a -w flag to the attach, checkpoint, initialize, replace,
remove, and scrub subcommands. When used, this flag makes the operations
kicked off by these subcommands synchronous instead of asynchronous.
This functionality is implemented using a new ioctl. The type of
activity to wait for is provided as input to the ioctl, and the ioctl
blocks until all activity of that type has completed. An ioctl was used
over other methods of kernel-userspace communiction primarily for the
sake of portability.
Porting Notes:
This is ported from Delphix OS change DLPX-44432. The following changes
were made while porting:
- Added ZoL-style ioctl input declaration.
- Reorganized error handling in zpool_initialize in libzfs to integrate
better with changes made for TRIM support.
- Fixed check for whether a checkpoint discard is in progress.
Previously it also waited if the pool had a checkpoint, instead of
just if a checkpoint was being discarded.
- Exposed zfs_initialize_chunk_size as a ZoL-style tunable.
- Updated more existing tests to make use of new 'zpool wait'
functionality, tests that don't exist in Delphix OS.
- Used existing ZoL tunable zfs_scan_suspend_progress, together with
zinject, in place of a new tunable zfs_scan_max_blks_per_txg.
- Added support for a non-integral interval argument to zpool wait.
Future work:
ZoL has support for trimming devices, which Delphix OS does not. In the
future, 'zpool wait' could be extended to add the ability to wait for
trim operations to complete.
Reviewed-by: Matt Ahrens <matt@delphix.com>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: John Gallagher <john.gallagher@delphix.com>
Closes #9162
2019-09-14 04:09:06 +03:00
|
|
|
boolean_t
|
|
|
|
bpobj_is_empty(bpobj_t *bpo)
|
|
|
|
{
|
|
|
|
mutex_enter(&bpo->bpo_lock);
|
|
|
|
boolean_t is_empty = bpobj_is_empty_impl(bpo);
|
|
|
|
mutex_exit(&bpo->bpo_lock);
|
|
|
|
return (is_empty);
|
|
|
|
}
|
|
|
|
|
2019-03-06 20:50:55 +03:00
|
|
|
/*
|
|
|
|
* A recursive iteration of the bpobjs would be nice here but we run the risk
|
|
|
|
* of overflowing function stack space. Instead, find each subobj and add it
|
|
|
|
* to the head of our list so it can be scanned for subjobjs. Like a
|
|
|
|
* recursive implementation, the "deepest" subobjs will be freed first.
|
|
|
|
* When a subobj is found to have no additional subojs, free it.
|
|
|
|
*/
|
|
|
|
typedef struct bpobj_info {
|
|
|
|
bpobj_t *bpi_bpo;
|
|
|
|
/*
|
|
|
|
* This object is a subobj of bpi_parent,
|
|
|
|
* at bpi_index in its subobj array.
|
|
|
|
*/
|
|
|
|
struct bpobj_info *bpi_parent;
|
|
|
|
uint64_t bpi_index;
|
|
|
|
/* How many of our subobj's are left to process. */
|
|
|
|
uint64_t bpi_unprocessed_subobjs;
|
|
|
|
/* True after having visited this bpo's directly referenced BPs. */
|
|
|
|
boolean_t bpi_visited;
|
|
|
|
list_node_t bpi_node;
|
|
|
|
} bpobj_info_t;
|
|
|
|
|
|
|
|
static bpobj_info_t *
|
|
|
|
bpi_alloc(bpobj_t *bpo, bpobj_info_t *parent, uint64_t index)
|
2010-05-29 00:45:14 +04:00
|
|
|
{
|
2019-03-06 20:50:55 +03:00
|
|
|
bpobj_info_t *bpi = kmem_zalloc(sizeof (bpobj_info_t), KM_SLEEP);
|
|
|
|
bpi->bpi_bpo = bpo;
|
|
|
|
bpi->bpi_parent = parent;
|
|
|
|
bpi->bpi_index = index;
|
|
|
|
if (bpo->bpo_havesubobj && bpo->bpo_phys->bpo_subobjs != 0) {
|
|
|
|
bpi->bpi_unprocessed_subobjs = bpo->bpo_phys->bpo_num_subobjs;
|
|
|
|
}
|
|
|
|
return (bpi);
|
|
|
|
}
|
2010-05-29 00:45:14 +04:00
|
|
|
|
2019-03-06 20:50:55 +03:00
|
|
|
/*
|
|
|
|
* Update bpobj and all of its parents with new space accounting.
|
|
|
|
*/
|
|
|
|
static void
|
2019-07-26 20:54:14 +03:00
|
|
|
propagate_space_reduction(bpobj_info_t *bpi, int64_t freed,
|
|
|
|
int64_t comp_freed, int64_t uncomp_freed, dmu_tx_t *tx)
|
2019-03-06 20:50:55 +03:00
|
|
|
{
|
2010-05-29 00:45:14 +04:00
|
|
|
|
2019-03-06 20:50:55 +03:00
|
|
|
for (; bpi != NULL; bpi = bpi->bpi_parent) {
|
|
|
|
bpobj_t *p = bpi->bpi_bpo;
|
|
|
|
ASSERT(dmu_buf_is_dirty(p->bpo_dbuf, tx));
|
|
|
|
p->bpo_phys->bpo_bytes -= freed;
|
|
|
|
ASSERT3S(p->bpo_phys->bpo_bytes, >=, 0);
|
|
|
|
if (p->bpo_havecomp) {
|
|
|
|
p->bpo_phys->bpo_comp -= comp_freed;
|
|
|
|
p->bpo_phys->bpo_uncomp -= uncomp_freed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-05-29 00:45:14 +04:00
|
|
|
|
2019-03-06 20:50:55 +03:00
|
|
|
static int
|
|
|
|
bpobj_iterate_blkptrs(bpobj_info_t *bpi, bpobj_itor_t func, void *arg,
|
2019-07-26 20:54:14 +03:00
|
|
|
int64_t start, dmu_tx_t *tx, boolean_t free)
|
2019-03-06 20:50:55 +03:00
|
|
|
{
|
|
|
|
int err = 0;
|
2019-07-26 20:54:14 +03:00
|
|
|
int64_t freed = 0, comp_freed = 0, uncomp_freed = 0;
|
2019-03-06 20:50:55 +03:00
|
|
|
dmu_buf_t *dbuf = NULL;
|
|
|
|
bpobj_t *bpo = bpi->bpi_bpo;
|
2010-05-29 00:45:14 +04:00
|
|
|
|
2019-07-26 20:54:14 +03:00
|
|
|
for (int64_t i = bpo->bpo_phys->bpo_num_blkptrs - 1; i >= start; i--) {
|
2019-03-06 20:50:55 +03:00
|
|
|
uint64_t offset = i * sizeof (blkptr_t);
|
|
|
|
uint64_t blkoff = P2PHASE(i, bpo->bpo_epb);
|
2010-05-29 00:45:14 +04:00
|
|
|
|
|
|
|
if (dbuf == NULL || dbuf->db_offset > offset) {
|
|
|
|
if (dbuf)
|
|
|
|
dmu_buf_rele(dbuf, FTAG);
|
2019-07-26 20:54:14 +03:00
|
|
|
err = dmu_buf_hold(bpo->bpo_os, bpo->bpo_object,
|
|
|
|
offset, FTAG, &dbuf, 0);
|
2010-05-29 00:45:14 +04:00
|
|
|
if (err)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ASSERT3U(offset, >=, dbuf->db_offset);
|
|
|
|
ASSERT3U(offset, <, dbuf->db_offset + dbuf->db_size);
|
|
|
|
|
2019-03-06 20:50:55 +03:00
|
|
|
blkptr_t *bparray = dbuf->db_data;
|
|
|
|
blkptr_t *bp = &bparray[blkoff];
|
2019-07-26 20:54:14 +03:00
|
|
|
|
|
|
|
boolean_t bp_freed = BP_GET_FREE(bp);
|
|
|
|
err = func(arg, bp, bp_freed, tx);
|
2010-05-29 00:45:14 +04:00
|
|
|
if (err)
|
|
|
|
break;
|
2019-03-06 20:50:55 +03:00
|
|
|
|
2010-05-29 00:45:14 +04:00
|
|
|
if (free) {
|
2019-07-26 20:54:14 +03:00
|
|
|
int sign = bp_freed ? -1 : +1;
|
2019-03-06 20:50:55 +03:00
|
|
|
spa_t *spa = dmu_objset_spa(bpo->bpo_os);
|
2019-07-26 20:54:14 +03:00
|
|
|
freed += sign * bp_get_dsize_sync(spa, bp);
|
|
|
|
comp_freed += sign * BP_GET_PSIZE(bp);
|
|
|
|
uncomp_freed += sign * BP_GET_UCSIZE(bp);
|
2019-03-06 20:50:55 +03:00
|
|
|
ASSERT(dmu_buf_is_dirty(bpo->bpo_dbuf, tx));
|
2010-05-29 00:45:14 +04:00
|
|
|
bpo->bpo_phys->bpo_num_blkptrs--;
|
|
|
|
ASSERT3S(bpo->bpo_phys->bpo_num_blkptrs, >=, 0);
|
2019-07-26 20:54:14 +03:00
|
|
|
if (bp_freed) {
|
|
|
|
ASSERT(bpo->bpo_havefreed);
|
|
|
|
bpo->bpo_phys->bpo_num_freed--;
|
|
|
|
ASSERT3S(bpo->bpo_phys->bpo_num_freed, >=, 0);
|
|
|
|
}
|
2010-05-29 00:45:14 +04:00
|
|
|
}
|
|
|
|
}
|
2019-03-06 20:50:55 +03:00
|
|
|
if (free) {
|
|
|
|
propagate_space_reduction(bpi, freed, comp_freed,
|
|
|
|
uncomp_freed, tx);
|
|
|
|
VERIFY0(dmu_free_range(bpo->bpo_os,
|
|
|
|
bpo->bpo_object,
|
|
|
|
bpo->bpo_phys->bpo_num_blkptrs * sizeof (blkptr_t),
|
|
|
|
DMU_OBJECT_END, tx));
|
|
|
|
}
|
2010-05-29 00:45:14 +04:00
|
|
|
if (dbuf) {
|
|
|
|
dmu_buf_rele(dbuf, FTAG);
|
|
|
|
dbuf = NULL;
|
|
|
|
}
|
2019-03-06 20:50:55 +03:00
|
|
|
return (err);
|
|
|
|
}
|
2010-05-29 00:45:14 +04:00
|
|
|
|
2019-03-06 20:50:55 +03:00
|
|
|
/*
|
|
|
|
* Given an initial bpo, start by freeing the BPs that are directly referenced
|
|
|
|
* by that bpo. If the bpo has subobjs, read in its last subobj and push the
|
|
|
|
* subobj to our stack. By popping items off our stack, eventually we will
|
|
|
|
* encounter a bpo that has no subobjs. We can free its bpobj_info_t, and if
|
|
|
|
* requested also free the now-empty bpo from disk and decrement
|
|
|
|
* its parent's subobj count. We continue popping each subobj from our stack,
|
|
|
|
* visiting its last subobj until they too have no more subobjs, and so on.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
bpobj_iterate_impl(bpobj_t *initial_bpo, bpobj_itor_t func, void *arg,
|
2019-07-26 20:54:14 +03:00
|
|
|
dmu_tx_t *tx, boolean_t free, uint64_t *bpobj_size)
|
2019-03-06 20:50:55 +03:00
|
|
|
{
|
|
|
|
list_t stack;
|
|
|
|
bpobj_info_t *bpi;
|
|
|
|
int err = 0;
|
2010-05-29 00:45:14 +04:00
|
|
|
|
2019-03-06 20:50:55 +03:00
|
|
|
/*
|
|
|
|
* Create a "stack" for us to work with without worrying about
|
|
|
|
* stack overflows. Initialize it with the initial_bpo.
|
|
|
|
*/
|
|
|
|
list_create(&stack, sizeof (bpobj_info_t),
|
|
|
|
offsetof(bpobj_info_t, bpi_node));
|
|
|
|
mutex_enter(&initial_bpo->bpo_lock);
|
2019-07-26 20:54:14 +03:00
|
|
|
|
|
|
|
if (bpobj_size != NULL)
|
|
|
|
*bpobj_size = initial_bpo->bpo_phys->bpo_num_blkptrs;
|
|
|
|
|
2019-03-06 20:50:55 +03:00
|
|
|
list_insert_head(&stack, bpi_alloc(initial_bpo, NULL, 0));
|
|
|
|
|
|
|
|
while ((bpi = list_head(&stack)) != NULL) {
|
|
|
|
bpobj_t *bpo = bpi->bpi_bpo;
|
|
|
|
|
|
|
|
ASSERT3P(bpo, !=, NULL);
|
|
|
|
ASSERT(MUTEX_HELD(&bpo->bpo_lock));
|
|
|
|
ASSERT(bpobj_is_open(bpo));
|
|
|
|
|
|
|
|
if (free)
|
|
|
|
dmu_buf_will_dirty(bpo->bpo_dbuf, tx);
|
|
|
|
|
|
|
|
if (bpi->bpi_visited == B_FALSE) {
|
2019-07-26 20:54:14 +03:00
|
|
|
err = bpobj_iterate_blkptrs(bpi, func, arg, 0, tx,
|
|
|
|
free);
|
2019-03-06 20:50:55 +03:00
|
|
|
bpi->bpi_visited = B_TRUE;
|
|
|
|
if (err != 0)
|
2010-05-29 00:45:14 +04:00
|
|
|
break;
|
|
|
|
}
|
2019-03-06 20:50:55 +03:00
|
|
|
/*
|
|
|
|
* We've finished with this bpo's directly-referenced BP's and
|
|
|
|
* it has no more unprocessed subobjs. We can free its
|
|
|
|
* bpobj_info_t (unless it is the topmost, initial_bpo).
|
|
|
|
* If we are freeing from disk, we can also do that.
|
|
|
|
*/
|
|
|
|
if (bpi->bpi_unprocessed_subobjs == 0) {
|
|
|
|
/*
|
|
|
|
* If there are no entries, there should
|
|
|
|
* be no bytes.
|
|
|
|
*/
|
Add subcommand to wait for background zfs activity to complete
Currently the best way to wait for the completion of a long-running
operation in a pool, like a scrub or device removal, is to poll 'zpool
status' and parse its output, which is neither efficient nor convenient.
This change adds a 'wait' subcommand to the zpool command. When invoked,
'zpool wait' will block until a specified type of background activity
completes. Currently, this subcommand can wait for any of the following:
- Scrubs or resilvers to complete
- Devices to initialized
- Devices to be replaced
- Devices to be removed
- Checkpoints to be discarded
- Background freeing to complete
For example, a scrub that is in progress could be waited for by running
zpool wait -t scrub <pool>
This also adds a -w flag to the attach, checkpoint, initialize, replace,
remove, and scrub subcommands. When used, this flag makes the operations
kicked off by these subcommands synchronous instead of asynchronous.
This functionality is implemented using a new ioctl. The type of
activity to wait for is provided as input to the ioctl, and the ioctl
blocks until all activity of that type has completed. An ioctl was used
over other methods of kernel-userspace communiction primarily for the
sake of portability.
Porting Notes:
This is ported from Delphix OS change DLPX-44432. The following changes
were made while porting:
- Added ZoL-style ioctl input declaration.
- Reorganized error handling in zpool_initialize in libzfs to integrate
better with changes made for TRIM support.
- Fixed check for whether a checkpoint discard is in progress.
Previously it also waited if the pool had a checkpoint, instead of
just if a checkpoint was being discarded.
- Exposed zfs_initialize_chunk_size as a ZoL-style tunable.
- Updated more existing tests to make use of new 'zpool wait'
functionality, tests that don't exist in Delphix OS.
- Used existing ZoL tunable zfs_scan_suspend_progress, together with
zinject, in place of a new tunable zfs_scan_max_blks_per_txg.
- Added support for a non-integral interval argument to zpool wait.
Future work:
ZoL has support for trimming devices, which Delphix OS does not. In the
future, 'zpool wait' could be extended to add the ability to wait for
trim operations to complete.
Reviewed-by: Matt Ahrens <matt@delphix.com>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: John Gallagher <john.gallagher@delphix.com>
Closes #9162
2019-09-14 04:09:06 +03:00
|
|
|
if (bpobj_is_empty_impl(bpo)) {
|
2019-03-06 20:50:55 +03:00
|
|
|
ASSERT0(bpo->bpo_phys->bpo_bytes);
|
|
|
|
ASSERT0(bpo->bpo_phys->bpo_comp);
|
|
|
|
ASSERT0(bpo->bpo_phys->bpo_uncomp);
|
|
|
|
}
|
2010-05-29 00:45:14 +04:00
|
|
|
|
2019-03-06 20:50:55 +03:00
|
|
|
/* The initial_bpo has no parent and is not closed. */
|
|
|
|
if (bpi->bpi_parent != NULL) {
|
|
|
|
if (free) {
|
|
|
|
bpobj_t *p = bpi->bpi_parent->bpi_bpo;
|
|
|
|
|
|
|
|
ASSERT0(bpo->bpo_phys->bpo_num_blkptrs);
|
|
|
|
ASSERT3U(p->bpo_phys->bpo_num_subobjs,
|
|
|
|
>, 0);
|
|
|
|
ASSERT3U(bpi->bpi_index, ==,
|
|
|
|
p->bpo_phys->bpo_num_subobjs - 1);
|
|
|
|
ASSERT(dmu_buf_is_dirty(bpo->bpo_dbuf,
|
|
|
|
tx));
|
|
|
|
|
|
|
|
p->bpo_phys->bpo_num_subobjs--;
|
|
|
|
|
|
|
|
VERIFY0(dmu_free_range(p->bpo_os,
|
|
|
|
p->bpo_phys->bpo_subobjs,
|
|
|
|
bpi->bpi_index * sizeof (uint64_t),
|
|
|
|
sizeof (uint64_t), tx));
|
|
|
|
|
|
|
|
/* eliminate the empty subobj list */
|
|
|
|
if (bpo->bpo_havesubobj &&
|
|
|
|
bpo->bpo_phys->bpo_subobjs != 0) {
|
|
|
|
ASSERT0(bpo->bpo_phys->
|
|
|
|
bpo_num_subobjs);
|
|
|
|
err = dmu_object_free(
|
|
|
|
bpo->bpo_os,
|
|
|
|
bpo->bpo_phys->bpo_subobjs,
|
|
|
|
tx);
|
|
|
|
if (err)
|
|
|
|
break;
|
|
|
|
bpo->bpo_phys->bpo_subobjs = 0;
|
|
|
|
}
|
|
|
|
err = dmu_object_free(p->bpo_os,
|
|
|
|
bpo->bpo_object, tx);
|
|
|
|
if (err)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
mutex_exit(&bpo->bpo_lock);
|
|
|
|
bpobj_close(bpo);
|
|
|
|
kmem_free(bpo, sizeof (bpobj_t));
|
|
|
|
} else {
|
|
|
|
mutex_exit(&bpo->bpo_lock);
|
|
|
|
}
|
2010-05-29 00:45:14 +04:00
|
|
|
|
2019-03-06 20:50:55 +03:00
|
|
|
/*
|
|
|
|
* Finished processing this bpo. Unlock, and free
|
|
|
|
* our "stack" info.
|
|
|
|
*/
|
|
|
|
list_remove_head(&stack);
|
|
|
|
kmem_free(bpi, sizeof (bpobj_info_t));
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* We have unprocessed subobjs. Process the next one.
|
|
|
|
*/
|
|
|
|
ASSERT(bpo->bpo_havecomp);
|
2019-07-26 20:54:14 +03:00
|
|
|
ASSERT3P(bpobj_size, ==, NULL);
|
2019-03-06 20:50:55 +03:00
|
|
|
|
|
|
|
/* Add the last subobj to stack. */
|
|
|
|
int64_t i = bpi->bpi_unprocessed_subobjs - 1;
|
|
|
|
uint64_t offset = i * sizeof (uint64_t);
|
|
|
|
|
|
|
|
uint64_t obj_from_sublist;
|
|
|
|
err = dmu_read(bpo->bpo_os, bpo->bpo_phys->bpo_subobjs,
|
|
|
|
offset, sizeof (uint64_t), &obj_from_sublist,
|
|
|
|
DMU_READ_PREFETCH);
|
|
|
|
if (err)
|
2010-05-29 00:45:14 +04:00
|
|
|
break;
|
2019-03-06 20:50:55 +03:00
|
|
|
bpobj_t *sublist = kmem_alloc(sizeof (bpobj_t),
|
|
|
|
KM_SLEEP);
|
2010-05-29 00:45:14 +04:00
|
|
|
|
2019-03-06 20:50:55 +03:00
|
|
|
err = bpobj_open(sublist, bpo->bpo_os,
|
|
|
|
obj_from_sublist);
|
2010-05-29 00:45:14 +04:00
|
|
|
if (err)
|
|
|
|
break;
|
2019-03-06 20:50:55 +03:00
|
|
|
|
|
|
|
list_insert_head(&stack, bpi_alloc(sublist, bpi, i));
|
|
|
|
mutex_enter(&sublist->bpo_lock);
|
|
|
|
bpi->bpi_unprocessed_subobjs--;
|
2010-05-29 00:45:14 +04:00
|
|
|
}
|
|
|
|
}
|
2019-03-06 20:50:55 +03:00
|
|
|
/*
|
|
|
|
* Cleanup anything left on the "stack" after we left the loop.
|
|
|
|
* Every bpo on the stack is locked so we must remember to undo
|
|
|
|
* that now (in LIFO order).
|
|
|
|
*/
|
|
|
|
while ((bpi = list_remove_head(&stack)) != NULL) {
|
|
|
|
bpobj_t *bpo = bpi->bpi_bpo;
|
|
|
|
ASSERT(err != 0);
|
|
|
|
ASSERT3P(bpo, !=, NULL);
|
2010-05-29 00:45:14 +04:00
|
|
|
|
2019-03-06 20:50:55 +03:00
|
|
|
mutex_exit(&bpo->bpo_lock);
|
|
|
|
|
|
|
|
/* do not free the initial_bpo */
|
|
|
|
if (bpi->bpi_parent != NULL) {
|
|
|
|
bpobj_close(bpi->bpi_bpo);
|
|
|
|
kmem_free(bpi->bpi_bpo, sizeof (bpobj_t));
|
|
|
|
}
|
|
|
|
kmem_free(bpi, sizeof (bpobj_info_t));
|
2014-06-06 01:19:08 +04:00
|
|
|
}
|
2010-05-29 00:45:14 +04:00
|
|
|
|
2019-03-06 20:50:55 +03:00
|
|
|
list_destroy(&stack);
|
|
|
|
|
2010-05-29 00:45:14 +04:00
|
|
|
return (err);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Iterate and remove the entries. If func returns nonzero, iteration
|
|
|
|
* will stop and that entry will not be removed.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
bpobj_iterate(bpobj_t *bpo, bpobj_itor_t func, void *arg, dmu_tx_t *tx)
|
|
|
|
{
|
2019-07-26 20:54:14 +03:00
|
|
|
return (bpobj_iterate_impl(bpo, func, arg, tx, B_TRUE, NULL));
|
2010-05-29 00:45:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Iterate the entries. If func returns nonzero, iteration will stop.
|
2019-07-26 20:54:14 +03:00
|
|
|
*
|
|
|
|
* If there are no subobjs:
|
|
|
|
*
|
|
|
|
* *bpobj_size can be used to return the number of block pointers in the
|
|
|
|
* bpobj. Note that this may be different from the number of block pointers
|
|
|
|
* that are iterated over, if iteration is terminated early (e.g. by the func
|
|
|
|
* returning nonzero).
|
|
|
|
*
|
|
|
|
* If there are concurrent (or subsequent) modifications to the bpobj then the
|
|
|
|
* returned *bpobj_size can be passed as "start" to
|
|
|
|
* livelist_bpobj_iterate_from_nofree() to iterate the newly added entries.
|
2010-05-29 00:45:14 +04:00
|
|
|
*/
|
|
|
|
int
|
2019-07-26 20:54:14 +03:00
|
|
|
bpobj_iterate_nofree(bpobj_t *bpo, bpobj_itor_t func, void *arg,
|
|
|
|
uint64_t *bpobj_size)
|
2010-05-29 00:45:14 +04:00
|
|
|
{
|
2019-07-26 20:54:14 +03:00
|
|
|
return (bpobj_iterate_impl(bpo, func, arg, NULL, B_FALSE, bpobj_size));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Iterate over the blkptrs in the bpobj beginning at index start. If func
|
|
|
|
* returns nonzero, iteration will stop. This is a livelist specific function
|
|
|
|
* since it assumes that there are no subobjs present.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
livelist_bpobj_iterate_from_nofree(bpobj_t *bpo, bpobj_itor_t func, void *arg,
|
|
|
|
int64_t start)
|
|
|
|
{
|
|
|
|
if (bpo->bpo_havesubobj)
|
|
|
|
VERIFY0(bpo->bpo_phys->bpo_subobjs);
|
|
|
|
bpobj_info_t *bpi = bpi_alloc(bpo, NULL, 0);
|
|
|
|
int err = bpobj_iterate_blkptrs(bpi, func, arg, start, NULL, B_FALSE);
|
|
|
|
kmem_free(bpi, sizeof (bpobj_info_t));
|
|
|
|
return (err);
|
2010-05-29 00:45:14 +04:00
|
|
|
}
|
|
|
|
|
bpobj_enqueue_subobj() should copy small subobj's
When we delete a snapshot, we consolidate some bpobj's together because
we no longer need to keep their entries in separate buckets. This is
done in constant time by including the "sub" bpobj by reference in the
parent bpobj.
After many snapshots have been deleted, we may have many sub-bpobj's.
Usually, most sub-bpobj's don't contain many BP's. Compared to this
small payload, the sub-bpobj is relatively heavyweight since it is a
object in the MOS. A common scenario on a long-lived pool is for the
vast majority of MOS objects to be small sub-bpobj's.
To improve this situation, when consolidating bpobj's together,
bpobj_enqueue_subobj() can copy the contents of small bpobj's into the
parent, and then delete the enqueued bpobj, rather than including it by
reference. Since this copying is limited in size (to one block), the
consolidation is still constant time, though with a larger constant due
to reading in the one block of the enqueued bpobj.
This idea and mechanism are similar to how we handle "sub-subobj's".
When including a sub-bpobj by reference, if the sub-bpobj itself has
less than a block of sub-sub-bpobj's, the list of sub-sub-bpobj's is
copied to the parent bpobj's list of sub-bpobj's.
Reviewed-by: Serapheim Dimitropoulos <serapheim@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Paul Zuchowski <pzuchowski@datto.com>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #8053
Issue #7908
2018-10-31 19:58:17 +03:00
|
|
|
/*
|
|
|
|
* Logically add subobj's contents to the parent bpobj.
|
|
|
|
*
|
|
|
|
* In the most general case, this is accomplished in constant time by adding
|
|
|
|
* a reference to subobj. This case is used when enqueuing a large subobj:
|
|
|
|
* +--------------+ +--------------+
|
|
|
|
* | bpobj |----------------------->| subobj list |
|
|
|
|
* +----+----+----+----+----+ +-----+-----+--+--+
|
|
|
|
* | bp | bp | bp | bp | bp | | obj | obj | obj |
|
|
|
|
* +----+----+----+----+----+ +-----+-----+-----+
|
|
|
|
*
|
|
|
|
* +--------------+ +--------------+
|
|
|
|
* | sub-bpobj |----------------------> | subsubobj |
|
|
|
|
* +----+----+----+----+---------+----+ +-----+-----+--+--------+-----+
|
|
|
|
* | bp | bp | bp | bp | ... | bp | | obj | obj | ... | obj |
|
|
|
|
* +----+----+----+----+---------+----+ +-----+-----+-----------+-----+
|
|
|
|
*
|
|
|
|
* Result: sub-bpobj added to parent's subobj list.
|
|
|
|
* +--------------+ +--------------+
|
|
|
|
* | bpobj |----------------------->| subobj list |
|
|
|
|
* +----+----+----+----+----+ +-----+-----+--+--+-----+
|
|
|
|
* | bp | bp | bp | bp | bp | | obj | obj | obj | OBJ |
|
|
|
|
* +----+----+----+----+----+ +-----+-----+-----+--|--+
|
|
|
|
* |
|
|
|
|
* /-----------------------------------------------------/
|
|
|
|
* v
|
|
|
|
* +--------------+ +--------------+
|
|
|
|
* | sub-bpobj |----------------------> | subsubobj |
|
|
|
|
* +----+----+----+----+---------+----+ +-----+-----+--+--------+-----+
|
|
|
|
* | bp | bp | bp | bp | ... | bp | | obj | obj | ... | obj |
|
|
|
|
* +----+----+----+----+---------+----+ +-----+-----+-----------+-----+
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* In a common case, the subobj is small: its bp's and its list of subobj's
|
|
|
|
* are each stored in a single block. In this case we copy the subobj's
|
|
|
|
* contents to the parent:
|
|
|
|
* +--------------+ +--------------+
|
|
|
|
* | bpobj |----------------------->| subobj list |
|
|
|
|
* +----+----+----+----+----+ +-----+-----+--+--+
|
|
|
|
* | bp | bp | bp | bp | bp | | obj | obj | obj |
|
|
|
|
* +----+----+----+----+----+ +-----+-----+-----+
|
|
|
|
* ^ ^
|
|
|
|
* +--------------+ | +--------------+ |
|
|
|
|
* | sub-bpobj |---------^------------> | subsubobj | ^
|
|
|
|
* +----+----+----+ | +-----+-----+--+ |
|
|
|
|
* | BP | BP |-->-->-->-->-/ | OBJ | OBJ |-->-/
|
|
|
|
* +----+----+ +-----+-----+
|
|
|
|
*
|
|
|
|
* Result: subobj destroyed, contents copied to parent:
|
|
|
|
* +--------------+ +--------------+
|
|
|
|
* | bpobj |----------------------->| subobj list |
|
|
|
|
* +----+----+----+----+----+----+----+ +-----+-----+--+--+-----+-----+
|
|
|
|
* | bp | bp | bp | bp | bp | BP | BP | | obj | obj | obj | OBJ | OBJ |
|
|
|
|
* +----+----+----+----+----+----+----+ +-----+-----+-----+-----+-----+
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* If the subobj has many BP's but few subobj's, we can copy the sub-subobj's
|
|
|
|
* but retain the sub-bpobj:
|
|
|
|
* +--------------+ +--------------+
|
|
|
|
* | bpobj |----------------------->| subobj list |
|
|
|
|
* +----+----+----+----+----+ +-----+-----+--+--+
|
|
|
|
* | bp | bp | bp | bp | bp | | obj | obj | obj |
|
|
|
|
* +----+----+----+----+----+ +-----+-----+-----+
|
|
|
|
* ^
|
|
|
|
* +--------------+ +--------------+ |
|
|
|
|
* | sub-bpobj |----------------------> | subsubobj | ^
|
|
|
|
* +----+----+----+----+---------+----+ +-----+-----+--+ |
|
|
|
|
* | bp | bp | bp | bp | ... | bp | | OBJ | OBJ |-->-/
|
|
|
|
* +----+----+----+----+---------+----+ +-----+-----+
|
|
|
|
*
|
|
|
|
* Result: sub-sub-bpobjs and subobj added to parent's subobj list.
|
|
|
|
* +--------------+ +--------------+
|
|
|
|
* | bpobj |-------------------->| subobj list |
|
|
|
|
* +----+----+----+----+----+ +-----+-----+--+--+-----+-----+------+
|
|
|
|
* | bp | bp | bp | bp | bp | | obj | obj | obj | OBJ | OBJ | OBJ* |
|
|
|
|
* +----+----+----+----+----+ +-----+-----+-----+-----+-----+--|---+
|
|
|
|
* |
|
|
|
|
* /--------------------------------------------------------------/
|
|
|
|
* v
|
|
|
|
* +--------------+
|
|
|
|
* | sub-bpobj |
|
|
|
|
* +----+----+----+----+---------+----+
|
|
|
|
* | bp | bp | bp | bp | ... | bp |
|
|
|
|
* +----+----+----+----+---------+----+
|
|
|
|
*/
|
2010-05-29 00:45:14 +04:00
|
|
|
void
|
|
|
|
bpobj_enqueue_subobj(bpobj_t *bpo, uint64_t subobj, dmu_tx_t *tx)
|
|
|
|
{
|
|
|
|
bpobj_t subbpo;
|
2010-08-27 01:24:34 +04:00
|
|
|
uint64_t used, comp, uncomp, subsubobjs;
|
bpobj_enqueue_subobj() should copy small subobj's
When we delete a snapshot, we consolidate some bpobj's together because
we no longer need to keep their entries in separate buckets. This is
done in constant time by including the "sub" bpobj by reference in the
parent bpobj.
After many snapshots have been deleted, we may have many sub-bpobj's.
Usually, most sub-bpobj's don't contain many BP's. Compared to this
small payload, the sub-bpobj is relatively heavyweight since it is a
object in the MOS. A common scenario on a long-lived pool is for the
vast majority of MOS objects to be small sub-bpobj's.
To improve this situation, when consolidating bpobj's together,
bpobj_enqueue_subobj() can copy the contents of small bpobj's into the
parent, and then delete the enqueued bpobj, rather than including it by
reference. Since this copying is limited in size (to one block), the
consolidation is still constant time, though with a larger constant due
to reading in the one block of the enqueued bpobj.
This idea and mechanism are similar to how we handle "sub-subobj's".
When including a sub-bpobj by reference, if the sub-bpobj itself has
less than a block of sub-sub-bpobj's, the list of sub-sub-bpobj's is
copied to the parent bpobj's list of sub-bpobj's.
Reviewed-by: Serapheim Dimitropoulos <serapheim@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Paul Zuchowski <pzuchowski@datto.com>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #8053
Issue #7908
2018-10-31 19:58:17 +03:00
|
|
|
boolean_t copy_subsub = B_TRUE;
|
|
|
|
boolean_t copy_bps = B_TRUE;
|
2010-05-29 00:45:14 +04:00
|
|
|
|
OpenZFS 7614, 9064 - zfs device evacuation/removal
OpenZFS 7614 - zfs device evacuation/removal
OpenZFS 9064 - remove_mirror should wait for device removal to complete
This project allows top-level vdevs to be removed from the storage pool
with "zpool remove", reducing the total amount of storage in the pool.
This operation copies all allocated regions of the device to be removed
onto other devices, recording the mapping from old to new location.
After the removal is complete, read and free operations to the removed
(now "indirect") vdev must be remapped and performed at the new location
on disk. The indirect mapping table is kept in memory whenever the pool
is loaded, so there is minimal performance overhead when doing operations
on the indirect vdev.
The size of the in-memory mapping table will be reduced when its entries
become "obsolete" because they are no longer used by any block pointers
in the pool. An entry becomes obsolete when all the blocks that use
it are freed. An entry can also become obsolete when all the snapshots
that reference it are deleted, and the block pointers that reference it
have been "remapped" in all filesystems/zvols (and clones). Whenever an
indirect block is written, all the block pointers in it will be "remapped"
to their new (concrete) locations if possible. This process can be
accelerated by using the "zfs remap" command to proactively rewrite all
indirect blocks that reference indirect (removed) vdevs.
Note that when a device is removed, we do not verify the checksum of
the data that is copied. This makes the process much faster, but if it
were used on redundant vdevs (i.e. mirror or raidz vdevs), it would be
possible to copy the wrong data, when we have the correct data on e.g.
the other side of the mirror.
At the moment, only mirrors and simple top-level vdevs can be removed
and no removal is allowed if any of the top-level vdevs are raidz.
Porting Notes:
* Avoid zero-sized kmem_alloc() in vdev_compact_children().
The device evacuation code adds a dependency that
vdev_compact_children() be able to properly empty the vdev_child
array by setting it to NULL and zeroing vdev_children. Under Linux,
kmem_alloc() and related functions return a sentinel pointer rather
than NULL for zero-sized allocations.
* Remove comment regarding "mpt" driver where zfs_remove_max_segment
is initialized to SPA_MAXBLOCKSIZE.
Change zfs_condense_indirect_commit_entry_delay_ticks to
zfs_condense_indirect_commit_entry_delay_ms for consistency with
most other tunables in which delays are specified in ms.
* ZTS changes:
Use set_tunable rather than mdb
Use zpool sync as appropriate
Use sync_pool instead of sync
Kill jobs during test_removal_with_operation to allow unmount/export
Don't add non-disk names such as "mirror" or "raidz" to $DISKS
Use $TEST_BASE_DIR instead of /tmp
Increase HZ from 100 to 1000 which is more common on Linux
removal_multiple_indirection.ksh
Reduce iterations in order to not time out on the code
coverage builders.
removal_resume_export:
Functionally, the test case is correct but there exists a race
where the kernel thread hasn't been fully started yet and is
not visible. Wait for up to 1 second for the removal thread
to be started before giving up on it. Also, increase the
amount of data copied in order that the removal not finish
before the export has a chance to fail.
* MMP compatibility, the concept of concrete versus non-concrete devices
has slightly changed the semantics of vdev_writeable(). Update
mmp_random_leaf_impl() accordingly.
* Updated dbuf_remap() to handle the org.zfsonlinux:large_dnode pool
feature which is not supported by OpenZFS.
* Added support for new vdev removal tracepoints.
* Test cases removal_with_zdb and removal_condense_export have been
intentionally disabled. When run manually they pass as intended,
but when running in the automated test environment they produce
unreliable results on the latest Fedora release.
They may work better once the upstream pool import refectoring is
merged into ZoL at which point they will be re-enabled.
Authored by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Alex Reece <alex@delphix.com>
Reviewed-by: George Wilson <george.wilson@delphix.com>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Richard Laager <rlaager@wiktel.com>
Reviewed by: Tim Chase <tim@chase2k.com>
Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Approved by: Garrett D'Amore <garrett@damore.org>
Ported-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Tim Chase <tim@chase2k.com>
OpenZFS-issue: https://www.illumos.org/issues/7614
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/f539f1eb
Closes #6900
2016-09-22 19:30:13 +03:00
|
|
|
ASSERT(bpobj_is_open(bpo));
|
|
|
|
ASSERT(subobj != 0);
|
2010-05-29 00:45:14 +04:00
|
|
|
ASSERT(bpo->bpo_havesubobj);
|
|
|
|
ASSERT(bpo->bpo_havecomp);
|
2012-12-24 03:57:14 +04:00
|
|
|
ASSERT(bpo->bpo_object != dmu_objset_pool(bpo->bpo_os)->dp_empty_bpobj);
|
|
|
|
|
|
|
|
if (subobj == dmu_objset_pool(bpo->bpo_os)->dp_empty_bpobj) {
|
|
|
|
bpobj_decr_empty(bpo->bpo_os, tx);
|
|
|
|
return;
|
|
|
|
}
|
2010-05-29 00:45:14 +04:00
|
|
|
|
|
|
|
VERIFY3U(0, ==, bpobj_open(&subbpo, bpo->bpo_os, subobj));
|
|
|
|
VERIFY3U(0, ==, bpobj_space(&subbpo, &used, &comp, &uncomp));
|
|
|
|
|
OpenZFS 7614, 9064 - zfs device evacuation/removal
OpenZFS 7614 - zfs device evacuation/removal
OpenZFS 9064 - remove_mirror should wait for device removal to complete
This project allows top-level vdevs to be removed from the storage pool
with "zpool remove", reducing the total amount of storage in the pool.
This operation copies all allocated regions of the device to be removed
onto other devices, recording the mapping from old to new location.
After the removal is complete, read and free operations to the removed
(now "indirect") vdev must be remapped and performed at the new location
on disk. The indirect mapping table is kept in memory whenever the pool
is loaded, so there is minimal performance overhead when doing operations
on the indirect vdev.
The size of the in-memory mapping table will be reduced when its entries
become "obsolete" because they are no longer used by any block pointers
in the pool. An entry becomes obsolete when all the blocks that use
it are freed. An entry can also become obsolete when all the snapshots
that reference it are deleted, and the block pointers that reference it
have been "remapped" in all filesystems/zvols (and clones). Whenever an
indirect block is written, all the block pointers in it will be "remapped"
to their new (concrete) locations if possible. This process can be
accelerated by using the "zfs remap" command to proactively rewrite all
indirect blocks that reference indirect (removed) vdevs.
Note that when a device is removed, we do not verify the checksum of
the data that is copied. This makes the process much faster, but if it
were used on redundant vdevs (i.e. mirror or raidz vdevs), it would be
possible to copy the wrong data, when we have the correct data on e.g.
the other side of the mirror.
At the moment, only mirrors and simple top-level vdevs can be removed
and no removal is allowed if any of the top-level vdevs are raidz.
Porting Notes:
* Avoid zero-sized kmem_alloc() in vdev_compact_children().
The device evacuation code adds a dependency that
vdev_compact_children() be able to properly empty the vdev_child
array by setting it to NULL and zeroing vdev_children. Under Linux,
kmem_alloc() and related functions return a sentinel pointer rather
than NULL for zero-sized allocations.
* Remove comment regarding "mpt" driver where zfs_remove_max_segment
is initialized to SPA_MAXBLOCKSIZE.
Change zfs_condense_indirect_commit_entry_delay_ticks to
zfs_condense_indirect_commit_entry_delay_ms for consistency with
most other tunables in which delays are specified in ms.
* ZTS changes:
Use set_tunable rather than mdb
Use zpool sync as appropriate
Use sync_pool instead of sync
Kill jobs during test_removal_with_operation to allow unmount/export
Don't add non-disk names such as "mirror" or "raidz" to $DISKS
Use $TEST_BASE_DIR instead of /tmp
Increase HZ from 100 to 1000 which is more common on Linux
removal_multiple_indirection.ksh
Reduce iterations in order to not time out on the code
coverage builders.
removal_resume_export:
Functionally, the test case is correct but there exists a race
where the kernel thread hasn't been fully started yet and is
not visible. Wait for up to 1 second for the removal thread
to be started before giving up on it. Also, increase the
amount of data copied in order that the removal not finish
before the export has a chance to fail.
* MMP compatibility, the concept of concrete versus non-concrete devices
has slightly changed the semantics of vdev_writeable(). Update
mmp_random_leaf_impl() accordingly.
* Updated dbuf_remap() to handle the org.zfsonlinux:large_dnode pool
feature which is not supported by OpenZFS.
* Added support for new vdev removal tracepoints.
* Test cases removal_with_zdb and removal_condense_export have been
intentionally disabled. When run manually they pass as intended,
but when running in the automated test environment they produce
unreliable results on the latest Fedora release.
They may work better once the upstream pool import refectoring is
merged into ZoL at which point they will be re-enabled.
Authored by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Alex Reece <alex@delphix.com>
Reviewed-by: George Wilson <george.wilson@delphix.com>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Richard Laager <rlaager@wiktel.com>
Reviewed by: Tim Chase <tim@chase2k.com>
Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Approved by: Garrett D'Amore <garrett@damore.org>
Ported-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Tim Chase <tim@chase2k.com>
OpenZFS-issue: https://www.illumos.org/issues/7614
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/f539f1eb
Closes #6900
2016-09-22 19:30:13 +03:00
|
|
|
if (bpobj_is_empty(&subbpo)) {
|
2010-05-29 00:45:14 +04:00
|
|
|
/* No point in having an empty subobj. */
|
2010-08-27 01:24:34 +04:00
|
|
|
bpobj_close(&subbpo);
|
2010-05-29 00:45:14 +04:00
|
|
|
bpobj_free(bpo->bpo_os, subobj, tx);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-09 21:19:12 +03:00
|
|
|
mutex_enter(&bpo->bpo_lock);
|
2010-05-29 00:45:14 +04:00
|
|
|
dmu_buf_will_dirty(bpo->bpo_dbuf, tx);
|
|
|
|
|
bpobj_enqueue_subobj() should copy small subobj's
When we delete a snapshot, we consolidate some bpobj's together because
we no longer need to keep their entries in separate buckets. This is
done in constant time by including the "sub" bpobj by reference in the
parent bpobj.
After many snapshots have been deleted, we may have many sub-bpobj's.
Usually, most sub-bpobj's don't contain many BP's. Compared to this
small payload, the sub-bpobj is relatively heavyweight since it is a
object in the MOS. A common scenario on a long-lived pool is for the
vast majority of MOS objects to be small sub-bpobj's.
To improve this situation, when consolidating bpobj's together,
bpobj_enqueue_subobj() can copy the contents of small bpobj's into the
parent, and then delete the enqueued bpobj, rather than including it by
reference. Since this copying is limited in size (to one block), the
consolidation is still constant time, though with a larger constant due
to reading in the one block of the enqueued bpobj.
This idea and mechanism are similar to how we handle "sub-subobj's".
When including a sub-bpobj by reference, if the sub-bpobj itself has
less than a block of sub-sub-bpobj's, the list of sub-sub-bpobj's is
copied to the parent bpobj's list of sub-bpobj's.
Reviewed-by: Serapheim Dimitropoulos <serapheim@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Paul Zuchowski <pzuchowski@datto.com>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #8053
Issue #7908
2018-10-31 19:58:17 +03:00
|
|
|
dmu_object_info_t doi;
|
2013-09-04 16:00:57 +04:00
|
|
|
|
bpobj_enqueue_subobj() should copy small subobj's
When we delete a snapshot, we consolidate some bpobj's together because
we no longer need to keep their entries in separate buckets. This is
done in constant time by including the "sub" bpobj by reference in the
parent bpobj.
After many snapshots have been deleted, we may have many sub-bpobj's.
Usually, most sub-bpobj's don't contain many BP's. Compared to this
small payload, the sub-bpobj is relatively heavyweight since it is a
object in the MOS. A common scenario on a long-lived pool is for the
vast majority of MOS objects to be small sub-bpobj's.
To improve this situation, when consolidating bpobj's together,
bpobj_enqueue_subobj() can copy the contents of small bpobj's into the
parent, and then delete the enqueued bpobj, rather than including it by
reference. Since this copying is limited in size (to one block), the
consolidation is still constant time, though with a larger constant due
to reading in the one block of the enqueued bpobj.
This idea and mechanism are similar to how we handle "sub-subobj's".
When including a sub-bpobj by reference, if the sub-bpobj itself has
less than a block of sub-sub-bpobj's, the list of sub-sub-bpobj's is
copied to the parent bpobj's list of sub-bpobj's.
Reviewed-by: Serapheim Dimitropoulos <serapheim@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Paul Zuchowski <pzuchowski@datto.com>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #8053
Issue #7908
2018-10-31 19:58:17 +03:00
|
|
|
if (bpo->bpo_phys->bpo_subobjs != 0) {
|
|
|
|
ASSERT0(dmu_object_info(bpo->bpo_os, bpo->bpo_phys->bpo_subobjs,
|
|
|
|
&doi));
|
|
|
|
ASSERT3U(doi.doi_type, ==, DMU_OT_BPOBJ_SUBOBJ);
|
|
|
|
}
|
2010-08-27 01:24:34 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If subobj has only one block of subobjs, then move subobj's
|
bpobj_enqueue_subobj() should copy small subobj's
When we delete a snapshot, we consolidate some bpobj's together because
we no longer need to keep their entries in separate buckets. This is
done in constant time by including the "sub" bpobj by reference in the
parent bpobj.
After many snapshots have been deleted, we may have many sub-bpobj's.
Usually, most sub-bpobj's don't contain many BP's. Compared to this
small payload, the sub-bpobj is relatively heavyweight since it is a
object in the MOS. A common scenario on a long-lived pool is for the
vast majority of MOS objects to be small sub-bpobj's.
To improve this situation, when consolidating bpobj's together,
bpobj_enqueue_subobj() can copy the contents of small bpobj's into the
parent, and then delete the enqueued bpobj, rather than including it by
reference. Since this copying is limited in size (to one block), the
consolidation is still constant time, though with a larger constant due
to reading in the one block of the enqueued bpobj.
This idea and mechanism are similar to how we handle "sub-subobj's".
When including a sub-bpobj by reference, if the sub-bpobj itself has
less than a block of sub-sub-bpobj's, the list of sub-sub-bpobj's is
copied to the parent bpobj's list of sub-bpobj's.
Reviewed-by: Serapheim Dimitropoulos <serapheim@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Paul Zuchowski <pzuchowski@datto.com>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #8053
Issue #7908
2018-10-31 19:58:17 +03:00
|
|
|
* subobjs to bpo's subobj list directly. This reduces recursion in
|
|
|
|
* bpobj_iterate due to nested subobjs.
|
2010-08-27 01:24:34 +04:00
|
|
|
*/
|
|
|
|
subsubobjs = subbpo.bpo_phys->bpo_subobjs;
|
|
|
|
if (subsubobjs != 0) {
|
bpobj_enqueue_subobj() should copy small subobj's
When we delete a snapshot, we consolidate some bpobj's together because
we no longer need to keep their entries in separate buckets. This is
done in constant time by including the "sub" bpobj by reference in the
parent bpobj.
After many snapshots have been deleted, we may have many sub-bpobj's.
Usually, most sub-bpobj's don't contain many BP's. Compared to this
small payload, the sub-bpobj is relatively heavyweight since it is a
object in the MOS. A common scenario on a long-lived pool is for the
vast majority of MOS objects to be small sub-bpobj's.
To improve this situation, when consolidating bpobj's together,
bpobj_enqueue_subobj() can copy the contents of small bpobj's into the
parent, and then delete the enqueued bpobj, rather than including it by
reference. Since this copying is limited in size (to one block), the
consolidation is still constant time, though with a larger constant due
to reading in the one block of the enqueued bpobj.
This idea and mechanism are similar to how we handle "sub-subobj's".
When including a sub-bpobj by reference, if the sub-bpobj itself has
less than a block of sub-sub-bpobj's, the list of sub-sub-bpobj's is
copied to the parent bpobj's list of sub-bpobj's.
Reviewed-by: Serapheim Dimitropoulos <serapheim@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Paul Zuchowski <pzuchowski@datto.com>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #8053
Issue #7908
2018-10-31 19:58:17 +03:00
|
|
|
VERIFY0(dmu_object_info(bpo->bpo_os, subsubobjs, &doi));
|
|
|
|
if (doi.doi_max_offset > doi.doi_data_block_size) {
|
|
|
|
copy_subsub = B_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If, in addition to having only one block of subobj's, subobj has
|
|
|
|
* only one block of bp's, then move subobj's bp's to bpo's bp list
|
|
|
|
* directly. This reduces recursion in bpobj_iterate due to nested
|
|
|
|
* subobjs.
|
|
|
|
*/
|
|
|
|
VERIFY3U(0, ==, dmu_object_info(bpo->bpo_os, subobj, &doi));
|
|
|
|
if (doi.doi_max_offset > doi.doi_data_block_size || !copy_subsub) {
|
|
|
|
copy_bps = B_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (copy_subsub && subsubobjs != 0) {
|
|
|
|
dmu_buf_t *subdb;
|
|
|
|
uint64_t numsubsub = subbpo.bpo_phys->bpo_num_subobjs;
|
|
|
|
|
|
|
|
VERIFY0(dmu_buf_hold(bpo->bpo_os, subsubobjs,
|
|
|
|
0, FTAG, &subdb, 0));
|
|
|
|
/*
|
|
|
|
* Make sure that we are not asking dmu_write()
|
|
|
|
* to write more data than we have in our buffer.
|
|
|
|
*/
|
|
|
|
VERIFY3U(subdb->db_size, >=,
|
|
|
|
numsubsub * sizeof (subobj));
|
|
|
|
if (bpo->bpo_phys->bpo_subobjs == 0) {
|
|
|
|
bpo->bpo_phys->bpo_subobjs =
|
|
|
|
dmu_object_alloc(bpo->bpo_os,
|
|
|
|
DMU_OT_BPOBJ_SUBOBJ, SPA_OLD_MAXBLOCKSIZE,
|
|
|
|
DMU_OT_NONE, 0, tx);
|
2010-08-27 01:24:34 +04:00
|
|
|
}
|
bpobj_enqueue_subobj() should copy small subobj's
When we delete a snapshot, we consolidate some bpobj's together because
we no longer need to keep their entries in separate buckets. This is
done in constant time by including the "sub" bpobj by reference in the
parent bpobj.
After many snapshots have been deleted, we may have many sub-bpobj's.
Usually, most sub-bpobj's don't contain many BP's. Compared to this
small payload, the sub-bpobj is relatively heavyweight since it is a
object in the MOS. A common scenario on a long-lived pool is for the
vast majority of MOS objects to be small sub-bpobj's.
To improve this situation, when consolidating bpobj's together,
bpobj_enqueue_subobj() can copy the contents of small bpobj's into the
parent, and then delete the enqueued bpobj, rather than including it by
reference. Since this copying is limited in size (to one block), the
consolidation is still constant time, though with a larger constant due
to reading in the one block of the enqueued bpobj.
This idea and mechanism are similar to how we handle "sub-subobj's".
When including a sub-bpobj by reference, if the sub-bpobj itself has
less than a block of sub-sub-bpobj's, the list of sub-sub-bpobj's is
copied to the parent bpobj's list of sub-bpobj's.
Reviewed-by: Serapheim Dimitropoulos <serapheim@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Paul Zuchowski <pzuchowski@datto.com>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #8053
Issue #7908
2018-10-31 19:58:17 +03:00
|
|
|
dmu_write(bpo->bpo_os, bpo->bpo_phys->bpo_subobjs,
|
|
|
|
bpo->bpo_phys->bpo_num_subobjs * sizeof (subobj),
|
|
|
|
numsubsub * sizeof (subobj), subdb->db_data, tx);
|
|
|
|
dmu_buf_rele(subdb, FTAG);
|
|
|
|
bpo->bpo_phys->bpo_num_subobjs += numsubsub;
|
|
|
|
|
|
|
|
dmu_buf_will_dirty(subbpo.bpo_dbuf, tx);
|
|
|
|
subbpo.bpo_phys->bpo_subobjs = 0;
|
|
|
|
VERIFY0(dmu_object_free(bpo->bpo_os, subsubobjs, tx));
|
2010-08-27 01:24:34 +04:00
|
|
|
}
|
bpobj_enqueue_subobj() should copy small subobj's
When we delete a snapshot, we consolidate some bpobj's together because
we no longer need to keep their entries in separate buckets. This is
done in constant time by including the "sub" bpobj by reference in the
parent bpobj.
After many snapshots have been deleted, we may have many sub-bpobj's.
Usually, most sub-bpobj's don't contain many BP's. Compared to this
small payload, the sub-bpobj is relatively heavyweight since it is a
object in the MOS. A common scenario on a long-lived pool is for the
vast majority of MOS objects to be small sub-bpobj's.
To improve this situation, when consolidating bpobj's together,
bpobj_enqueue_subobj() can copy the contents of small bpobj's into the
parent, and then delete the enqueued bpobj, rather than including it by
reference. Since this copying is limited in size (to one block), the
consolidation is still constant time, though with a larger constant due
to reading in the one block of the enqueued bpobj.
This idea and mechanism are similar to how we handle "sub-subobj's".
When including a sub-bpobj by reference, if the sub-bpobj itself has
less than a block of sub-sub-bpobj's, the list of sub-sub-bpobj's is
copied to the parent bpobj's list of sub-bpobj's.
Reviewed-by: Serapheim Dimitropoulos <serapheim@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Paul Zuchowski <pzuchowski@datto.com>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #8053
Issue #7908
2018-10-31 19:58:17 +03:00
|
|
|
|
|
|
|
if (copy_bps) {
|
|
|
|
dmu_buf_t *bps;
|
|
|
|
uint64_t numbps = subbpo.bpo_phys->bpo_num_blkptrs;
|
|
|
|
|
|
|
|
ASSERT(copy_subsub);
|
|
|
|
VERIFY0(dmu_buf_hold(bpo->bpo_os, subobj,
|
|
|
|
0, FTAG, &bps, 0));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure that we are not asking dmu_write()
|
|
|
|
* to write more data than we have in our buffer.
|
|
|
|
*/
|
|
|
|
VERIFY3U(bps->db_size, >=, numbps * sizeof (blkptr_t));
|
|
|
|
dmu_write(bpo->bpo_os, bpo->bpo_object,
|
|
|
|
bpo->bpo_phys->bpo_num_blkptrs * sizeof (blkptr_t),
|
|
|
|
numbps * sizeof (blkptr_t),
|
|
|
|
bps->db_data, tx);
|
|
|
|
dmu_buf_rele(bps, FTAG);
|
|
|
|
bpo->bpo_phys->bpo_num_blkptrs += numbps;
|
|
|
|
|
|
|
|
bpobj_close(&subbpo);
|
|
|
|
VERIFY0(dmu_object_free(bpo->bpo_os, subobj, tx));
|
|
|
|
} else {
|
|
|
|
bpobj_close(&subbpo);
|
|
|
|
if (bpo->bpo_phys->bpo_subobjs == 0) {
|
|
|
|
bpo->bpo_phys->bpo_subobjs =
|
|
|
|
dmu_object_alloc(bpo->bpo_os,
|
|
|
|
DMU_OT_BPOBJ_SUBOBJ, SPA_OLD_MAXBLOCKSIZE,
|
|
|
|
DMU_OT_NONE, 0, tx);
|
|
|
|
}
|
|
|
|
|
|
|
|
dmu_write(bpo->bpo_os, bpo->bpo_phys->bpo_subobjs,
|
|
|
|
bpo->bpo_phys->bpo_num_subobjs * sizeof (subobj),
|
|
|
|
sizeof (subobj), &subobj, tx);
|
|
|
|
bpo->bpo_phys->bpo_num_subobjs++;
|
|
|
|
}
|
|
|
|
|
2010-05-29 00:45:14 +04:00
|
|
|
bpo->bpo_phys->bpo_bytes += used;
|
|
|
|
bpo->bpo_phys->bpo_comp += comp;
|
|
|
|
bpo->bpo_phys->bpo_uncomp += uncomp;
|
|
|
|
mutex_exit(&bpo->bpo_lock);
|
2010-08-27 01:24:34 +04:00
|
|
|
|
2010-05-29 00:45:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-07-26 20:54:14 +03:00
|
|
|
bpobj_enqueue(bpobj_t *bpo, const blkptr_t *bp, boolean_t bp_freed,
|
|
|
|
dmu_tx_t *tx)
|
2010-05-29 00:45:14 +04:00
|
|
|
{
|
|
|
|
blkptr_t stored_bp = *bp;
|
|
|
|
uint64_t offset;
|
|
|
|
int blkoff;
|
|
|
|
blkptr_t *bparray;
|
|
|
|
|
OpenZFS 7614, 9064 - zfs device evacuation/removal
OpenZFS 7614 - zfs device evacuation/removal
OpenZFS 9064 - remove_mirror should wait for device removal to complete
This project allows top-level vdevs to be removed from the storage pool
with "zpool remove", reducing the total amount of storage in the pool.
This operation copies all allocated regions of the device to be removed
onto other devices, recording the mapping from old to new location.
After the removal is complete, read and free operations to the removed
(now "indirect") vdev must be remapped and performed at the new location
on disk. The indirect mapping table is kept in memory whenever the pool
is loaded, so there is minimal performance overhead when doing operations
on the indirect vdev.
The size of the in-memory mapping table will be reduced when its entries
become "obsolete" because they are no longer used by any block pointers
in the pool. An entry becomes obsolete when all the blocks that use
it are freed. An entry can also become obsolete when all the snapshots
that reference it are deleted, and the block pointers that reference it
have been "remapped" in all filesystems/zvols (and clones). Whenever an
indirect block is written, all the block pointers in it will be "remapped"
to their new (concrete) locations if possible. This process can be
accelerated by using the "zfs remap" command to proactively rewrite all
indirect blocks that reference indirect (removed) vdevs.
Note that when a device is removed, we do not verify the checksum of
the data that is copied. This makes the process much faster, but if it
were used on redundant vdevs (i.e. mirror or raidz vdevs), it would be
possible to copy the wrong data, when we have the correct data on e.g.
the other side of the mirror.
At the moment, only mirrors and simple top-level vdevs can be removed
and no removal is allowed if any of the top-level vdevs are raidz.
Porting Notes:
* Avoid zero-sized kmem_alloc() in vdev_compact_children().
The device evacuation code adds a dependency that
vdev_compact_children() be able to properly empty the vdev_child
array by setting it to NULL and zeroing vdev_children. Under Linux,
kmem_alloc() and related functions return a sentinel pointer rather
than NULL for zero-sized allocations.
* Remove comment regarding "mpt" driver where zfs_remove_max_segment
is initialized to SPA_MAXBLOCKSIZE.
Change zfs_condense_indirect_commit_entry_delay_ticks to
zfs_condense_indirect_commit_entry_delay_ms for consistency with
most other tunables in which delays are specified in ms.
* ZTS changes:
Use set_tunable rather than mdb
Use zpool sync as appropriate
Use sync_pool instead of sync
Kill jobs during test_removal_with_operation to allow unmount/export
Don't add non-disk names such as "mirror" or "raidz" to $DISKS
Use $TEST_BASE_DIR instead of /tmp
Increase HZ from 100 to 1000 which is more common on Linux
removal_multiple_indirection.ksh
Reduce iterations in order to not time out on the code
coverage builders.
removal_resume_export:
Functionally, the test case is correct but there exists a race
where the kernel thread hasn't been fully started yet and is
not visible. Wait for up to 1 second for the removal thread
to be started before giving up on it. Also, increase the
amount of data copied in order that the removal not finish
before the export has a chance to fail.
* MMP compatibility, the concept of concrete versus non-concrete devices
has slightly changed the semantics of vdev_writeable(). Update
mmp_random_leaf_impl() accordingly.
* Updated dbuf_remap() to handle the org.zfsonlinux:large_dnode pool
feature which is not supported by OpenZFS.
* Added support for new vdev removal tracepoints.
* Test cases removal_with_zdb and removal_condense_export have been
intentionally disabled. When run manually they pass as intended,
but when running in the automated test environment they produce
unreliable results on the latest Fedora release.
They may work better once the upstream pool import refectoring is
merged into ZoL at which point they will be re-enabled.
Authored by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Alex Reece <alex@delphix.com>
Reviewed-by: George Wilson <george.wilson@delphix.com>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Richard Laager <rlaager@wiktel.com>
Reviewed by: Tim Chase <tim@chase2k.com>
Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Approved by: Garrett D'Amore <garrett@damore.org>
Ported-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Tim Chase <tim@chase2k.com>
OpenZFS-issue: https://www.illumos.org/issues/7614
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/f539f1eb
Closes #6900
2016-09-22 19:30:13 +03:00
|
|
|
ASSERT(bpobj_is_open(bpo));
|
2010-05-29 00:45:14 +04:00
|
|
|
ASSERT(!BP_IS_HOLE(bp));
|
2012-12-24 03:57:14 +04:00
|
|
|
ASSERT(bpo->bpo_object != dmu_objset_pool(bpo->bpo_os)->dp_empty_bpobj);
|
2010-05-29 00:45:14 +04:00
|
|
|
|
2014-06-06 01:19:08 +04:00
|
|
|
if (BP_IS_EMBEDDED(bp)) {
|
|
|
|
/*
|
|
|
|
* The bpobj will compress better without the payload.
|
|
|
|
*
|
|
|
|
* Note that we store EMBEDDED bp's because they have an
|
|
|
|
* uncompressed size, which must be accounted for. An
|
|
|
|
* alternative would be to add their size to bpo_uncomp
|
|
|
|
* without storing the bp, but that would create additional
|
|
|
|
* complications: bpo_uncomp would be inconsistent with the
|
|
|
|
* set of BP's stored, and bpobj_iterate() wouldn't visit
|
|
|
|
* all the space accounted for in the bpobj.
|
|
|
|
*/
|
|
|
|
bzero(&stored_bp, sizeof (stored_bp));
|
|
|
|
stored_bp.blk_prop = bp->blk_prop;
|
|
|
|
stored_bp.blk_birth = bp->blk_birth;
|
|
|
|
} else if (!BP_GET_DEDUP(bp)) {
|
|
|
|
/* The bpobj will compress better without the checksum */
|
|
|
|
bzero(&stored_bp.blk_cksum, sizeof (stored_bp.blk_cksum));
|
|
|
|
}
|
|
|
|
|
2010-05-29 00:45:14 +04:00
|
|
|
stored_bp.blk_fill = 0;
|
2019-07-26 20:54:14 +03:00
|
|
|
BP_SET_FREE(&stored_bp, bp_freed);
|
2010-05-29 00:45:14 +04:00
|
|
|
|
|
|
|
mutex_enter(&bpo->bpo_lock);
|
|
|
|
|
|
|
|
offset = bpo->bpo_phys->bpo_num_blkptrs * sizeof (stored_bp);
|
|
|
|
blkoff = P2PHASE(bpo->bpo_phys->bpo_num_blkptrs, bpo->bpo_epb);
|
|
|
|
|
|
|
|
if (bpo->bpo_cached_dbuf == NULL ||
|
|
|
|
offset < bpo->bpo_cached_dbuf->db_offset ||
|
|
|
|
offset >= bpo->bpo_cached_dbuf->db_offset +
|
|
|
|
bpo->bpo_cached_dbuf->db_size) {
|
|
|
|
if (bpo->bpo_cached_dbuf)
|
|
|
|
dmu_buf_rele(bpo->bpo_cached_dbuf, bpo);
|
|
|
|
VERIFY3U(0, ==, dmu_buf_hold(bpo->bpo_os, bpo->bpo_object,
|
|
|
|
offset, bpo, &bpo->bpo_cached_dbuf, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
dmu_buf_will_dirty(bpo->bpo_cached_dbuf, tx);
|
|
|
|
bparray = bpo->bpo_cached_dbuf->db_data;
|
|
|
|
bparray[blkoff] = stored_bp;
|
|
|
|
|
|
|
|
dmu_buf_will_dirty(bpo->bpo_dbuf, tx);
|
|
|
|
bpo->bpo_phys->bpo_num_blkptrs++;
|
2019-07-26 20:54:14 +03:00
|
|
|
int sign = bp_freed ? -1 : +1;
|
|
|
|
bpo->bpo_phys->bpo_bytes += sign *
|
2010-05-29 00:45:14 +04:00
|
|
|
bp_get_dsize_sync(dmu_objset_spa(bpo->bpo_os), bp);
|
|
|
|
if (bpo->bpo_havecomp) {
|
2019-07-26 20:54:14 +03:00
|
|
|
bpo->bpo_phys->bpo_comp += sign * BP_GET_PSIZE(bp);
|
|
|
|
bpo->bpo_phys->bpo_uncomp += sign * BP_GET_UCSIZE(bp);
|
|
|
|
}
|
|
|
|
if (bp_freed) {
|
|
|
|
ASSERT(bpo->bpo_havefreed);
|
|
|
|
bpo->bpo_phys->bpo_num_freed++;
|
2010-05-29 00:45:14 +04:00
|
|
|
}
|
|
|
|
mutex_exit(&bpo->bpo_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct space_range_arg {
|
|
|
|
spa_t *spa;
|
|
|
|
uint64_t mintxg;
|
|
|
|
uint64_t maxtxg;
|
|
|
|
uint64_t used;
|
|
|
|
uint64_t comp;
|
|
|
|
uint64_t uncomp;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ARGSUSED */
|
|
|
|
static int
|
2019-07-26 20:54:14 +03:00
|
|
|
space_range_cb(void *arg, const blkptr_t *bp, boolean_t bp_freed, dmu_tx_t *tx)
|
2010-05-29 00:45:14 +04:00
|
|
|
{
|
|
|
|
struct space_range_arg *sra = arg;
|
|
|
|
|
|
|
|
if (bp->blk_birth > sra->mintxg && bp->blk_birth <= sra->maxtxg) {
|
2011-11-17 22:14:36 +04:00
|
|
|
if (dsl_pool_sync_context(spa_get_dsl(sra->spa)))
|
|
|
|
sra->used += bp_get_dsize_sync(sra->spa, bp);
|
|
|
|
else
|
|
|
|
sra->used += bp_get_dsize(sra->spa, bp);
|
2010-05-29 00:45:14 +04:00
|
|
|
sra->comp += BP_GET_PSIZE(bp);
|
|
|
|
sra->uncomp += BP_GET_UCSIZE(bp);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
bpobj_space(bpobj_t *bpo, uint64_t *usedp, uint64_t *compp, uint64_t *uncompp)
|
|
|
|
{
|
OpenZFS 7614, 9064 - zfs device evacuation/removal
OpenZFS 7614 - zfs device evacuation/removal
OpenZFS 9064 - remove_mirror should wait for device removal to complete
This project allows top-level vdevs to be removed from the storage pool
with "zpool remove", reducing the total amount of storage in the pool.
This operation copies all allocated regions of the device to be removed
onto other devices, recording the mapping from old to new location.
After the removal is complete, read and free operations to the removed
(now "indirect") vdev must be remapped and performed at the new location
on disk. The indirect mapping table is kept in memory whenever the pool
is loaded, so there is minimal performance overhead when doing operations
on the indirect vdev.
The size of the in-memory mapping table will be reduced when its entries
become "obsolete" because they are no longer used by any block pointers
in the pool. An entry becomes obsolete when all the blocks that use
it are freed. An entry can also become obsolete when all the snapshots
that reference it are deleted, and the block pointers that reference it
have been "remapped" in all filesystems/zvols (and clones). Whenever an
indirect block is written, all the block pointers in it will be "remapped"
to their new (concrete) locations if possible. This process can be
accelerated by using the "zfs remap" command to proactively rewrite all
indirect blocks that reference indirect (removed) vdevs.
Note that when a device is removed, we do not verify the checksum of
the data that is copied. This makes the process much faster, but if it
were used on redundant vdevs (i.e. mirror or raidz vdevs), it would be
possible to copy the wrong data, when we have the correct data on e.g.
the other side of the mirror.
At the moment, only mirrors and simple top-level vdevs can be removed
and no removal is allowed if any of the top-level vdevs are raidz.
Porting Notes:
* Avoid zero-sized kmem_alloc() in vdev_compact_children().
The device evacuation code adds a dependency that
vdev_compact_children() be able to properly empty the vdev_child
array by setting it to NULL and zeroing vdev_children. Under Linux,
kmem_alloc() and related functions return a sentinel pointer rather
than NULL for zero-sized allocations.
* Remove comment regarding "mpt" driver where zfs_remove_max_segment
is initialized to SPA_MAXBLOCKSIZE.
Change zfs_condense_indirect_commit_entry_delay_ticks to
zfs_condense_indirect_commit_entry_delay_ms for consistency with
most other tunables in which delays are specified in ms.
* ZTS changes:
Use set_tunable rather than mdb
Use zpool sync as appropriate
Use sync_pool instead of sync
Kill jobs during test_removal_with_operation to allow unmount/export
Don't add non-disk names such as "mirror" or "raidz" to $DISKS
Use $TEST_BASE_DIR instead of /tmp
Increase HZ from 100 to 1000 which is more common on Linux
removal_multiple_indirection.ksh
Reduce iterations in order to not time out on the code
coverage builders.
removal_resume_export:
Functionally, the test case is correct but there exists a race
where the kernel thread hasn't been fully started yet and is
not visible. Wait for up to 1 second for the removal thread
to be started before giving up on it. Also, increase the
amount of data copied in order that the removal not finish
before the export has a chance to fail.
* MMP compatibility, the concept of concrete versus non-concrete devices
has slightly changed the semantics of vdev_writeable(). Update
mmp_random_leaf_impl() accordingly.
* Updated dbuf_remap() to handle the org.zfsonlinux:large_dnode pool
feature which is not supported by OpenZFS.
* Added support for new vdev removal tracepoints.
* Test cases removal_with_zdb and removal_condense_export have been
intentionally disabled. When run manually they pass as intended,
but when running in the automated test environment they produce
unreliable results on the latest Fedora release.
They may work better once the upstream pool import refectoring is
merged into ZoL at which point they will be re-enabled.
Authored by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Alex Reece <alex@delphix.com>
Reviewed-by: George Wilson <george.wilson@delphix.com>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Richard Laager <rlaager@wiktel.com>
Reviewed by: Tim Chase <tim@chase2k.com>
Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Approved by: Garrett D'Amore <garrett@damore.org>
Ported-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Tim Chase <tim@chase2k.com>
OpenZFS-issue: https://www.illumos.org/issues/7614
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/f539f1eb
Closes #6900
2016-09-22 19:30:13 +03:00
|
|
|
ASSERT(bpobj_is_open(bpo));
|
2010-05-29 00:45:14 +04:00
|
|
|
mutex_enter(&bpo->bpo_lock);
|
|
|
|
|
|
|
|
*usedp = bpo->bpo_phys->bpo_bytes;
|
|
|
|
if (bpo->bpo_havecomp) {
|
|
|
|
*compp = bpo->bpo_phys->bpo_comp;
|
|
|
|
*uncompp = bpo->bpo_phys->bpo_uncomp;
|
|
|
|
mutex_exit(&bpo->bpo_lock);
|
|
|
|
return (0);
|
|
|
|
} else {
|
|
|
|
mutex_exit(&bpo->bpo_lock);
|
|
|
|
return (bpobj_space_range(bpo, 0, UINT64_MAX,
|
|
|
|
usedp, compp, uncompp));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the amount of space in the bpobj which is:
|
|
|
|
* mintxg < blk_birth <= maxtxg
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
bpobj_space_range(bpobj_t *bpo, uint64_t mintxg, uint64_t maxtxg,
|
|
|
|
uint64_t *usedp, uint64_t *compp, uint64_t *uncompp)
|
|
|
|
{
|
|
|
|
struct space_range_arg sra = { 0 };
|
|
|
|
int err;
|
|
|
|
|
OpenZFS 7614, 9064 - zfs device evacuation/removal
OpenZFS 7614 - zfs device evacuation/removal
OpenZFS 9064 - remove_mirror should wait for device removal to complete
This project allows top-level vdevs to be removed from the storage pool
with "zpool remove", reducing the total amount of storage in the pool.
This operation copies all allocated regions of the device to be removed
onto other devices, recording the mapping from old to new location.
After the removal is complete, read and free operations to the removed
(now "indirect") vdev must be remapped and performed at the new location
on disk. The indirect mapping table is kept in memory whenever the pool
is loaded, so there is minimal performance overhead when doing operations
on the indirect vdev.
The size of the in-memory mapping table will be reduced when its entries
become "obsolete" because they are no longer used by any block pointers
in the pool. An entry becomes obsolete when all the blocks that use
it are freed. An entry can also become obsolete when all the snapshots
that reference it are deleted, and the block pointers that reference it
have been "remapped" in all filesystems/zvols (and clones). Whenever an
indirect block is written, all the block pointers in it will be "remapped"
to their new (concrete) locations if possible. This process can be
accelerated by using the "zfs remap" command to proactively rewrite all
indirect blocks that reference indirect (removed) vdevs.
Note that when a device is removed, we do not verify the checksum of
the data that is copied. This makes the process much faster, but if it
were used on redundant vdevs (i.e. mirror or raidz vdevs), it would be
possible to copy the wrong data, when we have the correct data on e.g.
the other side of the mirror.
At the moment, only mirrors and simple top-level vdevs can be removed
and no removal is allowed if any of the top-level vdevs are raidz.
Porting Notes:
* Avoid zero-sized kmem_alloc() in vdev_compact_children().
The device evacuation code adds a dependency that
vdev_compact_children() be able to properly empty the vdev_child
array by setting it to NULL and zeroing vdev_children. Under Linux,
kmem_alloc() and related functions return a sentinel pointer rather
than NULL for zero-sized allocations.
* Remove comment regarding "mpt" driver where zfs_remove_max_segment
is initialized to SPA_MAXBLOCKSIZE.
Change zfs_condense_indirect_commit_entry_delay_ticks to
zfs_condense_indirect_commit_entry_delay_ms for consistency with
most other tunables in which delays are specified in ms.
* ZTS changes:
Use set_tunable rather than mdb
Use zpool sync as appropriate
Use sync_pool instead of sync
Kill jobs during test_removal_with_operation to allow unmount/export
Don't add non-disk names such as "mirror" or "raidz" to $DISKS
Use $TEST_BASE_DIR instead of /tmp
Increase HZ from 100 to 1000 which is more common on Linux
removal_multiple_indirection.ksh
Reduce iterations in order to not time out on the code
coverage builders.
removal_resume_export:
Functionally, the test case is correct but there exists a race
where the kernel thread hasn't been fully started yet and is
not visible. Wait for up to 1 second for the removal thread
to be started before giving up on it. Also, increase the
amount of data copied in order that the removal not finish
before the export has a chance to fail.
* MMP compatibility, the concept of concrete versus non-concrete devices
has slightly changed the semantics of vdev_writeable(). Update
mmp_random_leaf_impl() accordingly.
* Updated dbuf_remap() to handle the org.zfsonlinux:large_dnode pool
feature which is not supported by OpenZFS.
* Added support for new vdev removal tracepoints.
* Test cases removal_with_zdb and removal_condense_export have been
intentionally disabled. When run manually they pass as intended,
but when running in the automated test environment they produce
unreliable results on the latest Fedora release.
They may work better once the upstream pool import refectoring is
merged into ZoL at which point they will be re-enabled.
Authored by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Alex Reece <alex@delphix.com>
Reviewed-by: George Wilson <george.wilson@delphix.com>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Richard Laager <rlaager@wiktel.com>
Reviewed by: Tim Chase <tim@chase2k.com>
Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Approved by: Garrett D'Amore <garrett@damore.org>
Ported-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Tim Chase <tim@chase2k.com>
OpenZFS-issue: https://www.illumos.org/issues/7614
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/f539f1eb
Closes #6900
2016-09-22 19:30:13 +03:00
|
|
|
ASSERT(bpobj_is_open(bpo));
|
|
|
|
|
2010-05-29 00:45:14 +04:00
|
|
|
/*
|
|
|
|
* As an optimization, if they want the whole txg range, just
|
|
|
|
* get bpo_bytes rather than iterating over the bps.
|
|
|
|
*/
|
|
|
|
if (mintxg < TXG_INITIAL && maxtxg == UINT64_MAX && bpo->bpo_havecomp)
|
|
|
|
return (bpobj_space(bpo, usedp, compp, uncompp));
|
|
|
|
|
|
|
|
sra.spa = dmu_objset_spa(bpo->bpo_os);
|
|
|
|
sra.mintxg = mintxg;
|
|
|
|
sra.maxtxg = maxtxg;
|
|
|
|
|
|
|
|
err = bpobj_iterate_nofree(bpo, space_range_cb, &sra, NULL);
|
|
|
|
*usedp = sra.used;
|
|
|
|
*compp = sra.comp;
|
|
|
|
*uncompp = sra.uncomp;
|
|
|
|
return (err);
|
|
|
|
}
|
2019-07-26 20:54:14 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* A bpobj_itor_t to append blkptrs to a bplist. Note that while blkptrs in a
|
|
|
|
* bpobj are designated as free or allocated that information is not preserved
|
|
|
|
* in bplists.
|
|
|
|
*/
|
|
|
|
/* ARGSUSED */
|
|
|
|
int
|
|
|
|
bplist_append_cb(void *arg, const blkptr_t *bp, boolean_t bp_freed,
|
|
|
|
dmu_tx_t *tx)
|
|
|
|
{
|
|
|
|
bplist_t *bpl = arg;
|
|
|
|
bplist_append(bpl, bp);
|
|
|
|
return (0);
|
|
|
|
}
|