source: gpfs_3.1_ker2.6.20/lpp/mmfs/bin/mmlssnapshot @ 177

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