2008-11-20 20:01:55 +00: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
|
|
|
|
*/
|
|
|
|
/*
|
2010-05-28 20:45:14 +00:00
|
|
|
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
OpenZFS 9102 - zfs should be able to initialize storage devices
PROBLEM
========
The first access to a block incurs a performance penalty on some platforms
(e.g. AWS's EBS, VMware VMDKs). Therefore we recommend that volumes are
"thick provisioned", where supported by the platform (VMware). This can
create a large delay in getting a new virtual machines up and running (or
adding storage to an existing Engine). If the thick provision step is
omitted, write performance will be suboptimal until all blocks on the LUN
have been written.
SOLUTION
=========
This feature introduces a way to 'initialize' the disks at install or in the
background to make sure we don't incur this first read penalty.
When an entire LUN is added to ZFS, we make all space available immediately,
and allow ZFS to find unallocated space and zero it out. This works with
concurrent writes to arbitrary offsets, ensuring that we don't zero out
something that has been (or is in the middle of being) written. This scheme
can also be applied to existing pools (affecting only free regions on the
vdev). Detailed design:
- new subcommand:zpool initialize [-cs] <pool> [<vdev> ...]
- start, suspend, or cancel initialization
- Creates new open-context thread for each vdev
- Thread iterates through all metaslabs in this vdev
- Each metaslab:
- select a metaslab
- load the metaslab
- mark the metaslab as being zeroed
- walk all free ranges within that metaslab and translate
them to ranges on the leaf vdev
- issue a "zeroing" I/O on the leaf vdev that corresponds to
a free range on the metaslab we're working on
- continue until all free ranges for this metaslab have been
"zeroed"
- reset/unmark the metaslab being zeroed
- if more metaslabs exist, then repeat above tasks.
- if no more metaslabs, then we're done.
- progress for the initialization is stored on-disk in the vdev’s
leaf zap object. The following information is stored:
- the last offset that has been initialized
- the state of the initialization process (i.e. active,
suspended, or canceled)
- the start time for the initialization
- progress is reported via the zpool status command and shows
information for each of the vdevs that are initializing
Porting notes:
- Added zfs_initialize_value module parameter to set the pattern
written by "zpool initialize".
- Added zfs_vdev_{initializing,removal}_{min,max}_active module options.
Authored by: George Wilson <george.wilson@delphix.com>
Reviewed by: John Wren Kennedy <john.kennedy@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: loli10K <ezomori.nozomu@gmail.com>
Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Approved by: Richard Lowe <richlowe@richlowe.net>
Signed-off-by: Tim Chase <tim@chase2k.com>
Ported-by: Tim Chase <tim@chase2k.com>
OpenZFS-issue: https://www.illumos.org/issues/9102
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/c3963210eb
Closes #8230
2018-12-19 14:54:59 +00:00
|
|
|
* Copyright (c) 2011, 2016 by Delphix. All rights reserved.
|
2008-11-20 20:01:55 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/zfs_context.h>
|
|
|
|
#include <sys/spa.h>
|
2013-05-02 23:36:32 +00:00
|
|
|
#include <sys/spa_impl.h>
|
2008-11-20 20:01:55 +00:00
|
|
|
#include <sys/vdev_file.h>
|
|
|
|
#include <sys/vdev_impl.h>
|
2019-03-29 16:13:20 +00:00
|
|
|
#include <sys/vdev_trim.h>
|
2008-11-20 20:01:55 +00:00
|
|
|
#include <sys/zio.h>
|
|
|
|
#include <sys/fs/zfs.h>
|
2008-12-03 20:09:06 +00:00
|
|
|
#include <sys/fm/fs/zfs.h>
|
2016-07-22 15:52:49 +00:00
|
|
|
#include <sys/abd.h>
|
2019-03-29 16:13:20 +00:00
|
|
|
#include <sys/fcntl.h>
|
|
|
|
#include <sys/vnode.h>
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Virtual device vector for files.
|
|
|
|
*/
|
|
|
|
|
2016-12-21 18:47:15 +00:00
|
|
|
static taskq_t *vdev_file_taskq;
|
|
|
|
|
2010-05-28 20:45:14 +00:00
|
|
|
static void
|
|
|
|
vdev_file_hold(vdev_t *vd)
|
|
|
|
{
|
|
|
|
ASSERT(vd->vdev_path != NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vdev_file_rele(vdev_t *vd)
|
|
|
|
{
|
|
|
|
ASSERT(vd->vdev_path != NULL);
|
|
|
|
}
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
static int
|
2012-01-24 02:43:32 +00:00
|
|
|
vdev_file_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
|
|
|
|
uint64_t *ashift)
|
2008-11-20 20:01:55 +00:00
|
|
|
{
|
|
|
|
vdev_file_t *vf;
|
|
|
|
vnode_t *vp;
|
2008-12-03 20:09:06 +00:00
|
|
|
vattr_t vattr;
|
2008-11-20 20:01:55 +00:00
|
|
|
int error;
|
|
|
|
|
2019-03-29 16:13:20 +00:00
|
|
|
/*
|
|
|
|
* Rotational optimizations only make sense on block devices.
|
|
|
|
*/
|
2015-08-29 16:01:07 +00:00
|
|
|
vd->vdev_nonrot = B_TRUE;
|
|
|
|
|
2019-03-29 16:13:20 +00:00
|
|
|
/*
|
|
|
|
* Allow TRIM on file based vdevs. This may not always be supported,
|
|
|
|
* since it depends on your kernel version and underlying filesystem
|
|
|
|
* type but it is always safe to attempt.
|
|
|
|
*/
|
|
|
|
vd->vdev_has_trim = B_TRUE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable secure TRIM on file based vdevs. There is no way to
|
|
|
|
* request this behavior from the underlying filesystem.
|
|
|
|
*/
|
|
|
|
vd->vdev_has_securetrim = B_FALSE;
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
/*
|
|
|
|
* We must have a pathname, and it must be absolute.
|
|
|
|
*/
|
|
|
|
if (vd->vdev_path == NULL || vd->vdev_path[0] != '/') {
|
|
|
|
vd->vdev_stat.vs_aux = VDEV_AUX_BAD_LABEL;
|
2013-03-08 18:41:28 +00:00
|
|
|
return (SET_ERROR(EINVAL));
|
2008-11-20 20:01:55 +00:00
|
|
|
}
|
|
|
|
|
2010-05-28 20:45:14 +00:00
|
|
|
/*
|
|
|
|
* Reopen the device if it's not currently open. Otherwise,
|
|
|
|
* just update the physical size of the device.
|
|
|
|
*/
|
|
|
|
if (vd->vdev_tsd != NULL) {
|
|
|
|
ASSERT(vd->vdev_reopening);
|
|
|
|
vf = vd->vdev_tsd;
|
|
|
|
goto skip_open;
|
|
|
|
}
|
|
|
|
|
2014-11-21 00:09:39 +00:00
|
|
|
vf = vd->vdev_tsd = kmem_zalloc(sizeof (vdev_file_t), KM_SLEEP);
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We always open the files from the root of the global zone, even if
|
|
|
|
* we're in a local zone. If the user has gotten to this point, the
|
|
|
|
* administrator has already decided that the pool should be available
|
|
|
|
* to local zone users, so the underlying devices should be as well.
|
|
|
|
*/
|
|
|
|
ASSERT(vd->vdev_path != NULL && vd->vdev_path[0] == '/');
|
|
|
|
error = vn_openat(vd->vdev_path + 1, UIO_SYSSPACE,
|
2009-01-15 21:59:39 +00:00
|
|
|
spa_mode(vd->vdev_spa) | FOFFMAX, 0, &vp, 0, 0, rootdir, -1);
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
if (error) {
|
|
|
|
vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED;
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
vf->vf_vnode = vp;
|
|
|
|
|
|
|
|
#ifdef _KERNEL
|
|
|
|
/*
|
|
|
|
* Make sure it's a regular file.
|
|
|
|
*/
|
|
|
|
if (vp->v_type != VREG) {
|
|
|
|
vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED;
|
2013-03-08 18:41:28 +00:00
|
|
|
return (SET_ERROR(ENODEV));
|
2008-11-20 20:01:55 +00:00
|
|
|
}
|
|
|
|
#endif
|
2010-05-28 20:45:14 +00:00
|
|
|
|
|
|
|
skip_open:
|
2008-11-20 20:01:55 +00:00
|
|
|
/*
|
|
|
|
* Determine the physical size of the file.
|
|
|
|
*/
|
|
|
|
vattr.va_mask = AT_SIZE;
|
|
|
|
error = VOP_GETATTR(vf->vf_vnode, &vattr, 0, kcred, NULL);
|
|
|
|
if (error) {
|
|
|
|
vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED;
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
2012-01-24 02:43:32 +00:00
|
|
|
*max_psize = *psize = vattr.va_size;
|
2008-11-20 20:01:55 +00:00
|
|
|
*ashift = SPA_MINBLOCKSHIFT;
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vdev_file_close(vdev_t *vd)
|
|
|
|
{
|
|
|
|
vdev_file_t *vf = vd->vdev_tsd;
|
|
|
|
|
2010-05-28 20:45:14 +00:00
|
|
|
if (vd->vdev_reopening || vf == NULL)
|
2008-11-20 20:01:55 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (vf->vf_vnode != NULL) {
|
|
|
|
(void) VOP_PUTPAGE(vf->vf_vnode, 0, 0, B_INVAL, kcred, NULL);
|
2009-01-15 21:59:39 +00:00
|
|
|
(void) VOP_CLOSE(vf->vf_vnode, spa_mode(vd->vdev_spa), 1, 0,
|
|
|
|
kcred, NULL);
|
2008-11-20 20:01:55 +00:00
|
|
|
}
|
|
|
|
|
2010-05-28 20:45:14 +00:00
|
|
|
vd->vdev_delayed_close = B_FALSE;
|
2008-11-20 20:01:55 +00:00
|
|
|
kmem_free(vf, sizeof (vdev_file_t));
|
|
|
|
vd->vdev_tsd = NULL;
|
|
|
|
}
|
|
|
|
|
2013-05-02 23:36:32 +00:00
|
|
|
static void
|
|
|
|
vdev_file_io_strategy(void *arg)
|
2008-11-20 20:01:55 +00:00
|
|
|
{
|
2013-05-02 23:36:32 +00:00
|
|
|
zio_t *zio = (zio_t *)arg;
|
2008-11-20 20:01:55 +00:00
|
|
|
vdev_t *vd = zio->io_vd;
|
2013-05-02 23:36:32 +00:00
|
|
|
vdev_file_t *vf = vd->vdev_tsd;
|
|
|
|
ssize_t resid;
|
2016-07-22 15:52:49 +00:00
|
|
|
void *buf;
|
|
|
|
|
|
|
|
if (zio->io_type == ZIO_TYPE_READ)
|
|
|
|
buf = abd_borrow_buf(zio->io_abd, zio->io_size);
|
|
|
|
else
|
|
|
|
buf = abd_borrow_buf_copy(zio->io_abd, zio->io_size);
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2013-05-02 23:36:32 +00:00
|
|
|
zio->io_error = vn_rdwr(zio->io_type == ZIO_TYPE_READ ?
|
2016-07-22 15:52:49 +00:00
|
|
|
UIO_READ : UIO_WRITE, vf->vf_vnode, buf, zio->io_size,
|
|
|
|
zio->io_offset, UIO_SYSSPACE, 0, RLIM64_INFINITY, kcred, &resid);
|
|
|
|
|
|
|
|
if (zio->io_type == ZIO_TYPE_READ)
|
|
|
|
abd_return_buf_copy(zio->io_abd, buf, zio->io_size);
|
|
|
|
else
|
|
|
|
abd_return_buf(zio->io_abd, buf, zio->io_size);
|
2013-05-02 23:36:32 +00:00
|
|
|
|
|
|
|
if (resid != 0 && zio->io_error == 0)
|
2013-03-08 18:41:28 +00:00
|
|
|
zio->io_error = SET_ERROR(ENOSPC);
|
2012-04-09 17:01:46 +00:00
|
|
|
|
2016-05-23 17:41:29 +00:00
|
|
|
zio_delay_interrupt(zio);
|
2013-05-02 23:36:32 +00:00
|
|
|
}
|
|
|
|
|
2014-07-13 18:35:19 +00:00
|
|
|
static void
|
|
|
|
vdev_file_io_fsync(void *arg)
|
|
|
|
{
|
|
|
|
zio_t *zio = (zio_t *)arg;
|
|
|
|
vdev_file_t *vf = zio->io_vd->vdev_tsd;
|
|
|
|
|
|
|
|
zio->io_error = VOP_FSYNC(vf->vf_vnode, FSYNC | FDSYNC, kcred, NULL);
|
|
|
|
|
|
|
|
zio_interrupt(zio);
|
|
|
|
}
|
|
|
|
|
2014-10-20 22:07:45 +00:00
|
|
|
static void
|
2013-05-02 23:36:32 +00:00
|
|
|
vdev_file_io_start(zio_t *zio)
|
|
|
|
{
|
|
|
|
vdev_t *vd = zio->io_vd;
|
|
|
|
vdev_file_t *vf = vd->vdev_tsd;
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2012-04-09 17:01:46 +00:00
|
|
|
if (zio->io_type == ZIO_TYPE_IOCTL) {
|
2013-05-02 23:36:32 +00:00
|
|
|
/* XXPOLICY */
|
|
|
|
if (!vdev_readable(vd)) {
|
2013-03-08 18:41:28 +00:00
|
|
|
zio->io_error = SET_ERROR(ENXIO);
|
2014-10-20 22:07:45 +00:00
|
|
|
zio_interrupt(zio);
|
|
|
|
return;
|
2013-05-02 23:36:32 +00:00
|
|
|
}
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
switch (zio->io_cmd) {
|
|
|
|
case DKIOCFLUSHWRITECACHE:
|
2014-05-15 00:58:11 +00:00
|
|
|
|
|
|
|
if (zfs_nocacheflush)
|
|
|
|
break;
|
|
|
|
|
2014-07-13 18:35:19 +00:00
|
|
|
/*
|
|
|
|
* We cannot safely call vfs_fsync() when PF_FSTRANS
|
|
|
|
* is set in the current context. Filesystems like
|
|
|
|
* XFS include sanity checks to verify it is not
|
|
|
|
* already set, see xfs_vm_writepage(). Therefore
|
|
|
|
* the sync must be dispatched to a different context.
|
|
|
|
*/
|
2017-05-09 17:38:46 +00:00
|
|
|
if (__spl_pf_fstrans_check()) {
|
2016-12-21 18:47:15 +00:00
|
|
|
VERIFY3U(taskq_dispatch(vdev_file_taskq,
|
2016-10-28 22:40:14 +00:00
|
|
|
vdev_file_io_fsync, zio, TQ_SLEEP), !=,
|
|
|
|
TASKQID_INVALID);
|
2014-10-20 22:07:45 +00:00
|
|
|
return;
|
2014-07-13 18:35:19 +00:00
|
|
|
}
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
zio->io_error = VOP_FSYNC(vf->vf_vnode, FSYNC | FDSYNC,
|
|
|
|
kcred, NULL);
|
|
|
|
break;
|
|
|
|
default:
|
2013-03-08 18:41:28 +00:00
|
|
|
zio->io_error = SET_ERROR(ENOTSUP);
|
2008-11-20 20:01:55 +00:00
|
|
|
}
|
|
|
|
|
2019-03-29 16:13:20 +00:00
|
|
|
zio_execute(zio);
|
|
|
|
return;
|
|
|
|
} else if (zio->io_type == ZIO_TYPE_TRIM) {
|
|
|
|
struct flock flck;
|
|
|
|
|
|
|
|
ASSERT3U(zio->io_size, !=, 0);
|
|
|
|
bzero(&flck, sizeof (flck));
|
|
|
|
flck.l_type = F_FREESP;
|
|
|
|
flck.l_start = zio->io_offset;
|
|
|
|
flck.l_len = zio->io_size;
|
2019-04-25 17:17:28 +00:00
|
|
|
flck.l_whence = SEEK_SET;
|
2019-03-29 16:13:20 +00:00
|
|
|
|
|
|
|
zio->io_error = VOP_SPACE(vf->vf_vnode, F_FREESP, &flck,
|
|
|
|
0, 0, kcred, NULL);
|
|
|
|
|
2014-10-20 22:07:45 +00:00
|
|
|
zio_execute(zio);
|
|
|
|
return;
|
2008-11-20 20:01:55 +00:00
|
|
|
}
|
|
|
|
|
2016-05-23 17:41:29 +00:00
|
|
|
zio->io_target_timestamp = zio_handle_io_delay(zio);
|
|
|
|
|
2016-12-21 18:47:15 +00:00
|
|
|
VERIFY3U(taskq_dispatch(vdev_file_taskq, vdev_file_io_strategy, zio,
|
2016-10-28 22:40:14 +00:00
|
|
|
TQ_SLEEP), !=, TASKQID_INVALID);
|
2008-11-20 20:01:55 +00:00
|
|
|
}
|
|
|
|
|
2008-12-03 20:09:06 +00:00
|
|
|
/* ARGSUSED */
|
|
|
|
static void
|
2008-11-20 20:01:55 +00:00
|
|
|
vdev_file_io_done(zio_t *zio)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
vdev_ops_t vdev_file_ops = {
|
|
|
|
vdev_file_open,
|
|
|
|
vdev_file_close,
|
|
|
|
vdev_default_asize,
|
|
|
|
vdev_file_io_start,
|
|
|
|
vdev_file_io_done,
|
|
|
|
NULL,
|
2017-05-13 00:28:03 +00:00
|
|
|
NULL,
|
2010-05-28 20:45:14 +00:00
|
|
|
vdev_file_hold,
|
|
|
|
vdev_file_rele,
|
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 16:30:13 +00:00
|
|
|
NULL,
|
OpenZFS 9102 - zfs should be able to initialize storage devices
PROBLEM
========
The first access to a block incurs a performance penalty on some platforms
(e.g. AWS's EBS, VMware VMDKs). Therefore we recommend that volumes are
"thick provisioned", where supported by the platform (VMware). This can
create a large delay in getting a new virtual machines up and running (or
adding storage to an existing Engine). If the thick provision step is
omitted, write performance will be suboptimal until all blocks on the LUN
have been written.
SOLUTION
=========
This feature introduces a way to 'initialize' the disks at install or in the
background to make sure we don't incur this first read penalty.
When an entire LUN is added to ZFS, we make all space available immediately,
and allow ZFS to find unallocated space and zero it out. This works with
concurrent writes to arbitrary offsets, ensuring that we don't zero out
something that has been (or is in the middle of being) written. This scheme
can also be applied to existing pools (affecting only free regions on the
vdev). Detailed design:
- new subcommand:zpool initialize [-cs] <pool> [<vdev> ...]
- start, suspend, or cancel initialization
- Creates new open-context thread for each vdev
- Thread iterates through all metaslabs in this vdev
- Each metaslab:
- select a metaslab
- load the metaslab
- mark the metaslab as being zeroed
- walk all free ranges within that metaslab and translate
them to ranges on the leaf vdev
- issue a "zeroing" I/O on the leaf vdev that corresponds to
a free range on the metaslab we're working on
- continue until all free ranges for this metaslab have been
"zeroed"
- reset/unmark the metaslab being zeroed
- if more metaslabs exist, then repeat above tasks.
- if no more metaslabs, then we're done.
- progress for the initialization is stored on-disk in the vdev’s
leaf zap object. The following information is stored:
- the last offset that has been initialized
- the state of the initialization process (i.e. active,
suspended, or canceled)
- the start time for the initialization
- progress is reported via the zpool status command and shows
information for each of the vdevs that are initializing
Porting notes:
- Added zfs_initialize_value module parameter to set the pattern
written by "zpool initialize".
- Added zfs_vdev_{initializing,removal}_{min,max}_active module options.
Authored by: George Wilson <george.wilson@delphix.com>
Reviewed by: John Wren Kennedy <john.kennedy@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: loli10K <ezomori.nozomu@gmail.com>
Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Approved by: Richard Lowe <richlowe@richlowe.net>
Signed-off-by: Tim Chase <tim@chase2k.com>
Ported-by: Tim Chase <tim@chase2k.com>
OpenZFS-issue: https://www.illumos.org/issues/9102
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/c3963210eb
Closes #8230
2018-12-19 14:54:59 +00:00
|
|
|
vdev_default_xlate,
|
2008-11-20 20:01:55 +00:00
|
|
|
VDEV_TYPE_FILE, /* name of this vdev type */
|
|
|
|
B_TRUE /* leaf vdev */
|
|
|
|
};
|
|
|
|
|
2016-12-21 18:47:15 +00:00
|
|
|
void
|
|
|
|
vdev_file_init(void)
|
|
|
|
{
|
|
|
|
vdev_file_taskq = taskq_create("z_vdev_file", MAX(boot_ncpus, 16),
|
|
|
|
minclsyspri, boot_ncpus, INT_MAX, TASKQ_DYNAMIC);
|
|
|
|
|
|
|
|
VERIFY(vdev_file_taskq);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vdev_file_fini(void)
|
|
|
|
{
|
|
|
|
taskq_destroy(vdev_file_taskq);
|
|
|
|
}
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
/*
|
|
|
|
* From userland we access disks just like files.
|
|
|
|
*/
|
|
|
|
#ifndef _KERNEL
|
|
|
|
|
|
|
|
vdev_ops_t vdev_disk_ops = {
|
|
|
|
vdev_file_open,
|
|
|
|
vdev_file_close,
|
|
|
|
vdev_default_asize,
|
|
|
|
vdev_file_io_start,
|
|
|
|
vdev_file_io_done,
|
|
|
|
NULL,
|
2017-05-13 00:28:03 +00:00
|
|
|
NULL,
|
2010-05-28 20:45:14 +00:00
|
|
|
vdev_file_hold,
|
|
|
|
vdev_file_rele,
|
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 16:30:13 +00:00
|
|
|
NULL,
|
OpenZFS 9102 - zfs should be able to initialize storage devices
PROBLEM
========
The first access to a block incurs a performance penalty on some platforms
(e.g. AWS's EBS, VMware VMDKs). Therefore we recommend that volumes are
"thick provisioned", where supported by the platform (VMware). This can
create a large delay in getting a new virtual machines up and running (or
adding storage to an existing Engine). If the thick provision step is
omitted, write performance will be suboptimal until all blocks on the LUN
have been written.
SOLUTION
=========
This feature introduces a way to 'initialize' the disks at install or in the
background to make sure we don't incur this first read penalty.
When an entire LUN is added to ZFS, we make all space available immediately,
and allow ZFS to find unallocated space and zero it out. This works with
concurrent writes to arbitrary offsets, ensuring that we don't zero out
something that has been (or is in the middle of being) written. This scheme
can also be applied to existing pools (affecting only free regions on the
vdev). Detailed design:
- new subcommand:zpool initialize [-cs] <pool> [<vdev> ...]
- start, suspend, or cancel initialization
- Creates new open-context thread for each vdev
- Thread iterates through all metaslabs in this vdev
- Each metaslab:
- select a metaslab
- load the metaslab
- mark the metaslab as being zeroed
- walk all free ranges within that metaslab and translate
them to ranges on the leaf vdev
- issue a "zeroing" I/O on the leaf vdev that corresponds to
a free range on the metaslab we're working on
- continue until all free ranges for this metaslab have been
"zeroed"
- reset/unmark the metaslab being zeroed
- if more metaslabs exist, then repeat above tasks.
- if no more metaslabs, then we're done.
- progress for the initialization is stored on-disk in the vdev’s
leaf zap object. The following information is stored:
- the last offset that has been initialized
- the state of the initialization process (i.e. active,
suspended, or canceled)
- the start time for the initialization
- progress is reported via the zpool status command and shows
information for each of the vdevs that are initializing
Porting notes:
- Added zfs_initialize_value module parameter to set the pattern
written by "zpool initialize".
- Added zfs_vdev_{initializing,removal}_{min,max}_active module options.
Authored by: George Wilson <george.wilson@delphix.com>
Reviewed by: John Wren Kennedy <john.kennedy@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: loli10K <ezomori.nozomu@gmail.com>
Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Approved by: Richard Lowe <richlowe@richlowe.net>
Signed-off-by: Tim Chase <tim@chase2k.com>
Ported-by: Tim Chase <tim@chase2k.com>
OpenZFS-issue: https://www.illumos.org/issues/9102
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/c3963210eb
Closes #8230
2018-12-19 14:54:59 +00:00
|
|
|
vdev_default_xlate,
|
2008-11-20 20:01:55 +00:00
|
|
|
VDEV_TYPE_DISK, /* name of this vdev type */
|
|
|
|
B_TRUE /* leaf vdev */
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|