Skip to contentSkip to conversation

fstests: new testcases for delegation support

PATCH Superseded Jeff Layton 2 participants 6 messages Nov 19, 2025 – Dec 2, 2025 VFS

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover fstests: new testcases for delegation support

This version of the patchset does a bit of cleanup first, adds a directory delegation test and then a set of tests for file delegations.

Christian has taken the initial directory delegation series into his vfs-6.19.directory.delegations branch [1]. There is a follow-on set of patches to fix some bugs as well [2].

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git/log/?h=vfs-6.19.directory.delegations
[2]: https://lore.kernel.org/linux-fsdevel/[email protected]/

---
Changes in v2:
- Add tests for file delegations
- Clean up after testing whether leases are supported
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Jeff Layton (3):
common/rc: clean up after the _require_test_fcntl_setlease() test
generic: add test for directory delegations
generic: add tests for file delegations

 common/locktest       |  19 +-
 common/rc             |  11 +
 src/locktest.c        | 621 +++++++++++++++++++++++++++++++++++++++++++++++++-
 tests/generic/998     |  22 ++
 tests/generic/998.out |   2 +
 tests/generic/999     |  22 ++
 tests/generic/999.out |   2 +
 7 files changed, 684 insertions(+), 15 deletions(-)

---
base-commit: 5b75444bc9123f261e0aa95f72328af4c827786a
change-id: 20251111-dir-deleg-ff05013ca540

Best regards,

Signature · 1 line
Jeff Layton <[email protected]>
#1 lore raw

PATCH v2 1/3 common/rc: clean up after the _require_test_fcntl_setlease() test

Remove setlease_testfile after validating whether a lease can be set.

---
 common/rc | 1 +
 1 file changed, 1 insertion(+)
common/rc +1 -0
index a10ac17746a3ca4d9aca1d4ce434ccd6f39838b9..116216ca8aeb4e53f3e0d741cc99a050cb3a7462 100644
@@ -4656,6 +4656,7 @@ _require_test_fcntl_setlease()
 	touch $TEST_DIR/setlease_testfile
 	$here/src/locktest -t $TEST_DIR/setlease_testfile >/dev/null 2>&1
 	local ret=$?
+	rm -f $TEST_DIR/setlease_testfile
 	[ $ret -eq 22 ] && _notrun "Require fcntl setlease support"
 	[ "$FSTYP" == "nfs" -a $ret -eq 11 ] && \
 		_notrun "NFS requires delegation before setlease"
Signature · 1 line
2.51.1
#2 lore raw

PATCH v2 2/3 generic: add test for directory delegations

In reply to Jeff Layton

With the advent of directory delegation support coming to the kernel, add support for testing them to the existing locktest.c program, and add testcases for all of the different ways that they can be broken.

---
 common/locktest       |  14 +-
 common/rc             |  10 ++
 src/locktest.c        | 423 ++++++++++++++++++++++++++++++++++++++++++++++++--
 tests/generic/999     |  22 +++
 tests/generic/999.out |   2 +
 5 files changed, 456 insertions(+), 15 deletions(-)
common/locktest +11 -3
index 61e7dd42785dd3d4f21050e10bd5ec9d76a3b15a..609078485dac9358da7298082ad5ca5acada51dc 100644
@@ -6,6 +6,7 @@ SERVER_LOG=$TEST_DIR/server.out
 SERVER_PORT=$TEST_DIR/server.port
 CLIENT_LOG=$TEST_DIR/client.out
 TESTFILE=$TEST_DIR/lock_file
+DELEGDIR=$TEST_DIR/dirdeleg
 client_pid=""
 server_pid=""
 
@@ -13,7 +14,7 @@ _cleanup()
 {
 	kill $client_pid > /dev/null 2>&1
 	kill $server_pid > /dev/null 2>&1
-	rm -f $TESTFILE
+	rm -rf $TESTFILE $DELEGDIR
 }
 
 _dump_logs_fail()
