2023-05-04 13:16:54

by Petr Vorel

[permalink] [raw]
Subject: [PATCH v5 0/5] NFS: test on btrfs, ext4, xfs filesystems

Hi,

changes v4->v5:
* test only on btrfs, ext4, xfs instead on all available filesystems
This increases coverage but minimises the runtime (compare to running on
all available filesystems) => should be safer to commit now, before git
freeze.
* increase sleep to 2 sec after first umount (to avoid "device in use")
* new commit to fix not enough space on nfs03.sh
TODO: better handling space

NOTE: this patchset also fixes problem with device in use in case
somebody used TMPDIR on mounted loop device on current master (without
TST_ALL_FILESYSTEMS=1).

Petr Vorel (5):
nfs_lib.sh: Cleanup local and remote directories setup
nfs_lib.sh: Unexport on proper side on netns
nfs05.sh: Lower down the default values
nfs03.sh: Lower down the default values
nfs: Run on btrfs, ext4, xfs

testcases/network/nfs/nfs_stress/nfs03.sh | 4 +-
testcases/network/nfs/nfs_stress/nfs05.sh | 6 +-
testcases/network/nfs/nfs_stress/nfs_lib.sh | 73 +++++++++++++++------
3 files changed, 57 insertions(+), 26 deletions(-)

--
2.40.0


2023-05-04 13:16:54

by Petr Vorel

[permalink] [raw]
Subject: [PATCH v5 2/5] nfs_lib.sh: Unexport on proper side on netns

f6b267055 changed exportfs run locally on netns, therefore unexporting
should be also run at the same namespace. This is not problematic now,
but will be a problem with TST_ALL_FILESYSTEMS=1, which is sensitive for
timing.

Fixes: f6b267055 ("nfs_lib.sh: run exportfs at "server side" in LTP_NETNS case")

Signed-off-by: Petr Vorel <[email protected]>
---
testcases/network/nfs/nfs_stress/nfs_lib.sh | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/testcases/network/nfs/nfs_stress/nfs_lib.sh b/testcases/network/nfs/nfs_stress/nfs_lib.sh
index 1b5604ab5..042fea5e4 100644
--- a/testcases/network/nfs/nfs_stress/nfs_lib.sh
+++ b/testcases/network/nfs/nfs_stress/nfs_lib.sh
@@ -215,8 +215,16 @@ nfs_cleanup()
for i in $VERSION; do
type=$(get_socket_type $n)
remote_dir="$(get_remote_dir $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"
+
+ if tst_net_use_netns; then
+ if test -d $remote_dir; then
+ exportfs -u *:$remote_dir
+ rm -rf $remote_dir
+ fi
+ else
+ tst_rhost_run -c "test -d $remote_dir && exportfs -u *:$remote_dir"
+ tst_rhost_run -c "test -d $remote_dir && rm -rf $remote_dir"
+ fi
n=$(( n + 1 ))
done
}
--
2.40.0

2023-05-04 13:16:54

by Petr Vorel

[permalink] [raw]
Subject: [PATCH v5 1/5] nfs_lib.sh: Cleanup local and remote directories setup

Logic for creating local and remote directories was on more places.
Create get_local_dir() and get_remote_dir() functions to keep it on
single place.

local dir is needed in nfs_mount(), but was defined in nfs_setup()
and reused local variable with shell inheritance (ugly!), because there
were all parameters from loop. Similarly, remote dir is needed in
both nfs_mount() and nfs_setup_server(), but created with shell
inheritance in nfs_setup(). Pass these params to nfs_mount() and
nfs_setup_server() and define variables with new functions
get_local_dir() and get_remote_dir().

Use get_remote_dir() in nfs_get_remote_path().

Move cd to local directory to the end of nfs_mount() (it used to cd
after nfs_mount(), but only if -v parameter contained single version,
but it does not harm to always cd).

Signed-off-by: Petr Vorel <[email protected]>
---
testcases/network/nfs/nfs_stress/nfs_lib.sh | 52 ++++++++++++++-------
1 file changed, 34 insertions(+), 18 deletions(-)

