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

Last change on this file since 177 was 16, checked in by rock, 17 years ago
  • Property svn:executable set to *
File size: 9.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. 1998,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# @(#)02 1.64 src/avs/fs/mmfs/ts/admin/mmmvfs.sh, mmfs, avs_rgpfs24, rgpfs24s001a 3/30/06 14:59:15
17##############################################################################
18#
19# Usage:
20#   mmmvfs Device -W newDeviceName
21#
22# where
23#   Device            is the file system to be renamed.
24#   -W newDeviceName  is the new name for the file system.
25#
26##############################################################################
27
28# Include global declarations and service routines
29. /usr/lpp/mmfs/bin/mmglobfuncs
30. /usr/lpp/mmfs/bin/mmsdrfsdef
31. /usr/lpp/mmfs/bin/mmfsfuncs
32
33sourceFile="mmmvfs.sh"
34[[ -n $DEBUG || -n $DEBUGmmmvfs ]] && set -x
35$mmTRACE_ENTER "$*"
36
37
38# Local work files.  Names should be of the form:
39#   fn=${tmpDir}fn.${mmcmd}.$$
40
41oldNodes=${tmpDir}oldNodes.${mmcmd}.$$
42newNodes=${tmpDir}newNodes.${mmcmd}.$$
43oldcfgFile=${tmpDir}oldcfgFile.${mmcmd}.$$
44
45LOCAL_FILES=" $oldNodes $newNodes $oldcfgFile "
46
47# Local variable declarations
48usageMsg=185
49newNodesetIdFound=no
50oldNodesetId=""
51fsMountPoint=""
52existingMountPoints=""
53existingMinorNumbers=""
54newVSDfound=""
55newDiskLeaseRequired=""
56newLVfound=""
57existingLVfound=""
58existingVSDfound=""
59existingDiskLeaseRequired=""
60preferredNode=0
61
62
63# Local functions
64
65
66
67#######################
68# Mainline processing.
69#######################
70
71
72#################################
73# Process the command arguments.
74#################################
75[[ $arg1 = '-?' || $arg1 = '-h' || $arg1 = '--help' || $arg1 = '--' ]] && \
76  syntaxError "help" $usageMsg
77
78[[ $argc -lt 2 ]] && \
79  syntaxError "missingArgs" $usageMsg
80
81[[ $argc -gt 3 ]] && syntaxError "help" $usageMsg
82
83device=$arg1   # Save the file system device (always the first parameter).
84shift 1        # Drop the device name from the parameter list.
85
86while getopts :W: OPT
87do
88  case $OPT in
89
90    W) # Rename the file system to the specified name.
91       newFsName=$OPTARG
92       ;;
93
94    +[W]) syntaxError "invalidOption" $usageMsg $OPT
95       ;;
96
97    :) syntaxError "missingValue" $usageMsg $OPTARG
98       ;;
99
100    *) # invalid option specified
101       syntaxError "invalidOption" $usageMsg $OPTARG
102       ;;
103  esac
104done
105
106shift OPTIND-1
107[[ $# != 0 ]] && syntaxError "extraArg" $usageMsg $1
108
109
110#####################################################################
111# Verify the correctness of the input new device name parameter.
112# The correctness of the existing device name is checked in findFS.
113#####################################################################
114newDeviceName=${newFsName##+(/)dev+(/)}  # name stripped of /dev/ prefix
115newfqDeviceName="/dev/$newDeviceName"    # name with /dev/ prefix
116if [[ $newDeviceName != ${newDeviceName#*/} ]]
117then
118  if [[ $newDeviceName = ${newDeviceName#/} ]]
119  then
120    printErrorMsg 170 $mmcmd $newFsName
121  else
122    # Name starts with a slash, but not /dev/.
123    printErrorMsg 169 $mmcmd $newFsName
124  fi
125  cleanupAndExit
126fi
127
128
129#####################################################################
130# Set up trap exception handling and call the gpfsInit function.
131# It will ensure that the local copy of the mmsdrfs and the rest of
132# the GPFS system files are up-to-date and will obtain the sdr lock.
133#####################################################################
134trap pretrap HUP INT QUIT KILL
135gpfsInitOutput=$(gpfsInit $lockId)
136setGlobalVar $? $gpfsInitOutput
137
138
139###########################################################
140# Make sure the specified file system exists and is local.
141###########################################################
142findFSoutput=$(findFS "$device" $mmsdrfsFile)
143[[ -z $findFSoutput ]] && cleanupAndExit
144
145# Parse the output from the findFS function.
146set -f ; set -- $findFSoutput ; set +f
147fqDeviceName=$1
148deviceName=$2
149fsHomeCluster=$3
150
151# Exit with a message if the command was invoked for a remote file system.
152if [[ $fsHomeCluster != $HOME_CLUSTER ]]
153then
154  # Command is not allowed for remote file systems.
155  printErrorMsg 106 $mmcmd $device $fsHomeCluster
156  cleanupAndExit 1
157fi
158
159
160##############################################
161# Create the new version of the mmsdrfs file.
162##############################################
163$rm -f $newsdrfs $nodefile $allQuorumNodes
164IFS=":"         # Change the field separator to ':'.
165exec 3<&-
166exec 3< $mmsdrfsFile
167while read -u3 sdrfsLine
168do
169  # Parse the line.
170  set -f ; set -A v -- - $sdrfsLine ; set +f
171
172  IFS="$IFS_sv"   # Restore the default IFS settings.
173
174  # Change some of the fields depending on the type of line.
175  case ${v[$LINE_TYPE_Field]} in
176
177    $VERSION_LINE )  # This is the global header line.
178       # Increment the generation number.
179       newGenNumber=${v[$SDRFS_GENNUM_Field]}+1
180       v[$SDRFS_GENNUM_Field]=$newGenNumber
181       ;;
182
183    $MEMBER_NODE )  # This line describes a node.
184       # Add the reliable node name to nodefile.
185       print -- "${v[$REL_HOSTNAME_Field]}" >> $nodefile
186       checkForErrors "writing to file $nodefile" $?
187
188       # Create a list of the quorum nodes.
189       if [[ ${v[$CORE_QUORUM_Field]} = $quorumNode ]]
190       then
191         print -- "${v[$REL_HOSTNAME_Field]}" >> $allQuorumNodes
192         checkForErrors "writing to file $allQuorumNodes" $?
193       fi
194
195       # If the node that is executing this command is part of the nodeset,
196       # designate it as a "preferred node"
197       [[ ${v[$NODE_NUMBER_Field]} = $ourNodeNumber ]] && \
198         preferredNode=${v[$REL_HOSTNAME_Field]}
199       ;;
200
201    $SG_HEADR )  # This is a fs header line.
202       # Make sure that the new file system name does not already exist.
203       if [[ ${v[$DEV_NAME_Field]} = $newDeviceName ]]
204       then
205         printErrorMsg 107 $mmcmd $newFsName
206         cleanupAndExit
207       fi
208       # If the line is for our file system, replace the
209       # existing file system name with the new one.
210       [[ ${v[$DEV_NAME_Field]} = $deviceName ]] && \
211         v[$DEV_NAME_Field]=$newDeviceName
212       ;;
213
214    $SG_MOUNT | $SG_DISKS | $AUTHORIZED_FS )
215       # If the line is for our file system, replace the
216       # existing file system name with the new one.
217       [[ ${v[$DEV_NAME_Field]} = $deviceName ]] && \
218         v[$DEV_NAME_Field]=$newDeviceName
219       ;;
220
221    $SG_ETCFS )  # This is an /etc/filesystem line.
222       # If the line is for our file system, replace the
223       # existing file system name with the new one.
224       # If it is the line for the device name, change the
225       # device name to reflect the new device name as well.
226       if [[ ${v[$DEV_NAME_Field]} = $deviceName ]]
227       then
228         v[$DEV_NAME_Field]=$newDeviceName
229         if [[ ${v[$LINE_NUMBER_Field]} = $DEV_Line ]]
230         then
231           v[$ETCFS_TEXT_Field]="$DEV_Line_Prefix$newfqDeviceName"
232         fi
233       fi
234       ;;
235
236    * )  # Pass all other lines without a change.
237       ;;
238
239  esac  # end Change some of the fields
240
241  # Build and write the line to the new mmsdrfs file.
242  print_newLine >> $newsdrfs
243  checkForErrors "writing to file $newsdrfs" $?
244
245  IFS=":"  # Change the separator back to ":" for the next iteration.
246
247done  # end while read -u3 sdrfsLine
248
249IFS="$IFS_sv"  # Restore the default IFS settings.
250
251
252####################################################################
253# Invoke tschfs with the -W parameter to rename the file system.
254# This call, if successful, schedules the fs name change.
255# The change is committed or rolled back depending on what name
256# is used on the next file system request.  This in turn will
257# depend on whether the mmsdrfs changes are successfully committed.
258####################################################################
259$mmcommon onactive $preferredNode $nodefile \
260                   $NO_FILE_COPY $fqDeviceName $CHECK_ALL $NO_LINK \
261                   tschfs $fqDeviceName -W $newDeviceName
262rc=$?
263if [[ $rc -ne 0 ]]
264then
265  # The tschfs step failed.
266  printErrorMsg 104 $mmcmd tschfs
267  cleanupAndExit
268fi
269
270
271############################################################
272# Replace the mmsdrfs file in the sdr with the new version.
273############################################################
274trap "" HUP INT QUIT KILL
275gpfsObjectInfo=$(commitChanges \
276   $nsId $nsId $gpfsObjectInfo $newGenNumber $newsdrfs $primaryServer)
277rc=$?
278if [[ $rc -ne 0 ]]
279then
280  # Cannot replace the file in the sdr.
281  printErrorMsg 381 $mmcmd
282  cleanupAndExit
283fi
284
285
286######################################################################
287# Finalize the stripe group descriptor changes (see comments above)
288# by making a simple mmlsfs call to force the daemon to open the
289# file system.  The -r option on mmlsfs is an arbitrary choice.
290######################################################################
291$mmcommon linkCommand  \
292  $preferredNode $nodefile mmlsfs $newfqDeviceName -r > /dev/null 2>&1
293
294
295###################
296# Unlock the sdr.
297###################
298freeLockOnServer $primaryServer $ourNodeNumber >/dev/null
299sdrLocked=no
300trap posttrap HUP INT QUIT KILL
301
302
303#########################################################
304# Propagate the changes to all the nodes in the cluster.
305#########################################################
306propagateSdrfsFile async $nodefile $newsdrfs $newGenNumber
307
308
309###################################################
310# If installed, invoke the syncfsconfig user exit.
311###################################################
312if [[ -x $syncfsconfig ]]
313then
314   print -- "$mmcmd:  Starting $syncfsconfig ..."
315   $syncfsconfig
316   print -- "$mmcmd$syncfsconfig finished."
317fi
318
319cleanupAndExit 0
320
Note: See TracBrowser for help on using the repository browser.