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

Function vdev_cache_write

freebsd/contrib/openzfs/module/zfs/vdev_cache.c:329–364  ·  view source on GitHub ↗

* Update cache contents upon write completion. */

Source from the content-addressed store, hash-verified

327 * Update cache contents upon write completion.
328 */
329void
330vdev_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
366void
367vdev_cache_purge(vdev_t *vd)

Callers 1

zio_vdev_io_doneFunction · 0.85

Calls 5

mutex_enterFunction · 0.85
avl_findFunction · 0.85
avl_nearestFunction · 0.85
abd_copy_offFunction · 0.85
mutex_exitFunction · 0.85

Tested by

no test coverage detected