diff --git a/testcases/network/nfs/nfs_stress/nfs_lib.sh b/testcases/network/nfs/nfs_stress/nfs_lib.sh
index af7d46a21..1b5604ab5 100644
--- a/testcases/network/nfs/nfs_stress/nfs_lib.sh
+++ b/testcases/network/nfs/nfs_stress/nfs_lib.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
-# Copyright (c) Linux Test Project, 2016-2022
+# Copyright (c) Linux Test Project, 2016-2023
# Copyright (c) 2015-2018 Oracle and/or its affiliates. All Rights Reserved.
# Copyright (c) International Business Machines Corp., 2001

@@ -53,6 +53,24 @@ get_socket_type()
done
}

+# directory mounted by NFS client
+get_local_dir()
+{
+ local v="$1"
+ local n="$2"
+
+ echo "$TST_TMPDIR/$v/$n"
+}
+
+# directory on NFS server
+get_remote_dir()
+{
+ local v="$1"
+ local n="$2"
+
+ echo "$TST_TMPDIR/$v/$n"
+}
+
nfs_get_remote_path()
{
local v
@@ -63,7 +81,7 @@ nfs_get_remote_path()
done

v=${1:-$v}
- echo "$TST_TMPDIR/$v/$type"
+ echo "$(get_remote_dir $v $type)"
}

nfs_server_udp_enabled()
@@ -78,8 +96,8 @@ nfs_server_udp_enabled()

nfs_setup_server()
{
-
- local fsid="$1"
+ local remote_dir="$1"
+ local fsid="$2"
local export_cmd="exportfs -i -o fsid=$fsid,no_root_squash,rw *:$remote_dir"

[ -z "$fsid" ] && tst_brk TBROK "empty fsid"
@@ -97,10 +115,14 @@ nfs_setup_server()

nfs_mount()
{
- local opts="$1"
+ local local_dir="$1"
+ local remote_dir="$2"
+ local opts="$3"
local host_type=rhost
local mount_dir

+ mkdir -p "$local_dir"
+
tst_net_use_netns && host_type=

if [ $TST_IPV6 ]; then
@@ -131,6 +153,8 @@ nfs_mount()

tst_brk TBROK "mount command failed"
fi
+
+ cd "$local_dir"
}

nfs_setup()
@@ -162,20 +186,12 @@ nfs_setup()
tst_brk TCONF "UDP support disabled on NFS server"
fi

- local_dir="$TST_TMPDIR/$i/$n"
- remote_dir="$TST_TMPDIR/$i/$type"
- mkdir -p $local_dir
-
- nfs_setup_server $(($$ + n))
-
- nfs_mount "-o proto=$type,vers=$i"
+ remote_dir="$(get_remote_dir $i $type)"
+ nfs_setup_server "$remote_dir" "$(($$ + n))"
+ nfs_mount "$(get_local_dir $i $n)" "$remote_dir" "-o proto=$type,vers=$i"

n=$(( n + 1 ))
done
-
- if [ "$n" -eq 1 ]; then
- cd ${VERSION}/0
- fi
}

nfs_cleanup()
@@ -190,7 +206,7 @@ nfs_cleanup()

local n=0
for i in $VERSION; do
- local_dir="$TST_TMPDIR/$i/$n"
+ local_dir="$(get_local_dir $i $n)"
grep -q "$local_dir" /proc/mounts && umount $local_dir
n=$(( n + 1 ))
done
@@ -198,7 +214,7 @@ nfs_cleanup()
n=0
for i in $VERSION; do
type=$(get_socket_type $n)
- remote_dir="$TST_TMPDIR/$i/$type"
+ remote_dir="$(get_remote_dir $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 ))
--
2.40.0

2023-05-04 13:17:13

by Petr Vorel

[permalink] [raw]
Subject: [PATCH v5 3/5] nfs05.sh: Lower down the default values

nfs05_make_tree.c runs make which needs on Btrfs quite a lot of
temporary space. This is a preparation for the next commit which
start using all filesystems via TST_ALL_FILESYSTEMS=1. Currently we use
300 MB, which was not enough for Btrfs:

Filesystem Type Size Used Avail Use% Mounted on
/dev/loop0 btrfs 300M 62M 20K 100% /tmp/LTP_nfs05.Vau10kcszO/mntpoint