@@ -42,8 +43,6 @@ _run_generic() {
 	rm -f $CLIENT_LOG
 	touch $CLIENT_LOG
 
-	touch $TESTFILE
-
 	# Start the server
 	$here/src/locktest $mode $TESTFILE 2> $SERVER_LOG 1> $SERVER_PORT &
 	server_pid=$!
@@ -87,9 +86,18 @@ _run_generic() {
 }
 
 _run_locktest() {
+	touch $TESTFILE
+
 	_run_generic ""
 }
 
 _run_leasetest() {
+	touch $TESTFILE
+
 	_run_generic "-L"
 }
+
+_run_dirleasetest() {
+	TESTFILE=$DELEGDIR
+	_run_generic "-D"
+}
common/rc +10 -0
index 116216ca8aeb4e53f3e0d741cc99a050cb3a7462..8df2b387a8a85c7dafeea02f9f9422f52a7d0d01 100644
@@ -4662,6 +4662,16 @@ _require_test_fcntl_setlease()
 		_notrun "NFS requires delegation before setlease"
 }
 
+_require_test_fcntl_setdeleg()
+{
+	_require_test_program "locktest"
+	mkdir $TEST_DIR/setdeleg_testdir
+	$here/src/locktest -t -D $TEST_DIR/setdeleg_testdir >/dev/null 2>&1
+	local ret=$?
+	rm -rf $TEST_DIR/setdeleg_testdir
+	[ $ret -eq 22 ] && _notrun "Require fcntl setdeleg support"
+}
+
 _require_ofd_locks()
 {
 	# Give a test run by getlk wrlck on testfile.
src/locktest.c +411 -12

569 lines not on this page · raw message

tests/generic/999 new file +22 -0
new file mode 100755
index 0000000000000000000000000000000000000000..1392e98c937d65d2d6402f1eb5822f22bc265342
@@ -0,0 +1,22 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 Intel, Corp.  All Rights Reserved.
+#
+# FSQA Test No. XXX
+#
+# lease test
+#
+. ./common/preamble
+_begin_fstest auto quick
+
+# Import common functions.
+. ./common/filter
+. ./common/locktest
+
+_require_test
+_require_test_fcntl_advisory_locks
+_require_test_fcntl_setdeleg
+
+_run_dirleasetest
+
+exit
tests/generic/999.out new file +2 -0
new file mode 100644
index 0000000000000000000000000000000000000000..c2a252d46cdcd730cf1ed2c503fa9631e9fcdd06
@@ -0,0 +1,2 @@
+QA output created by 999
+success!
Signature · 1 line
2.51.1
#3 lore raw

Re: [PATCH fstests v2 2/3] generic: add test for directory delegations

Quoted 6 lines · Jeff Layton

With the advent of directory delegation support coming to the kernel, add support for testing them to the existing locktest.c program, and add testcases for all of the different ways that they can be broken.

---

Hi Jeff,

Glad to get you patches to fstests again :)

Quoted 7 lines
 common/locktest       |  14 +-
 common/rc             |  10 ++
 src/locktest.c        | 423 ++++++++++++++++++++++++++++++++++++++++++++++++--
 tests/generic/999     |  22 +++
 tests/generic/999.out |   2 +
 5 files changed, 456 insertions(+), 15 deletions(-)

[snip]

tests/generic/999 line 5

Quoted 11 lines
tests/generic/999 new file +5 -0
new file mode 100755
index 0000000000000000000000000000000000000000..1392e98c937d65d2d6402f1eb5822f22bc265342
@@ -0,0 +1,22 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 Intel, Corp.  All Rights Reserved.
+#
+# FSQA Test No. XXX

FS QA Test No. 999

Please don't change the format which xfstests/new generate. Other script (e.g. tools/mvtest) depends on that :)

Quoted 7 lines
tests/generic/999 new file +7 -0
+#
+# lease test
+#
+. ./common/preamble
+_begin_fstest auto quick
+
+# Import common functions.

tests/generic/999 line 22

Quoted 10 lines
tests/generic/999 new file +10 -0
+. ./common/filter
+. ./common/locktest
+
+_require_test
+_require_test_fcntl_advisory_locks
+_require_test_fcntl_setdeleg
+
+_run_dirleasetest
+
+exit

_exit 0

