generic: show locks info owned by dead process
authorXiong Murphy Zhou <xzhou@redhat.com>
Thu, 9 Aug 2018 07:53:53 +0000 (15:53 +0800)
committerEryu Guan <guaneryu@gmail.com>
Sun, 12 Aug 2018 14:53:21 +0000 (22:53 +0800)
Regression test case for kernel patchset:
    fs/lock: show locks info owned by dead/invisible processes

Open new fd by exec shell built-in, then require exclusive lock
by flock(1) command. Checking /proc/locks for the lock info.

This patchset post by Konstantin Khorenko <khorenko@virtuozzo.com>
has not been merged v4.18-rc8.

[Eryu: require $FLOCK_PROG and add more comments]

Signed-off-by: Xiong Murphy Zhou <xzhou@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
tests/generic/504 [new file with mode: 0755]
tests/generic/504.out [new file with mode: 0644]
tests/generic/group

diff --git a/tests/generic/504 b/tests/generic/504
new file mode 100755 (executable)
index 0000000..c7d015d
--- /dev/null
@@ -0,0 +1,59 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2018 RedHat Inc.  All Rights Reserved.
+#
+# FS QA Test 504
+#
+# Regression test case for kernel patch:
+# fs/lock: skip lock owner pid translation in case we are in init_pid_ns
+#
+# Open new fd by exec shell built-in, then require exclusive lock
+# by flock(1) command. Checking /proc/locks for the lock info.
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1       # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+       cd /
+       rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_test
+_require_command "$FLOCK_PROG" "flock"
+
+# Create test file and find its inode NO.
+testfile=$TEST_DIR/flock_testfile_$seq
+touch $testfile
+tf_inode=$(stat -c %i $testfile)
+echo inode $tf_inode >> $seqres.full
+
+# Create new fd by exec
+exec 9> $testfile
+# flock locks the fd then exits, we should see the lock info even the owner is dead
+flock -x 9
+cat /proc/locks >> $seqres.full
+
+# Checking
+grep -qw $tf_inode /proc/locks || echo "lock info not found"
+
+# success, all done
+status=0
+echo "Silence is golden"
+exit
diff --git a/tests/generic/504.out b/tests/generic/504.out
new file mode 100644 (file)
index 0000000..d46394b
--- /dev/null
@@ -0,0 +1,2 @@
+QA output created by 504
+Silence is golden
index 79a5705a87bbf5acd851c3bf73dfc7df69651249..55155de8bc299f767c69e086c4780042c7cb615e 100644 (file)
 501 auto quick clone log
 502 auto quick log
 503 auto quick dax punch collapse zero
+504 auto quick locks