From 63fd3c6cfd264cab94dc186fe8cceecac8bc0d50 Mon Sep 17 00:00:00 2001 From: Adam Leventhal Date: Wed, 28 Aug 2013 16:05:48 -0700 Subject: Illumos #3582, #3584 3582 zfs_delay() should support a variable resolution 3584 DTrace sdt probes for ZFS txg states Reviewed by: Matthew Ahrens Reviewed by: George Wilson Reviewed by: Christopher Siden Reviewed by: Dan McDonald Reviewed by: Richard Elling Approved by: Garrett D'Amore References: https://www.illumos.org/issues/3582 illumos/illumos-gate@0689f76 Ported by: Ned Bass Signed-off-by: Brian Behlendorf Issue #1775 --- lib/libzpool/kernel.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'lib/libzpool') diff --git a/lib/libzpool/kernel.c b/lib/libzpool/kernel.c index 2e5eef69b..f994f8ee3 100644 --- a/lib/libzpool/kernel.c +++ b/lib/libzpool/kernel.c @@ -528,6 +528,41 @@ top: return (1); } +/*ARGSUSED*/ +clock_t +cv_timedwait_hires(kcondvar_t *cv, kmutex_t *mp, hrtime_t tim, hrtime_t res, + int flag) +{ + int error; + timestruc_t ts; + hrtime_t delta; + + ASSERT(flag == 0); + +top: + delta = tim - gethrtime(); + if (delta <= 0) + return (-1); + + ts.tv_sec = delta / NANOSEC; + ts.tv_nsec = delta % NANOSEC; + + ASSERT(mutex_owner(mp) == curthread); + mp->m_owner = NULL; + error = pthread_cond_timedwait(&cv->cv, &mp->m_lock, &ts); + mp->m_owner = curthread; + + if (error == ETIME) + return (-1); + + if (error == EINTR) + goto top; + + ASSERT(error == 0); + + return (1); +} + void cv_signal(kcondvar_t *cv) { -- cgit v1.2.3