Oh, I guess you didn't use ./new to create this test case, you copied it from g/131 or g/571. I'd recommend using ./new to create a new test case :)

Quoted 13 lines
tests/generic/999.out new file +2 -0
new file mode 100644
index 0000000000000000000000000000000000000000..c2a252d46cdcd730cf1ed2c503fa9631e9fcdd06
@@ -0,0 +1,2 @@
+QA output created by 999
+success!
Signature · 2 lines
-- 
2.51.1
#4 lore raw

PATCH v2 3/3 generic: add tests for file delegations

In reply to Jeff Layton

Mostly the same ones as leases, but some additional tests to validate that they are broken on metadata changes.

---
 common/locktest       |   5 ++
 src/locktest.c        | 202 +++++++++++++++++++++++++++++++++++++++++++++++++-
 tests/generic/998     |  22 ++++++
 tests/generic/998.out |   2 +
 4 files changed, 229 insertions(+), 2 deletions(-)
common/locktest +5 -0
index 609078485dac9358da7298082ad5ca5acada51dc..7654e9ea792ced93cdf2b35b0ed7f877df76ba84 100644
@@ -101,3 +101,8 @@ _run_dirleasetest() {
 	TESTFILE=$DELEGDIR
 	_run_generic "-D"
 }
+
+_run_filedelegtest() {
+	TESTFILE=$DELEGDIR
+	_run_generic "-F"
+}
src/locktest.c +200 -2

268 lines not on this page · raw message

tests/generic/998 new file +22 -0
new file mode 100755
index 0000000000000000000000000000000000000000..5e7e62137ba3a52c62718f9f674094a107e3edca
@@ -0,0 +1,22 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 Intel, Corp.  All Rights Reserved.
+#
+# FSQA Test No. XXX
+#
+# file delegation test
+#
+. ./common/preamble
+_begin_fstest auto quick
+
+# Import common functions.
+. ./common/filter
+. ./common/locktest
+
+_require_test
+_require_test_fcntl_advisory_locks
+_require_test_fcntl_setdeleg
+
+_run_filedelegtest
+
+exit
tests/generic/998.out new file +2 -0
new file mode 100644
index 0000000000000000000000000000000000000000..b65a7660fea895dc4d60cec8fabe7be1695beabe
@@ -0,0 +1,2 @@
+QA output created by 998
+success!
Signature · 1 line
2.51.1
#5 lore raw

Re: [PATCH fstests v2 3/3] generic: add tests for file delegations

Quoted 11 lines · Jeff Layton

Mostly the same ones as leases, but some additional tests to validate that they are broken on metadata changes.

---
 common/locktest       |   5 ++
 src/locktest.c        | 202 +++++++++++++++++++++++++++++++++++++++++++++++++-
 tests/generic/998     |  22 ++++++
 tests/generic/998.out |   2 +
 4 files changed, 229 insertions(+), 2 deletions(-)

[snip]

Quoted 6 lines
tests/generic/998 new file +0 -0
new file mode 100755
index 0000000000000000000000000000000000000000..5e7e62137ba3a52c62718f9f674094a107e3edca

tests/generic/998 line 10

Quoted 10 lines
tests/generic/998 new file +10 -0
@@ -0,0 +1,22 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 Intel, Corp.  All Rights Reserved.
+#
+# FSQA Test No. XXX
+#
+# file delegation test
+#
+. ./common/preamble
+_begin_fstest auto quick

Same review points with patch 2/3. And I'm wondering if we these common/locktest related test cases should be in "locks" (refer to doc/group-names.txt) group.

Thanks,
Zorro

Quoted 25 lines
tests/generic/998 new file +12 -0
+
+# Import common functions.
+. ./common/filter
+. ./common/locktest
+
+_require_test
+_require_test_fcntl_advisory_locks
+_require_test_fcntl_setdeleg
+
+_run_filedelegtest
+
+exit
tests/generic/998.out new file +2 -0
new file mode 100644
index 0000000000000000000000000000000000000000..b65a7660fea895dc4d60cec8fabe7be1695beabe
@@ -0,0 +1,2 @@
+QA output created by 998
+success!
Signature · 2 lines
-- 
2.51.1