summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorStas Sergeev <stsp2@yandex.ru>2023-08-01 22:52:19 +0500
committerZorro Lang <zlang@kernel.org>2023-08-19 02:44:54 +0800
commit857c18868a0e34ca140e3162bccc44024c649e12 (patch)
treedb5496f552191f9d66155774b8b9f1d33a4262ee /tests
parent4a78fc26ab16e4fce6f4bc0e8293c70551942792 (diff)
t_ofd_locks: fix stalled semaphore handling
Currently IPC_RMID was attempted on a semid returned after failed semget() with flags=IPC_CREAT|IPC_EXCL. So nothing was actually removed. This patch introduces the much more reliable scheme where the wrapper script creates and removes semaphores, passing a sem key to the test binary via new -K option. This patch speeds up the test ~5 times by removing the sem-awaiting loop in a lock-getter process. As the semaphore is now created before the test process started, there is no need to wait for anything. CC: fstests@vger.kernel.org CC: Murphy Zhou <xzhou@redhat.com> CC: Jeff Layton <jlayton@kernel.org> CC: Zorro Lang <zlang@redhat.com> Signed-off-by: Stas Sergeev <stsp2@yandex.ru> Reviwed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/generic/47837
1 files changed, 33 insertions, 4 deletions
diff --git a/tests/generic/478 b/tests/generic/478
index 480762d2..419acc94 100755
--- a/tests/generic/478
+++ b/tests/generic/478
@@ -99,33 +99,62 @@ _require_ofd_locks
$XFS_IO_PROG -f -c "pwrite -S 0xFF 0 4096" \
$TEST_DIR/testfile >> $seqres.full 2>&1
+mk_sem()
+{
+ SEMID=$(ipcmk -S 2 | cut -d ":" -f 2 | tr -d '[:space:]')
+ if [ -z "$SEMID" ]; then
+ echo "ipcmk failed"
+ exit 1
+ fi
+ SEMKEY=$(ipcs -s | grep $SEMID | cut -d " " -f 1)
+ if [ -z "$SEMKEY" ]; then
+ echo "ipcs failed"
+ exit 1
+ fi
+}
+
+rm_sem()
+{
+ ipcrm -s $SEMID 2>/dev/null
+}
+
do_test()
{
- local soptions="$1"
- local goptions="$2"
+ local soptions
+ local goptions
# print options and getlk output for debug
echo $* >> $seqres.full 2>&1
+ mk_sem
+ soptions="$1 -K $SEMKEY"
+ goptions="$2 -K $SEMKEY"
# -s : do setlk
$here/src/t_ofd_locks $soptions $TEST_DIR/testfile &
# -g : do getlk
$here/src/t_ofd_locks $goptions $TEST_DIR/testfile | \
tee -a $seqres.full
wait $!
+ rm_sem
+ mk_sem
# add -F to clone with CLONE_FILES
- soptions="$1 -F"
+ soptions="$1 -F -K $SEMKEY"
+ goptions="$2 -K $SEMKEY"
# with -F, new locks are always file to place
$here/src/t_ofd_locks $soptions $TEST_DIR/testfile &
$here/src/t_ofd_locks $goptions $TEST_DIR/testfile | \
tee -a $seqres.full
wait $!
+ rm_sem
+ mk_sem
# add -d to dup and close
- soptions="$1 -d"
+ soptions="$1 -d -K $SEMKEY"
+ goptions="$2 -K $SEMKEY"
$here/src/t_ofd_locks $soptions $TEST_DIR/testfile &
$here/src/t_ofd_locks $goptions $TEST_DIR/testfile | \
tee -a $seqres.full
wait $!
+ rm_sem
}
# Always setlk at range [0,9], getlk at range [0,9] [5,24] or [20,29].