More space is required on ppc64le (higher page size ?).

Proper solution would be to detect available size in nfs05_make_tree.c
and lower down values based on free space.

Signed-off-by: Petr Vorel <[email protected]>
---
testcases/network/nfs/nfs_stress/nfs05.sh | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/testcases/network/nfs/nfs_stress/nfs05.sh b/testcases/network/nfs/nfs_stress/nfs05.sh
index c18ef1ab4..760b585e4 100755
--- a/testcases/network/nfs/nfs_stress/nfs05.sh
+++ b/testcases/network/nfs/nfs_stress/nfs05.sh
@@ -8,9 +8,9 @@
#
# Created by: Robbie Williamson ([email protected])

-DIR_NUM=${DIR_NUM:-"10"}
-FILE_NUM=${FILE_NUM:-"30"}
-THREAD_NUM=${THREAD_NUM:-"8"}
+DIR_NUM=${DIR_NUM:-"5"}
+FILE_NUM=${FILE_NUM:-"20"}
+THREAD_NUM=${THREAD_NUM:-"5"}
TST_NEEDS_CMDS="make gcc"
TST_TESTFUNC="do_test"

--
2.40.0

2023-05-04 13:17:15

by Petr Vorel

[permalink] [raw]
Subject: [PATCH v5 4/5] nfs03.sh: Lower down the default values

Needed for tmpfs on ppc64le:

nfs03 7 TINFO: Cleaning up testcase
nfs03 7 TINFO: === Testing on tmpfs ===
nfs03 7 TINFO: Skipping mkfs for TMPFS filesystem
nfs03 7 TINFO: Mounting device: mount -t tmpfs /dev/loop0 /tmp/LTP_nfs03.5oEyxwo5nP/mntpoint
nfs03 7 TINFO: timeout per run is 0h 15m 0s
nfs03 7 TINFO: mount.nfs: (linux nfs-utils 2.1.1)
nfs03 7 TINFO: setup NFSv3, socket type udp
nfs03 7 TINFO: Mounting NFS: mount -v -t nfs -o proto=udp,vers=3 10.0.0.2:/tmp/LTP_nfs03.5oEyxwo5nP/mntpoint/3/udp /tmp/LTP_nfs03.5oEyxwo5nP/3/0
nfs03 7 TINFO: Setting server side nfsd count to 1
nfs03 7 TINFO: Multiple processes creating and deleting files
nfs03 7 TINFO: creating dir1 subdirectories & files
nfs03 7 TINFO: make '100' directories
nfs03 7 TINFO: creating dir2 subdirectories & files
nfs03 7 TINFO: make '100' directories
nfs03 7 TINFO: cd dir1 & removing files
touch: cannot touch 'file5464': No space left on device
nfs03 7 TBROK: touch file5464 failed
touch: cannot touch 'file5364': No space left on device
nfs03 7 TBROK: touch file5364 failed
nfs03 7 TINFO: nfs03 7 Cleaning up testcase
TINFO: Cleaning up testcase

Signed-off-by: Petr Vorel <[email protected]>
---
testcases/network/nfs/nfs_stress/nfs03.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/testcases/network/nfs/nfs_stress/nfs03.sh b/testcases/network/nfs/nfs_stress/nfs03.sh
index e5f4de67c..5884bb9b9 100755
--- a/testcases/network/nfs/nfs_stress/nfs03.sh
+++ b/testcases/network/nfs/nfs_stress/nfs03.sh
@@ -8,8 +8,8 @@ TST_CLEANUP="nfs03_cleanup"
TST_SETUP="nfs03_setup"
TST_TESTFUNC="do_test"

-DIR_NUM=${DIR_NUM:-"100"}
-FILE_NUM=${FILE_NUM:-"100"}
+DIR_NUM=${DIR_NUM:-"80"}
+FILE_NUM=${FILE_NUM:-"80"}
THREAD_NUM=${THREAD_NUM:-"1"}
ORIG_NFSD=

--
2.40.0

2023-05-04 13:17:16

by Petr Vorel

[permalink] [raw]
Subject: [PATCH v5 5/5] nfs: Run on btrfs, ext4, xfs

