mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-24 19:28:53 +03:00
Update core ZFS code from build 121 to build 141.
This commit is contained in:
+76
-12
@@ -20,8 +20,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <sys/spa.h>
|
||||
@@ -75,7 +74,6 @@ spa_config_load(void)
|
||||
void *buf = NULL;
|
||||
nvlist_t *nvlist, *child;
|
||||
nvpair_t *nvpair;
|
||||
spa_t *spa;
|
||||
char *pathname;
|
||||
struct _buf *file;
|
||||
uint64_t fsize;
|
||||
@@ -119,7 +117,6 @@ spa_config_load(void)
|
||||
mutex_enter(&spa_namespace_lock);
|
||||
nvpair = NULL;
|
||||
while ((nvpair = nvlist_next_nvpair(nvlist, nvpair)) != NULL) {
|
||||
|
||||
if (nvpair_type(nvpair) != DATA_TYPE_NVLIST)
|
||||
continue;
|
||||
|
||||
@@ -127,13 +124,7 @@ spa_config_load(void)
|
||||
|
||||
if (spa_lookup(nvpair_name(nvpair)) != NULL)
|
||||
continue;
|
||||
spa = spa_add(nvpair_name(nvpair), NULL);
|
||||
|
||||
/*
|
||||
* We blindly duplicate the configuration here. If it's
|
||||
* invalid, we will catch it when the pool is first opened.
|
||||
*/
|
||||
VERIFY(nvlist_dup(child, &spa->spa_config, 0) == 0);
|
||||
(void) spa_add(nvpair_name(nvpair), child, NULL);
|
||||
}
|
||||
mutex_exit(&spa_namespace_lock);
|
||||
|
||||
@@ -313,6 +304,24 @@ spa_config_set(spa_t *spa, nvlist_t *config)
|
||||
mutex_exit(&spa->spa_props_lock);
|
||||
}
|
||||
|
||||
/* Add discovered rewind info, if any to the provided nvlist */
|
||||
void
|
||||
spa_rewind_data_to_nvlist(spa_t *spa, nvlist_t *tonvl)
|
||||
{
|
||||
int64_t loss = 0;
|
||||
|
||||
if (tonvl == NULL || spa->spa_load_txg == 0)
|
||||
return;
|
||||
|
||||
VERIFY(nvlist_add_uint64(tonvl, ZPOOL_CONFIG_LOAD_TIME,
|
||||
spa->spa_load_txg_ts) == 0);
|
||||
if (spa->spa_last_ubsync_txg)
|
||||
loss = spa->spa_last_ubsync_txg_ts - spa->spa_load_txg_ts;
|
||||
VERIFY(nvlist_add_int64(tonvl, ZPOOL_CONFIG_REWIND_TIME, loss) == 0);
|
||||
VERIFY(nvlist_add_uint64(tonvl, ZPOOL_CONFIG_LOAD_DATA_ERRORS,
|
||||
spa->spa_load_data_errors) == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generate the pool's configuration based on the current in-core state.
|
||||
* We infer whether to generate a complete config or just one top-level config
|
||||
@@ -325,6 +334,7 @@ spa_config_generate(spa_t *spa, vdev_t *vd, uint64_t txg, int getstats)
|
||||
vdev_t *rvd = spa->spa_root_vdev;
|
||||
unsigned long hostid = 0;
|
||||
boolean_t locked = B_FALSE;
|
||||
uint64_t split_guid;
|
||||
|
||||
if (vd == NULL) {
|
||||
vd = rvd;
|
||||
@@ -381,12 +391,66 @@ spa_config_generate(spa_t *spa, vdev_t *vd, uint64_t txg, int getstats)
|
||||
VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_IS_LOG,
|
||||
1ULL) == 0);
|
||||
vd = vd->vdev_top; /* label contains top config */
|
||||
} else {
|
||||
/*
|
||||
* Only add the (potentially large) split information
|
||||
* in the mos config, and not in the vdev labels
|
||||
*/
|
||||
if (spa->spa_config_splitting != NULL)
|
||||
VERIFY(nvlist_add_nvlist(config, ZPOOL_CONFIG_SPLIT,
|
||||
spa->spa_config_splitting) == 0);
|
||||
}
|
||||
|
||||
nvroot = vdev_config_generate(spa, vd, getstats, B_FALSE, B_FALSE);
|
||||
/*
|
||||
* Add the top-level config. We even add this on pools which
|
||||
* don't support holes in the namespace as older pools will
|
||||
* just ignore it.
|
||||
*/
|
||||
vdev_top_config_generate(spa, config);
|
||||
|
||||
/*
|
||||
* If we're splitting, record the original pool's guid.
|
||||
*/
|
||||
if (spa->spa_config_splitting != NULL &&
|
||||
nvlist_lookup_uint64(spa->spa_config_splitting,
|
||||
ZPOOL_CONFIG_SPLIT_GUID, &split_guid) == 0) {
|
||||
VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_SPLIT_GUID,
|
||||
split_guid) == 0);
|
||||
}
|
||||
|
||||
nvroot = vdev_config_generate(spa, vd, getstats, 0);
|
||||
VERIFY(nvlist_add_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, nvroot) == 0);
|
||||
nvlist_free(nvroot);
|
||||
|
||||
if (getstats && spa_load_state(spa) == SPA_LOAD_NONE) {
|
||||
ddt_histogram_t *ddh;
|
||||
ddt_stat_t *dds;
|
||||
ddt_object_t *ddo;
|
||||
|
||||
ddh = kmem_zalloc(sizeof (ddt_histogram_t), KM_SLEEP);
|
||||
ddt_get_dedup_histogram(spa, ddh);
|
||||
VERIFY(nvlist_add_uint64_array(config,
|
||||
ZPOOL_CONFIG_DDT_HISTOGRAM,
|
||||
(uint64_t *)ddh, sizeof (*ddh) / sizeof (uint64_t)) == 0);
|
||||
kmem_free(ddh, sizeof (ddt_histogram_t));
|
||||
|
||||
ddo = kmem_zalloc(sizeof (ddt_object_t), KM_SLEEP);
|
||||
ddt_get_dedup_object_stats(spa, ddo);
|
||||
VERIFY(nvlist_add_uint64_array(config,
|
||||
ZPOOL_CONFIG_DDT_OBJ_STATS,
|
||||
(uint64_t *)ddo, sizeof (*ddo) / sizeof (uint64_t)) == 0);
|
||||
kmem_free(ddo, sizeof (ddt_object_t));
|
||||
|
||||
dds = kmem_zalloc(sizeof (ddt_stat_t), KM_SLEEP);
|
||||
ddt_get_dedup_stats(spa, dds);
|
||||
VERIFY(nvlist_add_uint64_array(config,
|
||||
ZPOOL_CONFIG_DDT_STATS,
|
||||
(uint64_t *)dds, sizeof (*dds) / sizeof (uint64_t)) == 0);
|
||||
kmem_free(dds, sizeof (ddt_stat_t));
|
||||
}
|
||||
|
||||
spa_rewind_data_to_nvlist(spa, config);
|
||||
|
||||
if (locked)
|
||||
spa_config_exit(spa, SCL_CONFIG | SCL_STATE, FTAG);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user