[OPW,kernel] Staging: lustre: lnet: Improve 'incarnation' stamp
diff mbox

Message ID 20141031004522.GA64957@localhost
State New, archived
Headers show

Commit Message

Tina Ruchandani Oct. 31, 2014, 12:45 a.m. UTC
ksock_net_t uses a __u64 quantity as an 'incarnation' timestamp. This is also
passed on in hello messages and used to detect if a reboot has occurred.
This 'incarnation' is obtained using do_gettimeofday.It is only used in equality
checks, so the absolute value does not matter.

This patch replaces do_gettimeofday with ktime_get_ns for the following reasons:
1. ktime_get_ns returns a __u64 which is safer than 'struct timeval'
which will overflow on 32-bit systems in year 2038 and beyond.
2. Reduced compute: ktime_get_ns is faster than the multiply/add
   combination used in this function

Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>
 drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff mbox

diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index 038854e..8ac6410 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -2348,16 +2348,11 @@  ksocknal_base_shutdown(void)
 static __u64
 ksocknal_new_incarnation (void)
-	struct timeval tv;
 	/* The incarnation number is the time this module loaded and it
-	 * identifies this particular instance of the socknal.  Hopefully
-	 * we won't be able to reboot more frequently than 1MHz for the
-	 * foreseeable future :) */
-	do_gettimeofday(&tv);
-	return (((__u64)tv.tv_sec) * 1000000) + tv.tv_usec;
+	 * identifies this particular instance of the socknal.
+	 */
+	return ktime_get_ns();
 static int