network/nfs: support default setup, use local mount

Message ID 1539091079-21887-1-git-send-email-alexey.kodanev@oracle.com
State Accepted
Delegated to: Petr Vorel
Headers show
Series
  • network/nfs: support default setup, use local mount
Related show

Commit Message

Alexey Kodanev Oct. 9, 2018, 1:17 p.m.
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.

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 testcases/network/nfs/nfs_stress/nfs_lib.sh |   63 +++++++++++++++++++--------
 1 files changed, 44 insertions(+), 19 deletions(-)

Comments

Petr Vorel Oct. 12, 2018, 4:13 p.m. | #1
Hi Alexey,

> 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.

> Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
Acked-by: Petr Vorel <pvorel@suse.cz>

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
Alexey Kodanev Oct. 15, 2018, 4:03 p.m. | #2
On 10/12/2018 07:13 PM, Petr Vorel wrote:
> Hi Alexey,
> 
>> 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.
> 
>> Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
> Acked-by: Petr Vorel <pvorel@suse.cz>
> 
> LGTM, thanks for the patch!
> 

Applied, thanks for review Petr!

> 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)...

Patch

diff --git a/testcases/network/nfs/nfs_stress/nfs_lib.sh b/testcases/network/nfs/nfs_stress/nfs_lib.sh
index 7e11dc4..28b73e1 100644
--- a/testcases/network/nfs/nfs_stress/nfs_lib.sh
+++ b/testcases/network/nfs/nfs_stress/nfs_lib.sh
@@ -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