Changeset View
Changeset View
Standalone View
Standalone View
head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c
Show First 20 Lines • Show All 653 Lines • ▼ Show 20 Lines | zio_create(zio_t *pio, spa_t *spa, uint64_t txg, const blkptr_t *bp, | ||||
IMPLY(lsize != psize, (flags & ZIO_FLAG_RAW) != 0); | IMPLY(lsize != psize, (flags & ZIO_FLAG_RAW) != 0); | ||||
zio = kmem_cache_alloc(zio_cache, KM_SLEEP); | zio = kmem_cache_alloc(zio_cache, KM_SLEEP); | ||||
bzero(zio, sizeof (zio_t)); | bzero(zio, sizeof (zio_t)); | ||||
mutex_init(&zio->io_lock, NULL, MUTEX_DEFAULT, NULL); | mutex_init(&zio->io_lock, NULL, MUTEX_DEFAULT, NULL); | ||||
cv_init(&zio->io_cv, NULL, CV_DEFAULT, NULL); | cv_init(&zio->io_cv, NULL, CV_DEFAULT, NULL); | ||||
#if defined(__FreeBSD__) && defined(_KERNEL) | |||||
callout_init(&zio->io_timer, 1); | |||||
#endif | |||||
list_create(&zio->io_parent_list, sizeof (zio_link_t), | list_create(&zio->io_parent_list, sizeof (zio_link_t), | ||||
offsetof(zio_link_t, zl_parent_node)); | offsetof(zio_link_t, zl_parent_node)); | ||||
list_create(&zio->io_child_list, sizeof (zio_link_t), | list_create(&zio->io_child_list, sizeof (zio_link_t), | ||||
offsetof(zio_link_t, zl_child_node)); | offsetof(zio_link_t, zl_child_node)); | ||||
metaslab_trace_init(&zio->io_alloc_list); | metaslab_trace_init(&zio->io_alloc_list); | ||||
if (vd != NULL) | if (vd != NULL) | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | #endif | ||||
} | } | ||||
return (zio); | return (zio); | ||||
} | } | ||||
static void | static void | ||||
zio_destroy(zio_t *zio) | zio_destroy(zio_t *zio) | ||||
{ | { | ||||
#ifdef __FreeBSD__ | |||||
KASSERT(!(callout_active(&zio->io_timer) || | |||||
callout_pending(&zio->io_timer)), ("zio_destroy: timer active")); | |||||
#endif | |||||
metaslab_trace_fini(&zio->io_alloc_list); | metaslab_trace_fini(&zio->io_alloc_list); | ||||
list_destroy(&zio->io_parent_list); | list_destroy(&zio->io_parent_list); | ||||
list_destroy(&zio->io_child_list); | list_destroy(&zio->io_child_list); | ||||
mutex_destroy(&zio->io_lock); | mutex_destroy(&zio->io_lock); | ||||
cv_destroy(&zio->io_cv); | cv_destroy(&zio->io_cv); | ||||
kmem_cache_free(zio_cache, zio); | kmem_cache_free(zio_cache, zio); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 968 Lines • ▼ Show 20 Lines | if (now >= zio->io_target_timestamp) { | ||||
zio_interrupt(zio); | zio_interrupt(zio); | ||||
} else { | } else { | ||||
hrtime_t diff = zio->io_target_timestamp - now; | hrtime_t diff = zio->io_target_timestamp - now; | ||||
DTRACE_PROBE3(zio__delay__hit, zio_t *, zio, | DTRACE_PROBE3(zio__delay__hit, zio_t *, zio, | ||||
hrtime_t, now, hrtime_t, diff); | hrtime_t, now, hrtime_t, diff); | ||||
#ifdef __FreeBSD__ | |||||
callout_reset_sbt(&zio->io_timer, nstosbt(diff), 0, | |||||
(void (*)(void *))zio_interrupt, zio, C_HARDCLOCK); | |||||
#else | |||||
(void) timeout_generic(CALLOUT_NORMAL, | (void) timeout_generic(CALLOUT_NORMAL, | ||||
(void (*)(void *))zio_interrupt, zio, diff, 1, 0); | (void (*)(void *))zio_interrupt, zio, diff, 1, 0); | ||||
#endif | |||||
} | } | ||||
return; | return; | ||||
} | } | ||||
#endif | #endif | ||||
DTRACE_PROBE1(zio__delay__skip, zio_t *, zio); | DTRACE_PROBE1(zio__delay__skip, zio_t *, zio); | ||||
zio_interrupt(zio); | zio_interrupt(zio); | ||||
▲ Show 20 Lines • Show All 2,648 Lines • Show Last 20 Lines |