2012-12-13 23:24:15 +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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
Illumos #4101, #4102, #4103, #4105, #4106
4101 metaslab_debug should allow for fine-grained control
4102 space_maps should store more information about themselves
4103 space map object blocksize should be increased
4105 removing a mirrored log device results in a leaked object
4106 asynchronously load metaslab
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Sebastien Roy <seb@delphix.com>
Approved by: Garrett D'Amore <garrett@damore.org>
Prior to this patch, space_maps were preferred solely based on the
amount of free space left in each. Unfortunately, this heuristic didn't
contain any information about the make-up of that free space, which
meant we could keep preferring and loading a highly fragmented space map
that wouldn't actually have enough contiguous space to satisfy the
allocation; then unloading that space_map and repeating the process.
This change modifies the space_map's to store additional information
about the contiguous space in the space_map, so that we can use this
information to make a better decision about which space_map to load.
This requires reallocating all space_map objects to increase their
bonus buffer size sizes enough to fit the new metadata.
The above feature can be enabled via a new feature flag introduced by
this change: com.delphix:spacemap_histogram
In addition to the above, this patch allows the space_map block size to
be increase. Currently the block size is set to be 4K in size, which has
certain implications including the following:
* 4K sector devices will not see any compression benefit
* large space_maps require more metadata on-disk
* large space_maps require more time to load (typically random reads)
Now the space_map block size can adjust as needed up to the maximum size
set via the space_map_max_blksz variable.
A bug was fixed which resulted in potentially leaking an object when
removing a mirrored log device. The previous logic for vdev_remove() did
not deal with removing top-level vdevs that are interior vdevs (i.e.
mirror) correctly. The problem would occur when removing a mirrored log
device, and result in the DTL space map object being leaked; because
top-level vdevs don't have DTL space map objects associated with them.
References:
https://www.illumos.org/issues/4101
https://www.illumos.org/issues/4102
https://www.illumos.org/issues/4103
https://www.illumos.org/issues/4105
https://www.illumos.org/issues/4106
https://github.com/illumos/illumos-gate/commit/0713e23
Porting notes:
A handful of kmem_alloc() calls were converted to kmem_zalloc(). Also,
the KM_PUSHPAGE and TQ_PUSHPAGE flags were used as necessary.
Ported-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #2488
2013-10-01 21:25:53 +00:00
|
|
|
* Copyright (c) 2013 by Delphix. All rights reserved.
|
2013-01-23 09:54:30 +00:00
|
|
|
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
|
2012-12-13 23:24:15 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef _KERNEL
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#else
|
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
|
|
|
#endif
|
|
|
|
#include <sys/debug.h>
|
|
|
|
#include <sys/fs/zfs.h>
|
|
|
|
#include <sys/inttypes.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include "zfeature_common.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set to disable all feature checks while opening pools, allowing pools with
|
|
|
|
* unsupported features to be opened. Set for testing only.
|
|
|
|
*/
|
|
|
|
boolean_t zfeature_checks_disable = B_FALSE;
|
|
|
|
|
|
|
|
zfeature_info_t spa_feature_table[SPA_FEATURES];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Valid characters for feature guids. This list is mainly for aesthetic
|
|
|
|
* purposes and could be expanded in the future. There are different allowed
|
|
|
|
* characters in the guids reverse dns portion (before the colon) and its
|
|
|
|
* short name (after the colon).
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
valid_char(char c, boolean_t after_colon)
|
|
|
|
{
|
|
|
|
return ((c >= 'a' && c <= 'z') ||
|
|
|
|
(c >= '0' && c <= '9') ||
|
|
|
|
c == (after_colon ? '_' : '.'));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Every feature guid must contain exactly one colon which separates a reverse
|
|
|
|
* dns organization name from the feature's "short" name (e.g.
|
|
|
|
* "com.company:feature_name").
|
|
|
|
*/
|
|
|
|
boolean_t
|
|
|
|
zfeature_is_valid_guid(const char *name)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
boolean_t has_colon = B_FALSE;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (name[i] != '\0') {
|
|
|
|
char c = name[i++];
|
|
|
|
if (c == ':') {
|
|
|
|
if (has_colon)
|
|
|
|
return (B_FALSE);
|
|
|
|
has_colon = B_TRUE;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!valid_char(c, has_colon))
|
|
|
|
return (B_FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (has_colon);
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean_t
|
|
|
|
zfeature_is_supported(const char *guid)
|
|
|
|
{
|
2013-10-08 17:13:05 +00:00
|
|
|
spa_feature_t i;
|
|
|
|
|
2012-12-13 23:24:15 +00:00
|
|
|
if (zfeature_checks_disable)
|
|
|
|
return (B_TRUE);
|
|
|
|
|
|
|
|
for (i = 0; i < SPA_FEATURES; i++) {
|
|
|
|
zfeature_info_t *feature = &spa_feature_table[i];
|
2013-10-08 17:13:05 +00:00
|
|
|
if (strcmp(guid, feature->fi_guid) == 0)
|
|
|
|
return (B_TRUE);
|
2012-12-13 23:24:15 +00:00
|
|
|
}
|
|
|
|
|
2013-10-08 17:13:05 +00:00
|
|
|
return (B_FALSE);
|
2012-12-13 23:24:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2013-10-08 17:13:05 +00:00
|
|
|
zfeature_lookup_name(const char *name, spa_feature_t *res)
|
2012-12-13 23:24:15 +00:00
|
|
|
{
|
2013-10-08 17:13:05 +00:00
|
|
|
spa_feature_t i;
|
2012-12-13 23:24:15 +00:00
|
|
|
|
|
|
|
for (i = 0; i < SPA_FEATURES; i++) {
|
|
|
|
zfeature_info_t *feature = &spa_feature_table[i];
|
|
|
|
if (strcmp(name, feature->fi_uname) == 0) {
|
|
|
|
if (res != NULL)
|
2013-10-08 17:13:05 +00:00
|
|
|
*res = i;
|
2012-12-13 23:24:15 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (ENOENT);
|
|
|
|
}
|
|
|
|
|
2013-12-09 18:37:51 +00:00
|
|
|
boolean_t
|
|
|
|
zfeature_depends_on(spa_feature_t fid, spa_feature_t check) {
|
|
|
|
zfeature_info_t *feature = &spa_feature_table[fid];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; feature->fi_depends[i] != SPA_FEATURE_NONE; i++) {
|
|
|
|
if (feature->fi_depends[i] == check)
|
|
|
|
return (B_TRUE);
|
|
|
|
}
|
|
|
|
return (B_FALSE);
|
|
|
|
}
|
|
|
|
|
2012-12-13 23:24:15 +00:00
|
|
|
static void
|
2013-10-08 17:13:05 +00:00
|
|
|
zfeature_register(spa_feature_t fid, const char *guid, const char *name,
|
|
|
|
const char *desc, boolean_t readonly, boolean_t mos,
|
2013-12-09 18:37:51 +00:00
|
|
|
boolean_t activate_on_enable, const spa_feature_t *deps)
|
2012-12-13 23:24:15 +00:00
|
|
|
{
|
|
|
|
zfeature_info_t *feature = &spa_feature_table[fid];
|
2013-10-08 17:13:05 +00:00
|
|
|
static spa_feature_t nodeps[] = { SPA_FEATURE_NONE };
|
2012-12-13 23:24:15 +00:00
|
|
|
|
|
|
|
ASSERT(name != NULL);
|
|
|
|
ASSERT(desc != NULL);
|
|
|
|
ASSERT(!readonly || !mos);
|
|
|
|
ASSERT3U(fid, <, SPA_FEATURES);
|
|
|
|
ASSERT(zfeature_is_valid_guid(guid));
|
|
|
|
|
|
|
|
if (deps == NULL)
|
|
|
|
deps = nodeps;
|
|
|
|
|
2013-10-08 17:13:05 +00:00
|
|
|
feature->fi_feature = fid;
|
2012-12-13 23:24:15 +00:00
|
|
|
feature->fi_guid = guid;
|
|
|
|
feature->fi_uname = name;
|
|
|
|
feature->fi_desc = desc;
|
|
|
|
feature->fi_can_readonly = readonly;
|
|
|
|
feature->fi_mos = mos;
|
2013-12-09 18:37:51 +00:00
|
|
|
feature->fi_activate_on_enable = activate_on_enable;
|
2012-12-13 23:24:15 +00:00
|
|
|
feature->fi_depends = deps;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
zpool_feature_init(void)
|
|
|
|
{
|
|
|
|
zfeature_register(SPA_FEATURE_ASYNC_DESTROY,
|
|
|
|
"com.delphix:async_destroy", "async_destroy",
|
2013-12-09 18:37:51 +00:00
|
|
|
"Destroy filesystems asynchronously.", B_TRUE, B_FALSE,
|
|
|
|
B_FALSE, NULL);
|
|
|
|
|
2012-12-23 23:57:14 +00:00
|
|
|
zfeature_register(SPA_FEATURE_EMPTY_BPOBJ,
|
|
|
|
"com.delphix:empty_bpobj", "empty_bpobj",
|
2013-12-09 18:37:51 +00:00
|
|
|
"Snapshots use less space.", B_TRUE, B_FALSE,
|
|
|
|
B_FALSE, NULL);
|
|
|
|
|
2013-01-23 09:54:30 +00:00
|
|
|
zfeature_register(SPA_FEATURE_LZ4_COMPRESS,
|
|
|
|
"org.illumos:lz4_compress", "lz4_compress",
|
2013-12-09 18:37:51 +00:00
|
|
|
"LZ4 compression algorithm support.", B_FALSE, B_FALSE,
|
|
|
|
B_FALSE, NULL);
|
|
|
|
|
Illumos #4101, #4102, #4103, #4105, #4106
4101 metaslab_debug should allow for fine-grained control
4102 space_maps should store more information about themselves
4103 space map object blocksize should be increased
4105 removing a mirrored log device results in a leaked object
4106 asynchronously load metaslab
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Sebastien Roy <seb@delphix.com>
Approved by: Garrett D'Amore <garrett@damore.org>
Prior to this patch, space_maps were preferred solely based on the
amount of free space left in each. Unfortunately, this heuristic didn't
contain any information about the make-up of that free space, which
meant we could keep preferring and loading a highly fragmented space map
that wouldn't actually have enough contiguous space to satisfy the
allocation; then unloading that space_map and repeating the process.
This change modifies the space_map's to store additional information
about the contiguous space in the space_map, so that we can use this
information to make a better decision about which space_map to load.
This requires reallocating all space_map objects to increase their
bonus buffer size sizes enough to fit the new metadata.
The above feature can be enabled via a new feature flag introduced by
this change: com.delphix:spacemap_histogram
In addition to the above, this patch allows the space_map block size to
be increase. Currently the block size is set to be 4K in size, which has
certain implications including the following:
* 4K sector devices will not see any compression benefit
* large space_maps require more metadata on-disk
* large space_maps require more time to load (typically random reads)
Now the space_map block size can adjust as needed up to the maximum size
set via the space_map_max_blksz variable.
A bug was fixed which resulted in potentially leaking an object when
removing a mirrored log device. The previous logic for vdev_remove() did
not deal with removing top-level vdevs that are interior vdevs (i.e.
mirror) correctly. The problem would occur when removing a mirrored log
device, and result in the DTL space map object being leaked; because
top-level vdevs don't have DTL space map objects associated with them.
References:
https://www.illumos.org/issues/4101
https://www.illumos.org/issues/4102
https://www.illumos.org/issues/4103
https://www.illumos.org/issues/4105
https://www.illumos.org/issues/4106
https://github.com/illumos/illumos-gate/commit/0713e23
Porting notes:
A handful of kmem_alloc() calls were converted to kmem_zalloc(). Also,
the KM_PUSHPAGE and TQ_PUSHPAGE flags were used as necessary.
Ported-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #2488
2013-10-01 21:25:53 +00:00
|
|
|
zfeature_register(SPA_FEATURE_SPACEMAP_HISTOGRAM,
|
|
|
|
"com.delphix:spacemap_histogram", "spacemap_histogram",
|
2013-12-09 18:37:51 +00:00
|
|
|
"Spacemaps maintain space histograms.", B_TRUE, B_FALSE,
|
|
|
|
B_FALSE, NULL);
|
|
|
|
|
|
|
|
zfeature_register(SPA_FEATURE_ENABLED_TXG,
|
|
|
|
"com.delphix:enabled_txg", "enabled_txg",
|
|
|
|
"Record txg at which a feature is enabled", B_TRUE, B_FALSE,
|
|
|
|
B_FALSE, NULL);
|
|
|
|
|
|
|
|
{
|
2013-12-11 22:33:41 +00:00
|
|
|
static const spa_feature_t hole_birth_deps[] = {
|
|
|
|
SPA_FEATURE_ENABLED_TXG,
|
|
|
|
SPA_FEATURE_NONE
|
|
|
|
};
|
2013-12-09 18:37:51 +00:00
|
|
|
zfeature_register(SPA_FEATURE_HOLE_BIRTH,
|
|
|
|
"com.delphix:hole_birth", "hole_birth",
|
|
|
|
"Retain hole birth txg for more precise zfs send",
|
|
|
|
B_FALSE, B_TRUE, B_TRUE, hole_birth_deps);
|
|
|
|
}
|
|
|
|
|
2013-10-08 17:13:05 +00:00
|
|
|
zfeature_register(SPA_FEATURE_EXTENSIBLE_DATASET,
|
|
|
|
"com.delphix:extensible_dataset", "extensible_dataset",
|
|
|
|
"Enhanced dataset functionality, used by other features.",
|
2013-12-09 18:37:51 +00:00
|
|
|
B_FALSE, B_FALSE, B_FALSE, NULL);
|
2013-12-11 22:33:41 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
static const spa_feature_t bookmarks_deps[] = {
|
|
|
|
SPA_FEATURE_EXTENSIBLE_DATASET,
|
|
|
|
SPA_FEATURE_NONE
|
|
|
|
};
|
|
|
|
|
|
|
|
zfeature_register(SPA_FEATURE_BOOKMARKS,
|
|
|
|
"com.delphix:bookmarks", "bookmarks",
|
|
|
|
"\"zfs bookmark\" command",
|
|
|
|
B_TRUE, B_FALSE, B_FALSE, bookmarks_deps);
|
|
|
|
}
|
2014-06-05 21:19:08 +00:00
|
|
|
|
|
|
|
zfeature_register(SPA_FEATURE_EMBEDDED_DATA,
|
|
|
|
"com.delphix:embedded_data", "embedded_data",
|
|
|
|
"Blocks which compress very well use even less space.",
|
|
|
|
B_FALSE, B_TRUE, B_TRUE, NULL);
|
2012-12-13 23:24:15 +00:00
|
|
|
}
|