source: gpfs_3.1_ker2.6.20/lpp/mmfs/bin/mmchmgr @ 16

Last change on this file since 16 was 16, checked in by rock, 16 years ago
  • Property svn:executable set to *
File size: 4.8 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. 1999,2005
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# @(#)79 1.28 src/avs/fs/mmfs/ts/admin/mmchmgr.sh, mmfs, avs_rgpfs24, rgpfs240610b 6/20/05 12:50:49
17#######################################################################
18#
19# Usage:  mmchmgr Device [ToNode]
20#
21#######################################################################
22
23# Include global declarations and service routines.
24. /usr/lpp/mmfs/bin/mmglobfuncs
25. /usr/lpp/mmfs/bin/mmsdrfsdef
26. /usr/lpp/mmfs/bin/mmfsfuncs
27
28sourceFile="mmchmgr.sh"
29[[ -n $DEBUG || -n $DEBUGmmchmgr ]] && set -x
30$mmTRACE_ENTER "$*"
31
32# Local variables
33usageMsg=304
34integer rc=0
35integer nodeCount=0
36
37
38#####################################################################
39# Process the command arguments.
40# The detailed syntax checking is left for the ts command.
41# Here we make sure that we have the minimum needed to continue.
42#####################################################################
43[[ $arg1 = '-?' || $arg1 = '-h' || $arg1 = '--help' || $arg1 = '--' ]] &&  \
44  syntaxError "help" $usageMsg
45
46[[ $argc -lt 1  ]] &&  \
47  syntaxError "missingArgs" $usageMsg
48
49device=$arg1     # Save stripe group device (always the first parameter).
50shift 1          # Drop the device name from the parameter list.
51argList=$@       # Save the remainder of the argument list.
52
53
54########################################################################
55# Set up trap exception handling and call the gpfsInit function.
56# It will ensure that the local copy of the mmsdrfs and the rest of the
57# GPFS system files are up-to-date.  There is no need to lock the sdr.
58########################################################################
59trap pretrap2 HUP INT QUIT KILL
60gpfsInitOutput=$(gpfsInit nolock)
61setGlobalVar $? $gpfsInitOutput
62
63if [[ $MMMODE = single ]]
64then
65  # Command currently not valid for cluster type single.
66  printErrorMsg 376 $mmcmd single
67  cleanupAndExit
68fi
69
70
71###########################################################
72# Make sure the specified file system exists and is local.
73###########################################################
74findFSoutput=$(findFS "$device" $mmsdrfsFile)
75[[ -z $findFSoutput ]] && cleanupAndExit
76
77# Parse the output from the findFS function.
78set -f ; set -- $findFSoutput ; set +f
79fqDeviceName=$1
80deviceName=$2
81fsHomeCluster=$3
82
83# Exit with a message if the command was invoked for a remote file system.
84if [[ $fsHomeCluster != $HOME_CLUSTER ]]
85then
86  # Command is not allowed for remote file systems.
87  printErrorMsg 106 $mmcmd $device $fsHomeCluster
88  cleanupAndExit
89fi
90
91
92###########################################################
93# If a node was specified, make sure that it is valid
94# and convert it if necessary to a daemon node name.
95###########################################################
96if [[ -n $argList ]]
97then
98  nodeName=$(checkAndConvertNodeValue $argList $DAEMON_NODENAME_Field)
99  [[ $? -ne 0 ]] && cleanupAndExit
100  argList=$nodeName
101fi  # end of if [[ -n $argList ]]
102
103
104##########################################################
105# If the cluster to which this node belongs is the same
106# as the cluster in which the file system resides,
107# invoke the command directly.
108##########################################################
109if [[ $nsId = $fsHomeCluster ]]
110then
111  ${mmcmdDir}/${links}/mmchmgr $fqDeviceName $argList 2>$errMsg
112  rc=$(remapRC $?)
113
114  # If the command completed successfully, or if there is an
115  # unacceptable error, display any error messages and get out.
116  if [[ $rc -ne $MM_DaemonDown && $rc -ne $MM_QuorumWait ]]
117  then
118    [[ -s $errMsg ]] && $cat $errMsg 1>&2
119    if [[ $rc -eq $MM_ConnectionReset ]]
120    then
121      # An internode connection was reset.
122      printErrorMsg 257 $mmcmd
123    fi
124    cleanupAndExit $rc
125  fi
126fi
127$rm -f $errMsg
128
129
130###################################################
131# If the local daemon is not available,
132# find an active node and send the command there.
133###################################################
134
135# Create a file with the reliable names that form
136# the cluster to which the file system belongs.
137nodeCount=$(getNodeFile $REL_HOSTNAME_Field $fsHomeCluster $mmsdrfsFile $nodefile)
138if [[ $nodeCount -eq 0 ]]
139then
140  # The cluster is empty; there is nobody to run the command.
141  printErrorMsg 171 $mmcmd "getNodeFile (nodeCount=0)" 1
142  cleanupAndExit
143fi
144
145# Try the nodes one by one until you find a node that can execute the command.
146preferredNode=0     # We have no idea where to go first; let mmcommon decide.
147$mmcommon linkCommand $preferredNode $nodefile mmchmgr $fqDeviceName $argList
148rc=$?
149
150cleanupAndExit $rc
151
Note: See TracBrowser for help on using the repository browser.