source: gpfs_3.1_ker2.6.20/lpp/mmfs/bin/mmdeldisk @ 148

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