| 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. 2005,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 | # @(#)42 1.6.1.1 src/avs/fs/mmfs/ts/admin/mmcrfileset.sh, mmfs, avs_rgpfs24, rgpfs24s007a 10/18/06 12:02:54 | 
|---|
| 17 | ############################################################################### | 
|---|
| 18 | # | 
|---|
| 19 | # Usage: | 
|---|
| 20 | #   mmcrfileset Device FilesetName [-t Comment] | 
|---|
| 21 | # | 
|---|
| 22 | # where | 
|---|
| 23 | #   Device            is the device name of the file system. | 
|---|
| 24 | #   FilesetName       is the fileset name. | 
|---|
| 25 | #   Comment           is a user-provided description of the fileset. | 
|---|
| 26 | #                       The total length cannot exceed 255 characters. | 
|---|
| 27 | # | 
|---|
| 28 | ############################################################################### | 
|---|
| 29 |  | 
|---|
| 30 | # Include global declarations and service routines. | 
|---|
| 31 | . /usr/lpp/mmfs/bin/mmglobfuncs | 
|---|
| 32 | . /usr/lpp/mmfs/bin/mmsdrfsdef | 
|---|
| 33 | . /usr/lpp/mmfs/bin/mmfsfuncs | 
|---|
| 34 |  | 
|---|
| 35 | sourceFile="mmcrfileset.sh" | 
|---|
| 36 | [[ -n $DEBUG || -n $DEBUGmmcrfileset ]] && set -x | 
|---|
| 37 | $mmTRACE_ENTER "$*" | 
|---|
| 38 |  | 
|---|
| 39 | # Local work files.  Names should be of the form: | 
|---|
| 40 | #   fn=${tmpDir}fn.${mmcmd}.$$ | 
|---|
| 41 |  | 
|---|
| 42 | LOCAL_FILES=" " | 
|---|
| 43 |  | 
|---|
| 44 |  | 
|---|
| 45 | # Local variables | 
|---|
| 46 | usageMsg=513 | 
|---|
| 47 |  | 
|---|
| 48 |  | 
|---|
| 49 | # Local functions | 
|---|
| 50 |  | 
|---|
| 51 |  | 
|---|
| 52 |  | 
|---|
| 53 | ####################### | 
|---|
| 54 | # Mainline processing | 
|---|
| 55 | ####################### | 
|---|
| 56 |  | 
|---|
| 57 |  | 
|---|
| 58 | ####################################### | 
|---|
| 59 | # Process the command line arguments. | 
|---|
| 60 | ####################################### | 
|---|
| 61 | [[ $arg1 = '-?' || $arg1 = '-h' || $arg1 = '--help' || $arg1 = '--' ]] &&  \ | 
|---|
| 62 | syntaxError "help" $usageMsg | 
|---|
| 63 |  | 
|---|
| 64 | [[ $argc -lt 2 ]] &&  \ | 
|---|
| 65 | syntaxError "missingArgs" $usageMsg | 
|---|
| 66 |  | 
|---|
| 67 | # The first argument is always the file system name. | 
|---|
| 68 | device=$arg1 | 
|---|
| 69 | deviceName=${device##+(/)dev+(/)}  # name stripped of /dev/ prefix | 
|---|
| 70 | fqDeviceName="/dev/$deviceName"    # fully-qualified name (with /dev/ prefix) | 
|---|
| 71 |  | 
|---|
| 72 | # The second argument is always the fileset name. | 
|---|
| 73 | filesetName=$arg2 | 
|---|
| 74 | checkName filesetName 255 "$filesetName" | 
|---|
| 75 | [[ $? -ne 0 ]] && cleanupAndExit | 
|---|
| 76 |  | 
|---|
| 77 | # Move past the positional parameters. | 
|---|
| 78 | shift 2 | 
|---|
| 79 |  | 
|---|
| 80 | # Process the rest of the parameters. | 
|---|
| 81 | while getopts :t: OPT | 
|---|
| 82 | do | 
|---|
| 83 | case $OPT in | 
|---|
| 84 |  | 
|---|
| 85 | t) # Comment string. | 
|---|
| 86 | [[ -n $tflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT" | 
|---|
| 87 | tflag="-$OPT"; targ="$OPTARG" | 
|---|
| 88 | userComments="$targ" | 
|---|
| 89 | checkName lengthCheckOnly 255 "$userComments" | 
|---|
| 90 | [[ $? -ne 0 ]] && cleanupAndExit | 
|---|
| 91 | ;; | 
|---|
| 92 |  | 
|---|
| 93 | +[t]) # Invalid option. | 
|---|
| 94 | syntaxError "invalidOption" $usageMsg $OPT | 
|---|
| 95 | ;; | 
|---|
| 96 |  | 
|---|
| 97 | :) # Missing argument. | 
|---|
| 98 | syntaxError "missingValue" $usageMsg $OPTARG | 
|---|
| 99 | ;; | 
|---|
| 100 |  | 
|---|
| 101 | *) # Invalid option. | 
|---|
| 102 | syntaxError "invalidOption" $usageMsg $OPTARG | 
|---|
| 103 | ;; | 
|---|
| 104 |  | 
|---|
| 105 | esac | 
|---|
| 106 | done  # end of while getopts :t: OPT do | 
|---|
| 107 | shift OPTIND-1 | 
|---|
| 108 |  | 
|---|
| 109 | [[ $# != 0 ]] && syntaxError "extraArg" $usageMsg $1 | 
|---|
| 110 |  | 
|---|
| 111 |  | 
|---|
| 112 | ##################################################################### | 
|---|
| 113 | # Set up trap exception handling and ensure that the local copy of | 
|---|
| 114 | # the mmsdrfs is up-to-date.  There is no need to lock the mmsdrfs. | 
|---|
| 115 | ##################################################################### | 
|---|
| 116 | trap pretrap2 HUP INT QUIT KILL | 
|---|
| 117 | gpfsInitOutput=$(gpfsInit nolock) | 
|---|
| 118 | setGlobalVar $? $gpfsInitOutput | 
|---|
| 119 |  | 
|---|
| 120 |  | 
|---|
| 121 | ########################################################### | 
|---|
| 122 | # Make sure the specified file system exists and is local. | 
|---|
| 123 | ########################################################### | 
|---|
| 124 | findFSoutput=$(findFS "$device" $mmsdrfsFile) | 
|---|
| 125 | [[ -z $findFSoutput ]] && cleanupAndExit | 
|---|
| 126 |  | 
|---|
| 127 | # Parse the output from the findFS function. | 
|---|
| 128 | set -f ; set -- $findFSoutput ; set +f | 
|---|
| 129 | fqDeviceName=$1 | 
|---|
| 130 | deviceName=$2 | 
|---|
| 131 | fsHomeCluster=$3 | 
|---|
| 132 |  | 
|---|
| 133 | # Exit if the command was invoked for a remote file system. | 
|---|
| 134 | if [[ $fsHomeCluster != $HOME_CLUSTER ]] | 
|---|
| 135 | then | 
|---|
| 136 | # Command is not allowed for remote file systems. | 
|---|
| 137 | printErrorMsg 106 $mmcmd $device $fsHomeCluster | 
|---|
| 138 | cleanupAndExit | 
|---|
| 139 | fi | 
|---|
| 140 |  | 
|---|
| 141 |  | 
|---|
| 142 | ######################################################################### | 
|---|
| 143 | # Invoke the tscrfileset command on the local node. | 
|---|
| 144 | # Display any error messages and exit if any of the following are true: | 
|---|
| 145 | #   - the command completed successfully | 
|---|
| 146 | #   - there is an unacceptable error | 
|---|
| 147 | #       (anything other than daemon down or quorum wait) | 
|---|
| 148 | #   - the user comment string contains blanks or tabs | 
|---|
| 149 | #       (the existing infrastructure cannot deal with imbedded blanks) | 
|---|
| 150 | #   - the fileset name contains path name expansion triggers | 
|---|
| 151 | #   - this is a single node cluster | 
|---|
| 152 | ######################################################################### | 
|---|
| 153 | if [[ -n $userComments ]] | 
|---|
| 154 | then | 
|---|
| 155 | $tscrfileset $fqDeviceName "$filesetName" -t "$userComments" 2>$errMsg | 
|---|
| 156 | rc=$(remapRC $?) | 
|---|
| 157 | else | 
|---|
| 158 | $tscrfileset $fqDeviceName "$filesetName" 2>$errMsg | 
|---|
| 159 | rc=$(remapRC $?) | 
|---|
| 160 | fi | 
|---|
| 161 |  | 
|---|
| 162 | if [[ $rc -ne $MM_DaemonDown && $rc -ne $MM_QuorumWait || | 
|---|
| 163 | "$userComments" = *+([;$BLANKchar$TABchar])*     || | 
|---|
| 164 | $MMMODE = single ]] | 
|---|
| 165 | then | 
|---|
| 166 | if [[ $rc -eq $MM_DaemonDown ]] | 
|---|
| 167 | then | 
|---|
| 168 | # GPFS is down on this node. | 
|---|
| 169 | printErrorMsg 109 $mmcmd | 
|---|
| 170 | elif [[ $rc -eq $MM_QuorumWait ]] | 
|---|
| 171 | then | 
|---|
| 172 | # GPFS is not ready for commands. | 
|---|
| 173 | printErrorMsg 110 $mmcmd | 
|---|
| 174 | elif [[ $rc -eq $MM_ConnectionReset ]] | 
|---|
| 175 | then | 
|---|
| 176 | # An internode connection was reset. | 
|---|
| 177 | printErrorMsg 257 $mmcmd | 
|---|
| 178 | else | 
|---|
| 179 | # Either the command worked, or it is an unexpected error. | 
|---|
| 180 | [[ -s $errMsg ]] && $cat $errMsg 1>&2 | 
|---|
| 181 | #   [[ $rc -ne 0 ]] && printErrorMsg 171 "$mmcmd" "tscrfileset" $rc | 
|---|
| 182 | fi  # end of if [[ $rc -eq $MM_FsNotFound ]] | 
|---|
| 183 | cleanupAndExit $rc | 
|---|
| 184 | fi  # end of if [[ ($rc -ne $MM_DaemonDown && ... ]] | 
|---|
| 185 | $rm -f $errMsg | 
|---|
| 186 |  | 
|---|
| 187 |  | 
|---|
| 188 | #################################################################### | 
|---|
| 189 | # We come here if the local GPFS daemon is not ready for commands. | 
|---|
| 190 | # Find an active node and send the command there. | 
|---|
| 191 | #################################################################### | 
|---|
| 192 |  | 
|---|
| 193 | # Create a file with the reliable names of the nodes in the cluster. | 
|---|
| 194 | getNodeList $REL_HOSTNAME_Field $GLOBAL_ID $mmsdrfsFile > $nodefile | 
|---|
| 195 | preferredNode=$ourNodeName | 
|---|
| 196 |  | 
|---|
| 197 | # Try the nodes one by one until you find a node that can execute the command. | 
|---|
| 198 | if [[ -n $userComments ]] | 
|---|
| 199 | then | 
|---|
| 200 | $mmcommon onactive $preferredNode $nodefile     \ | 
|---|
| 201 | $NO_FILE_COPY $NO_MOUNT_CHECK NULL $NO_LINK  \ | 
|---|
| 202 | tscrfileset $fqDeviceName $filesetName -t "$userComments" | 
|---|
| 203 | rc=$? | 
|---|
| 204 | else | 
|---|
| 205 | $mmcommon onactive $preferredNode $nodefile     \ | 
|---|
| 206 | $NO_FILE_COPY $NO_MOUNT_CHECK NULL $NO_LINK  \ | 
|---|
| 207 | tscrfileset $fqDeviceName $filesetName | 
|---|
| 208 | rc=$? | 
|---|
| 209 | fi | 
|---|
| 210 |  | 
|---|
| 211 | # if [[ $rc -ne 0 ]] | 
|---|
| 212 | # then | 
|---|
| 213 | #   # tscrfileset failed. | 
|---|
| 214 | #   printErrorMsg 104 $mmcmd tscrfileset | 
|---|
| 215 | #   cleanupAndExit $rc | 
|---|
| 216 | # fi | 
|---|
| 217 |  | 
|---|
| 218 | cleanupAndExit $rc | 
|---|
| 219 |  | 
|---|