because there are some problems with at least vfat, exfat and tmpfs (on
nfs-utils < 2) instead of testing on all available filesystems, test
just on modern Linux filesystems btrfs, ext4, xfs.

Use variables:
* TST_ALL_FILESYSTEMS=1 to run on all filesystems
* TST_FORMAT_DEVICE=1 to get loop device formatted
* TST_MOUNT_DEVICE=1 to get it mounted

Filesystems (tested the usual LTP way on loop device) are used for
server side (exportfs), client side (NFS mount) is kept outside of it.

For some reason umounting needs some time before NFS server stops using
underlying loop device. Also exportfs needs time before files can be
removed. Otherwise second umounting fails:

nfs07 4 TINFO: Cleaning up testcase
umount: /var/tmp/LTP_nfs07.FNZ7yCbqZe/mntpoint: target is busy.
nfs07 4 TINFO: umount(/var/tmp/LTP_nfs07.FNZ7yCbqZe/mntpoint) failed, try 1 ...
nfs07 4 TINFO: Likely gvfsd-trash is probing newly mounted fs, kill it to speed up tests.
umount: /var/tmp/LTP_nfs07.FNZ7yCbqZe/mntpoint: target is busy.

Solved with adding sleep for 2 sec after first umount and sleeps for 1 sec after exportfs.
Second umount of the loop device in tst_test.sh works without any extra
sleep.

Signed-off-by: Petr Vorel <[email protected]>
---
testcases/network/nfs/nfs_stress/nfs_lib.sh | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/testcases/network/nfs/nfs_stress/nfs_lib.sh b/testcases/network/nfs/nfs_stress/nfs_lib.sh
index 042fea5e4..abf7ba5a2 100644
--- a/testcases/network/nfs/nfs_stress/nfs_lib.sh
+++ b/testcases/network/nfs/nfs_stress/nfs_lib.sh
@@ -28,7 +28,10 @@ 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_SKIP_FILESYSTEMS="exfat,ext2,ext3,fuse,ntfs,vfat,tmpfs"
+TST_MOUNT_DEVICE=1
+TST_FORMAT_DEVICE=1
TST_NEEDS_ROOT=1
TST_NEEDS_CMDS="$TST_NEEDS_CMDS mount exportfs mount.nfs"
TST_SETUP="${TST_SETUP:-nfs_setup}"
@@ -68,7 +71,7 @@ get_remote_dir()
local v="$1"
local n="$2"

- echo "$TST_TMPDIR/$v/$n"
+ echo "$TST_MNTPOINT/$v/$n"
}

nfs_get_remote_path()
@@ -210,6 +213,7 @@ nfs_cleanup()
grep -q "$local_dir" /proc/mounts && umount $local_dir
n=$(( n + 1 ))
done
+ sleep 2

n=0
for i in $VERSION; do
@@ -219,12 +223,15 @@ nfs_cleanup()
if tst_net_use_netns; then
if test -d $remote_dir; then
exportfs -u *:$remote_dir
+ sleep 1
rm -rf $remote_dir
fi
else
tst_rhost_run -c "test -d $remote_dir && exportfs -u *:$remote_dir"
+ sleep 1
tst_rhost_run -c "test -d $remote_dir && rm -rf $remote_dir"
fi
+
n=$(( n + 1 ))
done
}
--
2.40.0

2023-05-04 14:03:23

by Cyril Hrubis

[permalink] [raw]
Subject: Re: [PATCH v5 1/5] nfs_lib.sh: Cleanup local and remote directories setup

