vdev.c (339106) | vdev.c (339111) |
---|---|
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 --- 37 unchanged lines hidden (view full) --- 46#include <sys/zio.h> 47#include <sys/zap.h> 48#include <sys/fs/zfs.h> 49#include <sys/arc.h> 50#include <sys/zil.h> 51#include <sys/dsl_scan.h> 52#include <sys/abd.h> 53#include <sys/trim_map.h> | 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 --- 37 unchanged lines hidden (view full) --- 46#include <sys/zio.h> 47#include <sys/zap.h> 48#include <sys/fs/zfs.h> 49#include <sys/arc.h> 50#include <sys/zil.h> 51#include <sys/dsl_scan.h> 52#include <sys/abd.h> 53#include <sys/trim_map.h> |
54#include <sys/vdev_initialize.h> |
|
54 55SYSCTL_DECL(_vfs_zfs); 56SYSCTL_NODE(_vfs_zfs, OID_AUTO, vdev, CTLFLAG_RW, 0, "ZFS VDEV"); 57 58/* 59 * Virtual device management. 60 */ 61 --- 222 unchanged lines hidden (view full) --- 284 285 for (opspp = vdev_ops_table; (ops = *opspp) != NULL; opspp++) 286 if (strcmp(ops->vdev_op_type, type) == 0) 287 break; 288 289 return (ops); 290} 291 | 55 56SYSCTL_DECL(_vfs_zfs); 57SYSCTL_NODE(_vfs_zfs, OID_AUTO, vdev, CTLFLAG_RW, 0, "ZFS VDEV"); 58 59/* 60 * Virtual device management. 61 */ 62 --- 222 unchanged lines hidden (view full) --- 285 286 for (opspp = vdev_ops_table; (ops = *opspp) != NULL; opspp++) 287 if (strcmp(ops->vdev_op_type, type) == 0) 288 break; 289 290 return (ops); 291} 292 |
293/* ARGSUSED */ 294void 295vdev_default_xlate(vdev_t *vd, const range_seg_t *in, range_seg_t *res) 296{ 297 res->rs_start = in->rs_start; 298 res->rs_end = in->rs_end; 299} 300 |
|
292/* 293 * Default asize function: return the MAX of psize with the asize of 294 * all children. This is what's used by anything other than RAID-Z. 295 */ 296uint64_t 297vdev_default_asize(vdev_t *vd, uint64_t psize) 298{ 299 uint64_t asize = P2ROUNDUP(psize, 1ULL << vd->vdev_top->vdev_ashift); --- 255 unchanged lines hidden (view full) --- 555 mutex_init(&vd->vdev_obsolete_lock, NULL, MUTEX_DEFAULT, NULL); 556 vd->vdev_obsolete_segments = range_tree_create(NULL, NULL); 557 558 mutex_init(&vd->vdev_dtl_lock, NULL, MUTEX_DEFAULT, NULL); 559 mutex_init(&vd->vdev_stat_lock, NULL, MUTEX_DEFAULT, NULL); 560 mutex_init(&vd->vdev_probe_lock, NULL, MUTEX_DEFAULT, NULL); 561 mutex_init(&vd->vdev_queue_lock, NULL, MUTEX_DEFAULT, NULL); 562 mutex_init(&vd->vdev_scan_io_queue_lock, NULL, MUTEX_DEFAULT, NULL); | 301/* 302 * Default asize function: return the MAX of psize with the asize of 303 * all children. This is what's used by anything other than RAID-Z. 304 */ 305uint64_t 306vdev_default_asize(vdev_t *vd, uint64_t psize) 307{ 308 uint64_t asize = P2ROUNDUP(psize, 1ULL << vd->vdev_top->vdev_ashift); --- 255 unchanged lines hidden (view full) --- 564 mutex_init(&vd->vdev_obsolete_lock, NULL, MUTEX_DEFAULT, NULL); 565 vd->vdev_obsolete_segments = range_tree_create(NULL, NULL); 566 567 mutex_init(&vd->vdev_dtl_lock, NULL, MUTEX_DEFAULT, NULL); 568 mutex_init(&vd->vdev_stat_lock, NULL, MUTEX_DEFAULT, NULL); 569 mutex_init(&vd->vdev_probe_lock, NULL, MUTEX_DEFAULT, NULL); 570 mutex_init(&vd->vdev_queue_lock, NULL, MUTEX_DEFAULT, NULL); 571 mutex_init(&vd->vdev_scan_io_queue_lock, NULL, MUTEX_DEFAULT, NULL); |
563 | 572 mutex_init(&vd->vdev_initialize_lock, NULL, MUTEX_DEFAULT, NULL); 573 mutex_init(&vd->vdev_initialize_io_lock, NULL, MUTEX_DEFAULT, NULL); 574 cv_init(&vd->vdev_initialize_cv, NULL, CV_DEFAULT, NULL); 575 cv_init(&vd->vdev_initialize_io_cv, NULL, CV_DEFAULT, NULL); 576 |
564 for (int t = 0; t < DTL_TYPES; t++) { 565 vd->vdev_dtl[t] = range_tree_create(NULL, NULL); 566 } 567 txg_list_create(&vd->vdev_ms_list, spa, 568 offsetof(struct metaslab, ms_txg_node)); 569 txg_list_create(&vd->vdev_dtl_list, spa, 570 offsetof(struct vdev, vdev_dtl_node)); 571 vd->vdev_stat.vs_timestamp = gethrtime(); --- 256 unchanged lines hidden (view full) --- 828 829 return (0); 830} 831 832void 833vdev_free(vdev_t *vd) 834{ 835 spa_t *spa = vd->vdev_spa; | 577 for (int t = 0; t < DTL_TYPES; t++) { 578 vd->vdev_dtl[t] = range_tree_create(NULL, NULL); 579 } 580 txg_list_create(&vd->vdev_ms_list, spa, 581 offsetof(struct metaslab, ms_txg_node)); 582 txg_list_create(&vd->vdev_dtl_list, spa, 583 offsetof(struct vdev, vdev_dtl_node)); 584 vd->vdev_stat.vs_timestamp = gethrtime(); --- 256 unchanged lines hidden (view full) --- 841 842 return (0); 843} 844 845void 846vdev_free(vdev_t *vd) 847{ 848 spa_t *spa = vd->vdev_spa; |
849 ASSERT3P(vd->vdev_initialize_thread, ==, NULL); |
|
836 837 /* 838 * Scan queues are normally destroyed at the end of a scan. If the 839 * queue exists here, that implies the vdev is being removed while 840 * the scan is still running. 841 */ 842 if (vd->vdev_scan_io_queue != NULL) { 843 mutex_enter(&vd->vdev_scan_io_queue_lock); --- 14 unchanged lines hidden (view full) --- 858 /* 859 * Free all children. 860 */ 861 for (int c = 0; c < vd->vdev_children; c++) 862 vdev_free(vd->vdev_child[c]); 863 864 ASSERT(vd->vdev_child == NULL); 865 ASSERT(vd->vdev_guid_sum == vd->vdev_guid); | 850 851 /* 852 * Scan queues are normally destroyed at the end of a scan. If the 853 * queue exists here, that implies the vdev is being removed while 854 * the scan is still running. 855 */ 856 if (vd->vdev_scan_io_queue != NULL) { 857 mutex_enter(&vd->vdev_scan_io_queue_lock); --- 14 unchanged lines hidden (view full) --- 872 /* 873 * Free all children. 874 */ 875 for (int c = 0; c < vd->vdev_children; c++) 876 vdev_free(vd->vdev_child[c]); 877 878 ASSERT(vd->vdev_child == NULL); 879 ASSERT(vd->vdev_guid_sum == vd->vdev_guid); |
880 ASSERT(vd->vdev_initialize_thread == NULL); |
|
866 867 /* 868 * Discard allocation state. 869 */ 870 if (vd->vdev_mg != NULL) { 871 vdev_metaslab_fini(vd); 872 metaslab_group_destroy(vd->vdev_mg); 873 } --- 57 unchanged lines hidden (view full) --- 931 rw_destroy(&vd->vdev_indirect_rwlock); 932 mutex_destroy(&vd->vdev_obsolete_lock); 933 934 mutex_destroy(&vd->vdev_queue_lock); 935 mutex_destroy(&vd->vdev_dtl_lock); 936 mutex_destroy(&vd->vdev_stat_lock); 937 mutex_destroy(&vd->vdev_probe_lock); 938 mutex_destroy(&vd->vdev_scan_io_queue_lock); | 881 882 /* 883 * Discard allocation state. 884 */ 885 if (vd->vdev_mg != NULL) { 886 vdev_metaslab_fini(vd); 887 metaslab_group_destroy(vd->vdev_mg); 888 } --- 57 unchanged lines hidden (view full) --- 946 rw_destroy(&vd->vdev_indirect_rwlock); 947 mutex_destroy(&vd->vdev_obsolete_lock); 948 949 mutex_destroy(&vd->vdev_queue_lock); 950 mutex_destroy(&vd->vdev_dtl_lock); 951 mutex_destroy(&vd->vdev_stat_lock); 952 mutex_destroy(&vd->vdev_probe_lock); 953 mutex_destroy(&vd->vdev_scan_io_queue_lock); |
954 mutex_destroy(&vd->vdev_initialize_lock); 955 mutex_destroy(&vd->vdev_initialize_io_lock); 956 cv_destroy(&vd->vdev_initialize_io_cv); 957 cv_destroy(&vd->vdev_initialize_cv); |
|
939 940 if (vd == spa->spa_root_vdev) 941 spa->spa_root_vdev = NULL; 942 943 kmem_free(vd, sizeof (vdev_t)); 944} 945 946/* --- 2078 unchanged lines hidden (view full) --- 3025void 3026vdev_sync_done(vdev_t *vd, uint64_t txg) 3027{ 3028 metaslab_t *msp; 3029 boolean_t reassess = !txg_list_empty(&vd->vdev_ms_list, TXG_CLEAN(txg)); 3030 3031 ASSERT(vdev_is_concrete(vd)); 3032 | 958 959 if (vd == spa->spa_root_vdev) 960 spa->spa_root_vdev = NULL; 961 962 kmem_free(vd, sizeof (vdev_t)); 963} 964 965/* --- 2078 unchanged lines hidden (view full) --- 3044void 3045vdev_sync_done(vdev_t *vd, uint64_t txg) 3046{ 3047 metaslab_t *msp; 3048 boolean_t reassess = !txg_list_empty(&vd->vdev_ms_list, TXG_CLEAN(txg)); 3049 3050 ASSERT(vdev_is_concrete(vd)); 3051 |
3033 while (msp = txg_list_remove(&vd->vdev_ms_list, TXG_CLEAN(txg))) | 3052 while ((msp = txg_list_remove(&vd->vdev_ms_list, TXG_CLEAN(txg))) 3053 != NULL) |
3034 metaslab_sync_done(msp, txg); 3035 3036 if (reassess) 3037 metaslab_sync_reassess(vd->vdev_mg); 3038} 3039 3040void 3041vdev_sync(vdev_t *vd, uint64_t txg) --- 209 unchanged lines hidden (view full) --- 3251 if ((flags & ZFS_ONLINE_EXPAND) || spa->spa_autoexpand) { 3252 3253 /* XXX - L2ARC 1.0 does not support expansion */ 3254 if (vd->vdev_aux) 3255 return (spa_vdev_state_exit(spa, vd, ENOTSUP)); 3256 spa_async_request(spa, SPA_ASYNC_CONFIG_UPDATE); 3257 } 3258 | 3054 metaslab_sync_done(msp, txg); 3055 3056 if (reassess) 3057 metaslab_sync_reassess(vd->vdev_mg); 3058} 3059 3060void 3061vdev_sync(vdev_t *vd, uint64_t txg) --- 209 unchanged lines hidden (view full) --- 3271 if ((flags & ZFS_ONLINE_EXPAND) || spa->spa_autoexpand) { 3272 3273 /* XXX - L2ARC 1.0 does not support expansion */ 3274 if (vd->vdev_aux) 3275 return (spa_vdev_state_exit(spa, vd, ENOTSUP)); 3276 spa_async_request(spa, SPA_ASYNC_CONFIG_UPDATE); 3277 } 3278 |
3279 /* Restart initializing if necessary */ 3280 mutex_enter(&vd->vdev_initialize_lock); 3281 if (vdev_writeable(vd) && 3282 vd->vdev_initialize_thread == NULL && 3283 vd->vdev_initialize_state == VDEV_INITIALIZE_ACTIVE) { 3284 (void) vdev_initialize(vd); 3285 } 3286 mutex_exit(&vd->vdev_initialize_lock); 3287 |
|
3259 if (wasoffline || 3260 (oldstate < VDEV_STATE_DEGRADED && 3261 vd->vdev_state >= VDEV_STATE_DEGRADED)) 3262 spa_event_notify(spa, vd, NULL, ESC_ZFS_VDEV_ONLINE); 3263 3264 return (spa_vdev_state_exit(spa, vd, 0)); 3265} 3266 --- 286 unchanged lines hidden (view full) --- 3553 3554 ASSERT(spa_config_held(spa, SCL_ALL, RW_READER) != 0); 3555 3556 mutex_enter(&vd->vdev_stat_lock); 3557 bcopy(&vd->vdev_stat, vs, sizeof (*vs)); 3558 vs->vs_timestamp = gethrtime() - vs->vs_timestamp; 3559 vs->vs_state = vd->vdev_state; 3560 vs->vs_rsize = vdev_get_min_asize(vd); | 3288 if (wasoffline || 3289 (oldstate < VDEV_STATE_DEGRADED && 3290 vd->vdev_state >= VDEV_STATE_DEGRADED)) 3291 spa_event_notify(spa, vd, NULL, ESC_ZFS_VDEV_ONLINE); 3292 3293 return (spa_vdev_state_exit(spa, vd, 0)); 3294} 3295 --- 286 unchanged lines hidden (view full) --- 3582 3583 ASSERT(spa_config_held(spa, SCL_ALL, RW_READER) != 0); 3584 3585 mutex_enter(&vd->vdev_stat_lock); 3586 bcopy(&vd->vdev_stat, vs, sizeof (*vs)); 3587 vs->vs_timestamp = gethrtime() - vs->vs_timestamp; 3588 vs->vs_state = vd->vdev_state; 3589 vs->vs_rsize = vdev_get_min_asize(vd); |
3561 if (vd->vdev_ops->vdev_op_leaf) | 3590 if (vd->vdev_ops->vdev_op_leaf) { |
3562 vs->vs_rsize += VDEV_LABEL_START_SIZE + VDEV_LABEL_END_SIZE; | 3591 vs->vs_rsize += VDEV_LABEL_START_SIZE + VDEV_LABEL_END_SIZE; |
3592 /* 3593 * Report intializing progress. Since we don't have the 3594 * initializing locks held, this is only an estimate (although a 3595 * fairly accurate one). 3596 */ 3597 vs->vs_initialize_bytes_done = vd->vdev_initialize_bytes_done; 3598 vs->vs_initialize_bytes_est = vd->vdev_initialize_bytes_est; 3599 vs->vs_initialize_state = vd->vdev_initialize_state; 3600 vs->vs_initialize_action_time = vd->vdev_initialize_action_time; 3601 } |
|
3563 /* 3564 * Report expandable space on top-level, non-auxillary devices only. 3565 * The expandable space is reported in terms of metaslab sized units 3566 * since that determines how much space the pool can expand. 3567 */ 3568 if (vd->vdev_aux == NULL && tvd != NULL && vd->vdev_max_asize != 0) { 3569 vs->vs_esize = P2ALIGN(vd->vdev_max_asize - vd->vdev_asize - 3570 spa->spa_bootsize, 1ULL << tvd->vdev_ms_shift); --- 721 unchanged lines hidden --- | 3602 /* 3603 * Report expandable space on top-level, non-auxillary devices only. 3604 * The expandable space is reported in terms of metaslab sized units 3605 * since that determines how much space the pool can expand. 3606 */ 3607 if (vd->vdev_aux == NULL && tvd != NULL && vd->vdev_max_asize != 0) { 3608 vs->vs_esize = P2ALIGN(vd->vdev_max_asize - vd->vdev_asize - 3609 spa->spa_bootsize, 1ULL << tvd->vdev_ms_shift); --- 721 unchanged lines hidden --- |