Whamcloud - gitweb
LU-4423 libcfs: tracefile document seconds overflow 37/23137/2
authorArnd Bergmann <arnd@arndb.de>
Thu, 13 Oct 2016 18:04:39 +0000 (14:04 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Sun, 1 Jan 2017 01:58:35 +0000 (01:58 +0000)
commita05ff6f7a0377bb1c2f9b1699f9b08ae9e981e1e
treeca70e6ba8452fa64c0c5f034c1c916a897384158
parent0c06af45b0c49955a5928eb92f13621919a223d0
LU-4423 libcfs: tracefile document seconds overflow

The lustre tracefile has a timestamp defined as

__u32 ph_sec;
__u64 ph_usec;

which seems completely backwards, as the microsecond portion of
a time stamp will always fit into a __u32 value, while the second
portion will overflow in 2038 or 2106 (in case of unsigned seconds).

Changing this would unfortunately change the format in an incompatible
way, breaking all existing user space tools that access the data.

This uses ktime_get_real_ts64() to replace the insufficient
do_gettimeofday() and then truncates the seconds portion to
an u32 type, along with comments to explain the result.

A possible alternative would be the use of ktime_get_ts64() to
read a monotonic timestamp that never overflows, but this would
trigger a check in user space 'hdr->ph_sec < (1 << 30)' that
attempts to ensure that the values are within a reasonable range.

Linux-commit: 65f28840e4c653b7d78feabcb65280c09d3d0d23

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Change-Id: I5fdf6d09d39fbb4da8ccba51a745b00996f116f7
Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/23137
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Frank Zago <fzago@cray.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
libcfs/include/libcfs/libcfs_debug.h
libcfs/libcfs/linux/linux-tracefile.c