spa_misc.c (228103) | spa_misc.c (236884) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 6 unchanged lines hidden (view full) --- 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21/* 22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 6 unchanged lines hidden (view full) --- 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21/* 22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
23 * Copyright (c) 2011 by Delphix. All rights reserved. | 23 * Copyright (c) 2012 by Delphix. All rights reserved. |
24 * Copyright 2011 Nexenta Systems, Inc. All rights reserved. 25 */ 26 27#include <sys/zfs_context.h> 28#include <sys/spa_impl.h> 29#include <sys/zio.h> 30#include <sys/zio_checksum.h> 31#include <sys/zio_compress.h> --- 11 unchanged lines hidden (view full) --- 43#include <sys/dsl_dir.h> 44#include <sys/dsl_prop.h> 45#include <sys/dsl_scan.h> 46#include <sys/fs/zfs.h> 47#include <sys/metaslab_impl.h> 48#include <sys/arc.h> 49#include <sys/ddt.h> 50#include "zfs_prop.h" | 24 * Copyright 2011 Nexenta Systems, Inc. All rights reserved. 25 */ 26 27#include <sys/zfs_context.h> 28#include <sys/spa_impl.h> 29#include <sys/zio.h> 30#include <sys/zio_checksum.h> 31#include <sys/zio_compress.h> --- 11 unchanged lines hidden (view full) --- 43#include <sys/dsl_dir.h> 44#include <sys/dsl_prop.h> 45#include <sys/dsl_scan.h> 46#include <sys/fs/zfs.h> 47#include <sys/metaslab_impl.h> 48#include <sys/arc.h> 49#include <sys/ddt.h> 50#include "zfs_prop.h" |
51#include "zfeature_common.h" |
|
51 52/* 53 * SPA locking 54 * 55 * There are four basic locks for managing spa_t structures: 56 * 57 * spa_namespace_lock (global mutex) 58 * --- 152 unchanged lines hidden (view full) --- 211 * spa_vdev_exit() Release the config lock, wait for all I/O 212 * to complete, sync the updated configs to the 213 * cache, and release the namespace lock. 214 * 215 * vdev state is protected by spa_vdev_state_enter() / spa_vdev_state_exit(). 216 * Like spa_vdev_enter/exit, these are convenience wrappers -- the actual 217 * locking is, always, based on spa_namespace_lock and spa_config_lock[]. 218 * | 52 53/* 54 * SPA locking 55 * 56 * There are four basic locks for managing spa_t structures: 57 * 58 * spa_namespace_lock (global mutex) 59 * --- 152 unchanged lines hidden (view full) --- 212 * spa_vdev_exit() Release the config lock, wait for all I/O 213 * to complete, sync the updated configs to the 214 * cache, and release the namespace lock. 215 * 216 * vdev state is protected by spa_vdev_state_enter() / spa_vdev_state_exit(). 217 * Like spa_vdev_enter/exit, these are convenience wrappers -- the actual 218 * locking is, always, based on spa_namespace_lock and spa_config_lock[]. 219 * |
219 * spa_rename() is also implemented within this file since is requires | 220 * spa_rename() is also implemented within this file since it requires |
220 * manipulation of the namespace. 221 */ 222 223static avl_tree_t spa_namespace_avl; 224kmutex_t spa_namespace_lock; 225static kcondvar_t spa_namespace_cv; 226static int spa_active_count; 227int spa_max_replication_override = SPA_DVAS_PER_BP; --- 254 unchanged lines hidden (view full) --- 482 483 dp = kmem_zalloc(sizeof (spa_config_dirent_t), KM_SLEEP); 484 dp->scd_path = altroot ? NULL : spa_strdup(spa_config_path); 485 list_insert_head(&spa->spa_config_list, dp); 486 487 VERIFY(nvlist_alloc(&spa->spa_load_info, NV_UNIQUE_NAME, 488 KM_SLEEP) == 0); 489 | 221 * manipulation of the namespace. 222 */ 223 224static avl_tree_t spa_namespace_avl; 225kmutex_t spa_namespace_lock; 226static kcondvar_t spa_namespace_cv; 227static int spa_active_count; 228int spa_max_replication_override = SPA_DVAS_PER_BP; --- 254 unchanged lines hidden (view full) --- 483 484 dp = kmem_zalloc(sizeof (spa_config_dirent_t), KM_SLEEP); 485 dp->scd_path = altroot ? NULL : spa_strdup(spa_config_path); 486 list_insert_head(&spa->spa_config_list, dp); 487 488 VERIFY(nvlist_alloc(&spa->spa_load_info, NV_UNIQUE_NAME, 489 KM_SLEEP) == 0); 490 |
490 if (config != NULL) | 491 if (config != NULL) { 492 nvlist_t *features; 493 494 if (nvlist_lookup_nvlist(config, ZPOOL_CONFIG_FEATURES_FOR_READ, 495 &features) == 0) { 496 VERIFY(nvlist_dup(features, &spa->spa_label_features, 497 0) == 0); 498 } 499 |
491 VERIFY(nvlist_dup(config, &spa->spa_config, 0) == 0); | 500 VERIFY(nvlist_dup(config, &spa->spa_config, 0) == 0); |
501 } |
|
492 | 502 |
503 if (spa->spa_label_features == NULL) { 504 VERIFY(nvlist_alloc(&spa->spa_label_features, NV_UNIQUE_NAME, 505 KM_SLEEP) == 0); 506 } 507 |
|
493 return (spa); 494} 495 496/* 497 * Removes a spa_t from the namespace, freeing up any memory used. Requires 498 * spa_namespace_lock. This is called only after the spa_t has been closed and 499 * deactivated. 500 */ --- 19 unchanged lines hidden (view full) --- 520 list_remove(&spa->spa_config_list, dp); 521 if (dp->scd_path != NULL) 522 spa_strfree(dp->scd_path); 523 kmem_free(dp, sizeof (spa_config_dirent_t)); 524 } 525 526 list_destroy(&spa->spa_config_list); 527 | 508 return (spa); 509} 510 511/* 512 * Removes a spa_t from the namespace, freeing up any memory used. Requires 513 * spa_namespace_lock. This is called only after the spa_t has been closed and 514 * deactivated. 515 */ --- 19 unchanged lines hidden (view full) --- 535 list_remove(&spa->spa_config_list, dp); 536 if (dp->scd_path != NULL) 537 spa_strfree(dp->scd_path); 538 kmem_free(dp, sizeof (spa_config_dirent_t)); 539 } 540 541 list_destroy(&spa->spa_config_list); 542 |
543 nvlist_free(spa->spa_label_features); |
|
528 nvlist_free(spa->spa_load_info); 529 spa_config_set(spa, NULL); 530 531 refcount_destroy(&spa->spa_refcount); 532 533 spa_config_lock_destroy(spa); 534 535 for (int t = 0; t < TXG_SIZE; t++) --- 492 unchanged lines hidden (view full) --- 1028} 1029 1030/* 1031 * ========================================================================== 1032 * Miscellaneous functions 1033 * ========================================================================== 1034 */ 1035 | 544 nvlist_free(spa->spa_load_info); 545 spa_config_set(spa, NULL); 546 547 refcount_destroy(&spa->spa_refcount); 548 549 spa_config_lock_destroy(spa); 550 551 for (int t = 0; t < TXG_SIZE; t++) --- 492 unchanged lines hidden (view full) --- 1044} 1045 1046/* 1047 * ========================================================================== 1048 * Miscellaneous functions 1049 * ========================================================================== 1050 */ 1051 |
1052void 1053spa_activate_mos_feature(spa_t *spa, const char *feature) 1054{ 1055 (void) nvlist_add_boolean(spa->spa_label_features, feature); 1056 vdev_config_dirty(spa->spa_root_vdev); 1057} 1058 1059void 1060spa_deactivate_mos_feature(spa_t *spa, const char *feature) 1061{ 1062 (void) nvlist_remove_all(spa->spa_label_features, feature); 1063 vdev_config_dirty(spa->spa_root_vdev); 1064} 1065 |
|
1036/* 1037 * Rename a spa_t. 1038 */ 1039int 1040spa_rename(const char *name, const char *newname) 1041{ 1042 spa_t *spa; 1043 int err; --- 134 unchanged lines hidden (view full) --- 1178 } 1179 1180 return (guid); 1181} 1182 1183void 1184sprintf_blkptr(char *buf, const blkptr_t *bp) 1185{ | 1066/* 1067 * Rename a spa_t. 1068 */ 1069int 1070spa_rename(const char *name, const char *newname) 1071{ 1072 spa_t *spa; 1073 int err; --- 134 unchanged lines hidden (view full) --- 1208 } 1209 1210 return (guid); 1211} 1212 1213void 1214sprintf_blkptr(char *buf, const blkptr_t *bp) 1215{ |
1186 char *type = NULL; | 1216 char type[256]; |
1187 char *checksum = NULL; 1188 char *compress = NULL; 1189 1190 if (bp != NULL) { | 1217 char *checksum = NULL; 1218 char *compress = NULL; 1219 1220 if (bp != NULL) { |
1191 type = dmu_ot[BP_GET_TYPE(bp)].ot_name; | 1221 if (BP_GET_TYPE(bp) & DMU_OT_NEWTYPE) { 1222 dmu_object_byteswap_t bswap = 1223 DMU_OT_BYTESWAP(BP_GET_TYPE(bp)); 1224 (void) snprintf(type, sizeof (type), "bswap %s %s", 1225 DMU_OT_IS_METADATA(BP_GET_TYPE(bp)) ? 1226 "metadata" : "data", 1227 dmu_ot_byteswap[bswap].ob_name); 1228 } else { 1229 (void) strlcpy(type, dmu_ot[BP_GET_TYPE(bp)].ot_name, 1230 sizeof (type)); 1231 } |
1192 checksum = zio_checksum_table[BP_GET_CHECKSUM(bp)].ci_name; 1193 compress = zio_compress_table[BP_GET_COMPRESS(bp)].ci_name; 1194 } 1195 1196 SPRINTF_BLKPTR(snprintf, ' ', buf, bp, type, checksum, compress); 1197} 1198 1199void --- 65 unchanged lines hidden (view full) --- 1265} 1266 1267dsl_pool_t * 1268spa_get_dsl(spa_t *spa) 1269{ 1270 return (spa->spa_dsl_pool); 1271} 1272 | 1232 checksum = zio_checksum_table[BP_GET_CHECKSUM(bp)].ci_name; 1233 compress = zio_compress_table[BP_GET_COMPRESS(bp)].ci_name; 1234 } 1235 1236 SPRINTF_BLKPTR(snprintf, ' ', buf, bp, type, checksum, compress); 1237} 1238 1239void --- 65 unchanged lines hidden (view full) --- 1305} 1306 1307dsl_pool_t * 1308spa_get_dsl(spa_t *spa) 1309{ 1310 return (spa->spa_dsl_pool); 1311} 1312 |
1313boolean_t 1314spa_is_initializing(spa_t *spa) 1315{ 1316 return (spa->spa_is_initializing); 1317} 1318 |
|
1273blkptr_t * 1274spa_get_rootblkptr(spa_t *spa) 1275{ 1276 return (&spa->spa_ubsync.ub_rootbp); 1277} 1278 1279void 1280spa_set_rootblkptr(spa_t *spa, const blkptr_t *bp) --- 267 unchanged lines hidden (view full) --- 1548 refcount_sysinit(); 1549 unique_init(); 1550 zio_init(); 1551 dmu_init(); 1552 zil_init(); 1553 vdev_cache_stat_init(); 1554 zfs_prop_init(); 1555 zpool_prop_init(); | 1319blkptr_t * 1320spa_get_rootblkptr(spa_t *spa) 1321{ 1322 return (&spa->spa_ubsync.ub_rootbp); 1323} 1324 1325void 1326spa_set_rootblkptr(spa_t *spa, const blkptr_t *bp) --- 267 unchanged lines hidden (view full) --- 1594 refcount_sysinit(); 1595 unique_init(); 1596 zio_init(); 1597 dmu_init(); 1598 zil_init(); 1599 vdev_cache_stat_init(); 1600 zfs_prop_init(); 1601 zpool_prop_init(); |
1602 zpool_feature_init(); |
|
1556 spa_config_load(); 1557 l2arc_start(); 1558} 1559 1560void 1561spa_fini(void) 1562{ 1563 l2arc_stop(); --- 132 unchanged lines hidden --- | 1603 spa_config_load(); 1604 l2arc_start(); 1605} 1606 1607void 1608spa_fini(void) 1609{ 1610 l2arc_stop(); --- 132 unchanged lines hidden --- |