X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fsetup-nfs.sh;h=eb6720febdd012d0d8a515eb5b6c1c4a3ce33687;hb=54301fe4f598eef5aebdbdb0c7f3dddea9541c4e;hp=284381b7bee0e7eab742532f8abc4498535ffd07;hpb=d238e5d049e2b73f7997fa0add1a094fec432cb2;p=fs%2Flustre-release.git diff --git a/lustre/tests/setup-nfs.sh b/lustre/tests/setup-nfs.sh index 284381b..eb6720f 100755 --- a/lustre/tests/setup-nfs.sh +++ b/lustre/tests/setup-nfs.sh @@ -1,72 +1,48 @@ #!/bin/bash -#set -x -EXPORT_OPTS=${EXPORT_OPTS:-"rw,async,no_root_squash"} -setup_nfs() { - local NFS_VER=${1} - local MNTPNT=${2} - local LUSTRE_CLIENT=${3} - local NFS_CLIENTS=${4} - local nfs_climntpt=${5:-$MNTPNT} - - local export_opts_v=$EXPORT_OPTS - - echo "Exporting Lustre filesystem..." - - if [ "$NFS_VER" = "4" ]; then - export_opts_v="$EXPORT_OPTS,fsid=0" - do_nodes $LUSTRE_CLIENT "mkdir -p /var/lib/nfs/v4recovery" - fi - - do_nodes $LUSTRE_CLIENT,$NFS_CLIENTS "grep -q rpc_pipefs' ' /proc/mounts ||\ - { mkdir -p /var/lib/nfs/rpc_pipefs && \ - mount -t rpc_pipefs sunrpc /var/lib/nfs/rpc_pipefs; }" || return 1 - sleep 5 - - do_nodes $LUSTRE_CLIENT "chkconfig --list nfsserver > /dev/null 2>&1 && - service nfsserver restart || - service nfs restart" || return 1 - - do_nodes $NFS_CLIENTS "chkconfig --list rpcidmapd 2>/dev/null | - grep -q rpcidmapd && service rpcidmapd restart || - true" +DEFAULT_NFS_OPTIONS=${DEFAULT_NFS_OPTIONS:-"rw,async,no_root_squash"} +DEFAULT_EXPORTS_FILE=${DEFAULT_EXPORTS_FILE:-"/etc/exports.d/lustre.exports"} - do_nodes $LUSTRE_CLIENT "exportfs -o $export_opts_v *:$MNTPNT \ - && exportfs -v" || return 1 - - echo -e "\nMounting NFS clients (version $NFS_VER)..." +setup_nfs() { + local LUSTRE_CLIENT=$1 + local LUSTRE_MOUNT_POINT=$2 + local NFS_CLIENTS=$3 + local NFS_MOUNT_POINT=$4 + local NFS_VERSION=$5 + local EXPORTS_FILE=$DEFAULT_EXPORTS_FILE + local NFS_OPTIONS=$DEFAULT_NFS_OPTIONS + + echo "Exporting Lustre filesystem via NFS version $NFS_VERSION" + do_nodes "$LUSTRE_CLIENT" \ + "echo '$LUSTRE_MOUNT_POINT *($NFS_OPTIONS)' | \ + tee $EXPORTS_FILE" || return 1 + do_nodes "$LUSTRE_CLIENT" "systemctl restart nfs-server" || return 1 + do_nodes "$LUSTRE_CLIENT" "systemctl restart nfs-idmapd" || return 1 + + echo "Mounting NFS clients version $NFS_VERSION" + do_nodes "$NFS_CLIENTS" "systemctl restart nfs-idmapd" || return 1 + do_nodes "$NFS_CLIENTS" "mkdir -p $NFS_MOUNT_POINT" || return 1 + do_nodes "$NFS_CLIENTS" \ + "mount -v -t nfs -o nfsvers=$NFS_VERSION,async \ + $LUSTRE_CLIENT:$LUSTRE_MOUNT_POINT \ + $NFS_MOUNT_POINT" || return 1 - do_nodes $NFS_CLIENTS "mkdir -p $nfs_climntpt" || return 1 - if [ "$NFS_VER" = "4" ]; then - do_nodes $NFS_CLIENTS \ - "mount -t nfs$NFS_VER -o async \ - $LUSTRE_CLIENT:/ $nfs_climntpt" || return 1 - else - do_nodes $NFS_CLIENTS \ - "mount -t nfs -o nfsvers=$NFS_VER,async \ - $LUSTRE_CLIENT:$MNTPNT $nfs_climntpt" || return 1 - fi return 0 } cleanup_nfs() { - local MNTPNT=${1} - local LUSTRE_CLIENT=${2} - local NFS_CLIENTS=${3} - - echo -e "\nUnmounting NFS clients..." - do_nodes $NFS_CLIENTS "umount -f $MNTPNT" || true - - echo -e "\nUnexporting Lustre filesystem..." - do_nodes $NFS_CLIENTS "chkconfig --list rpcidmapd 2>/dev/null | - grep -q rpcidmapd && service rpcidmapd stop || - true" - - do_nodes $LUSTRE_CLIENT "chkconfig --list nfsserver > /dev/null 2>&1 && - service nfsserver stop || service nfs stop" || - return 1 - - do_nodes $LUSTRE_CLIENT "exportfs -u *:$MNTPNT" - - do_nodes $LUSTRE_CLIENT "exportfs -v" + local LUSTRE_CLIENT=$1 + local LUSTRE_MOUNT_POINT=$2 + local NFS_CLIENTS=$3 + local NFS_MOUNT_POINT=$4 + local EXPORTS_FILE=$DEFAULT_EXPORTS_FILE + + echo "Unmounting NFS clients" + do_nodes "$NFS_CLIENTS" "umount -v -f $NFS_MOUNT_POINT" || return 1 + do_nodes "$NFS_CLIENTS" "systemctl stop nfs-idmapd" || return 1 + + echo "Unexporting Lustre filesystem" + do_nodes "$LUSTRE_CLIENT" "systemctl stop nfs-server" || return 1 + do_nodes "$LUSTRE_CLIENT" "systemctl stop nfs-idmapd" || return 1 + do_nodes "$LUSTRE_CLIENT" "rm -v $EXPORTS_FILE" || return 1 }