* Update the in-core space usage stats for this vdev, its metaslab class, * and the root vdev. */
| 4520 | * and the root vdev. |
| 4521 | */ |
| 4522 | void |
| 4523 | vdev_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 |
no test coverage detected