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

Function vdev_sync

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

Source from the content-addressed store, hash-verified

3536}
3537
3538void
3539vdev_sync(vdev_t *vd, uint64_t txg)
3540{
3541 spa_t *spa = vd->vdev_spa;
3542 vdev_t *lvd;
3543 metaslab_t *msp;
3544
3545 ASSERT3U(txg, ==, spa->spa_syncing_txg);
3546 dmu_tx_t *tx = dmu_tx_create_assigned(spa->spa_dsl_pool, txg);
3547 if (range_tree_space(vd->vdev_obsolete_segments) > 0) {
3548 ASSERT(vd->vdev_removing ||
3549 vd->vdev_ops == &vdev_indirect_ops);
3550
3551 vdev_indirect_sync_obsolete(vd, tx);
3552
3553 /*
3554 * If the vdev is indirect, it can't have dirty
3555 * metaslabs or DTLs.
3556 */
3557 if (vd->vdev_ops == &vdev_indirect_ops) {
3558 ASSERT(txg_list_empty(&vd->vdev_ms_list, txg));
3559 ASSERT(txg_list_empty(&vd->vdev_dtl_list, txg));
3560 dmu_tx_commit(tx);
3561 return;
3562 }
3563 }
3564
3565 ASSERT(vdev_is_concrete(vd));
3566
3567 if (vd->vdev_ms_array == 0 && vd->vdev_ms_shift != 0 &&
3568 !vd->vdev_removing) {
3569 ASSERT(vd == vd->vdev_top);
3570 ASSERT0(vd->vdev_indirect_config.vic_mapping_object);
3571 vd->vdev_ms_array = dmu_object_alloc(spa->spa_meta_objset,
3572 DMU_OT_OBJECT_ARRAY, 0, DMU_OT_NONE, 0, tx);
3573 ASSERT(vd->vdev_ms_array != 0);
3574 vdev_config_dirty(vd);
3575 }
3576
3577 while ((msp = txg_list_remove(&vd->vdev_ms_list, txg)) != NULL) {
3578 metaslab_sync(msp, txg);
3579 (void) txg_list_add(&vd->vdev_ms_list, msp, TXG_CLEAN(txg));
3580 }
3581
3582 while ((lvd = txg_list_remove(&vd->vdev_dtl_list, txg)) != NULL)
3583 vdev_dtl_sync(lvd, txg);
3584
3585 /*
3586 * If this is an empty log device being removed, destroy the
3587 * metadata associated with it.
3588 */
3589 if (vd->vdev_islog && vd->vdev_stat.vs_alloc == 0 && vd->vdev_removing)
3590 vdev_remove_empty_log(vd, txg);
3591
3592 (void) txg_list_add(&spa->spa_vdev_txg_list, vd, TXG_CLEAN(txg));
3593 dmu_tx_commit(tx);
3594}
3595

Callers 1

Calls 13

dmu_tx_create_assignedFunction · 0.85
range_tree_spaceFunction · 0.85
txg_list_emptyFunction · 0.85
dmu_tx_commitFunction · 0.85
vdev_is_concreteFunction · 0.85
dmu_object_allocFunction · 0.85
vdev_config_dirtyFunction · 0.85
txg_list_removeFunction · 0.85
metaslab_syncFunction · 0.85
txg_list_addFunction · 0.85
vdev_dtl_syncFunction · 0.85

Tested by

no test coverage detected