source: gpfs_3.1_ker2.6.20/lpp/mmfs/bin/mmrestripefs @ 152

Last change on this file since 152 was 16, checked in by rock, 17 years ago
  • Property svn:executable set to *
File size: 9.0 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,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# @(#)87 1.33.1.2 src/avs/fs/mmfs/ts/admin/mmrestripefs.sh, mmfs, avs_rgpfs24, rgpfs24s008a 11/20/06 19:31:37
17###########################################################################
18#
19# Usage:
20#
21# mmrestripefs Device {-m | -r | -b | -p | -R} [-P PoolName]
22#              [-N {all | mount | Node[,Node...] | NodeFile | NodeClass}]
23#
24###########################################################################
25
26# Include global declarations and service routines.
27. /usr/lpp/mmfs/bin/mmglobfuncs
28. /usr/lpp/mmfs/bin/mmsdrfsdef
29. /usr/lpp/mmfs/bin/mmfsfuncs
30
31sourceFile="mmrestripefs.sh"
32[[ -n $DEBUG || -n $DEBUGmmrestripefs ]] && set -x
33$mmTRACE_ENTER "$*"
34
35usageMsg=302
36integer rc=0
37integer nodeCount=0
38
39
40#####################################################################
41# Process the command arguments.
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 the file system name (always the first parameter).
50shift 1          # Drop the device name from the parameter list.
51
52# Parse the optional parameters.
53while getopts :bmrRN:pP: OPT
54do
55   case $OPT in
56      b) # Restripe all files.
57         [[ -n $bflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
58         [[ -n $mflag ]] &&  \
59           syntaxError "invalidCombination"  $usageMsg "-b" "-m"
60         [[ -n $pflag ]] &&  \
61           syntaxError "invalidCombination"  $usageMsg "-b" "-p"
62         [[ -n $rflag ]] &&  \
63           syntaxError "invalidCombination"  $usageMsg "-b" "-r"
64         [[ -n $Rflag ]] &&  \
65           syntaxError "invalidCombination" $usageMsg "-b" "-R"
66         bflag=yes
67         argList="$argList -$OPT "
68         ;;
69
70      m) # Migrate critical data.
71         [[ -n $mflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
72         [[ -n $bflag ]] &&  \
73           syntaxError "invalidCombination"  $usageMsg "-b" "-m"
74         [[ -n $pflag ]] &&  \
75           syntaxError "invalidCombination"  $usageMsg "-m" "-p"
76         [[ -n $rflag ]] &&  \
77           syntaxError "invalidCombination"  $usageMsg "-m" "-r"
78         [[ -n $Rflag ]] &&  \
79           syntaxError "invalidCombination" $usageMsg "-m" "-R"
80         mflag=yes
81         argList="$argList -$OPT "
82         ;;
83
84      p) # Restore storage pool placement.
85         [[ -n $pflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
86         [[ -n $bflag ]] &&  \
87           syntaxError "invalidCombination"  $usageMsg "-b" "-p"
88         [[ -n $mflag ]] &&  \
89           syntaxError "invalidCombination"  $usageMsg "-m" "-p"
90         [[ -n $rflag ]] &&  \
91           syntaxError "invalidCombination"  $usageMsg "-p" "-r"
92         [[ -n $Rflag ]] &&  \
93           syntaxError "invalidCombination" $usageMsg "-p" "-R"
94         pflag=yes
95         argList="$argList -$OPT "
96         ;;
97
98      r) # Restore replication.
99         [[ -n $rflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
100         [[ -n $mflag ]] &&  \
101           syntaxError "invalidCombination"  $usageMsg "-m" "-r"
102         [[ -n $bflag ]] &&  \
103           syntaxError "invalidCombination"  $usageMsg "-b" "-r"
104         [[ -n $pflag ]] &&  \
105           syntaxError "invalidCombination"  $usageMsg "-p" "-r"
106         [[ -n $Rflag ]] &&  \
107           syntaxError "invalidCombination" $usageMsg "-R" "-r"
108         rflag=yes
109         argList="$argList -$OPT "
110         ;;
111
112      R) # Restore replication to system defaults.
113         [[ -n $Rflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
114         [[ -n $mflag ]] &&  \
115           syntaxError "invalidCombination" $usageMsg "-m" "-R"
116         [[ -n $bflag ]] &&  \
117           syntaxError "invalidCombination" $usageMsg "-b" "-R"
118         [[ -n $pflag ]] &&  \
119           syntaxError "invalidCombination" $usageMsg "-p" "-R"
120         [[ -n $rflag ]] &&  \
121           syntaxError "invalidCombination" $usageMsg "-r" "-R"
122         Rflag=yes
123         argList="$argList -$OPT "
124         ;;
125
126      N) # Change the state of the specified disks.
127         [[ -n $Nflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
128         nodeList="$OPTARG"
129         Nflag=yes
130         ;;
131
132      P) # Change the state of the specified disks.
133         [[ -n $Pflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
134         poolName="$OPTARG"
135         Pflag=yes
136         argList="$argList -$OPT $OPTARG "
137         ;;
138
139      :) # missing required value after an option
140         syntaxError "missingValue" $usageMsg $OPTARG
141         ;;
142
143     +[bmrNpP]) # plus flags are not allowed
144         syntaxError "invalidOption" $usageMsg $OPT
145         ;;
146
147      *) # invalid option specified
148         syntaxError "invalidOption" $usageMsg $OPTARG
149         ;;
150   esac
151done
152
153shift OPTIND-1
154[[ $# != 0 ]] && syntaxError "extraArg" $usageMsg $1
155
156[[ -z $bflag && -z $mflag && -z $rflag && -z $pflag && -z $Rflag ]] &&  \
157  syntaxError "missingArgs" $usageMsg
158
159
160#####################################################################
161# Set up trap exception handling and ensure that the local copy of
162# the mmsdrfs is up-to-date.  There is no need to lock mmsdrfs file.
163#####################################################################
164trap pretrap2 HUP INT QUIT KILL
165gpfsInitOutput=$(gpfsInit nolock)
166setGlobalVar $? $gpfsInitOutput
167
168# Determine the lookup order for resolving host names.
169[[ $osName != AIX ]] && resolveOrder=$(setHostResolveOrder)
170
171
172###########################################################
173# Make sure the specified file system exists and is local.
174###########################################################
175findFSoutput=$(findFS "$device" $mmsdrfsFile)
176[[ -z $findFSoutput ]] && cleanupAndExit
177
178# Parse the output from the findFS function.
179set -f ; set -- $findFSoutput ; set +f
180fqDeviceName=$1
181deviceName=$2
182fsHomeCluster=$3
183
184# Exit with a message if the command was invoked for a remote file system.
185if [[ $fsHomeCluster != $HOME_CLUSTER ]]
186then
187  # Command is not allowed for remote file systems.
188  printErrorMsg 106 $mmcmd $device $fsHomeCluster
189  cleanupAndExit
190fi
191
192
193###################################################################
194# If a keyword or a list of nodes was specified via the -N option,
195# verify the input and add it to the argList and argListQ strings.
196###################################################################
197if [[ -n $Nflag ]]
198then
199  if [[ $nodeList = all || $nodeList = mount ]]
200  then
201    # Add the keyword ("all" or "mount") to the argList string.
202    argList="$argList -N $nodeList "
203  else
204    # Verify the node list and convert it to a file of daemon node names.
205    createVerifiedNodefile "$nodeList" $DAEMON_NODENAME_Field no $nodefile
206    [[ $? -ne 0 ]] && cleanupAndExit
207
208    # Convert the output data from a file to a comma-separated list.
209    newNodeList=$(print -- $(cat $nodefile) | $sed 's/ /,/g')
210
211    # Add the verified node list to the argList string.
212    argList="$argList -N $newNodeList "
213  fi  # end of if [[ $nodeList = all || $nodeList = mount ]]
214fi  # end of if [[ -n $Nflag ]]
215
216
217#######################################################################
218# If the cluster to which this node belongs is the same as the cluster
219# in which the file system resides, invoke the command directly.
220#######################################################################
221if [[ $nsId = $fsHomeCluster ]]
222then
223  ${mmcmdDir}/${links}/mmrestripefs $fqDeviceName $argList 2>$errMsg
224  rc=$(remapRC $?)
225
226  # If the command completed successfully, or if there is an
227  # unacceptable error, display any error messages and get out.
228  if [[ $rc -ne $MM_DaemonDown && $rc -ne $MM_QuorumWait ]]
229  then
230    [[ -s $errMsg ]] && $cat $errMsg 1>&2
231    if [[ $rc -eq $MM_ConnectionReset ]]
232    then
233      # An internode connection was reset.
234      printErrorMsg 257 $mmcmd
235    fi
236    cleanupAndExit $rc
237  fi
238fi
239$rm -f $errMsg
240
241
242############################################################################
243# If the local daemon is not available, send the command to an active node.
244############################################################################
245
246# Create a file with the reliable names of the nodes
247# in the cluster to which the file system belongs.
248nodeCount=$(getNodeFile $REL_HOSTNAME_Field $fsHomeCluster $mmsdrfsFile $nodefile)
249if [[ $nodeCount -eq 0 ]]
250then
251  # The cluster is empty; there is nobody to run the command.
252  printErrorMsg 171 $mmcmd "getNodeFile (nodeCount=0)" 1
253  cleanupAndExit
254fi
255
256# Try the nodes one by one until you find a node that can execute the command.
257preferredNode=0     # We have no idea where to go first; let mmcommon decide.
258$mmcommon linkCommand $preferredNode $nodefile mmrestripefs $fqDeviceName "$argList"
259rc=$?
260
261cleanupAndExit $rc
262
Note: See TracBrowser for help on using the repository browser.