* Update cache contents upon write completion. */
| 327 | * Update cache contents upon write completion. |
| 328 | */ |
| 329 | void |
| 330 | vdev_cache_write(zio_t *zio) |
| 331 | { |
| 332 | vdev_cache_t *vc = &zio->io_vd->vdev_cache; |
| 333 | vdev_cache_entry_t *ve, ve_search; |
| 334 | uint64_t io_start = zio->io_offset; |
| 335 | uint64_t io_end = io_start + zio->io_size; |
| 336 | uint64_t min_offset = P2ALIGN(io_start, VCBS); |
| 337 | uint64_t max_offset = P2ROUNDUP(io_end, VCBS); |
| 338 | avl_index_t where; |
| 339 | |
| 340 | ASSERT3U(zio->io_type, ==, ZIO_TYPE_WRITE); |
| 341 | |
| 342 | mutex_enter(&vc->vc_lock); |
| 343 | |
| 344 | ve_search.ve_offset = min_offset; |
| 345 | ve = avl_find(&vc->vc_offset_tree, &ve_search, &where); |
| 346 | |
| 347 | if (ve == NULL) |
| 348 | ve = avl_nearest(&vc->vc_offset_tree, where, AVL_AFTER); |
| 349 | |
| 350 | while (ve != NULL && ve->ve_offset < max_offset) { |
| 351 | uint64_t start = MAX(ve->ve_offset, io_start); |
| 352 | uint64_t end = MIN(ve->ve_offset + VCBS, io_end); |
| 353 | |
| 354 | if (ve->ve_fill_io != NULL) { |
| 355 | ve->ve_missed_update = 1; |
| 356 | } else { |
| 357 | abd_copy_off(ve->ve_abd, zio->io_abd, |
| 358 | start - ve->ve_offset, start - io_start, |
| 359 | end - start); |
| 360 | } |
| 361 | ve = AVL_NEXT(&vc->vc_offset_tree, ve); |
| 362 | } |
| 363 | mutex_exit(&vc->vc_lock); |
| 364 | } |
| 365 | |
| 366 | void |
| 367 | vdev_cache_purge(vdev_t *vd) |
no test coverage detected