From: Avinesh Kumar via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] nfs_lib: Skip NFS versions disabled on server
Date: Thu, 6 Aug 2026 09:47:12 +0200 [thread overview]
Message-ID: <20260806074713.158271-1-avinesh.kumar@suse.com> (raw)
From: Avinesh Kumar <avinesh.kumar@suse.com>
nfs06.sh mount several NFS versions in a single run
(e.g. "3,4.0,4.1,4.2"). If the server has disabled one of
the requested versions (reported via /proc/fs/nfsd/versions),
the whole test currently aborts with TBROK on the failed mount
instead of continuing with the versions that are supported.
nfs06 1 TINFO: setup NFSv4.0, socket type tcp
nfs06 1 TINFO: Mounting /var/tmp/LTP_nfs06.GHDqCwPYES/4.0/1
nfs06 1 TINFO: Mounting NFS: mount -v -t nfs -o proto=tcp,vers=4.0 10.0.0.2:/var/tmp/LTP_nfs06.GHDqCwPYES/mntpoint/4.0/tcp /var/tmp/LTP_nfs06.GHDqCwPYES/4.0/1
mount.nfs: mount(2): Invalid argument
mount.nfs: an incorrect mount option was specified for /var/tmp/LTP_nfs06.GHDqCwPYES/4.0/1
mount.nfs: timeout set for Wed Aug 5 08:06:38 2026
mount.nfs: trying text-based options 'proto=tcp,vers=4.0,addr=10.0.0.2,clientaddr=10.0.0.1'
nfs06 1 TBROK: mount command failed
Add nfs_server_vers_enabled() to check /proc/fs/nfsd/versions on the
server, and nfs_filter_versions() to drop disabled versions from
$VERSION (keeping $SOCKET_TYPE aligned by position) before mounting.
If none of the requested versions are enabled, TCONF as before.
Signed-off-by: Avinesh Kumar <avinesh.kumar@suse.com>
---
testcases/network/nfs/nfs_stress/nfs_lib.sh | 56 ++++++++++++++++++++-
1 file changed, 54 insertions(+), 2 deletions(-)
diff --git a/testcases/network/nfs/nfs_stress/nfs_lib.sh b/testcases/network/nfs/nfs_stress/nfs_lib.sh
index 8bff3f23ae12..4065b000467e 100644
--- a/testcases/network/nfs/nfs_stress/nfs_lib.sh
+++ b/testcases/network/nfs/nfs_stress/nfs_lib.sh
@@ -55,19 +55,24 @@ TST_NEEDS_DRIVERS="nfsd"
# debugging whether test failures are related to veth/netns).
LTP_NFS_NETNS_USE_LO=${LTP_NFS_NETNS_USE_LO:-}
-get_socket_type()
+get_socket_type_raw()
{
local t
local k=0
for t in $SOCKET_TYPE; do
if [ "$k" -eq "$1" ]; then
- echo "${t}${TST_IPV6}"
+ echo "$t"
return
fi
k=$(( k + 1 ))
done
}
+get_socket_type()
+{
+ echo "$(get_socket_type_raw "$1")${TST_IPV6}"
+}
+
# directory mounted by NFS client
get_local_dir()
{
@@ -109,6 +114,51 @@ nfs_server_udp_enabled()
tst_rhost_run -c "grep -q \"^[# ]*udp *= *y\" /etc/nfs.conf $config"
}
+# nfs_server_vers_enabled VERS
+# Only returns false (1) when the server explicitly lists "-VERS" in
+# /proc/fs/nfsd/versions. If that file is unavailable or doesn't mention
+# VERS at all, defaults to true so the mount is still attempted.
+nfs_server_vers_enabled()
+{
+ local vers="$1"
+ local versions=" $(tst_rhost_run -c 'cat /proc/fs/nfsd/versions 2>/dev/null') "
+
+ case "$versions" in
+ *" -$vers "*) return 1;;
+ esac
+
+ return 0
+}
+
+# Drops NFS versions the server explicitly disabled from $VERSION, keeping
+# $SOCKET_TYPE entries aligned by position with what remains.
+nfs_filter_versions()
+{
+ local v type
+ local n=0
+ local new_version=
+ local new_socket_type=
+
+ for v in $VERSION; do
+ type=$(get_socket_type_raw $n)
+
+ if nfs_server_vers_enabled "$v"; then
+ new_version="$new_version $v"
+ new_socket_type="$new_socket_type $type"
+ else
+ tst_res TINFO "NFSv$v disabled on server, skipping"
+ fi
+
+ n=$(( n + 1 ))
+ done
+
+ [ -z "$new_version" ] && \
+ tst_brk TCONF "none of the requested NFS versions ($VERSION) are enabled on server"
+
+ VERSION="${new_version# }"
+ SOCKET_TYPE="${new_socket_type# }"
+}
+
nfs_setup_server()
{
local remote_dir="$1"
@@ -198,6 +248,8 @@ nfs_setup()
tst_res TINFO "$(mount.nfs -V)"
+ nfs_filter_versions
+
for i in $VERSION; do
type=$(get_socket_type $n)
tst_res TINFO "setup NFSv$i, socket type $type"
--
2.55.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next reply other threads:[~2026-08-06 7:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 7:47 Avinesh Kumar via ltp [this message]
2026-08-06 10:39 ` [LTP] nfs_lib: Skip NFS versions disabled on server linuxtestproject.agent
2026-08-10 10:31 ` [LTP] [PATCH] " Petr Vorel
2026-08-11 8:48 ` Avinesh Kumar via ltp
2026-08-11 9:03 ` Petr Vorel
2026-08-11 9:20 ` [LTP] [PATCH v2] " Avinesh Kumar via ltp
2026-08-11 10:02 ` [LTP] " linuxtestproject.agent
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260806074713.158271-1-avinesh.kumar@suse.com \
--to=ltp@lists.linux.it \
--cc=avinesh.kumar@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.