shell: nfs: $TST_ALL_FILESYSTEMS (.all_filesystems)
Subsystems (2)
cover shell: nfs: $TST_ALL_FILESYSTEMS (.all_filesystems)
Hi,
this is quite ready $TST_ALL_FILESYSTEMS (i.e. support for LTP shell API to run test on all available filesystems, equivalent of .all_filesystems in C API). It's used in NFS tests, where I have questions (RFC).
As it uses testcases/lib/tst_supported_fs.c binary it supports the same features as C API:
* detect supported filesystems
* run only on single filesystem with $LTP_SINGLE_FS_TYPE (debugging)
825e10a91 ("Skip tmpfs in all-filesystem shell tests")
TODO API:
* filtering filesystems when test does not run on certain filesystem
* (i.e. nfs01.sh on vfat) with $TST_SKIP_FILESYSTEMS (equivalent of skip_filesystems variable in C API)
* testcases/lib/tst_supported_fs.c skips tmpfs by default since 825e10a91 ("Skip tmpfs in all-filesystem shell tests"). After implementing $TST_SKIP_FILESYSTEMS it could be removed.
TODO NFS tests:
* Do not require restart NFS server (otherwise legacy testcases/lib/daemonlib.sh would have to be used)
Comments are welcome.
Code is also at: https://github.com/pevik/ltp/tree/shell/all_filesystems.v2
Kind regards,
Petr
Petr Vorel (9):
tst_test.sh: Add $TST_MOUNT_DEVICE
df01.sh: Use TST_MOUNT_DEVICE=1
tst_test.sh: allow ' in pattern for allowed variables
shell: Add test for TST_MOUNT_DEVICE=1 tst_test.sh: Add $TST_ALL_FILESYSTEMS
tst_device: Remove unnecessary braces
tst_device: Add clear command
shell: Add test for TST_ALL_FILESYSTEMS=1
nfs: Use TST_ALL_FILESYSTEMS=1
doc/shell-test-api.txt | 3 + lib/newlib_tests/shell/tst_all_filesystems.sh | 27 +++++ lib/newlib_tests/shell/tst_mount_device.sh | 21 ++++ testcases/commands/df/df01.sh | 5 +- testcases/lib/tst_device.c | 25 ++++- testcases/lib/tst_test.sh | 104 ++++++++++++------ testcases/network/nfs/nfs_stress/nfs_lib.sh | 25 +++-- 7 files changed, 159 insertions(+), 51 deletions(-) create mode 100755 lib/newlib_tests/shell/tst_all_filesystems.sh create mode 100755 lib/newlib_tests/shell/tst_mount_device.sh
Signature · 1 line
2.36.1
PATCH v2 1/9 tst_test.sh: Add $TST_MOUNT_DEVICE
--- doc/shell-test-api.txt | 2 ++ testcases/lib/tst_test.sh | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-)
doc/shell-test-api.txt +2 -0
@@ -214,6 +214,8 @@ simply by setting right '$TST_FOO'. https://github.com/linux-test-project/ltp/wiki/Shell-Test-API#formatting-device-with-a-filesystem[Formatting device with a filesystem]. | 'TST_MNT_PARAMS' | Extra mount params for 'tst_mount', see https://github.com/linux-test-project/ltp/wiki/Shell-Test-API#formatting-device-with-a-filesystem[Formatting device with a filesystem]. +| 'TST_MOUNT_DEVICE' | Mount device, see + https://github.com/linux-test-project/ltp/wiki/Shell-Test-API#mounting-and-unmounting-filesystems[Mounting and unmounting filesystems]. | 'TST_NEEDS_ROOT' | Exit the test with 'TCONF' unless executed under root. Alternatively the 'tst_require_root' command can be used. | 'TST_NEEDS_TMPDIR' | Create test temporary directory and cd into it.
testcases/lib/tst_test.sh +11 -1
@@ -41,6 +41,10 @@ _tst_do_exit() fi fi + if [ "$TST_MOUNT_FLAG" = 1 ]; then + tst_umount + fi + if [ "$TST_NEEDS_DEVICE" = 1 -a "$TST_DEVICE_FLAG" = 1 ]; then if ! tst_device release "$TST_DEVICE"; then tst_res TWARN "Failed to release device '$TST_DEVICE'"
@@ -632,7 +636,7 @@ tst_run() NET_SKIP_VARIABLE_INIT|NEEDS_CHECKPOINTS);; CHECKPOINT_WAIT|CHECKPOINT_WAKE);; CHECKPOINT_WAKE2|CHECKPOINT_WAKE_AND_WAIT);; - DEV_EXTRA_OPTS|DEV_FS_OPTS|FORMAT_DEVICE);; + DEV_EXTRA_OPTS|DEV_FS_OPTS|FORMAT_DEVICE|MOUNT_DEVICE);; *) tst_res TWARN "Reserved variable TST_$_tst_i used!";; esac done
@@ -666,6 +670,7 @@ tst_run() _tst_setup_timer + [ "$TST_MOUNT_DEVICE" = 1 ] && TST_FORMAT_DEVICE=1 [ "$TST_FORMAT_DEVICE" = 1 ] && TST_NEEDS_DEVICE=1 [ "$TST_NEEDS_DEVICE" = 1 ] && TST_NEEDS_TMPDIR=1
@@ -702,6 +707,11 @@ tst_run() tst_mkfs $TST_FS_TYPE $TST_DEV_FS_OPTS $TST_DEVICE $TST_DEV_EXTRA_OPTS fi + if [ "$TST_MOUNT_DEVICE" = 1 ]; then + tst_mount + TST_MOUNT_FLAG=1 + fi + [ -n "$TST_NEEDS_CHECKPOINTS" ] && _tst_init_checkpoints if [ -n "$TST_SETUP" ]; then
Signature · 1 line
2.36.1
PATCH v2 2/9 df01.sh: Use TST_MOUNT_DEVICE=1
In reply to Petr Vorel--- testcases/commands/df/df01.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
testcases/commands/df/df01.sh +2 -3
@@ -1,19 +1,19 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0-or-later # Copyright (c) 2015 Fujitsu Ltd. +# Copyright (c) 2018-2022 Petr Vorel <[email protected]> # Author: Zhang Jin <[email protected]> # # Test df command with some basic options. TST_CNT=12 TST_SETUP=setup -TST_CLEANUP=tst_umount TST_TESTFUNC=test TST_OPTS="f:" TST_USAGE=usage TST_PARSE_ARGS=parse_args TST_NEEDS_ROOT=1 -TST_FORMAT_DEVICE=1 +TST_MOUNT_DEVICE=1 usage() {
@@ -34,7 +34,6 @@ parse_args() setup() { - tst_mount DF_FS_TYPE=$(mount | grep "$TST_DEVICE" | awk 'NR==1{print $5}') }
Signature · 1 line
2.36.1
PATCH v2 3/9 tst_test.sh: allow ' in pattern for allowed variables
In reply to Petr Vorelto allow using '... $TST_FOO'
i.e. without filtering 'EXPECT_PASS "grep '$TST_MNTPOINT $TST_FS_TYPE' /proc/mounts" would produce warning:tst_mount_device 1 TWARN: Reserved variable TST_FS_TYPE' used! because sed filters it as: FS_TYPE'
Will be needed for next commit.
--- testcases/lib/tst_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/lib/tst_test.sh +1 -1
@@ -621,7 +621,7 @@ tst_run() local _tst_name if [ -n "$TST_TEST_PATH" ]; then - for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[="} \t\/:`].*//'); do + for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[='\''"} \t\/:`].*//'); do case "$_tst_i" in DISABLE_APPARMOR|DISABLE_SELINUX);; SETUP|CLEANUP|TESTFUNC|ID|CNT|MIN_KVER);;
Signature · 1 line
2.36.1
Re: [LTP] [PATCH v2 3/9] tst_test.sh: allow ' in pattern for allowed variables
PATCH v2 4/9 shell: Add test for TST_MOUNT_DEVICE=1
In reply to Petr VorelUnfortunately GitHub Actions don't have loop devices, thus cannot be run in CI:
tst_format_device 1 TINFO: timeout per run is 0h 5m 0s /__w/ltp/ltp/lib/tst_device.c:139: TINFO: No free devices found
--- lib/newlib_tests/shell/tst_mount_device.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 lib/newlib_tests/shell/tst_mount_device.sh
lib/newlib_tests/shell/tst_mount_device.sh new file +21 -0
@@ -0,0 +1,21 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Petr Vorel <[email protected]> + +TST_MOUNT_DEVICE=1 +TST_FS_TYPE=ext4 +TST_TESTFUNC=test +TST_CNT=2 + +test1() +{ + EXPECT_PASS "cd $TST_MNTPOINT" +} + +test2() +{ + EXPECT_PASS "grep '$TST_MNTPOINT $TST_FS_TYPE' /proc/mounts" +} + +. tst_test.sh +tst_run
Signature · 1 line
2.36.1
Re: [PATCH v2 4/9] shell: Add test for TST_MOUNT_DEVICE=1
Hi all,
FYI merged up to this patch, the rest (the actual $TST_ALL_FILESYSTEMS) will go in v3.
Kind regards,
Petr
PATCH v2 5/9 tst_test.sh: Add $TST_ALL_FILESYSTEMS
In reply to Petr Vorel--- doc/shell-test-api.txt | 1 + testcases/lib/tst_test.sh | 106 ++++++++++++++++++++++++-------------- 2 files changed, 69 insertions(+), 38 deletions(-)
doc/shell-test-api.txt +1 -0
@@ -199,6 +199,7 @@ simply by setting right '$TST_FOO'. [options="header"] |============================================================================= | Variable name | Action done +| 'TST_ALL_FILESYSTEMS' | Testing on all available filesystems (tst_test.all_filesystems equivalent). | 'TST_DEV_EXTRA_OPTS' | Pass extra 'mkfs' options _after_ device name, to 'tst_mkfs', use with 'TST_FORMAT_DEVICE=1'. | 'TST_DEV_FS_OPTS' | Pass 'mkfs' options _before_ the device name,
testcases/lib/tst_test.sh +68 -38
179 lines not on this page · raw message
Signature · 1 line
2.36.1
Re: [LTP] [PATCH v2 5/9] tst_test.sh: Add $TST_ALL_FILESYSTEMS
Hi!
Quoted 36 lines
(quoted diff) +11
-8+_tst_run_iterations() +{ + local _tst_i=$TST_ITERATIONS - if [ "$TST_MOUNT_DEVICE" = 1 ]; then - tst_mount - TST_MOUNT_FLAG=1 - fi + [ "$TST_NEEDS_TMPDIR" = 1 ] && cd "$TST_TMPDIR" - [ -n "$TST_NEEDS_CHECKPOINTS" ] && _tst_init_checkpoints + _tst_setup_timer if [ -n "$TST_SETUP" ]; then if command -v $TST_SETUP >/dev/null 2>/dev/null; then@@ -724,7 +741,7 @@ tst_run() fi #TODO check that test reports some results for each test function call - while [ $TST_ITERATIONS -gt 0 ]; do + while [ $_tst_i -gt 0 ]; do if [ -n "$TST_TEST_DATA" ]; then tst_require_cmds cut tr wc _tst_max=$(( $(echo $TST_TEST_DATA | tr -cd "$TST_TEST_DATA_IFS" | wc -c) +1))@@ -735,9 +752,22 @@ tst_run() else _tst_run_tests fi - TST_ITERATIONS=$((TST_ITERATIONS-1)) + _tst_i=$((_tst_i-1)) done - _tst_do_exit + + if [ -n "$TST_DO_CLEANUP" -a -n "$TST_CLEANUP" -a -z "$TST_NO_CLEANUP" ]; then + if command -v $TST_CLEANUP >/dev/null 2>/dev/null; then + $TST_CLEANUP
Review tst_run() · line 770
Quoted 10 lines
(quoted diff) +10
-0+ else + tst_res TWARN "TST_CLEANUP=$TST_CLEANUP declared, but function not defined (or cmd not found)" + fi + fi + + if [ "$TST_MOUNT_FLAG" = 1 ]; then + tst_umount + fi + + _tst_cleanup_timer
Generally the code looks good, there is still a minor difference between C API and this changes though. As we do call the _tst_cleanup_timer at the end of this function the script runs without a timeout for a short while (which includes tst_mkfs call).
I guess that instead of stopping the timer at the end of the _tst_run_iterations() we can simply reset it (on the top of this patch):
testcases/lib/tst_test.sh +11 -3
@@ -50,6 +50,8 @@ _tst_do_exit() rm $LTP_IPC_PATH fi + _tst_cleanup_timer + if [ $TST_FAIL -gt 0 ]; then ret=$((ret|1)) fi
@@ -552,6 +554,12 @@ _tst_setup_timer() done } +_tst_reset_timer() +{ + _tst_cleanup_timer + _tst_setup_timer +} + tst_require_root() { if [ "$(id -ru)" != 0 ]; then
@@ -665,6 +673,8 @@ tst_run() tst_brk TBROK "Number of iterations (-i) must be >= 0" fi + _tst_setup_timer + [ "$TST_NEEDS_ROOT" = 1 ] && tst_require_root [ "$TST_DISABLE_APPARMOR" = 1 ] && tst_disable_apparmor
@@ -729,8 +739,6 @@ _tst_run_iterations() [ "$TST_NEEDS_TMPDIR" = 1 ] && cd "$TST_TMPDIR" - _tst_setup_timer - if [ -n "$TST_SETUP" ]; then if command -v $TST_SETUP >/dev/null 2>/dev/null; then TST_DO_CLEANUP=1
@@ -767,7 +775,7 @@ _tst_run_iterations() tst_umount fi - _tst_cleanup_timer + _tst_reset_timer }
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 5/9] tst_test.sh: Add $TST_ALL_FILESYSTEMS
Hi Cyril,
Quoted 7 lines
Generally the code looks good, there is still a minor difference between C API and this changes though. As we do call the
_tst_cleanup_timerat the end of this function the script runs without a timeout for a short while (which includestst_mkfscall).I guess that instead of stopping the timer at the end of the
_tst_run_iterations()we can simply reset it (on the top of this patch):
Good catch, thanks for providing a patch.
LGTM, I'll have a deeper look later.
Kind regards,
Petr
Re: [PATCH v2 5/9] tst_test.sh: Add $TST_ALL_FILESYSTEMS
In reply to Petr VorelHi all,
I wonder if we want to sort filesystems:
-for _tst_fs in $(tst_supported_fs); do
+for _tst_fs in $(tst_supported_fs | sort); do
or even -u (as uniq).
Martin used it in testcases/misc/lvm/prepare_lvm.sh, but IMHO it should not be
needed: looping over fs_type_whitelist() should be always the same.
FS_LIST=tst_supported_fs | sort -u
Therefore I'd remove it (don't use unnecessary dependencies - be nice for people with minimal environment):
Kind regards,
Petr
PATCH v2 6/9 tst_device: Remove unnecessary braces
In reply to Petr Vorelto keep checkpatch.pl happy.
--- testcases/lib/tst_device.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
testcases/lib/tst_device.c +2 -3
@@ -40,11 +40,10 @@ static int acquire_device(int argc, char *argv[]) } } -if (argc >=4 ) { +if (argc >=4 ) device =tst_acquire_loop_device (size, argv[3 ]); - }else { +else device =tst_acquire_device__ (size); - }if (!device)return 1 ;
Signature · 1 line
2.36.1
Re: [LTP] [PATCH v2 6/9] tst_device: Remove unnecessary braces
PATCH v2 7/9 tst_device: Add clear command
In reply to Petr Vorelclearing block device will be needed for TST_ALL_FILESYSTEMS implementation in shell API. Now we clear device during acquire, but we will reuse this device for each tested filesystem, thus we need a separate command for it.
--- testcases/lib/tst_device.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
testcases/lib/tst_device.c +18 -2
@@ -18,8 +18,10 @@ static struct tst_test test = {static void print_help (void ) { -fprintf (stderr,"\nUsage: tst_device acquire [size [filename]]\n" ); -fprintf (stderr," or: tst_device release /path/to/device\n\n" ); +fprintf (stderr,"\nUsage:\n" ); +fprintf (stderr,"tst_device acquire [size [filename]]\n" ); +fprintf (stderr,"tst_device release /path/to/device\n" ); +fprintf (stderr,"tst_device clear /path/to/device\n\n" ); }static int acquire_device (int argc,char *argv[])
@@ -72,6 +74,17 @@ static int release_device(int argc, char *argv[])return tst_detach_device (argv[2 ]); } +static int clear_device (int argc,char *argv[]) +{ +if (argc !=3 ) +return 1 ; + +if (tst_clear_device (argv[2 ])) +return 1 ; + +return 0 ; +} +int main (int argc,char *argv[]) {/*
@@ -94,6 +107,9 @@ int main(int argc, char *argv[]) }else if (!strcmp (argv[1 ],"release" )) {if (release_device (argc, argv)) goto help; + }else if (!strcmp (argv[1 ],"clear" )) { +if (clear_device (argc, argv)) + goto help; }else {fprintf (stderr,"ERROR: Invalid COMMAND '%s'\n" , argv[1 ]); goto help;
Signature · 1 line
2.36.1
Re: [LTP] [PATCH v2 7/9] tst_device: Add clear command
Hi!
Looks good, but should go before the "add: $TST_ALL_FILESYSTEMS" right?
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 8/9 shell: Add test for TST_ALL_FILESYSTEMS=1
In reply to Petr VorelUnfortunately GitHub Actions don't have loop devices, thus cannot be run in CI:
tst_format_device 1 TINFO: timeout per run is 0h 5m 0s /__w/ltp/ltp/lib/tst_device.c:139: TINFO: No free devices found
--- lib/newlib_tests/shell/tst_all_filesystems.sh | 27 +++++++++++++++++++ testcases/lib/tst_test.sh | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100755 lib/newlib_tests/shell/tst_all_filesystems.sh
lib/newlib_tests/shell/tst_all_filesystems.sh new file +27 -0
@@ -0,0 +1,27 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Petr Vorel <[email protected]> + +TST_ALL_FILESYSTEMS=1 +TST_TESTFUNC=test +TST_CNT=2 + +test1() +{ + tst_res TPASS "device using filesystem" +} + +test2() +{ + local pattern + + + if [ "$TST_FS_TYPE" = "exfat" -o "$TST_FS_TYPE" = "ntfs" ]; then + pattern="|fuseblk" + fi + + EXPECT_PASS "grep -E '$TST_MNTPOINT ($TST_FS_TYPE${pattern})' /proc/mounts" +} + +. tst_test.sh +tst_run
testcases/lib/tst_test.sh +1 -1
@@ -603,7 +603,7 @@ _tst_init_checkpoints() _prepare_device() { if [ "$TST_FORMAT_DEVICE" = 1 ]; then - tst_clear_device $TST_DEVICE + tst_device clear "$TST_DEVICE" tst_mkfs $TST_FS_TYPE $TST_DEV_FS_OPTS $TST_DEVICE $TST_DEV_EXTRA_OPTS fi
Signature · 1 line
2.36.1
Re: [LTP] [PATCH v2 8/9] shell: Add test for TST_ALL_FILESYSTEMS=1
Hi Petr,
Nice work! For patches 1/9~8/9:
Signature · 2 lines
Regards, Li Wang
Signature · 2 lines
-- Mailing list info: https://lists.linux.it/listinfo/ltp
RFC PATCH v2 9/9 nfs: Use TST_ALL_FILESYSTEMS=1
In reply to Petr Vorel---
Hi NFS developers,
your comments are welcome. This is an effort how to support NFS tests on all filesystems available on SUT. Using $TST_MNTPOINT means test run in loop, each time different filesystem is used. It's implemented via formatted loop device (the same way as in LTP C API).
Code is also at: https://github.com/pevik/ltp/tree/shell/all_filesystems.v2
But this requires restarting NFS server (otherwise legacy testcases/lib/daemonlib.sh would have to be used), which is IMHO not optimal.
Without that (or only run 'systemctl reload nfs-server' or exportfs -r on remote side) it cannot be umounted after testing - debugging with fuser, code at:
https://github.com/pevik/ltp/commit/3656d035d43445a107154ef397ef1db2fad2c4f0
The problem is that loop device is still referenced by nfs server and thus cannot be unmounted. Can this be somehow fixed? Is it even wanted to have tests on loop device (the only reasonable way to support more filesystems)? Also tests will run much longer (we could filter out some filesystems not supported, if there are any).
# LTP_SINGLE_FS_TYPE=ext2 PATH="/opt/ltp/testcases/bin:$PATH" nfs07.sh -v 3 -t tcp -i3
## NOTE: testing itself is OK
nfs07 1 TINFO: initialize 'lhost' 'ltp_ns_veth2' interface
nfs07 1 TINFO: add local addr 10.0.0.2/24
nfs07 1 TINFO: add local addr fd00:1:1:1::2/64
nfs07 1 TINFO: initialize 'rhost' 'ltp_ns_veth1' interface
nfs07 1 TINFO: add remote addr 10.0.0.1/24
nfs07 1 TINFO: add remote addr fd00:1:1:1::1/64
nfs07 1 TINFO: Network config (local -- remote):
nfs07 1 TINFO: ltp_ns_veth2 -- ltp_ns_veth1
nfs07 1 TINFO: 10.0.0.2/24 -- 10.0.0.1/24
nfs07 1 TINFO: fd00:1:1:1::2/64 -- fd00:1:1:1::1/64
tst_device.c:89: TINFO: Found free device 0 '/dev/loop0'
tst_supported_fs_types.c:148: TINFO: WARNING: testing only ext2
tst_supported_fs_types.c:89: TINFO: Kernel supports ext2
tst_supported_fs_types.c:51: TINFO: mkfs.ext2 does exist
nfs07 1 TINFO: Testing on ext2
nfs07 1 TINFO: Formatting ext2 with opts='/dev/loop0'
nfs07 1 TINFO: timeout per run is 0h 5m 0s
nfs07 1 TINFO: mount.nfs: (linux nfs-utils 2.6.1)
nfs07 1 TINFO: setup NFSv3, socket type tcp
nfs07 1 TINFO: Mounting NFS: mount -v -t nfs -o proto=tcp,vers=3 10.0.0.2:/tmp/LTP_nfs07.A3PIB82iUv/mntpoint/3/tcp /tmp/LTP_nfs07.A3PIB82iUv/mntpoint/3/0 nfs07 1 TPASS: All files and directories were correctly listed
nfs07 2 TPASS: All files and directories were correctly listed
nfs07 3 TPASS: All files and directories were correctly listed
nfs07 4 TINFO: Cleaning up testcase
## DEBUGGING CODE in nfs_cleanup()
nfs07 4 TINFO: fuser -mv /tmp/LTP_nfs07.P1XS9smc5w ($TST_TMPDIR)
USER PID ACCESS COMMAND/tmp/LTP_nfs07.P1XS9smc5w:
root kernel mount /tmp
root 2125 ..c.. tst_timeout_kil
nfs07 4 TINFO: fuser -mv /tmp/LTP_nfs07.P1XS9smc5w/mntpoint ($TST_MNTPOINT)
USER PID ACCESS COMMAND/tmp/LTP_nfs07.P1XS9smc5w/mntpoint:
root kernel mount /tmp/LTP_nfs07.P1XS9smc5w/mntpoint
nfs07 4 TINFO: fuser -mv /tmp/LTP_nfs07.P1XS9smc5w/mntpoint/3/0
USER PID ACCESS COMMAND/tmp/LTP_nfs07.P1XS9smc5w/mntpoint/3/0:
root kernel mount /tmp/LTP_nfs07.P1XS9smc5w/mntpoint/3/0
## from nfs_cleanup()
## grep -q "$local_dir" /proc/mounts && umount $local_dir nfs07 4 TINFO: umount /tmp/LTP_nfs07.P1XS9smc5w/mntpoint/3/0
umount: /tmp/LTP_nfs07.P1XS9smc5w/mntpoint: target is busy.
## The rest is not relevant as the problem is above
## tst_umount from tst_test.sh trying hard to umount
nfs07 4 TINFO: umount(/tmp/LTP_nfs07.P1XS9smc5w/mntpoint) failed, try 1 ... nfs07 4 TINFO: Likely gvfsd-trash is probing newly mounted fs, kill it to speed up tests.
umount: /tmp/LTP_nfs07.P1XS9smc5w/mntpoint: target is busy.
nfs07 4 TINFO: umount(/tmp/LTP_nfs07.P1XS9smc5w/mntpoint) failed, try 2 ... nfs07 4 TINFO: Likely gvfsd-trash is probing newly mounted fs, kill it to speed up tests.
...
nfs07 4 TINFO: umount(/tmp/LTP_nfs07.P1XS9smc5w/mntpoint) failed, try 50 ... nfs07 4 TINFO: Likely gvfsd-trash is probing newly mounted fs, kill it to speed up tests. nfs07 4 TWARN: Failed to umount(/tmp/LTP_nfs07.P1XS9smc5w/mntpoint) after 50 retries
## if ! tst_device release "$TST_DEVICE"; then in _tst_do_exit() in tst_test.sh tst_device.c:255: TWARN: ioctl(/dev/loop1, LOOP_CLR_FD, 0) no ENXIO for too long
Usagetst_device acquire [size [filename]]tst_device release /path/to/device
tst_device clear /path/to/device
## rm -r "$TST_TMPDIR" in _tst_do_exit() in tst_test.sh
nfs07 4 TWARN: Failed to release device '/dev/loop1'
rm: cannot remove '/tmp/LTP_nfs07.P1XS9smc5w/mntpoint': Device or resource busy
rm: cannot remove '/tmp/LTP_nfs07.P1XS9smc5w/mntpoint': Device or resource busy nfs07 4 TINFO: AppArmor enabled, this may affect test results
nfs07 4 TINFO: it can be disabled with TST_DISABLE_APPARMOR=1 (requires super/root) nfs07 4 TINFO: loaded AppArmor profiles: none
Kind regards,
Petr
testcases/network/nfs/nfs_stress/nfs_lib.sh | 25 ++++++++++++--------- 1 file changed, 14 insertions(+), 11 deletions(-)
testcases/network/nfs/nfs_stress/nfs_lib.sh +14 -11
@@ -28,7 +28,7 @@ NFS_PARSE_ARGS_CALLER="$TST_PARSE_ARGS" TST_OPTS="v:t:$TST_OPTS" TST_PARSE_ARGS=nfs_parse_args TST_USAGE=nfs_usage -TST_NEEDS_TMPDIR=1 +TST_ALL_FILESYSTEMS=1 TST_NEEDS_ROOT=1 TST_NEEDS_CMDS="$TST_NEEDS_CMDS mount exportfs mount.nfs" TST_SETUP="${TST_SETUP:-nfs_setup}"
@@ -63,7 +63,7 @@ nfs_get_remote_path() done v=${1:-$v} - echo "$TST_TMPDIR/$v/$type" + echo "$TST_MNTPOINT/$v/$type" } nfs_server_udp_enabled()
@@ -162,8 +162,8 @@ nfs_setup() tst_brk TCONF "UDP support disabled on NFS server" fi - local_dir="$TST_TMPDIR/$i/$n" - remote_dir="$TST_TMPDIR/$i/$type" + local_dir="$TST_MNTPOINT/$i/$n" + remote_dir="$TST_MNTPOINT/$i/$type" mkdir -p $local_dir nfs_setup_server $(($$ + n))
@@ -174,7 +174,7 @@ nfs_setup() done if [ "$n" -eq 1 ]; then - cd ${VERSION}/0 + cd $TST_MNTPOINT/$VERSION/0 fi }
@@ -190,19 +190,22 @@ nfs_cleanup() local n=0 for i in $VERSION; do - local_dir="$TST_TMPDIR/$i/$n" - grep -q "$local_dir" /proc/mounts && umount $local_dir + type=$(get_socket_type $n) + remote_dir="$TST_MNTPOINT/$i/$type" + tst_rhost_run -c "test -d $remote_dir && exportfs -u *:$remote_dir" + tst_rhost_run -c "test -d $remote_dir && rm -rf $remote_dir" n=$(( n + 1 )) done n=0 for i in $VERSION; do - type=$(get_socket_type $n) - remote_dir="$TST_TMPDIR/$i/$type" - tst_rhost_run -c "test -d $remote_dir && exportfs -u *:$remote_dir" - tst_rhost_run -c "test -d $remote_dir && rm -rf $remote_dir" + local_dir="$TST_MNTPOINT/$i/$n" + + grep -q "$local_dir" /proc/mounts && umount $local_dir n=$(( n + 1 )) done + + systemctl restart nfs-server } . tst_net.sh
Signature · 1 line
2.36.1
Re: [LTP] [RFC][PATCH v2 9/9] nfs: Use TST_ALL_FILESYSTEMS=1
Quoted 74 lines · Petr Vorel
Signed-off-by Petr Vorel <[email protected]>---
Hi NFS developers,your comments are welcome. This is an effort how to support NFS tests on all filesystems available on SUT. Using $TST_MNTPOINT means test run in loop, each time different filesystem is used. It's implemented via formatted loop device (the same way as in LTP C API).
Code is also at:
https://github.com/pevik/ltp/tree/shell/all_filesystems.v2But this requires restarting NFS server (otherwise legacy
testcases/lib/daemonlib.sh
would have to be used), which is IMHO not optimal.Without that (or only run 'systemctl reload nfs-server' or exportfs -r on remote side) it cannot be umounted after testing - debugging with fuser, code at:
https://github.com/pevik/ltp/commit/3656d035d43445a107154ef397ef1db2fad2c4f0
The problem is that loop device is still referenced by nfs server and thus cannot be unmounted. Can this be somehow fixed? Is it even wanted to have tests on loop device (the only reasonable way to support more filesystems)? Also tests will run much longer (we could filter out some filesystems not supported, if there are any).
# LTP_SINGLE_FS_TYPE=ext2 PATH="/opt/ltp/testcases/bin:$PATH"
nfs07.sh-v
3 -t tcp -i3
## NOTE: testing itself is OK
nfs07 1 TINFO: initialize 'lhost' 'ltp_ns_veth2' interface
nfs07 1 TINFO: add local addr 10.0.0.2/24
nfs07 1 TINFO: add local addr fd00:1:1:1::2/64
nfs07 1 TINFO: initialize 'rhost' 'ltp_ns_veth1' interface
nfs07 1 TINFO: add remote addr 10.0.0.1/24
nfs07 1 TINFO: add remote addr fd00:1:1:1::1/64
nfs07 1 TINFO: Network config (local -- remote):
nfs07 1 TINFO:ltp_ns_veth2--ltp_ns_veth1
nfs07 1 TINFO: 10.0.0.2/24 -- 10.0.0.1/24
nfs07 1 TINFO: fd00:1:1:1::2/64 -- fd00:1:1:1::1/64
tst_device.c:89: TINFO: Found free device 0 '/dev/loop0'
tst_supported_fs_types.c:148: TINFO: WARNING: testing only ext2
tst_supported_fs_types.c:89: TINFO: Kernel supports ext2
tst_supported_fs_types.c:51: TINFO: mkfs.ext2 does exist
nfs07 1 TINFO: Testing on ext2
nfs07 1 TINFO: Formatting ext2 with opts='/dev/loop0'
nfs07 1 TINFO: timeout per run is 0h 5m 0s
nfs07 1 TINFO: mount.nfs: (linux nfs-utils 2.6.1)
nfs07 1 TINFO: setup NFSv3, socket type tcp
nfs07 1 TINFO: Mounting NFS: mount -v -t nfs -o proto=tcp,vers=3 10.0.0.2:/tmp/LTP_nfs07.A3PIB82iUv/mntpoint/3/tcp/tmp/LTP_nfs07.A3PIB82iUv/mntpoint/3/0
nfs07 1 TPASS: All files and directories were correctly listed
nfs07 2 TPASS: All files and directories were correctly listed
nfs07 3 TPASS: All files and directories were correctly listed
nfs07 4 TINFO: Cleaning up testcase## DEBUGGING CODE in
nfs_cleanup()
nfs07 4 TINFO: fuser -mv/tmp/LTP_nfs07.P1XS9smc5w($TST_TMPDIR)
USER PID ACCESS COMMAND/tmp/LTP_nfs07.P1XS9smc5w:
root kernel mount /tmp
root 2125 ..c..tst_timeout_kil
nfs07 4 TINFO: fuser -mv/tmp/LTP_nfs07.P1XS9smc5w/mntpoint($TST_MNTPOINT)
USER PID ACCESS COMMAND/tmp/LTP_nfs07.P1XS9smc5w/mntpoint:
root kernel mount/tmp/LTP_nfs07.P1XS9smc5w/mntpoint
nfs07 4 TINFO: fuser -mv/tmp/LTP_nfs07.P1XS9smc5w/mntpoint/3/0
USER PID ACCESS COMMAND/tmp/LTP_nfs07.P1XS9smc5w/mntpoint/3/0:
root kernel mount/tmp/LTP_nfs07.P1XS9smc5w/mntpoint/3/0
Quoted 5 lines
## from
nfs_cleanup()
## grep -q "$local_dir"/proc/mounts&& umount $local_dir nfs07 4 TINFO: umount/tmp/LTP_nfs07.P1XS9smc5w/mntpoint/3/0
umount:/tmp/LTP_nfs07.P1XS9smc5w/mntpoint: target is busy.
Maybe try with umount -fl?
unmount manual says:
-f, --force force unmount (in case of an unreachable NFS system)
-l, --lazy detach the filesystem now, clean up things later
Signature · 2 lines
Regards, Li Wang
Signature · 2 lines
-- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [RFC][PATCH v2 9/9] nfs: Use TST_ALL_FILESYSTEMS=1
Quoted 76 lines · Petr Vorel
Quoted 74 lines
Signed-off-by Petr Vorel <[email protected]>---
Hi NFS developers,your comments are welcome. This is an effort how to support NFS tests on all filesystems available on SUT. Using $TST_MNTPOINT means test run in loop, each time different filesystem is used. It's implemented via formatted loop device (the same way as in LTP C API).
Code is also at:
https://github.com/pevik/ltp/tree/shell/all_filesystems.v2But this requires restarting NFS server (otherwise legacy
testcases/lib/daemonlib.sh
would have to be used), which is IMHO not optimal.Without that (or only run 'systemctl reload nfs-server' or exportfs -r on remote side) it cannot be umounted after testing - debugging with fuser, code at:
https://github.com/pevik/ltp/commit/3656d035d43445a107154ef397ef1db2fad2c4f0
The problem is that loop device is still referenced by nfs server and thus cannot be unmounted. Can this be somehow fixed? Is it even wanted to have tests on loop device (the only reasonable way to support more filesystems)? Also tests will run much longer (we could filter out some filesystems not supported, if there are any).
# LTP_SINGLE_FS_TYPE=ext2 PATH="/opt/ltp/testcases/bin:$PATH"
nfs07.sh-v
3 -t tcp -i3
## NOTE: testing itself is OK
nfs07 1 TINFO: initialize 'lhost' 'ltp_ns_veth2' interface
nfs07 1 TINFO: add local addr 10.0.0.2/24
nfs07 1 TINFO: add local addr fd00:1:1:1::2/64
nfs07 1 TINFO: initialize 'rhost' 'ltp_ns_veth1' interface
nfs07 1 TINFO: add remote addr 10.0.0.1/24
nfs07 1 TINFO: add remote addr fd00:1:1:1::1/64
nfs07 1 TINFO: Network config (local -- remote):
nfs07 1 TINFO:ltp_ns_veth2--ltp_ns_veth1
nfs07 1 TINFO: 10.0.0.2/24 -- 10.0.0.1/24
nfs07 1 TINFO: fd00:1:1:1::2/64 -- fd00:1:1:1::1/64
tst_device.c:89: TINFO: Found free device 0 '/dev/loop0'
tst_supported_fs_types.c:148: TINFO: WARNING: testing only ext2
tst_supported_fs_types.c:89: TINFO: Kernel supports ext2
tst_supported_fs_types.c:51: TINFO: mkfs.ext2 does exist
nfs07 1 TINFO: Testing on ext2
nfs07 1 TINFO: Formatting ext2 with opts='/dev/loop0'
nfs07 1 TINFO: timeout per run is 0h 5m 0s
nfs07 1 TINFO: mount.nfs: (linux nfs-utils 2.6.1)
nfs07 1 TINFO: setup NFSv3, socket type tcp
nfs07 1 TINFO: Mounting NFS: mount -v -t nfs -o proto=tcp,vers=3 10.0.0.2:/tmp/LTP_nfs07.A3PIB82iUv/mntpoint/3/tcp/tmp/LTP_nfs07.A3PIB82iUv/mntpoint/3/0
nfs07 1 TPASS: All files and directories were correctly listed
nfs07 2 TPASS: All files and directories were correctly listed
nfs07 3 TPASS: All files and directories were correctly listed
nfs07 4 TINFO: Cleaning up testcase## DEBUGGING CODE in
nfs_cleanup()
nfs07 4 TINFO: fuser -mv/tmp/LTP_nfs07.P1XS9smc5w($TST_TMPDIR)
USER PID ACCESS COMMAND/tmp/LTP_nfs07.P1XS9smc5w:
root kernel mount /tmp
root 2125 ..c..tst_timeout_kil
nfs07 4 TINFO: fuser -mv/tmp/LTP_nfs07.P1XS9smc5w/mntpoint($TST_MNTPOINT)
USER PID ACCESS COMMAND/tmp/LTP_nfs07.P1XS9smc5w/mntpoint:
root kernel mount/tmp/LTP_nfs07.P1XS9smc5w/mntpoint
nfs07 4 TINFO: fuser -mv/tmp/LTP_nfs07.P1XS9smc5w/mntpoint/3/0
USER PID ACCESS COMMAND/tmp/LTP_nfs07.P1XS9smc5w/mntpoint/3/0:
root kernel mount/tmp/LTP_nfs07.P1XS9smc5w/mntpoint/3/0
Quoted 7 lines
Quoted 4 lines
## from
nfs_cleanup()
## grep -q "$local_dir"/proc/mounts&& umount $local_dir nfs07 4 TINFO: umount/tmp/LTP_nfs07.P1XS9smc5w/mntpoint/3/0
umount:/tmp/LTP_nfs07.P1XS9smc5w/mntpoint: target is busy.Maybe try with
umount -fl?
Thank you! Unfortunately it does not work (I tried this before ending up with restarting server because even -fl did not help).
I also consider the need of 'umount -fl' as kind of error just less aggressive then restarting server. But if this is considered ok, why not.
Kind regards,
Petr
Quoted 3 lines
unmount manual says:
-f, --force force unmount (in case of an unreachable NFS system)
-l, --lazy detach the filesystem now, clean up things later
Re: [LTP] [RFC][PATCH v2 9/9] nfs: Use TST_ALL_FILESYSTEMS=1
In reply to Petr VorelHi!
Review
Quoted 2 lines
(quoted diff) +2
-0+ + systemctl restart nfs-server
I wonder do we stil have to care for systems without systemd?
We do have daemonlib.sh in LTP that has restart_daemon() function that branches to systemctl|service|/etc/init.d/ that is used by a few tests.
Signature · 2 lines
Cyril Hrubis [email protected]
Re: [LTP] [RFC][PATCH v2 9/9] nfs: Use TST_ALL_FILESYSTEMS=1
Hi all,
Quoted 3 lines
testcases/network/nfs/nfs_stress/nfs_lib.sh nfs_cleanup() · line 208
Quoted 1 line
testcases/network/nfs/nfs_stress/nfs_lib.sh +1
-0+ systemctl restart nfs-serverI wonder do we stil have to care for systems without systemd?
That'd be a question for embedded people. I myself wonder if they all moved to systemd. But at least Alpine and Buildroot distros allow to use Busybox as init, thus I'd still care.
Quoted 2 lines
We do have
daemonlib.shin LTP that hasrestart_daemon()function that branches to systemctl|service|/etc/init.d/ that is used by a few tests.
That's exactly what I'm planning to use.
Kind regards,
Petr