aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAdam Leventhal <[email protected]>2013-08-28 16:05:48 -0700
committerBrian Behlendorf <[email protected]>2013-11-04 10:55:25 -0800
commit63fd3c6cfd264cab94dc186fe8cceecac8bc0d50 (patch)
tree2b4c580be7c82a4c5160ef99c0020c4752ba9eff /lib
parentc1fabe7961b100a7dfd77cddba1650d9a6580dc0 (diff)
Illumos #3582, #3584
3582 zfs_delay() should support a variable resolution 3584 DTrace sdt probes for ZFS txg states Reviewed by: Matthew Ahrens <[email protected]> Reviewed by: George Wilson <[email protected]> Reviewed by: Christopher Siden <[email protected]> Reviewed by: Dan McDonald <[email protected]> Reviewed by: Richard Elling <[email protected]> Approved by: Garrett D'Amore <[email protected]> References: https://www.illumos.org/issues/3582 illumos/illumos-gate@0689f76 Ported by: Ned Bass <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Issue #1775
Diffstat (limited to 'lib')
-rw-r--r--lib/libspl/include/sys/time.h8
-rw-r--r--lib/libzpool/kernel.c35
2 files changed, 43 insertions, 0 deletions
diff --git a/lib/libspl/include/sys/time.h b/lib/libspl/include/sys/time.h
index 0cbbd928d..852b2eff9 100644
--- a/lib/libspl/include/sys/time.h
+++ b/lib/libspl/include/sys/time.h
@@ -50,6 +50,14 @@
#define NSEC_PER_USEC 1000L
#endif
+#ifndef MSEC2NSEC
+#define MSEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / MILLISEC))
+#endif
+
+#ifndef NSEC2MSEC
+#define NSEC2MSEC(n) ((n) / (NANOSEC / MILLISEC))
+#endif
+
extern hrtime_t gethrtime(void);
extern void gethrestime(timestruc_t *);
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)
{