| [16] | 1 | #!/bin/ksh |
|---|
| 2 | # IBM_PROLOG_BEGIN_TAG |
|---|
| 3 | # This is an automatically generated prolog. |
|---|
| 4 | # |
|---|
| 5 | # |
|---|
| 6 | # |
|---|
| 7 | # Licensed Materials - Property of IBM |
|---|
| 8 | # |
|---|
| 9 | # (C) COPYRIGHT International Business Machines Corp. 1999,2006 |
|---|
| 10 | # All Rights Reserved |
|---|
| 11 | # |
|---|
| 12 | # US Government Users Restricted Rights - Use, duplication or |
|---|
| 13 | # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. |
|---|
| 14 | # |
|---|
| 15 | # IBM_PROLOG_END_TAG |
|---|
| 16 | # @(#)81 1.38 src/avs/fs/mmfs/ts/admin/mmdf.sh, mmfs, avs_rgpfs24, rgpfs240610b 1/23/06 01:56:50 |
|---|
| 17 | ####################################################################### |
|---|
| 18 | # |
|---|
| 19 | # Usage: mmdf Device [-d | -F | -m ] [-q] [-P PoolName] |
|---|
| 20 | # |
|---|
| 21 | ####################################################################### |
|---|
| 22 | |
|---|
| 23 | # Include global declarations and service routines. |
|---|
| 24 | . /usr/lpp/mmfs/bin/mmglobfuncs |
|---|
| 25 | if [[ $ourUid -eq 0 ]] |
|---|
| 26 | then |
|---|
| 27 | . /usr/lpp/mmfs/bin/mmsdrfsdef |
|---|
| 28 | . /usr/lpp/mmfs/bin/mmfsfuncs |
|---|
| 29 | fi |
|---|
| 30 | |
|---|
| 31 | sourceFile="mmdf.sh" |
|---|
| 32 | [[ -n $DEBUG || -n $DEBUGmmdf ]] && set -x |
|---|
| 33 | $mmTRACE_ENTER "$*" |
|---|
| 34 | |
|---|
| 35 | usageMsg=298 |
|---|
| 36 | integer rc=0 |
|---|
| 37 | integer nodeCount=0 |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | ##################################################################### |
|---|
| 41 | # Process the command arguments. |
|---|
| 42 | # The detailed syntax checking is left for the ts command. |
|---|
| 43 | # Here we make sure that we have the minimum needed to continue. |
|---|
| 44 | ##################################################################### |
|---|
| 45 | [[ $arg1 = '-?' || $arg1 = '-h' || $arg1 = '--help' || $arg1 = '--' ]] && \ |
|---|
| 46 | syntaxError "help" $usageMsg |
|---|
| 47 | |
|---|
| 48 | [[ $argc -lt 1 ]] && \ |
|---|
| 49 | syntaxError "missingArgs" $usageMsg |
|---|
| 50 | |
|---|
| 51 | device=$arg1 # Save stripe group device (always the first parameter). |
|---|
| 52 | shift 1 # Drop the device name from the parameter list. |
|---|
| 53 | argList=$@ # Save the remainder of the argument list. |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | ################################### |
|---|
| 57 | # Set up trap exception handling. |
|---|
| 58 | ################################### |
|---|
| 59 | trap pretrap2 HUP INT QUIT KILL |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | #################################################################### |
|---|
| 63 | # If invoked by a root user, call the gpfsInit function to ensure |
|---|
| 64 | # that the local copy of the mmsdrfs file and the rest of the GPFS |
|---|
| 65 | # system files are up-to-date. There is no need to lock the sdr. |
|---|
| 66 | # Non-root users are not allowed to invoke commands on other nodes. |
|---|
| 67 | #################################################################### |
|---|
| 68 | if [[ $ourUid -eq 0 ]] |
|---|
| 69 | then |
|---|
| 70 | gpfsInitOutput=$(gpfsInit nolock) |
|---|
| 71 | setGlobalVar $? $gpfsInitOutput |
|---|
| 72 | fi |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | #################################### |
|---|
| 76 | # Make sure the file system exists. |
|---|
| 77 | #################################### |
|---|
| 78 | # If the invocation is not for an explicitly-remote device, obtain the |
|---|
| 79 | # needed information about the filesystem from the mmsdrfs file. |
|---|
| 80 | if [[ $device != *:* ]] |
|---|
| 81 | then |
|---|
| 82 | findFSoutput=$(findFS "$device" $mmsdrfsFile) |
|---|
| 83 | [[ -z $findFSoutput ]] && cleanupAndExit |
|---|
| 84 | |
|---|
| 85 | # Parse the output from the findFS function. |
|---|
| 86 | set -f ; set -- $findFSoutput ; set +f |
|---|
| 87 | fqDeviceName=$1 |
|---|
| 88 | deviceName=$2 |
|---|
| 89 | fsHomeCluster=$3 |
|---|
| 90 | remoteDevice=$4 |
|---|
| 91 | |
|---|
| 92 | # If this is a remote file system, set fqDeviceName appropriately. |
|---|
| 93 | [[ $fsHomeCluster != $HOME_CLUSTER ]] && \ |
|---|
| 94 | fqDeviceName="$fsHomeCluster:/dev/$remoteDevice" |
|---|
| 95 | else |
|---|
| 96 | fqDeviceName=$device |
|---|
| 97 | deviceName=${fqDeviceName##*:} |
|---|
| 98 | fsHomeCluster=${fqDeviceName%%:*} |
|---|
| 99 | remoteDevice=$deviceName |
|---|
| 100 | fi |
|---|
| 101 | |
|---|
| 102 | |
|---|
| 103 | ######################################################################## |
|---|
| 104 | # Invoke the command on the local node. |
|---|
| 105 | # Display any error messages and exit if any of the following are true: |
|---|
| 106 | # - the command completed successfully |
|---|
| 107 | # - there is an unacceptable error |
|---|
| 108 | # (anything other than daemon down or quorum wait) |
|---|
| 109 | # - the file system is remote |
|---|
| 110 | # - we are not running as UID 0 |
|---|
| 111 | # - this is a single node cluster |
|---|
| 112 | ######################################################################## |
|---|
| 113 | ${mmcmdDir}/${links}/mmdf $fqDeviceName $argList 2>$errMsg |
|---|
| 114 | rc=$(remapRC $?) |
|---|
| 115 | if [[ ($rc -ne $MM_DaemonDown && $rc -ne $MM_QuorumWait) || |
|---|
| 116 | $fsHomeCluster != $HOME_CLUSTER || |
|---|
| 117 | $ourUid -ne 0 || |
|---|
| 118 | $MMMODE = single ]] |
|---|
| 119 | then |
|---|
| 120 | if [[ $rc -eq $MM_FsNotFound ]] |
|---|
| 121 | then |
|---|
| 122 | if [[ $fsHomeCluster != $HOME_CLUSTER ]] |
|---|
| 123 | then |
|---|
| 124 | # The remote cluster does not know anything about this file system. |
|---|
| 125 | printErrorMsg 108 $mmcmd $remoteDevice $fsHomeCluster |
|---|
| 126 | else |
|---|
| 127 | # Unexpected error. |
|---|
| 128 | printErrorMsg 171 $mmcmd "file system $deviceName not found" $rc |
|---|
| 129 | fi |
|---|
| 130 | elif [[ $rc -eq $MM_Remotefs && $fsHomeCluster != $HOME_CLUSTER ]] |
|---|
| 131 | then |
|---|
| 132 | # The file system is not owned by the remote cluster. |
|---|
| 133 | [[ $device != *:* ]] && \ |
|---|
| 134 | printErrorMsg 111 $mmcmd $device $remoteDevice $fsHomeCluster |
|---|
| 135 | printErrorMsg 112 $mmcmd $remoteDevice $fsHomeCluster |
|---|
| 136 | elif [[ ($rc -eq $MM_HostDown || |
|---|
| 137 | $rc -eq $MM_TimedOut || |
|---|
| 138 | $rc -eq $MM_SecurityCfg || |
|---|
| 139 | $rc -eq $MM_AuthorizationFailed || |
|---|
| 140 | $rc -eq $MM_UnknownCluster) && |
|---|
| 141 | $fsHomeCluster != $HOME_CLUSTER ]] |
|---|
| 142 | then |
|---|
| 143 | # Failed to connect to the remote cluster. |
|---|
| 144 | [[ $rc -eq $MM_SecurityCfg ]] && \ |
|---|
| 145 | printErrorMsg 150 $mmcmd |
|---|
| 146 | [[ $rc -eq $MM_AuthorizationFailed ]] && \ |
|---|
| 147 | printErrorMsg 151 $mmcmd |
|---|
| 148 | printErrorMsg 105 $mmcmd $fsHomeCluster |
|---|
| 149 | elif [[ $rc -eq $MM_DaemonDown ]] |
|---|
| 150 | then |
|---|
| 151 | # GPFS is down on this node. |
|---|
| 152 | printErrorMsg 109 $mmcmd |
|---|
| 153 | elif [[ $rc -eq $MM_QuorumWait ]] |
|---|
| 154 | then |
|---|
| 155 | # GPFS is not ready for commands. |
|---|
| 156 | printErrorMsg 110 $mmcmd |
|---|
| 157 | elif [[ $rc -eq $MM_ConnectionReset ]] |
|---|
| 158 | then |
|---|
| 159 | # An internode connection was reset. |
|---|
| 160 | printErrorMsg 257 $mmcmd |
|---|
| 161 | else |
|---|
| 162 | # Either the command worked, or it is an unexpected error. |
|---|
| 163 | if [[ -s $errMsg ]] |
|---|
| 164 | then |
|---|
| 165 | $cat $errMsg 1>&2 |
|---|
| 166 | else |
|---|
| 167 | [[ $rc -ne 0 ]] && printErrorMsg 113 "$mmcmd" "tsdf $fqDeviceName" $rc |
|---|
| 168 | fi |
|---|
| 169 | fi # end of if [[ $rc -eq $MM_FsNotFound ]] |
|---|
| 170 | cleanupAndExit $rc |
|---|
| 171 | fi # end of if [[ ($rc -ne $MM_DaemonDown && ... ]] |
|---|
| 172 | $rm -f $errMsg |
|---|
| 173 | |
|---|
| 174 | |
|---|
| 175 | ####################################################################### |
|---|
| 176 | # We come here if the file system is local but the local daemon is not |
|---|
| 177 | # available. Find an active node and send the command there. |
|---|
| 178 | ####################################################################### |
|---|
| 179 | |
|---|
| 180 | # Create a file with the reliable names that form |
|---|
| 181 | # the cluster to which the file system belongs. |
|---|
| 182 | nodeCount=$(getNodeFile $REL_HOSTNAME_Field $fsHomeCluster $mmsdrfsFile $nodefile) |
|---|
| 183 | if [[ $nodeCount -eq 0 ]] |
|---|
| 184 | then |
|---|
| 185 | # The cluster is empty; there is nobody to run the command. |
|---|
| 186 | printErrorMsg 171 $mmcmd "getNodeFile (nodeCount=0)" 1 |
|---|
| 187 | cleanupAndExit |
|---|
| 188 | fi |
|---|
| 189 | |
|---|
| 190 | # Try the nodes one by one until you find a node that can execute the command. |
|---|
| 191 | preferredNode=0 # We have no idea where to go first; let mmcommon decide. |
|---|
| 192 | $mmcommon linkCommand $preferredNode $nodefile mmdf $fqDeviceName $argList |
|---|
| 193 | rc=$? |
|---|
| 194 | |
|---|
| 195 | cleanupAndExit $rc |
|---|
| 196 | |
|---|