spa_misc.c (208047) | spa_misc.c (209962) |
---|---|
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 --- 5 unchanged lines hidden (view full) --- 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 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/* | 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 --- 5 unchanged lines hidden (view full) --- 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 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 2008 Sun Microsystems, Inc. All rights reserved. | 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. |
23 * Use is subject to license terms. 24 */ 25 26#include <sys/zfs_context.h> 27#include <sys/spa_impl.h> 28#include <sys/zio.h> 29#include <sys/zio_checksum.h> 30#include <sys/zio_compress.h> --- 194 unchanged lines hidden (view full) --- 225int spa_max_replication_override = SPA_DVAS_PER_BP; 226 227static kmutex_t spa_spare_lock; 228static avl_tree_t spa_spare_avl; 229static kmutex_t spa_l2cache_lock; 230static avl_tree_t spa_l2cache_avl; 231 232kmem_cache_t *spa_buffer_pool; | 23 * Use is subject to license terms. 24 */ 25 26#include <sys/zfs_context.h> 27#include <sys/spa_impl.h> 28#include <sys/zio.h> 29#include <sys/zio_checksum.h> 30#include <sys/zio_compress.h> --- 194 unchanged lines hidden (view full) --- 225int spa_max_replication_override = SPA_DVAS_PER_BP; 226 227static kmutex_t spa_spare_lock; 228static avl_tree_t spa_spare_avl; 229static kmutex_t spa_l2cache_lock; 230static avl_tree_t spa_l2cache_avl; 231 232kmem_cache_t *spa_buffer_pool; |
233int spa_mode; | 233int spa_mode_global; |
234 235#ifdef ZFS_DEBUG 236/* Everything except dprintf is on by default in debug builds */ 237int zfs_flags = ~ZFS_DEBUG_DPRINTF; 238#else 239int zfs_flags = 0; 240#endif 241 --- 182 unchanged lines hidden (view full) --- 424 spa_t *spa; 425 spa_config_dirent_t *dp; 426 427 ASSERT(MUTEX_HELD(&spa_namespace_lock)); 428 429 spa = kmem_zalloc(sizeof (spa_t), KM_SLEEP); 430 431 mutex_init(&spa->spa_async_lock, NULL, MUTEX_DEFAULT, NULL); | 234 235#ifdef ZFS_DEBUG 236/* Everything except dprintf is on by default in debug builds */ 237int zfs_flags = ~ZFS_DEBUG_DPRINTF; 238#else 239int zfs_flags = 0; 240#endif 241 --- 182 unchanged lines hidden (view full) --- 424 spa_t *spa; 425 spa_config_dirent_t *dp; 426 427 ASSERT(MUTEX_HELD(&spa_namespace_lock)); 428 429 spa = kmem_zalloc(sizeof (spa_t), KM_SLEEP); 430 431 mutex_init(&spa->spa_async_lock, NULL, MUTEX_DEFAULT, NULL); |
432 mutex_init(&spa->spa_async_root_lock, NULL, MUTEX_DEFAULT, NULL); | |
433 mutex_init(&spa->spa_scrub_lock, NULL, MUTEX_DEFAULT, NULL); 434 mutex_init(&spa->spa_errlog_lock, NULL, MUTEX_DEFAULT, NULL); 435 mutex_init(&spa->spa_errlist_lock, NULL, MUTEX_DEFAULT, NULL); 436 mutex_init(&spa->spa_sync_bplist.bpl_lock, NULL, MUTEX_DEFAULT, NULL); 437 mutex_init(&spa->spa_history_lock, NULL, MUTEX_DEFAULT, NULL); 438 mutex_init(&spa->spa_props_lock, NULL, MUTEX_DEFAULT, NULL); 439 440 cv_init(&spa->spa_async_cv, NULL, CV_DEFAULT, NULL); | 432 mutex_init(&spa->spa_scrub_lock, NULL, MUTEX_DEFAULT, NULL); 433 mutex_init(&spa->spa_errlog_lock, NULL, MUTEX_DEFAULT, NULL); 434 mutex_init(&spa->spa_errlist_lock, NULL, MUTEX_DEFAULT, NULL); 435 mutex_init(&spa->spa_sync_bplist.bpl_lock, NULL, MUTEX_DEFAULT, NULL); 436 mutex_init(&spa->spa_history_lock, NULL, MUTEX_DEFAULT, NULL); 437 mutex_init(&spa->spa_props_lock, NULL, MUTEX_DEFAULT, NULL); 438 439 cv_init(&spa->spa_async_cv, NULL, CV_DEFAULT, NULL); |
441 cv_init(&spa->spa_async_root_cv, NULL, CV_DEFAULT, NULL); | |
442 cv_init(&spa->spa_scrub_io_cv, NULL, CV_DEFAULT, NULL); 443 cv_init(&spa->spa_suspend_cv, NULL, CV_DEFAULT, NULL); 444 445 (void) strlcpy(spa->spa_name, name, sizeof (spa->spa_name)); 446 spa->spa_state = POOL_STATE_UNINITIALIZED; 447 spa->spa_freeze_txg = UINT64_MAX; 448 spa->spa_final_txg = UINT64_MAX; 449 --- 57 unchanged lines hidden (view full) --- 507 508 spa_config_set(spa, NULL); 509 510 refcount_destroy(&spa->spa_refcount); 511 512 spa_config_lock_destroy(spa); 513 514 cv_destroy(&spa->spa_async_cv); | 440 cv_init(&spa->spa_scrub_io_cv, NULL, CV_DEFAULT, NULL); 441 cv_init(&spa->spa_suspend_cv, NULL, CV_DEFAULT, NULL); 442 443 (void) strlcpy(spa->spa_name, name, sizeof (spa->spa_name)); 444 spa->spa_state = POOL_STATE_UNINITIALIZED; 445 spa->spa_freeze_txg = UINT64_MAX; 446 spa->spa_final_txg = UINT64_MAX; 447 --- 57 unchanged lines hidden (view full) --- 505 506 spa_config_set(spa, NULL); 507 508 refcount_destroy(&spa->spa_refcount); 509 510 spa_config_lock_destroy(spa); 511 512 cv_destroy(&spa->spa_async_cv); |
515 cv_destroy(&spa->spa_async_root_cv); | |
516 cv_destroy(&spa->spa_scrub_io_cv); 517 cv_destroy(&spa->spa_suspend_cv); 518 519 mutex_destroy(&spa->spa_async_lock); | 513 cv_destroy(&spa->spa_scrub_io_cv); 514 cv_destroy(&spa->spa_suspend_cv); 515 516 mutex_destroy(&spa->spa_async_lock); |
520 mutex_destroy(&spa->spa_async_root_lock); | |
521 mutex_destroy(&spa->spa_scrub_lock); 522 mutex_destroy(&spa->spa_errlog_lock); 523 mutex_destroy(&spa->spa_errlist_lock); 524 mutex_destroy(&spa->spa_sync_bplist.bpl_lock); 525 mutex_destroy(&spa->spa_history_lock); 526 mutex_destroy(&spa->spa_props_lock); 527 mutex_destroy(&spa->spa_suspend_lock); 528 --- 350 unchanged lines hidden (view full) --- 879 * Note: this txg_wait_synced() is important because it ensures 880 * that there won't be more than one config change per txg. 881 * This allows us to use the txg as the generation number. 882 */ 883 if (error == 0) 884 txg_wait_synced(spa->spa_dsl_pool, txg); 885 886 if (vd != NULL) { | 517 mutex_destroy(&spa->spa_scrub_lock); 518 mutex_destroy(&spa->spa_errlog_lock); 519 mutex_destroy(&spa->spa_errlist_lock); 520 mutex_destroy(&spa->spa_sync_bplist.bpl_lock); 521 mutex_destroy(&spa->spa_history_lock); 522 mutex_destroy(&spa->spa_props_lock); 523 mutex_destroy(&spa->spa_suspend_lock); 524 --- 350 unchanged lines hidden (view full) --- 875 * Note: this txg_wait_synced() is important because it ensures 876 * that there won't be more than one config change per txg. 877 * This allows us to use the txg as the generation number. 878 */ 879 if (error == 0) 880 txg_wait_synced(spa->spa_dsl_pool, txg); 881 882 if (vd != NULL) { |
887 ASSERT(!vd->vdev_detached || vd->vdev_dtl.smo_object == 0); | 883 ASSERT(!vd->vdev_detached || vd->vdev_dtl_smo.smo_object == 0); 884 spa_config_enter(spa, SCL_ALL, spa, RW_WRITER); |
888 vdev_free(vd); | 885 vdev_free(vd); |
886 spa_config_exit(spa, SCL_ALL, spa); |
|
889 } 890 891 /* 892 * If the config changed, update the config cache. 893 */ 894 if (config_changed) 895 spa_config_sync(spa, B_FALSE, B_TRUE); 896 --- 14 unchanged lines hidden (view full) --- 911int 912spa_vdev_state_exit(spa_t *spa, vdev_t *vd, int error) 913{ 914 if (vd != NULL) 915 vdev_state_dirty(vd->vdev_top); 916 917 spa_config_exit(spa, SCL_STATE_ALL, spa); 918 | 887 } 888 889 /* 890 * If the config changed, update the config cache. 891 */ 892 if (config_changed) 893 spa_config_sync(spa, B_FALSE, B_TRUE); 894 --- 14 unchanged lines hidden (view full) --- 909int 910spa_vdev_state_exit(spa_t *spa, vdev_t *vd, int error) 911{ 912 if (vd != NULL) 913 vdev_state_dirty(vd->vdev_top); 914 915 spa_config_exit(spa, SCL_STATE_ALL, spa); 916 |
917 /* 918 * If anything changed, wait for it to sync. This ensures that, 919 * from the system administrator's perspective, zpool(1M) commands 920 * are synchronous. This is important for things like zpool offline: 921 * when the command completes, you expect no further I/O from ZFS. 922 */ 923 if (vd != NULL) 924 txg_wait_synced(spa->spa_dsl_pool, 0); 925 |
|
919 return (error); 920} 921 922/* 923 * ========================================================================== 924 * Miscellaneous functions 925 * ========================================================================== 926 */ --- 186 unchanged lines hidden (view full) --- 1113 va_list adx; 1114 1115 va_start(adx, fmt); 1116 vcmn_err(zfs_recover ? CE_WARN : CE_PANIC, fmt, adx); 1117 va_end(adx); 1118} 1119 1120/* | 926 return (error); 927} 928 929/* 930 * ========================================================================== 931 * Miscellaneous functions 932 * ========================================================================== 933 */ --- 186 unchanged lines hidden (view full) --- 1120 va_list adx; 1121 1122 va_start(adx, fmt); 1123 vcmn_err(zfs_recover ? CE_WARN : CE_PANIC, fmt, adx); 1124 va_end(adx); 1125} 1126 1127/* |
1128 * This is a stripped-down version of strtoull, suitable only for converting 1129 * lowercase hexidecimal numbers that don't overflow. 1130 */ 1131uint64_t 1132zfs_strtonum(const char *str, char **nptr) 1133{ 1134 uint64_t val = 0; 1135 char c; 1136 int digit; 1137 1138 while ((c = *str) != '\0') { 1139 if (c >= '0' && c <= '9') 1140 digit = c - '0'; 1141 else if (c >= 'a' && c <= 'f') 1142 digit = 10 + c - 'a'; 1143 else 1144 break; 1145 1146 val *= 16; 1147 val += digit; 1148 1149 str++; 1150 } 1151 1152 if (nptr) 1153 *nptr = (char *)str; 1154 1155 return (val); 1156} 1157 1158/* |
|
1121 * ========================================================================== 1122 * Accessor functions 1123 * ========================================================================== 1124 */ 1125 1126boolean_t 1127spa_shutting_down(spa_t *spa) 1128{ --- 221 unchanged lines hidden (view full) --- 1350 offsetof(spa_t, spa_avl)); 1351 1352 avl_create(&spa_spare_avl, spa_spare_compare, sizeof (spa_aux_t), 1353 offsetof(spa_aux_t, aux_avl)); 1354 1355 avl_create(&spa_l2cache_avl, spa_l2cache_compare, sizeof (spa_aux_t), 1356 offsetof(spa_aux_t, aux_avl)); 1357 | 1159 * ========================================================================== 1160 * Accessor functions 1161 * ========================================================================== 1162 */ 1163 1164boolean_t 1165spa_shutting_down(spa_t *spa) 1166{ --- 221 unchanged lines hidden (view full) --- 1388 offsetof(spa_t, spa_avl)); 1389 1390 avl_create(&spa_spare_avl, spa_spare_compare, sizeof (spa_aux_t), 1391 offsetof(spa_aux_t, aux_avl)); 1392 1393 avl_create(&spa_l2cache_avl, spa_l2cache_compare, sizeof (spa_aux_t), 1394 offsetof(spa_aux_t, aux_avl)); 1395 |
1358 spa_mode = mode; | 1396 spa_mode_global = mode; |
1359 1360 refcount_sysinit(); 1361 unique_init(); 1362 zio_init(); 1363 dmu_init(); 1364 zil_init(); 1365 vdev_cache_stat_init(); 1366 zfs_prop_init(); --- 40 unchanged lines hidden (view full) --- 1407/* 1408 * Return whether this pool is the root pool. 1409 */ 1410boolean_t 1411spa_is_root(spa_t *spa) 1412{ 1413 return (spa->spa_is_root); 1414} | 1397 1398 refcount_sysinit(); 1399 unique_init(); 1400 zio_init(); 1401 dmu_init(); 1402 zil_init(); 1403 vdev_cache_stat_init(); 1404 zfs_prop_init(); --- 40 unchanged lines hidden (view full) --- 1445/* 1446 * Return whether this pool is the root pool. 1447 */ 1448boolean_t 1449spa_is_root(spa_t *spa) 1450{ 1451 return (spa->spa_is_root); 1452} |
1453 1454boolean_t 1455spa_writeable(spa_t *spa) 1456{ 1457 return (!!(spa->spa_mode & FWRITE)); 1458} 1459 1460int 1461spa_mode(spa_t *spa) 1462{ 1463 return (spa->spa_mode); 1464} |
|