Print this page
NEX-9808 SMB3 persistent handles
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-9808 SMB3 persistent handles
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-4239 smbtorture create failures re. allocation size
Reviewed by: Matt Barden <Matt.Barden@nexenta.com>
Reviewed by: Kevin Crowe <kevin.crowe@nexenta.com>
NEX-2781 SMB2 credit handling needs work
SMB-50 User-mode SMB server
 Includes work by these authors:
 Thomas Keiser <thomas.keiser@nexenta.com>
 Albert Lee <trisk@nexenta.com>

@@ -8,11 +8,11 @@
  * source.  A copy of the CDDL is also available via the Internet at
  * http://www.illumos.org/license/CDDL.
  */
 
 /*
- * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright 2017 Nexenta Systems, Inc.  All rights reserved.
  */
 
 
 #include <sys/types.h>
 #include <sys/time.h>

@@ -80,6 +80,51 @@
 
 /* ARGSUSED */
 void
 scalehrtime(hrtime_t *t)
 {
+}
+
+/*
+ * These functions are blatently stolen from the kernel.
+ * See the dissertation in the comments preceding the
+ * hrt2ts() and ts2hrt() functions in:
+ *      uts/common/os/timers.c
+ */
+void
+hrt2ts(hrtime_t hrt, timespec_t *tsp)
+{
+        uint32_t sec, nsec, tmp;
+
+        tmp = (uint32_t)(hrt >> 30);
+        sec = tmp - (tmp >> 2);
+        sec = tmp - (sec >> 5);
+        sec = tmp + (sec >> 1);
+        sec = tmp - (sec >> 6) + 7;
+        sec = tmp - (sec >> 3);
+        sec = tmp + (sec >> 1);
+        sec = tmp + (sec >> 3);
+        sec = tmp + (sec >> 4);
+        tmp = (sec << 7) - sec - sec - sec;
+        tmp = (tmp << 7) - tmp - tmp - tmp;
+        tmp = (tmp << 7) - tmp - tmp - tmp;
+        nsec = (uint32_t)hrt - (tmp << 9);
+        while (nsec >= NANOSEC) {
+                nsec -= NANOSEC;
+                sec++;
+        }
+        tsp->tv_sec = (time_t)sec;
+        tsp->tv_nsec = nsec;
+}
+
+hrtime_t
+ts2hrt(const timestruc_t *tsp)
+{
+        hrtime_t hrt;
+
+        hrt = tsp->tv_sec;
+        hrt = (hrt << 7) - hrt - hrt - hrt;
+        hrt = (hrt << 7) - hrt - hrt - hrt;
+        hrt = (hrt << 7) - hrt - hrt - hrt;
+        hrt = (hrt << 9) + tsp->tv_nsec;
+        return (hrt);
 }