Skip to contentSkip to conversation

Tests for AT_HANDLE_CONNECTABLE

PATCH Superseded Amir Goldstein 2 participants 7 messages Apr 9, 2025 – May 9, 2025 VFS

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Tests for AT_HANDLE_CONNECTABLE

Hi Zorro,

This is a test for new flag AT_HANDLE_CONNECTABLE from v6.13. I've had this test for a while, but apparently I forgot to post it. See man page update of this flag here [1].

Thanks,
Amir.

[1] https://lore.kernel.org/linux-fsdevel/[email protected]/

Amir Goldstein (2):
open_by_handle: add support for testing connectable file handles
open_by_handle: add a test for connectable file handles

 common/rc             | 16 +++++++--
 src/open_by_handle.c  | 44 +++++++++++++++++++-----
 tests/generic/777     | 79 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/777.out | 15 ++++++++
 4 files changed, 142 insertions(+), 12 deletions(-)
 create mode 100755 tests/generic/777
 create mode 100644 tests/generic/777.out
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/2 open_by_handle: add support for testing connectable file handles

Test for kernel and filesystem support for conenctable file handles.

With -N flag, encode connectable file handles and fail the test if the kernel or filesystem do not support conenctable file handles.

---
 common/rc            | 16 +++++++++++++---
 src/open_by_handle.c | 44 +++++++++++++++++++++++++++++++++++---------
 2 files changed, 48 insertions(+), 12 deletions(-)
common/rc +13 -3
index 6592c835..6407b744 100644
@@ -3829,8 +3829,14 @@ _require_freeze()
 }
 
 # Does NFS export work on this fs?
-_require_exportfs()
+_require_open_by_handle()
 {
+	local what="NFS export"
+	local opts="$1"
+	if [ "$1" == "-N" ]; then
+		what="connectable file handles"
+	fi
+
 	_require_test_program "open_by_handle"
 
 	# virtiofs doesn't support open_by_handle_at(2) yet, though the syscall
@@ -3841,10 +3847,14 @@ _require_exportfs()
 		_notrun "$FSTYP doesn't support open_by_handle_at(2)"
 
 	mkdir -p "$TEST_DIR"/exportfs_test
-	$here/src/open_by_handle -c "$TEST_DIR"/exportfs_test 2>&1 \
-		|| _notrun "$FSTYP does not support NFS export"
+	$here/src/open_by_handle $opts -c "$TEST_DIR"/exportfs_test 2>&1 \
+		|| _notrun "$FSTYP does not support $what"
 }
 
+_require_exportfs()
+{
+	_require_open_by_handle
+}
 
 # Does shutdown work on this fs?
 _require_scratch_shutdown()
src/open_by_handle.c +35 -9

120 lines not on this page · raw message

Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/2 open_by_handle: add a test for connectable file handles

In reply to Amir Goldstein

This is a variant of generic/477 with connectable file handles. This test uses load and store of file handles from a temp file to test decoding connectable file handles after cycle mount and after renames. Decoding connectable file handles after being moved to a new parent is expected to fail.

---
 tests/generic/777     | 79 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/777.out | 15 ++++++++
 2 files changed, 94 insertions(+)
 create mode 100755 tests/generic/777
 create mode 100644 tests/generic/777.out
