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

Last change on this file since 223 was 16, checked in by rock, 17 years ago
  • Property svn:executable set to *
File size: 7.0 KB
RevLine 
[16]1#!/bin/ksh
2# IBM_PROLOG_BEGIN_TAG
3# This is an automatically generated prolog.
4
5
6
7# Licensed Materials - Property of IBM
8
9# (C) COPYRIGHT International Business Machines Corp. 2002,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# @(#)56 1.14 src/avs/fs/mmfs/ts/admin/mmsnaplatest.sh, mmfs, avs_rgpfs24, rgpfs240610b 3/22/05 13:20:55
17#######################################################################
18#
19#  Usage:  mmsnaplatest Device [-q | -d | -s snapLatestName]
20#
21#######################################################################
22
23# Include global declarations and service routines.
24. /usr/lpp/mmfs/bin/mmglobfuncs
25if [[ $ourUid -eq 0 ]]
26then
27  . /usr/lpp/mmfs/bin/mmsdrfsdef
28  . /usr/lpp/mmfs/bin/mmfsfuncs
29fi
30
31sourceFile="mmsnaplatest.sh"
32[[ -n $DEBUG || -n $DEBUGmmsnaplatest ]] && set -x
33$mmTRACE_ENTER "$*"
34
35usageMsg=555
36integer rc=0
37integer nodeCount=0
38
39
40#####################################################################
41# Process the command arguments.
42# The detailed syntax checking is left for the ts command.
43# Here we make sure that we have the minimum needed to continue.
44#####################################################################
45[[ $arg1 = '-?' || $arg1 = '-h' || $arg1 = '--help' || $arg1 = '--' ]] &&  \
46  syntaxError "help" $usageMsg
47
48[[ $argc -lt 1  ]] &&  \
49  syntaxError "missingArgs" $usageMsg
50
51device=$arg1     # Save stripe group device (always the first parameter).
52shift 1          # Drop the device name from the parameter list.
53argList=$@       # Save the remainder of the argument list.
54
55
56###################################
57# Set up trap exception handlin.g
58###################################
59trap pretrap2 HUP INT QUIT KILL
60
61
62####################################################################
63# If invoked by a root user, call the gpfsInit function to ensure
64# that the local copy of the mmsdrfs file and the rest of the GPFS
65# system files are up-to-date.  There is no need to lock the sdr.
66# Non-root users are not allowed to invoke commands on other nodes.
67####################################################################
68if [[ $ourUid -eq 0 ]]
69then
70  gpfsInitOutput=$(gpfsInit nolock)
71  setGlobalVar $? $gpfsInitOutput
72fi
73
74
75####################################
76# Make sure the file system exists.
77####################################
78# If the invocation is not for an explicitly-remote device, obtain the
79# needed information about the filesystem from the mmsdrfs file.
80if [[ $device != *:* ]]
81then
82  findFSoutput=$(findFS "$device" $mmsdrfsFile)
83  [[ -z $findFSoutput ]] && cleanupAndExit
84
85  # Parse the output from the findFS function.
86  set -f ; set -- $findFSoutput ; set +f
87  fqDeviceName=$1
88  deviceName=$2
89  fsHomeCluster=$3
90  remoteDevice=$4
91
92  # If this is a remote file system, set fqDeviceName appropriately.
93  [[ $fsHomeCluster != $HOME_CLUSTER ]] &&  \
94    fqDeviceName="$fsHomeCluster:/dev/$remoteDevice"
95else
96  fqDeviceName=$device
97  deviceName=${fqDeviceName##*:}
98  fsHomeCluster=${fqDeviceName%%:*}
99  remoteDevice=$deviceName
100fi
101
102
103# If this is a remote file system, only the query option is allowed.
104# Note: If no options are specified, -q is assumed.
105if [[ $fsHomeCluster != $HOME_CLUSTER && $argc -gt 1 && $arg2 != "-q" ]]
106then
107  # Command is not allowed for remote file systems.
108  printErrorMsg 106 $mmcmd $device $fsHomeCluster
109  cleanupAndExit 1
110fi
111
112
113########################################################################
114# Invoke the command on the local node.
115# Display any error messages and exit if any of the following are true:
116#   - the command completed successfully
117#   - there is an unacceptable error
118#       (anything other than daemon down or quorum wait)
119#   - the file system is remote
120#   - we are not running as UID 0
121#   - this is a single node cluster
122########################################################################
123${mmcmdDir}/${links}/mmsnaplatest $fqDeviceName $argList 2>$errMsg
124rc=$(remapRC $?)
125if [[ ($rc -ne $MM_DaemonDown && $rc -ne $MM_QuorumWait) ||
126      $fsHomeCluster != $HOME_CLUSTER                    ||
127      $ourUid -ne 0                                      ||
128      $MMMODE = single ]]
129then
130  if [[ $rc -eq $MM_FsNotFound ]]
131  then
132    if [[ $fsHomeCluster != $HOME_CLUSTER ]]
133    then
134      # The remote cluster does not know anything about this file system.
135      printErrorMsg 108 $mmcmd $remoteDevice $fsHomeCluster
136    else
137      # Unexpected error.
138      printErrorMsg 171 $mmcmd "file system $deviceName not found" $rc
139    fi
140  elif [[ $rc -eq $MM_Remotefs && $fsHomeCluster != $HOME_CLUSTER ]]
141  then
142    # The file system is not owned by the remote cluster.
143    [[ $device != *:* ]] &&  \
144      printErrorMsg 111 $mmcmd $device $remoteDevice $fsHomeCluster
145    printErrorMsg 112 $mmcmd $remoteDevice $fsHomeCluster
146  elif [[ ($rc -eq $MM_HostDown    ||
147           $rc -eq $MM_TimedOut    ||
148           $rc -eq $MM_SecurityCfg ||
149           $rc -eq $MM_AuthorizationFailed ||
150           $rc -eq $MM_UnknownCluster)    &&
151          $fsHomeCluster != $HOME_CLUSTER ]]
152  then
153    # Failed to connect to the remote cluster.
154    [[ $rc -eq $MM_SecurityCfg ]] &&  \
155      printErrorMsg 150 $mmcmd
156    [[ $rc -eq $MM_AuthorizationFailed ]] &&  \
157      printErrorMsg 151 $mmcmd
158    printErrorMsg 105 $mmcmd $fsHomeCluster
159  elif [[ $rc -eq $MM_DaemonDown ]]
160  then
161    # GPFS is down on this node.
162    printErrorMsg 109 $mmcmd
163  elif [[ $rc -eq $MM_QuorumWait ]]
164  then
165    # GPFS is not ready for commands.
166    printErrorMsg 110 $mmcmd
167  elif [[ $rc -eq $MM_ConnectionReset ]]
168  then
169    # An internode connection was reset.
170    printErrorMsg 257 $mmcmd
171  else
172    # Either the command worked, or it is an unexpected error.
173    if [[ -s $errMsg ]]
174    then
175      # Show the error messages from the daemon.
176      $cat $errMsg 1>&2
177    elif [[ $rc -ne 0 ]]
178    then
179      # tssnaplatest failed.
180      printErrorMsg 104 "$mmcmd" "tssnaplatest $fqDeviceName"
181    else
182      :  # The command must have worked.
183    fi
184  fi  # end of if [[ $rc -eq $MM_FsNotFound ]]
185  cleanupAndExit $rc
186fi  # end of if [[ ($rc -ne $MM_DaemonDown && ... ]]
187$rm -f $errMsg
188
189
190#########################################################################
191# We come here if the command was invoked for a local file system but
192# the local daemon is not available; send the command to an active node.
193#########################################################################
194
195# Create a file with the reliable names of the nodes in the cluster.
196nodeCount=$(getNodeFile $REL_HOSTNAME_Field $fsHomeCluster $mmsdrfsFile $nodefile)
197if [[ $nodeCount -eq 0 ]]
198then
199  # The cluster is empty; there is nobody to run the command.
200  printErrorMsg 171 $mmcmd "getNodeFile (nodeCount=0)" 1
201  cleanupAndExit
202fi
203
204# Try the nodes one by one until you find a node that can execute the command.
205preferredNode=0     # We have no idea where to go first; let mmcommon decide.
206$mmcommon linkCommand $preferredNode $nodefile  \
207    mmsnaplatest $fqDeviceName $argList
208rc=$?
209
210cleanupAndExit $rc
211
Note: See TracBrowser for help on using the repository browser.