| 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. 2000,2004 | 
|---|
| 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 | # @(#)54 1.17 src/avs/fs/mmfs/ts/admin/mmcrsnapshot.sh, mmfs, avs_rgpfs24, rgpfs240610b 11/15/04 02:34:46 | 
|---|
| 17 | ####################################################################### | 
|---|
| 18 | # | 
|---|
| 19 | #  Usage:  mmcrsnapshot Device Directory | 
|---|
| 20 | # | 
|---|
| 21 | ####################################################################### | 
|---|
| 22 |  | 
|---|
| 23 | # Include global declarations and service routines. | 
|---|
| 24 | . /usr/lpp/mmfs/bin/mmglobfuncs | 
|---|
| 25 | . /usr/lpp/mmfs/bin/mmsdrfsdef | 
|---|
| 26 | . /usr/lpp/mmfs/bin/mmfsfuncs | 
|---|
| 27 |  | 
|---|
| 28 | sourceFile="mmcrsnapshot.sh" | 
|---|
| 29 | [[ -n $DEBUG || -n $DEBUGmmcrsnapshot ]] && set -x | 
|---|
| 30 | $mmTRACE_ENTER "$*" | 
|---|
| 31 |  | 
|---|
| 32 | usageMsg=371 | 
|---|
| 33 | integer rc=0 | 
|---|
| 34 | integer nodeCount=0 | 
|---|
| 35 |  | 
|---|
| 36 |  | 
|---|
| 37 | ##################################################################### | 
|---|
| 38 | # Process the command arguments. | 
|---|
| 39 | # The detailed syntax checking is left for the ts command. | 
|---|
| 40 | # Here we make sure that we have the minimum needed to continue. | 
|---|
| 41 | ##################################################################### | 
|---|
| 42 | [[ $arg1 = '-?' || $arg1 = '-h' || $arg1 = '--help' || $arg1 = '--' ]] && \ | 
|---|
| 43 | syntaxError "help" $usageMsg | 
|---|
| 44 |  | 
|---|
| 45 | [[ $argc -lt 1  ]] && \ | 
|---|
| 46 | syntaxError "missingArgs" $usageMsg | 
|---|
| 47 |  | 
|---|
| 48 | device=$arg1   # Save the stripe group device (always the first parameter). | 
|---|
| 49 | shift 1        # Drop the device name from the parameter list. | 
|---|
| 50 | argList=$@     # Save the remainder of the argument list. | 
|---|
| 51 |  | 
|---|
| 52 |  | 
|---|
| 53 | ######################################################################## | 
|---|
| 54 | # Set up trap exception handling and call the gpfsInit function. | 
|---|
| 55 | # It will ensure that the local copy of the mmsdrfs and the rest of the | 
|---|
| 56 | # GPFS system files are up-to-date.  There is no need to lock the sdr. | 
|---|
| 57 | ######################################################################## | 
|---|
| 58 | trap pretrap2 HUP INT QUIT KILL | 
|---|
| 59 | gpfsInitOutput=$(gpfsInit nolock) | 
|---|
| 60 | setGlobalVar $? $gpfsInitOutput | 
|---|
| 61 |  | 
|---|
| 62 |  | 
|---|
| 63 | ########################################################### | 
|---|
| 64 | # Make sure the specified file system exists and is local. | 
|---|
| 65 | ########################################################### | 
|---|
| 66 | findFSoutput=$(findFS "$device" $mmsdrfsFile) | 
|---|
| 67 | [[ -z $findFSoutput ]] && cleanupAndExit | 
|---|
| 68 |  | 
|---|
| 69 | # Parse the output from the findFS function | 
|---|
| 70 | set -f ; set -- $findFSoutput ; set +f | 
|---|
| 71 | fqDeviceName=$1 | 
|---|
| 72 | deviceName=$2 | 
|---|
| 73 | fsHomeCluster=$3 | 
|---|
| 74 |  | 
|---|
| 75 | # Exit with a message if the command was invoked for a remote file system. | 
|---|
| 76 | if [[ $fsHomeCluster != $HOME_CLUSTER ]] | 
|---|
| 77 | then | 
|---|
| 78 | # Command is not allowed for remote file systems. | 
|---|
| 79 | printErrorMsg 106 $mmcmd $device $fsHomeCluster | 
|---|
| 80 | cleanupAndExit 1 | 
|---|
| 81 | fi | 
|---|
| 82 |  | 
|---|
| 83 |  | 
|---|
| 84 | ############################################################################ | 
|---|
| 85 | # We come here if this is a local filesystem.  Invoke the command directly. | 
|---|
| 86 | ############################################################################ | 
|---|
| 87 | ${mmcmdDir}/${links}/mmcrsnapshot $fqDeviceName $argList | 
|---|
| 88 | rc=$(remapRC $?) | 
|---|
| 89 |  | 
|---|
| 90 | # If acceptable error (daemon not running, waiting for quorum), | 
|---|
| 91 | # try some other node.  Otherwise, get out; either the command worked | 
|---|
| 92 | # or the errors are not acceptable. | 
|---|
| 93 | if [[ $rc -ne $MM_DaemonDown && $rc -ne $MM_QuorumWait ]] | 
|---|
| 94 | then | 
|---|
| 95 | if [[ $rc -eq $MM_ConnectionReset ]] | 
|---|
| 96 | then | 
|---|
| 97 | # An internode connection was reset. | 
|---|
| 98 | printErrorMsg 257 $mmcmd | 
|---|
| 99 | fi | 
|---|
| 100 | cleanupAndExit $rc | 
|---|
| 101 | fi | 
|---|
| 102 |  | 
|---|
| 103 |  | 
|---|
| 104 | ################################################### | 
|---|
| 105 | # We come here if the daemon was not up. | 
|---|
| 106 | # Find an active node and send the command there. | 
|---|
| 107 | ################################################### | 
|---|
| 108 |  | 
|---|
| 109 | # Create a file with the reliable names that form | 
|---|
| 110 | # the cluster to which the file system belongs. | 
|---|
| 111 | nodeCount=$(getNodeFile $REL_HOSTNAME_Field $fsHomeCluster $mmsdrfsFile $nodefile) | 
|---|
| 112 | if [[ $nodeCount -eq 0 ]] | 
|---|
| 113 | then | 
|---|
| 114 | # The cluster is empty; there is nobody to run the command. | 
|---|
| 115 | printErrorMsg 171 $mmcmd "getNodeFile (nodeCount=0)" 1 | 
|---|
| 116 | cleanupAndExit | 
|---|
| 117 | fi | 
|---|
| 118 |  | 
|---|
| 119 | # Try the nodes one by one until you find a node that can execute the command. | 
|---|
| 120 | preferredNode=0     # We have no idea where to go first; let mmcommon decide. | 
|---|
| 121 | $mmcommon linkCommand $preferredNode $nodefile mmcrsnapshot $fqDeviceName $argList | 
|---|
| 122 | rc=$? | 
|---|
| 123 |  | 
|---|
| 124 | cleanupAndExit $rc | 
|---|
| 125 |  | 
|---|