Skip to contentSkip to conversation

network/nfs: support default setup, use local mount

PATCH New Alexey Kodanev 2 participants 3 messages Oct 9, 2018 – Oct 15, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 network/nfs: support default setup, use local mount

For default setup, start the server locally instead and mount inside netns to run NFS traffic over the veth or whatever is used for a single machine setup.

We could also use lo interface, we just need to skip the last check in nfs_mount()/nfs_lib.sh.

---
 testcases/network/nfs/nfs_stress/nfs_lib.sh |   63 +++++++++++++++++++--------
 1 files changed, 44 insertions(+), 19 deletions(-)
testcases/network/nfs/nfs_stress/nfs_lib.sh +44 -19
index 7e11dc4..28b73e1 100644
@@ -46,6 +46,47 @@ get_socket_type()
 	done
 }
 
+nfs_setup_server()
+{
+	local export_cmd="exportfs -i -o no_root_squash,rw *:$remote_dir"
+
+	if [ -n "$LTP_NETNS" ]; then
+		if [ ! -d $remote_dir ]; then
+			mkdir -p $remote_dir
+			ROD $export_cmd
+		fi
+		return
+	fi
+
+	if ! tst_rhost_run -c "test -d $remote_dir"; then
+		tst_rhost_run -s -c "mkdir -p $remote_dir; $export_cmd"
+	fi
+}
+
+nfs_mount()
+{
+	local host_type=rhost
+	local mount_dir
+
+	[ -n "$LTP_NETNS" ] && host_type=
+
+	if [ $TST_IPV6 ]; then
+		mount_dir="[$(tst_ipaddr $host_type)]:$remote_dir"
+	else
+		mount_dir="$(tst_ipaddr $host_type):$remote_dir"
+	fi
+
+	local mnt_cmd="mount -t nfs $opts $mount_dir $local_dir"
+
+	tst_res TINFO "Mounting NFS: $mnt_cmd"
+	if [ -n "$LTP_NETNS" ]; then
+		tst_rhost_run -s -c "$mnt_cmd"
+		return
+	fi
+
+	ROD $mnt_cmd
+}
+
 nfs_setup()
 {
 	# Check if current filesystem is NFS
@@ -60,35 +101,19 @@ nfs_setup()
 	local local_dir
 	local remote_dir
 	local mount_dir
+
 	for i in $VERSION; do
 		type=$(get_socket_type $n)
 		tst_res TINFO "setup NFSv$i, socket type $type"
 
 		local_dir="$TST_TMPDIR/$i/$n"
 		remote_dir="$TST_TMPDIR/$i/$type"
-
 		mkdir -p $local_dir
 
-		tst_rhost_run -c "test -d $remote_dir"
-		if [ "$?" -ne 0  ]; then
-			tst_rhost_run -s -c "mkdir -p $remote_dir"
-			tst_rhost_run -s -c "exportfs -i -o no_root_squash,rw \
-				*:$remote_dir"
-		fi
+		nfs_setup_server
 
 		opts="-o proto=$type,vers=$i"
-
-		if [ $TST_IPV6 ]; then
-			mount_dir="[$(tst_ipaddr rhost)]:$remote_dir"
-		else
-			mount_dir="$(tst_ipaddr rhost):$remote_dir"
-		fi
-
-
-		tst_res TINFO "Mounting NFS '$mount_dir'"
-		tst_res TINFO "to '$local_dir' with options '$opts'"
-
-		ROD mount -t nfs $opts $mount_dir $local_dir
+		nfs_mount
 
 		n=$(( n + 1 ))
 	done
Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/1 network/nfs: support default setup, use local mount

Hi Alexey,

Quoted 8 lines

For default setup, start the server locally instead and mount inside netns to run NFS traffic over the veth or whatever is used for a single machine setup.

We could also use lo interface, we just need to skip the last check in nfs_mount()/nfs_lib.sh.

LGTM, thanks for the patch!

BTW how about split runtest/net.nfs, so it takes shorter to run? Maybe it takes so long on my side as I still experience some problems with NFS, which I haven't debugged yet (timeout).

Kind regards,
Petr

author Applied
#2 lore raw

PATCH 1/1 network/nfs: support default setup, use local mount

Quoted 6 lines · Petr Vorel

Hi Alexey,

Quoted 3 lines

For default setup, start the server locally instead and mount inside netns to run NFS traffic over the veth or whatever is used for a single machine setup.

Quoted 8 lines
Quoted 4 lines

We could also use lo interface, we just need to skip the last check in nfs_mount()/nfs_lib.sh.

LGTM, thanks for the patch!

Applied, thanks for review Petr!

Quoted 3 lines

BTW how about split runtest/net.nfs, so it takes shorter to run? Maybe it takes so long on my side as I still experience some problems with NFS, which I haven't debugged yet (timeout).

Perhaps some default parameters are unreasonably large, e.g. DIR_NUM, FILE_NUM, THREAD_NUM (nfs03, nfs05 tests)...