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

Last change on this file since 223 was 16, checked in by rock, 17 years ago
  • Property svn:executable set to *
File size: 25.4 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# @(#)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
52sourceFile="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
59descfile=${tmpDir}descfile.${mmcmd}.$$     # temp file for descriptors
60tsddFile=${tmpDir}tsddFile.${mmcmd}.$$     # disk descriptors in tscrfs format
61freeDisks=${tmpDir}freeDisks.${mmcmd}.$$   # available unused disks
62
63LOCAL_FILES=" $descfile $tsddFile $freeDisks "
64
65
66# Local variables
67usageMsg=420
68integer seqNo=0
69
70# Values for /etc/filesystems stanza lines
71sgVFS_Line_Value="mmfs"       # only acceptable value
72sgTYPE_Line_Value="mmfs"      # only acceptable value
73sgNODENAME_Line_Value="-"     # only acceptable value
74sgACCOUNT_Line_Value="false"  # only acceptable value
75sgRW_OPT_Value="rw"           # only acceptable value
76sgOTHER_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.
97mountPoint=$arg1
98device=$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.
102if [[ $arg3 = "-F" ]]
103then
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 ]]
114else
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
120fi  # end of if [[ $arg3 = "-F" ]]
121
122# Save the remainder of the argument list for later processing by mmcrfsc.
123argList=$@
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.
128while 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
129do
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
156done  # end of while getopts
157
158# Verify the device name.
159deviceName=${device##+(/)dev+(/)}  # name stripped of /dev/ prefix
160fqDeviceName="/dev/$deviceName"    # fully-qualified name with /dev/ prefix
161if [[ $deviceName = /* ]]
162then
163  printErrorMsg 169 $mmcmd $device
164  cleanupAndExit
165elif [[ $deviceName = */* ]]
166then
167  printErrorMsg 170 $mmcmd $device
168  cleanupAndExit
169else
170  checkName deviceName 255 "$deviceName"
171  [[ $? -ne 0 ]] && cleanupAndExit
172fi
173
174# Verify the mount point parameter.
175checkName pathName 1023 "$mountPoint"
176[[ $? -ne 0 ]] && cleanupAndExit
177
178if [[ $mountPoint = ${mountPoint#/} ]]
179then
180  # The mountpoint must not be a relative path name.
181  printErrorMsg 148 $mmcmd $mountPoint
182  cleanupAndExit
183fi
184
185if [[ $fqDeviceName = $mountPoint ]]
186then
187  # The mount point cannot be the same as the device name.
188  printErrorMsg 305 $mmcmd $mountPoint
189  cleanupAndExit
190fi
191
192# Process the -N option (mmcrfsc is not suited for this option).
193# Verify that the value is of the form NumInodes[:NumInodesToPreallocate]
194if [[ -n $Narg ]]
195then
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
215fi  # 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#######################################################################
223trap pretrap HUP INT QUIT KILL
224gpfsInitOutput=$(gpfsInit $lockId)
225setGlobalVar $? $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.
246IFS=":"            # Change the field separator to ':'.
247exec 3<&-
248exec 3< $mmsdrfsFile
249while read -u3 sdrfsLine
250do
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
333done  # end while read -u3 mmsdrfsFile
334
335IFS="$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#############################################################
344if [[ -n $desclist ]]
345then
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"
356fi  # end of if [[ -n $desclist ]]
357
358
359##########################################################
360# Make sure that there is at least one free disk line.
361##########################################################
362if [[ ! -s $freeDisks ]]
363then
364  printErrorMsg 470 $mmcmd $mmcmd mmcrnsd
365  cleanupAndExit
366fi
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
375foundErrors=false
376fsHomeCluster=$HOME_CLUSTER
377
378exec 3<&-
379exec 3< $descfile
380while read -u3 mmDiskDesc
381do
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
513done   # end of while read -u3 mmDiskDesc
514
515
516# Give up if there were errors with one or more of the descriptors.
517if [[ $foundErrors = true ]]
518then
519  # Command failed.
520  printErrorMsg 389 $mmcmd
521  cleanupAndExit
522fi
523
524# Were there disks to begin with?
525if [[ -z $onemeta && -z $onedata ]]
526then
527  # No disks were specified.
528  printErrorMsg 264 $mmcmd
529  cleanupAndExit
530fi
531
532# Make sure that not all of the disks are dataOnly or metadataOnly.
533if [[ -z $onemeta ]]
534then
535  # All disks are dataOnly.
536  printErrorMsg 198 $mmcmd
537  cleanupAndExit
538fi
539
540if [[ -z $onedata ]]
541then
542  # All disks are metadataOnly.
543  printErrorMsg 197 $mmcmd
544  cleanupAndExit
545fi
546
547# If there are any SG_DISKS lines for remaining free disks,
548# put them back in the mmsdrfs file.
549if [[ -s $freeDisks ]]
550then
551  $cat $freeDisks >> $newsdrfs
552  checkForErrors "cat $freeDisks >> $newsdrfs" $?
553fi
554
555
556# Before checking the rest of the parameters,
557# we need to determine the current maxblocksize in effect.
558maxblocksize=$($mmcommon onactive $preferredNode $nodefile  \
559  $NO_FILE_COPY $NO_MOUNT_CHECK NULL $NO_LINK tsctl showCfgValue maxblocksize)
560rc=$?
561if [[ -z $maxblocksize || $rc -ne 0 ]]
562then
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
582fi
583
584# Use mmcrfsc to check the rest of the arguments.
585# Error messages will be issued by mmcrfsc.
586mmcrfscOutput=$($mmcrfsc M $maxblocksize $argList)
587rc=$?
588[[ $rc -eq 123 ]] && printErrorMsg $usageMsg $mmcmd
589[[ $rc -ne   0 ]] && cleanupAndExit
590
591# Parse the mmcrfsc output.
592set -f ; set -- $mmcrfscOutput ; set +f
593sgMOUNT_Line_Value=$1
594sgMTIME_OPT_Value=$2
595quotaOption=$3
596sgATIME_OPT_Value=$4
597shift 4
598tsArguments="$*"
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.
608if [[ $quotaOption = enableQuota ]]
609then
610  sgQUOTA_OPT_Value=$QUOTA_ACTIVATED
611else
612  sgQUOTA_OPT_Value=$QUOTA_DISACTIVATED
613fi
614
615# Figure out what should the major number be.
616if [[ $osName = Linux ]]
617then
618  checkVfsNumber
619  devMajor=$currentMajorNumber
620fi
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.
625rc=0
626minor=""
627while [[ -z $minor && $rc -eq 0 ]]
628do
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 ]]
646done # end of while [[ -z $minor && $rc -eq 0 ]]
647
648if [[ -z $minor ]]
649then
650  print -u2 "$mmcmd:  Cannot assign a minor number for the file system."
651  cleanupAndExit
652fi
653
654
655# If this is the first automountable GPFS file system,
656# run the automount command on the nodes in the cluster.
657if [[ $sgMOUNT_Line_Value = automount && -z $automountMounts ]]
658then
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 ]]
681fi  # 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.
687IFS=' '
688
689newLine="$fsHomeCluster:$SG_HEADR:$deviceName::$minor::::"
690print "$newLine" >> $newsdrfs
691
692newLine="$fsHomeCluster:$SG_ETCFS:$deviceName:$MOUNT_POINT_Line:$mountPoint:"
693print "$newLine" >> $newsdrfs
694
695newLine="$fsHomeCluster:$SG_ETCFS:$deviceName:$DEV_Line"
696newLine="$newLine:$DEV_Line_Prefix$fqDeviceName"
697print "$newLine" >> $newsdrfs
698
699newLine="$fsHomeCluster:$SG_ETCFS:$deviceName:$VFS_Line"
700newLine="$newLine:$VFS_Line_Prefix$sgVFS_Line_Value"
701print "$newLine" >> $newsdrfs
702
703newLine="$fsHomeCluster:$SG_ETCFS:$deviceName:$NODENAME_Line"
704newLine="$newLine:$NODENAME_Line_Prefix$sgNODENAME_Line_Value"
705print "$newLine" >> $newsdrfs
706
707newLine="$fsHomeCluster:$SG_ETCFS:$deviceName:$MOUNT_Line"
708newLine="$newLine:$MOUNT_Line_Prefix$sgMOUNT_Line_Value"
709print "$newLine" >> $newsdrfs
710
711newLine="$fsHomeCluster:$SG_ETCFS:$deviceName:$TYPE_Line"
712newLine="$newLine:$TYPE_Line_Prefix$sgTYPE_Line_Value"
713print "$newLine" >> $newsdrfs
714
715newLine="$fsHomeCluster:$SG_ETCFS:$deviceName:$ACCOUNT_Line"
716newLine="$newLine:$ACCOUNT_Line_Prefix$sgACCOUNT_Line_Value"
717print "$newLine" >> $newsdrfs
718
719newLine="$fsHomeCluster:$SG_MOUNT:$deviceName::$sgRW_OPT_Value"
720newLine="$newLine:$sgMTIME_OPT_Value:$sgATIME_OPT_Value"
721newLine="$newLine:$sgQUOTA_OPT_Value:$sgOTHER_OPT_Value:::::::::::::"
722print "$newLine" >> $newsdrfs
723checkForErrors "writing to file $newsdrfs" $?
724
725IFS="$IFS_sv"
726
727
728# The last step in creating the new mmsdrfs file is sorting it.
729LC_ALL=C $SORT_MMSDRFS $newsdrfs -o $newsdrfs
730checkForErrors "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"
739rc=$?
740if [[ $rc -ne 0 ]]
741then
742  # tscrfs failed.
743  printErrorMsg 100 $mmcmd $device
744  cleanupAndExit $rc
745fi
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#############################################################
753trap "" HUP INT QUIT KILL
754gpfsObjectInfo=$(commitChanges  \
755   $fsHomeCluster $nsId $gpfsObjectInfo $newGenNumber $newsdrfs $primaryServer)
756rc=$?
757if [[ $rc -ne 0 ]]
758then
759  # The commit step failed; we cannot replace the file in the sdr.
760  printErrorMsg 381 $mmcmd
761  cleanupAndExit
762fi
763
764
765#############################################################
766# Unlock the sdr.
767#############################################################
768freeLockOnServer $primaryServer $ourNodeNumber >/dev/null
769sdrLocked=no
770trap 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#########################################################################
778propagateSdrfsFile async $nodefile $newsdrfs $newGenNumber
779
780
781###################################################
782# If installed, invoke the syncfsconfig user exit.
783###################################################
784if [[ -x $syncfsconfig ]]
785then
786   print -- "$mmcmd:  Starting $syncfsconfig ..."
787   $syncfsconfig
788   print -- "$mmcmd$syncfsconfig finished."
789fi
790
791cleanupAndExit 0
792
Note: See TracBrowser for help on using the repository browser.