source: gpfs_3.1_ker2.6.20/lpp/mmfs/bin/mmchfs @ 108

Last change on this file since 108 was 16, checked in by rock, 17 years ago
  • Property svn:executable set to *
File size: 30.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. 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# @(#)18 1.109.1.5 src/avs/fs/mmfs/ts/admin/mmchfs.sh, mmfs, avs_rgpfs24, rgpfs24s006a 8/25/06 13:05:47
17################################################################################
18#
19# Usage:
20#
21#   mmchfs Device [-A {yes | no | automount}] [-D {posix | nfs4}]
22#                 [-E {yes | no}] [-F MaxNumInodes[:NumInodesToPreallocate]]
23#                 [-k {posix | nfs4 | all}] [-m DefaultMetadataReplicas]
24#                 [-o mountOptions] [-Q {yes | no}] [-r DefaultDataReplicas]
25#                 [-K {no | whenpossible | always}]
26#                 [-s {roundRobin | random | balancedRandom}]
27#                 [-S {yes | no}] [-T Mountpoint] [-V] [-z {yes | no}]
28# or
29#   mmchfs Device [-W newDeviceName]
30#
31# where
32#
33#   Device           is the device name of the file system.
34#
35#   -A {yes|no|automount}  Set the automount option.
36#
37#   -D {posix|nfs4}  Indicates whether CIFS deny write locks block NFS writes
38#                      (nfs4) or not (posix)
39#
40#   -E {yes|no}      Enable or disable exact mtime
41#
42#   -F MaxNumInodes[:NumInodesToPreallocate]
43#                    Specify the maximum number of files in the file system.
44#                    Optionally, specify how many inodes to preallocate.
45#
46#   -k {posix|nfs4|all}  Specify the ACL semantics (posix, nfs4, all)
47#
48#   -K {no|whenpossible|always} Replica allocation behavior
49#
50#   -m DefaultMetadataReplicas
51#                    is the default for the current number of replicas
52#                    for metadata.
53#
54#   -o mountOptions  is a comma-separated list of mount options.
55#
56#   -Q {yes|no}      Enable or disable the quota option.
57#
58#   -r DefaultDataReplicas
59#                    is the default for the current number of replicas for data.
60#
61#   -s StripeMethod  is the stripe method.
62#
63#   -S {yes|no}      Enable or disable (suppress) atime.
64#
65#   -T {mountpoint}  Change the mount point to the specified value.
66#
67#   -V               Change the file system to the latest format version.
68#
69#   -W newDeviceName  is the desired new name of the file system.
70#
71#   -z {yes|no}      Enable or disable DMAPI.
72#
73#
74#  Note:  The -s option is undocumented.
75#
76#  Note:  The -C option is obsolete; use mmexportfs/mmimportfs instead.
77#
78################################################################################
79
80# Include global declarations and service routines.
81. /usr/lpp/mmfs/bin/mmglobfuncs
82. /usr/lpp/mmfs/bin/mmsdrfsdef
83. /usr/lpp/mmfs/bin/mmfsfuncs
84
85sourceFile="mmchfs.sh"
86[[ -n $DEBUG || -n $DEBUGmmchfs ]] && set -x
87$mmTRACE_ENTER "$*"
88
89
90# Local work files.  Names should be of the form:
91#   fn=${tmpDir}fn.${mmcmd}.$$
92
93LOCAL_FILES=" "
94
95
96# Local variables
97integer n
98usageMsg=421
99
100
101# Local functions
102
103
104###########################################################
105# This function is called if there is an interrupt after
106# mmsdrfs changes are committed but before ts changes are.
107###########################################################
108function localPosttrap
109{
110  if [[ -n $mmsdrfsParms ]]
111  then
112    # Interrupt received:  only -A, -Q, and -T changed.
113    printErrorMsg 33 $mmcmd
114  else
115    # Interrupt received:  no changes made.
116    printErrorMsg 20 $mmcmd
117  fi
118  $mmTRACE_EXIT "rc=2"
119  cleanupAndExit 2
120}
121
122
123###########################################################################
124#
125# Function:  Process the specified mount options string.
126#            Provide default values for missing options.
127#            This function is called if the -o flag is specified.
128#
129# Input:     $1 - A comma-separated list of mount options.
130#
131# Output:    Colon-separated string containing the fields:
132#              rwOption:mtimeOption:atimeOption:quotaOptions:otherOptions:
133#
134# Returns:   0 - success
135#            1 - error encountered
136#
137###########################################################################
138function parseMountOptions   # <optionsString>
139{
140  typeset sourceFile="mmchfs.sh"
141  [[ -n $DEBUG || -n $DEBUGparseMountOptions ]] && set -x
142  $mmTRACE_ENTER "$*"
143  typeset optionsString=$1
144
145  typeset rc=0
146  typeset rwOption=""
147  typeset mtimeOption=""
148  typeset atimeOption=""
149  typeset quotaOptions=""
150  typeset otherOptions=""
151
152
153  # Parse the options string looking for certain options.
154  # All other options are simply passed through.
155  IFS=","
156  for option in $optionsString
157  do
158    case $option in
159
160      rw | ro | rs )
161        [[ $option = rs ]] && option=ro
162        rwOption=$option
163        ;;
164
165      atime* | noatime )
166        if [[ $option = atime || $option = "atime=1" || $option = "atime=yes" ]]
167        then
168          atimeOption=atime
169        elif [[ $option = noatime || $option = "atime=0" || $option = "atime=no" ]]
170        then
171          atimeOption=noatime
172        else
173          print -u2 "$mmcmd:  Invalid mount option specified: $option."
174          return 1
175        fi
176        ;;
177
178      mtime* | nomtime )
179        if [[ $option = mtime || $option = "mtime=1" || $option = "mtime=yes" ]]
180        then
181          mtimeOption=mtime
182        elif [[ $option = nomtime || $option = "mtime=0" || $option = "mtime=no" ]]
183        then
184          mtimeOption=nomtime
185        else
186          print -u2 "$mmcmd:  Invalid mount option specified: $option."
187          return 1
188        fi
189        ;;
190
191      syncnfs* | nosyncnfs )
192        if [[ $option = syncnfs || $option = "syncnfs=1" || $option = "syncnfs=yes" ]]
193        then
194          otherOptions="${otherOptions},syncnfs"
195        elif [[ $option = nosyncnfs || $option = "syncnfs=0" || $option = "syncnfs=no" ]]
196        then
197          otherOptions="${otherOptions},nosyncnfs"
198        else
199          print -u2 "$mmcmd:  Invalid mount option specified: $option."
200          return 1
201        fi
202        ;;
203
204      *quota* )
205        quotaOptions="${quotaOptions};$option"
206        ;;
207
208      *rootSquash* )
209        :       # Do nothing; root squash is controlled with mmauth grant.
210        ;;
211
212      * )
213        otherOptions="${otherOptions},$option"
214        ;;
215
216    esac  # end of case $option in
217  done  # end of for option in $optionsString do
218  IFS="$IFS_sv"
219
220  quotaOptions="${quotaOptions##+(;)}"   # Strip leading  semicolons, if any.
221  quotaOptions="${quotaOptions%%+(;)}"   # Strip trailing semicolons, if any.
222  otherOptions="${otherOptions##+(,)}"   # Strip leading  commas, if any.
223  otherOptions="${otherOptions%%+(,)}"   # Strip trailing commas, if any.
224
225  # Output the results and return.
226  print -- "$rwOption:$mtimeOption:$atimeOption:$quotaOptions:$otherOptions:"
227
228  $mmTRACE_EXIT "rc=$rc"
229  return $rc
230
231}  #------ end of function parseMountOptions -----------------
232
233
234
235######################
236# Mainline processing
237######################
238
239
240#################################
241# Process the command arguments.
242#################################
243[[ $arg1 = '-?' || $arg1 = '-h' || $arg1 = '--help' || $arg1 = '--' ]] &&  \
244  syntaxError "help" $usageMsg
245
246[[ $argc -lt 2  ]] &&  \
247  syntaxError "missingArgs" $usageMsg
248
249# The first argument is always the file system name.
250device=$arg1
251shift 1          # Drop the device name from the parameter list.
252
253# Process the individual arguments and the values associated with them.
254while getopts :A:C:D:E:F:k:K:m:o:Q:r:s:S:T:W:z:V OPT
255do
256  case $OPT in
257
258    A) [[ -n $Aflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
259       Aflag="-$OPT"; Aarg=$OPTARG;
260       [[ $Aarg != yes && $Aarg != no && $Aarg != automount ]] &&  \
261         syntaxError "invalidOption" $usageMsg "-$OPT $OPTARG"
262       if [[ $Aarg = yes ]]
263       then
264         Aarg=mmfs
265       elif [[ $Aarg = no ]]
266       then
267         Aarg=false
268       else
269         :  # It must be "automount".
270       fi
271       # Add -A to the list of parameters not handled by the daemon.
272       if [[ -z $mmsdrfsParms ]]
273       then
274         mmsdrfsParms="-$OPT"
275       else
276         mmsdrfsParms="${mmsdrfsParms}, -$OPT"
277       fi
278       ;;
279
280    C) syntaxError "obsoleteOption" $usageMsg "-$OPT"
281       ;;
282
283    D) [[ -n $Dflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
284       Dflag="-$OPT"; Darg=$OPTARG;
285       [[ $Darg != nfs4 && $Darg != posix ]] &&  \
286         syntaxError "invalidOption" $usageMsg "-$OPT $OPTARG"
287       # Add -D to the list of parameters handled by tschfs.
288       tschfsParms="${tschfsParms} $Dflag $Darg"
289       ;;
290
291    E) [[ -n $Eflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
292       Eflag="-$OPT"; Earg=$OPTARG;
293       [[ $Earg != yes && $Earg != no ]] &&  \
294         syntaxError "YesNoValue" $noUsageMsg "-$OPT"
295       # Add -E to the list of parameters not handled by the daemon.
296       if [[ -z $mmsdrfsParms ]]
297       then
298         mmsdrfsParms="-$OPT"
299       else
300         mmsdrfsParms="${mmsdrfsParms}, -$OPT"
301       fi
302       if [[ $Earg = yes ]]
303       then
304         Earg="mtime"
305       else
306         Earg="nomtime"
307       fi
308       callResetEFOptions=yes
309       ;;
310
311    F) [[ -n $Fflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
312       Fflag="-$OPT"; Farg=$OPTARG;
313       ;;
314
315    k) [[ -n $kflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
316       kflag="-$OPT"; karg=$OPTARG;
317       [[ $karg != posix && $karg != nfs4 && $karg != all ]] &&  \
318         syntaxError "invalidOption" $usageMsg "-$OPT $OPTARG"
319       # Add -k to the list of parameters handled by tschfs.
320       tschfsParms="${tschfsParms} $kflag $karg"
321       ;;
322
323    K) [[ -n $Kflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
324       Kflag="-$OPT"; Karg=$OPTARG;
325       [[ $Karg != no && $Karg != whenpossible && $Karg != always ]] &&  \
326         syntaxError "invalidOption" $usageMsg "-$OPT $OPTARG"
327       # Add -K to the list of parameters handled by tschfs.
328       tschfsParms="${tschfsParms} $Kflag $Karg"
329       ;;
330
331    m) [[ -n $mflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
332       mflag="-$OPT"; marg=$OPTARG;
333       # Ensure that marg is an integer, and that its value is 1 or 2.
334       n=$(checkIntRange $mflag $marg 1 2)
335       [[ $? -ne 0 ]] && cleanupAndExit
336       # Add -m to the list of parameters handled by tschfs.
337       tschfsParms="${tschfsParms} $mflag $marg"
338       ;;
339
340    o) [[ -n $oflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
341       oflag="-$OPT"; oarg=$OPTARG;
342       [[ -z $oarg ]] && oarg=DELETE
343       # Add -o to the list of parameters not handled by the daemon.
344       if [[ -z $mmsdrfsParms ]]
345       then
346         mmsdrfsParms="-$OPT"
347       else
348         mmsdrfsParms="${mmsdrfsParms}, -$OPT"
349       fi
350       callResetEFOptions=yes
351       ;;
352
353    Q) [[ -n $Qflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
354       Qflag="-$OPT"; Qarg=$OPTARG;
355       [[ $Qarg != yes && $Qarg != no ]] &&  \
356         syntaxError "YesNoValue" $noUsageMsg "-$OPT"
357       # Add -Q to the list of parameters not handled by the daemon.
358       if [[ -z $mmsdrfsParms ]]
359       then
360         mmsdrfsParms="-$OPT"
361       else
362         mmsdrfsParms="${mmsdrfsParms}, -$OPT"
363       fi
364       if [[ $Qarg = yes ]]
365       then
366         Qarg=$QUOTA_ACTIVATED
367       else
368         Qarg=DELETE
369       fi
370       callResetEFOptions=yes
371       ;;
372
373    r) [[ -n $rflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
374       rflag="-$OPT"; rarg=$OPTARG;
375       # Ensure that rarg is an integer, and that its value is 1 or 2.
376       n=$(checkIntRange $rflag $rarg 1 2)
377       [[ $? -ne 0 ]] && cleanupAndExit
378       # Add -r to the list of parameters handled by tschfs.
379       tschfsParms="${tschfsParms} $rflag $rarg"
380       ;;
381
382    s) [[ -n $sflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
383       sflag="-$OPT"; sarg=$OPTARG;
384       # Let tschfs validate the argument.
385       # Add -s to the list of parameters handled by tschfs.
386       tschfsParms="${tschfsParms} $sflag $sarg"
387       ;;
388
389    S) [[ -n $Sflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
390       Sflag="-$OPT"; Sarg=$OPTARG;
391       [[ $Sarg != yes && $Sarg != no ]] &&  \
392         syntaxError "YesNoValue" $noUsageMsg "-$OPT"
393       # Add -S to the list of parameters not handled by the daemon.
394       if [[ -z $mmsdrfsParms ]]
395       then
396         mmsdrfsParms="-$OPT"
397       else
398         mmsdrfsParms="${mmsdrfsParms}, -$OPT"
399       fi
400       if [[ $Sarg = yes ]]
401       then
402         Sarg="noatime"
403       else
404         Sarg="atime"
405       fi
406       callResetEFOptions=yes
407       ;;
408
409    T) [[ -n $Tflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
410       Tflag="-$OPT"; Targ=$OPTARG;
411       # Ensure the pathname starts with a slash.
412       [[ $Targ = ${Targ#/} ]] &&  \
413         syntaxError "absolutePath" $noUsageMsg $Targ
414       # Add -T to the list of parameters not handled by the daemon.
415       if [[ -z $mmsdrfsParms ]]
416       then
417         mmsdrfsParms="-$OPT"
418       else
419         mmsdrfsParms="${mmsdrfsParms}, -$OPT"
420       fi
421       callResetEFOptions=yes
422       ;;
423
424    V) [[ -n $Vflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
425       Vflag="-$OPT";
426       # Add -V to the list of parameters handled by tschfs.
427       tschfsParms="${tschfsParms} $Vflag"
428       ;;
429
430    W) # If specified, W must be the only option.
431       [[ $argc -gt 3 ]] && syntaxError "help" $usageMsg
432       Wflag="-$OPT"; Warg=$OPTARG;
433       checkName deviceName 255 "$Warg"
434       [[ $? -ne 0 ]] && cleanupAndExit
435       ;;
436
437    z) [[ -n $zflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
438       zflag="-$OPT"; zarg=$OPTARG;
439       [[ $zarg != yes && $zarg != no ]] &&  \
440         syntaxError "YesNoValue" $noUsageMsg "-$OPT"
441       # Add -z to the list of parameters handled by tschfs.
442       tschfsParms="${tschfsParms} $zflag $zarg"
443       ;;
444
445     +[ACDEFkKmoQrsSTVWz]) # Invalid option.
446        syntaxError "invalidOption" $usageMsg $OPT
447        ;;
448
449     :) # Missing argument.
450        syntaxError "missingValue" $usageMsg $OPTARG
451        ;;
452
453     *) # Invalid option.
454        syntaxError "invalidOption" $usageMsg $OPTARG
455        ;;
456   esac
457done
458
459shift OPTIND-1
460[[ $# != 0 ]] && syntaxError "extraArg" $usageMsg $1
461
462# Parse and process the -o value if it was specified.
463# This can result in prior values for Earg, Qarg, and Sarg
464# being overridden.
465if [[ $oarg = DEFAULT || $oarg = DELETE ]]
466then
467  # Set the default mount options; leave the quota setting alone.
468  sgRW_OPT_Value="rw"
469  Earg="mtime"
470  Sarg="atime"
471  oarg=DELETE
472elif [[ -n $oarg ]]
473then
474  # Parse the mount options and set variables to be used later.
475  parseMountOptionsOutput=$(parseMountOptions $oarg)
476  [[ $? -ne 0 ]] && cleanupAndExit
477  IFS=":"
478  set -f ; set -- $parseMountOptionsOutput ; set +f
479  [[ -n $1 ]] && sgRW_OPT_Value=$1
480  [[ -n $2 ]] && Earg=$2
481  [[ -n $3 ]] && Sarg=$3
482  [[ -n $4 ]] && Qarg=$4
483  oarg=$5
484  IFS="$IFS_sv"
485fi  # end of if [[ $oarg = DEFAULT || $oarg = DELETE ]]
486
487# Process the -F value.  Verify it is of the form NumInodes[:NumInodesToPreallocate]
488if [[ -n $Farg ]]
489then
490  IFS=":"
491  set -f ; set -- $Farg ; set +f
492  numInodes=$1
493  numInodesToPreallocate=$2
494  IFS="$IFS_sv"
495
496  [[ -z $numInodes ]] &&  \
497    syntaxError "invalidOption" $usageMsg "$Fflag $Farg"
498
499  n=$(checkIntRange $Fflag $numInodes)
500  [[ $? -ne 0 ]] && cleanupAndExit
501  Farg=$n
502
503  if [[ -n $numInodesToPreallocate && $numInodesToPreallocate != 0 ]]
504  then
505    n=$(checkIntRange $Fflag $numInodesToPreallocate)
506    [[ $? -ne 0 ]] && cleanupAndExit
507    Farg="${Farg}:$n"
508  fi
509
510  # Add -F to the list of parameters handled by tschfs.
511  tschfsParms="${tschfsParms} $Fflag $Farg"
512fi  # end of if [[ -n $Farg ]]
513
514
515###########################################################
516# If the request is to rename the file system (-W option),
517# invoke the mmmvfs script.
518###########################################################
519if [[ -n $Wflag ]]
520then
521  $mmmvfs $device $Wflag $Warg
522  cleanupAndExit $?
523fi
524
525
526#####################################################################
527# Set up trap exception handling and call the gpfsInit function.
528# It will ensure that the local copy of the mmsdrfs and the rest of
529# the GPFS system files are up-to-date and will obtain the sdr lock.
530#####################################################################
531trap pretrap HUP INT QUIT KILL
532gpfsInitOutput=$(gpfsInit $lockId)
533setGlobalVar $? $gpfsInitOutput
534
535
536###########################################################
537# Make sure the specified file system exists and is local.
538###########################################################
539findFSoutput=$(findFS "$device" $mmsdrfsFile)
540[[ -z $findFSoutput ]] && cleanupAndExit
541
542# Parse the output from the findFS function.
543set -f ; set -- $findFSoutput ; set +f
544fqDeviceName=$1
545deviceName=$2
546fsHomeCluster=$3
547
548# Exit with a message if the command was invoked for a remote file system.
549if [[ $fsHomeCluster != $HOME_CLUSTER ]]
550then
551  # Command is not allowed for remote file systems.
552  printErrorMsg 106 $mmcmd $device $fsHomeCluster
553  cleanupAndExit
554fi
555
556
557###############################################################################
558# Go through the mmsdrfs file.  If changing parameters that are kept in the file,
559# create a new version of the file.  It will have a new generation number and
560# the appropriate parameters in the SG_ETCFS and/or SG_MOUNT lines will be
561# set to their new values.  Simultaneously, create a file with the names of
562# the nodes that belong to the cluster.  This file will be used later for
563# propagating the changes to the individual nodes and for finding a node
564# on which to execute the tschfs command if needed.
565###############################################################################
566$rm -f $newsdrfs $nodefile $allQuorumNodes
567existingMountPoints=""
568IFS=":"         # Change the field separator to ':'.
569exec 3<&-
570exec 3< $mmsdrfsFile
571while read -u3 sdrfsLine
572do
573  # Parse the line.
574  set -f ; set -A v -- - $sdrfsLine ; set +f
575
576  IFS="$IFS_sv"  # Restore the default IFS settings.
577
578  # Change some of the fields depending on the type of line.
579  case ${v[$LINE_TYPE_Field]} in
580
581    $VERSION_LINE )  # This is the global header line.
582       # Increment the generation number.
583       newGenNumber=${v[$SDRFS_GENNUM_Field]}+1
584       v[$SDRFS_GENNUM_Field]=$newGenNumber
585
586       ourClusterName=${v[$CLUSTER_NAME_Field]}
587       ;;
588
589    $NODESET_HDR )  # This is the header line for some cluster.
590       # If this is our cluster, save the release level information.
591       if [[ ${v[$NODESETID_Field]} = $fsHomeCluster ]]
592       then
593         lowestVersion=${v[$MIN_DAEMON_VERSION_Field]}
594         highestVersion=${v[$MAX_DAEMON_VERSION_Field]}
595       fi
596       ;;
597
598    $MEMBER_NODE )  # This line describes a node.
599       # Add the reliable node name to nodefile.
600       print -- "${v[$REL_HOSTNAME_Field]}" >> $nodefile
601       checkForErrors "writing to file $nodefile" $?
602
603       # Create a list of the quorum nodes.
604       if [[ ${v[$CORE_QUORUM_Field]} = $quorumNode ]]
605       then
606         print -- "${v[$REL_HOSTNAME_Field]}" >> $allQuorumNodes
607         checkForErrors "writing to file $allQuorumNodes" $?
608       fi
609
610       # If this is the line for the node that is executing
611       # this command, set the preferredNode variable.
612       [[ ${v[$NODE_NUMBER_Field]} = $ourNodeNumber ]] &&  \
613         preferredNode=${v[$REL_HOSTNAME_Field]}
614       ;;
615
616    $SG_ETCFS )  # This is an /etc/filesystem line.
617       # The processing of the SG_ETCFS lines will depend
618       # on the options that were specified on the mmchfs command.
619
620       if [[ -n $Targ && ${v[$LINE_NUMBER_Field]} = $MOUNT_POINT_Line ]]
621       then
622         # We are changing the mount point and this
623         # is a mount point line for some file system.
624         # If this is the mount point for our file system,
625         # set it to the new value.  Otherwise, add it to
626         # the list of existing mount points.
627         if [[ ${v[$DEV_NAME_Field]} = $deviceName ]]
628         then
629           oldMountPoint=${v[$ETCFS_TEXT_Field]}
630           v[$ETCFS_TEXT_Field]=$Targ
631           fsMustNotBeMounted=yes
632           [[ $mountCheckScope != $CHECK_ALL ]] &&  \
633              mountCheckScope=$ourClusterName
634         else
635           existingMountPoints="$existingMountPoints ${v[$ETCFS_TEXT_Field]}"
636         fi
637       fi  # end if [[ -n $Targ && ${v[$LINE_NUMBER_Field]} = $MOUNT_POINT_Line ]]
638
639       if [[ -n $Aarg && ${v[$LINE_NUMBER_Field]} = $MOUNT_Line ]]
640       then
641         # We are changing the automount option and
642         # this is a mount line for some file system.
643
644         # See if any file system requires the system automounter.
645         [[ ${v[$ETCFS_TEXT_Field]}  = *automount* ]] &&  \
646           automountMounts=true
647
648         # If this is the mount line for our file system,
649         # set the new value for the mount option.
650         if [[ ${v[$DEV_NAME_Field]} = $deviceName ]]
651         then
652           # If switching to or from automount the file system must be unmounted.
653           if [[ $Aarg = automount || ${v[$ETCFS_TEXT_Field]} = *automount* ]]
654           then
655             fsMustNotBeMounted=yes
656             [[ $mountCheckScope != $CHECK_ALL ]] &&  \
657                mountCheckScope=$ourClusterName
658           fi
659
660           # Set the new value for the mount option.
661           v[$ETCFS_TEXT_Field]="$MOUNT_Line_Prefix$Aarg"
662         fi  # end of if [[ ${v[$DEV_NAME_Field]} = $deviceName ]]
663       fi  # end if [[ -n $Aarg && ${v[$LINE_NUMBER_Field]} = $MOUNT_Line ]]
664       ;;
665
666    $SG_MOUNT )  # This line describes stripe group mount options.
667
668       if [[ ${v[$DEV_NAME_Field]} = $deviceName ]]
669       then
670         # Change mount options for our file system.
671
672         [[ -n $Earg ]] && v[$MTIME_OPT_Field]=$Earg
673
674         if [[ -n $Qarg ]]
675         then
676           fsMustNotBeMounted=yes
677           mountCheckScope=$CHECK_ALL
678           if [[ $Qarg = DELETE ]]
679           then
680             v[$QUOTA_OPT_Field]=$QUOTA_DISACTIVATED
681           else
682             v[$QUOTA_OPT_Field]=$Qarg
683           fi
684         fi
685
686         [[ -n $Sarg ]] && v[$ATIME_OPT_Field]=$Sarg
687
688         if [[ -n $oarg ]]
689         then
690           if [[ $oarg = DELETE ]]
691           then
692             v[$OTHER_OPT_Field]=""
693           else
694             v[$OTHER_OPT_Field]=$oarg
695           fi
696         fi
697
698         [[ -n $sgRW_OPT_Value ]] && v[$RW_OPT_Field]=$sgRW_OPT_Value
699
700       fi  # end of if [[ ${v[$DEV_NAME_Field]} = $deviceName ]]
701       ;;
702
703    * )  # Pass all other lines without a change.
704       ;;
705  esac  # end Change some of the fields
706
707  # Build and write the line to the new mmsdrfs file.
708  print_newLine >> $newsdrfs
709  checkForErrors "writing to file $newsdrfs" $?
710
711  IFS=":"  # Change the separator back to ":" for the next iteration.
712
713done  # end while read -u3 sdrfsLine
714
715IFS="$IFS_sv"  # Restore the default IFS settings.
716
717
718# If the mount point was changed, make sure that the new mount point
719# is not already used by some other file system and that the file system
720# is not mounted anywhere.
721if [[ -n $Targ ]]
722then
723  for mpnt in $existingMountPoints
724  do
725    if [[ $mpnt = $Targ ]]
726    then
727      # There is already an existing filesystem using this mountpoint.
728      printErrorMsg 107 $mmcmd $Targ
729      cleanupAndExit
730    fi
731  done
732fi  # end if [[ -n $Targ ]]
733
734# If necessary, ensure that the file system is not mounted.
735if [[ -n $fsMustNotBeMounted ]]
736then
737  $mmcommon onactive $preferredNode $nodefile $NO_FILE_COPY  \
738     $fqDeviceName $mountCheckScope $NO_LINK $MOUNT_CHECK_ONLY 2>$errMsg
739  rc=$?
740  if [[ $rc -eq $MM_FsMounted ]]
741  then
742    # File system is still mounted (messages were issued by mmcommon).
743    cleanupAndExit $rc
744  elif [[ $rc -eq $MM_DaemonDown ]]
745  then
746    # GPFS is down on all nodes that we care about.
747    rc=0
748  elif [[ $rc -eq $MM_ConnectionReset ]]
749  then
750    # An internode connection was reset.
751    printErrorMsg 257 $mmcmd
752    cleanupAndExit $rc
753  elif [[ $rc -ne 0 ]]
754  then
755    # An unexpected error occurred during the mount check.
756    if [[ -s $errMsg ]]
757    then
758      # Show the error messages from the daemon.
759      $cat $errMsg 1>&2
760    else
761      # The mount check failed and there were no messages from the daemon.
762      printErrorMsg 171 $mmcmd "mount check for $fqDeviceName" $rc
763    fi
764    # The command was unable to determine whether the file system is mounted.
765    printErrorMsg 564 $mmcmd $fqDeviceName
766    cleanupAndExit $rc
767  fi  # end if [[ $rc -eq $MM_FsMounted ]]
768  $rm -f $errMsg
769fi  # end if [[ -n $fsMustNotBeMounted ]]
770
771# If this is the first automountable GPFS file system,
772# run the automount command on the nodes in the cluster.
773if [[ $Aarg = "automount" && -z $automountMounts ]]
774then
775  # Determine the value of the automountDir parameter.
776  automountDir=$(showCfgValue automountDir)
777  [[ -z $automountDir ]] && automountDir=$defaultAutomountDir
778
779  # Run the automount command on the nodes on which GPFS is active.
780  # On nodes that do not have GPFS running right now, this will be
781  # done by the mmchecksubsys processing when the daemon is started.
782  $mmcommon onactive $preferredNode $nodefile        \
783      $NO_FILE_COPY $NO_MOUNT_CHECK NULL $NO_LINK    \
784      tsdsh $mmremote startAutomounter $automountDir >$tmpfile 2>&1
785  rc=$?
786
787  # Ignore errors but show messages from the nodes, if any.
788  if [[ $rc -ne 0 && $rc -ne $MM_DaemonDown && -s $tmpfile ]]
789  then
790    $awk '                             \
791      # Skip the lines with rc values. \
792      $2 == "rc" { next }              \
793      # Print everything else.         \
794      { print $0 }                     \
795    ' $tmpfile
796  fi  # end of if [[ -s $tmpfile ]]
797fi  # end of if [[ $Aarg = "automount" && -z $automountMounts ]]
798
799# If changing the file system to the latest format version (-V),
800# verify that all nodes are running the same level of code.
801# if [[ -n $Vflag ]]
802# then
803#   VflagAllowed=no  # Assume the worst.
804#
805#   # First look at the current information in the mmsdrfs file.
806#   if [[ $lowestVersion -ne $highestVersion ]]
807#   then
808#     # -V requires all nodes to be at the same level.
809#     printErrorMsg 583 $mmcmd
810#     cleanupAndExit
811#   fi  # end if [[ $lowestVersion -ne $highestVersion ]]
812#
813#   # According to the mmsdrfs file, all nodes are at the same level.
814#   # Verify that this is indeed the case at least on the nodes
815#   # on which the GPFS daemon is currently running.
816#   getCodeRangeOutput=$($mmcommon onactive $preferredNode $nodefile  \
817#     $NO_FILE_COPY $NO_MOUNT_CHECK NULL $NO_LINK mmremote getCodeRange)
818#   rc=$?
819#   if [[ -z $getCodeRangeOutput || $rc -ne 0 ]]
820#   then
821#     # Something went wrong with the mmcommon call.
822#     [[ $rc -eq 0 ]] && rc=1
823#     if [[ -n $getCodeRangeOutput ]]
824#     then
825#       # If there was some output, assume it is an error message.
826#       # Filter out the standard output strings, if any.
827#       print -- "$getCodeRangeOutput" | $grep -v "getCodeRange:" 1>&2
828#     else
829#       # Otherwise, output the generic unexpected error message.
830#       printErrorMsg 171 "$mmcmd" "mmcommon onactive mmremote getCodeRange" $rc
831#     fi
832#
833#   else
834#     # The mmcommon call seems to have worked.  Parse the results.
835#     IFS=":"
836#     set -f ; set -- $getCodeRangeOutput ; set +f
837#     kword=$1
838#     rc=$2
839#     status=$3
840#     maxDaemonVersion=$4
841#     minDaemonVersion=$5
842#     IFS="$IFS_sv"
843#
844#     if [[ $kword = getCodeRange && $status = complete ]]
845#     then
846#       if [[ $minDaemonVersion = $maxDaemonVersion ]]
847#       then
848#         VflagAllowed=yes
849#       else
850#         # -V requires all nodes to be at the same level.
851#         printErrorMsg 583 $mmcmd
852#       fi
853#     else
854#       # Otherwise, output the generic unexpected error message.
855#       printErrorMsg 171 "$mmcmd" "mmcommon onactive mmremote getCodeRange" $rc
856#     fi  # end if [[ $kword = getCodeRange && $status = complete ]]
857#   fi  # end if [[ -z $getCodeRangeOutput || $rc -ne 0 ]]
858#
859#   # If we were not able to convince ourselves that it is OK
860#   # to procede with the -V call, give up.
861#   [[ $VflagAllowed = no ]] && cleanupAndExit
862#
863# fi  # end if [[ -n $Vflag ]]
864
865
866#######################################################
867# Change parameters that are kept in the mmsdrfs file.
868#######################################################
869if [[ -n $mmsdrfsParms ]]
870then
871  # Put the mmsdrfs file into the sdr.
872  trap "" HUP INT QUIT KILL
873  gpfsObjectInfo=$(commitChanges $fsHomeCluster $nsId  \
874                      $gpfsObjectInfo $newGenNumber $newsdrfs $primaryServer)
875  rc=$?
876  if [[ $rc -ne 0 ]]
877  then
878    # Cannot replace file in the sdr.
879    printErrorMsg 381 $mmcmd
880    cleanupAndExit
881  fi
882
883  # Unlock the sdr.
884  [[ $sdrLocked = yes ]] &&  \
885    freeLockOnServer $primaryServer $ourNodeNumber >/dev/null
886  sdrLocked=no
887  trap localPosttrap HUP INT QUIT KILL
888
889  # If necessary, tell the daemon to invalidate its currently-cached
890  # mount options.
891  if [[ -n $callResetEFOptions ]]
892  then
893    $mmcommon onactive $preferredNode $allQuorumNodes  \
894                       $NO_FILE_COPY $NO_MOUNT_CHECK NULL $NO_LINK  \
895                       tsctl resetEFOptions $fqDeviceName > $errMsg 2>&1
896    rc=$?
897    [[ $rc = $MM_DaemonDown ]] && rc=0
898    [[ $rc -ne 0 && -s $errMsg ]] && cat $errMsg 2>&1
899    $rm -f $errMsg
900  fi
901
902  # If the mount point changed, remove the old mount point.
903  [[ -n $oldMountPoint && $Targ != $oldMountPoint ]] &&  \
904    propagateOptions="rmdir$oldMountPoint"
905
906  # Make the changes visible to the affected nodes.  Note that when
907  # changing the mount point or mount options, there is a window during
908  # which different nodes may see different mount points and/or options.
909  propagateSdrfsFile async $nodefile $newsdrfs $newGenNumber $propagateOptions
910
911fi  # end if [[ -n $mmsdrfsParms ]]
912
913
914############################################################
915# If changes are requested that need to be handled by GPFS,
916# run the tschfs command on an active daemon.
917############################################################
918if [[ -n $tschfsParms && $tschfsParms != +( ) ]]
919then
920  $mmcommon onactive $preferredNode $nodefile  \
921                     $NO_FILE_COPY $NO_MOUNT_CHECK NULL $NO_LINK  \
922                     tschfs $fqDeviceName $tschfsParms
923  rc=$?
924  if [[ $rc -ne 0 ]]
925  then
926    if [[ -n $mmsdrfsParms ]]
927    then
928      # The tschfs step failed.  Some parameters changed.
929      printErrorMsg 318 $mmcmd tschfs "$mmsdrfsParms"
930    else
931      # The tschfs step failed.
932      printErrorMsg 104 $mmcmd tschfs
933    fi
934    cleanupAndExit
935  fi
936fi  # end of if [[ -n $tschfsParms && $tschfsParms != +( ) ]]
937
938
939###################################################
940# If installed, invoke the syncfsconfig user exit.
941###################################################
942if [[ -x $syncfsconfig && -n $mmsdrfsParms ]]
943then
944   print -- "$mmcmd:  Starting $syncfsconfig ..."
945   $syncfsconfig
946   print -- "$mmcmd$syncfsconfig finished."
947fi
948
949$mmTRACE_EXIT "rc=0"
950cleanupAndExit 0
951
Note: See TracBrowser for help on using the repository browser.