MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vdev_dtl_sync

Function vdev_dtl_sync

freebsd/contrib/openzfs/module/zfs/vdev.c:3083–3156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3081}
3082
3083static void
3084vdev_dtl_sync(vdev_t *vd, uint64_t txg)
3085{
3086 spa_t *spa = vd->vdev_spa;
3087 range_tree_t *rt = vd->vdev_dtl[DTL_MISSING];
3088 objset_t *mos = spa->spa_meta_objset;
3089 range_tree_t *rtsync;
3090 dmu_tx_t *tx;
3091 uint64_t object = space_map_object(vd->vdev_dtl_sm);
3092
3093 ASSERT(vdev_is_concrete(vd));
3094 ASSERT(vd->vdev_ops->vdev_op_leaf);
3095
3096 tx = dmu_tx_create_assigned(spa->spa_dsl_pool, txg);
3097
3098 if (vd->vdev_detached || vd->vdev_top->vdev_removing) {
3099 mutex_enter(&vd->vdev_dtl_lock);
3100 space_map_free(vd->vdev_dtl_sm, tx);
3101 space_map_close(vd->vdev_dtl_sm);
3102 vd->vdev_dtl_sm = NULL;
3103 mutex_exit(&vd->vdev_dtl_lock);
3104
3105 /*
3106 * We only destroy the leaf ZAP for detached leaves or for
3107 * removed log devices. Removed data devices handle leaf ZAP
3108 * cleanup later, once cancellation is no longer possible.
3109 */
3110 if (vd->vdev_leaf_zap != 0 && (vd->vdev_detached ||
3111 vd->vdev_top->vdev_islog)) {
3112 vdev_destroy_unlink_zap(vd, vd->vdev_leaf_zap, tx);
3113 vd->vdev_leaf_zap = 0;
3114 }
3115
3116 dmu_tx_commit(tx);
3117 return;
3118 }
3119
3120 if (vd->vdev_dtl_sm == NULL) {
3121 uint64_t new_object;
3122
3123 new_object = space_map_alloc(mos, zfs_vdev_dtl_sm_blksz, tx);
3124 VERIFY3U(new_object, !=, 0);
3125
3126 VERIFY0(space_map_open(&vd->vdev_dtl_sm, mos, new_object,
3127 0, -1ULL, 0));
3128 ASSERT(vd->vdev_dtl_sm != NULL);
3129 }
3130
3131 rtsync = range_tree_create(NULL, RANGE_SEG64, NULL, 0, 0);
3132
3133 mutex_enter(&vd->vdev_dtl_lock);
3134 range_tree_walk(rt, range_tree_add, rtsync);
3135 mutex_exit(&vd->vdev_dtl_lock);
3136
3137 space_map_truncate(vd->vdev_dtl_sm, zfs_vdev_dtl_sm_blksz, tx);
3138 space_map_write(vd->vdev_dtl_sm, rtsync, SM_ALLOC, SM_NO_VDEVID, tx);
3139 range_tree_vacate(rtsync, NULL, NULL);
3140

Callers 1

vdev_syncFunction · 0.85

Calls 15

space_map_objectFunction · 0.85
vdev_is_concreteFunction · 0.85
dmu_tx_create_assignedFunction · 0.85
mutex_enterFunction · 0.85
space_map_freeFunction · 0.85
space_map_closeFunction · 0.85
mutex_exitFunction · 0.85
vdev_destroy_unlink_zapFunction · 0.85
dmu_tx_commitFunction · 0.85
space_map_allocFunction · 0.85
space_map_openFunction · 0.85
range_tree_createFunction · 0.85

Tested by

no test coverage detected