Hi!
> Signed-off-by: Petr Vorel <[email protected]>
> ---
> testcases/network/nfs/nfs_stress/nfs_lib.sh | 52 ++++++++++++++-------
> 1 file changed, 34 insertions(+), 18 deletions(-)
>
> diff --git a/testcases/network/nfs/nfs_stress/nfs_lib.sh b/testcases/network/nfs/nfs_stress/nfs_lib.sh
> index af7d46a21..1b5604ab5 100644
> --- a/testcases/network/nfs/nfs_stress/nfs_lib.sh
> +++ b/testcases/network/nfs/nfs_stress/nfs_lib.sh
> @@ -1,6 +1,6 @@
> #!/bin/sh
> # SPDX-License-Identifier: GPL-2.0-or-later
> -# Copyright (c) Linux Test Project, 2016-2022
> +# Copyright (c) Linux Test Project, 2016-2023
> # Copyright (c) 2015-2018 Oracle and/or its affiliates. All Rights Reserved.
> # Copyright (c) International Business Machines Corp., 2001
>
> @@ -53,6 +53,24 @@ get_socket_type()
> done
> }
>
> +# directory mounted by NFS client
> +get_local_dir()
> +{
> + local v="$1"
> + local n="$2"
> +
> + echo "$TST_TMPDIR/$v/$n"
> +}
> +
> +# directory on NFS server
> +get_remote_dir()
> +{
> + local v="$1"
> + local n="$2"
> +
> + echo "$TST_TMPDIR/$v/$n"
> +}

It's a bit puzzling why we have two identical functions with a different
name...

--
Cyril Hrubis
[email protected]

2023-05-04 14:09:52

by Cyril Hrubis

[permalink] [raw]
Subject: Re: [PATCH v5 5/5] nfs: Run on btrfs, ext4, xfs

Hi!
> nfs_get_remote_path()
> @@ -210,6 +213,7 @@ nfs_cleanup()
> grep -q "$local_dir" /proc/mounts && umount $local_dir
> n=$(( n + 1 ))
> done
> + sleep 2
>
> n=0
> for i in $VERSION; do
> @@ -219,12 +223,15 @@ nfs_cleanup()
> if tst_net_use_netns; then
> if test -d $remote_dir; then
> exportfs -u *:$remote_dir
> + sleep 1
> rm -rf $remote_dir
> fi
> else
> tst_rhost_run -c "test -d $remote_dir && exportfs -u *:$remote_dir"
> + sleep 1
> tst_rhost_run -c "test -d $remote_dir && rm -rf $remote_dir"
> fi
> +
> n=$(( n + 1 ))
> done

Generally I'm not happy about the sleeps in the code, the main problem
is that the test still may fail in a case that something was slower than
usuall and we decided to proceed after we slept for a pre-defined
interval. Ideally these should be replaced with a active waiting, i.e.
loop that checks some condition 10 times in a second or so. Hoewever I'm
okay with getting this in so that we manage to have these tests in
before the release and fixing it later on.

--
Cyril Hrubis
[email protected]

2023-05-04 21:28:38

by Petr Vorel

[permalink] [raw]
Subject: Re: [PATCH v5 1/5] nfs_lib.sh: Cleanup local and remote directories setup

Hi Cyril,

...
> > +# directory mounted by NFS client
> > +get_local_dir()
> > +{
> > + local v="$1"
> > + local n="$2"
> > +
> > + echo "$TST_TMPDIR/$v/$n"
> > +}
> > +
> > +# directory on NFS server
> > +get_remote_dir()
> > +{
> > + local v="$1"
> > + local n="$2"
> > +
> > + echo "$TST_TMPDIR/$v/$n"
> > +}

> It's a bit puzzling why we have two identical functions with a different
> name...

It's a preparation for TST_ALL_FILESYSTEMS=1 where the location changes.
I can squash this into that commit where it changes.

Kind regards,
Petr

2023-05-04 22:02:40

by Petr Vorel

[permalink] [raw]
Subject: Re: [PATCH v5 5/5] nfs: Run on btrfs, ext4, xfs

> Hi!
> > nfs_get_remote_path()
> > @@ -210,6 +213,7 @@ nfs_cleanup()
> > grep -q "$local_dir" /proc/mounts && umount $local_dir
> > n=$(( n + 1 ))
> > done
> > + sleep 2

> > n=0
> > for i in $VERSION; do
> > @@ -219,12 +223,15 @@ nfs_cleanup()
> > if tst_net_use_netns; then
> > if test -d $remote_dir; then
> > exportfs -u *:$remote_dir
> > + sleep 1
> > rm -rf $remote_dir
> > fi
> > else
> > tst_rhost_run -c "test -d $remote_dir && exportfs -u *:$remote_dir"
> > + sleep 1
> > tst_rhost_run -c "test -d $remote_dir && rm -rf $remote_dir"
> > fi
> > +
> > n=$(( n + 1 ))
> > done

