source: gpfs_3.1_ker2.6.20/lpp/mmfs/bin/mmadddisk @ 223

Last change on this file since 223 was 16, checked in by rock, 17 years ago
  • Property svn:executable set to *
File size: 27.0 KB
RevLine 
[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# @(#)14 1.128.1.3 src/avs/fs/mmfs/ts/admin/mmadddisk.sh, mmfs, avs_rgpfs24, rgpfs24s005a 7/14/06 17:46:24
17################################################################################
18#
19# Usage:
20#   mmadddisk Device {"DiskDesc[;DiskDesc...]" | -F DescFile} [-a] [-r]
21#     [-v {yes | no}] [-N {all | mount | Node[,Node...] | NodeFile | NodeClass}]
22#
23# where
24#   Device    is the file system device name
25#   DiskDesc  is the same syntax as DiskDesc of mmcrfs
26#   -r        rebalance stripe group when done
27#   -a        if -r specified, command returns before rebalancing is finished
28#   -v        make sure the disk does not belong to another file system
29#   -N        parallel restripe options:
30#               all        - use all of the nodes in the cluster
31#               mount      - use only the nodes on which the fs is mounted
32#               node list  - use only the nodes in the list
33#               node file  - use only the nodes in the file
34#               node class - use only the nodes in the class
35#
36################################################################################
37
38# Include global declarations and service routines.
39. /usr/lpp/mmfs/bin/mmglobfuncs
40. /usr/lpp/mmfs/bin/mmsdrfsdef
41. /usr/lpp/mmfs/bin/mmfsfuncs
42
43sourceFile="mmadddisk.sh"
44[[ -n $DEBUG || -n $DEBUGmmadddisk ]] && set -x
45$mmTRACE_ENTER "$*"
46
47# Local work files.  Names should be of the form:
48#   fn=${tmpDir}fn.${mmcmd}.$$
49
50tsddFile=${tmpDir}tsddFile.${mmcmd}.$$     # tsadddisk format disk descriptors
51descfile=${tmpDir}descfile.${mmcmd}.$$     # temp file for descriptors
52freeDisks=${tmpDir}freeDisks.${mmcmd}.$$   # available unused disks
53
54LOCAL_FILES=" $tsddFile $descfile $freeDisks "
55
56
57# Local variables
58usageMsg=296
59noUsageMsg=0
60integer seqNo=0
61
62
63# Local functions
64
65#####################################################
66# This function is called if there is an interrupt
67# after some sdr changes are committed.
68#####################################################
69function localPosttrap
70{
71  # Restriping may not have finished.
72  [[ -n $rflag && -z $aflag ]] &&  \
73    printErrorMsg 35 $mmcmd
74
75  # Exit via the standard post trap routine.
76  posttrap
77}
78
79
80
81######################
82# Mainline processing
83######################
84
85
86######################################
87# Process the command line arguments.
88######################################
89[[ $arg1 = '-?' || $arg1 = '-h' || $arg1 = '--help' || $arg1 = '--' ]] &&  \
90  syntaxError "help" $usageMsg
91
92[[ $argc -lt 2  ]] &&  \
93  syntaxError "missingArgs" $usageMsg
94
95# The first argument is always the file system name.
96device=$arg1
97
98if [[ $arg2 != "-F" ]]
99then
100  # If the second argument is not -F, it must be a disk descriptor list.
101  desclist=$arg2
102  # Ensure that semi-colon is used as a disk name separator.
103  [[ "$desclist" = *+([,${BLANKchar}${TABchar}])* ]] &&  \
104    syntaxError "badSeparator_notSemicolon" $noUsageMsg
105
106else
107  # -F specified.  The third argument must be a file name.
108  if [[ -z $arg3 ]]
109  then
110    syntaxError "missingFile" $usageMsg
111  else
112    # Verify the existence of the file and create our own copy.
113    checkUserFile $arg3 $descfile
114    [[ $? -ne 0 ]] && cleanupAndExit
115    shift
116  fi  # end of if [[ -z $arg3 ]]
117fi  # end of if [[ $arg2 != "-F" ]]
118
119# Move past the required parameters.
120shift 2
121
122# Check the validity of the flags.
123while getopts :arv:N: OPT
124do
125  case $OPT in
126    a) [[ -n $aflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
127       aflag=yes
128       ;;
129
130    r) [[ -n $rflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
131       rflag=yes
132       ;;
133
134    N) [[ -n $Nflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
135       nodeList="$OPTARG"
136       Nflag="-N $OPTARG"
137       ;;
138
139    v) [[ -n $vflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
140       if [[ $OPTARG = yes || $OPTARG = no ]]
141       then
142         vflag="-v $OPTARG"
143       else
144         syntaxError "YesNoValue" $noUsageMsg "-$OPT"
145       fi
146       ;;
147
148    +[arvN])
149     syntaxError "invalidOption" $usageMsg $OPT
150       ;;
151
152    :) syntaxError "missingValue" $usageMsg $OPTARG
153       ;;
154
155    *) syntaxError "invalidOption" $usageMsg $OPTARG
156       ;;
157  esac
158done
159
160shift OPTIND-1
161[[ $# != 0 ]] && syntaxError "extraArg" $usageMsg $1
162
163
164#####################################################################
165# Set up trap exception handling and call the gpfsInit function.
166# It will ensure that the local copy of the mmsdrfs and the rest of
167# the GPFS system files are up-to-date and will obtain the sdr lock.
168#####################################################################
169trap pretrap HUP INT QUIT KILL
170gpfsInitOutput=$(gpfsInit $lockId)
171setGlobalVar $? $gpfsInitOutput
172
173# Determine the lookup order for resolving host names.
174[[ $osName != AIX ]] && resolveOrder=$(setHostResolveOrder)
175
176
177###########################################################
178# Make sure the specified file system exists and is local.
179###########################################################
180findFSoutput=$(findFS "$device" $mmsdrfsFile)
181[[ -z $findFSoutput ]] && cleanupAndExit
182
183# Parse the output from the findFS function.
184set -f ; set -- $findFSoutput ; set +f
185fqDeviceName=$1
186deviceName=$2
187fsHomeCluster=$3
188oddState=$5
189
190# Exit with a message if the command was invoked for a remote file system.
191if [[ $fsHomeCluster != $HOME_CLUSTER ]]
192then
193  # Command is not allowed for remote file systems.
194  printErrorMsg 106 $mmcmd $device $fsHomeCluster
195  cleanupAndExit
196fi
197
198# Check whether some of the disks in the file system may be in an odd state.
199if [[ $oddState = yes ]]
200then
201  # Some of the disks in the file system appear to be in an odd state.
202  # Reconcile the sdrfs file with the GPFS daemon's view of the filesystem.
203  $cp $mmsdrfsFile $newsdrfs
204  reconcileSdrfsWithDaemon $deviceName $newsdrfs
205  rc=$?
206  if [[ $rc -ne 0 ]]
207  then
208    # reconcileSdrfsWithDaemon failed.
209    printErrorMsg 171 $mmcmd reconcileSdrfsWithDaemon $rc
210    # Tell the user to run mmcommon recoverfs against the file system.
211    printErrorMsg 103 $mmcmd $deviceName $deviceName
212    cleanupAndExit
213  fi
214
215  # Obtain the generation number from the version line of the new sdrfs file.
216  versionLine=$($head -1 $newsdrfs)
217  IFS=':'
218  set -f ; set -- $versionLine ; set +f
219  newGenNumber=$6
220  IFS="$IFS_sv"
221
222  # Commit the reconciled version of the sdrfs file to the server
223  # so the admin scripts and the daemon are in sync.
224  trap "" HUP INT QUIT KILL    # Disable interrupts until the commit is done.
225  gpfsObjectInfo=$(commitChanges  \
226    $fsHomeCluster $nsId $gpfsObjectInfo $newGenNumber $newsdrfs $primaryServer)
227  if [[ $? -ne 0 ]]
228  then
229    # We were unable to replace the file in the sdr.
230    printErrorMsg 381 $mmcmd
231    # Tell the user to run mmcommon recoverfs against the filesystem.
232    printErrorMsg 190 $mmcmd $deviceName $deviceName
233    printErrorMsg 104 $mmcmd mmadddisk
234    cleanupAndExit
235  fi
236  trap posttrap HUP INT QUIT KILL
237fi  # end of if [[ $oddState = yes ]]
238
239
240#######################################################
241# If a list of nodes was specified via the -N option,
242# convert it to a verified list of daemon node names.
243#######################################################
244if [[ -n $Nflag && $nodeList != all && $nodeList != mount ]]
245then
246  createVerifiedNodefile "$nodeList" $DAEMON_NODENAME_Field no $nodefile
247  [[ $? -ne 0 ]] && cleanupAndExit
248
249  # Convert the output data from a file to a comma-separated list.
250  newNodeList=$(print -- $(cat $nodefile) | $sed 's/ /,/g')
251  Nflag="-N $newNodeList"
252fi  # end of if [[ -n $Nflag && $nodeList != all && $nodeList != mount ]]
253
254
255#########################################################################
256# Create a new version of the mmsdrfs file with a new generation number
257# for the final commit after the tsadddisk command has succeeded.
258# Generate a file with the reliable host names of the affected nodes.
259#########################################################################
260$rm -f $nodefile $newsdrfs $freeDisks $allQuorumNodes
261$touch $freeDisks  # Ensure the file exists even if empty.
262IFS=":"            # Change the field separator to ':'.
263exec 3<&-
264exec 3< $mmsdrfsFile
265while read -u3 sdrfsLine
266do
267  # Parse the line.
268  set -f ; set -A v -- - $sdrfsLine ; set +f
269
270  IFS="$IFS_sv"    # Restore the default IFS settings.
271  printLine=true   # Assume the line will be printed.
272
273  # Change some of the fields depending on the type of line.
274  case ${v[$LINE_TYPE_Field]} in
275
276    $VERSION_LINE )  # This is the global header line.
277       # Increment the generation number by 1.
278       newGenNumber=${v[$SDRFS_GENNUM_Field]}+1
279       v[$SDRFS_GENNUM_Field]=$newGenNumber
280       ;;
281
282    $MEMBER_NODE )  # This line describes a node that belongs to some nodeset.
283       # Add the reliable node name to nodefile.
284       print -- "${v[$REL_HOSTNAME_Field]}" >> $nodefile
285       checkForErrors "writing to file $nodefile" $?
286
287       # Create a list of the quorum nodes.
288       if [[ ${v[$CORE_QUORUM_Field]} = $quorumNode ]]
289       then
290         print -- "${v[$REL_HOSTNAME_Field]}" >> $allQuorumNodes
291         checkForErrors "writing to file $allQuorumNodes" $?
292       fi
293
294       # If the node that is executing this command is part of the nodeset,
295       # designate it as a "preferred node".
296       [[ ${v[$NODE_NUMBER_Field]} = $ourNodeNumber ]] &&  \
297         preferredNode=${v[$REL_HOSTNAME_Field]}
298       ;;
299
300    $SG_HEADR )  # This is the header line for some file system.
301       # Check whether the filesystem has disks that are in an "odd state".
302       if [[ -n ${v[$ODD_STATE_Field]} && ${v[$ODD_STATE_Field]} != no ]]
303       then
304         # Is this filesystem a different one than the one for which
305         # this command was invoked?
306         if [[ ${v[$DEV_NAME_Field]} != $deviceName ]]
307         then
308           # The "odd state" flag is set for a different file system
309           # than our filesystem.  Add the name of the file system to a
310           # list of filesystems to be reported to the user later.
311           fsOddStateList="${fsOddStateList} ${v[$DEV_NAME_Field]}"
312         else
313           # The "odd state" flag is set for the file system
314           # for which this command was invoked.
315           :  # Allow the command to proceed, since it may succeed.
316              # We will report any failures if it does not.
317         fi
318       else
319         # Is this filesystem the one for which this command was invoked?
320         if [[ ${v[$DEV_NAME_Field]} = $deviceName ]]
321         then
322           # Set the "odd state" field in case we don't succeed.
323           # We will reset it later if tsadddisk succeeds.
324           v[$ODD_STATE_Field]=mmadddisk
325         fi
326       fi
327       ;;
328
329    $SG_DISKS )  # This line describes a disk that belongs to some file system.
330       # If this disk belongs to our file system, make sure the line
331       # has a valid sequence number.  Older file systems were created
332       # without numbering the lines.  Furthermore, it is possible to add
333       # disks from a node that still runs a previous GPFS release and this
334       # could result in SG_DISKS lines without a line number.
335       if [[ ${v[$DEV_NAME_Field]} = $deviceName ]]
336       then
337         seqNo=seqNo+1
338         v[$LINE_NUMBER_Field]=$seqNo
339       fi
340
341       # Collect the SG_DISKS lines for all free disks into a file.
342       # These are the disks that are available to the new file system.
343       if [[ ${v[$NODESETID_Field]} = $FREE_DISK ]]
344       then
345         print_newLine >> $freeDisks
346         printLine=false
347       fi
348       ;;
349
350    * )  # Pass all other lines without a change.
351       ;;
352
353  esac  # end of "Change some of the fields . . . "
354
355  # Build and write the line to the new mmsdrfs file.
356  if [[ $printLine = true ]]
357  then
358    print_newLine >> $newsdrfs
359    checkForErrors "writing to file $newsdrfs" $?
360  fi
361
362  IFS=":"  # Change the separator back to ":" for the next iteration.
363
364done  # end while read -u3 sdrfsLine
365
366IFS="$IFS_sv"  # Restore the default IFS settings.
367
368
369###########################################################
370# If a descriptor list is specified on the command line,
371# create a file with one disk descriptor per line.
372# Note:  If the input is in a file, descfile was created
373#        by the checkUserFile function.
374###########################################################
375if [[ -n $desclist ]]
376then
377  # Copy the descriptors into a temporary file.
378  $rm -f $descfile
379  IFS=";"
380  for diskDesc in $desclist
381  do
382    [[ -z $diskDesc ]] && continue
383    print -- "$diskDesc" >> $descfile
384    checkForErrors "writing to file $descfile" $?
385  done  # end for diskDesc in $desclist
386  IFS="$IFS_sv"
387fi  # end of if [[ -n $desclist ]]
388
389
390##########################################################
391# Make sure that there is at least one free disk line.
392##########################################################
393if [[ ! -s $freeDisks ]]
394then
395  # There are no available free disks.
396  printErrorMsg 470 $mmcmd $mmcmd mmcrnsd
397  cleanupAndExit
398fi
399
400
401#########################################################################
402# Process the descriptors for the new disks.  If all of the information
403# is correct, the descriptor is converted into the format recognized by
404# the tsadddisk command.
405#########################################################################
406$rm -f $tsddFile
407foundErrors=false
408exec 3<&-
409exec 3< $descfile
410while read -u3 mmDiskDesc
411do
412  # Skip empty and comment lines.
413  [[ $mmDiskDesc = *([$BLANKchar$TABchar])   ]] && continue
414  [[ $mmDiskDesc = *([$BLANKchar$TABchar])#* ]] && continue
415
416  # Parse mmDiskDesc to get the name of the disk.
417  IFS=':'
418  set -f ; set -- $mmDiskDesc ; set +f
419  diskName=$1
420  IFS="$IFS_sv"
421
422  if [[ -z $diskName ]]
423  then
424    # The disk name must be specified in the disk descriptor.
425    printErrorMsg 23 $mmcmd
426
427    # Show the bad descriptor.
428    printErrorMsg 386 $mmcmd "$mmDiskDesc"
429
430    # The command will fail, but before giving up, we will check the
431    # remainder of the descriptors to flush out as many errors as possible.
432    foundErrors=true
433    [[ $sdrLocked = yes ]] &&  \
434      freeLockOnServer $primaryServer $ourNodeNumber >/dev/null
435    sdrLocked=no
436
437    # Move to the next descriptor.
438    continue
439  fi
440
441  # Locate and extract the FREE_DISK line for this disk.
442  $rm -f $tmpfile
443  seqNo=seqNo+1
444  freeDiskLine=$($awk -F: '                                                   \
445    # If the line is for our disk, assign it to freeDiskLine.                 \
446    # Do not put the line in the temp file.                                   \
447    $'$DISK_NAME_Field' == "'$diskName'"  {                                   \
448        { $'$LINE_NUMBER_Field' = "'$seqNo'" }                                \
449        { print  $1":" $2":" $3":" $4":" $5":" $6":" $7":" $8":" $9":"$10":"  \
450                $11":"$12":"$13":"$14":"$15":"$16":"$17":"$18":"$19":"$20":"  \
451                $21":"$22":"$23":"$24":"$25":"$26":"$27":" }                  \
452        { next }                                                              \
453     }                                                                        \
454    # If the line is for some other disk, add it to tmpfile.                  \
455    { print $0 >> "'$tmpfile'" }                                              \
456  ' $freeDisks)
457  checkForErrors awk $?
458
459  # Prepare the freeDisks file for the next iteration.
460  # It will contain all of its original lines except the line
461  # that describes the disk that is currently being processed.
462  $touch $tmpfile    # Ensure file exists even if empty.
463  $mv $tmpfile $freeDisks
464  checkForErrors "mv $tmpfile $freeDisks" $?
465
466  # If not found, issue an appropriate error message.
467  if [[ -z $freeDiskLine ]]
468  then
469    # Check whether the disk already belongs to some file system.
470    fileSystem=$(findFSforDisk "$diskName" $newsdrfs)
471    if [[ -n $fileSystem ]]
472    then
473      # The disk is already assigned to a file system.
474      # This may be because the disk was specified more than once as input,
475      # or because the disk was assigned to the file system in the past.
476      printErrorMsg 265 $mmcmd $diskName $fileSystem
477      # Show the bad descriptor.
478      printErrorMsg 386 $mmcmd "$mmDiskDesc"
479    else
480      # Print error stating disk descriptor should refer to an existing NSD.
481      printErrorMsg 415 $mmcmd "$mmDiskDesc"
482    fi
483
484    # The command will fail, but before giving up, we will check the
485    # remainder of the descriptors to flush out as many errors as possible.
486    foundErrors=true
487    [[ $sdrLocked = yes ]] &&  \
488      freeLockOnServer $primaryServer $ourNodeNumber >/dev/null
489    sdrLocked=no
490
491    # Move to the next descriptor.
492    continue
493  fi  # end of if [[ -z $freeDiskLine ]]
494
495  # Check the correctness of the disk descriptor.  If everything is OK,
496  # validateAndConvertNsdDescriptor will convert the descriptor into its
497  # tsadddisk format and will create the SG_DISKS line for the new disk.
498  validateDescriptorOutput=$(validateAndConvertNsdDescriptor "$mmDiskDesc"  \
499                             $freeDiskLine $deviceName $fsHomeCluster mmadd)
500  rc=$?
501  if [[ $rc -ne 0 ]]
502  then
503    # If an error was found, the validate routine issued a message.
504    # We will now print the entire descriptor to help the guy some more.
505    printErrorMsg 386 $mmcmd "$mmDiskDesc"
506
507    # The command will fail, but before giving up, we will check the remainder
508    # of the descriptors to flush out as many errors as possible.
509    foundErrors=true
510    [[ $sdrLocked = yes ]] &&  \
511      freeLockOnServer $primaryServer $ourNodeNumber >/dev/null
512    sdrLocked=no
513
514    # Move to the next descriptor.
515    continue
516  fi   # end of if [[ $rc -ne 0 ]]
517
518  # If the descriptor seems to be OK, parse the output
519  # from the validateAndConvertNsdDescriptor routine.
520  set -f ; set -- $validateDescriptorOutput ; set +f
521  updatedDiskLine="$1"
522  tsDiskDesc="$2"
523  diskUsage="$3"
524
525  # Add the converted descriptor to the input for tsadddisk.
526  print -- $tsDiskDesc >> $tsddFile
527  checkForErrors "writing to file $tsddFile" $?
528
529  # Add the SG_DISKS line for the new disk to the mmsdrfs file.
530  print -- $updatedDiskLine >> $newsdrfs
531  checkForErrors "writing to file $newsdrfs" $?
532
533done   # end of while read -u3 mmDiskDesc
534
535# Give up if there were errors with one or more of the descriptors.
536if [[ $foundErrors = true ]]
537then
538  # Command failed.
539  printErrorMsg 389 $mmcmd
540  cleanupAndExit
541fi
542
543# If there are any SG_DISKS lines for remaining free disks,
544# put them back in the mmsdrfs file.
545if [[ -s $freeDisks ]]
546then
547  $cat $freeDisks >> $newsdrfs
548  checkForErrors "cat $freeDisks >> $newsdrfs" $?
549fi
550
551# Make a copy of the current mmsdrfs file.  It may be needed
552# to restore the mmsdrfs file if the tsadddisk command fails.
553$cp $mmsdrfsFile $oldsdrfs
554checkForErrors cp $?
555
556
557############################################################################
558# Do the "pre-commit" of the sdrfs file.  The most important changes
559# being recorded are the indication that an mmadddisk is in progress and
560# the free disks that have been changed to belong to the file system with
561# a disk status of mmadd to indicate they are being added by mmadddisk.
562############################################################################
563# Sort the new version of the mmsdrfs file.
564LC_ALL=C $SORT_MMSDRFS $newsdrfs -o $newsdrfs
565checkForErrors "sorting $newsdrfs" $?
566
567trap "" HUP INT QUIT KILL    # Disable interrupts until the commit is done.
568gpfsObjectInfo=$(commitChanges  \
569  $fsHomeCluster $nsId $gpfsObjectInfo $newGenNumber $newsdrfs $primaryServer)
570rc=$?
571if [[ $rc -ne 0 ]]
572then
573  # We were unable to replace the file in the sdr.
574  printErrorMsg 381 $mmcmd
575  cleanupAndExit
576fi
577trap localPosttrap HUP INT QUIT KILL
578
579
580################################
581# Invoke the tsadddisk command.
582################################
583$mmcommon onactive $preferredNode $nodefile                      \
584                   $tsddFile $NO_MOUNT_CHECK NULL $NO_LINK       \
585                   tsadddisk "$fqDeviceName -F $tsddFile $vflag"
586rc=$?
587if [[ $rc -ne 0 ]]
588then
589  # tsadddisk failed.
590  printErrorMsg 104 $mmcmd tsadddisk
591
592  # Was the GPFS daemon up anywhere for tsadddisk to run?
593  if [[ $rc -eq $MM_DaemonDown ]]
594  then
595    # tsadddisk was never attempted because the daemon was not up anywhere.
596    # Make a modified version of the original sdrfs file with the generation
597    # number in the global header incremented by 2 but no other changes.
598    $rm -f $newsdrfs
599    newGenNumber=$($awk -F:  '                                                 \
600      BEGIN { gen = 0 }                                                        \
601      # If this is the global header line, increment the gen number.           \
602      /^'$GLOBAL_ID:$VERSION_LINE:'/ {                                         \
603        { gen = $'$SDRFS_GENNUM_Field' + 2 }                                   \
604        { $'$SDRFS_GENNUM_Field' = gen }                                       \
605        { print  $1":" $2":" $3":" $4":" $5":" $6":" $7":" $8":" $9":"$10":"   \
606                $11":"$12":"$13":"$14":"$15":"$16":"$17":"$18":"$19":"$20":"   \
607                $21":"$22":"$23":"$24":"$25":"$26":"$27":" >> "'$newsdrfs'" }  \
608        { next }                                                               \
609      }                                                                        \
610      # All other lines are printed without change.                            \
611      { print $0 >> "'$newsdrfs'" }                                            \
612      END { print gen }                                                        \
613    ' $oldsdrfs)
614    checkForErrors awk $?
615  else
616    # Since tsadddisk was attempted but failed, reconcile the
617    # sdrfs file with the GPFS daemon's view of the filesystem.
618    reconcileSdrfsWithDaemon $deviceName $newsdrfs
619    rc2=$?
620    if [[ $rc2 -ne 0 ]]
621    then
622      # reconcileSdrfsWithDaemon failed.
623      printErrorMsg 171 $mmcmd reconcileSdrfsWithDaemon $rc2
624      # Tell the user to run mmcommon recoverfs against the filesystem.
625      printErrorMsg 190 $mmcmd $deviceName $deviceName
626      cleanupAndExit $rc
627    fi
628    # Obtain the generation number from the version line of the new sdrfs file.
629    versionLine=$($head -1 $newsdrfs)
630    IFS=':'
631    set -f ; set -- $versionLine ; set +f
632    newGenNumber=$6
633    IFS="$IFS_sv"
634  fi  # end of if [[ $rc -eq $MM_DaemonDown ]]
635
636  # Commit the modified version of the sdrfs file to the server.
637  trap "" HUP INT QUIT KILL    # Disable interrupts until the commit is done.
638  gpfsObjectInfo=$(commitChanges  \
639    $fsHomeCluster $nsId $gpfsObjectInfo $newGenNumber $newsdrfs $primaryServer)
640  if [[ $? -ne 0 ]]
641  then
642    # We were unable to replace the file in the sdr.
643    printErrorMsg 381 $mmcmd
644    # Tell the user to run mmcommon recoverfs against the filesystem.
645    printErrorMsg 190 $mmcmd $deviceName $deviceName
646  fi
647
648  # Unlock the sdr.
649  [[ $sdrLocked = yes ]] &&  \
650    freeLockOnServer $primaryServer $ourNodeNumber >/dev/null
651  sdrLocked=no
652  trap localPosttrap HUP INT QUIT KILL
653
654  # Propagate the new mmsdrfs file.  This process is asynchronous.
655  propagateSdrfsFile async $nodefile $newsdrfs $newGenNumber
656
657  # Exit.
658  cleanupAndExit $rc
659fi
660
661
662###################################################################
663# If here, tsadddisk was successful.
664# Invoke routine to reset the "odd state" flag on the filesystem's
665# SG_HEADR line and change the SG_DISKS lines with a disk status
666# of mmadd to a regular (null) disk status.  The new mmsdrfs file
667# is then committed.  This makes the new disks visible to future
668# mm commands and to the mmcommon getEFOptions function.
669###################################################################
670# Reset the status fields of the disks we just added.
671resetDiskStatus $deviceName $newsdrfs mmadd
672checkForErrors updateDiskStatus $?
673
674# Obtain the generation number from the version line of the new sdrfs file.
675versionLine=$($head -1 $newsdrfs)
676IFS=':'
677set -f ; set -- $versionLine ; set +f
678newGenNumber=$6
679IFS="$IFS_sv"
680
681# Commit the new mmsdrfs file.
682trap "" HUP INT QUIT KILL    # Disable interrupts until the commit is done.
683gpfsObjectInfo=$(commitChanges  \
684   $fsHomeCluster $nsId $gpfsObjectInfo $newGenNumber $newsdrfs $primaryServer)
685rc=$?
686if [[ $rc -ne 0 ]]
687then
688  # We were unable to replace the file in the sdr.
689  printErrorMsg 381 $mmcmd
690  # Tell the user to run mmcommon recoverfs against the filesystem.
691  printErrorMsg 190 $mmcmd $deviceName $deviceName
692  cleanupAndExit
693fi
694
695
696##################
697# Unlock the sdr.
698##################
699[[ $sdrLocked = yes ]] &&  \
700  freeLockOnServer $primaryServer $ourNodeNumber >/dev/null
701sdrLocked=no
702trap localPosttrap HUP INT QUIT KILL
703
704
705######################################################################
706# Tell the daemon to invalidate its currently-cached mount options.
707######################################################################
708$mmcommon onactive $preferredNode $allQuorumNodes  \
709                   $NO_FILE_COPY $NO_MOUNT_CHECK NULL $NO_LINK  \
710                   tsctl resetEFOptions $fqDeviceName > $errMsg 2>&1
711rc=$?
712[[ $rc = $MM_DaemonDown ]] && rc=0
713[[ $rc -ne 0 && -s $errMsg ]] && cat $errMsg 2>&1
714$rm -f $errMsg
715
716
717#################################################################
718# Propagate the new mmsdrfs file.  This process is asynchronous.
719#################################################################
720propagateSdrfsFile async $nodefile $newsdrfs $newGenNumber
721
722
723###################################################
724# If installed, invoke the syncfsconfig user exit.
725###################################################
726if [[ -x $syncfsconfig ]]
727then
728   print -- "$mmcmd:  Starting $syncfsconfig ..."
729   $syncfsconfig
730   print -- "$mmcmd$syncfsconfig finished."
731fi
732
733
734#########################################
735# Restripe the file system if requested.
736#########################################
737if [[ -n $rflag ]]
738then
739  if [[ -n $aflag ]]
740  then
741    $ln $nodefile ${nodefile}async2
742    $mmcommon onactive_async $preferredNode  \
743      ${nodefile}async2 $NO_FILE_COPY $NO_MOUNT_CHECK NULL $NO_LINK  \
744      tsrestripefs "$fqDeviceName -b $Nflag" >/dev/null 2>/dev/null &
745  else
746    # Start restriping the file system.
747    printInfoMsg 95 $device
748    $mmcommon onactive  \
749        $preferredNode $nodefile $NO_FILE_COPY $NO_MOUNT_CHECK NULL $NO_LINK  \
750        tsrestripefs "$fqDeviceName -b $Nflag"
751    rc=$?
752    if [[ $rc -ne 0 ]]
753    then
754      # The restripe step failed.
755      printErrorMsg 104 $mmcmd tsrestripefs
756      # Warning:  File system may be unbalanced.
757      printErrorMsg 313 $mmcmd
758      cleanupAndExit
759    else
760      # Disable error message in localPosttrap.
761      rflag="r"
762      # Finished restriping.
763      printInfoMsg 99
764    fi
765  fi  # end if [[ -n $aflag ]]
766fi  # end if [[ -n $rflag ]]
767
768
769#####################################################################
770# If an "odd state" flag was encountered for any other file systems
771# in the mmsdrfs file, tell the user to issue commands to reconcile
772# the mmsdrfs file with the GPFS daemon's view of the filesystems.
773#####################################################################
774for fsname in $fsOddStateList
775do
776  # Tell the user to run mmcommon recoverfs against the file system.
777  printErrorMsg 103 $mmcmd $fsname $fsname
778done
779
780cleanupAndExit 0
781
Note: See TracBrowser for help on using the repository browser.