Whamcloud - gitweb
LU-13665 lfs: use correct DST setting for mktime() 06/49206/3
authorMr NeilBrown <neilb@suse.de>
Tue, 22 Nov 2022 05:09:59 +0000 (16:09 +1100)
committerOleg Drokin <green@whamcloud.com>
Tue, 6 Dec 2022 02:44:41 +0000 (02:44 +0000)
When lfs is passed a "-newerXY" arg when Y=='t' and the arg doesn't
start %H, it leaves ->tm_isdst set to 0 which tells mktime() to assume
that DST is not active.
This means that it produces incorrect results for times when DST is
active.

We should set ->tm_isdst to -1 to tell mktime() that it is not known
whether DST is active.  Then mktime() will use the timezone database
to determine the correct DST setting.

This allows us to re-enable test 56oc on all platforms.

Test-Parameters: trivial clientdistro=sles15sp3 env=ONLY=56
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I94afba96e2563442786726096501c5ec0b40a881
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49206
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/sanity.sh
lustre/utils/lfs.c

index 041b0c5..8b47fdb 100755 (executable)
@@ -6689,9 +6689,6 @@ test_56oc() {
        test_newerXY_base "c" "m"
        test_newerXY_base "c" "c"
 
-       [[ -n "$sles_version" ]] &&
-               echo "skip timestamp tests on SLES, LU-13665" && return 0
-
        test_newerXY_base "a" "t"
        test_newerXY_base "m" "t"
        test_newerXY_base "c" "t"
index 3b1d6ea..23e13b0 100644 (file)
@@ -5252,10 +5252,12 @@ static int lfs_find(int argc, char **argv)
                                        char *ptr;
 
                                        /* Init for times relative to today */
-                                       if (strncmp(fmts[i], "%H", 2) == 0)
+                                       if (strncmp(fmts[i], "%H", 2) == 0) {
                                                localtime_r(&ref, &tm);
-                                       else
+                                       } else {
                                                memset(&tm, 0, sizeof(tm));
+                                               tm.tm_isdst = -1;
+                                       }
                                        ptr = strptime(optarg, fmts[i], &tm);
                                        /* Skip spaces */
                                        while (ptr && isspace(*ptr))