[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,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 | # @(#)20 1.163.1.5 src/avs/fs/mmfs/ts/admin/mmcrfs.sh, mmfs, avs_rgpfs24, rgpfs24s007a 10/18/06 13:06:14 |
---|
| 17 | ################################################################################ |
---|
| 18 | # |
---|
| 19 | # Usage: |
---|
| 20 | # mmcrfs Mountpoint Device {"DiskDesc[;DiskDesc...]" | -F DescFile} |
---|
| 21 | # [-A {yes | no | automount}] [-D {posix | nfs4}] |
---|
| 22 | # [-j {cluster | scatter}] [-k {posix | nfs4 | all}] |
---|
| 23 | # [-B BlockSize] [-i InodeSize] [-I IndirectSize] [ -L LogFileSize] |
---|
| 24 | # [-m DefaultMetadataReplicas] [-M MaxMetadataReplicas] |
---|
| 25 | # [-n NumNodes] [-N NumInodes[:NumInodesToPreallocate]] [-Q {yes | no}] |
---|
| 26 | # [-r DefaultDataReplicas] [-R MaxDataReplicas] |
---|
| 27 | # [-s {roundRobin | random | balancedRandom}] |
---|
| 28 | # [-u {yes | no}] |
---|
| 29 | # [-v {yes | no}] [-z {yes | no}] |
---|
| 30 | # [-E {yes | no}] [-S {yes | no}] |
---|
| 31 | # [-K {no | whenpossible | always}] |
---|
| 32 | # |
---|
| 33 | # where |
---|
| 34 | # MountPoint is the mount point directory of the new file system. |
---|
| 35 | # Device is the device name of the new filesystem (/dev/sg0). |
---|
| 36 | # DiskDescList is a list of semicolon-separated disk descriptors. |
---|
| 37 | # DescFile is a file containing disk descriptors, one per line. |
---|
| 38 | # |
---|
| 39 | # See the Admin guide for detailed descriptions of the optional flags. |
---|
| 40 | # |
---|
| 41 | # Notes: The [-z] option will be allowed only if DMAPI is enabled. |
---|
| 42 | # The [-i InodeSize], [-I IndirectSize], [-L LogFileSize] and |
---|
| 43 | # [-s {roundRobin|random|balancedRandom}] options are undocumented. |
---|
| 44 | # |
---|
| 45 | ################################################################################ |
---|
| 46 | |
---|
| 47 | # Include global declarations and service routines. |
---|
| 48 | . /usr/lpp/mmfs/bin/mmglobfuncs |
---|
| 49 | . /usr/lpp/mmfs/bin/mmsdrfsdef |
---|
| 50 | . /usr/lpp/mmfs/bin/mmfsfuncs |
---|
| 51 | |
---|
| 52 | sourceFile="mmcrfs.sh" |
---|
| 53 | [[ -n $DEBUG || -n $DEBUGmmcrfs ]] && set -x |
---|
| 54 | $mmTRACE_ENTER "$*" |
---|
| 55 | |
---|
| 56 | # Local work files. Names should be of the form: |
---|
| 57 | # fn=${tmpDir}fn.${mmcmd}.$$ |
---|
| 58 | |
---|
| 59 | descfile=${tmpDir}descfile.${mmcmd}.$$ # temp file for descriptors |
---|
| 60 | tsddFile=${tmpDir}tsddFile.${mmcmd}.$$ # disk descriptors in tscrfs format |
---|
| 61 | freeDisks=${tmpDir}freeDisks.${mmcmd}.$$ # available unused disks |
---|
| 62 | |
---|
| 63 | LOCAL_FILES=" $descfile $tsddFile $freeDisks " |
---|
| 64 | |
---|
| 65 | |
---|
| 66 | # Local variables |
---|
| 67 | usageMsg=420 |
---|
| 68 | integer seqNo=0 |
---|
| 69 | |
---|
| 70 | # Values for /etc/filesystems stanza lines |
---|
| 71 | sgVFS_Line_Value="mmfs" # only acceptable value |
---|
| 72 | sgTYPE_Line_Value="mmfs" # only acceptable value |
---|
| 73 | sgNODENAME_Line_Value="-" # only acceptable value |
---|
| 74 | sgACCOUNT_Line_Value="false" # only acceptable value |
---|
| 75 | sgRW_OPT_Value="rw" # only acceptable value |
---|
| 76 | sgOTHER_OPT_Value="" |
---|
| 77 | |
---|
| 78 | # Local functions |
---|
| 79 | |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | ####################### |
---|
| 83 | # Mainline processing |
---|
| 84 | ####################### |
---|
| 85 | |
---|
| 86 | |
---|
| 87 | ####################################### |
---|
| 88 | # Process the command line arguments. |
---|
| 89 | ####################################### |
---|
| 90 | [[ $arg1 = '-?' || $arg1 = '-h' || $arg1 = '--help' || $arg1 = '--' ]] && \ |
---|
| 91 | syntaxError "help" $usageMsg |
---|
| 92 | |
---|
| 93 | [[ $argc -lt 3 ]] && \ |
---|
| 94 | syntaxError "missingArgs" $usageMsg |
---|
| 95 | |
---|
| 96 | # Retrieve the positional parameters. |
---|
| 97 | mountPoint=$arg1 |
---|
| 98 | device=$arg2 |
---|
| 99 | |
---|
| 100 | # The disk descriptors were either given as the third command line argument, |
---|
| 101 | # or in a readable file given as the fourth command line argument. |
---|
| 102 | if [[ $arg3 = "-F" ]] |
---|
| 103 | then |
---|
| 104 | # -F specified. The fourth argument must be a file name. |
---|
| 105 | if [[ -z $arg4 ]] |
---|
| 106 | then |
---|
| 107 | syntaxError "missingFile" $usageMsg |
---|
| 108 | else |
---|
| 109 | # Verify the existence of the file and create our own copy. |
---|
| 110 | checkUserFile $arg4 $descfile |
---|
| 111 | [[ $? -ne 0 ]] && cleanupAndExit |
---|
| 112 | shift 4 |
---|
| 113 | fi # end of if [[ -z $arg4 ]] |
---|
| 114 | else |
---|
| 115 | desclist=$arg3 |
---|
| 116 | # Ensure that semi-colon is used as a disk name separator. |
---|
| 117 | [[ "$desclist" = *+([,${BLANKchar}${TABchar}])* ]] && \ |
---|
| 118 | syntaxError "badSeparator_notSemicolon" $noUsageMsg |
---|
| 119 | shift 3 |
---|
| 120 | fi # end of if [[ $arg3 = "-F" ]] |
---|
| 121 | |
---|
| 122 | # Save the remainder of the argument list for later processing by mmcrfsc. |
---|
| 123 | argList=$@ |
---|
| 124 | |
---|
| 125 | # Check for the no-longer-valid -C <nodesetId> parameter. |
---|
| 126 | # Simultaneously, make a quick check for other invalid options. |
---|
| 127 | # The detailed checking will be done later by mmcrfsc. |
---|
| 128 | while getopts :a:A:B:c:C:D:E:f:F:G:i:I:j:k:K:l:L:m:M:n:N:Q:r:R:s:S:U:u:v:w:Z:z: OPT |
---|
| 129 | do |
---|
| 130 | case $OPT in |
---|
| 131 | C) # create the file system in the specified nodeset |
---|
| 132 | syntaxError "obsoleteOption" $usageMsg "-$OPT" |
---|
| 133 | ;; |
---|
| 134 | |
---|
| 135 | N) # maximum number of inodes |
---|
| 136 | [[ -n $Nflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT" |
---|
| 137 | Nflag="-$OPT"; Narg=$OPTARG; |
---|
| 138 | ;; |
---|
| 139 | |
---|
| 140 | [aABcDEfFGijIkKlLmMnNQrRsSUuvwZz]) # all other valid options |
---|
| 141 | : # detailed checking will be done later |
---|
| 142 | ;; |
---|
| 143 | |
---|
| 144 | +[aABcCDEfFGijIkKlLmMnNQrRsSUvwZz]) # invalid option specified |
---|
| 145 | syntaxError "invalidOption" $usageMsg $OPT |
---|
| 146 | ;; |
---|
| 147 | |
---|
| 148 | :) # missing required value after an option |
---|
| 149 | syntaxError "missingValue" $usageMsg $OPTARG |
---|
| 150 | ;; |
---|
| 151 | |
---|
| 152 | *) # invalid option specified |
---|
| 153 | syntaxError "invalidOption" $usageMsg $OPTARG |
---|
| 154 | ;; |
---|
| 155 | esac |
---|
| 156 | done # end of while getopts |
---|
| 157 | |
---|
| 158 | # Verify the device name. |
---|
| 159 | deviceName=${device##+(/)dev+(/)} # name stripped of /dev/ prefix |
---|
| 160 | fqDeviceName="/dev/$deviceName" # fully-qualified name with /dev/ prefix |
---|
| 161 | if [[ $deviceName = /* ]] |
---|
| 162 | then |
---|
| 163 | printErrorMsg 169 $mmcmd $device |
---|
| 164 | cleanupAndExit |
---|
| 165 | elif [[ $deviceName = */* ]] |
---|
| 166 | then |
---|
| 167 | printErrorMsg 170 $mmcmd $device |
---|
| 168 | cleanupAndExit |
---|
| 169 | else |
---|
| 170 | checkName deviceName 255 "$deviceName" |
---|
| 171 | [[ $? -ne 0 ]] && cleanupAndExit |
---|
| 172 | fi |
---|
| 173 | |
---|
| 174 | # Verify the mount point parameter. |
---|
| 175 | checkName pathName 1023 "$mountPoint" |
---|
| 176 | [[ $? -ne 0 ]] && cleanupAndExit |
---|
| 177 | |
---|
| 178 | if [[ $mountPoint = ${mountPoint#/} ]] |
---|
| 179 | then |
---|
| 180 | # The mountpoint must not be a relative path name. |
---|
| 181 | printErrorMsg 148 $mmcmd $mountPoint |
---|
| 182 | cleanupAndExit |
---|
| 183 | fi |
---|
| 184 | |
---|
| 185 | if [[ $fqDeviceName = $mountPoint ]] |
---|
| 186 | then |
---|
| 187 | # The mount point cannot be the same as the device name. |
---|
| 188 | printErrorMsg 305 $mmcmd $mountPoint |
---|
| 189 | cleanupAndExit |
---|
| 190 | fi |
---|
| 191 | |
---|
| 192 | # Process the -N option (mmcrfsc is not suited for this option). |
---|
| 193 | # Verify that the value is of the form NumInodes[:NumInodesToPreallocate] |
---|
| 194 | if [[ -n $Narg ]] |
---|
| 195 | then |
---|
| 196 | IFS=":" |
---|
| 197 | set -f ; set -- $Narg ; set +f |
---|
| 198 | numInodes=$1 |
---|
| 199 | numInodesToPreallocate=$2 |
---|
| 200 | IFS="$IFS_sv" |
---|
| 201 | |
---|
| 202 | [[ -z $numInodes ]] && \ |
---|
| 203 | syntaxError "invalidOption" $usageMsg "$Nflag $Narg" |
---|
| 204 | |
---|
| 205 | n=$(checkIntRange $Nflag $numInodes) |
---|
| 206 | [[ $? -ne 0 ]] && cleanupAndExit |
---|
| 207 | Narg=$n |
---|
| 208 | |
---|
| 209 | if [[ -n $numInodesToPreallocate && $numInodesToPreallocate != 0 ]] |
---|
| 210 | then |
---|
| 211 | n=$(checkIntRange $Nflag $numInodesToPreallocate) |
---|
| 212 | [[ $? -ne 0 ]] && cleanupAndExit |
---|
| 213 | Narg="${Narg}:$n" |
---|
| 214 | fi |
---|
| 215 | fi # end of if [[ -n $Narg ]] |
---|
| 216 | |
---|
| 217 | |
---|
| 218 | ####################################################################### |
---|
| 219 | # Set up trap exception handling and call the gpfsInit function. |
---|
| 220 | # It will ensure that the local copy of the mmsdrfs and the rest of |
---|
| 221 | # the GPFS system files are up-to-date and will obtain the sdr lock. |
---|
| 222 | ####################################################################### |
---|
| 223 | trap pretrap HUP INT QUIT KILL |
---|
| 224 | gpfsInitOutput=$(gpfsInit $lockId) |
---|
| 225 | setGlobalVar $? $gpfsInitOutput |
---|
| 226 | |
---|
| 227 | # Determine the lookup order for resolving host names. |
---|
| 228 | [[ $osName != AIX ]] && resolveOrder=$(setHostResolveOrder) |
---|
| 229 | |
---|
| 230 | |
---|
| 231 | ############################################################################ |
---|
| 232 | # Go through the mmsdrfs file and make sure that the file system we |
---|
| 233 | # are about to create does not already exist and that the new mount |
---|
| 234 | # point is not already in use by some other file system in the nodeset. |
---|
| 235 | # |
---|
| 236 | # Simultaneously, we will create a file containing the reliable node names |
---|
| 237 | # of the nodes in the nodeset. This file will be later used to propagate |
---|
| 238 | # the changes to /etc/filesystems. |
---|
| 239 | # |
---|
| 240 | # We will also create a file containing the names of all disks that |
---|
| 241 | # belong to some file system. This file will be used to assure that |
---|
| 242 | # none of the new disks are already in use. |
---|
| 243 | ############################################################################ |
---|
| 244 | $rm -f $newsdrfs $nodefile $freeDisks |
---|
| 245 | $touch $freeDisks # Ensure the file exists even if empty. |
---|
| 246 | IFS=":" # Change the field separator to ':'. |
---|
| 247 | exec 3<&- |
---|
| 248 | exec 3< $mmsdrfsFile |
---|
| 249 | while read -u3 sdrfsLine |
---|
| 250 | do |
---|
| 251 | # Parse the line. |
---|
| 252 | set -f ; set -A v -- - $sdrfsLine ; set +f |
---|
| 253 | |
---|
| 254 | IFS="$IFS_sv" # Restore the default IFS settings. |
---|
| 255 | printLine=true # Assume the line will be printed. |
---|
| 256 | |
---|
| 257 | # Change some of the fields depending on the type of line. |
---|
| 258 | case ${v[$LINE_TYPE_Field]} in |
---|
| 259 | |
---|
| 260 | $VERSION_LINE ) |
---|
| 261 | # Increment the generation number. |
---|
| 262 | newGenNumber=${v[$SDRFS_GENNUM_Field]}+1 |
---|
| 263 | v[$SDRFS_GENNUM_Field]=$newGenNumber |
---|
| 264 | ;; |
---|
| 265 | |
---|
| 266 | $MEMBER_NODE ) |
---|
| 267 | # Add the reliable node name to nodefile. |
---|
| 268 | print -- "${v[$REL_HOSTNAME_Field]}" >> $nodefile |
---|
| 269 | checkForErrors "writing to file $nodefile" $? |
---|
| 270 | |
---|
| 271 | # If this is the line for the node that is executing |
---|
| 272 | # this command, set the preferredNode variable. |
---|
| 273 | [[ ${v[$NODE_NUMBER_Field]} = $ourNodeNumber ]] && \ |
---|
| 274 | preferredNode=${v[$REL_HOSTNAME_Field]} |
---|
| 275 | ;; |
---|
| 276 | |
---|
| 277 | $SG_HEADR ) |
---|
| 278 | # Make sure that the file system that we want to create |
---|
| 279 | # does not already exist. |
---|
| 280 | if [[ ${v[$DEV_NAME_Field]} = $deviceName ]] |
---|
| 281 | then |
---|
| 282 | printErrorMsg 107 $mmcmd $device |
---|
| 283 | cleanupAndExit |
---|
| 284 | fi |
---|
| 285 | |
---|
| 286 | # Make a list of the used minor numbers in the nodeset. |
---|
| 287 | existingMinorNumbers="$existingMinorNumbers ${v[$DEV_MINOR_Field]}" |
---|
| 288 | ;; |
---|
| 289 | |
---|
| 290 | $SG_ETCFS ) |
---|
| 291 | # Make sure that the new mount point is not already used |
---|
| 292 | # by some other file system in the nodeset. |
---|
| 293 | if [[ ${v[$LINE_NUMBER_Field]} = $MOUNT_POINT_Line && |
---|
| 294 | ${v[$ETCFS_TEXT_Field]} = $mountPoint ]] |
---|
| 295 | then |
---|
| 296 | printErrorMsg 107 $mmcmd $mountPoint |
---|
| 297 | cleanupAndExit |
---|
| 298 | fi |
---|
| 299 | |
---|
| 300 | # See if any of the existing file systems requires |
---|
| 301 | # the system automounter. |
---|
| 302 | if [[ ${v[$LINE_NUMBER_Field]} = $MOUNT_Line && |
---|
| 303 | ${v[$ETCFS_TEXT_Field]} = *automount* ]] |
---|
| 304 | then |
---|
| 305 | automountMounts=true |
---|
| 306 | fi |
---|
| 307 | ;; |
---|
| 308 | |
---|
| 309 | $SG_DISKS ) |
---|
| 310 | # Collect the SG_DISKS lines for all free disks into a file. |
---|
| 311 | # These are the disks that are available to the new file system. |
---|
| 312 | if [[ ${v[$NODESETID_Field]} = $FREE_DISK ]] |
---|
| 313 | then |
---|
| 314 | print_newLine >> $freeDisks |
---|
| 315 | printLine=false |
---|
| 316 | fi |
---|
| 317 | ;; |
---|
| 318 | |
---|
| 319 | * ) # Pass all other lines without a change. |
---|
| 320 | ;; |
---|
| 321 | |
---|
| 322 | esac # end of Change some of the fields |
---|
| 323 | |
---|
| 324 | # Build and write the line to the new mmsdrfs file. |
---|
| 325 | if [[ $printLine = true ]] |
---|
| 326 | then |
---|
| 327 | print_newLine >> $newsdrfs |
---|
| 328 | checkForErrors "writing to file $newsdrfs" $? |
---|
| 329 | fi |
---|
| 330 | |
---|
| 331 | IFS=":" # Change the separator back to ":" for the next iteration. |
---|
| 332 | |
---|
| 333 | done # end while read -u3 mmsdrfsFile |
---|
| 334 | |
---|
| 335 | IFS="$IFS_sv" # Restore the default IFS settings. |
---|
| 336 | |
---|
| 337 | |
---|
| 338 | ############################################################# |
---|
| 339 | # If a descriptor list is specified on the command line, |
---|
| 340 | # create a file with one disk descriptor per line. |
---|
| 341 | # Note: If the input is in a file, descfile was created |
---|
| 342 | # by the checkUserFile function. |
---|
| 343 | ############################################################# |
---|
| 344 | if [[ -n $desclist ]] |
---|
| 345 | then |
---|
| 346 | # Move the descriptors into a temporary file. |
---|
| 347 | $rm -f $descfile |
---|
| 348 | IFS=";" |
---|
| 349 | for diskDesc in $desclist |
---|
| 350 | do |
---|
| 351 | [[ -z $diskDesc ]] && continue |
---|
| 352 | print -- "$diskDesc" >> $descfile |
---|
| 353 | checkForErrors "writing to file $descfile" $? |
---|
| 354 | done # end for diskDesc in $desclist |
---|
| 355 | IFS="$IFS_sv" |
---|
| 356 | fi # end of if [[ -n $desclist ]] |
---|
| 357 | |
---|
| 358 | |
---|
| 359 | ########################################################## |
---|
| 360 | # Make sure that there is at least one free disk line. |
---|
| 361 | ########################################################## |
---|
| 362 | if [[ ! -s $freeDisks ]] |
---|
| 363 | then |
---|
| 364 | printErrorMsg 470 $mmcmd $mmcmd mmcrnsd |
---|
| 365 | cleanupAndExit |
---|
| 366 | fi |
---|
| 367 | |
---|
| 368 | |
---|
| 369 | ########################################################## |
---|
| 370 | # Process the descriptors for the new disks. If a disk |
---|
| 371 | # is successfully validated, its descriptor is converted |
---|
| 372 | # into the format recognized by the tscrfs command. |
---|
| 373 | ########################################################## |
---|
| 374 | $rm -f $tsddFile |
---|
| 375 | foundErrors=false |
---|
| 376 | fsHomeCluster=$HOME_CLUSTER |
---|
| 377 | |
---|
| 378 | exec 3<&- |
---|
| 379 | exec 3< $descfile |
---|
| 380 | while read -u3 mmDiskDesc |
---|
| 381 | do |
---|
| 382 | # Skip empty and comment lines. |
---|
| 383 | [[ $mmDiskDesc = *([$BLANKchar$TABchar]) ]] && continue |
---|
| 384 | [[ $mmDiskDesc = *([$BLANKchar$TABchar])#* ]] && continue |
---|
| 385 | |
---|
| 386 | # Parse mmDiskDesc to get the name of the disk. |
---|
| 387 | IFS=':' |
---|
| 388 | set -f ; set -- $mmDiskDesc ; set +f |
---|
| 389 | diskName=$1 |
---|
| 390 | IFS="$IFS_sv" |
---|
| 391 | |
---|
| 392 | if [[ -z $diskName ]] |
---|
| 393 | then |
---|
| 394 | # The disk name must be specified in the disk descriptor. |
---|
| 395 | printErrorMsg 23 $mmcmd |
---|
| 396 | |
---|
| 397 | # Show the bad descriptor. |
---|
| 398 | printErrorMsg 386 $mmcmd "$mmDiskDesc" |
---|
| 399 | |
---|
| 400 | # The command will fail, but before giving up, we will check the |
---|
| 401 | # remainder of the descriptors to flush out as many errors as possible. |
---|
| 402 | foundErrors=true |
---|
| 403 | [[ $sdrLocked = yes ]] && \ |
---|
| 404 | freeLockOnServer $primaryServer $ourNodeNumber >/dev/null |
---|
| 405 | sdrLocked=no |
---|
| 406 | |
---|
| 407 | # Move to the next descriptor. |
---|
| 408 | continue |
---|
| 409 | fi |
---|
| 410 | |
---|
| 411 | # Locate and extract the FREE_DISK line for this disk. |
---|
| 412 | $rm -f $tmpfile |
---|
| 413 | seqNo=seqNo+1 |
---|
| 414 | freeDiskLine=$($awk -F: ' \ |
---|
| 415 | # If the line is for our disk, assign it to freeDiskLine. \ |
---|
| 416 | # Do not put the line in the temp file. \ |
---|
| 417 | $'$DISK_NAME_Field' == "'$diskName'" { \ |
---|
| 418 | { $'$LINE_NUMBER_Field' = "'$seqNo'" } \ |
---|
| 419 | { print $1":" $2":" $3":" $4":" $5":" $6":" $7":" $8":" $9":"$10":" \ |
---|
| 420 | $11":"$12":"$13":"$14":"$15":"$16":"$17":"$18":"$19":"$20":" \ |
---|
| 421 | $21":"$22":"$23":"$24":"$25":"$26":"$27":" } \ |
---|
| 422 | { next } \ |
---|
| 423 | } \ |
---|
| 424 | # If the line is for some other disk, add it to tmpfile. \ |
---|
| 425 | { print $0 >> "'$tmpfile'" } \ |
---|
| 426 | ' $freeDisks) |
---|
| 427 | checkForErrors awk $? |
---|
| 428 | |
---|
| 429 | # Prepare the freeDisks file for the next iteration. |
---|
| 430 | # It will contain all of its original lines except the line |
---|
| 431 | # that describes the disk that is currently being processed. |
---|
| 432 | $touch $tmpfile # ensure file exists even if empty |
---|
| 433 | $mv $tmpfile $freeDisks |
---|
| 434 | checkForErrors "mv $tmpfile $freeDisks" $? |
---|
| 435 | |
---|
| 436 | # If not found, issue an appropriate error message. |
---|
| 437 | if [[ -z $freeDiskLine ]] |
---|
| 438 | then |
---|
| 439 | # Check whether the disk already belongs to some file system. |
---|
| 440 | fileSystem=$(findFSforDisk "$diskName" $newsdrfs) |
---|
| 441 | if [[ $fileSystem = $deviceName ]] |
---|
| 442 | then |
---|
| 443 | # This disk was already processed; |
---|
| 444 | # this must be due to a duplicate entry in the input list since |
---|
| 445 | # the file system did not exist at the start of this command. |
---|
| 446 | printErrorMsg 88 $mmcmd $diskName |
---|
| 447 | # Show the bad descriptor. |
---|
| 448 | printErrorMsg 386 $mmcmd "$mmDiskDesc" |
---|
| 449 | elif [[ -n $fileSystem ]] |
---|
| 450 | then |
---|
| 451 | # The disk already exists in some other file system. |
---|
| 452 | printErrorMsg 265 $mmcmd $diskName $fileSystem |
---|
| 453 | # Show the bad descriptor. |
---|
| 454 | printErrorMsg 386 $mmcmd "$mmDiskDesc" |
---|
| 455 | else |
---|
| 456 | # Print error stating disk descriptor should refer to an existing NSD. |
---|
| 457 | printErrorMsg 415 $mmcmd "$mmDiskDesc" |
---|
| 458 | fi |
---|
| 459 | |
---|
| 460 | # The command will fail, but before giving up, we will check the |
---|
| 461 | # remainder of the descriptors to flush out as many errors as possible. |
---|
| 462 | foundErrors=true |
---|
| 463 | [[ $sdrLocked = yes ]] && \ |
---|
| 464 | freeLockOnServer $primaryServer $ourNodeNumber >/dev/null |
---|
| 465 | sdrLocked=no |
---|
| 466 | |
---|
| 467 | # Move to the next descriptor. |
---|
| 468 | continue |
---|
| 469 | fi # end of if [[ -z $freeDiskLine ]] |
---|
| 470 | |
---|
| 471 | # Check the correctness of the disk descriptor. If everything is OK, |
---|
| 472 | # validateAndConvertNsdDescriptor will convert the descriptor into its |
---|
| 473 | # tscrfs format and will create the SG_DISKS line for the new disk. |
---|
| 474 | validateDescriptorOutput=$(validateAndConvertNsdDescriptor \ |
---|
| 475 | "$mmDiskDesc" $freeDiskLine $deviceName $fsHomeCluster NULL) |
---|
| 476 | rc=$? |
---|
| 477 | if [[ $rc -ne 0 ]] |
---|
| 478 | then |
---|
| 479 | # If an error was found, the validate routine issued a message. |
---|
| 480 | # We will now print the entire descriptor to help the guy some more. |
---|
| 481 | printErrorMsg 386 $mmcmd "$mmDiskDesc" |
---|
| 482 | |
---|
| 483 | # The command will fail, but before giving up, we will check the remainder |
---|
| 484 | # of the descriptors to flush out as many errors as possible. |
---|
| 485 | foundErrors=true |
---|
| 486 | [[ $sdrLocked = yes ]] && \ |
---|
| 487 | freeLockOnServer $primaryServer $ourNodeNumber >/dev/null |
---|
| 488 | sdrLocked=no |
---|
| 489 | |
---|
| 490 | # Move to the next descriptor. |
---|
| 491 | continue |
---|
| 492 | fi # end of if [[ $rc -ne 0 ]] |
---|
| 493 | |
---|
| 494 | # If the descriptor seems to be OK, parse the output |
---|
| 495 | # from the validateAndConvertNsdDescriptor routine. |
---|
| 496 | set -f ; set -- $validateDescriptorOutput ; set +f |
---|
| 497 | updatedDiskLine="$1" |
---|
| 498 | tsDiskDesc="$2" |
---|
| 499 | diskUsage="$3" |
---|
| 500 | |
---|
| 501 | # Add the converted descriptor to the input for tscrfs. |
---|
| 502 | print -- "$tsDiskDesc" >> $tsddFile |
---|
| 503 | checkForErrors "writing to file $tsddFile" $? |
---|
| 504 | |
---|
| 505 | # Add the SG_DISKS line for the new disk to the mmsdrfs file. |
---|
| 506 | print -- "$updatedDiskLine" >> $newsdrfs |
---|
| 507 | checkForErrors "writing to file $newsdrfs" $? |
---|
| 508 | |
---|
| 509 | # Keep track of the overall disk usage. |
---|
| 510 | [[ $diskUsage != metadataOnly && $diskUsage != descOnly ]] && onedata=ok |
---|
| 511 | [[ $diskUsage != dataOnly && $diskUsage != descOnly ]] && onemeta=ok |
---|
| 512 | |
---|
| 513 | done # end of while read -u3 mmDiskDesc |
---|
| 514 | |
---|
| 515 | |
---|
| 516 | # Give up if there were errors with one or more of the descriptors. |
---|
| 517 | if [[ $foundErrors = true ]] |
---|
| 518 | then |
---|
| 519 | # Command failed. |
---|
| 520 | printErrorMsg 389 $mmcmd |
---|
| 521 | cleanupAndExit |
---|
| 522 | fi |
---|
| 523 | |
---|
| 524 | # Were there disks to begin with? |
---|
| 525 | if [[ -z $onemeta && -z $onedata ]] |
---|
| 526 | then |
---|
| 527 | # No disks were specified. |
---|
| 528 | printErrorMsg 264 $mmcmd |
---|
| 529 | cleanupAndExit |
---|
| 530 | fi |
---|
| 531 | |
---|
| 532 | # Make sure that not all of the disks are dataOnly or metadataOnly. |
---|
| 533 | if [[ -z $onemeta ]] |
---|
| 534 | then |
---|
| 535 | # All disks are dataOnly. |
---|
| 536 | printErrorMsg 198 $mmcmd |
---|
| 537 | cleanupAndExit |
---|
| 538 | fi |
---|
| 539 | |
---|
| 540 | if [[ -z $onedata ]] |
---|
| 541 | then |
---|
| 542 | # All disks are metadataOnly. |
---|
| 543 | printErrorMsg 197 $mmcmd |
---|
| 544 | cleanupAndExit |
---|
| 545 | fi |
---|
| 546 | |
---|
| 547 | # If there are any SG_DISKS lines for remaining free disks, |
---|
| 548 | # put them back in the mmsdrfs file. |
---|
| 549 | if [[ -s $freeDisks ]] |
---|
| 550 | then |
---|
| 551 | $cat $freeDisks >> $newsdrfs |
---|
| 552 | checkForErrors "cat $freeDisks >> $newsdrfs" $? |
---|
| 553 | fi |
---|
| 554 | |
---|
| 555 | |
---|
| 556 | # Before checking the rest of the parameters, |
---|
| 557 | # we need to determine the current maxblocksize in effect. |
---|
| 558 | maxblocksize=$($mmcommon onactive $preferredNode $nodefile \ |
---|
| 559 | $NO_FILE_COPY $NO_MOUNT_CHECK NULL $NO_LINK tsctl showCfgValue maxblocksize) |
---|
| 560 | rc=$? |
---|
| 561 | if [[ -z $maxblocksize || $rc -ne 0 ]] |
---|
| 562 | then |
---|
| 563 | [[ $rc -eq 0 ]] && rc=1 |
---|
| 564 | if [[ $rc -eq $MM_DaemonDown || $rc -eq $MM_QuorumWait ]] |
---|
| 565 | then |
---|
| 566 | : # Do nothing; a message was already issued. |
---|
| 567 | elif [[ $rc -eq $MM_ConnectionReset ]] |
---|
| 568 | then |
---|
| 569 | # An internode connection was reset. |
---|
| 570 | printErrorMsg 257 $mmcmd |
---|
| 571 | elif [[ -n $maxblocksize ]] |
---|
| 572 | then |
---|
| 573 | # If there was some output, assume it is an error message. |
---|
| 574 | print -u2 $maxblocksize |
---|
| 575 | else |
---|
| 576 | # An unexpected error occurred during the tsctl operation. |
---|
| 577 | printErrorMsg 171 $mmcmd "mmcommon onactive tsctl showCfgValue maxblocksize" $rc |
---|
| 578 | fi |
---|
| 579 | # The command failed. |
---|
| 580 | printErrorMsg 389 $mmcmd |
---|
| 581 | cleanupAndExit $rc |
---|
| 582 | fi |
---|
| 583 | |
---|
| 584 | # Use mmcrfsc to check the rest of the arguments. |
---|
| 585 | # Error messages will be issued by mmcrfsc. |
---|
| 586 | mmcrfscOutput=$($mmcrfsc M $maxblocksize $argList) |
---|
| 587 | rc=$? |
---|
| 588 | [[ $rc -eq 123 ]] && printErrorMsg $usageMsg $mmcmd |
---|
| 589 | [[ $rc -ne 0 ]] && cleanupAndExit |
---|
| 590 | |
---|
| 591 | # Parse the mmcrfsc output. |
---|
| 592 | set -f ; set -- $mmcrfscOutput ; set +f |
---|
| 593 | sgMOUNT_Line_Value=$1 |
---|
| 594 | sgMTIME_OPT_Value=$2 |
---|
| 595 | quotaOption=$3 |
---|
| 596 | sgATIME_OPT_Value=$4 |
---|
| 597 | shift 4 |
---|
| 598 | tsArguments="$*" |
---|
| 599 | |
---|
| 600 | # If something is wrong, get out. |
---|
| 601 | [[ -z $tsArguments ]] && cleanupAndExit |
---|
| 602 | |
---|
| 603 | # Append the value of the -N NumInodes[:NumInodesToPreallocate] parameter. |
---|
| 604 | [[ -n $Narg ]] && tsArguments="$tsArguments $Nflag $Narg" |
---|
| 605 | |
---|
| 606 | # Translate the quota option into its /etc/filesystems format. |
---|
| 607 | # The other mount options, mtime and atime, are set by mmcrfsc. |
---|
| 608 | if [[ $quotaOption = enableQuota ]] |
---|
| 609 | then |
---|
| 610 | sgQUOTA_OPT_Value=$QUOTA_ACTIVATED |
---|
| 611 | else |
---|
| 612 | sgQUOTA_OPT_Value=$QUOTA_DISACTIVATED |
---|
| 613 | fi |
---|
| 614 | |
---|
| 615 | # Figure out what should the major number be. |
---|
| 616 | if [[ $osName = Linux ]] |
---|
| 617 | then |
---|
| 618 | checkVfsNumber |
---|
| 619 | devMajor=$currentMajorNumber |
---|
| 620 | fi |
---|
| 621 | [[ -z $devMajor ]] && devMajor=$defaultMajorNumber |
---|
| 622 | |
---|
| 623 | # Assign a minor number to the file system. |
---|
| 624 | # Keep trying until we get a minor number that is not used by anybody. |
---|
| 625 | rc=0 |
---|
| 626 | minor="" |
---|
| 627 | while [[ -z $minor && $rc -eq 0 ]] |
---|
| 628 | do |
---|
| 629 | # Assign a minor number to the file system. |
---|
| 630 | devMinor=$(assignDevMinor "$existingMinorNumbers") |
---|
| 631 | rc=$? |
---|
| 632 | if [[ $rc -eq 0 ]] |
---|
| 633 | then |
---|
| 634 | # Check whether the new device number is being used by somebody. |
---|
| 635 | inuse=$($ls -lL /dev 2>/dev/null | $grep "^${fsDeviceType}.* $devMajor, *$devMinor ") |
---|
| 636 | if [[ -z $inuse ]] |
---|
| 637 | then |
---|
| 638 | # The number seems to be free. |
---|
| 639 | minor=$devMinor |
---|
| 640 | fi |
---|
| 641 | |
---|
| 642 | # Add the number to the list of existing minor numbers. |
---|
| 643 | existingMinorNumbers="$existingMinorNumbers $devMinor" |
---|
| 644 | |
---|
| 645 | fi # end of if [[ $rc -eq 0 ]] |
---|
| 646 | done # end of while [[ -z $minor && $rc -eq 0 ]] |
---|
| 647 | |
---|
| 648 | if [[ -z $minor ]] |
---|
| 649 | then |
---|
| 650 | print -u2 "$mmcmd: Cannot assign a minor number for the file system." |
---|
| 651 | cleanupAndExit |
---|
| 652 | fi |
---|
| 653 | |
---|
| 654 | |
---|
| 655 | # If this is the first automountable GPFS file system, |
---|
| 656 | # run the automount command on the nodes in the cluster. |
---|
| 657 | if [[ $sgMOUNT_Line_Value = automount && -z $automountMounts ]] |
---|
| 658 | then |
---|
| 659 | # Determine the value of the automountDir parameter. |
---|
| 660 | automountDir=$(showCfgValue automountDir) |
---|
| 661 | [[ -z $automountDir ]] && automountDir=$defaultAutomountDir |
---|
| 662 | |
---|
| 663 | # Run the automount command on the nodes on which GPFS is active. |
---|
| 664 | # On nodes that do not have GPFS running right now, this will be |
---|
| 665 | # done by the mmchecksubsys processing when the daemon is started. |
---|
| 666 | $mmcommon onactive $preferredNode $nodefile \ |
---|
| 667 | $NO_FILE_COPY $NO_MOUNT_CHECK NULL $NO_LINK \ |
---|
| 668 | tsdsh $mmremote startAutomounter $automountDir >$tmpfile 2>&1 |
---|
| 669 | rc=$? |
---|
| 670 | |
---|
| 671 | # Ignore errors but show messages from the nodes, if any. |
---|
| 672 | if [[ $rc -ne 0 && $rc -ne $MM_DaemonDown && -s $tmpfile ]] |
---|
| 673 | then |
---|
| 674 | $awk ' \ |
---|
| 675 | # Skip the lines with rc values. \ |
---|
| 676 | $2 == "rc" { next } \ |
---|
| 677 | # Print everything else. \ |
---|
| 678 | { print $0 } \ |
---|
| 679 | ' $tmpfile |
---|
| 680 | fi # end of if [[ -s $tmpfile ]] |
---|
| 681 | fi # end of if [[ $sgMOUNT_Line_Value = automount && -z $automountMounts ]] |
---|
| 682 | |
---|
| 683 | |
---|
| 684 | # Build the rest of the SG-related lines for the new file system. |
---|
| 685 | # Note: In order to preserve the tab characters in the /etc/filesystems lines, |
---|
| 686 | # we temporarily reset the value of the IFS variable to exclude the tab. |
---|
| 687 | IFS=' ' |
---|
| 688 | |
---|
| 689 | newLine="$fsHomeCluster:$SG_HEADR:$deviceName::$minor::::" |
---|
| 690 | print "$newLine" >> $newsdrfs |
---|
| 691 | |
---|
| 692 | newLine="$fsHomeCluster:$SG_ETCFS:$deviceName:$MOUNT_POINT_Line:$mountPoint:" |
---|
| 693 | print "$newLine" >> $newsdrfs |
---|
| 694 | |
---|
| 695 | newLine="$fsHomeCluster:$SG_ETCFS:$deviceName:$DEV_Line" |
---|
| 696 | newLine="$newLine:$DEV_Line_Prefix$fqDeviceName" |
---|
| 697 | print "$newLine" >> $newsdrfs |
---|
| 698 | |
---|
| 699 | newLine="$fsHomeCluster:$SG_ETCFS:$deviceName:$VFS_Line" |
---|
| 700 | newLine="$newLine:$VFS_Line_Prefix$sgVFS_Line_Value" |
---|
| 701 | print "$newLine" >> $newsdrfs |
---|
| 702 | |
---|
| 703 | newLine="$fsHomeCluster:$SG_ETCFS:$deviceName:$NODENAME_Line" |
---|
| 704 | newLine="$newLine:$NODENAME_Line_Prefix$sgNODENAME_Line_Value" |
---|
| 705 | print "$newLine" >> $newsdrfs |
---|
| 706 | |
---|
| 707 | newLine="$fsHomeCluster:$SG_ETCFS:$deviceName:$MOUNT_Line" |
---|
| 708 | newLine="$newLine:$MOUNT_Line_Prefix$sgMOUNT_Line_Value" |
---|
| 709 | print "$newLine" >> $newsdrfs |
---|
| 710 | |
---|
| 711 | newLine="$fsHomeCluster:$SG_ETCFS:$deviceName:$TYPE_Line" |
---|
| 712 | newLine="$newLine:$TYPE_Line_Prefix$sgTYPE_Line_Value" |
---|
| 713 | print "$newLine" >> $newsdrfs |
---|
| 714 | |
---|
| 715 | newLine="$fsHomeCluster:$SG_ETCFS:$deviceName:$ACCOUNT_Line" |
---|
| 716 | newLine="$newLine:$ACCOUNT_Line_Prefix$sgACCOUNT_Line_Value" |
---|
| 717 | print "$newLine" >> $newsdrfs |
---|
| 718 | |
---|
| 719 | newLine="$fsHomeCluster:$SG_MOUNT:$deviceName::$sgRW_OPT_Value" |
---|
| 720 | newLine="$newLine:$sgMTIME_OPT_Value:$sgATIME_OPT_Value" |
---|
| 721 | newLine="$newLine:$sgQUOTA_OPT_Value:$sgOTHER_OPT_Value:::::::::::::" |
---|
| 722 | print "$newLine" >> $newsdrfs |
---|
| 723 | checkForErrors "writing to file $newsdrfs" $? |
---|
| 724 | |
---|
| 725 | IFS="$IFS_sv" |
---|
| 726 | |
---|
| 727 | |
---|
| 728 | # The last step in creating the new mmsdrfs file is sorting it. |
---|
| 729 | LC_ALL=C $SORT_MMSDRFS $newsdrfs -o $newsdrfs |
---|
| 730 | checkForErrors "sorting $newsdrfs" $? |
---|
| 731 | |
---|
| 732 | |
---|
| 733 | ############################# |
---|
| 734 | # Invoke the tscrfs command. |
---|
| 735 | ############################# |
---|
| 736 | $mmcommon onactive $preferredNode $nodefile \ |
---|
| 737 | $tsddFile $NO_MOUNT_CHECK NULL $NO_LINK \ |
---|
| 738 | tscrfs "$fqDeviceName -F $tsddFile $tsArguments" |
---|
| 739 | rc=$? |
---|
| 740 | if [[ $rc -ne 0 ]] |
---|
| 741 | then |
---|
| 742 | # tscrfs failed. |
---|
| 743 | printErrorMsg 100 $mmcmd $device |
---|
| 744 | cleanupAndExit $rc |
---|
| 745 | fi |
---|
| 746 | |
---|
| 747 | |
---|
| 748 | ############################################################# |
---|
| 749 | # Put the mmsdrfs file into the sdr. This will make the new |
---|
| 750 | # file system visible to nodes that have not come up yet. |
---|
| 751 | # Nodes that are currently active are handled below. |
---|
| 752 | ############################################################# |
---|
| 753 | trap "" HUP INT QUIT KILL |
---|
| 754 | gpfsObjectInfo=$(commitChanges \ |
---|
| 755 | $fsHomeCluster $nsId $gpfsObjectInfo $newGenNumber $newsdrfs $primaryServer) |
---|
| 756 | rc=$? |
---|
| 757 | if [[ $rc -ne 0 ]] |
---|
| 758 | then |
---|
| 759 | # The commit step failed; we cannot replace the file in the sdr. |
---|
| 760 | printErrorMsg 381 $mmcmd |
---|
| 761 | cleanupAndExit |
---|
| 762 | fi |
---|
| 763 | |
---|
| 764 | |
---|
| 765 | ############################################################# |
---|
| 766 | # Unlock the sdr. |
---|
| 767 | ############################################################# |
---|
| 768 | freeLockOnServer $primaryServer $ourNodeNumber >/dev/null |
---|
| 769 | sdrLocked=no |
---|
| 770 | trap posttrap HUP INT QUIT KILL |
---|
| 771 | |
---|
| 772 | |
---|
| 773 | ######################################################################### |
---|
| 774 | # Make the new file system visible to the nodes. This includes adding |
---|
| 775 | # a stanza to /etc/filesystems, creating the character mode device, |
---|
| 776 | # and creating the mount point directory. This process is asynchronous. |
---|
| 777 | ######################################################################### |
---|
| 778 | propagateSdrfsFile async $nodefile $newsdrfs $newGenNumber |
---|
| 779 | |
---|
| 780 | |
---|
| 781 | ################################################### |
---|
| 782 | # If installed, invoke the syncfsconfig user exit. |
---|
| 783 | ################################################### |
---|
| 784 | if [[ -x $syncfsconfig ]] |
---|
| 785 | then |
---|
| 786 | print -- "$mmcmd: Starting $syncfsconfig ..." |
---|
| 787 | $syncfsconfig |
---|
| 788 | print -- "$mmcmd: $syncfsconfig finished." |
---|
| 789 | fi |
---|
| 790 | |
---|
| 791 | cleanupAndExit 0 |
---|
| 792 | |
---|