[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. 1997,2007 |
---|
| 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 | # @(#)30 1.103.3.4 src/avs/fs/mmfs/ts/admin/mmrpldisk.sh, mmfs, avs_rgpfs24, rgpfs24s010a 2/15/07 03:27:20 |
---|
| 17 | ############################################################################# |
---|
| 18 | # |
---|
| 19 | # Usage: |
---|
| 20 | # mmrpldisk Device DiskName {DiskDesc | -F DescFile} [-v {yes | no}] |
---|
| 21 | # [-N {all | mount | Node[,Node...] | NodeFile | NodeClass}] |
---|
| 22 | # |
---|
| 23 | # where |
---|
| 24 | # Device is the file system device name |
---|
| 25 | # DiskName is the name of the disk to replace ($olddisk) |
---|
| 26 | # DiskDesc is a single disk descriptor |
---|
| 27 | # -v make sure the disk does not belong to another file system |
---|
| 28 | # -N parallel restripe options: |
---|
| 29 | # all - use all of the nodes in the cluster |
---|
| 30 | # mount - use only the nodes on which the fs is mounted |
---|
| 31 | # node list - use only the nodes in the list |
---|
| 32 | # node file - use only the nodes in the file |
---|
| 33 | # node class - use only the nodes in the class |
---|
| 34 | # |
---|
| 35 | ############################################################################# |
---|
| 36 | |
---|
| 37 | # Include global declarations and service routines. |
---|
| 38 | . /usr/lpp/mmfs/bin/mmglobfuncs |
---|
| 39 | . /usr/lpp/mmfs/bin/mmsdrfsdef |
---|
| 40 | . /usr/lpp/mmfs/bin/mmfsfuncs |
---|
| 41 | |
---|
| 42 | sourceFile="mmrpldisk.sh" |
---|
| 43 | [[ -n $DEBUG || -n $DEBUGmmrpldisk ]] && set -x |
---|
| 44 | $mmTRACE_ENTER "$*" |
---|
| 45 | |
---|
| 46 | |
---|
| 47 | # Local work files. Names should be of the form: |
---|
| 48 | # fn=${tmpDir}fn.${mmcmd}.$$ |
---|
| 49 | |
---|
| 50 | descfile=${tmpDir}descfile.${mmcmd}.$$ |
---|
| 51 | tempsdrfs=${tmpDir}tempsdrfs.${mmcmd}.$$ |
---|
| 52 | |
---|
| 53 | LOCAL_FILES=" $descfile $tempsdrfs " |
---|
| 54 | |
---|
| 55 | |
---|
| 56 | # Local variables |
---|
| 57 | usageMsg=295 |
---|
| 58 | |
---|
| 59 | |
---|
| 60 | # Local functions |
---|
| 61 | |
---|
| 62 | |
---|
| 63 | ####################### |
---|
| 64 | # Mainline processing |
---|
| 65 | ####################### |
---|
| 66 | |
---|
| 67 | |
---|
| 68 | ####################################### |
---|
| 69 | # Process the command line arguments. |
---|
| 70 | ####################################### |
---|
| 71 | [[ $arg1 = '-?' || $arg1 = '-h' || $arg1 = '--help' || $arg1 = '--' ]] && \ |
---|
| 72 | syntaxError "help" $usageMsg |
---|
| 73 | |
---|
| 74 | [[ $argc -lt 3 ]] && \ |
---|
| 75 | syntaxError "missingArgs" $usageMsg |
---|
| 76 | |
---|
| 77 | # The first argument is always the file system name. |
---|
| 78 | device=$arg1 |
---|
| 79 | |
---|
| 80 | # The second argument is always the name of the disk to be replaced. |
---|
| 81 | olddisk=$arg2 |
---|
| 82 | |
---|
| 83 | if [[ $arg3 != "-F" ]] |
---|
| 84 | then |
---|
| 85 | # If the third argument is not -F, it must be |
---|
| 86 | # a disk descriptor for the new disk. |
---|
| 87 | mmDiskDesc=$arg3 |
---|
| 88 | shift 3 |
---|
| 89 | else |
---|
| 90 | # -F was specified. The fourth argument must be a file name |
---|
| 91 | # containing a single disk descriptor for the new disk. |
---|
| 92 | if [[ -z $arg4 ]] |
---|
| 93 | then |
---|
| 94 | syntaxError "missingFile" $usageMsg |
---|
| 95 | else |
---|
| 96 | # Verify the existence of the file and create our own copy. |
---|
| 97 | checkUserFile $arg4 $descfile |
---|
| 98 | [[ $? -ne 0 ]] && cleanupAndExit |
---|
| 99 | shift 4 |
---|
| 100 | fi # end of if [[ -z $arg4 ]] |
---|
| 101 | |
---|
| 102 | # Get the descriptor from the file. |
---|
| 103 | # We will get only the first non-comment and non-white |
---|
| 104 | # space only line. Everything else will be ignored. |
---|
| 105 | exec 3<&- |
---|
| 106 | exec 3< $descfile |
---|
| 107 | while read -u3 inputLine |
---|
| 108 | do |
---|
| 109 | # Skip empty and comment lines. |
---|
| 110 | [[ $inputLine = *([$BLANKchar$TABchar]) ]] && continue |
---|
| 111 | [[ $inputLine = *([$BLANKchar$TABchar])#* ]] && continue |
---|
| 112 | |
---|
| 113 | # Assume this line contains a descriptor. |
---|
| 114 | if [[ -z $mmDiskDesc ]] |
---|
| 115 | then |
---|
| 116 | mmDiskDesc=$inputLine |
---|
| 117 | else |
---|
| 118 | # The descriptor file contains more than one descriptor. |
---|
| 119 | printErrorMsg 537 $mmcmd |
---|
| 120 | cleanupAndExit |
---|
| 121 | fi |
---|
| 122 | done # end of while read -u3 inputLine |
---|
| 123 | |
---|
| 124 | if [[ -z $mmDiskDesc ]] |
---|
| 125 | then |
---|
| 126 | # The descriptor file contains no descriptor. |
---|
| 127 | printErrorMsg 538 $mmcmd |
---|
| 128 | cleanupAndExit |
---|
| 129 | fi |
---|
| 130 | fi # end of if [[ $arg3 != "-F" ]] |
---|
| 131 | |
---|
| 132 | |
---|
| 133 | # Parse the optional parameters. |
---|
| 134 | while getopts :v:N: OPT |
---|
| 135 | do |
---|
| 136 | case $OPT in |
---|
| 137 | v) [[ -n $vflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT" |
---|
| 138 | if [[ $OPTARG = yes || $OPTARG = no ]] |
---|
| 139 | then |
---|
| 140 | vflag="-v $OPTARG" |
---|
| 141 | else |
---|
| 142 | syntaxError "YesNoValue" $noUsageMsg "-$OPT" |
---|
| 143 | fi |
---|
| 144 | ;; |
---|
| 145 | |
---|
| 146 | N) [[ -n $Nflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT" |
---|
| 147 | nodeList="$OPTARG" |
---|
| 148 | Nflag="-N $OPTARG" |
---|
| 149 | ;; |
---|
| 150 | |
---|
| 151 | :) syntaxError "missingValue" $usageMsg $OPTARG |
---|
| 152 | ;; |
---|
| 153 | |
---|
| 154 | +[vN) |
---|
| 155 | syntaxError "invalidOption" $usageMsg $OPT |
---|
| 156 | ;; |
---|
| 157 | |
---|
| 158 | *) syntaxError "invalidOption" $usageMsg $OPTARG |
---|
| 159 | ;; |
---|
| 160 | esac |
---|
| 161 | done |
---|
| 162 | |
---|
| 163 | shift OPTIND-1 |
---|
| 164 | [[ $# != 0 ]] && syntaxError "extraArg" $usageMsg $1 |
---|
| 165 | |
---|
| 166 | |
---|
| 167 | ####################################################################### |
---|
| 168 | # Set up trap exception handling and call the gpfsInit function. |
---|
| 169 | # It will ensure that the local copy of the mmsdrfs and the rest of |
---|
| 170 | # the GPFS system files are up-to-date and will obtain the sdr lock. |
---|
| 171 | ####################################################################### |
---|
| 172 | trap pretrap HUP INT QUIT KILL |
---|
| 173 | gpfsInitOutput=$(gpfsInit $lockId) |
---|
| 174 | setGlobalVar $? $gpfsInitOutput |
---|
| 175 | |
---|
| 176 | # Determine the lookup order for resolving host names. |
---|
| 177 | [[ $osName != AIX ]] && resolveOrder=$(setHostResolveOrder) |
---|
| 178 | |
---|
| 179 | |
---|
| 180 | ########################################################### |
---|
| 181 | # Make sure the specified file system exists and is local. |
---|
| 182 | ########################################################### |
---|
| 183 | findFSoutput=$(findFS "$device" $mmsdrfsFile) |
---|
| 184 | [[ -z $findFSoutput ]] && cleanupAndExit |
---|
| 185 | |
---|
| 186 | # Parse the output from the findFS function. |
---|
| 187 | set -f ; set -- $findFSoutput ; set +f |
---|
| 188 | fqDeviceName=$1 |
---|
| 189 | deviceName=$2 |
---|
| 190 | fsHomeCluster=$3 |
---|
| 191 | oddState=$5 |
---|
| 192 | |
---|
| 193 | # Exit with a message if the command was invoked for a remote file system. |
---|
| 194 | if [[ $fsHomeCluster != $HOME_CLUSTER ]] |
---|
| 195 | then |
---|
| 196 | # Command is not allowed for remote file systems. |
---|
| 197 | printErrorMsg 106 $mmcmd $device $fsHomeCluster |
---|
| 198 | cleanupAndExit |
---|
| 199 | fi |
---|
| 200 | |
---|
| 201 | # Check whether some of the disks in the file system may be in an odd state. |
---|
| 202 | if [[ $oddState = yes ]] |
---|
| 203 | then |
---|
| 204 | # Some of the disks in the file system appear to be in an odd state. |
---|
| 205 | # Reconcile the sdrfs file with the GPFS daemon's view of the filesystem. |
---|
| 206 | $cp $mmsdrfsFile $newsdrfs |
---|
| 207 | reconcileSdrfsWithDaemon $deviceName $newsdrfs |
---|
| 208 | rc=$? |
---|
| 209 | if [[ $rc -ne 0 ]] |
---|
| 210 | then |
---|
| 211 | # reconcileSdrfsWithDaemon failed. |
---|
| 212 | printErrorMsg 171 $mmcmd reconcileSdrfsWithDaemon $rc |
---|
| 213 | # Tell the user to run mmcommon recoverfs against the file system. |
---|
| 214 | printErrorMsg 103 $mmcmd $deviceName $deviceName |
---|
| 215 | cleanupAndExit |
---|
| 216 | fi |
---|
| 217 | |
---|
| 218 | # Obtain the generation number from the version line of the new sdrfs file. |
---|
| 219 | versionLine=$($head -1 $newsdrfs) |
---|
| 220 | IFS=':' |
---|
| 221 | set -f ; set -- $versionLine ; set +f |
---|
| 222 | newGenNumber=$6 |
---|
| 223 | IFS="$IFS_sv" |
---|
| 224 | |
---|
| 225 | # Commit the reconciled version of the sdrfs file to the server |
---|
| 226 | # so the admin scripts and the daemon are in sync. |
---|
| 227 | trap "" HUP INT QUIT KILL # Disable interrupts until the commit is done. |
---|
| 228 | gpfsObjectInfo=$(commitChanges \ |
---|
| 229 | $fsHomeCluster $nsId $gpfsObjectInfo $newGenNumber $newsdrfs $primaryServer) |
---|
| 230 | if [[ $? -ne 0 ]] |
---|
| 231 | then |
---|
| 232 | # We were unable to replace the file in the sdr. |
---|
| 233 | printErrorMsg 381 $mmcmd |
---|
| 234 | # Tell the user to run mmcommon recoverfs against the filesystem. |
---|
| 235 | printErrorMsg 190 $mmcmd $deviceName $deviceName |
---|
| 236 | printErrorMsg 104 $mmcmd mmrpldisk |
---|
| 237 | cleanupAndExit |
---|
| 238 | fi |
---|
| 239 | trap posttrap HUP INT QUIT KILL |
---|
| 240 | fi # end of if [[ $oddState = yes ]] |
---|
| 241 | |
---|
| 242 | |
---|
| 243 | ####################################################### |
---|
| 244 | # If a list of nodes was specified via the -N option, |
---|
| 245 | # convert it to a verified list of daemon node names. |
---|
| 246 | ####################################################### |
---|
| 247 | if [[ -n $Nflag && $nodeList != all && $nodeList != mount ]] |
---|
| 248 | then |
---|
| 249 | createVerifiedNodefile "$nodeList" $DAEMON_NODENAME_Field no $nodefile |
---|
| 250 | [[ $? -ne 0 ]] && cleanupAndExit |
---|
| 251 | |
---|
| 252 | # Convert the output data from a file to a comma-separated list. |
---|
| 253 | newNodeList=$(print -- $(cat $nodefile) | $sed 's/ /,/g') |
---|
| 254 | Nflag="-N $newNodeList" |
---|
| 255 | fi # end of if [[ -n $Nflag && $nodeList != all && $nodeList != mount ]] |
---|
| 256 | |
---|
| 257 | |
---|
| 258 | ################################################## |
---|
| 259 | # Obtain the disk name from the disk descriptor. |
---|
| 260 | ################################################## |
---|
| 261 | IFS=":" |
---|
| 262 | set -f ; set -- $mmDiskDesc ; set +f |
---|
| 263 | diskName=$1 |
---|
| 264 | IFS="$IFS_sv" |
---|
| 265 | |
---|
| 266 | if [[ -z $diskName ]] |
---|
| 267 | then |
---|
| 268 | # Disk name must be specified in the disk descriptor. |
---|
| 269 | printErrorMsg 23 $mmcmd |
---|
| 270 | cleanupAndExit |
---|
| 271 | fi |
---|
| 272 | |
---|
| 273 | |
---|
| 274 | ######################################################################## |
---|
| 275 | # Create the new version of the mmsdrfs file. |
---|
| 276 | # |
---|
| 277 | # It will have a new generation number and the SG_DISKS lines |
---|
| 278 | # for the involved disks will have new values. |
---|
| 279 | # |
---|
| 280 | # Simultaneously, we will make sure that the new disk does not already |
---|
| 281 | # belong to some other file system, and we will create a list of the |
---|
| 282 | # nodes in the cluster. |
---|
| 283 | ######################################################################## |
---|
| 284 | $rm -f $newsdrfs $nodefile $allQuorumNodes |
---|
| 285 | IFS=":" |
---|
| 286 | exec 3<&- |
---|
| 287 | exec 3< $mmsdrfsFile |
---|
| 288 | while read -u3 sdrfsLine |
---|
| 289 | do |
---|
| 290 | # Parse the line. |
---|
| 291 | set -f ; set -A v -- - $sdrfsLine ; set +f |
---|
| 292 | |
---|
| 293 | IFS="$IFS_sv" # Restore the default IFS settings. |
---|
| 294 | printLine=true # Assume the line will be printed. |
---|
| 295 | |
---|
| 296 | case ${v[$LINE_TYPE_Field]} in |
---|
| 297 | |
---|
| 298 | $VERSION_LINE ) # This is the global header line. |
---|
| 299 | # Increment the generation number. |
---|
| 300 | newGenNumber=${v[$SDRFS_GENNUM_Field]}+1 |
---|
| 301 | v[$SDRFS_GENNUM_Field]=$newGenNumber |
---|
| 302 | ;; |
---|
| 303 | |
---|
| 304 | $MEMBER_NODE ) # This line describes a node. |
---|
| 305 | # Add the reliable node name to nodefile. |
---|
| 306 | print -- "${v[$REL_HOSTNAME_Field]}" >> $nodefile |
---|
| 307 | checkForErrors "writing to file $nodefile" $? |
---|
| 308 | |
---|
| 309 | # Create a list of the quorum nodes. |
---|
| 310 | if [[ ${v[$CORE_QUORUM_Field]} = $quorumNode ]] |
---|
| 311 | then |
---|
| 312 | print -- "${v[$REL_HOSTNAME_Field]}" >> $allQuorumNodes |
---|
| 313 | checkForErrors "writing to file $allQuorumNodes" $? |
---|
| 314 | fi |
---|
| 315 | |
---|
| 316 | # If this is the line for the node that is executing |
---|
| 317 | # this command, set the preferredNode variable. |
---|
| 318 | [[ ${v[$NODE_NUMBER_Field]} = $ourNodeNumber ]] && \ |
---|
| 319 | preferredNode=${v[$REL_HOSTNAME_Field]} |
---|
| 320 | ;; |
---|
| 321 | |
---|
| 322 | $SG_HEADR ) # This is the header line for some file system. |
---|
| 323 | # Check whether the filesystem has disks that are in an "odd state". |
---|
| 324 | if [[ -n ${v[$ODD_STATE_Field]} && ${v[$ODD_STATE_Field]} != no ]] |
---|
| 325 | then |
---|
| 326 | # Is this filesystem a different one than the one for which |
---|
| 327 | # this command was invoked? |
---|
| 328 | if [[ ${v[$DEV_NAME_Field]} != $deviceName ]] |
---|
| 329 | then |
---|
| 330 | # The "odd state" flag is set for a different file system |
---|
| 331 | # than our filesystem. Add the name of the file system to a |
---|
| 332 | # list of filesystems to be reported to the user later. |
---|
| 333 | fsOddStateList="${fsOddStateList} ${v[$DEV_NAME_Field]}" |
---|
| 334 | else |
---|
| 335 | # The "odd state" flag is set for the file system |
---|
| 336 | # for which this command was invoked. |
---|
| 337 | : # Allow the command to proceed, since it may succeed. |
---|
| 338 | # We will report any failures if it does not. |
---|
| 339 | fi |
---|
| 340 | else |
---|
| 341 | # Is this filesystem the one for which this command was invoked? |
---|
| 342 | if [[ ${v[$DEV_NAME_Field]} = $deviceName ]] |
---|
| 343 | then |
---|
| 344 | # Set the "odd state" field in case we don't succeed. |
---|
| 345 | # We will reset it later if tsrpldisk succeeds. |
---|
| 346 | v[$ODD_STATE_Field]=mmrpldisk |
---|
| 347 | fi |
---|
| 348 | fi |
---|
| 349 | ;; |
---|
| 350 | |
---|
| 351 | $SG_DISKS ) # This line describes a disk. |
---|
| 352 | # If this is the line for the new disk (the replacement disk), |
---|
| 353 | # make sure that it is either a free disk or a replacement disk |
---|
| 354 | # from a prior mmrpldisk that did not complete. |
---|
| 355 | if [[ ${v[$DISK_NAME_Field]} = $diskName ]] |
---|
| 356 | then |
---|
| 357 | # Is the disk a free disk or a replacement disk from a |
---|
| 358 | # prior mmrpldisk that did not complete? |
---|
| 359 | if [[ ${v[$NODESETID_Field]} = $FREE_DISK || |
---|
| 360 | ( ${v[$DEV_NAME_Field]} = $device && |
---|
| 361 | ${v[$DISK_STATUS_Field]} = "replacement" ) ]] |
---|
| 362 | then |
---|
| 363 | # We found the intended replacement disk. |
---|
| 364 | # Create a copy of the line in $sgdiskLine with a sequence |
---|
| 365 | # number equal to that of the disk being replaced; this will |
---|
| 366 | # be passed to the validateAndConvertNsdDescriptor routine. |
---|
| 367 | # Suppress printing of the line now, since we will use the |
---|
| 368 | # updated line produced by the validate routine. |
---|
| 369 | v[$LINE_NUMBER_Field]=$seqNo |
---|
| 370 | sgdiskLine=$(print_newLine) |
---|
| 371 | printLine=false |
---|
| 372 | else |
---|
| 373 | # The disk already exists in another file system. |
---|
| 374 | # Issue an error and quit. |
---|
| 375 | printErrorMsg 265 $mmcmd $diskName ${v[$DEV_NAME_Field]} |
---|
| 376 | cleanupAndExit |
---|
| 377 | fi # end of if [[ ${v[$NODESETID_Field]} = $FREE_DISK ]] |
---|
| 378 | |
---|
| 379 | # If this is the line for the old disk (the disk being replaced), |
---|
| 380 | # make sure that it belongs to the specified file system and |
---|
| 381 | # change the disk status to indicate the disk should be deleted |
---|
| 382 | # (converted to a free disk) if tsrpldisk succeeds. |
---|
| 383 | elif [[ ${v[$DISK_NAME_Field]} = $olddisk ]] |
---|
| 384 | then |
---|
| 385 | if [[ ${v[$DEV_NAME_Field]} = $deviceName ]] |
---|
| 386 | then |
---|
| 387 | v[$EXCLUDE_Field]=$includedDisk |
---|
| 388 | v[$DISK_STATUS_Field]="mmdel" |
---|
| 389 | oldDiskFound=yes |
---|
| 390 | seqNo=${v[$LINE_NUMBER_Field]} |
---|
| 391 | else |
---|
| 392 | # The disk being replaced is not part of the specified file system. |
---|
| 393 | # Issue an error and quit. |
---|
| 394 | printErrorMsg 101 $mmcmd $olddisk $device |
---|
| 395 | cleanupAndExit |
---|
| 396 | fi |
---|
| 397 | |
---|
| 398 | # If this line is for some other disk in the same file system, |
---|
| 399 | # set a flag to indicate that this is not a single disk file system. |
---|
| 400 | elif [[ ${v[$DEV_NAME_Field]} = $deviceName ]] |
---|
| 401 | then |
---|
| 402 | singleDiskFileSystem=no |
---|
| 403 | |
---|
| 404 | fi # end of if [[ ${v[$DISK_NAME_Field]} = $diskName ]] |
---|
| 405 | ;; |
---|
| 406 | |
---|
| 407 | * ) # Pass all other lines without a change. |
---|
| 408 | ;; |
---|
| 409 | |
---|
| 410 | esac # end of "Change some of the fields . . . " |
---|
| 411 | |
---|
| 412 | # Build and write the line to the new mmsdrfs file. |
---|
| 413 | if [[ $printLine = true ]] |
---|
| 414 | then |
---|
| 415 | print_newLine >> $newsdrfs |
---|
| 416 | checkForErrors "writing to file $newsdrfs" $? |
---|
| 417 | fi |
---|
| 418 | |
---|
| 419 | IFS=":" # Change the separator back to ":" for the next iteration. |
---|
| 420 | |
---|
| 421 | done # end while read -u3 sdrfsLine |
---|
| 422 | |
---|
| 423 | IFS="$IFS_sv" # Restore the default IFS settings. |
---|
| 424 | |
---|
| 425 | |
---|
| 426 | if [[ -z $oldDiskFound ]] |
---|
| 427 | then |
---|
| 428 | # The disk to be replaced was not found to belong to the file system. |
---|
| 429 | printErrorMsg 315 $mmcmd $olddisk $device |
---|
| 430 | cleanupAndExit |
---|
| 431 | fi |
---|
| 432 | |
---|
| 433 | if [[ -z $sgdiskLine ]] |
---|
| 434 | then |
---|
| 435 | # We did not find the replacement disk. |
---|
| 436 | # The disk descriptor should refer to an existing NSD. |
---|
| 437 | printErrorMsg 415 $mmcmd "$mmDiskDesc" |
---|
| 438 | cleanupAndExit |
---|
| 439 | fi |
---|
| 440 | |
---|
| 441 | |
---|
| 442 | ############################################################################## |
---|
| 443 | # Process the descriptor for the replacement disk. |
---|
| 444 | # If all of the information is correct, the descriptor is converted into |
---|
| 445 | # the format recognized by the tsrpldisk command. Specifying oldDiskUsage |
---|
| 446 | # will cause the validate routine to not set the hasData and hasMetadata |
---|
| 447 | # flags in the ts descriptor. As a result, the replacement disk will inherit |
---|
| 448 | # the usage properties from the disk being replaced. If the user specified |
---|
| 449 | # diskUsage in the mm descriptor, the oldDiskUsage parameter has no effect. |
---|
| 450 | ############################################################################## |
---|
| 451 | validateDescriptorOutput=$(validateAndConvertNsdDescriptor "$mmDiskDesc" \ |
---|
| 452 | $sgdiskLine $deviceName $fsHomeCluster mmadd oldDiskUsage) |
---|
| 453 | rc=$? |
---|
| 454 | if [[ $rc -ne 0 ]] |
---|
| 455 | then |
---|
| 456 | # If an error was found, the validate routine issued a message. |
---|
| 457 | # We will now print the entire descriptor to help the guy some more. |
---|
| 458 | printErrorMsg 386 $mmcmd "$mmDiskDesc" |
---|
| 459 | cleanupAndExit |
---|
| 460 | fi |
---|
| 461 | |
---|
| 462 | # If the descriptor seems to be OK, parse the output |
---|
| 463 | # from the validateAndConvertNsdDescriptor routine. |
---|
| 464 | set -f ; set -- $validateDescriptorOutput ; set +f |
---|
| 465 | updatedDiskLine="$1" |
---|
| 466 | tsDiskDesc="$2" |
---|
| 467 | |
---|
| 468 | # Add the SG_DISKS line for the replacement disk to the mmsdrfs file. |
---|
| 469 | print -- $updatedDiskLine >> $newsdrfs |
---|
| 470 | checkForErrors "writing to file $newsdrfs" $? |
---|
| 471 | |
---|
| 472 | # Make a copy of the current mmsdrfs file. It may be needed |
---|
| 473 | # to restore the mmsdrfs file if the tsrpldisk command fails. |
---|
| 474 | $cp $mmsdrfsFile $oldsdrfs |
---|
| 475 | checkForErrors cp $? |
---|
| 476 | |
---|
| 477 | |
---|
| 478 | ############################################################################# |
---|
| 479 | # Put the new mmsdrfs file in the sdr. This will allow the getEFOptions |
---|
| 480 | # call that tsrpldisk is going to make shortly to return a list of disks |
---|
| 481 | # that does not include the disk that is being replaced. This commit also |
---|
| 482 | # serves as the "pre-commit" that indicates an mmrpldisk is in progress. |
---|
| 483 | # The commit is done only if there is more than one disk in the file system. |
---|
| 484 | ############################################################################# |
---|
| 485 | trap "" HUP INT QUIT KILL # Disable interrupts until the commit is done. |
---|
| 486 | if [[ $singleDiskFileSystem = no ]] |
---|
| 487 | then |
---|
| 488 | # Make sure the file is properly sorted. |
---|
| 489 | LC_ALL=C $SORT_MMSDRFS $newsdrfs -o $newsdrfs |
---|
| 490 | |
---|
| 491 | gpfsObjectInfo=$(commitChanges $fsHomeCluster $nsId \ |
---|
| 492 | $gpfsObjectInfo $newGenNumber $newsdrfs $primaryServer) |
---|
| 493 | rc=$? |
---|
| 494 | if [[ $rc -ne 0 ]] |
---|
| 495 | then |
---|
| 496 | # We were unable to replace the file in the sdr. |
---|
| 497 | printErrorMsg 381 $mmcmd |
---|
| 498 | cleanupAndExit |
---|
| 499 | fi |
---|
| 500 | else |
---|
| 501 | # You cannot use mmrpldisk to replace the only disk in a file system. |
---|
| 502 | printErrorMsg 360 $mmcmd $olddisk $device |
---|
| 503 | cleanupAndExit |
---|
| 504 | fi |
---|
| 505 | trap posttrap HUP INT QUIT KILL |
---|
| 506 | |
---|
| 507 | |
---|
| 508 | ################################ |
---|
| 509 | # Invoke the tsrpldisk command. |
---|
| 510 | ################################ |
---|
| 511 | # Issue "Replacing disk . . ." message. |
---|
| 512 | printInfoMsg 96 $olddisk |
---|
| 513 | |
---|
| 514 | $mmcommon onactive \ |
---|
| 515 | $preferredNode $nodefile $NO_FILE_COPY $NO_MOUNT_CHECK NULL $NO_LINK \ |
---|
| 516 | tsrpldisk "$fqDeviceName -d $olddisk -n $tsDiskDesc $vflag $Nflag" |
---|
| 517 | rc=$? |
---|
| 518 | if [[ $rc -ne 0 ]] |
---|
| 519 | then |
---|
| 520 | # tsrpldisk failed. |
---|
| 521 | printErrorMsg 104 $mmcmd tsrpldisk |
---|
| 522 | |
---|
| 523 | # Was the GPFS daemon up anywhere for tsrpldisk to run? |
---|
| 524 | if [[ $rc -eq $MM_DaemonDown ]] |
---|
| 525 | then |
---|
| 526 | # tsrpldisk was never attempted because the daemon was not up anywhere. |
---|
| 527 | # Make a modified version of the original sdrfs file with the generation |
---|
| 528 | # number in the global header incremented by 2 but no other changes. |
---|
| 529 | $rm -f $newsdrfs |
---|
| 530 | newGenNumber=$($awk -F: ' \ |
---|
| 531 | BEGIN { gen = 0 } \ |
---|
| 532 | # If this is the global header line, increment the gen number. \ |
---|
| 533 | /^'$GLOBAL_ID:$VERSION_LINE:'/ { \ |
---|
| 534 | { gen = $'$SDRFS_GENNUM_Field' + 2 } \ |
---|
| 535 | { $'$SDRFS_GENNUM_Field' = gen } \ |
---|
| 536 | { print $1":" $2":" $3":" $4":" $5":" $6":" $7":" $8":" $9":"$10":" \ |
---|
| 537 | $11":"$12":"$13":"$14":"$15":"$16":"$17":"$18":"$19":"$20":" \ |
---|
| 538 | $21":"$22":"$23":"$24":"$25":"$26":"$27":" >> "'$newsdrfs'" } \ |
---|
| 539 | { next } \ |
---|
| 540 | } \ |
---|
| 541 | # All other lines are printed without change. \ |
---|
| 542 | { print $0 >> "'$newsdrfs'" } \ |
---|
| 543 | END { print gen } \ |
---|
| 544 | ' $oldsdrfs) |
---|
| 545 | checkForErrors awk $? |
---|
| 546 | else |
---|
| 547 | # Since tsrpldisk was attempted but failed, reconcile the |
---|
| 548 | # sdrfs file with the GPFS daemon's view of the filesystem. |
---|
| 549 | reconcileSdrfsWithDaemon $deviceName $newsdrfs |
---|
| 550 | rc2=$? |
---|
| 551 | if [[ $rc2 -ne 0 ]] |
---|
| 552 | then |
---|
| 553 | # reconcileSdrfsWithDaemon failed. |
---|
| 554 | printErrorMsg 171 $mmcmd reconcileSdrfsWithDaemon $rc2 |
---|
| 555 | # Tell the user to run mmcommon recoverfs against the filesystem. |
---|
| 556 | printErrorMsg 190 $mmcmd $deviceName $deviceName |
---|
| 557 | cleanupAndExit $rc |
---|
| 558 | fi |
---|
| 559 | # Obtain the generation number from the version line of the new sdrfs file. |
---|
| 560 | versionLine=$($head -1 $newsdrfs) |
---|
| 561 | IFS=':' |
---|
| 562 | set -f ; set -- $versionLine ; set +f |
---|
| 563 | newGenNumber=$6 |
---|
| 564 | IFS="$IFS_sv" |
---|
| 565 | fi # end of if [[ $rc -eq $MM_DaemonDown ]] |
---|
| 566 | |
---|
| 567 | # Commit the modified version of the sdrfs file to the server. |
---|
| 568 | trap "" HUP INT QUIT KILL # Disable interrupts until the commit is done. |
---|
| 569 | gpfsObjectInfo=$(commitChanges \ |
---|
| 570 | $fsHomeCluster $nsId $gpfsObjectInfo $newGenNumber $newsdrfs $primaryServer) |
---|
| 571 | if [[ $? -ne 0 ]] |
---|
| 572 | then |
---|
| 573 | # We were unable to replace the file in the sdr. |
---|
| 574 | printErrorMsg 381 $mmcmd |
---|
| 575 | # Tell the user to run mmcommon recoverfs against the filesystem. |
---|
| 576 | printErrorMsg 190 $mmcmd $deviceName $deviceName |
---|
| 577 | fi |
---|
| 578 | |
---|
| 579 | # Unlock the sdr. |
---|
| 580 | [[ $sdrLocked = yes ]] && \ |
---|
| 581 | freeLockOnServer $primaryServer $ourNodeNumber >/dev/null |
---|
| 582 | sdrLocked=no |
---|
| 583 | trap posttrap HUP INT QUIT KILL |
---|
| 584 | |
---|
| 585 | # Propagate the new mmsdrfs file. This process is asynchronous. |
---|
| 586 | propagateSdrfsFile async $nodefile $newsdrfs $newGenNumber |
---|
| 587 | |
---|
| 588 | cleanupAndExit $rc |
---|
| 589 | fi |
---|
| 590 | |
---|
| 591 | |
---|
| 592 | ################################################################### |
---|
| 593 | # If here, tsrpldisk was successful. |
---|
| 594 | # Invoke routine to change the SG_DISKS lines with a disk status |
---|
| 595 | # of mmadd and mmdel to a regular (null) disk status and then |
---|
| 596 | # commit the new mmsdrfs file. This makes the new disks visible |
---|
| 597 | # to future mm commands and to the mmcommon getEFOptions function. |
---|
| 598 | ################################################################### |
---|
| 599 | # We finished replacing the disk. |
---|
| 600 | printInfoMsg 99 |
---|
| 601 | |
---|
| 602 | # Reset the status fields of the two involved disks (replacer/replacee). |
---|
| 603 | resetDiskStatus $deviceName $newsdrfs mmadd mmdel |
---|
| 604 | checkForErrors updateDiskStatus $? |
---|
| 605 | |
---|
| 606 | # Obtain the generation number from the version line of the new sdrfs file. |
---|
| 607 | versionLine=$($head -1 $newsdrfs) |
---|
| 608 | IFS=':' |
---|
| 609 | set -f ; set -- $versionLine ; set +f |
---|
| 610 | newGenNumber=$6 |
---|
| 611 | IFS="$IFS_sv" |
---|
| 612 | |
---|
| 613 | # Commit the new mmsdrfs file. |
---|
| 614 | trap "" HUP INT QUIT KILL # Disable interrupts until the commit is done. |
---|
| 615 | gpfsObjectInfo=$(commitChanges \ |
---|
| 616 | $fsHomeCluster $nsId $gpfsObjectInfo $newGenNumber $newsdrfs $primaryServer) |
---|
| 617 | rc=$? |
---|
| 618 | if [[ $rc -ne 0 ]] |
---|
| 619 | then |
---|
| 620 | # We were unable to replace the file in the sdr. |
---|
| 621 | printErrorMsg 381 $mmcmd |
---|
| 622 | # Tell the user to run mmcommon recoverfs against the filesystem. |
---|
| 623 | printErrorMsg 190 $mmcmd $deviceName $deviceName |
---|
| 624 | cleanupAndExit |
---|
| 625 | fi |
---|
| 626 | |
---|
| 627 | |
---|
| 628 | ################################################### |
---|
| 629 | # Unlock the sdr. |
---|
| 630 | ################################################### |
---|
| 631 | [[ $sdrLocked = yes ]] && \ |
---|
| 632 | freeLockOnServer $primaryServer $ourNodeNumber >/dev/null |
---|
| 633 | sdrLocked=no |
---|
| 634 | trap posttrap HUP INT QUIT KILL |
---|
| 635 | |
---|
| 636 | |
---|
| 637 | ###################################################################### |
---|
| 638 | # Tell the daemon to invalidate its currently-cached mount options. |
---|
| 639 | ###################################################################### |
---|
| 640 | $mmcommon onactive $preferredNode $allQuorumNodes \ |
---|
| 641 | $NO_FILE_COPY $NO_MOUNT_CHECK NULL $NO_LINK \ |
---|
| 642 | tsctl resetEFOptions $fqDeviceName > $errMsg 2>&1 |
---|
| 643 | rc=$? |
---|
| 644 | [[ $rc = $MM_DaemonDown ]] && rc=0 |
---|
| 645 | [[ $rc -ne 0 && -s $errMsg ]] && cat $errMsg 2>&1 |
---|
| 646 | $rm -f $errMsg |
---|
| 647 | |
---|
| 648 | |
---|
| 649 | ################################################################# |
---|
| 650 | # Propagate the new mmsdrfs file. This process is asynchronous. |
---|
| 651 | ################################################################# |
---|
| 652 | propagateSdrfsFile async $nodefile $newsdrfs $newGenNumber |
---|
| 653 | |
---|
| 654 | |
---|
| 655 | ################################################### |
---|
| 656 | # If installed, invoke the syncfsconfig user exit. |
---|
| 657 | ################################################### |
---|
| 658 | if [[ -x $syncfsconfig ]] |
---|
| 659 | then |
---|
| 660 | print -- "$mmcmd: Starting $syncfsconfig ..." |
---|
| 661 | $syncfsconfig |
---|
| 662 | print -- "$mmcmd: $syncfsconfig finished." |
---|
| 663 | fi |
---|
| 664 | |
---|
| 665 | |
---|
| 666 | ##################################################################### |
---|
| 667 | # If an "odd state" flag was encountered for any other file systems |
---|
| 668 | # in the mmsdrfs file, tell the user to issue commands to reconcile |
---|
| 669 | # the mmsdrfs file with the GPFS daemon's view of the filesystems. |
---|
| 670 | ##################################################################### |
---|
| 671 | for fsname in $fsOddStateList |
---|
| 672 | do |
---|
| 673 | # Tell the user to run mmcommon recoverfs against the file system. |
---|
| 674 | printErrorMsg 103 $mmcmd $fsname $fsname |
---|
| 675 | done |
---|
| 676 | |
---|
| 677 | cleanupAndExit 0 |
---|
| 678 | |
---|