From c5aa16db172afc9cbf0d4fd2c85261fef1a40d7b Mon Sep 17 00:00:00 2001 From: Arshad Hussain Date: Wed, 8 Nov 2023 12:08:07 +0530 Subject: [PATCH] LU-17265 tests: allow margin for sanity/39r The timestamp may be little outdated due to a gap between writing a file and checking the timestamp, so take that into consideration and allow 2 second leniency when comparing timestamps. The on-disk inode may also not be flushed from the journal immediately, so allow some time for it to be updated. This patch also converts the hex value read via debugfs to decimal. Test-Parameters: trivial testlist=sanity env=ONLY=39r,ONLY_REPEAT=100 Signed-off-by: Arshad Hussain Change-Id: I9e765f9cd572fb25821f9a0401c34209b7c3f574 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53035 Reviewed-by: James Simmons Reviewed-by: xinliang Reviewed-by: Oleg Drokin Reviewed-by: Andreas Dilger Tested-by: jenkins Tested-by: Maloo --- lustre/tests/sanity.sh | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 60460e3..1aa2d54 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -5263,6 +5263,7 @@ test_39r() { fi local saved_adiff + local ahost=$(facet_active_host ost1) saved_adiff=$(do_facet ost1 \ lctl get_param -n obdfilter.*OST0000.atime_diff) stack_trap "do_facet ost1 \ @@ -5280,11 +5281,9 @@ test_39r() { dd if=$DIR/$tfile of=/dev/null bs=4k count=1 || error "can't udpate atime" + # atime_cli value is in decimal local atime_cli=$(stat -c %X $DIR/$tfile) echo "client atime: $atime_cli" - # allow atime update to be written to device - do_facet ost1 "$LCTL set_param -n osd*.*OST*.force_sync 1" - sleep 5 local ostdev=$(ostdevname 1) local fid=($($LFS getstripe $DIR/$tfile | grep 0x)) @@ -5300,11 +5299,30 @@ test_39r() { local objpath="O/$seq/d$(($oid % 32))/$oid_hex" local cmd="debugfs -c -R \\\"stat $objpath\\\" $ostdev" + # allow atime update to be written to device + do_facet ost1 "$LCTL set_param -n osd*.*OST*.force_sync=1" echo "OST atime: $(do_facet ost1 "$cmd" |& grep atime)" + + # Give enough time for server to get updated. Until then + # the value read is defaulted to "0x00000000:00000000" + # Wait until atime read via debugfs is not equal to zero. + # Max limit to wait is 30 seconds. + wait_update_cond $ahost \ + "$cmd |& awk -F'[: ]' '/atime:/ { print \\\$4 }'" \ + "-gt" "0" 30 || error "atime on ost is still 0 after 30 seconds" + # atime_ost value is in hex local atime_ost=$(do_facet ost1 "$cmd" |& awk -F'[: ]' '/atime:/ { print $4 }') - (( atime_cli == atime_ost )) || - error "atime on client $atime_cli != ost $atime_ost" + # debugfs returns atime in 0xNNNNNNNN:00000000 format + # convert Hex to decimal before comparing + local atime_ost_dec=$((atime_ost)) + + # The test pass criteria is that the client time and server should + # be same (2s gap accepted). This gap could arise due to VFS updating + # the atime after the read(dd), stat and the updated time from the + # inode + (( $((atime_cli - atime_ost_dec)) <= 2 )) || + error "atime on client $atime_cli != ost $atime_ost_dec" } run_test 39r "lazy atime update on OST" -- 1.8.3.1