glusterfs/tests/nfs.rc
Emmanuel Dreyfus c51eb694bc Tests portability: umount(8)
1) Avoid hangs on unmounting NFS on NetBSD

NetBSD umount(8) on a NFS mount whose server is gone will wait forever
because umount(8) calls realpath(3) and tries to access the mount before
it calls unmount(2). The non-portable, NetBSD-specific umount -R flag
prevent that behavior.

We therefore introduce UMOUNT_F, defined as "umount -f" on Linux and
"umount -f -R" on NetBSD to take care of forced unmounts, especially
in the NFS case.

2) Enforce usage of force_umount wrapper with timeout

Whenever umount is used it should be wrapped in force_umount with
tiemout handling. That saves us timing issues, and it handles the
NetBSD NFS case.

3) Cleanup kernel cache flush.

We used (cd $M0 && umount $M0 )	as a portable kernel cache flush
trick, but it does not flush everything we need on Linux. Introduce
a drop_cache() shell function that reverts to previously used
echo 3 > /proc/sys/vm/drop_caches on Linux, and keeps
(cd $M0 && umount $M0 ) on other systems.

BUG: 1129939
Change-Id: Iab1f5a023405f1f7270c42b595573702ca1eb6f3
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/11114
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
2015-06-09 06:24:47 -07:00

71 lines
1.9 KiB
Bash

#!/bin/bash
# Due to portmap registration NFS takes some time to
# export all volumes. Therefore tests should start only
# after exports are visible by showmount command. This
# routine will check if showmount shows the exports or not
#
function is_nfs_export_available ()
{
local vol=$1
if [ "$vol" == "" ]; then
vol=$V0
fi
exp=$(showmount -e localhost 2> /dev/null | grep $vol | wc -l)
echo "$exp"
}
function mount_nfs ()
{
local e=$1
local m=$2
local opt=$3
if [ ! -z "$opt" ]; then opt=",$opt"; fi
opt="soft,intr,vers=3$opt"
nopt=""
for o in ${opt//,/ }; do
case $OSTYPE in
NetBSD)
test "x${nopt}" = "x" && nopt="tcp,-R=2,"
case $o in
nolock|noac|actimeo=*|mountproto=udp)
continue
;;
proto=tcp)
o="tcp"
;;
vers=3)
o="nfsv3"
;;
retry=*)
o=${o/retry=/-R}
;;
timeo=*)
o=${o/timeo=/-t}
;;
retrans=*)
o=${o/retrans=/-x}
;;
*)
;;
esac
;;
*)
;;
esac
if [ ! -z "$nopt" ]; then nopt="${nopt},"; fi
nopt="${nopt}$o"
done
mount -t nfs -o $nopt $e $m
}
function umount_nfs {
${UMOUNT_F} $1
if [ $? -eq 0 ]; then echo "Y"; else echo "N"; fi
}