> Generally I'm not happy about the sleeps in the code, the main problem
> is that the test still may fail in a case that something was slower than
> usuall and we decided to proceed after we slept for a pre-defined
> interval. Ideally these should be replaced with a active waiting, i.e.
> loop that checks some condition 10 times in a second or so. Hoewever I'm
> okay with getting this in so that we manage to have these tests in
> before the release and fixing it later on.

I wonder myself what is wrong and if there is a problem with my code (likely) or
with nfsd or with loop device (Christoph Hellwig has been changing
drivers/block/loop.c quite a lot).

Because if first umount is too early, it does not recover (i.e. tst_umount
contain 50 times trying to umount with 100ms, and that does not help).

I also wonder how should I detect it's ready to be umounted.
I'll have look if losetup "fuser -vm /dev/loop0" would help, but instead of
depending on the device, we'd probably want to look into /proc/mounts, right?
Tomorrow I'll test this:

check_umount()
{
local i
local dir="$1"
local type="${2:-lhost}"
local cmd="grep -q $dir /proc/mounts"

for i in $(seq 50); do
if [ "$type" = "lhost" ]; then
$cmd || return
else
tst_rhost_run -c "$cmd" || return
fi
tst_sleep 100ms
tst_res TWARN "failed to umount '$dir'"
done
}

for i in $VERSION; do
local_dir="$(get_local_dir $i $n)"
grep -q "$local_dir" /proc/mounts && umount $local_dir

# instead of 'sleep 2' below check here:
check_umount "$local_dir"

n=$(( n + 1 ))
done

n=0
for i in $VERSION; do
type=$(get_socket_type $n)
remote_dir="$(get_remote_dir $i $type)"

if tst_net_use_netns; then
if test -d $remote_dir; then
exportfs -u *:$remote_dir
check_umount "$remote_dir" # instead of sleep 1
rm -rf $remote_dir
fi
else
tst_rhost_run -c "test -d $remote_dir && exportfs -u *:$remote_dir"
check_umount "$remote_dir" rhost # instead of sleep 1
tst_rhost_run -c "test -d $remote_dir && rm -rf $remote_dir"
fi

n=$(( n + 1 ))
done

[1] https://gitlab.com/psmisc/psmisc/-/blob/master/src/fuser.c

2023-05-04 22:04:20

by Petr Vorel

[permalink] [raw]
Subject: Re: [PATCH v5 5/5] nfs: Run on btrfs, ext4, xfs

Hi,

