#!/bin/ksh # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # # # Licensed Materials - Property of IBM # # (C) COPYRIGHT International Business Machines Corp. 2002,2005 # All Rights Reserved # # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # # IBM_PROLOG_END_TAG # @(#)56 1.14 src/avs/fs/mmfs/ts/admin/mmsnaplatest.sh, mmfs, avs_rgpfs24, rgpfs240610b 3/22/05 13:20:55 ####################################################################### # # Usage: mmsnaplatest Device [-q | -d | -s snapLatestName] # ####################################################################### # Include global declarations and service routines. . /usr/lpp/mmfs/bin/mmglobfuncs if [[ $ourUid -eq 0 ]] then . /usr/lpp/mmfs/bin/mmsdrfsdef . /usr/lpp/mmfs/bin/mmfsfuncs fi sourceFile="mmsnaplatest.sh" [[ -n $DEBUG || -n $DEBUGmmsnaplatest ]] && set -x $mmTRACE_ENTER "$*" usageMsg=555 integer rc=0 integer nodeCount=0 ##################################################################### # Process the command arguments. # The detailed syntax checking is left for the ts command. # Here we make sure that we have the minimum needed to continue. ##################################################################### [[ $arg1 = '-?' || $arg1 = '-h' || $arg1 = '--help' || $arg1 = '--' ]] && \ syntaxError "help" $usageMsg [[ $argc -lt 1 ]] && \ syntaxError "missingArgs" $usageMsg device=$arg1 # Save stripe group device (always the first parameter). shift 1 # Drop the device name from the parameter list. argList=$@ # Save the remainder of the argument list. ################################### # Set up trap exception handlin.g ################################### trap pretrap2 HUP INT QUIT KILL #################################################################### # If invoked by a root user, call the gpfsInit function to ensure # that the local copy of the mmsdrfs file and the rest of the GPFS # system files are up-to-date. There is no need to lock the sdr. # Non-root users are not allowed to invoke commands on other nodes. #################################################################### if [[ $ourUid -eq 0 ]] then gpfsInitOutput=$(gpfsInit nolock) setGlobalVar $? $gpfsInitOutput fi #################################### # Make sure the file system exists. #################################### # If the invocation is not for an explicitly-remote device, obtain the # needed information about the filesystem from the mmsdrfs file. if [[ $device != *:* ]] then findFSoutput=$(findFS "$device" $mmsdrfsFile) [[ -z $findFSoutput ]] && cleanupAndExit # Parse the output from the findFS function. set -f ; set -- $findFSoutput ; set +f fqDeviceName=$1 deviceName=$2 fsHomeCluster=$3 remoteDevice=$4 # If this is a remote file system, set fqDeviceName appropriately. [[ $fsHomeCluster != $HOME_CLUSTER ]] && \ fqDeviceName="$fsHomeCluster:/dev/$remoteDevice" else fqDeviceName=$device deviceName=${fqDeviceName##*:} fsHomeCluster=${fqDeviceName%%:*} remoteDevice=$deviceName fi # If this is a remote file system, only the query option is allowed. # Note: If no options are specified, -q is assumed. if [[ $fsHomeCluster != $HOME_CLUSTER && $argc -gt 1 && $arg2 != "-q" ]] then # Command is not allowed for remote file systems. printErrorMsg 106 $mmcmd $device $fsHomeCluster cleanupAndExit 1 fi ######################################################################## # Invoke the command on the local node. # Display any error messages and exit if any of the following are true: # - the command completed successfully # - there is an unacceptable error # (anything other than daemon down or quorum wait) # - the file system is remote # - we are not running as UID 0 # - this is a single node cluster ######################################################################## ${mmcmdDir}/${links}/mmsnaplatest $fqDeviceName $argList 2>$errMsg rc=$(remapRC $?) if [[ ($rc -ne $MM_DaemonDown && $rc -ne $MM_QuorumWait) || $fsHomeCluster != $HOME_CLUSTER || $ourUid -ne 0 || $MMMODE = single ]] then if [[ $rc -eq $MM_FsNotFound ]] then if [[ $fsHomeCluster != $HOME_CLUSTER ]] then # The remote cluster does not know anything about this file system. printErrorMsg 108 $mmcmd $remoteDevice $fsHomeCluster else # Unexpected error. printErrorMsg 171 $mmcmd "file system $deviceName not found" $rc fi elif [[ $rc -eq $MM_Remotefs && $fsHomeCluster != $HOME_CLUSTER ]] then # The file system is not owned by the remote cluster. [[ $device != *:* ]] && \ printErrorMsg 111 $mmcmd $device $remoteDevice $fsHomeCluster printErrorMsg 112 $mmcmd $remoteDevice $fsHomeCluster elif [[ ($rc -eq $MM_HostDown || $rc -eq $MM_TimedOut || $rc -eq $MM_SecurityCfg || $rc -eq $MM_AuthorizationFailed || $rc -eq $MM_UnknownCluster) && $fsHomeCluster != $HOME_CLUSTER ]] then # Failed to connect to the remote cluster. [[ $rc -eq $MM_SecurityCfg ]] && \ printErrorMsg 150 $mmcmd [[ $rc -eq $MM_AuthorizationFailed ]] && \ printErrorMsg 151 $mmcmd printErrorMsg 105 $mmcmd $fsHomeCluster elif [[ $rc -eq $MM_DaemonDown ]] then # GPFS is down on this node. printErrorMsg 109 $mmcmd elif [[ $rc -eq $MM_QuorumWait ]] then # GPFS is not ready for commands. printErrorMsg 110 $mmcmd elif [[ $rc -eq $MM_ConnectionReset ]] then # An internode connection was reset. printErrorMsg 257 $mmcmd else # Either the command worked, or it is an unexpected error. if [[ -s $errMsg ]] then # Show the error messages from the daemon. $cat $errMsg 1>&2 elif [[ $rc -ne 0 ]] then # tssnaplatest failed. printErrorMsg 104 "$mmcmd" "tssnaplatest $fqDeviceName" else : # The command must have worked. fi fi # end of if [[ $rc -eq $MM_FsNotFound ]] cleanupAndExit $rc fi # end of if [[ ($rc -ne $MM_DaemonDown && ... ]] $rm -f $errMsg ######################################################################### # We come here if the command was invoked for a local file system but # the local daemon is not available; send the command to an active node. ######################################################################### # Create a file with the reliable names of the nodes in the cluster. nodeCount=$(getNodeFile $REL_HOSTNAME_Field $fsHomeCluster $mmsdrfsFile $nodefile) if [[ $nodeCount -eq 0 ]] then # The cluster is empty; there is nobody to run the command. printErrorMsg 171 $mmcmd "getNodeFile (nodeCount=0)" 1 cleanupAndExit fi # Try the nodes one by one until you find a node that can execute the command. preferredNode=0 # We have no idea where to go first; let mmcommon decide. $mmcommon linkCommand $preferredNode $nodefile \ mmsnaplatest $fqDeviceName $argList rc=$? cleanupAndExit $rc