From 348e764b9bab92e628dd3dda4861b0068a7cb4f3 Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Tue, 22 Nov 2022 16:09:59 +1100 Subject: [PATCH] LU-13665 lfs: use correct DST setting for mktime() 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 Change-Id: I94afba96e2563442786726096501c5ec0b40a881 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49206 Tested-by: jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/tests/sanity.sh | 3 --- lustre/utils/lfs.c | 6 ++++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 041b0c5..8b47fdb 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -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" diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 3b1d6ea..23e13b0 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -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)) -- 1.8.3.1