tests/generic/777 new file +79 -0
new file mode 100755
index 00000000..52a461c3
@@ -0,0 +1,79 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2018-2025 CTERA Networks. All Rights Reserved.
+#
+# FS QA Test No. 777
+#
+# Check open by connectable file handle after cycle mount.
+#
+# This is a variant of test 477 with connectable file handles.
+# This test uses load and store of file handles from a temp file to test
+# decoding file handles after cycle mount and after directory renames.
+# Decoding connectable file handles after being moved to a new parent
+# is expected to fail.
+#
+. ./common/preamble
+_begin_fstest auto quick exportfs
+
+# Import common functions.
+. ./common/filter
+
+
+# Modify as appropriate.
+_require_test
+# Require connectable file handles support
+_require_open_by_handle -N
+
+NUMFILES=10
+testroot=$TEST_DIR/$seq-dir
+testdir=$testroot/testdir
+
+# Create test dir and test files, encode connectable file handles and store to tmp file
+create_test_files()
+{
+	rm -rf $testdir
+	mkdir -p $testdir
+	$here/src/open_by_handle -N -cwp -o $tmp.handles_file $testdir $NUMFILES
+}
+
+# Decode connectable file handles loaded from tmp file
+test_file_handles()
+{
+	local opt=$1
+	local when=$2
+
+	echo test_file_handles after $when
+	$here/src/open_by_handle $opt -i $tmp.handles_file $TEST_DIR $NUMFILES
+}
+
+# Decode file handles of files/dir after cycle mount
+create_test_files
+_test_cycle_mount
+test_file_handles -rp "cycle mount"
+
+# Decode file handles of files/dir after rename of parent and cycle mount
+create_test_files $testdir
+rm -rf $testdir.renamed
+mv $testdir $testdir.renamed/
+_test_cycle_mount
+test_file_handles -rp "rename parent"
+
+# Decode file handles of files/dir after rename of grandparent and cycle mount
+create_test_files $testdir
+rm -rf $testroot.renamed
+mv $testroot $testroot.renamed/
+_test_cycle_mount
+test_file_handles -rp "rename grandparent"
+
+# Decode file handles of files/dir after move to new parent and cycle mount
+# This is expected to fail because the conectable file handle encodes the
+# old parent.
+create_test_files $testdir
+rm -rf $testdir.new
+mkdir -p $testdir.new
+mv $testdir/* $testdir.new/
+_test_cycle_mount
+test_file_handles -r "move to new parent" | _filter_test_dir
+
+status=0
+exit
tests/generic/777.out new file +15 -0
new file mode 100644
index 00000000..648c480c
@@ -0,0 +1,15 @@
+QA output created by 777
+test_file_handles after cycle mount
+test_file_handles after rename parent
+test_file_handles after rename grandparent
+test_file_handles after move to new parent
+open_by_handle(TEST_DIR/file000000) returned 116 incorrectly on a linked file!
+open_by_handle(TEST_DIR/file000001) returned 116 incorrectly on a linked file!
+open_by_handle(TEST_DIR/file000002) returned 116 incorrectly on a linked file!
+open_by_handle(TEST_DIR/file000003) returned 116 incorrectly on a linked file!
+open_by_handle(TEST_DIR/file000004) returned 116 incorrectly on a linked file!
+open_by_handle(TEST_DIR/file000005) returned 116 incorrectly on a linked file!
+open_by_handle(TEST_DIR/file000006) returned 116 incorrectly on a linked file!
+open_by_handle(TEST_DIR/file000007) returned 116 incorrectly on a linked file!
+open_by_handle(TEST_DIR/file000008) returned 116 incorrectly on a linked file!
+open_by_handle(TEST_DIR/file000009) returned 116 incorrectly on a linked file!
Signature · 1 line
2.34.1
#3 lore raw

Re: [PATCH 2/2] open_by_handle: add a test for connectable file handles

Quoted 8 lines · Amir Goldstein

This is a variant of generic/477 with connectable file handles. This test uses load and store of file handles from a temp file to test decoding connectable file handles after cycle mount and after renames. Decoding connectable file handles after being moved to a new parent is expected to fail.

---

Hi Amir,

This test case fails on some filesystems, e.g. nfs [1] and tmpfs [2]. Is this as your expected?

Thanks,
Zorro

[1]
generic/777 fails on nfs:

777.out.bad renamed from dev/fd/63 +30 -0
@@ -1,7 +1,37 @@
 QA output created by 777
 test_file_handles after cycle mount
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000000) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000001) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000002) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000003) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000004) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000005) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000006) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000007) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000008) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000009) returned 116 incorrectly on a linked file!
 test_file_handles after rename parent
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000000) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000001) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000002) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000003) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000004) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000005) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000006) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000007) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000008) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000009) returned 116 incorrectly on a linked file!
 test_file_handles after rename grandparent
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000000) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000001) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000002) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000003) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000004) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000005) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000006) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000007) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000008) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000009) returned 116 incorrectly on a linked file!
 test_file_handles after move to new parent
 open_by_handle(TEST_DIR/file000000) returned 116 incorrectly on a linked file!
 open_by_handle(TEST_DIR/file000001) returned 116 incorrectly on a linked file!

[2]
generic/777 fails on tmpfs:

777.out.bad renamed from dev/fd/63 +0 -10
@@ -3,13 +3,3 @@
 test_file_handles after rename parent
 test_file_handles after rename grandparent
 test_file_handles after move to new parent
-open_by_handle(TEST_DIR/file000000) returned 116 incorrectly on a linked file!
-open_by_handle(TEST_DIR/file000001) returned 116 incorrectly on a linked file!
-open_by_handle(TEST_DIR/file000002) returned 116 incorrectly on a linked file!
-open_by_handle(TEST_DIR/file000003) returned 116 incorrectly on a linked file!
-open_by_handle(TEST_DIR/file000004) returned 116 incorrectly on a linked file!
-open_by_handle(TEST_DIR/file000005) returned 116 incorrectly on a linked file!
-open_by_handle(TEST_DIR/file000006) returned 116 incorrectly on a linked file!
-open_by_handle(TEST_DIR/file000007) returned 116 incorrectly on a linked file!
-open_by_handle(TEST_DIR/file000008) returned 116 incorrectly on a linked file!
-open_by_handle(TEST_DIR/file000009) returned 116 incorrectly on a linked file!
Quoted 115 lines
 tests/generic/777     | 79 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/777.out | 15 ++++++++
 2 files changed, 94 insertions(+)
 create mode 100755 tests/generic/777
 create mode 100644 tests/generic/777.out
tests/generic/777 new file +79 -0
new file mode 100755
index 00000000..52a461c3
@@ -0,0 +1,79 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2018-2025 CTERA Networks. All Rights Reserved.
+#
+# FS QA Test No. 777
+#
+# Check open by connectable file handle after cycle mount.
+#
+# This is a variant of test 477 with connectable file handles.
+# This test uses load and store of file handles from a temp file to test
+# decoding file handles after cycle mount and after directory renames.
+# Decoding connectable file handles after being moved to a new parent
+# is expected to fail.
+#
+. ./common/preamble
+_begin_fstest auto quick exportfs
+
+# Import common functions.
+. ./common/filter
+
+
+# Modify as appropriate.
+_require_test
+# Require connectable file handles support
+_require_open_by_handle -N
+
+NUMFILES=10
+testroot=$TEST_DIR/$seq-dir
+testdir=$testroot/testdir
+
+# Create test dir and test files, encode connectable file handles and store to tmp file
+create_test_files()
+{
+	rm -rf $testdir
+	mkdir -p $testdir
+	$here/src/open_by_handle -N -cwp -o $tmp.handles_file $testdir $NUMFILES
+}
+
+# Decode connectable file handles loaded from tmp file
+test_file_handles()
+{
+	local opt=$1
+	local when=$2
+
+	echo test_file_handles after $when
+	$here/src/open_by_handle $opt -i $tmp.handles_file $TEST_DIR $NUMFILES
+}
+
+# Decode file handles of files/dir after cycle mount
+create_test_files
+_test_cycle_mount
+test_file_handles -rp "cycle mount"
+
+# Decode file handles of files/dir after rename of parent and cycle mount
+create_test_files $testdir
+rm -rf $testdir.renamed
+mv $testdir $testdir.renamed/
+_test_cycle_mount
+test_file_handles -rp "rename parent"
+
+# Decode file handles of files/dir after rename of grandparent and cycle mount
+create_test_files $testdir
+rm -rf $testroot.renamed
+mv $testroot $testroot.renamed/
+_test_cycle_mount
+test_file_handles -rp "rename grandparent"
+
+# Decode file handles of files/dir after move to new parent and cycle mount
+# This is expected to fail because the conectable file handle encodes the
+# old parent.
+create_test_files $testdir
+rm -rf $testdir.new
+mkdir -p $testdir.new
+mv $testdir/* $testdir.new/
+_test_cycle_mount
+test_file_handles -r "move to new parent" | _filter_test_dir
+
+status=0
+exit
tests/generic/777.out new file +15 -0
new file mode 100644
index 00000000..648c480c
@@ -0,0 +1,15 @@
+QA output created by 777
+test_file_handles after cycle mount
+test_file_handles after rename parent
+test_file_handles after rename grandparent
+test_file_handles after move to new parent
+open_by_handle(TEST_DIR/file000000) returned 116 incorrectly on a linked file!
+open_by_handle(TEST_DIR/file000001) returned 116 incorrectly on a linked file!
+open_by_handle(TEST_DIR/file000002) returned 116 incorrectly on a linked file!
+open_by_handle(TEST_DIR/file000003) returned 116 incorrectly on a linked file!
+open_by_handle(TEST_DIR/file000004) returned 116 incorrectly on a linked file!
+open_by_handle(TEST_DIR/file000005) returned 116 incorrectly on a linked file!
+open_by_handle(TEST_DIR/file000006) returned 116 incorrectly on a linked file!
+open_by_handle(TEST_DIR/file000007) returned 116 incorrectly on a linked file!
+open_by_handle(TEST_DIR/file000008) returned 116 incorrectly on a linked file!
+open_by_handle(TEST_DIR/file000009) returned 116 incorrectly on a linked file!
Signature · 1 line
2.34.1
#4 lore raw

Re: [PATCH 2/2] open_by_handle: add a test for connectable file handles

Quoted 8 lines · Zorro Lang
Quoted 6 lines · Amir Goldstein

This is a variant of generic/477 with connectable file handles. This test uses load and store of file handles from a temp file to test decoding connectable file handles after cycle mount and after renames. Decoding connectable file handles after being moved to a new parent is expected to fail.

Quoted 7 lines
Quoted 2 lines

---

Hi Amir,

This test case fails on some filesystems, e.g. nfs [1] and tmpfs [2]. Is this as your expected?

No. I will look into this failure.
Thanks for testing!

Amir.

Quoted 185 lines

Thanks,
Zorro

[1]
generic/777 fails on nfs:

777.out.bad 2025-05-07 02:44:23.999734558 -0400 renamed from dev/fd/63 2025-05-07 02:44:24.150560533 -0400 +30 -0
@@ -1,7 +1,37 @@
 QA output created by 777
 test_file_handles after cycle mount
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000000) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000001) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000002) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000003) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000004) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000005) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000006) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000007) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000008) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000009) returned 116 incorrectly on a linked file!
 test_file_handles after rename parent
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000000) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000001) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000002) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000003) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000004) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000005) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000006) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000007) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000008) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000009) returned 116 incorrectly on a linked file!
 test_file_handles after rename grandparent
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000000) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000001) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000002) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000003) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000004) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000005) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000006) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000007) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000008) returned 116 incorrectly on a linked file!
+open_by_handle(/mnt/fstests/TEST_DIR/nfs-client/file000009) returned 116 incorrectly on a linked file!
 test_file_handles after move to new parent
 open_by_handle(TEST_DIR/file000000) returned 116 incorrectly on a linked file!
 open_by_handle(TEST_DIR/file000001) returned 116 incorrectly on a linked file!

[2]
generic/777 fails on tmpfs:

777.out.bad 2025-05-07 07:53:25.536434660 -0400 renamed from dev/fd/63 2025-05-07 07:53:26.265453903 -0400 +0 -10
@@ -3,13 +3,3 @@
 test_file_handles after rename parent
 test_file_handles after rename grandparent
 test_file_handles after move to new parent
-open_by_handle(TEST_DIR/file000000) returned 116 incorrectly on a linked file!
-open_by_handle(TEST_DIR/file000001) returned 116 incorrectly on a linked file!
-open_by_handle(TEST_DIR/file000002) returned 116 incorrectly on a linked file!
-open_by_handle(TEST_DIR/file000003) returned 116 incorrectly on a linked file!
-open_by_handle(TEST_DIR/file000004) returned 116 incorrectly on a linked file!
-open_by_handle(TEST_DIR/file000005) returned 116 incorrectly on a linked file!
-open_by_handle(TEST_DIR/file000006) returned 116 incorrectly on a linked file!
-open_by_handle(TEST_DIR/file000007) returned 116 incorrectly on a linked file!
-open_by_handle(TEST_DIR/file000008) returned 116 incorrectly on a linked file!
-open_by_handle(TEST_DIR/file000009) returned 116 incorrectly on a linked file!
Quoted 117 lines

 tests/generic/777     | 79 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/777.out | 15 ++++++++
 2 files changed, 94 insertions(+)
 create mode 100755 tests/generic/777
 create mode 100644 tests/generic/777.out
tests/generic/777 new file +79 -0
new file mode 100755
index 00000000..52a461c3
@@ -0,0 +1,79 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2018-2025 CTERA Networks. All Rights Reserved.
+#
+# FS QA Test No. 777
+#
+# Check open by connectable file handle after cycle mount.
+#
+# This is a variant of test 477 with connectable file handles.
+# This test uses load and store of file handles from a temp file to test
+# decoding file handles after cycle mount and after directory renames.
+# Decoding connectable file handles after being moved to a new parent
+# is expected to fail.
+#
+. ./common/preamble
+_begin_fstest auto quick exportfs
+
+# Import common functions.
+. ./common/filter
+
+
+# Modify as appropriate.
+_require_test
+# Require connectable file handles support
+_require_open_by_handle -N
+
+NUMFILES=10
+testroot=$TEST_DIR/$seq-dir
+testdir=$testroot/testdir
+
+# Create test dir and test files, encode connectable file handles and store to tmp file
+create_test_files()
+{
+     rm -rf $testdir
+     mkdir -p $testdir
+     $here/src/open_by_handle -N -cwp -o $tmp.handles_file $testdir $NUMFILES
+}
+
+# Decode connectable file handles loaded from tmp file
+test_file_handles()
+{
+     local opt=$1
+     local when=$2
+
+     echo test_file_handles after $when
+     $here/src/open_by_handle $opt -i $tmp.handles_file $TEST_DIR $NUMFILES
+}
+
+# Decode file handles of files/dir after cycle mount
+create_test_files
+_test_cycle_mount
+test_file_handles -rp "cycle mount"
+
+# Decode file handles of files/dir after rename of parent and cycle mount
+create_test_files $testdir
+rm -rf $testdir.renamed
+mv $testdir $testdir.renamed/
+_test_cycle_mount
+test_file_handles -rp "rename parent"
+
+# Decode file handles of files/dir after rename of grandparent and cycle mount
+create_test_files $testdir
+rm -rf $testroot.renamed
+mv $testroot $testroot.renamed/
+_test_cycle_mount
+test_file_handles -rp "rename grandparent"
+
+# Decode file handles of files/dir after move to new parent and cycle mount
+# This is expected to fail because the conectable file handle encodes the
+# old parent.
+create_test_files $testdir
+rm -rf $testdir.new
+mkdir -p $testdir.new
+mv $testdir/* $testdir.new/
+_test_cycle_mount
+test_file_handles -r "move to new parent" | _filter_test_dir
+
+status=0
+exit
tests/generic/777.out new file +15 -1
new file mode 100644
index 00000000..648c480c
@@ -0,0 +1,15 @@
+QA output created by 777
+test_file_handles after cycle mount
+test_file_handles after rename parent
+test_file_handles after rename grandparent
+test_file_handles after move to new parent
+open_by_handle(TEST_DIR/file000000) returned 116 incorrectly on a linked file!
+open_by_handle(TEST_DIR/file000001) returned 116 incorrectly on a linked file!
+open_by_handle(TEST_DIR/file000002) returned 116 incorrectly on a linked file!
+open_by_handle(TEST_DIR/file000003) returned 116 incorrectly on a linked file!
+open_by_handle(TEST_DIR/file000004) returned 116 incorrectly on a linked file!
+open_by_handle(TEST_DIR/file000005) returned 116 incorrectly on a linked file!
+open_by_handle(TEST_DIR/file000006) returned 116 incorrectly on a linked file!
+open_by_handle(TEST_DIR/file000007) returned 116 incorrectly on a linked file!
+open_by_handle(TEST_DIR/file000008) returned 116 incorrectly on a linked file!
+open_by_handle(TEST_DIR/file000009) returned 116 incorrectly on a linked file!
--

2.34.1

#5 lore raw

Re: [PATCH 2/2] open_by_handle: add a test for connectable file handles

Quoted 13 lines · Amir Goldstein
Quoted 11 lines · Zorro Lang
Quoted 8 lines · Amir Goldstein

This is a variant of generic/477 with connectable file handles. This test uses load and store of file handles from a temp file to test decoding connectable file handles after cycle mount and after renames. Decoding connectable file handles after being moved to a new parent is expected to fail.

---

Quoted 6 lines
Quoted 4 lines

Hi Amir,

This test case fails on some filesystems, e.g. nfs [1] and tmpfs [2]. Is this as your expected?

No. I will look into this failure.

So what happens is that on filesystems that really get unmounted in mount cycle, trying to open a connectable file handle after file was moved to another parent is expected to fail and this is what the test expects, but tmpfs does not really get unmounted on mount cycle so opening the file handle does work.

Similarly for nfs, the file remains in cache on the local server so opening by handle works.

I have removed that test case in v2 because it is unpredictable and added verification that opened files have a connected path.

Thanks,
Amir.

#6 lore raw
In reply to Amir Goldstein
Quoted 7 lines · Amir Goldstein

Hi Zorro,

This is a test for new flag AT_HANDLE_CONNECTABLE from v6.13. I've had this test for a while, but apparently I forgot to post it. See man page update of this flag here [1].

Ping.

Zorro,

Can you take these patches which add one new test?

Thanks,
Amir.

Quoted 18 lines

[1] https://lore.kernel.org/linux-fsdevel/[email protected]/

Amir Goldstein (2):
open_by_handle: add support for testing connectable file handles
open_by_handle: add a test for connectable file handles

 common/rc             | 16 +++++++--
 src/open_by_handle.c  | 44 +++++++++++++++++++-----
 tests/generic/777     | 79 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/777.out | 15 ++++++++
 4 files changed, 142 insertions(+), 12 deletions(-)
 create mode 100755 tests/generic/777
 create mode 100644 tests/generic/777.out

--
2.34.1