source: gpfs_3.1_ker2.6.20/lpp/mmfs/bin/mmcrnsd @ 16

Last change on this file since 16 was 16, checked in by rock, 16 years ago
  • Property svn:executable set to *
File size: 23.2 KB
Line 
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,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# @(#)08 1.67.1.2 src/avs/fs/mmfs/ts/admin/mmcrnsd.sh, mmfs, avs_rgpfs24, rgpfs24s005a 6/14/06 14:40:06
17###############################################################################
18#
19#  Usage:
20#    mmcrnsd -F DescFile [-v {yes | no}]
21#
22#  where
23#    -F DescFile    specifies a file containing the disk descriptors for
24#                     the network shared disks to be created
25#    -v {yes | no}  verification flag; a value of "yes" specifies that the
26#                     disks in DescFile should only be created if they have
27#                     not been previously formatted as an NSD, while a value
28#                     of "no" specifies the disks should be created regardless
29#                     of whether they have been previously formatted or not.
30#                     The default value is "yes".
31#
32###############################################################################
33
34# Include global declarations and service routines.
35. /usr/lpp/mmfs/bin/mmglobfuncs
36. /usr/lpp/mmfs/bin/mmsdrfsdef
37. /usr/lpp/mmfs/bin/mmfsfuncs
38
39sourceFile="mmcrnsd.sh"
40[[ -n $DEBUG || -n $DEBUGmmcrnsd ]] && set -x
41$mmTRACE_ENTER "$*"
42
43# Local work files.  Names should be of the form:
44#   fn=${tmpDir}fn.${mmcmd}.$$
45
46tdescfile=${tmpDir}tdescfile.${mmcmd}.$$    # temp file for descriptors
47
48LOCAL_FILES=" $tdescfile "
49
50
51# Local variables
52integer highestGpfsDiskNbr
53integer seqNo=0
54usageMsg=410
55noUsageMsg=0
56hadSuccess=false
57
58
59# Local functions
60
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 1  ]] &&  \
75  syntaxError "missingArgs" $usageMsg
76
77while getopts :F:v: OPT
78do
79  case $OPT in
80
81    F) # node names file
82       [[ -n $Farg ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
83       Farg=$OPTARG
84       if [[ ! -r $Farg ]]
85       then
86         # Cannot open the file
87         printErrorMsg 43 $mmcmd $Farg
88         cleanupAndExit
89       fi
90       ;;
91
92    v) [[ -n $vflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
93       if [[ $OPTARG = yes || $OPTARG = no ]]
94       then
95         vflag="$OPTARG"
96       else
97         syntaxError "YesNoValue" $noUsageMsg "-$OPT"
98       fi
99       ;;
100
101    +[Fv]) # Invalid option
102       syntaxError "invalidOption" $usageMsg $OPT
103       ;;
104
105    :) # Missing argument
106       syntaxError "missingValue" $usageMsg $OPTARG
107       ;;
108
109    *) # Invalid option
110       syntaxError "invalidOption" $usageMsg $OPTARG
111       ;;
112  esac
113
114done  # end while getopts :F:v: OPT
115
116shift OPTIND-1
117[[ $# != 0 ]] && syntaxError "extraArg" $usageMsg $1
118
119[[ -z $vflag ]] && vflag=yes
120
121# Verify the mandatory -F parameter.
122[[ -z $Farg ]] && syntaxError "missingArgs" $usageMsg
123descfile=$Farg
124checkUserFile $descfile $descfile
125[[ $? -ne 0 ]] && cleanupAndExit
126
127
128#####################################################################
129# Set up trap exception handling and call the gpfsInit function.
130# It will ensure that the local copy of the mmsdrfs and the rest of
131# the GPFS system files are up-to-date and will obtain the sdr lock.
132#####################################################################
133trap pretrap HUP INT QUIT KILL
134gpfsInitOutput=$(gpfsInit $lockId)
135setGlobalVar $? $gpfsInitOutput
136
137
138#########################################################################
139# Create a new version of the mmsdrfs file with a new generation number.
140# Generate a file containing the names of the nodes in the cluster.
141#########################################################################
142$rm -f $nodefile $newsdrfs
143IFS=":"         # Change the field separator to ':'.
144exec 3<&-
145exec 3< $mmsdrfsFile
146while read -u3 sdrfsLine
147do
148  # Parse the line.
149  set -f ; set -A v -- - $sdrfsLine ; set +f
150
151  IFS="$IFS_sv"    # Restore the default IFS settings.
152  printLine=true   # Assume the line will be printed.
153
154  # Change some of the fields depending on the type of line.
155  case ${v[$LINE_TYPE_Field]} in
156
157    $VERSION_LINE )  # this is the global header line
158      # Increment the generation number and save the line for later output.
159      newGenNumber=${v[$SDRFS_GENNUM_Field]}+1
160      v[$SDRFS_GENNUM_Field]=$newGenNumber
161      versionLine_A="${v[1]}:${v[2]}:${v[3]}:${v[4]}:${v[5]}:${v[6]}"
162      versionLine_A="$versionLine_A:${v[7]}:${v[8]}:${v[9]}:${v[10]}"
163      highestGpfsDiskNbr=${v[$HIGHEST_GPFS_DISK_NBR_Field]}
164      versionLine_B="${v[12]}:${v[13]}:${v[14]}:${v[15]}:${v[16]}"
165      versionLine_B="$versionLine_B:${v[17]}:${v[18]}:${v[19]}:${v[20]}"
166      versionLine_B="$versionLine_B:${v[21]}:${v[22]}:${v[23]}:${v[24]}"
167      printLine=false
168      ;;
169
170    $MEMBER_NODE )  # this line describes a node
171       # Add the reliable node name to nodefile.
172       print -- ${v[$REL_HOSTNAME_Field]} >> $nodefile
173       checkForErrors "writing to file $nodefile" $?
174
175       [[ ${v[$NODE_NUMBER_Field]} = $ourNodeNumber ]] &&  \
176         preferredNode=${v[$REL_HOSTNAME_Field]}
177       ;;
178
179    * )  # Pass all other lines without a change.
180      ;;
181
182  esac  # end Change some of the fields
183
184  # Build and write the line to the new mmsdrfs file.
185  if [[ $printLine = true ]]
186  then
187    print_newLine >> $newsdrfs
188    checkForErrors "writing to file $newsdrfs" $?
189  fi
190
191  IFS=":"  # Change the separator back to ":" for the next iteration.
192
193done  # end while read -u3 sdrfsLine
194
195IFS="$IFS_sv"  # Restore the default IFS settings.
196
197
198############################################################################
199# Process the descriptors for the new disks.  Each descriptor is validated.
200# If the descriptor appears to be ok, tspreparedisk is invoked to generate
201# a unique physical id on the disk.  For each disk that is successfully
202# processed by tspreparedisk, an SG_DISKS line is added to the sdrfs file.
203############################################################################
204exec 3<&-
205exec 3< $descfile
206$rm -f $tdescfile
207while read -u3 mmDiskDesc
208do
209  # Skip empty lines and comment lines ('#' is the first non-white char).
210  if [[ $mmDiskDesc = *([$BLANKchar$TABchar])#* ||
211        $mmDiskDesc = *([$BLANKchar$TABchar])   ]]
212  then
213    # Preserve the line "as is" in the user's input file.
214    print -- "$mmDiskDesc" >> $tdescfile
215    continue
216  fi
217
218  # Append the commented-out descriptor to the temporary descriptor file.
219  # If the descriptor passes all error checking, this line will be followed
220  # by the converted descriptor with the assigned global name.
221  print -- "# $mmDiskDesc" >> $tdescfile
222  checkForErrors "writing to file $tdescfile" $?
223
224  # Parse the disk descriptor.
225  IFS=':'
226  set -f ; set -- $mmDiskDesc ; set +f
227  device=$1
228  diskName=${device##+(/)dev+(/)}    # name stripped of /dev/ prefix
229  server=$2
230  backup=$3
231  diskUsage=$4
232  failureGroup=$5
233  desiredName=$6
234  storagePool=$7
235  IFS="$IFS_sv"
236
237  # Issue an informational progress message (processing disk xyz ...).
238  printInfoMsg 251 $mmcmd $diskName
239
240  # If a server node was specified, check that it is valid
241  # and convert it if necessary to an admin adapter name.
242  if [[ -n $server ]]
243  then
244    server=$(checkAndConvertNodeValue $server $REL_HOSTNAME_Field)
245    [[ $? -ne 0 ]] && cleanupAndExit
246  fi
247  if [[ -n $backup ]]
248  then
249    backup=$(checkAndConvertNodeValue $backup $REL_HOSTNAME_Field)
250    [[ $? -ne 0 ]] && cleanupAndExit
251  fi
252
253  # Generate a template SG_DISK line for the new disk.
254  # For now, we assume that everything will check out.
255  diskSize=0
256  [[ -z $failureGroup ]] && failureGroup=-1
257  [[ -z $diskUsage ]] && diskUsage=dataAndMetadata
258  pvid=""
259  primaryNsdNode=""
260  backupNsdNode=""
261  diskType="nsd"
262
263  # Determine the name the nsd will be called.
264  if [[ -z $desiredName ]]
265  then
266    highestGpfsDiskNbr=highestGpfsDiskNbr+1
267    nsdName="gpfs${highestGpfsDiskNbr}nsd"
268    nameSource="$cmdGenerated"
269  else
270    # Check whether the desired disk name conforms to naming rules.
271    # If it does not, skip to the next disk descriptor.
272    checkName diskName 255 "$desiredName"
273    [[ $? -ne 0 ]] && continue
274
275    # Issue an error and skip to the next descriptor
276    # if the desired name begins with "gpfs".
277    if [[ $desiredName = gpfs* ]]
278    then
279      # The desired disk name begins with "gpfs".
280      printErrorMsg 505 $mmcmd $desiredName
281      continue                      # Skip to the next disk descriptor.
282    fi
283
284    # Issue an error and skip to the next descriptor
285    # if the desired name is already in use.
286    dn=$(getDiskInfo $DISK_NAME_Field $desiredName $newsdrfs)
287    rc=$?
288    if [[ $rc -ne 0 && -z $dn ]]
289    then
290      nsdName="$desiredName"
291    else
292      # The desired disk name is already in use by GPFS.
293      printErrorMsg 432 $mmcmd $desiredName
294      continue                      # Skip to the next disk descriptor.
295    fi
296    nameSource="$userSpecified"
297  fi
298
299  # Create a free disk line as a starting point for the validate routine.
300  freeDiskLine="$FREE_DISK:$SG_DISKS:$NO_DEVICE:$seqNo:$nsdName:$diskSize"
301  freeDiskLine="${freeDiskLine}:$failureGroup:$diskUsage:$pvid:$diskType"
302  freeDiskLine="${freeDiskLine}:$primaryNsdNode:$backupNsdNode::::$nameSource"
303  freeDiskLine="${freeDiskLine}::$includedDisk:"
304
305  # Check the correctness of the disk descriptor.  If everything is OK,
306  # validateAndConvertNsdDescriptor will return an updated SG_DISKS line.
307  validateDescriptorOutput=$(validateAndConvertNsdDescriptor "$mmDiskDesc"  \
308                               $freeDiskLine $NO_DEVICE $FREE_DISK NULL)
309  rc=$?
310  if [[ $rc -ne 0 ]]
311  then
312    # If an error was found, the validate routine issued a message.
313    # We will now print the entire descriptor to help the guy some more.
314    printErrorMsg 386 $mmcmd "$mmDiskDesc"
315    [[ -z $desiredName ]] && highestGpfsDiskNbr=highestGpfsDiskNbr-1
316    continue                        # Skip to the next disk descriptor.
317  fi
318
319  # If the descriptor seems to be OK, parse the output
320  # from the validateAndConvertNsdDescriptor routine.
321  set -f ; set -- $validateDescriptorOutput ; set +f
322  updatedDiskLine="$1"
323
324  # Generate and write a unique pvid on sector 2 of the disk.
325  # If an NSD server is specified, invoke the function on that node.
326  # This call will also return the type of the underlying disk.
327  if [[ -z $server || $server = $ourNodeName ]]
328  then
329    invokedNode=$ourNodeName
330    createNsdOutput=$(createNsd $diskName $vflag mmcrnsd NULL)
331    rc=$?
332  else
333    invokedNode=$server
334    createNsdOutput=$(run on1 $server  \
335                      createNsd $diskName $vflag mmcrnsd NULL)
336    rc=$?
337  fi
338
339  # The output of createNsd consists of a one-word NSD subtype value,
340  # followed by the output from tspreparedisk.  Separate the two parts.
341  nsdSubtype=${createNsdOutput%% *}
342  tspreparediskOutput=${createNsdOutput#* }
343
344  # Set the value for the nsd subtype diskname if the nsd subtype
345  # is lv, vsd or file; this name is persistent across the nodes.
346  nsdSubtypeDiskname=""
347  [[ $nsdSubtype = lv || $nsdSubtype = vsd || $nsdSubtype = file ]] &&  \
348    nsdSubtypeDiskname=$diskName
349
350  # Parse the output from the tspreparedisk command.
351  IFS=":"
352  set -f ; set -- $tspreparediskOutput ; set +f
353  magicWord=$1
354  rc2=$2
355  pvid=$3
356  primaryLocalName=$4
357  status=$5
358  diskSize=$6
359  oldPvid=$8
360  IFS="$IFS_sv"
361
362  if [[ $rc  -ne 0 || $nsdSubtype = error ||
363        $rc2 -ne 0 || $magicWord != tspreparedisk ]]
364  then
365    # Try to make sense of the error.
366    if [[ $nsdSubtype = error ]]
367    then
368      : # determineNsdSubtype failed.  Messages were already issued.
369
370    elif [[ $magicWord = tspreparedisk ]]
371    then
372      # tspreparedisk was executed but was not happy about something.
373      if [[ $rc2 = 1 ]]
374      then
375        # Permission was denied for disk.
376        printErrorMsg 523 $mmcmd $device
377      elif [[ $rc2 = 2 ]]
378      then
379        # The disk was not found.
380        printErrorMsg 524 $mmcmd $device
381      elif [[ $rc2 = 5 ]]
382      then
383        # I/O error
384        printErrorMsg 525 $mmcmd $device
385      elif [[ $rc2 = $MM_DeviceNotFound ]]
386      then
387        # A return code of ENODEV was returned for the disk.
388        printErrorMsg 187 $mmcmd $invokedNode $device
389      elif [[ $rc2 = 27 ]]
390      then
391        # The disk is too large.
392        printErrorMsg 508 $mmcmd $device
393      elif [[ $rc2 = 50 ]]
394      then
395        # The disk is fenced out.
396        printErrorMsg 395 $mmcmd $invokedNode $device
397      else
398        # Show the result from tspreparedisk.
399        print -u2 "$tspreparediskOutput"
400        # Unexpected error from tspreparedisk
401        printErrorMsg 171 "$mmcmd" "tspreparedisk $diskName" $rc2
402      fi  # end if [[ $rc2 = 1 ]]
403    else
404      # Something is really wrong.  Output error information if any.
405      [[ -n $createNsdOutput ]] && print -u2 "$createNsdOutput"
406    fi  # end if [[ $nsdSubtype = error ]]
407
408    # Issue "failed while processing disk descriptor xyz" message.
409    [[ -z $server ]] && server=$ourNodeName
410    printErrorMsg 411 $mmcmd "$mmDiskDesc" $server
411
412    # We will process the rest of the descriptors to create
413    # NSDs for those that are good and to flush out as many
414    # errors with the descriptors as possible.
415    [[ -z $desiredName ]] && highestGpfsDiskNbr=highestGpfsDiskNbr-1
416    continue                        # Skip to the next disk descriptor.
417  fi  # end if [[ $rc  -ne 0 || $nsdSubtype = error ||  ...
418
419  if [[ $status = old ]]
420  then
421    # The tspreparedisk command discovered that this is an already-defined NSD.
422
423    # Find the SG_DISKS line for the disk and remove it from the mmsdrfs file.
424    # Note that it is possible that there is no SG_DISKS line for this disk.
425    # This can happen if a disk is forcefully deleted (mmdelnsd -p) from the
426    # mmsdrfs file but the pvid was not destroyed because the disk was not
427    # available, or a previous mmcrnsd could have failed after tspreparedisk
428    # successfully completed but before the information could be committed.
429    $rm -f $tmpfile
430    existingDiskLine=$($awk -F: '                                    \
431      # If the line is for our disk, assign it to existingDiskLine.  \
432      # Do not put the line in the temp file.                        \
433      /':$SG_DISKS:'/ {                                              \
434        if ($'$PVID_Field' == "'$oldPvid'") {                        \
435          { print $0 }                                               \
436          { next }                                                   \
437        }                                                            \
438      }                                                              \
439      # Write all other lines to tmpfile.                            \
440      { print $0 >> "'$tmpfile'" }                                   \
441    ' $newsdrfs)
442
443    # Prepare the newsdrfs file for the next iteration.
444    # It will contain all of its original lines except the line
445    # that describes the disk that is currently being processed.
446    $mv $tmpfile $newsdrfs
447    checkForErrors "mv $tmpfile $newsdrfs" $?
448
449    # Find the global name of the disk.
450    IFS=":"
451    set -f ; set -- $existingDiskLine ; set +f
452    IFS="$IFS_sv"
453    existingGlobalName=$5
454
455    if [[ $vflag = yes ]]
456    then
457      # The user requested existing disks to be flagged as an error.
458      printErrorMsg 412 $mmcmd "$mmDiskDesc" $existingGlobalName
459      [[ -z $desiredName ]] && highestGpfsDiskNbr=highestGpfsDiskNbr-1
460
461      # Put the old line back in the file and go to the next descriptor.
462      if [[ -n $existingDiskLine ]]
463      then
464        print -- $existingDiskLine >> $newsdrfs
465        checkForErrors "writing to file $newsdrfs" $?
466      fi
467      continue
468    fi
469
470    # The user specified that existing disks are acceptable (-v no).
471    # Was a line for the disk found in the mmsdrfs file?
472    if [[ -n $existingDiskLine ]]
473    then
474      # An SG_DISKS line for the disk was found.
475      # Did the user specify a name for the nsd?
476      if [[ -n $desiredName ]]
477      then
478        # Use the new nsd name specified by the user.
479        nsdName=$desiredName
480      else
481        # Reuse the old nsd name and un-increment the highest disk number.
482        nsdName=$existingGlobalName
483        highestGpfsDiskNbr=highestGpfsDiskNbr-1
484      fi
485    else
486      # No SG_DISKS line was found for this disk; treat the disk as new.
487      status=new
488    fi  # end of if [[ -n $existingDiskLine ]]
489
490  fi  # end of if [[ $status = old ]]
491
492  # At this point updatedDiskLine contains the SG_DISKS information
493  # for a disk which is successfully defined as an NSD by tspreparedisk.
494  IFS=":"
495  set -f ; set -A v -- - $updatedDiskLine ; set +f
496  IFS="$IFS_sv"
497
498  # Update descriptor values that might have been set by the validate function.
499  failureGroup=${v[$FAILURE_GROUP_Field]}
500  diskUsage=${v[$DISK_USAGE_Field]}
501
502  # Add the missing or updated information.
503  v[$DISK_NAME_Field]=$nsdName
504  v[$DISK_SIZE_Field]=$diskSize
505  v[$PVID_Field]=$pvid
506  v[$NSD_SUBTYPE_Field]=$nsdSubtype
507  v[$NSD_SUBTYPE_DISKNAME_Field]=$nsdSubtypeDiskname
508  updatedDiskLine=$(print_newLine)
509
510  # If a backup NSD node is specified, run the tspreparedisk command
511  # on that node to verify that the disk is properly connected.
512  if [[ -n $backup ]]
513  then
514    if [[ $nsdSubtype = vsd ]]
515    then
516      # Attempt to write to sector 2 of the disk from the backup
517      # server in order to determine whether the disk is accessible.
518      # (This will cause the backup server to be unfenced from the
519      # vsd if necessary.)
520      if [[ $backup = $ourNodeName ]]
521      then
522        invokedNode=$ourNodeName
523        createNsdOutput=$(createNsd $diskName yes mmcrnsd vsd)
524        rc=$?
525      else
526        invokedNode=$backup
527        createNsdOutput=$(run on1 $backup  \
528                          createNsd $diskName yes mmcrnsd vsd)
529        rc=$?
530      fi
531
532      # The output of createNsd consists of a one-word NSD subtype value
533      # followed by the tspreparedisk output.  Extract the tspreparedisk output.
534      tspreparediskOutput=${createNsdOutput#* }
535    else
536      if [[ $backup = $ourNodeName ]]
537      then
538        invokedNode=$ourNodeName
539        tspreparediskOutput=$($tspreparedisk -p $pvid -t $nsdSubtype)
540        rc=$?
541      else
542        invokedNode=$backup
543        tspreparediskOutput=$(run on1 $backup adminCmd  \
544                               tspreparedisk -p $pvid -t $nsdSubtype)
545        rc=$?
546      fi
547    fi
548
549    # Parse the output from the tspreparedisk command.
550    IFS=":"
551    set -f ; set -- $tspreparediskOutput ; set +f
552    magicWord=$1
553    rc2=$2
554    backupPvid=$3
555    backupLocalName=$4
556    status=$5
557    IFS="$IFS_sv"
558
559    if [[ $rc  -ne 0 || $magicWord != tspreparedisk ||
560          $rc2 -ne 0 || $pvid != $backupPvid ]]
561    then
562      # Try to make sense of the error.
563      if [[ $magicWord = tspreparedisk ]]
564      then
565        # tspreparedisk was executed but was not happy about something.
566        if [[ $rc2 = 1 ]]
567        then
568          # Permission was denied for disk.
569          printErrorMsg 523 $mmcmd $device
570        elif [[ $rc2 = 2 ]]
571        then
572          # The disk was not found.
573          printErrorMsg 524 $mmcmd $device
574        elif [[ $rc2 = 5 ]]
575        then
576          # I/O error
577          printErrorMsg 525 $mmcmd $device
578        elif [[ $rc2 = $MM_DeviceNotFound ]]
579        then
580          # A return code of ENODEV was returned for the disk.
581          printErrorMsg 187 $mmcmd $invokedNode $device
582        elif [[ $rc2 = 50 ]]
583        then
584          # The disk is fenced out.
585          printErrorMsg 395 $mmcmd $invokedNode $device
586        elif [[ $pvid != $backupPvid ]]
587        then
588          print -u2 "$mmcmd: Mismatched disk PVIDs"
589        else
590          # Show the result from tspreparedisk.
591          print -u2 "$tspreparediskOutput"
592          # Unexpected error from tspreparedisk -p
593          printErrorMsg 171 "$mmcmd"  \
594            "tspreparedisk -p $pvid -t $nsdSubtype" $rc2
595        fi  # end if [[ $rc2 = 1 ]]
596      else
597        # Something is really wrong.  Output error information if any.
598        [[ -n $tspreparediskOutput ]] && print -u2 "$tspreparediskOutput"
599      fi  # end if [[ $magicWord = tspreparedisk ]]
600
601      # Failed while processing disk descriptor
602      printErrorMsg 411 $mmcmd "$mmDiskDesc" $backup
603      [[ -z $desiredName ]] && highestGpfsDiskNbr=highestGpfsDiskNbr-1
604      continue                        # Skip to the next disk descriptor.
605    fi  # end if [[ $rc -ne 0 || $magicWord != tspreparedisk || ... ]]
606
607  fi  # end of if [[ -n $backup ]]
608
609  # At this point, the descriptor passed all checks successfully,
610  # the disk was formatted as an NSD, and updatedDiskLine contains
611  # the SG_DISKS line that needs to go in the mmsdrfs file.
612  print -- $updatedDiskLine >> $newsdrfs
613  checkForErrors "writing to file $newsdrfs" $?
614
615  # Append the good modified descriptor to the temporary descriptor file.
616  print -- "$nsdName:::$diskUsage:$failureGroup::$storagePool" >> $tdescfile
617  checkForErrors "writing to file $tdescfile" $?
618
619  # There is at least one good disk descriptor.
620  hadSuccess=true
621
622done  # end of while read -u3 mmDiskDesc
623
624
625# If all of the descriptors had some kind of error and not a single
626# disk was created, give up.  Messages have already been issued.
627[[ $hadSuccess != true ]] &&  \
628  cleanupAndExit
629
630
631####################################################################
632# We have now finished processing descriptors.
633# Create a new version line with an updated HIGHEST_GPFS_DISK_NBR
634# value that reflects the highest disk number currently assigned
635# and add it back to the mmsdrfs file.  Commit the changes.
636####################################################################
637newVersionLine="$versionLine_A:$highestGpfsDiskNbr:$versionLine_B"
638print -- $newVersionLine >> $newsdrfs
639checkForErrors "writing to file $newsdrfs" $?
640
641# Sort the new sdrfs file.
642LC_ALL=C $SORT_MMSDRFS $newsdrfs -o $newsdrfs
643
644# Replace the mmsdrfs file.
645# This makes the new disks visible to other mm commands.
646trap "" HUP INT QUIT KILL
647gpfsObjectInfo=$(commitChanges  \
648   $FREE_DISK $nsId $gpfsObjectInfo $newGenNumber $newsdrfs $primaryServer)
649rc=$?
650if [[ $rc -ne 0 ]]
651then
652  # We were unable to replace the file in the sdr.
653  printErrorMsg 381 $mmcmd
654  cleanupAndExit
655fi
656
657
658##################
659# Unlock the sdr.
660##################
661[[ $sdrLocked = yes ]] &&  \
662  freeLockOnServer $primaryServer $ourNodeNumber >/dev/null
663sdrLocked=no
664trap posttrap HUP INT QUIT KILL
665
666
667#############################################################################
668# Move the updated (and any commented out) descriptors into the user's file.
669#############################################################################
670$mv $tdescfile $descfile
671checkForErrors "writing to file $descfile" $?
672
673
674#################################################################
675# Propagate the new mmsdrfs file.  This process is asynchronous.
676#################################################################
677propagateSdrfsFile async $nodefile $newsdrfs $newGenNumber rereadnsd
678
679
680###################################################
681# If installed, invoke the syncfsconfig user exit.
682###################################################
683if [[ -x $syncfsconfig ]]
684then
685   print -- "$mmcmd:  Starting $syncfsconfig ..."
686   $syncfsconfig
687   print -- "$mmcmd$syncfsconfig finished."
688fi
689
690cleanupAndExit 0
691
Note: See TracBrowser for help on using the repository browser.