diff options
author | delphij <delphij@FreeBSD.org> | 2013-09-10 01:46:47 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2013-09-10 01:46:47 +0000 |
commit | a23043347caa65ac4c8e91f806ab2319dbbd657c (patch) | |
tree | 0687bff9ba2d5136268f4e5308ff47b239b85978 /cddl/contrib/opensolaris/lib/libzpool/common/kernel.c | |
parent | 545d815a3b9493ec2dee3f291049b47655c1ec46 (diff) | |
download | FreeBSD-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/contrib/opensolaris/lib/libzpool/common/kernel.c')
-rw-r--r-- | cddl/contrib/opensolaris/lib/libzpool/common/kernel.c | 35 |
1 files changed, 35 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) { |