...
> check_umount()
> {
> local i
> local dir="$1"
> local type="${2:-lhost}"
> local cmd="grep -q $dir /proc/mounts"

> for i in $(seq 50); do
> if [ "$type" = "lhost" ]; then
> $cmd || return
> else
> tst_rhost_run -c "$cmd" || return
> fi
> tst_sleep 100ms
> tst_res TWARN "failed to umount '$dir'"
> done
Obviously TWARN should be here.
...

Kind regards,
Petr

2023-05-04 23:47:02

by Petr Vorel

[permalink] [raw]
Subject: Re: [PATCH v5 5/5] nfs: Run on btrfs, ext4, xfs

Hi all,

...
> Tomorrow I'll test this:

> check_umount()
> {
> local i
> local dir="$1"
> local type="${2:-lhost}"
> local cmd="grep -q $dir /proc/mounts"

> for i in $(seq 50); do
> if [ "$type" = "lhost" ]; then
> $cmd || return
> else
> tst_rhost_run -c "$cmd" || return
> fi
> tst_sleep 100ms
> tst_res TWARN "failed to umount '$dir'"
> done
> }

> for i in $VERSION; do
> local_dir="$(get_local_dir $i $n)"
> grep -q "$local_dir" /proc/mounts && umount $local_dir

> # instead of 'sleep 2' below check here:
> check_umount "$local_dir"

> n=$(( n + 1 ))
> done

> n=0
> for i in $VERSION; do
> type=$(get_socket_type $n)
> remote_dir="$(get_remote_dir $i $type)"

> if tst_net_use_netns; then
> if test -d $remote_dir; then
> exportfs -u *:$remote_dir
> check_umount "$remote_dir" # instead of sleep 1
> rm -rf $remote_dir
> fi
> else
> tst_rhost_run -c "test -d $remote_dir && exportfs -u *:$remote_dir"
> check_umount "$remote_dir" rhost # instead of sleep 1
> tst_rhost_run -c "test -d $remote_dir && rm -rf $remote_dir"
> fi

> n=$(( n + 1 ))
> done

I tried various code (not only the one - wrong - above), but nothing works.
With fuser -vm, I wonder if there is some bug in older nfs versions:

USER PID ACCESS COMMAND
/tmp/LTP_nfs08.fncaxJum2W/mntpoint/4/tcp:
root kernel mount /tmp/LTP_nfs08.fncaxJum2W/mntpoint
root kernel knfsd /tmp/LTP_nfs08.fncaxJum2W/mntpoint/4

Looking at c6c7f2a84da4 ("nfsd: Ensure knfsd shuts down when the "nfsd" pseudofs
is unmounted"), maybe there are other bugs, which causes files are used.

I also tried to use /proc/fs/nfsd/unlock_filesystem and
/proc/fs/nfsd/write_unlock_ip which made things better a bit (6.2.12), but still
it's not 100% solution. Also, "Release all locks on a local file system"
(unlock_filesystem) and Release all locks used by a client (write_unlock_ip) are
unlikely what I'm searching.

umount $local_dir
echo "$local_dir" > /proc/fs/nfsd/unlock_filesystem
# $(tst_ipaddr rhost) => IP of the server
echo "$(tst_ipaddr rhost)" > /proc/fs/nfsd/write_unlock_ip
...

exportfs -u *:$remote_dir
echo "$remote_dir" > /proc/fs/nfsd/unlock_filesystem

=> any hint is welcome.

Kind regards,
Petr

2023-05-05 10:45:08

by Cyril Hrubis

[permalink] [raw]
Subject: Re: [PATCH v5 1/5] nfs_lib.sh: Cleanup local and remote directories setup

Hi!
> > It's a bit puzzling why we have two identical functions with a different
> > name...
>
> It's a preparation for TST_ALL_FILESYSTEMS=1 where the location changes.
> I can squash this into that commit where it changes.

That is the missing bit. No need to squash maybe just note that the
directory will change in the last commit of the patchset.

--
Cyril Hrubis
[email protected]

2023-05-05 11:05:14

by Petr Vorel

[permalink] [raw]
Subject: Re: [PATCH v5 1/5] nfs_lib.sh: Cleanup local and remote directories setup

Hi Cyril,

> Hi!
> > > It's a bit puzzling why we have two identical functions with a different
> > > name...

> > It's a preparation for TST_ALL_FILESYSTEMS=1 where the location changes.
> > I can squash this into that commit where it changes.

> That is the missing bit. No need to squash maybe just note that the
> directory will change in the last commit of the patchset.

+1 (I intended and obviously forgot).

Kind regards,
Petr

2023-05-05 11:17:43

by Cyril Hrubis

[permalink] [raw]
Subject: Re: [PATCH v5 5/5] nfs: Run on btrfs, ext4, xfs

Hi!
Let's get this merged with the sleeps for now and lets try to fix it
properly after the release. You can push the patchset with my Ack.

--
Cyril Hrubis
[email protected]

2023-05-05 13:02:12

by Petr Vorel

[permalink] [raw]
Subject: Re: [PATCH v5 4/5] nfs03.sh: Lower down the default values

Hi,

I'm rejecting this patch, because current patchset is not running on tmpfs.
I will double check on ppc64le anyway, when including any more filesystem
to check if size is big enough.

Kind regards,
Petr

2023-05-05 13:10:28

by Petr Vorel

[permalink] [raw]
Subject: Re: [PATCH v5 5/5] nfs: Run on btrfs, ext4, xfs

Hi Cyril,

> Hi!
> Let's get this merged with the sleeps for now and lets try to fix it
> properly after the release. You can push the patchset with my Ack.

Patchset merged, I guess we can freeze LTP before the release.
Thanks!

Kind regards,
Petr