Whamcloud - gitweb
LU-12261 tests: Race between exec and truncate 91/34791/3
authorPatrick Farrell <pfarrell@whamcloud.com>
Wed, 1 May 2019 19:05:37 +0000 (15:05 -0400)
committerAndreas Dilger <adilger@whamcloud.com>
Thu, 2 May 2019 01:17:21 +0000 (01:17 +0000)
Execing '$tdir/sleep' with & doesn't guarantee the file is
actually open before returning, so it is sometimes losing
the race with truncate, resulting in errors like this:
/usr/lib64/lustre/tests/sanity.sh: line 4172:
/mnt/lustre/d43b.sanity/sleep: Text file busy

Where $tdir/sleep gets ETXTBSY, instead of truncate as
expected.

A 1 second delay should be enough to guarantee exec wins
the race vs truncate.

Test-Parameters: trivial
Test-Parameters: testgroup=review-ldiskfs-arm
Test-Parameters: testgroup=review-ldiskfs
Test-Parameters: testgroup=review-ldiskfs-arm

Signed-off-by: Patrick Farrell <pfarrell@whamcloud.com>
Change-Id: Ice6f4567805e64c3be755b6c684b6a086a348dd8
Reviewed-on: https://review.whamcloud.com/34791
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Nunez <jnunez@whamcloud.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/tests/sanity.sh

index 1996346..45cc115 100755 (executable)
@@ -4159,6 +4159,8 @@ test_43a() {
        cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
        $DIR/$tdir/sleep 60 &
        SLEEP_PID=$!
        cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
        $DIR/$tdir/sleep 60 &
        SLEEP_PID=$!
+       # Make sure exec of $tdir/sleep wins race with truncate
+       sleep 1
        $MULTIOP $DIR/$tdir/sleep Oc && error "expected error, got success"
        kill $SLEEP_PID
 }
        $MULTIOP $DIR/$tdir/sleep Oc && error "expected error, got success"
        kill $SLEEP_PID
 }
@@ -4171,6 +4173,8 @@ test_43b() {
        cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
        $DIR/$tdir/sleep 60 &
        SLEEP_PID=$!
        cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
        $DIR/$tdir/sleep 60 &
        SLEEP_PID=$!
+       # Make sure exec of $tdir/sleep wins race with truncate
+       sleep 1
        $TRUNCATE $DIR/$tdir/sleep 0 && error "expected error, got success"
        kill $SLEEP_PID
 }
        $TRUNCATE $DIR/$tdir/sleep 0 && error "expected error, got success"
        kill $SLEEP_PID
 }