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

Function vdev_space_update

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

* Update the in-core space usage stats for this vdev, its metaslab class, * and the root vdev. */

Source from the content-addressed store, hash-verified

4520 * and the root vdev.
4521 */
4522void
4523vdev_space_update(vdev_t *vd, int64_t alloc_delta, int64_t defer_delta,
4524 int64_t space_delta)
4525{
4526 int64_t dspace_delta;
4527 spa_t *spa = vd->vdev_spa;
4528 vdev_t *rvd = spa->spa_root_vdev;
4529
4530 ASSERT(vd == vd->vdev_top);
4531
4532 /*
4533 * Apply the inverse of the psize-to-asize (ie. RAID-Z) space-expansion
4534 * factor. We must calculate this here and not at the root vdev
4535 * because the root vdev's psize-to-asize is simply the max of its
4536 * children's, thus not accurate enough for us.
4537 */
4538 dspace_delta = vdev_deflated_space(vd, space_delta);
4539
4540 mutex_enter(&vd->vdev_stat_lock);
4541 /* ensure we won't underflow */
4542 if (alloc_delta < 0) {
4543 ASSERT3U(vd->vdev_stat.vs_alloc, >=, -alloc_delta);
4544 }
4545
4546 vd->vdev_stat.vs_alloc += alloc_delta;
4547 vd->vdev_stat.vs_space += space_delta;
4548 vd->vdev_stat.vs_dspace += dspace_delta;
4549 mutex_exit(&vd->vdev_stat_lock);
4550
4551 /* every class but log contributes to root space stats */
4552 if (vd->vdev_mg != NULL && !vd->vdev_islog) {
4553 ASSERT(!vd->vdev_isl2cache);
4554 mutex_enter(&rvd->vdev_stat_lock);
4555 rvd->vdev_stat.vs_alloc += alloc_delta;
4556 rvd->vdev_stat.vs_space += space_delta;
4557 rvd->vdev_stat.vs_dspace += dspace_delta;
4558 mutex_exit(&rvd->vdev_stat_lock);
4559 }
4560 /* Note: metaslab_class_space_update moved to metaslab_space_update */
4561}
4562
4563/*
4564 * Mark a top-level vdev's config as dirty, placing it on the dirty list

Callers 9

metaslab_space_updateFunction · 0.85
arc_hdr_l2hdr_destroyFunction · 0.85
l2arc_write_doneFunction · 0.85
l2arc_evictFunction · 0.85
l2arc_write_buffersFunction · 0.85
l2arc_add_vdevFunction · 0.85
l2arc_rebuildFunction · 0.85
l2arc_hdr_restoreFunction · 0.85
l2arc_log_blk_commitFunction · 0.85

Calls 3

vdev_deflated_spaceFunction · 0.85
mutex_enterFunction · 0.85
mutex_exitFunction · 0.85

Tested by

no test coverage detected