summaryrefslogtreecommitdiffstats
path: root/cddl
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2013-09-10 01:46:47 +0000
committerdelphij <delphij@FreeBSD.org>2013-09-10 01:46:47 +0000
commita23043347caa65ac4c8e91f806ab2319dbbd657c (patch)
tree0687bff9ba2d5136268f4e5308ff47b239b85978 /cddl
parent545d815a3b9493ec2dee3f291049b47655c1ec46 (diff)
downloadFreeBSD-src-a23043347caa65ac4c8e91f806ab2319dbbd657c.zip
FreeBSD-src-a23043347caa65ac4c8e91f806ab2319dbbd657c.tar.gz
MFV r247844 (illumos-gate 13975:ef6409bc370f)
Illumos ZFS issues: 3582 zfs_delay() should support a variable resolution 3584 DTrace sdt probes for ZFS txg states Provide a compatibility shim for Solaris's cv_timedwait_hires to help aid future porting. Approved by: re (ZFS blanket)
Diffstat (limited to 'cddl')
-rw-r--r--cddl/contrib/opensolaris/lib/libzpool/common/kernel.c35
-rw-r--r--cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h2
2 files changed, 37 insertions, 0 deletions
diff --git a/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c b/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c
index 71c3dce..c4e2d2e 100644
--- a/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c
+++ b/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c
@@ -349,6 +349,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, &mp->m_lock, &ts);
+ mp->m_owner = curthread;
+
+ if (error == ETIMEDOUT)
+ return (-1);
+
+ if (error == EINTR)
+ goto top;
+
+ ASSERT(error == 0);
+
+ return (1);
+}
+
void
cv_signal(kcondvar_t *cv)
{
diff --git a/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h b/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h
index da153c7..15c181e 100644
--- a/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h
+++ b/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h
@@ -313,6 +313,8 @@ extern void cv_init(kcondvar_t *cv, char *name, int type, void *arg);
extern void cv_destroy(kcondvar_t *cv);
extern void cv_wait(kcondvar_t *cv, kmutex_t *mp);
extern clock_t cv_timedwait(kcondvar_t *cv, kmutex_t *mp, clock_t abstime);
+extern clock_t cv_timedwait_hires(kcondvar_t *cvp, kmutex_t *mp, hrtime_t tim,
+ hrtime_t res, int flag);
extern void cv_signal(kcondvar_t *cv);
extern void cv_broadcast(kcondvar_t *cv);
OpenPOWER on IntegriCloud