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

Last change on this file since 108 was 16, checked in by rock, 17 years ago
  • Property svn:executable set to *
File size: 5.6 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,2007
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# @(#)82 1.30.1.2 src/avs/fs/mmfs/ts/admin/mmfsck.sh, mmfs, avs_rgpfs24, rgpfs24s010a 2/12/07 10:38:18
17#########################################################################
18#
19# Usage:
20#   mmfsck Device [-n | -y] [-s | -v | -V] [-c | -o] [-t Directory]
21#            [-N {all | mount | Node[,Node...] | NodeFile | NodeClass}]
22#
23#########################################################################
24
25# Include global declarations and service routines.
26. /usr/lpp/mmfs/bin/mmglobfuncs
27. /usr/lpp/mmfs/bin/mmsdrfsdef
28. /usr/lpp/mmfs/bin/mmfsfuncs
29
30sourceFile="mmfsck.sh"
31[[ -n $DEBUG || -n $DEBUGmmfsck ]] && set -x
32$mmTRACE_ENTER "$*"
33
34# Local variables
35usageMsg=300
36integer rc=0
37integer nodeCount=0
38
39
40######################
41# Mainline processing
42######################
43
44#####################################################################
45# Process the command arguments.
46# Note that we do not use getopts to check the syntax.  tsfsck has some
47# unorthodox debugging options that cannot be handled with getopts.
48# The detailed syntax checking is left for the ts command.
49# Here we make sure that we have the minimum needed to continue.
50#####################################################################
51[[ $arg1 = '-?' || $arg1 = '-h' || $arg1 = '--help' || $arg1 = '--' ]] &&  \
52  syntaxError "help" $usageMsg
53
54[[ $argc -lt 1  ]] &&  \
55  syntaxError "missingArgs" $usageMsg
56
57device=$arg1     # Save stripe group device (always the first parameter).
58shift 1          # Drop the device name from the parameter list.
59
60while [[ -n $1 ]]
61do
62  if [[ $1 = "-N"* ]]
63  then
64    # Intercept the -N parameter.
65    [[ -n $Nflag ]] && syntaxError "multiple" $noUsageMsg "-N"
66    Nflag="-N"
67    if [[ $1 = "-N" ]]
68    then
69      [[ -z $2 ]] && syntaxError "missingValue" $noUsageMsg "-N"
70      Narg="$2"
71      nodeList="$2"
72      shift
73    else
74      Narg=${1#-N}
75      nodeList=${1#-N}
76    fi
77  else
78    # Pass all other parameters to the tsfsck command.
79    argList="$argList $1"
80  fi  # end of if [[ $token = "-N"* ]]
81
82  # Move to the next token
83  [[ -n $1 ]] && shift
84
85done  # end of while [[ -n $token ]]
86
87
88#####################################################################
89# Set up trap exception handling and ensure that the local copy of
90# the mmsdrfs is up-to-date.  There is no need to lock mmsdrfs file.
91#####################################################################
92trap pretrap2 HUP INT QUIT KILL
93gpfsInitOutput=$(gpfsInit nolock)
94setGlobalVar $? $gpfsInitOutput
95
96
97###########################################################
98# Make sure the specified file system exists and is local.
99###########################################################
100findFSoutput=$(findFS "$device" $mmsdrfsFile)
101[[ -z $findFSoutput ]] && cleanupAndExit
102
103# Parse the output from the findFS function.
104set -f ; set -- $findFSoutput ; set +f
105fqDeviceName=$1
106deviceName=$2
107fsHomeCluster=$3
108
109# Exit with a message if the command was invoked for a remote file system.
110if [[ $fsHomeCluster != $HOME_CLUSTER ]]
111then
112  # Command is not allowed for remote file systems.
113  printErrorMsg 106 $mmcmd $device $fsHomeCluster
114  cleanupAndExit
115fi
116
117
118#######################################################
119# If a list of nodes was specified via the -N option,
120# convert it to a verified list of daemon node names.
121#######################################################
122if [[ -n $Nflag ]]
123then
124  if [[ $nodeList = all || $nodeList = mount ]]
125  then
126    # Add the keyword ("all" or "mount") to the argList string.
127    argList="$argList -N $nodeList "
128  else
129    # Verify the node list and convert it to a file of daemon node names.
130    createVerifiedNodefile "$nodeList" $DAEMON_NODENAME_Field no $nodefile
131    [[ $? -ne 0 ]] && cleanupAndExit
132
133    # Convert the output data from a file to a comma-separated list.
134    newNodeList=$(print -- $(cat $nodefile) | $sed 's/ /,/g')
135
136    # Add the verified node list to the argList string.
137    argList="$argList -N $newNodeList "
138  fi  # end of if [[ $nodeList = all || $nodeList = mount ]]
139fi  # end of if [[ -n $Nflag ]]
140
141
142##################################################
143# First try to run the command on the local node.
144##################################################
145${mmcmdDir}/${links}/mmfsck $fqDeviceName $argList
146rc=$(remapRC $?)
147
148# If acceptable error (daemon not running, waiting for quorum),
149# try some other node.  Otherwise, get out; the command either
150# worked or the errors are not acceptable.
151if [[ $rc -ne $MM_DaemonDown && $rc -ne $MM_QuorumWait || $MMMODE = single ]]
152then
153  if [[ $rc -eq $MM_ConnectionReset ]]
154  then
155    # An internode connection was reset.
156    printErrorMsg 257 $mmcmd
157  fi
158  cleanupAndExit $rc
159fi
160
161
162############################################################################
163# If the local daemon is not available, send the command to an active node.
164############################################################################
165
166# Create a file with the reliable names of the nodes in the cluster.
167nodeCount=$(getNodeFile $REL_HOSTNAME_Field $GLOBAL_ID $mmsdrfsFile $nodefile)
168[[ $nodeCount = 0 ]] &&  \
169  checkForErrors "$mmcmd: No nodes found in the cluster." 1
170
171# Try the nodes one by one until you find a node that can execute the command.
172preferredNode=0     # We have no idea where to go first; let mmcommon decide.
173$mmcommon linkCommand $preferredNode $nodefile mmfsck $fqDeviceName $argList
174rc=$?
175
176cleanupAndExit $rc
177
Note: See TracBrowser for help on using the repository browser.