source: gpfs_3.1_ker2.6.20/lpp/mmfs/bin/mmremote @ 65

Last change on this file since 65 was 16, checked in by rock, 17 years ago
  • Property svn:executable set to *
File size: 79.5 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# @(#)29 1.290.1.9 src/avs/fs/mmfs/ts/admin/mmremote.sh, mmfs, avs_rgpfs24, rgpfs24s008a 11/25/06 00:29:43
17#######################################################################
18
19# Include global declarations and service routines.
20. /usr/lpp/mmfs/bin/mmglobfuncs
21. /usr/lpp/mmfs/bin/mmsdrfsdef
22. /usr/lpp/mmfs/bin/mmfsfuncs
23
24sourceFile="mmremote.sh"
25[[ -n $DEBUG || -n $DEBUGmmremote ]] && set -x
26$mmTRACE_ENTER "$*"
27
28# Local work files.  Names should be of the form:
29#   fn=${tmpDir}fn.${mmcmd}.$$
30
31LOCAL_FILES=" "
32
33
34# Local variables
35typeset -l kword_lc
36typeset -l arg3_lc
37rc=0
38
39
40# Local functions
41
42####################################################################
43#
44# Function:  Take a snapshot of the currently-running trace.
45#
46# Input:     $1 - action to perform
47#
48# Output:    None
49#
50# Returns:   0
51#
52####################################################################
53function traceSnapshot
54{
55  typeset sourceFile="mmremote.sh"
56  [[ -n $DEBUG || -n $DEBUGtraceSnapshot ]] && set -x
57  $mmTRACE_ENTER "$*"
58  typeset action=$1
59  typeset tracePid
60
61  if [[ -z $(print -- " off on offon log " | $fgrep " $action ") ]]
62  then
63    # Invalid value for flag
64    printErrorMsg 153 $mmcmd tsnap
65    return 1
66  fi
67
68  if [[ $action != off ]]
69  then
70    $mmfsadm showtrace >/dev/null
71    if [[ $? -eq 0 ]]
72    then
73      $mmfsadm trace all 9
74      $mmfsadm trace tm 2 thread 1 mutex 1 vnode 1 ksvfs 1 klockl 0
75      $mmfsadm trace io 3 pgalloc 1 mb 1 lock 2 dfs 2 fsck 3
76    fi
77  fi
78
79  tracePid=$($ps -eo "pid args" | $awk '/trace / && !/this process/ {print $1}')
80  if [[ ($action = off || $action = offon) && -n $tracePid ]]
81  then
82    $trcstop
83    $mv /var/adm/ras/trcfile  /var/adm/ras/trcfile.$(date +"%H.%M.%S")
84  fi
85
86  if [[ $action = offon || $action = on ]]
87  then
88    $trace -a -l -L 12000000 -T 4000000 -j 306,307,308,309  \
89       -o /var/adm/ras/trcfile >/dev/null 2>&1 &
90  fi
91
92  date=$(date +"%y%m%d")
93  $mkdir -p /log/$date 2>/dev/null
94
95  for trcname in $($ls /var/adm/ras | $grep trcfile.)
96  do
97    time=$(print -- $trcname | $awk -F. '{print $2}')
98    $cp -p /var/adm/ras/trcfile.$time  \
99        /log/$date/trcfile.$date.$time."$($hostname -s)"
100    $rm -f /var/adm/ras/trcfile.$time
101  done
102
103  return 0
104
105}  #------ end of function traceSnapshot -------------------
106
107
108###############################################################################
109#
110# Function:  Send the local mmsdrfs file to the node that is requesting it.
111#            Do this only if the client's generation number is smaller than
112#            the generation number of the mmsdrfs file on this node.
113#            If requested, get the lock.
114#
115# Input:     $1 - generation number of the sdr file on the client
116#            $2 - name of client requesting the file
117#            $3 - name to use on the client for the retrieved file
118#            $4 - lockId or nolock
119#
120# Output:    gpfsObject or 'fail'.
121#
122# Returns:   Zero if successful, non-zero otherwise.
123#
124###############################################################################
125function sendClusterSDRFiles  # <clientGenNumber> <client> <fileName> <lockId>
126{
127  typeset sourceFile="mmremote.sh"
128  [[ -n $DEBUG || -n $DEBUGsendClusterSDRFiles ]] && set -x
129  $mmTRACE_ENTER "$*"
130  typeset clientGenNumber=$1
131  typeset client=$2
132  typeset fileName=$3
133  typeset lockId=$4
134
135  typeset rc=0
136  typeset lockObtained=""
137  typeset lockResult gpfsObjectInfo serverGenNumber junk
138  typeset pid getObjectPort
139
140  # Get the lock if requested
141  if [[ $lockId != nolock ]]
142  then
143    lockResult=$(getLock $lockId)
144
145    # Look at the result from the lock request.
146    # If it is more than one word, we assume it is an error message.
147    set -f ; set -- $lockResult ; set +f
148    gpfsObjectInfo=$1
149    junk=$2
150    if [[ -z $gpfsObjectInfo || -n $junk ]]
151    then
152      # If unexpected output, give up
153      [[ -n $junk ]] &&  \
154        print -u2 "$lockResult"
155      return 1
156    fi
157    if [[ $lockResult = fail ]]
158    then
159      print -- "fail"
160      return 1
161    else
162      lockObtained=yes
163    fi
164  fi
165
166  # If we are here, either the caller did not need the lock or the lock
167  # was successfully obtained.  Make sure the caller has the latest data.
168
169  # Get the server's generation number.
170  gpfsObjectInfo=$(getGpfsObject)
171  rc=$?
172  IFS=':'
173  set -f ; set -- $gpfsObjectInfo ; set +f
174  IFS="$IFS_sv"
175  serverGenNumber=$2
176  if [[ $rc -ne 0 || -z $serverGenNumber ]]
177  then
178    # Unexpected value for the Gpfs object
179    [[ $rc -eq 0 ]] &&  \
180      printErrorMsg 286 sendClusterSDRFiles $gpfsObjectInfo
181    [[ $lockObtained = yes ]] &&  \
182      freeLock 0 > /dev/null
183    print -- "fail"
184    return 1
185  fi
186
187  # If the client's local generation number is smaller than
188  # the one we have here, copy our version to the client.
189  if [[ $clientGenNumber -lt $serverGenNumber ]]
190  then
191    $rcp $mmsdrfsFile ${client}:${fileName}
192    rc=$?
193  fi
194
195  # If everything is OK so far, return the Gpfs object.
196  if [[ $rc -eq 0 ]]
197  then
198    print -- "$gpfsObjectInfo"
199  else
200    [[ $lockObtained = yes ]] &&  \
201      freeLock 0 > /dev/null
202    print -- "fail"
203  fi
204  return $rc
205
206}  #------ end of function sendClusterSDRFiles ------------
207
208
209############################################################################
210#
211# Function:  Determine whether this node is new to GPFS and whether the
212#            GPFS code on this node can support clustering.  If it can,
213#            create a skeleton version of the sdrfs file that reflects
214#            the passed key attributes and a generation number of 1.
215#
216# Input:     cltype         - cluster and environment type (e.g., "lc/lc2")
217#            primaryServer  - primary server
218#            backupServer   - secondary server or _NOSECONDARY_
219#            localNodeData  - hostname, node number, etc. for the node
220#            rshPath        - remote shell command or _DEFAULT_
221#            rcpPath        - remote file copy command or _DEFAULT_
222#            clusterIdAndSt - cluster id and cluster subtype
223#
224# Output:    A colon-separated list of the following fields:
225#              keyword         - checkNewClusterNode
226#              status          - success, not_new, etc.
227#              adapter type    - e.g., eth0
228#              daemon version  - e.g., 800
229#              product version - e.g., 2.3.0.0
230#              OS name         - AIX or Linux
231#
232#            Note:  The adapter type and subsequent fields have meaningful
233#                   information only if status is "success".
234#
235# Returns:   zero if success, non-zero otherwise
236#
237############################################################################
238function checkNewClusterNode  # <cltype> <primaryServer> <backupServer>
239                              # <localNodeData> <rshPath> <rcpPath>
240                              # <clusterIdAndSt>
241{
242  typeset sourceFile="mmremote.sh"
243  [[ -n $DEBUG || -n $DEBUGcheckNewClusterNode ]] && set -x
244  $mmTRACE_ENTER "$*"
245  typeset cltype=$1
246  typeset primary=$2
247  typeset secondary=$3
248  typeset localNodeData=$4
249  typeset rshPath=$5
250  typeset rcpPath=$6
251  typeset clusterIdAndSt=$7
252
253  typeset clusterType environmentType result hostResult
254  typeset initialSystemFiles sdrfsLine nodeNumber ipa adminNodeName adminIpa
255  typeset clusterId clusterSubtype adapterType nodeStatus
256
257  typeset newGenNumber=1
258  typeset rc=0
259
260  initialSystemFiles="$mmsdrfsFile ${mmfsEnvLevel}$newGenNumber $mmfsNodeData"
261  [[ $secondary = "_NOSECONDARY_" ]] && secondary=""
262  [[ $rshPath = "_DEFAULT_" ]] && rshPath=""
263  [[ $rcpPath = "_DEFAULT_" ]] && rcpPath=""
264  export GPFS_rshPath="$rshPath"
265  export GPFS_rcpPath="$rcpPath"
266
267  # Check that no sdrfs file exists on this node;
268  # report "not new" if an sdrfs file already exists.
269  if [[ -f $mmsdrfsFile ]]
270  then
271    print -- "checkNewClusterNode:not_new:"
272    return 1
273  fi
274
275  # Parse the overloaded input parameters.
276  IFS='/'
277  set -f ; set -- $cltype ; set +f
278  IFS="$IFS_sv"
279  clusterType=$1
280  environmentType=$2
281  [[ -z $environmentType ]] && environmentType=$clusterType
282
283  IFS=':'
284  set -f ; set -- $clusterIdAndSt ; set +f
285  IFS="$IFS_sv"
286  clusterId=$1
287  clusterSubtype=$2
288  [[ -z $clusterSubtype ]] && clusterSubtype=$environmentType
289
290  # Check whether the prerequisite software for the specified
291  # cluster type is installed.
292  checkPrereqs $environmentType
293  if [[ $? -ne 0 ]]
294  then
295    print -- "checkNewClusterNode:not_supported:"
296    return 1
297  fi
298
299  # Create a skeleton sdrfs file on this node.
300  $mkdir -p $mmsdrfsDir
301  sdrfsLine="$GLOBAL_ID:$VERSION_LINE::$CURRENT_SDRFS_FORMAT:$CURRENT_SDRFS_VERSION"
302  sdrfsLine="$sdrfsLine:$newGenNumber::$clusterType:$primary:$secondary"
303  sdrfsLine="$sdrfsLine::$rshPath:$rcpPath:$clusterId:$clusterSubtype:"
304  print -- "$sdrfsLine" > $mmsdrfsFile
305
306  # Add threatening comment lines:  DO NOT MESS WITH THIS FILE!
307  sdrfsLine="$GLOBAL_ID:$COMMENT_LINE::1:"
308  print -- "$sdrfsLine" >> $mmsdrfsFile
309  sdrfsLine="$GLOBAL_ID:$COMMENT_LINE::2:$warningText"
310  print -- "$sdrfsLine" >> $mmsdrfsFile
311  sdrfsLine="$GLOBAL_ID:$COMMENT_LINE::3:"
312  print -- "$sdrfsLine" >> $mmsdrfsFile
313
314  # Add the local node information.
315  print -- "$localNodeData" >> $mmsdrfsFile
316  rc=$?
317  if [[ $rc -ne 0 ]]
318  then
319    printErrorMsg 171 "checkNewClusterNode" "writing to file $mmsdrfsFile" $rc
320    print -- "checkNewClusterNode:unexpected_error:"
321    $rm -f $initialSystemFiles
322    return 1
323  fi
324
325  # Create a file with the MEMBER_NODE line for this node.
326  # It will be used later to quickly determine the node's
327  # node number, reliable hostname, and other information.
328  print -- "$localNodeData" > $mmfsNodeData
329  rc=$?
330  if [[ $rc -ne 0 ]]
331  then
332    printErrorMsg 171 "checkNewClusterNode" "writing to file $mmfsNodeData" $rc
333    print -- "checkNewClusterNode:unexpected_error:"
334    $rm -f $initialSystemFiles
335    return 1
336  fi
337
338  # Remember the current level of the system files.
339  $touch ${mmfsEnvLevel}$newGenNumber
340
341  # Flush the important files to disk.
342  $mmsync $mmsdrfsFile $mmfsNodeData ${mmfsEnvLevel}$newGenNumber
343
344  # Retrieve needed information from the local node data.
345  IFS=':'
346  set -f ; set -A v -- - $localNodeData ; set +f
347  IFS="$IFS_sv"
348  nodeNumber=${v[$NODE_NUMBER_Field]}
349  ipa=${v[$IPA_Field]}
350  adapterType=${v[$ADAPTER_TYPE_Field]}
351  adminNodeName=${v[$REL_HOSTNAME_Field]}
352  daemonNodeName=${v[$DAEMON_NODENAME_Field]}
353
354  if [[ -z $adapterType ]]
355  then
356    # Get the node's adapter information.
357    $ifconfig -a > $adfile
358    rc=$?
359    if [[ $rc -ne 0 ]]
360    then
361      printErrorMsg 171 "checkNewClusterNode" "ifconfig -a" $rc
362      print -- "checkNewClusterNode:unexpected_error:"
363      $rm -f $initialSystemFiles
364      return 1
365    fi
366
367    # Find the adapter type for the primary GPFS network.
368    # The assumptions are that the ifconfig output is organized in stanzas.
369    # Each stanza begins with the adapter type starting in column 1.
370    # All other lines are indented by at least one space or tab character.
371    if [[ $osName = Linux ]]
372    then
373      adapterType=$($awk '                                     \
374        $0 !~ /^[   ]/      { adapterType = $1 }           \
375        / addr:'$ipa' /         { print adapterType ; exit }   \
376      ' $adfile)
377      rc=$?
378    elif [[ $osName = AIX ]]
379    then
380      adapterType=$($awk '                                     \
381        $0 !~ /^[   ]/      { adapterType = $1 }           \
382        /[  ]inet '$ipa' /  { print adapterType ; exit }   \
383      ' $adfile)
384      rc=$?
385      adapterType=${adapterType%:}
386    else
387      # Should never get here.
388      printErrorMsg 171 "checkNewClusterNode" "unsupported OS $osName" 1
389      print -- "checkNewClusterNode:unexpected_error:"
390      $rm -f $initialSystemFiles
391      return 1
392    fi
393    if [[ $rc -ne 0 ]]
394    then
395      printErrorMsg 171 "checkNewClusterNode" "awk" $rc
396      print -- "checkNewClusterNode:unexpected_error:"
397      $rm -f $initialSystemFiles
398      return 1
399    fi
400
401    # Verify that the adapter exists.
402    if [[ -z $adapterType ]]
403    then
404      # Print error type and return.
405      printErrorMsg 154 $mmcmd $ipa $adminNodeName
406      print -- "checkNewClusterNode:ipa_missing"
407      $rm -f $initialSystemFiles
408      return 1
409    fi
410
411    # If this is an IP alias, use the name of the main device.
412    adapterType=${adapterType%%:*}
413
414    # Add the new information to the local node data.
415    v[$ADAPTER_TYPE_Field]=$adapterType
416    localNodeData=$(print_newLine)
417    print -- "$localNodeData" > $mmfsNodeData
418    rc=$?
419    if [[ $rc -ne 0 ]]
420    then
421      printErrorMsg 171 "checkNewClusterNode" "writing to file $mmfsNodeData" $rc
422      print -- "checkNewClusterNode:unexpected_error:"
423      $rm -f $initialSystemFiles
424      return 1
425    fi
426  fi  # end of if [[ -z $adapterType ]]
427
428
429  # Check that the admin interface name is valid
430  # if it is different than the one we just checked.
431  if [[ $adminNodeName != $daemonNodeName ]]
432  then
433    # Determine the IP address for the specified admin node name.
434    hostResult=$($host $adminNodeName)
435    set -f ; set -- $hostResult ; set +f
436    adminIpa=${3%%,*}
437
438    # Check that the admin node name has a valid IP address.
439    if [[ -z $adminIpa ]]
440    then
441      # An invalid node name was specified.
442      printErrorMsg 54 $mmcmd $adminNodeName
443      $rm -f $initialSystemFiles
444      return 1
445    fi
446
447    # Find the adapter type for the admin network.
448    # The assumptions are that the ifconfig output is organized in stanzas.
449    # Each stanza begins with the adapter type starting in column 1.
450    # All other lines are indented by at least one space or tab character.
451    if [[ $osName = Linux ]]
452    then
453      adapterType=$($awk '                                          \
454        $0 !~ /^[   ]/           { adapterType = $1 }           \
455        / addr:'$adminIpa' /         { print adapterType ; exit }   \
456      ' $adfile)
457      rc=$?
458    elif [[ $osName = AIX ]]
459    then
460      adapterType=$($awk '                                          \
461        $0 !~ /^[   ]/           { adapterType = $1 }           \
462        /[  ]inet '$adminIpa' /  { print adapterType ; exit }   \
463      ' $adfile)
464      rc=$?
465      adapterType=${adapterType%:}
466    else
467      # Should never get here.
468      printErrorMsg 171 "checkNewClusterNode" "unsupported OS $osName" 1
469      print -- "checkNewClusterNode:unexpected_error:"
470      $rm -f $initialSystemFiles
471      return 1
472    fi
473
474    if [[ $rc -ne 0 ]]
475    then
476      printErrorMsg 171 "checkNewClusterNode" "awk" $rc
477      print -- "checkNewClusterNode:unexpected_error:"
478      $rm -f $initialSystemFiles
479      return 1
480    fi
481
482    # Verify that the adapter exists.
483    if [[ -z $adapterType ]]
484    then
485      # Print error type and return.
486      printErrorMsg 154 $mmcmd $adminIpa $adminNodeName
487      print -- "checkNewClusterNode:ipa_missing"
488      $rm -f $initialSystemFiles
489      return 1
490    fi
491
492    # If this is an IP alias, use the name of the main device.
493    adapterType=${adapterType%%:*}
494
495  fi  # end of if [[ $adminNodeName != $daemonNodeName ]]
496
497  # Report success and return to caller.
498  result="checkNewClusterNode:success:$adapterType:$currentDaemonVersion"
499  result="$result:$productVersion:$osName:"
500  print -- "$result"
501  return 0
502
503}  #------ end of function checkNewClusterNode --------------
504
505
506############################################################################
507#
508# Function:  Verify that the specified adapter exists.
509#
510# Input:     IP address of the adapter to check
511#
512# Output:    The word "success" or a keyword representing the type
513#            of failure: "unexpected_error", "ipa_missing", etc.
514#
515# Returns:   zero if success, non-zero otherwise
516#
517############################################################################
518function checkAdapter  # <ipa>
519{
520  typeset sourceFile="mmremote.sh"
521  [[ -n $DEBUG || -n $DEBUGcheckAdapter ]] && set -x
522  $mmTRACE_ENTER "$*"
523  typeset ipa=$1
524
525  typeset adapterType=""
526  typeset rc=0
527
528  # Get the node's adapter information.
529  $ifconfig -a > $adfile
530  rc=$?
531  if [[ $rc -ne 0 ]]
532  then
533    printErrorMsg 171 "checkAdapter" "ifconfig -a" $rc
534    print -- "unexpected_error"
535    return 1
536  fi
537
538  # Find the adapter type from the ifconfig output.
539  # The assumptions are that the output is organized in stanzas.
540  # Each stanza begins with the adapter type starting in column 1.
541  # All other lines are indented by at least one space or tab character.
542  if [[ $osName = Linux ]]
543  then
544    adapterType=$($awk '                                      \
545      $0 !~ /^[   ]/      { adapterType = $1 }          \
546      / addr:'$ipa' /           { print adapterType ; exit }  \
547    ' $adfile)
548    rc=$?
549  elif [[ $osName = AIX ]]
550  then
551    adapterType=$($awk '                                      \
552      $0 !~ /^[   ]/      { adapterType = $1 }          \
553      /[  ]inet '$ipa' /  { print adapterType ; exit }  \
554    ' $adfile)
555    rc=$?
556    adapterType=${adapterType%:}
557  else
558    # Should never get here.
559    printErrorMsg 171 "checkAdapter" "unsupported OS $osName" 1
560    print -- "unexpected_error"
561    return 1
562  fi
563  if [[ $rc -ne 0 ]]
564  then
565    printErrorMsg 171 "checkAdapter" "awk" $rc
566    print -- "unexpected_error"
567    return 1
568  fi
569
570  # Verify that the adapter exists.
571  if [[ -z $adapterType ]]
572  then
573    # Print error type and return.
574    print -- "ipa_missing"
575    return 1
576  fi
577
578  # Report success and return to caller.
579  print -- "success"
580  return 0
581
582}  #------ end of function checkAdapter ---------------------
583
584
585################################################################
586#
587# Function:  Run an administration command.
588#
589# Input:     Command name and arguments
590#
591# Output:    Depends on the command
592#
593# Returns:   127  Command not supported
594#            Return code from the command
595#
596################################################################
597function runCommand  #  <adminCommand> [<arguments>]
598{
599  typeset sourceFile="mmremote.sh"
600  [[ -n $DEBUG || -n $DEBUGrunCommand ]] && set -x
601  $mmTRACE_ENTER "$*"
602  typeset adminCmd=${1##*/} # get the basename part of <adminCommand>
603  typeset arguments="$2"
604
605  typeset rc=0
606
607
608  # Verify the command belongs to the set of allowed commands.
609  case $adminCmd in
610
611    "cat"           ) adminCmd=$cat                 ;;
612    "head"          ) adminCmd=$head                ;;
613    "lspv"          ) adminCmd=$lspv                ;;
614    "lssrc"         ) adminCmd=$lssrc               ;;
615    "lsvsd"         ) adminCmd=$lsvsd               ;;
616    "mmfsadm"       ) adminCmd=$mmfsadm             ;;
617    "mmtrace"       ) adminCmd=$mmtrace             ;;
618    "mount"         ) adminCmd=$mount               ;;
619    "removevsd"     ) adminCmd="$removevsd -f -v "  ;;
620    "touch"         ) adminCmd=$touch               ;;
621    "tsaddrmap"     ) adminCmd=$tsaddrmap           ;;
622    "tsctl"         ) adminCmd=$tsctl               ;;
623    "tspreparedisk" ) adminCmd=$tspreparedisk       ;;
624    "umount"        ) adminCmd=$umount              ;;
625    "unmount"       ) adminCmd=$unmount             ;;
626     *              ) return 127                    ;; # invalid command
627  esac
628
629  # Run the command and propagate back the return code.
630  $adminCmd $arguments
631  rc=$?
632
633  [[ $adminCmd = ts* || $adminCmd = mm* ]] &&  \
634    rc=$(remapRC $?)
635
636  return $rc
637
638}  #------ end of function runCommand -------------------
639
640
641##############################################################################
642#
643# Function:  Determine the state of the GPFS daemon and other node info.
644#
645# Input:     $1 - (optional) Extended output (-L option)
646#
647# Output:
648#   mmGetState:nsId:nodeNum:name:tsQuorum:up:total:state:quorumDesignation:
649#
650# Returns:   Zero if successful, non-zero otherwise.
651#
652##############################################################################
653function mmGetState  #  [-L]
654{
655  typeset sourceFile="mmremote.sh"
656  [[ -n $DEBUG || -n $DEBUGmmGetState ]] && set -x
657  $mmTRACE_ENTER "$*"
658  typeset extendedOutput=$1
659
660  typeset tsctlOutput=""
661  typeset rc tsQuorum nodesUp totalNodes daemonState quorumDesignation result
662  typeset gpfsInitOutput
663
664
665  if [[ -n $extendedOutput ]]
666  then
667    # Extended output is requested.
668    # Make sure that the local copies of the mmsdrfs, mmfs.cfg,
669    # and the rest of the system files are up to date.
670    gpfsInitOutput=$(gpfsInit nolock)
671    setGlobalVar $? $gpfsInitOutput
672
673    # Determine the total nodes value and whether or not this is a quorum node.
674    totalAndType=$($awk -F: '                                \
675      BEGIN {                                                \
676        { total = 0 }                                        \
677        { type = "" }                                        \
678      }                                                      \
679      /':$NODESET_HDR:'/ {                                   \
680        if ( $'$NODESETID_Field' == "'$nsId'" ) {            \
681          { total = $'$NODE_COUNT_Field' }                   \
682        }                                                    \
683      }                                                      \
684      /':$MEMBER_NODE:'/ {                                   \
685        if ( $'$REL_HOSTNAME_Field' == "'$ourNodeName'" ) {  \
686          { type = $'$CORE_QUORUM_Field' }                   \
687          { exit }                                           \
688        }                                                    \
689      }                                                      \
690      END { print total ":" type }                           \
691    ' $mmsdrfsFile)
692    checkForErrors awk $?
693
694    IFS=':'
695    set -f ; set -- $totalAndType ; set +f
696    totalNodes=$1
697    quorumDesignation=$2
698    IFS="$IFS_sv"
699
700  else
701    # Regular output is requested.  Return fake values
702    # for quorum designation and total nodes.
703    totalNodes=0
704    quorumDesignation=unknown
705  fi  # end of if [[ -n $extendedOutput ]]
706
707
708  # Determine the quorum state of the daemon.
709  tsctlOutput=$(LC_ALL=C $tsctl quorumState 2>$errMsg)
710  rc=$(remapRC $?)
711
712  # Interpret the results from the tsctl command.
713  if [[ -z $tsctlOutput ]]
714  then
715    # The command failed.  Filter out "Failed to connect" messages.
716    # Show any other error messages that might be there.
717    $grep -v -e "6027-665" -e "Failed to connect to file system daemon" $errMsg >$errMsg2
718    [[ -s $errMsg2 ]] && $cat $errMsg2 1>&2
719
720    # Provide default values to be returned to the caller.
721    tsQuorum=0
722    nodesUp=0
723
724    if [[ $rc -eq $MM_DaemonDown ]]
725    then
726      daemonState="down"
727    else
728      daemonState="unknown"
729    fi
730
731  else
732    # The tsctl command seemed to work.  Parse the output.
733    # We intentionally override the totalNodes value found prior to
734    # the tsctl call because the daemon value may include remote nodes
735    # not reflected in the value we obtained from the sdrfs file.
736    IFS=':'
737    set -f ; set -- $tsctlOutput ; set +f
738    tsQuorum=$1
739    nodesUp=$2
740    totalNodes=$3
741    daemonState=$4
742    IFS="$IFS_sv"
743
744    # Remap the daemon status strings.
745    case $daemonState in
746      "Initial" )  daemonState="arbitrating" ;;
747      "Active"  )  daemonState="active" ;;
748      *         )  : ;;                      # Unknown string; leave it as is.
749    esac
750  fi  # end of if [[ -z $tsctlOutput ]]
751
752  # Build and print the result string.
753  result="mmGetState:$nsId:$ourNodeNumber:$ourShortName:$tsQuorum"
754  result="${result}:$nodesUp:$totalNodes:$daemonState:$quorumDesignation:"
755  print -- "$result"
756
757  return 0
758
759}  #------ end of function mmGetState -------------------
760
761
762###################################################################
763#
764# Function:  Determine the state of the specified subsystem.
765#
766# Input:     $1 - subsystem name
767#
768# Output:    mmgetSubsysState:<nodeName>:<subsystemState>:
769#
770# Returns:   Always zero.
771#
772###################################################################
773function getSubsysState  # <subsystem>
774{
775  typeset sourceFile="mmremote.sh"
776  [[ -n $DEBUG || -n $DEBUGgetSubsysState ]] && set -x
777  $mmTRACE_ENTER "$*"
778  typeset subsys=$1
779
780  typeset subsysState=""
781
782  # Determine whether the subsystem is active.
783  if [[ $subsys = rvsd ]]
784  then
785    subsysState=$(LC_ALL=C $lssrc -ls  $subsys | $grep 'active=1, state=idle' 2>/dev/null)
786    [[ -n $subsysState ]] && subsysState=active
787
788  elif [[ $subsys = mmfs ]]
789  then
790    $ps -e | $grep -w mmfsd >/dev/null 2>&1
791    rc=$?
792    if [[ $rc -eq 0 ]]
793    then
794      print -- "active"
795    else
796      print -- "inactive"
797    fi
798
799  else
800    subsysState=$(LC_ALL=C $lssrc -s $subsys |  \
801      $awk '
802        BEGIN { state = "inactive" }
803        $1 == "'$subsys'"  { if ( $NF == "active" ) { state = "active" } }
804        END { print state }
805      ')
806  fi  # end if [[ $subsys = rvsd ]]
807
808  [[ -z $subsysState ]] && subsysState=down
809
810  # Build and print the result string.
811  result="mmgetSubsysState:$ourNodeName:$subsysState:"
812  print -- "$result"
813
814  return 0
815
816}  #------ end of function getSubsysState -------------------
817
818
819###########################################################################
820#
821# Function:  Verifies that the RVSD subsystem is active on all nodes
822#            on which the GPFS daemon is running and then sets the
823#            wait4RVSD parameter to yes.
824#
825# Input:     none
826#
827# Output:    none
828#
829# Returns:   0 - RVSD operational on all nodes
830#            1 - Error detected, or RVSD inactive on one or more nodes
831#
832###########################################################################
833function setWait4RVSD  #
834{
835  typeset sourceFile="mmremote.sh"
836  [[ -n $DEBUG || -n $DEBUGsetWait4RVSD ]] && set -x
837  $mmTRACE_ENTER "$*"
838
839  typeset subsysStateLine kword nodeName rvsdState failedNodes junk
840  typeset errorFound=""
841  typeset rc=0
842
843  ##################################################################
844  # Use tsdsh to find the state of RVSD on all active GPFS nodes.
845  ##################################################################
846  $tsdsh $mmremote getSubsysState rvsd >$tmpfile 2>&1
847  rc=$(remapRC $?)
848
849  if [[ ! -s $tmpfile ]]
850  then
851    # If there is no output at all, something is very wrong.
852    [[ $rc -eq 0 ]] && rc=1
853    checkForErrors "setWait4RVSD" $rc
854  else
855    # If we have output, ignore the rc from tsdsh.
856    rc=0
857  fi
858
859  # Parse the output from the RVSD active test.
860  $rm -f $errMsg
861  exec 3<&-
862  exec 3< $tmpfile
863  while read -u3 subsysStateLine
864  do
865    IFS=':'
866    set -f ; set -- $subsysStateLine ; set +f
867    IFS="$IFS_sv"
868    junk=$1
869    kword=$2
870    nodeName=$3
871    rvsdState=$4
872
873    if [[ $kword = ?( )mmgetSubsysState ]]
874    then
875      [[ $rvsdState != active ]] &&  \
876        failedNodes="$failedNodes\n\t$nodeName"
877    elif [[ -n $subsysStateLine ]]
878    then
879      # Unexpected output - must be an error.
880      # Collect the lines in a separate file for later.
881      print -- "$subsysStateLine" >> $errMsg
882      checkForErrors "writing to file $errMsg" $?
883    else
884      :  # do nothing
885    fi  # end of if [[ $kword = mmgetSubsysState ]]
886  done  # end of while read -u3 subsysStateLine
887
888  if [[ -n $failedNodes ]]
889  then
890    # RVSD is not yet ready on at least one node.
891    printErrorMsg 474 $mmcmd RVSD "$failedNodes"
892    rc=1
893  fi
894
895  if [[ -s $errMsg ]]
896  then
897    # Show the unexpected errors.
898    $cat $errMsg  1>&2
899    rc=1
900  fi
901  $rm -f $errMsg
902
903  # If things look OK so far, change the value of the wait4RVSD parameter.
904  if [[ $rc -eq 0 ]]
905  then
906    $tsctl setCfgValue wait4RVSD yes
907    rc=$(remapRC $?)
908    if [[ $rc -ne 0 ]]
909    then
910      # The tsctl command failed.
911      printErrorMsg 104 "$mmcmd" "tsctl setCfgValue wait4RVSD yes"
912    fi
913  fi
914
915  return $rc
916
917}  #------ end of function setWait4RVSD ------------------
918
919
920###########################################################################
921#
922# Function:  Determines the range of GPFS release levels on the
923#            nodes on which the daemon is currently running.
924#
925# Input:     None
926#
927# Output:    A string with the following format:
928#            getCodeRange:rc:status:maxDaemonVers:minDaemonVers
929#
930# Returns:   0 - Success
931#            1 - Error detected
932#
933###########################################################################
934function getCodeRange  # <nodefile> <sdrfsFile> <failedNodes>
935{
936  typeset sourceFile="mmremote.sh"
937  [[ -n $DEBUG || -n $getCodeRange ]] && set -x
938  $mmTRACE_ENTER "$*"
939
940  typeset mmVersion2output nodeName nodeNumber kword cmdVersion
941  typeset installedDaemonVersion installedProductVersion installedOsName
942  typeset maxDaemonVersion=0
943  typeset minDaemonVersion=100000
944  typeset rc=0
945
946  # Request the release level information for all of the nodes.
947  $tsdsh $mmremote mmVersion2 >$tmpfile 2>&1
948  rc=$(remapRC $?)
949
950  if [[ ! -s $tmpfile ]]
951  then
952    # If there is no output at all, something is very wrong.
953    [[ $rc -eq 0 ]] && rc=1
954    print -- "getCodeRange:$rc:unexpected_failure:0:0:"
955    printErrorMsg 171 $mmcmd "tsdsh mmremote mmVersion2" $rc
956    return $rc
957  else
958    # If we have output, ignore the rc from tsdsh.
959    rc=0
960  fi
961
962  # Parse the output from  mmremote mmVersion2.
963  $rm -f $errMsg
964  IFS=":"
965  exec 3<&-
966  exec 3< $tmpfile
967  while read -u3 mmVersion2output
968  do
969    IFS=':'
970    set -f ; set -- $mmVersion2output ; set +f
971    nodeName=$1
972    kword=$2
973    cmdVersion=$3
974    nodeNumber=$4
975    installedDaemonVersion=$5
976    installedProductVersion=$6
977    installedOsName=$7
978    IFS="$IFS_sv"
979
980    if [[ $kword != *( )mmVersion2 ]]
981    then
982      # Unexpected output; it must be an error.
983      # Collect the lines in a separate file for later.
984      print -- "$mmVersion2output" >> $errMsg
985      checkForErrors "writing to file $errMsg" $?
986      continue
987    fi
988
989    # Keep track of highest and lowest daemon versions found.
990    [[ $installedDaemonVersion -gt $maxDaemonVersion ]] &&  \
991      maxDaemonVersion=$installedDaemonVersion
992    [[ $installedDaemonVersion -lt $minDaemonVersion ]] &&  \
993      minDaemonVersion=$installedDaemonVersion
994
995    IFS=":"  # Change the separator back to ":" for the next iteration.
996  done  # end of while read -u3 mmVersion2output
997  IFS="$IFS_sv"
998
999  # Print out the results string and exit.
1000  if [[ $maxDaemonVersion -eq 0 ]]
1001  then
1002    # We did not get back any release level information.
1003    # The output must have been only error messages.
1004    [[ $rc -eq 0 ]] && rc=1
1005    $cat $errMsg  1>&2
1006    print -- "getCodeRange:$rc:unexpected_failure:0:0:"
1007  else
1008    # Everything looks good.
1009    rc=0
1010    print -- "getCodeRange:$rc:complete:$maxDaemonVersion:$minDaemonVersion:"
1011  fi
1012
1013  $rm -f $errMsg
1014  return $rc
1015
1016}  #------ end of function getCodeRange ------------------
1017
1018
1019#####################################################################
1020#
1021# Function:  Ensure local system configuration files are up-to-date.
1022#
1023# Input:     $1   -f rebuild all files
1024#
1025# Output:    None
1026#
1027# Returns:   Zero if successful, non-zero otherwise.
1028#
1029#####################################################################
1030function refreshSysconfig  #  [-f]
1031{
1032  typeset sourceFile="mmremote.sh"
1033  [[ -n $DEBUG || -n $DEBUGrefreshSysconfig ]] && set -x
1034  $mmTRACE_ENTER "$*"
1035  typeset option=$1
1036
1037  typeset gpfsInitOutput
1038  typeset rc=0
1039
1040  # If the -f option was specified, force mmfsNodeData
1041  # and the rest of the GPFS files to be rebuilt.
1042  if [[ $option = "-f" ]]
1043  then
1044    $rm -f $mmfscfgFile $mmfsNodeData $nsdpvol ${mmfsEnvLevel}+([0-9])  \
1045           ${mmfsNewKeyLevel}+([0-9]) ${mmfsCommittedKeyLevel}+([0-9])
1046    getLocalNodeData
1047  fi
1048
1049  # Verify there is an mmfs entry in /etc/vfs.
1050  checkVfsNumber
1051  rc=$?
1052  [[ $rc -ne 0 ]] &&  \
1053    return $rc
1054
1055  # Make sure that the local copies of the mmsdrfs, mmfs.cfg,
1056  # and the rest of the system files are up-to-date.
1057  gpfsInitOutput=$(gpfsInit nolock)
1058  rc=$?
1059  [[ $rc -ne 0 ]] && printErrorMsg 171 "$mmcmd" "gpfsInit" $rc
1060  setGlobalVar $rc $gpfsInitOutput
1061
1062  return $rc
1063
1064}  #------ end of function refreshSysconfig -------------------
1065
1066
1067###################################################################
1068#
1069# Function:  Tell the daemon to reread the authorized_keys list.
1070#
1071# Input:     None.
1072#
1073# Output:    None.
1074#
1075# Returns:   Zero if successful, non-zero otherwise.
1076#
1077###################################################################
1078function refreshAuth
1079{
1080  typeset sourceFile="mmremote.sh"
1081  [[ -n $DEBUG || -n $DEBUGrefreshAuth ]] && set -x
1082  $mmTRACE_ENTER "$*"
1083  typeset gpfsInitOutput=""
1084
1085  # Retrieve the latest mmsdrfs file and rebuild the environment.
1086  gpfsInitOutput=$(gpfsInit nolock)
1087  setGlobalVar $rc $gpfsInitOutput
1088
1089  # Tell the daemon to reread the authorized_keys list.
1090  $tsauth
1091
1092  return 0
1093
1094}  #------ end of function refreshAuth -------------------
1095
1096
1097###################################################################
1098#
1099# Function:  Determine the generation number of a sdrfs file.
1100#
1101# Input:     $1 - (optional) sdrfs file.  If not specified,
1102#                 /var/mmfs/gen/mmsdrfs is assumed.
1103#
1104# Output:    <genNumber>:<timeStamp>
1105#
1106# Returns:   Zero if successful, non-zero otherwise.
1107#
1108###################################################################
1109function getGenNumber
1110{
1111  typeset sourceFile="mmremote.sh"
1112  [[ -n $DEBUG || -n $DEBUGgetGenNumber ]] && set -x
1113  $mmTRACE_ENTER "$*"
1114  typeset sdrfs=$1
1115  typeset versionLine=""
1116
1117  # If file not specified, use /var/mmfs/gen/mmsdrfs.
1118  [[ -z $sdrfs ]] && sdrfs=$mmsdrfsFile
1119
1120  # Parse the version line of the mmsdrfs file.
1121  versionLine=$($head -1 $sdrfs)
1122  IFS=':'
1123  set -f ; set -A v -- - $versionLine ; set +f
1124  IFS="$IFS_sv"
1125
1126  # Perform a quick sanity check.
1127  [[ ${v[$LINE_TYPE_Field]} != $VERSION_LINE ]] &&  \
1128    corruptedSdrFileExit 137 "$versionLine"
1129
1130  # Make sure the time stamp field has a value.
1131  [[ -z ${v[$GENNUM_TSTAMP_Field]} ]] &&  \
1132    v[$GENNUM_TSTAMP_Field]=0
1133
1134  # Generate and display the result.
1135  print "${v[$SDRFS_GENNUM_Field]}:${v[$GENNUM_TSTAMP_Field]}:${v[$PRIMARY_SERVER_Field]}"
1136
1137  return 0
1138
1139}  #------ end of function getGenNumber -------------------
1140
1141
1142###################################################################
1143#
1144# Function:  Move and rename the specified file.
1145#            Verify its checksum.
1146#
1147# Input:     $1 - source file name
1148#            $2 - target file name
1149#            $3 - expected checksum
1150#            $4 - source host name
1151#
1152# Output:    None
1153#
1154# Returns:   Zero if successful, non-zero otherwise.
1155#
1156###################################################################
1157function mvSGDescFile  #  <source> <target> <checksum> <sourceNode>
1158{
1159  typeset sourceFile="mmremote.sh"
1160  [[ -n $DEBUG || -n $DEBUGmvSGDescFile ]] && set -x
1161  $mmTRACE_ENTER "$*"
1162  typeset source=$1
1163  typeset target=$2
1164  typeset checksum=$3
1165  typeset sourceNodeName=$4
1166
1167  typeset sumOutput newSum
1168  typeset rc=0
1169
1170  # Make sure the target directory exists.
1171  $mkdir -p ${target%/*}
1172
1173  # Retrieve the file.
1174  if [[ $sourceNodeName = $ourNodeName ]]
1175  then
1176    $cp $source $target
1177    rc=$?
1178  else
1179    $rcp ${sourceNodeName}:$source $target
1180    rc=$?
1181  fi
1182
1183  if [[ $rc -ne 0 ]]
1184  then
1185    print -- "mvSGDescFile:error:copyfile:"
1186    return 1
1187  fi
1188
1189  $mmsync $target
1190
1191  # Verify the checksum.
1192  sumOutput=$($sum $target)
1193  checkForErrors "sum $target" $?
1194  set -f ; set -- $sumOutput ; set +f
1195  newSum=$1
1196  if [[ $checksum -ne $newSum ]]
1197  then
1198    print -- "mvSGDescFile:error:checksum:"
1199    return 1
1200  fi
1201
1202  print -- "mvSGDescFile:success::"
1203  return 0
1204
1205}  #------ end of function mvSGDescFile -------------------
1206
1207
1208###################################################################
1209#
1210# Function:  Mount the specified file system(s).
1211#
1212# Input:     $1 - file system device name or all, all_local, or all_remote
1213#            $2 - mount point or DEFAULT
1214#            $3 - default mount options
1215#            $4 - new mount options or DEFAULT
1216#            $5 - do not remount indicator (optional)
1217#
1218# Output:    None
1219#
1220# Returns:    0 - mount command issued
1221#             non-zero - unexpected error
1222#
1223###################################################################
1224function mountFileSystems  #  <device> <mountPoint> <defaultOptions> <newOptions>
1225{
1226  typeset sourceFile="mmremote.sh"
1227  [[ -n $DEBUG || -n $DEBUGmountFileSystems ]] && set -x
1228  $mmTRACE_ENTER "$*"
1229  typeset deviceName=$1
1230  typeset mountPoint=$2
1231  typeset defaultOptions=$3
1232  typeset newOptions=$4
1233  typeset doNotRemount=$5
1234
1235  typeset nodeIndex=0
1236  typeset ourNodeIndex=0
1237  typeset fsNumber=0
1238  typeset n=0
1239  typeset rc=0
1240
1241  typeset gpfsInitOutput fsType fsName tsstatusOutput mountedFileSystems
1242  typeset mountDeviceList mountDeviceList_A mountDeviceList_B vfsType
1243  typeset nodeOptions mountAllRequested
1244
1245
1246  # Ensure the GPFS system data is up to date.
1247  # Note:  To avoid undesired side effects, tell gpfsInit to restrict mount
1248  #        point checking only to the file system(s) that we care about.
1249  export MOUNT_POINT_CHECK="$deviceName"
1250  gpfsInitOutput=$(gpfsInit nolock)
1251  setGlobalVar $? $gpfsInitOutput
1252  unset MOUNT_POINT_CHECK
1253
1254  # See if there are additional mount options to specify.
1255  if [[ $newOptions = DEFAULT ]]
1256  then
1257    newOptions=""
1258  else
1259    newOptions="-o $newOptions"
1260  fi
1261
1262  if [[ $deviceName = all || $deviceName = all_local || $deviceName = all_remote ]]
1263  then
1264    mountPoint=""
1265    mountAllRequested=yes
1266  fi
1267
1268  # Process the mount point parameter.  Its value will also determine
1269  # whether it will be necessary to explicitly specify on the mount command
1270  # the vfs type and options string or if it is OK to let the mount
1271  # command figure out those things on its own.
1272  [[ $mountPoint = DEFAULT ]] && mountPoint=""
1273  if [[ -n $mountPoint ]]
1274  then
1275    defaultOptions="-o $defaultOptions"
1276    if [[ $osName = AIX ]]
1277    then
1278      vfsType="-v mmfs"
1279    elif [[ $osName = Linux ]]
1280    then
1281      vfsType="-t gpfs"
1282    else
1283      # Should never get here.
1284      printErrorMsg 171 "mountFileSystems" "unsupported OS $osName" 1
1285      return 1
1286    fi  # end of if [[ $osName = AIX ]]
1287  else
1288    defaultOptions=""
1289  fi  # end of if [[ -n $mountPoint ]]
1290
1291  # Go through the local mmsdrfs file and create
1292  # a list of the file systems to be mounted.
1293  IFS=":"
1294  exec 3<&-
1295  exec 3< $mmsdrfsFile
1296  while read -u3 sdrfsLine
1297  do
1298    # Parse the line.
1299    set -f ; set -A v -- - $sdrfsLine ; set +f
1300    IFS="$IFS_sv"
1301
1302    # Change some of the fields depending on the type of line.
1303    case ${v[$LINE_TYPE_Field]} in
1304
1305      $MEMBER_NODE )
1306         # Determine the index of this node relative
1307         # to the rest of the nodes in the cluster.
1308         [[ ${v[$NODE_NUMBER_Field]} = $ourNodeNumber ]] &&  \
1309           ourNodeIndex=$nodeIndex
1310         (( nodeIndex += 1 ))
1311         ;;
1312
1313      $SG_HEADR )
1314         # See if we want to mount this file system.
1315         if [[ ${v[$DEV_NAME_Field]} = $deviceName || $deviceName = all     ||
1316               $deviceName = all_local  && ${v[$FS_TYPE_Field]} = $localfs  ||
1317               $deviceName = all_remote && ${v[$FS_TYPE_Field]} = $remotefs ]]
1318         then
1319           mountDeviceList="$mountDeviceList /dev/${v[$DEV_NAME_Field]}"
1320           (( fsNumber += 1 ))
1321         fi
1322         ;;
1323
1324      * )  # Not interested in any other lines.
1325         ;;
1326
1327    esac  # end of Change some of the fields
1328
1329    IFS=":"  # Change the separator back to ":" for the next iteration.
1330
1331  done  # end while read -u3 mmsdrfsFile
1332  IFS="$IFS_sv"
1333
1334  # Ensure the requested file systems were found.
1335  # This should always be the case at this point.
1336  if [[ $fsNumber -eq 0 ]]
1337  then
1338    if [[ $deviceName = all || $deviceName = all_local ]]
1339    then
1340      # No file systems found in the cluster.
1341      printErrorMsg 200 $mmcmd
1342    elif [[ $deviceName = all_remote ]]
1343    then
1344      # No remote file systems found in the cluster.
1345      printErrorMsg 193 $mmcmd
1346    else
1347      # The requested file system was not found.
1348      printErrorMsg 288 $mmcmd $deviceName
1349    fi
1350
1351    # Give up; nothing more to do.
1352    return $MM_FsNotFound
1353  fi  # end of if [[ $fsNumber -eq 0 ]]
1354
1355  # If more than one file system will be mounted, order the list
1356  # based on the index of the local node within the cluster.
1357  # This is done to avoid the simultaneous mounting of the same
1358  # file system from all of the nodes in the cluster.
1359  if [[ $fsNumber -gt 1 ]]
1360  then
1361    # Calculate our node's index in the file system list.
1362    (( ourNodeIndex = ourNodeIndex % fsNumber ))
1363
1364    # Break the list of file systems into two parts
1365    # based on the above calculated index.
1366    for fsName in $mountDeviceList
1367    do
1368      if [[ $n -ge $ourNodeIndex ]]
1369      then
1370        mountDeviceList_A="$mountDeviceList_A $fsName"
1371      else
1372        mountDeviceList_B="$mountDeviceList_B $fsName"
1373      fi
1374      (( n += 1 ))
1375    done  # end of for fsName in $mountDeviceList
1376
1377    # Combine the two parts of the mount list.
1378    mountDeviceList="$mountDeviceList_A $mountDeviceList_B"
1379  fi  # end of if [[ $fsNumber -gt 1 ]]
1380
1381  # Create a list of the currently mounted file systems on this node.
1382  if [[ $osName = AIX ]]
1383  then
1384    $mount >$tmpfile 2>/dev/null
1385    mountedFileSystems=$tmpfile
1386  elif [[ $osName = Linux ]]
1387  then
1388    mountedFileSystems=/proc/mounts
1389  else
1390    # Should never get here.
1391    printErrorMsg 171 "mountFileSystems" "unsupported OS $osName" 1
1392    return 1
1393  fi  # end of if [[ $osName = AIX ]]
1394
1395  # Ensure the local GPFS daemon is accepting commands.
1396  tsstatusOutput=$(LC_ALL=C $tsstatus -1 2>&1)
1397  print -- "$tsstatusOutput" | $grep -qe 'file system daemon is running' >/dev/null 2>&1
1398  if [[ $? -ne 0 ]]
1399  then
1400    # GPFS daemon is not ready for commands yet.
1401    printErrorMsg 110 $mmcmd
1402    return $MM_DaemonDown
1403  fi
1404
1405  # Mount the file systems.
1406  for fsName in $mountDeviceList
1407  do
1408    # See if this file system is already mounted.
1409    $grep -qw $fsName $mountedFileSystems > /dev/null 2>&1
1410    if [[ $? -eq 0 ]]
1411    then
1412      # The file system appears to be already mounted.  Verify that
1413      # everythig is OK by doing an internal remount if the stat on
1414      # mount point returns with a non-zero errno.
1415      activeMountPoint=$(findMountpoint $fsName)
1416      $perl -e ' $! = 0; stat "'$activeMountPoint'"; exit $!;'
1417      rc=$?
1418      if [[ $rc -ne 0 && -z $doNotRemount ]]
1419      then
1420        $tsremount ${fsName#/dev/}
1421        rc=$?
1422        if [[ $rc -ne 0 ]]
1423        then
1424          # The remount attempt failed.
1425          printErrorMsg 399 $mmcmd $fsName $rc
1426          [[ -n $mountAllRequested ]] && rc=0
1427        fi
1428      fi  # end of if [[ $rc -ne 0 && -z $doNotRemount ]]
1429
1430      # If a specific mount point has been requested, see if it matches
1431      # the currently active mount point for the file system.
1432      if [[ -n $mountPoint ]]
1433      then
1434        [[ $mountPoint != $activeMountPoint ]] &&  \
1435          printErrorMsg 280 $mmcmd $fsName $activeMountPoint
1436      fi
1437
1438      # There is nothing more to do for this file system.
1439      continue
1440    fi  # end of if [[ $? -eq 0 ]]
1441
1442    # See if there are local override mount options for this file system.
1443    if [[ -s ${localMountOptions}.${fsName#/dev/} ]]
1444    then
1445      nodeOptions="-o $($tail -n -1 ${localMountOptions}.${fsName#/dev/} 2>/dev/null)"
1446    else
1447      nodeOptions=""
1448    fi
1449
1450    # Mount the file system.  If the overall request is to mount a single
1451    # file system, show all messages from the mount command.  If the request
1452    # is to mount all GPFS file systems, hide the "already mounted" messages.
1453    if [[ -n $mountAllRequested ]]
1454    then
1455      $mount $vfsType $defaultOptions $nodeOptions $newOptions $fsName $mountPoint 2>&1 |  \
1456        $grep -i -v "already mounted"
1457      rc=0  # ignore errors
1458    else
1459      $mount $vfsType $defaultOptions $nodeOptions $newOptions $fsName $mountPoint
1460      rc=$?
1461    fi
1462  done  # end of for fsName in $mountDeviceList
1463
1464  return $rc
1465
1466}  #------ end of function mountFileSystems -------------------
1467
1468
1469###########################################################
1470#
1471#  Mainline processing
1472#
1473###########################################################
1474kword=$arg1
1475kword_lc=$arg1
1476arg3_lc=$arg3
1477
1478
1479if [[ -z $kword ]]
1480then
1481  # Missing keyword
1482  printErrorMsg 133 mmremote NULL
1483  cleanupAndExit
1484fi
1485
1486# Set up silent trap exception handling.
1487trap pretrap3 HUP INT QUIT KILL
1488
1489# Parse the caller's version information.  If missing,
1490# assume the request comes from a 3.1 compatible node.
1491[[ -z $mmrpc ]] && mmrpc="mmrpc:1:1:901:"
1492IFS=':'
1493set -f ; set -- $mmrpc ; set +f
1494rpcVersion=$2
1495rpcMinVersion=$3
1496daemonVersion=$4
1497IFS="$IFS_sv"
1498
1499# Determine the execution environment and set needed global variables.
1500if [[ $kword_lc = checknewclusternode ]]
1501then
1502  # The request is for a function that runs prior to the node becoming
1503  # a member of the GPFS cluster.  Use the function arguments to set
1504  # some global variables.
1505  if [[ -z $MMMODE ]]
1506  then
1507    IFS='/'
1508    set -f ; set -- $arg2 ; set +f
1509    export MMMODE=$1
1510    IFS="$IFS_sv"
1511  fi
1512  [[ -z $primaryServer ]] &&  \
1513    primaryServer=$arg3
1514elif [[ $arg3_lc = checknewclusternode* ||
1515        $arg3_lc = removefromclustercr  ]]
1516then
1517  # If the node is not yet a member of the GPFS cluster,
1518  # the functions to determine the local data do not work.
1519  [[ -z $ourNodeName ]] && ourNodeName=$($hostname)
1520  [[ -z $MMMODE ]] && export MMMODE=$arg4
1521else
1522  # In all other cases, file mmsdrfs should already exist
1523  # and we can use it as a starting point.
1524  [[ -z $MMMODE || -z $environmentType || -z $primaryServer ]] &&  \
1525    determineMode
1526  getLocalNodeData
1527fi
1528
1529# Restore the original positional parameters.
1530set -f ; set -- $cmdline ; set +f
1531
1532# Initialize the local version information string.
1533rpcMinSupported=1
1534rpcMaxSupported=1
1535localVersionInfo="$MM_Version3:$ourNodeNumber:$currentDaemonVersion:$productVersion"
1536localVersionInfo="${localVersionInfo}:$osName:$rpcMinSupported:$rpcMaxSupported"
1537
1538# Ensure we know how to interpret the request.
1539if [[ $rpcMinVersion -gt $rpcMaxSupported ]]
1540then
1541  # The caller is running incompatible GPFS version.
1542  # Tell him what our capabilities are and let him decide what to do.
1543  print -u2 "mmremote:incompatibleGPFScode:$ourNodeName:$localVersionInfo:"
1544  cleanupAndExit $MM_IncompatibleCode
1545fi
1546
1547# Make sure we have the proper credentials.
1548[[ $getCredCalled = no ]] && getCred
1549
1550# Reset the remote commands if necessary.
1551[[ -n $GPFS_rshPath ]] && rsh=$GPFS_rshPath
1552[[ -n $GPFS_rcpPath ]] && rcp=$GPFS_rcpPath
1553
1554# Depending on the keyword, perform the requested action.
1555case $kword_lc in
1556
1557                   #----------------------------------------
1558  mmversion )      # mmremote mmVersion  [<fileset>]
1559                   #----------------------------------------
1560    # Determine whether the daemon is running.
1561    tsstatusOutput=$(LC_ALL=C $tsstatus -1 2>&1)
1562    print -- "$tsstatusOutput" | $grep -e 'file system daemon is running' >/dev/null
1563    if [[ $? -eq 0 ]]
1564    then
1565      daemonStatus=active
1566    else
1567      print -- "$tsstatusOutput" | $grep -e 'Waiting for quorum' >/dev/null
1568      if [[ $? -eq 0 ]]
1569      then
1570        daemonStatus=waitingForQuorum
1571      else
1572        daemonStatus=down
1573      fi
1574    fi
1575
1576    # Get the level of the installed fileset.
1577    # If not specified by the caller, look for mmfs.gpfs.rte.
1578    if [[ -n $arg2 ]]
1579    then
1580      fileset=$arg2
1581    else
1582      fileset="mmfs.gpfs.rte"
1583    fi
1584
1585    # The output of the lslpp -c -Lq command has the following format:
1586    # #Package Name:Fileset:Level:State:PTF Id:Fix State:Type:Description:
1587    lslppOutput=$(LC_ALL=C $lslpp -c -Lq $fileset 2>/dev/null)
1588    IFS=':'
1589    set -f ; set -- $lslppOutput ; set +f
1590    package=$1
1591    fileset=$2
1592    level=$3
1593    IFS="$IFS_sv"
1594    [[ $package != mmfs* ]] && level=""
1595
1596    # Return the string 'mmVersion', the version of the commands (2), the level
1597    # of the currently-installed fileset, and the status of the daemon.
1598    print -- "mmVersion:$MM_Version3:$level:$daemonStatus"
1599    rc=0
1600    ;;
1601
1602                   #---------------------
1603  mmversion2 )     # mmremote mmVersion2
1604                   #---------------------
1605    # Return the keyword 'mmVersion2', the version of the commands (2),
1606    # the level of the currently-installed fileset (must match prod.h),
1607    # the OS name, and the fileset or rpm release string identifier for
1608    # the current level of the code.
1609    print -- "mmVersion2:$localVersionInfo"
1610    rc=0
1611    ;;
1612
1613                   #--------------------------------------------------
1614  unlock )         # mmremote unlock [<nodeNumber>] [<lockServer>]
1615                   #--------------------------------------------------
1616    # Find our node number.
1617    if [[ -z $arg2 ]]
1618    then
1619      nodeNumber=$ourNodeNumber
1620    else
1621      nodeNumber=$arg2
1622    fi
1623
1624    # Find the lock server.
1625    if [[ -z $arg3 ]]
1626    then
1627      lockServer=$primaryServer
1628    else
1629      lockServer=$arg3
1630    fi
1631
1632    # Release the lock.
1633    freeLock $nodeNumber $lockServer
1634    rc=0
1635    ;;
1636
1637                    #------------------------------------------------------
1638  copyremotefile )  # mmremote copyRemoteFile <remoteNode> <remoteFile>
1639                    #                               <localFile> <checksum>
1640                    #------------------------------------------------------
1641    if [[ $argc -lt 5 ]]
1642    then
1643      operands=" <remoteNode> <remoteFile> <localFile> <checksum>"
1644      printErrorMsg 260 mmremote $kword "$operands"
1645      cleanupAndExit
1646    fi
1647
1648    copyRemoteFileOutput=$(copyRemoteFile "$arg2" "$arg3" "$arg4" "$arg5")
1649    rc=$?
1650    print -- "$copyRemoteFileOutput"
1651    ;;
1652
1653                           #-------------------------------------------------
1654  committoprimaryserver )  # mmremote commitToPrimaryServer <newsdrfs> <sum>
1655                           #            <genNumber> <client> <primaryServer>
1656                           #            <commitOption> <backupServer>
1657                           #-------------------------------------------------
1658    if [[ $argc -lt 7 ]]
1659    then
1660      operands=" <newsdrfs> <checksum> <genNumber> <client> <primaryServer>"
1661      operands=$operands" <commitOption> <backupServer>"
1662      printErrorMsg 260 mmremote $kword "$operands"
1663      cleanupAndExit
1664    fi
1665
1666    # Check required system files.
1667    commitToPrimaryServer "$arg2" "$arg3" "$arg4" "$arg5" "$arg6" "$arg7" "$arg8"
1668    rc=$?
1669    ;;
1670
1671                          #----------------------------------------
1672                          # mmremote vfs
1673  vfs | checkvfsnumber )  # mmremote checkVfsNumber
1674                          #----------------------------------------
1675    # Verify there is an mmfs entry in /etc/vfs.
1676    checkVfsNumber
1677    rc=$?
1678    ;;
1679
1680                    #----------------------------------------
1681  fs )              # mmremote fs [optionalTasks]
1682                    #----------------------------------------
1683    # Verify there is an mmfs entry in /etc/vfs.
1684    checkVfsNumber
1685    rc=$?
1686    [[ $rc -ne 0 ]] && cleanupAndExit $rc
1687
1688    # Make sure that the local copies of the mmsdrfs, mmfs.cfg,
1689    # and the rest of the system files are up-to-date.
1690    gpfsInitOutput=$(gpfsInit nolock)
1691    checkForErrors gpfsInit $?
1692
1693    # Perform additional tasks as per the propagate options parameter.
1694    [[ -n $arg2 ]] && handlePropagateOptions $arg2
1695
1696    rc=0
1697    ;;
1698
1699                    #----------------------------------------
1700  cfg )             # mmremote cfg [-f]
1701                    #----------------------------------------
1702    # Ensure local config data is up-to-date.
1703    refreshSysconfig $arg2
1704    rc=$?
1705    ;;
1706
1707
1708                        #----------------------------------------------------
1709  upgradesystemfiles )  # mmremote upgradeSystemFiles <sdrfsFile> <checksum>
1710                        #                             [<optionalTasks>]
1711                        #----------------------------------------------------
1712    if [[ $argc -lt 3 ]]
1713    then
1714      operands="<sdrfsFile> <checksum> [<optionalTasks>]"
1715      printErrorMsg 260 mmremote $kword "$operands"
1716      cleanupAndExit
1717    fi
1718
1719    upgradeSystemFiles $arg2 $arg3 NULL 0
1720    rc=$?
1721
1722    # Perform additional tasks as per the propagate options parameter.
1723    [[ -n $arg4 ]] && handlePropagateOptions $arg4
1724    ;;
1725
1726
1727                        #----------------------------------------------------
1728  upgradesystemfiles2 ) # mmremote upgradeSystemFiles2 <sdrfsFile> <checksum>
1729                        #                              <keyFile> <checksum2>
1730                        #----------------------------------------------------
1731    if [[ $argc -lt 5 ]]
1732    then
1733      operands="<sdrfsFile> <checksum> <keyFile> <checksum2>"
1734      printErrorMsg 260 mmremote $kword "$operands"
1735      cleanupAndExit
1736    fi
1737
1738    upgradeSystemFiles $arg2 $arg3 $arg4 $arg5
1739    rc=$?
1740    ;;
1741
1742
1743                      #---------------------------------------------
1744  updategpfsobject )  # mmremote updateGpfsObject <chng1> [<chng2>]
1745                      #---------------------------------------------
1746    if [[ $argc -lt 2 ]]
1747    then
1748      operands="<change1> [<change2>] - Specify at least one change"
1749      printErrorMsg 260 mmremote $kword "$operands"
1750      cleanupAndExit
1751    fi
1752
1753    updateGpfsObject "$arg2" "$arg3"
1754    rc=$?
1755    ;;
1756
1757                           #----------------------------------------
1758  getgpfsobjectfromfile )  # mmremote getGpfsObjectFromFile
1759                           #----------------------------------------
1760
1761    # Retrieve the information.
1762    gpfsObjectInfo=$(getGpfsObjectFromFile)
1763    rc=$?
1764
1765    print -- "$gpfsObjectInfo"
1766    ;;
1767
1768                         #------------------------------------------------
1769  sendclustersdrfiles )  # mmremote sendClusterSDRFiles <clientGenNumber>
1770                         #    <client> <fileName> <lockId>
1771                         #------------------------------------------------
1772    if [[ $argc -lt 5 ]]
1773    then
1774      operands="<generationNumber> <client> <fileName> <lockId>"
1775      printErrorMsg 260 mmremote $kword "$operands"
1776      cleanupAndExit
1777    fi
1778
1779    sendClusterSDRFiles "$arg2" "$arg3" "$arg4" "$arg5"
1780    rc=$?
1781    ;;
1782
1783                  #-------------------------------------------------------------
1784  createshadow )  # mmremote createShadow <oldGenNumber> <newSum> <commitOption>
1785                  #-------------------------------------------------------------
1786    if [[ $argc -lt 4 ]]
1787    then
1788      operands="<oldGenNumber> <newSum> <commitOption>"
1789      printErrorMsg 260 mmremote $kword "$operands"
1790      cleanupAndExit
1791    fi
1792
1793    createShadow "$arg2" "$arg3" "$arg4"
1794    rc=$?
1795    ;;
1796
1797                       #--------------------------------------------------
1798  removeuncommitted )  # mmremote removeUncommitted <genNumber> <version>
1799                       #--------------------------------------------------
1800    if [[ $argc -lt 2 ]]
1801    then
1802      operands="<genNumber> <version>"
1803      printErrorMsg 260 mmremote $kword "$operands"
1804      cleanupAndExit
1805    fi
1806
1807    $rm -f $uncommitted.$arg3  ${mmsdrfsPrev}.$arg2
1808    rc=$?
1809    ;;
1810
1811                                              #----------------------------
1812  removefromcluster | removefromclustercr )   # mmremote removeFromCluster
1813                                              #----------------------------
1814    # Remove (almost) all traces.
1815    removeFromCluster
1816    rc=0
1817    ;;
1818
1819                   #-------------------------------------------
1820  rmfs )           # mmremote rmfs <fqDeviceName> <mountPoint>
1821                   #-------------------------------------------
1822    if [[ $argc -lt 2 ]]
1823    then
1824      operands="<fqDeviceName> <mountPoint>"
1825      printErrorMsg 260 mmremote $kword "$operands"
1826      cleanupAndExit
1827    fi
1828
1829    # Remove the file system stanza from /etc/filesystems.
1830    # Remove the device and mount point.  Ignore errors.
1831    removeStanza  $arg2 >/dev/null 2>&1
1832    removeMountPoint $arg2 $arg3 0 >/dev/null 2>&1
1833
1834    rc=0
1835    ;;
1836
1837                   #----------------------------------------
1838  pid )            # mmremote pid <pid>
1839                   #----------------------------------------
1840    if [[ $argc -lt 2 ]]
1841    then
1842      operands="<pid>"
1843      printErrorMsg 260 mmremote $kword "$operands"
1844      cleanupAndExit
1845    fi
1846
1847    # See if the specified process still exists.
1848    $ps "$arg2" >/dev/null 2>/dev/null
1849    rc=$?
1850    if [[ $rc -eq 0 ]]
1851    then
1852      print -- "alive"
1853    else
1854      print -- "died"
1855    fi
1856
1857    rc=0
1858    ;;
1859
1860                   #----------------------------------------
1861  active )         # mmremote active
1862                   #----------------------------------------
1863    $ps -e | $grep mmfsd >/dev/null 2>&1
1864    rc=$?
1865    if [[ $rc -eq 0 ]]
1866    then
1867      print -- "active"
1868    else
1869      print -- "down"
1870    fi
1871
1872    rc=0
1873    ;;
1874
1875                   #----------------------------------------
1876  quorum )         # mmremote quorum <quorumValue>
1877                   #----------------------------------------
1878    if [[ $argc -lt 2 ]]
1879    then
1880      operands="<quorumValue>"
1881      printErrorMsg 260 mmremote $kword "$operands"
1882      cleanupAndExit
1883    fi
1884
1885    # Set the node quorum to the specified value.
1886    $mmfsadm quorum $arg2
1887    rc=$?
1888    ;;
1889
1890                   #-----------------------------------------
1891  tschpool )       # mmremote tschpool <tschpool_arguments>
1892                   #-----------------------------------------
1893    if [[ $argc -lt 3 ]]
1894    then
1895      operands="<tschpool_arguments>"
1896      printErrorMsg 260 mmremote $kword "$operands"
1897      cleanupAndExit
1898    fi
1899
1900    # Collect the input parameters and invoke the command.
1901    shift 1
1902    commandArguments=$*
1903
1904    $tschpool $commandArguments
1905    rc=$(remapRC $?)
1906    ;;
1907
1908                   #----------------------------------------
1909  tsctl )          # mmremote tsctl <tsctl_arguments>
1910                   #----------------------------------------
1911    if [[ $argc -lt 3 ]]
1912    then
1913      operands="<tsctl_arguments>"
1914      printErrorMsg 260 mmremote $kword "$operands"
1915      cleanupAndExit
1916    fi
1917
1918    # Collect the input parameters and invoke the command.
1919    shift 1
1920    commandArguments=$*
1921
1922    $tsctl $commandArguments
1923    rc=$(remapRC $?)
1924    ;;
1925
1926                   #----------------------------------------
1927  tsnap )          # mmremote tsnap <action>
1928                   #----------------------------------------
1929    if [[ $argc -lt 2 ]]
1930    then
1931      operands="<action>"
1932      printErrorMsg 260 mmremote $kword "$operands"
1933      cleanupAndExit
1934    fi
1935
1936    # Take a trace snapshot.
1937    traceSnapshot $arg2
1938    rc=$?
1939    ;;
1940
1941                         #------------------------------------------------------
1942  checknewclusternode )  # mmremote checkNewClusterNode <clusterType> <primary>
1943                         #          <secondary | _NOSECONDARY_> <localNodeData>
1944                         #          <rshPath | _DEFAULT_> <rcpPath | _DEFAULT_>
1945                         #          <clusterId>
1946                         #------------------------------------------------------
1947    if [[ $argc -lt 8 ]]
1948    then
1949      operands="<clusterType> <primaryServer> <secondaryServer | _NOSECONDARY_> "
1950      operands=${operands}"<localNodeData> <rshPath | _DEFAULT_> <rcpPath | _DEFAULT_> "
1951      operands=${operands}"<clusterId> "
1952      printErrorMsg 260 mmremote $kword "$operands"
1953      cleanupAndExit
1954    fi
1955
1956    # Determine whether the node is new and supports clusters.
1957    checkNewClusterNode "$arg2" "$arg3" "$arg4" "$arg5" "$arg6" "$arg7" "$arg8"
1958    rc=$?
1959    ;;
1960
1961                   #-----------------------------
1962  checkadapter )   # mmremote checkAdapter <ipa>
1963                   #-----------------------------
1964    if [[ $argc -lt 2 ]]
1965    then
1966      operands="<ipa>"
1967      printErrorMsg 260 mmremote $kword "$operands"
1968      cleanupAndExit
1969    fi
1970
1971    # Verify the adapter exists.
1972    checkAdapter $arg2
1973    rc=0
1974    ;;
1975
1976                   #-----------------------------------------------
1977  admincmd )       # mmremote adminCmd <adminCommand> [<arg ... >]
1978                   #-----------------------------------------------
1979    if [[ $argc -lt 2 ]]
1980    then
1981      operands="<adminCommand> [<arg ... >]"
1982      printErrorMsg 260 mmremote $kword "$operands"
1983      cleanupAndExit
1984    fi
1985
1986    # Get the command name and collect its arguments.
1987    adminCommand=$2
1988    shift 2
1989    argList=$@
1990
1991    # Run the requested command.
1992    runCommand $adminCommand "$argList"
1993    rc=$?
1994    ;;
1995
1996                   #---------------------------------------
1997  exectsmcommand ) # mmremote execTSMcommand [<arg ... >]
1998                   #---------------------------------------
1999    if [[ $argc -lt 10 ]]
2000    then
2001      operands="<execTSMcommand> [<arg ... >]"
2002      printErrorMsg 260 mmremote $kword "$operands"
2003      cleanupAndExit
2004    fi
2005
2006    # Shift the command's arguments to remove the execTSMcommand verb.
2007    shift 1
2008    argList=$@
2009
2010    # Run the requested command.
2011    $mmexectsmcmd $argList
2012    rc=$?
2013    ;;
2014
2015                   #----------------------------------------------------
2016  startsubsys )    # mmremote startSubsys [-e <expTime>] [-E <envData>]
2017                   #            [-f] [-t <tracefile>] [-T <traceOpt>]
2018                   #----------------------------------------------------
2019    # Parse the optional parameters.
2020    shift 1
2021    while getopts :e:E:fT:t: OPT
2022    do
2023      case $OPT in
2024        e) expirationData="$OPTARG"  ;;
2025        E) envString=${envString}" $OPTARG " ;;
2026        f) argString='-a "-f"' ;;
2027        t) envString=${envString}" mmScriptTrace=$OPTARG " ;;
2028        T) envString=${envString}" MMTRACE=$OPTARG " ;;
2029        *) printErrorMsg 13 "$mmcmd" $OPTARG ;;
2030      esac
2031    done
2032
2033    # Process the expirationData parameter.
2034    if [[ -n $expirationData && ! -s mmSdrLockExp ]]
2035    then
2036      # Create a file with the sdr expiration data.
2037      print -- "$expirationData" > $mmSdrLockExp
2038
2039      # Start the background process that will remove the file.
2040      $mmcommon expirationDataCleanup $expirationData doNotUnlock >/dev/null 2>&1 &
2041    fi
2042
2043    # Check whether GPFS is running.
2044    pid=$($ps -eo "pid args" |  \
2045          $awk '/\/runmmfs/ && !/this process/ {print $1}')
2046    if [[ -n $pid ]]
2047    then
2048      # GPFS has already been started.
2049      printInfoMsg 586 GPFS
2050    else
2051      # Start GPFS.
2052      if [[ -n ${envString} ]]
2053      then
2054        $daemonize -e "$envString" -c $runmmfs $argString
2055      else
2056        $daemonize -c $runmmfs $argString
2057      fi
2058    fi  # end if [[ -n $pid ]]
2059    ;;
2060
2061                      #------------------------------------------
2062  startautomounter )  # mmremote startAutomounter <automountDir>
2063                      #------------------------------------------
2064    if [[ $argc -lt 2 ]]
2065    then
2066      operands="<automountDir>"
2067      printErrorMsg 260 mmremote $kword "$operands"
2068      cleanupAndExit
2069    fi
2070
2071    # Run the OS automount command.
2072    startAutomounter $arg2
2073    rc=$?
2074    ;;
2075
2076                      #-----------------------------------------------
2077  getlocaldiskname )  # mmremote getLocalDiskName <pvid> <nsdSubtype>
2078                      #-----------------------------------------------
2079    if [[ $argc -lt 3 ]]
2080    then
2081      operands="<pvid> <nsdSubtype>"
2082      printErrorMsg 260 mmremote $kword "$operands"
2083      cleanupAndExit
2084    fi
2085
2086    # Determine the physical disk with the specified pvid and nsdSubtype.
2087    getLocalDiskName $arg2 $arg3
2088
2089    rc=0
2090    ;;
2091
2092                        #--------------------------------------
2093  getlocaldisknamevg )  # mmremote getLocalDiskNameVG <vgname>
2094                        #--------------------------------------
2095    if [[ $argc -lt 2 ]]
2096    then
2097      operands="<vgname>"
2098      printErrorMsg 260 mmremote $kword "$operands"
2099      cleanupAndExit
2100    fi
2101
2102    # Determine the physical disk with the specified volume group name.
2103    getLocalDiskNameVG $arg2
2104    rc=0
2105    ;;
2106
2107                      #----------------------------------------
2108  findpvid )          # mmremote findPvid <lvname>
2109                      #----------------------------------------
2110    if [[ $argc -lt 2 ]]
2111    then
2112      operands="<lvname>"
2113      printErrorMsg 260 mmremote $kword "$operands"
2114      cleanupAndExit
2115    fi
2116
2117    # Determine the pvid of the disk with the specified lvname.
2118    findPvid $arg2
2119    rc=$?
2120    ;;
2121
2122                      #----------------------------------------
2123  findvgpvid )        # mmremote findVgPvid <vgname>
2124                      #----------------------------------------
2125    if [[ $argc -lt 2 ]]
2126    then
2127      operands="<vgname>"
2128      printErrorMsg 260 mmremote $kword "$operands"
2129      cleanupAndExit
2130    fi
2131
2132    # Determine the pvid of the disk with the specified vgname.
2133    findVgPvid $arg2
2134    rc=$?
2135    ;;
2136
2137                      #----------------------------------------
2138  findhdiskpvid )     # mmremote findHdiskPvid <hdisk_name>
2139                      #----------------------------------------
2140    if [[ $argc -lt 2 ]]
2141    then
2142      operands="<hdisk name>"
2143      printErrorMsg 260 mmremote $kword "$operands"
2144      cleanupAndExit
2145    fi
2146
2147    # Determine the pvid of the specified physical disk.
2148    findHdiskPvid $arg2
2149    rc=$?
2150    ;;
2151
2152                    #----------------------------------------
2153  mmgetstate )      # mmremote mmGetState
2154                    #----------------------------------------
2155    # Determine the quorum state.
2156    mmGetState $arg2
2157    rc=$?
2158    ;;
2159
2160                    #----------------------------------------
2161  getsubsysstate )  # mmremote getSubsysState <subsystem>
2162                    #----------------------------------------
2163    if [[ $argc -lt 2 ]]
2164    then
2165      operands="<subsystem>"
2166      printErrorMsg 260 mmremote $kword "$operands"
2167      cleanupAndExit
2168    fi
2169
2170    # Determine the state of the specified subsystem.
2171    getSubsysState $arg2
2172    rc=$?
2173    ;;
2174
2175                    #----------------------------------------
2176  killsdrserv )     # mmremote killSdrServ
2177                    #----------------------------------------
2178    # Kill the currently-running mmsdrserv daemon.
2179    killSdrServ
2180    rc=$?
2181    ;;
2182
2183                    #----------------------------------------
2184  startsdrserv )    # mmremote startSdrServ <sdrservPort>
2185                    #----------------------------------------
2186    if [[ $argc -lt 2 ]]
2187    then
2188      operands="<sdrservPort>"
2189      printErrorMsg 260 mmremote $kword "$operands"
2190      cleanupAndExit
2191    fi
2192
2193    # If this is a server node, start the mmsdrserv daemon.
2194    if [[ $ourNodeName = $primaryServer || $ourNodeName = $backupServer ]]
2195    then
2196      startSdrServ $arg2
2197      rc=$?
2198    else
2199      rc=132  # ESDR_NOT_SERVER  "Node is not a server"
2200    fi
2201    ;;
2202
2203                    #----------------------------------------
2204  setwait4rvsd )    # mmremote setWait4RVSD
2205                    #----------------------------------------
2206    # Set the wait4RVSD parm across the currently-active GPFS nodes.
2207    setWait4RVSD
2208    rc=$?
2209    ;;
2210
2211                    #----------------------------------------
2212  refreshauth )     # mmremote refreshAuth
2213                    #----------------------------------------
2214    # Refresh the auth key files.
2215    refreshAuth
2216    rc=$?
2217    ;;
2218
2219                    #----------------------------------------
2220  getcoderange )    # mmremote getCodeRange
2221                    #----------------------------------------
2222    # Determines the range of GPFS release levels on the
2223    # nodes on which the daemon is currently running.
2224    getCodeRange
2225    rc=$?
2226    ;;
2227
2228                   #----------------------------------------
2229  postmount )      # mmremote postMount
2230                   #----------------------------------------
2231    # Perform post-mount processing.  Currently, this is a no-op.
2232    rc=0
2233    ;;
2234
2235                   #----------------------------------------
2236  getgennumber )   # mmremote getGenNumber  [<filename>]
2237                   #----------------------------------------
2238    # Retrieve the generation number of the specified sdrfs file.
2239    getGenNumber $arg2
2240    rc=$?
2241    ;;
2242
2243                   #----------------------------------------
2244  rmdeventry )     # mmremote rmDevEntry <deviceNameList>
2245                   #----------------------------------------
2246    # Get the list of devices to delete.
2247    shift 1
2248    deviceNameList=$@
2249
2250    # Loop through the list and delete the /dev entries.
2251    for devName in $deviceNameList
2252    do
2253      removeMountPoint $devName _NO_MOUNT_POINT_DELETE_ 0
2254    done
2255    ;;
2256
2257                         #------------------------------------------------------
2258  determinedisksubtype ) # mmremote determineDiskSubtype <lvname> [<reevaluate>]
2259                         #------------------------------------------------------
2260    if [[ $argc -lt 2 ]]
2261    then
2262      operands="<lvname> [<reevaluate>]"
2263      printErrorMsg 260 mmremote $kword "$operands"
2264      cleanupAndExit
2265    fi
2266
2267    # Determine the disk type.
2268    determineDiskSubtype $arg2 $arg3
2269    rc=$?
2270    ;;
2271
2272                         #-----------------------------------------
2273  determinensdsubtype )  # mmremote determineNsdSubtype <diskName>
2274                         #-----------------------------------------
2275    if [[ $argc -lt 2 ]]
2276    then
2277      operands="<diskName>"
2278      printErrorMsg 260 mmremote $kword "$operands"
2279      cleanupAndExit
2280    fi
2281
2282    # Determine the disk type.
2283    determineNsdSubtype $arg2
2284    rc=$?
2285    ;;
2286
2287                         #------------------------------------
2288  getlocalnsddata )      # mmremote getLocalNsdData [<Xflag>]
2289                         #------------------------------------
2290    # Send the colon-delimited local nsd data from tspreparedisk -s
2291    # back to the requestor via stdout.
2292    getLocalNsdData $arg2
2293    rc=0
2294    ;;
2295
2296                         #---------------------------------------
2297  creatensd )            # mmremote createNsd <diskName> <vflag>
2298                         #        <invokingCommand> <nsdSubtype>
2299                         #---------------------------------------
2300    if [[ $argc -lt 5 ]]
2301    then
2302      operands="<diskName> <vflag> <invokingCommand> <nsdSubtype>"
2303      printErrorMsg 260 mmremote $kword "$operands"
2304      cleanupAndExit
2305    fi
2306
2307    # Make an NSD out of the disk.
2308    createNsd $arg2 $arg3 $arg4 $arg5
2309    rc=$?
2310    ;;
2311
2312                  #----------------------------------------------------
2313  mvsgdescfile )  # mmremote mvSGDescFile <sourceFile> <targetFile>
2314                  #                       <checksum> <sourceNode>
2315                  #----------------------------------------------------
2316    if [[ $argc -lt 5 ]]
2317    then
2318      operands="<sourceFile> <targetFile> <checksum> <sourceNode>"
2319      printErrorMsg 260 mmremote $kword "$operands"
2320      cleanupAndExit
2321    fi
2322
2323    # Move the specified file and verify its checksum.
2324    mvSGDescFile $arg2 $arg3 $arg4 $arg5
2325    rc=$?
2326    ;;
2327
2328                  #----------------------------------------------------
2329  lssgdescfile )  # mmremote lsSGDescFile
2330                  #----------------------------------------------------
2331    # Return a list of all disk descriptor recovery files.
2332    [[ -d ${tmpDir}mmimportfs ]] &&  \
2333      $ls -1 ${tmpDir}mmimportfs/tspreparedisk.diskDesc.* 2>/dev/null
2334    rc=0
2335    ;;
2336
2337                  #----------------------------------------------------
2338  rmsgdescfile )  # mmremote rmSGDescFile <diskName>
2339                  #----------------------------------------------------
2340    if [[ $argc -lt 2 ]]
2341    then
2342      operands="<diskName>"
2343      printErrorMsg 260 mmremote $kword "$operands"
2344      cleanupAndExit
2345    fi
2346
2347    # Remove all disk descriptor recovery files for the specified disk.
2348    $rm -f ${tmpDir}mmimportfs/tspreparedisk.diskDesc.${arg2}.*
2349    rc=0
2350    ;;
2351
2352                      #-------------------------------------------
2353  getgpfsdiskname )   # mmremote getGpfsDiskName <rawDiskName>
2354                      #-------------------------------------------
2355    if [[ $argc -lt 2 ]]
2356    then
2357      operands="<rawDiskName>"
2358      printErrorMsg 260 mmremote $kword "$operands"
2359      cleanupAndExit
2360    fi
2361
2362    # Determine the GPFS disk name of the specified physical disk.
2363    gpfsDiskName=$(getGpfsDiskName $arg2)
2364    rc=$?
2365    print -- "$gpfsDiskName"
2366    ;;
2367
2368                      #-------------------------------------------
2369  unfencedisks )      # mmremote unfenceDisks <diskFile>
2370                      #-------------------------------------------
2371    if [[ $argc -lt 2 ]]
2372    then
2373      operands="<diskNameFile> | <diskNameList>"
2374      printErrorMsg 260 mmremote $kword "$operands"
2375      cleanupAndExit
2376    fi
2377
2378    # Unfence the specified disks and clear the PR registrations.
2379    unfenceDisksOutput=$(unfenceDisks $arg2)
2380    rc=$?
2381    print -- "$unfenceDisksOutput"
2382
2383    # If this is invoked by mmimportfs, cleanup the input file.
2384    # Otherwise, leave the file alone.  The decision is based on
2385    # the input file's name.
2386    [[ $arg2 = ${tmpDir}disksToUnfence.mmimportfs.*tmp ]] &&  \
2387      $rm -f $arg2
2388    ;;
2389
2390                        #--------------------------------------------------
2391  mountfilesystems )    # mmremote mountFileSystems <device> <mountPoint>
2392                        #     <defaultOptions> <newOptions> [doNotRemount]
2393                        #--------------------------------------------------
2394    if [[ $argc -lt 5 ]]
2395    then
2396      operands="<device> {<mountPoint>|DEFAULT} <defaultOptions>"
2397      operands="${operands} {<newOptions>|DEFAULT} [doNotRemount]"
2398      printErrorMsg 260 mmremote $kword "$operands"
2399      cleanupAndExit
2400    fi
2401
2402    # Mount the specified file systems.
2403    mountFileSystems $arg2 "$arg3" "$arg4" "$arg5" $arg6
2404    rc=$?
2405    ;;
2406
2407                        #---------------------------------------------
2408  unmountfilesystems )  # mmremote unmountFileSystems <device> [-f]
2409                        #---------------------------------------------
2410    if [[ $argc -lt 2 ]]
2411    then
2412      operands="<device> [-f]"
2413      printErrorMsg 260 mmremote $kword "$operands"
2414      cleanupAndExit
2415    fi
2416
2417    # Invoke the preunmount user exit.
2418    [[ -x ${mmfscfgDir}preunmount ]] &&  \
2419      $mmcommon preunmount $arg2 umount
2420
2421    # Unmount the specified file systems.
2422    unmountFileSystems $arg2 "$arg3"
2423    rc=$?
2424    ;;
2425
2426                        #----------------------------------------------
2427  unmountmountpoint )   # mmremote unmountMountpoint <mountPoint> [-f]
2428                        #----------------------------------------------
2429    if [[ $argc -lt 2 ]]
2430    then
2431      operands="<mountPoint> [-f]"
2432      printErrorMsg 260 mmremote $kword "$operands"
2433      cleanupAndExit
2434    fi
2435
2436    # Unmount the specified file systems.
2437    unmountMountpoint $arg2 "$arg3"
2438    rc=$?
2439    ;;
2440
2441             #-------------------------------------------------------------
2442  lsmount )  # mmremote lsmount <fsToShow> <scope> <showNodes> [norefresh]
2443             #-------------------------------------------------------------
2444    if [[ $argc -lt 4 ]]
2445    then
2446      operands="<fsToShow> <scope> <showNodes> [norefresh]"
2447      printErrorMsg 260 mmremote $kword "$operands"
2448      cleanupAndExit
2449    fi
2450
2451    # Find out who has the file systems mounted.
2452    lsmount "$arg2" "$arg3" $arg4 $arg5
2453    rc=$?
2454    ;;
2455
2456                       #---------------------------------
2457  shutdowndaemon )     # mmremote shutdownDaemon
2458                       #---------------------------------
2459    # Remove the rerunmmfsFile file.
2460    # If not done, runmmfs will restart mmfsd.
2461    $rm -f $rerunmmfsFile
2462
2463    # Shut down the GPFS daemon.
2464    $mmfsadm shutdown 2>&1 | $grep -v -e "mmfs daemon not running"
2465    $sleep 3
2466
2467    # Kill the runmmfs and mmfsenv processes if they are still running.
2468    # This would be the case if we were in a backoff respawn
2469    # or the daemon was never started in the first place.
2470    pidNumbers=$($ps -eo "pid args" |  \
2471        $awk '( /\/runmmfs/ || /\/mmfsenv/ ) && !/this process/ {print $1}')
2472    [[ -n $pidNumbers ]] && $kill -s KILL $pidNumbers
2473    $rm -f "${respawnlog}".*
2474
2475    # If this is a server node, start the mmsdrserv daemon.
2476    [[ $ourNodeName = $primaryServer || $ourNodeName = $backupServer ]] &&  \
2477      startSdrServ CURRENT >> $mmsdrservLog 2>&1
2478
2479    # Unload the kernel extensions (in Linux only).
2480    [[ $osName = Linux ]] && $mmfsenv -u
2481
2482    # Always return OK.
2483    rc=0
2484    ;;
2485
2486                      #---------------------------------
2487  cleanupdaemon )     # mmremote cleanupDaemon
2488                      #---------------------------------
2489    # If this file is present, GPFS will be respawned.
2490    $rm -f $rerunmmfsFile >/dev/null 2>&1
2491
2492    # Shut down the daemon.
2493    $mmfsadm cleanup 2>&1 | $grep -v -e "mmfs daemon not running"
2494    $sleep 3
2495
2496    # If this is a server node, start the mmsdrserv daemon.
2497    [[ $ourNodeName = $primaryServer || $ourNodeName = $backupServer ]] &&  \
2498      startSdrServ CURRENT >> $mmsdrservLog 2>&1
2499
2500    # Unload the kernel extensions.
2501    [[ $osName = Linux ]] && $mmfsenv -u
2502
2503    # Always return OK.
2504    rc=0
2505    ;;
2506
2507
2508             #------------------------------------------------------------------
2509  onbehalf)  # mmremote onbehalf <reqNode> <rcFilename> <mmmode> <fileToCopy>
2510             #        <fsToCheck> <scope> <link> <remoteCommand> [<arg ... >]
2511             #------------------------------------------------------------------
2512    if [[ $argc -lt 9 ]]
2513    then
2514      operands="<requestingNode> <rcFilename> <mmmode> <fileToCopy>"
2515      operands="$operands <fsToCheck> <scope> <link> <remoteCommand> [<arg ... >] "
2516      printErrorMsg 260 mmremote $kword "$operands"
2517      cleanupAndExit
2518    fi
2519
2520    # Shift past all positional parameters and collect the command arguments.
2521    shift 9
2522    arguments="$@"
2523
2524    # Setup the environment.
2525    export MMMODE=$arg4
2526
2527    # If there is a file to copy, get it.
2528    fileCopied=no
2529    if [[ $arg5 != $NO_FILE_COPY ]]
2530    then
2531      rcpResult=$(LC_ALL=C $rcp ${arg2}:${arg5} $arg5 2>&1)
2532      rc=$?
2533      if [[ $rc -eq 0 ]]
2534      then
2535        fileCopied=yes
2536      else
2537        # If there was no need to copy the file, that's fine.
2538        print -- "$rcpResult" | $grep -e "refer to the same file" >/dev/null
2539        if [[ $? -ne 0 ]]
2540        then
2541          # Show the error from the rcp command and issue a message
2542          # that the rcp command failed.
2543          print -u2 "$rcpResult"
2544          printErrorMsg 171 $mmcmd "$rcp ${arg2}:${arg5} $arg5" $rc
2545        else
2546          fileCopied=yes
2547          rc=0
2548        fi
2549      fi  # end of if [[ $rc -eq 0 ]]
2550    fi  # end of if [[ $arg5 != $NO_FILE_COPY ]]
2551
2552    # If the copy worked, execute the command and return the return code.
2553    # The return code is reported by creating a temporary file in a scratch
2554    # directory on the caller's machine.  This temporary "return code" file
2555    # has the return code as the trailing part of its name.  It is the
2556    # caller's responsibility to look for this file to get the return code.
2557    # This mechanism is used because rsh does not return return codes.
2558    if [[ $rc -eq 0 ]]
2559    then
2560      runLocalCommand $arg6 $arg7 $arg8 $arg9 $arguments
2561      rc=$?
2562      rshResult=$($rsh $arg2 $mmremote adminCmd touch ${tmpDir}${arg3}.${rc} 2>&1)
2563      ec=$?
2564      if [[ $ec -ne 0 ]]
2565      then
2566        # Show the error from the rsh command and issue a message
2567        # that the rsh command failed.
2568        print -u2 $rshResult
2569        printErrorMsg 171 $mmcmd  \
2570          "$rsh ${arg2} mmremote adminCmd touch ${tmpDir}${arg3}.${rc}" $ec
2571      fi
2572
2573      # Remove the input file if it was not created on this node.
2574      [[ $fileCopied = yes && $arg2 != $ourNodeName ]] && $rm -f $arg5
2575    fi  # end of if [[ $rc -eq 0 ]]
2576    ;;
2577
2578              #-----------------------------------------------------------
2579  onbehalf2)  # mmremote onbehalf2 <reqNode> <rcFilename> <mmmode> <link>
2580              #                    <remoteCommand> [<arg ... >]
2581              #-----------------------------------------------------------
2582    if [[ $argc -lt 6 ]]
2583    then
2584      operands="<requestingNode> <rcFilename> <mmmode> <link>"
2585      operands="$operands <remoteCommand> [<arg ... >] "
2586      printErrorMsg 260 mmremote $kword "$operands"
2587      cleanupAndExit
2588    fi
2589
2590    # Shift past all positional parameters and collect the command arguments.
2591    shift 6
2592    arguments="$@"
2593
2594    # Setup the environment.
2595    export MMMODE=$arg4
2596
2597    # Execute the command and return the return code.
2598    # The return code is reported by creating a temporary file in a scratch
2599    # directory on the caller's machine.  This temporary "return code" file
2600    # has the return code as the trailing part of its name.  It is the
2601    # caller's responsibility to look for this file to get the return code.
2602    # This mechanism is used because rsh does not return return codes.
2603    runLocalCommand2 $arg5 $arg6 $arguments
2604    rc=$?
2605    rshResult=$($rsh $arg2 $mmremote adminCmd touch ${tmpDir}${arg3}.${rc} 2>&1)
2606    ec=$?
2607    if [[ $ec -ne 0 ]]
2608    then
2609      # Show the error from the rsh command and issue a message
2610      # that the rsh command failed.
2611      print -u2 -- $rshResult
2612      printErrorMsg 171 $mmcmd  \
2613        "$rsh ${arg2} mmremote adminCmd touch ${tmpDir}${arg3}.${rc}" $ec
2614    fi
2615    ;;
2616
2617                   #----------------------------------------
2618  * )              # Unknown action requested
2619                   #----------------------------------------
2620    # Invalid keyword. The caller is running incompatible GPFS version.
2621    # Tell him what our capabilities are and let him decide what to do.
2622    printErrorMsg 133 mmremote $kword
2623    print -u2 "mmremote:incompatibleGPFScode:$ourNodeName:$localVersionInfo:"
2624    cleanupAndExit $MM_IncompatibleCode
2625    ;;
2626
2627esac  # end first case $kword_lc in
2628
2629cleanupAndExit $rc doNotUnlock
2630
Note: See TracBrowser for help on using the repository browser.