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. 2000,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 | # @(#)09 1.54.1.2 src/avs/fs/mmfs/ts/admin/mmdelnsd.sh, mmfs, avs_rgpfs24, rgpfs24s005a 6/14/06 14:40:18 |
---|
17 | ################################################################################ |
---|
18 | # |
---|
19 | # Usage: |
---|
20 | # mmdelnsd {"DiskName[;DiskName...]" | -F DiskFile} |
---|
21 | # or |
---|
22 | # mmdelnsd -p NSDid [-N Node[,Node]] |
---|
23 | # |
---|
24 | # where: |
---|
25 | # |
---|
26 | # "DiskName[;DiskName...]" is a ";"-separated list of NSD names. |
---|
27 | # |
---|
28 | # DiskFile is the name of a file containing the names |
---|
29 | # of the NSDs to be deleted. |
---|
30 | # |
---|
31 | # -p NSDid is the NSD volume id of a GPFS NSD. |
---|
32 | # |
---|
33 | # -N Node[,Node] is a list of nodes to which the disk is attached. |
---|
34 | # If not specified, the disk is assumed to be |
---|
35 | # directly attached to all nodes in the cluster. |
---|
36 | # Although -N is processed the same as for other |
---|
37 | # GPFS commands (i.e., you could also specify |
---|
38 | # a longer node list, a node file, or a node class), |
---|
39 | # only the first two nodes will be used. |
---|
40 | # |
---|
41 | # Note: The second format of the command is intended primarily for use |
---|
42 | # after a successful removal of the disk from the mmsdrfs file, |
---|
43 | # but a failure to clear the NSD volume id of an NSD disk. |
---|
44 | # |
---|
45 | ################################################################################ |
---|
46 | |
---|
47 | # Include global declarations and service routines |
---|
48 | . /usr/lpp/mmfs/bin/mmglobfuncs |
---|
49 | . /usr/lpp/mmfs/bin/mmsdrfsdef |
---|
50 | . /usr/lpp/mmfs/bin/mmfsfuncs |
---|
51 | |
---|
52 | sourceFile="mmdelnsd.sh" |
---|
53 | [[ -n $DEBUG || -n $DEBUGmmdelnsd ]] && set -x |
---|
54 | $mmTRACE_ENTER "$*" |
---|
55 | |
---|
56 | |
---|
57 | # Local work files. Names should be of the form: |
---|
58 | # fn=${tmpDir}fn.${mmcmd}.$$ |
---|
59 | affectedNodes=${tmpDir}affectedNodes.${mmcmd}.$$ |
---|
60 | PVIDsToDelete=${tmpDir}PVIDsToDelete.${mmcmd}.$$ |
---|
61 | |
---|
62 | LOCAL_FILES=" $PVIDsToDelete $affectedNodes " |
---|
63 | |
---|
64 | |
---|
65 | # Local declarations |
---|
66 | usageMsg=413 |
---|
67 | |
---|
68 | |
---|
69 | # Local routines |
---|
70 | |
---|
71 | ############################################################################### |
---|
72 | # |
---|
73 | # Function: Delete the NSD volume id of an NSD disk. |
---|
74 | # |
---|
75 | # Input: pvid nsdSubtype nsdSubname primaryServer backupServer |
---|
76 | # |
---|
77 | ############################################################################### |
---|
78 | function clearPVID # <pvid> <nsdSubtype> <nsdSubname> |
---|
79 | # <primaryServer> <backupServer> |
---|
80 | { |
---|
81 | typeset sourceFile="mmdelnsd.sh" |
---|
82 | [[ -n $DEBUG || -n $DEBUGclearPVID ]] && set -x |
---|
83 | $mmTRACE_ENTER "$*" |
---|
84 | typeset pvid=$1 |
---|
85 | typeset nsdSubtype=$2 |
---|
86 | typeset nsdSubname=$3 |
---|
87 | typeset primaryServer=$4 |
---|
88 | typeset backupServer=$5 |
---|
89 | |
---|
90 | typeset firstChoice secondChoice tspreparediskOutput magicWord rc rc2 retcode |
---|
91 | |
---|
92 | # Determine where to send the request for deleting the NSD volume id. |
---|
93 | if [[ -z $primaryServer ]] |
---|
94 | then |
---|
95 | firstChoice=$ourNodeName |
---|
96 | secondChoice="" |
---|
97 | elif [[ $primaryServer = $ourNodeName ]] |
---|
98 | then |
---|
99 | firstChoice=$ourNodeName |
---|
100 | secondChoice=$backupServer |
---|
101 | elif [[ $backupServer = $ourNodeName ]] |
---|
102 | then |
---|
103 | firstChoice=$ourNodeName |
---|
104 | secondChoice=$primaryServer |
---|
105 | else |
---|
106 | firstChoice=$primaryServer |
---|
107 | secondChoice=$backupServer |
---|
108 | fi |
---|
109 | |
---|
110 | nsdSubnameParm="-Z $nsdSubname" |
---|
111 | [[ $nsdSubname = $UNKNOWN ]] && nsdSubnameParm="" |
---|
112 | |
---|
113 | # Clear (zero out) the NSD volume id. |
---|
114 | if [[ $firstChoice = $ourNodeName ]] |
---|
115 | then |
---|
116 | tspreparediskOutput=$($tspreparedisk -z $pvid -t $nsdSubtype $nsdSubnameParm) |
---|
117 | rc=$? |
---|
118 | else |
---|
119 | tspreparediskOutput=$($mmcommon on1 $firstChoice adminCmd \ |
---|
120 | tspreparedisk -z $pvid -t $nsdSubtype $nsdSubnameParm) |
---|
121 | rc=$? |
---|
122 | fi |
---|
123 | |
---|
124 | # Parse the output from the tspreparedisk command. |
---|
125 | IFS=":" |
---|
126 | set -f ; set -- $tspreparediskOutput ; set +f |
---|
127 | magicWord=$1 |
---|
128 | rc2=$2 |
---|
129 | IFS="$IFS_sv" |
---|
130 | |
---|
131 | if [[ $rc != 0 || $magicWord != tspreparedisk || $rc2 -ne 0 ]] |
---|
132 | then |
---|
133 | # tspreparedisk failed. If there is a second choice, try again. |
---|
134 | # Note that because of the way firstChoice and secondChoice |
---|
135 | # were determined, secondChoice cannot be the local node. |
---|
136 | if [[ -n $secondChoice ]] |
---|
137 | then |
---|
138 | tspreparediskOutput=$($mmcommon on1 $secondChoice adminCmd \ |
---|
139 | tspreparedisk -z $pvid -t $nsdSubtype $nsdSubnameParm) |
---|
140 | rc=$? |
---|
141 | # Parse the output from the tspreparedisk command. |
---|
142 | IFS=":" |
---|
143 | set -f ; set -- $tspreparediskOutput ; set +f |
---|
144 | magicWord=$1 |
---|
145 | rc2=$2 |
---|
146 | IFS="$IFS_sv" |
---|
147 | fi |
---|
148 | fi |
---|
149 | |
---|
150 | if [[ $rc != 0 || $magicWord != tspreparedisk || $rc2 -ne 0 ]] |
---|
151 | then |
---|
152 | retcode=$rc2 |
---|
153 | else |
---|
154 | retcode=0 |
---|
155 | fi |
---|
156 | |
---|
157 | return $retcode |
---|
158 | |
---|
159 | } #----- end of function clearPVID ------------------------ |
---|
160 | |
---|
161 | |
---|
162 | |
---|
163 | ###################### |
---|
164 | # Mainline processing |
---|
165 | ###################### |
---|
166 | |
---|
167 | |
---|
168 | ################################# |
---|
169 | # Process the command arguments. |
---|
170 | ################################# |
---|
171 | [[ $arg1 = '-?' || $arg1 = '-h' || $arg1 = '--help' || $arg1 = '--' ]] && \ |
---|
172 | syntaxError "help" $usageMsg |
---|
173 | |
---|
174 | [[ $argc -lt 1 ]] && \ |
---|
175 | syntaxError "missingArgs" $usageMsg |
---|
176 | |
---|
177 | while getopts :F:N:p: OPT |
---|
178 | do |
---|
179 | case $OPT in |
---|
180 | |
---|
181 | F) [[ -n $Fflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT" |
---|
182 | Farg="$OPTARG" |
---|
183 | Fflag="-F" |
---|
184 | ;; |
---|
185 | |
---|
186 | N) [[ -n $Nflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT" |
---|
187 | nodeList="$OPTARG" |
---|
188 | Nflag="-N" |
---|
189 | ;; |
---|
190 | |
---|
191 | p) [[ -n $pflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT" |
---|
192 | pflag="-p" |
---|
193 | pvidToDelete=$OPTARG |
---|
194 | ;; |
---|
195 | |
---|
196 | +[Np]) # Invalid option |
---|
197 | syntaxError "invalidOption" $usageMsg $OPT |
---|
198 | ;; |
---|
199 | |
---|
200 | :) # Missing argument |
---|
201 | syntaxError "missingValue" $usageMsg $OPTARG |
---|
202 | ;; |
---|
203 | |
---|
204 | *) # Invalid option |
---|
205 | syntaxError "invalidOption" $usageMsg $OPTARG |
---|
206 | ;; |
---|
207 | esac |
---|
208 | done |
---|
209 | |
---|
210 | # Drop the processed options from the parameter list. |
---|
211 | shift OPTIND-1 |
---|
212 | |
---|
213 | # Complete the parameter checking. |
---|
214 | if [[ -z $pflag && -z $Nflag ]] |
---|
215 | then |
---|
216 | if [[ -z $Fflag ]] |
---|
217 | then |
---|
218 | # The diskList form of the command syntax was used. |
---|
219 | if [[ $argc -eq 1 ]] |
---|
220 | then |
---|
221 | # If there is exactly one string left, it is assumed |
---|
222 | # to be the list of disks. |
---|
223 | diskList=$1 |
---|
224 | |
---|
225 | # Ensure that semi-colon is used as a disk name separator. |
---|
226 | [[ "$diskList" = *+([-:,${BLANKchar}${TABchar}])* ]] && \ |
---|
227 | syntaxError "badSeparator_notSemicolon" $noUsageMsg |
---|
228 | |
---|
229 | # Convert the list of disks into a file. |
---|
230 | $rm -f $diskNamesFile |
---|
231 | IFS=';' |
---|
232 | for disk in $diskList |
---|
233 | do |
---|
234 | print -- "$disk" >> $diskNamesFile |
---|
235 | checkForErrors "writing to $diskNamesFile" $? |
---|
236 | done |
---|
237 | IFS="$IFS_sv" # Restore the default IFS setting. |
---|
238 | |
---|
239 | elif [[ $argc -gt 1 ]] |
---|
240 | then |
---|
241 | # More than one string is left, so we have a syntax error. |
---|
242 | syntaxError "extraArg" $usageMsg "$2" |
---|
243 | |
---|
244 | else |
---|
245 | # If there are no more parameters, |
---|
246 | # a required parameter is missing. |
---|
247 | syntaxError "missingArgs" $usageMsg |
---|
248 | fi # end of if [[ $argc -eq 1 ]] |
---|
249 | |
---|
250 | else |
---|
251 | # The disks names are specified in a file. |
---|
252 | # Check the file and create a temp copy that we can modify. |
---|
253 | checkUserFile $Farg $diskNamesFile |
---|
254 | [[ $? -ne 0 ]] && cleanupAndExit |
---|
255 | fi # end of if [[ -z $Fflag ]] |
---|
256 | |
---|
257 | else |
---|
258 | # The second form of the syntax was used. |
---|
259 | # The -p flag must have been specified. |
---|
260 | [[ -z $pflag ]] && \ |
---|
261 | syntaxError "missingArgs" $usageMsg |
---|
262 | |
---|
263 | # There should be no other parms. |
---|
264 | [[ $# -ne 0 ]] && \ |
---|
265 | syntaxError "extraArg" $usageMsg "$1" |
---|
266 | |
---|
267 | # If a list of nodes was specified via the -N option, |
---|
268 | # convert it to a verified list of admin node names. |
---|
269 | if [[ -n $Nflag ]] |
---|
270 | then |
---|
271 | createVerifiedNodefile "$nodeList" $REL_HOSTNAME_Field no $nodefile |
---|
272 | [[ $? -ne 0 ]] && cleanupAndExit |
---|
273 | |
---|
274 | # Convert the output data from a file to a comma-separated list. |
---|
275 | newNodeList=$(print -- $(cat $nodefile) | $sed 's/ /,/g') |
---|
276 | fi # end of if [[ -n $Nflag ]] |
---|
277 | fi # end of if [[ -z $pflag && -z $Nflag ]] |
---|
278 | |
---|
279 | |
---|
280 | ##################################################################### |
---|
281 | # Set up trap exception handling and call the gpfsInit function. |
---|
282 | # It will ensure that the local copy of the mmsdrfs and the rest of |
---|
283 | # the GPFS system files are up-to-date and will obtain the sdr lock. |
---|
284 | ##################################################################### |
---|
285 | trap pretrap HUP INT QUIT KILL |
---|
286 | gpfsInitOutput=$(gpfsInit $lockId) |
---|
287 | setGlobalVar $? $gpfsInitOutput |
---|
288 | |
---|
289 | |
---|
290 | #################################################### |
---|
291 | # Determine whether disk-based quorum is in effect. |
---|
292 | #################################################### |
---|
293 | diskQuorumInEffect=$(showCfgValue tiebreakerDisks) |
---|
294 | [[ $diskQuorumInEffect = no ]] && diskQuorumInEffect="" |
---|
295 | |
---|
296 | |
---|
297 | ####################################################################### |
---|
298 | # Create a new version of the mmsdrfs file. Increment the generation |
---|
299 | # number and remove the free disk lines for the disks being deleted. |
---|
300 | # |
---|
301 | # Note: A disk cannot be deleted from the cluster if it is still |
---|
302 | # listed as an active disk in some file system. |
---|
303 | ####################################################################### |
---|
304 | $rm -f $newsdrfs $nodefile $PVIDsToDelete |
---|
305 | IFS=":" # Change the field separator to ':'. |
---|
306 | exec 3<&- |
---|
307 | exec 3< $mmsdrfsFile |
---|
308 | while read -u3 sdrfsLine |
---|
309 | do |
---|
310 | # Parse the line. |
---|
311 | set -f ; set -A v -- - $sdrfsLine ; set +f |
---|
312 | IFS="$IFS_sv" # Restore the default IFS settings. |
---|
313 | printLine=true # Assume the line will be printed. |
---|
314 | |
---|
315 | # Change some of the fields depending on the type of line. |
---|
316 | case ${v[$LINE_TYPE_Field]} in |
---|
317 | |
---|
318 | $VERSION_LINE ) # This is the global header line. |
---|
319 | # Increment the generation number |
---|
320 | newGenNumber=${v[$SDRFS_GENNUM_Field]}+1 |
---|
321 | v[$SDRFS_GENNUM_Field]=$newGenNumber |
---|
322 | ;; |
---|
323 | |
---|
324 | $MEMBER_NODE ) # This line describes a node. |
---|
325 | # Add the node's reliable name to the list of nodes |
---|
326 | # to be notified about the sdrfs changes. |
---|
327 | print -- "${v[$REL_HOSTNAME_Field]}" >> $nodefile |
---|
328 | checkForErrors "writing to file $nodefile" $? |
---|
329 | ;; |
---|
330 | |
---|
331 | $SG_DISKS ) # This line describes some disk. |
---|
332 | # Determine whether this disk is one of the disks to be deleted. |
---|
333 | if [[ -z $pflag ]] # Was the -p flag specified? |
---|
334 | then |
---|
335 | # We are in the "normal" disk list or disk file cases. |
---|
336 | # Was this disk one of the NSDs to be deleted? |
---|
337 | $grep -w ${v[$DISK_NAME_Field]} $diskNamesFile > /dev/null 2>&1 |
---|
338 | if [[ $? -eq 0 ]] |
---|
339 | then |
---|
340 | # The disk represented by the current SG_DISKS line |
---|
341 | # is one of the disks that should be deleted. |
---|
342 | # Check whether the disk can be removed from the mmsdrfs file. |
---|
343 | if [[ ${v[$PAXOS_Field]} = $PaxosDisk && -n $diskQuorumInEffect ]] |
---|
344 | then |
---|
345 | # The disk is a tiebreaker disk and cannot be deleted. |
---|
346 | # Issue a message but keep going; do not fail the command. |
---|
347 | printErrorMsg 130 $mmcmd ${v[$DISK_NAME_Field]} |
---|
348 | failedDisks=yes |
---|
349 | elif [[ ${v[$NODESETID_Field]} = $FREE_DISK ]] |
---|
350 | then |
---|
351 | # The disk will be deleted; save needed information. |
---|
352 | printLine=false |
---|
353 | deletedDisks=yes |
---|
354 | nsdSubtype=${v[$NSD_SUBTYPE_Field]} |
---|
355 | [[ $nsdSubtype = "" ]] && nsdSubtype=generic |
---|
356 | nsdSubName=${v[$NSD_SUBTYPE_DISKNAME_Field]} |
---|
357 | [[ $nsdSubName = "" ]] && nsdSubName=$UNKNOWN |
---|
358 | print -- ${v[$DISK_NAME_Field]} ${v[$PVID_Field]} \ |
---|
359 | $nsdSubtype $nsdSubName \ |
---|
360 | ${v[$NSD_PRIMARY_NODE_Field]} \ |
---|
361 | ${v[$NSD_BACKUP_NODE_Field]} >> $PVIDsToDelete |
---|
362 | checkForErrors "writing to file $PVIDsToDelete" $? |
---|
363 | else |
---|
364 | # The disk still belongs to a file system. |
---|
365 | # Issue a message but keep going; do not fail the command. |
---|
366 | printErrorMsg 485 $mmcmd ${v[$DISK_NAME_Field]} ${v[$DEV_NAME_Field]} |
---|
367 | failedDisks=yes |
---|
368 | fi # end of if [[ ${v[$PAXOS_Field]} = $PaxosDisk && ... ]] |
---|
369 | |
---|
370 | # Remove the disk from the file of disks to be deleted. |
---|
371 | grep -vw ${v[$DISK_NAME_Field]} $diskNamesFile > $tmpfile |
---|
372 | |
---|
373 | # Initialize the file for the next iteration. |
---|
374 | $mv $tmpfile $diskNamesFile |
---|
375 | checkForErrors "mv $tmpfile $diskNamesFile" $? |
---|
376 | fi # end of if [[ $? -eq 0]] |
---|
377 | |
---|
378 | else # We come here if the -p option for specifying |
---|
379 | # an NSD volume id was used. |
---|
380 | |
---|
381 | if [[ ${v[$PVID_Field]} = $pvidToDelete ]] |
---|
382 | then # We come here if the disk represented by the current |
---|
383 | # SG_DISKS line is the one that must be deleted. |
---|
384 | |
---|
385 | if [[ ${v[$NODESETID_Field]} = $FREE_DISK ]] |
---|
386 | then |
---|
387 | |
---|
388 | # The disk is not in use and can therefore be deleted. |
---|
389 | # Save the information needed for clearing the NSD volume id. |
---|
390 | nsdSubtype=${v[$NSD_SUBTYPE_Field]} |
---|
391 | [[ $nsdSubtype = "" ]] && nsdSubtype=generic |
---|
392 | nsdSubName=${v[$NSD_SUBTYPE_DISKNAME_Field]} |
---|
393 | [[ $nsdSubName = "" ]] && nsdSubName=$UNKNOWN |
---|
394 | if [[ -n $Nflag ]] |
---|
395 | then |
---|
396 | # A node list was specified. |
---|
397 | IFS=',' |
---|
398 | set -f ; set -- $newNodeList ; set +f |
---|
399 | nodeName1=$1 |
---|
400 | nodeName2=$2 |
---|
401 | IFS="$IFS_sv" |
---|
402 | print -- ${v[$DISK_NAME_Field]} ${v[$PVID_Field]} \ |
---|
403 | $nsdSubtype $nsdSubName \ |
---|
404 | ${v[$NSD_PRIMARY_NODE_Field]} \ |
---|
405 | ${v[$NSD_BACKUP_NODE_Field]} \ |
---|
406 | $nodeName1 $nodeName2 >> $PVIDsToDelete |
---|
407 | rc=$? |
---|
408 | else |
---|
409 | # A node list was not specified. |
---|
410 | print -- ${v[$DISK_NAME_Field]} ${v[$PVID_Field]} \ |
---|
411 | $nsdSubtype $nsdSubName \ |
---|
412 | ${v[$NSD_PRIMARY_NODE_Field]} \ |
---|
413 | ${v[$NSD_BACKUP_NODE_Field]} >> $PVIDsToDelete |
---|
414 | rc=$? |
---|
415 | fi |
---|
416 | checkForErrors "writing to file $PVIDsToDelete" $rc |
---|
417 | |
---|
418 | # Remove the disk from the mmsdrfs file. |
---|
419 | printLine=false |
---|
420 | deletedDisks=yes |
---|
421 | |
---|
422 | else |
---|
423 | # The disk still belongs to a file system. |
---|
424 | # Issue a message but keep going; do not fail the command. |
---|
425 | printErrorMsg 485 $mmcmd ${v[$DISK_NAME_Field]} ${v[$DEV_NAME_Field]} |
---|
426 | failedDisks=yes |
---|
427 | |
---|
428 | fi # end of if [[ ${v[$NODESETID_Field]} = $FREE_DISK ]] |
---|
429 | |
---|
430 | fi # end of if [[ ${v[$PVID_Field]} = $pvidToDelete ]] |
---|
431 | |
---|
432 | fi # end of if [[ -z $pflag ]] |
---|
433 | ;; |
---|
434 | |
---|
435 | * ) # There is no need to look at any of the other lines. |
---|
436 | ;; |
---|
437 | |
---|
438 | esac # end Change some of the fields |
---|
439 | |
---|
440 | # If the line is to be kept, write it to the new mmsdrfs file. |
---|
441 | if [[ $printLine = true ]] |
---|
442 | then |
---|
443 | print_newLine >> $newsdrfs |
---|
444 | checkForErrors "writing to file $newsdrfs" $? |
---|
445 | fi |
---|
446 | |
---|
447 | IFS=":" # Change the separator back to ":" for the next iteration. |
---|
448 | |
---|
449 | done # end while read -u3 sdrfsLine |
---|
450 | |
---|
451 | IFS="$IFS_sv" # Restore the default IFS settings. |
---|
452 | |
---|
453 | |
---|
454 | # If we are in the normal disk list or disk file case, inform the user of any |
---|
455 | # disks for which there were no corresponding SG_DISKS lines in the sdrfs file. |
---|
456 | # If disks were specified but none were found, print an error message and exit. |
---|
457 | if [[ -z $pflag ]] |
---|
458 | then |
---|
459 | # We are in the "normal" disk list or disk file case. If there are any |
---|
460 | # disks to delete that we didn't find in the mmsdrfs file, tell the user. |
---|
461 | if [[ -s $diskNamesFile ]] |
---|
462 | then |
---|
463 | # If the input file was generated by mmcrnsd, it may have comment |
---|
464 | # lines that will trigger a misleading warning message. Scan the |
---|
465 | # file and remove all comment and empty lines. In preparation for |
---|
466 | # the message that will be issued shortly, insert a tab character |
---|
467 | # at the begining of the non-comment lines. |
---|
468 | $awk ' \ |
---|
469 | BEGIN { TABchar = " " } \ |
---|
470 | $1 ~ /^#/ { next } \ |
---|
471 | NF == 0 { next } \ |
---|
472 | { print TABchar $0 } \ |
---|
473 | ' $diskNamesFile > $tmpfile |
---|
474 | |
---|
475 | # Issue "The following disks are not known to GPFS:" message. |
---|
476 | [[ -s $tmpfile ]] && \ |
---|
477 | printErrorMsg 486 $mmcmd "$($cat $tmpfile)" |
---|
478 | fi # end of if [[ -s $diskNamesFile ]] |
---|
479 | |
---|
480 | # If no disks will be deleted, issue an error and exit. |
---|
481 | if [[ -z $deletedDisks ]] |
---|
482 | then |
---|
483 | # No disks were specified that could be deleted. |
---|
484 | printErrorMsg 487 $mmcmd |
---|
485 | cleanupAndExit |
---|
486 | fi |
---|
487 | fi # end of if [[ -z $pflag ]] |
---|
488 | |
---|
489 | |
---|
490 | ############################################ |
---|
491 | # Put the new mmsdrfs file into the sdr. |
---|
492 | # This deletes the disks from the cluster. |
---|
493 | ############################################ |
---|
494 | |
---|
495 | # If no disks are being deleted from the sdrfs file, |
---|
496 | # there is no need to commit changes. |
---|
497 | # This test is only needed for the -p case, since we exit above |
---|
498 | # if there were no changes in the regular case. |
---|
499 | if [[ -n $deletedDisks ]] |
---|
500 | then |
---|
501 | trap "" HUP INT QUIT KILL |
---|
502 | gpfsObjectInfo=$(commitChanges \ |
---|
503 | $HOME_CLUSTER $nsId $gpfsObjectInfo $newGenNumber $newsdrfs $primaryServer) |
---|
504 | rc=$? |
---|
505 | if [[ $rc -ne 0 ]] |
---|
506 | then |
---|
507 | # We were unable to replace the file in the sdr. |
---|
508 | printErrorMsg 381 $mmcmd |
---|
509 | cleanupAndExit |
---|
510 | fi |
---|
511 | fi # end of if [[ -n $deletedDisks ]] |
---|
512 | |
---|
513 | |
---|
514 | ################## |
---|
515 | # Unlock the sdr. |
---|
516 | ################## |
---|
517 | [[ $sdrLocked = yes ]] && \ |
---|
518 | freeLockOnServer $primaryServer $ourNodeNumber > /dev/null |
---|
519 | sdrLocked=no |
---|
520 | trap posttrap HUP INT QUIT KILL |
---|
521 | |
---|
522 | |
---|
523 | ######################################################################## |
---|
524 | # Handle the case where -p was specified but the NSD volume id was not |
---|
525 | # found in the mmsdrfs file. In such a case we must still try to clear |
---|
526 | # the NSD volume id. This is one of the main uses of the -p option. |
---|
527 | ######################################################################## |
---|
528 | |
---|
529 | # If no match was found in the sdrfs file, we must be in the -p case, |
---|
530 | # since we exited earlier if no match was found in the disk list or |
---|
531 | # disk file case. |
---|
532 | if [[ -z $deletedDisks ]] |
---|
533 | then |
---|
534 | if [[ -z $failedDisks ]] |
---|
535 | then |
---|
536 | # If here, the NSD volume id was not found in the mmsdrfs file. |
---|
537 | # Store the info needed for deleting the NSDid in the delete file. |
---|
538 | if [[ -n $Nflag ]] |
---|
539 | then |
---|
540 | # A node list was specified. |
---|
541 | IFS=',' |
---|
542 | set -f ; set -- $newNodeList ; set +f |
---|
543 | nodeName1=$1 |
---|
544 | nodeName2=$2 |
---|
545 | IFS="$IFS_sv" |
---|
546 | print -- $UNKNOWN $pvidToDelete generic $UNKNOWN \ |
---|
547 | $nodeName1 $nodeName2 >> $PVIDsToDelete |
---|
548 | rc=$? |
---|
549 | else |
---|
550 | # A node list was not specified. |
---|
551 | print -- $UNKNOWN $pvidToDelete generic $UNKNOWN >> $PVIDsToDelete |
---|
552 | rc=$? |
---|
553 | fi |
---|
554 | checkForErrors "writing to file $PVIDsToDelete" $rc |
---|
555 | else |
---|
556 | # If here, the NSD volume id was found in the mmsdrfs file, but an |
---|
557 | # error (probably "disk still belongs to a file system") was found. |
---|
558 | # Issue a message that none of the disks were deleted, and quit. |
---|
559 | printErrorMsg 487 $mmcmd |
---|
560 | cleanupAndExit |
---|
561 | fi # end of if [[ -z $failedDisks ]] |
---|
562 | fi # end of if [[ -z $deletedDisks ]] |
---|
563 | |
---|
564 | |
---|
565 | ############################################################################# |
---|
566 | # Clear (zero-out) the NSD volume id on each disk in the PVIDsToDelete file. |
---|
567 | ############################################################################# |
---|
568 | |
---|
569 | if [[ -s $PVIDsToDelete ]] |
---|
570 | then |
---|
571 | # Process the PVIDsToDelete file one line at a time. |
---|
572 | exec 3<&- |
---|
573 | exec 3< $PVIDsToDelete |
---|
574 | while read -u3 diskLine |
---|
575 | do |
---|
576 | # Parse the line. |
---|
577 | set -f ; set -- $diskLine ; set +f |
---|
578 | diskName=$1 |
---|
579 | pvid=$2 |
---|
580 | nsdSubtype=$3 |
---|
581 | nsdSubname=$4 |
---|
582 | primarySvr=$5 |
---|
583 | backupSvr=$6 |
---|
584 | nodeName1=$7 |
---|
585 | nodeName2=$8 |
---|
586 | |
---|
587 | # Issue an informational progress message (processing disk xyz ...). |
---|
588 | printInfoMsg 251 $mmcmd $diskName |
---|
589 | |
---|
590 | # Clear the NSD volume id using one of the first two servers. |
---|
591 | clearPVID $pvid $nsdSubtype $nsdSubname $primarySvr $backupSvr |
---|
592 | rc=$? |
---|
593 | if [[ $rc -ne 0 ]] # if the clearPVID call failed |
---|
594 | then |
---|
595 | |
---|
596 | if [[ -z $nodeName1 ]] # if there are no other nodes to try |
---|
597 | then |
---|
598 | # tspreparedisk failed and we have no other nodes to try. |
---|
599 | # Tell the guy what to do. |
---|
600 | if [[ $rc -eq $MM_DeviceNotFound ]] |
---|
601 | then |
---|
602 | # The disk with the specified NSD volume id was not found. |
---|
603 | printErrorMsg 397 $mmcmd $pvid |
---|
604 | elif [[ -z $primarySvr ]] |
---|
605 | then |
---|
606 | # Tell the user to issue "mmdelnsd -p <pvid>" |
---|
607 | # to delete the disk. |
---|
608 | if [[ $diskName = $UNKNOWN ]] |
---|
609 | then |
---|
610 | printErrorMsg 247 $mmcmd $pvid $pvid |
---|
611 | else |
---|
612 | printErrorMsg 488 $mmcmd $diskName $pvid |
---|
613 | fi |
---|
614 | else |
---|
615 | # Tell the user to issue "mmdelnsd -p <pvid> -N <nodeList>" |
---|
616 | # to delete the disk. |
---|
617 | [[ -n $backupSvr ]] && primarySvr="${primarySvr},${backupSvr}" |
---|
618 | if [[ $diskName = $UNKNOWN ]] |
---|
619 | then |
---|
620 | printErrorMsg 248 $mmcmd $pvid $pvid $primarySvr |
---|
621 | else |
---|
622 | printErrorMsg 489 $mmcmd $diskName $pvid $primarySvr |
---|
623 | fi |
---|
624 | fi |
---|
625 | |
---|
626 | else |
---|
627 | # Besides the servers found on the SG_DISKS line of the mmsdrfs file, |
---|
628 | # the user specified other nodes via the -N option on the command. |
---|
629 | # Try to clear the NSD volume id using these nodes. |
---|
630 | clearPVID $pvid $nsdSubtype $nsdSubname $nodeName1 $nodeName2 |
---|
631 | rc=$? |
---|
632 | if [[ $rc -ne 0 ]] |
---|
633 | then |
---|
634 | # tspreparedisk failed and we have no other nodes to try. |
---|
635 | # Tell the guy what to do. |
---|
636 | # The NSD volume id was not erased from the disk. |
---|
637 | if [[ $rc -eq $MM_DeviceNotFound ]] |
---|
638 | then |
---|
639 | # The disk with the specified NSD volume id was not found. |
---|
640 | printErrorMsg 397 $mmcmd $pvid |
---|
641 | elif [[ -z $nodeName1 ]] |
---|
642 | then |
---|
643 | # Tell the user to issue "mmdelnsd -p <pvid>" |
---|
644 | # to delete the disk. |
---|
645 | if [[ $diskName = $UNKNOWN ]] |
---|
646 | then |
---|
647 | printErrorMsg 247 $mmcmd $pvid $pvid |
---|
648 | else |
---|
649 | printErrorMsg 488 $mmcmd $diskName $pvid |
---|
650 | fi |
---|
651 | else |
---|
652 | # Tell the user to issue "mmdelnsd -p <pvid> -N <nodeList>" |
---|
653 | # to delete the disk. |
---|
654 | [[ -n $nodeName2 ]] && nodeName1="${nodeName1},${nodeName2}" |
---|
655 | if [[ $diskName = $UNKNOWN ]] |
---|
656 | then |
---|
657 | printErrorMsg 248 $mmcmd $pvid $pvid $nodeName1 |
---|
658 | else |
---|
659 | printErrorMsg 489 $mmcmd $diskName $pvid $nodeName1 |
---|
660 | fi |
---|
661 | fi # end of if [[ -z $nodeName1 ]] |
---|
662 | fi # end of if [[ $rc -ne 0 ]] |
---|
663 | |
---|
664 | fi # end of if [[ -z $nodeName1 ]] |
---|
665 | |
---|
666 | fi # end of if [[ $rc -ne 0 ]] |
---|
667 | |
---|
668 | done # end of while read -u3 diskLine |
---|
669 | |
---|
670 | fi # end of if [[ -s $PVIDsToDelete ]] |
---|
671 | |
---|
672 | |
---|
673 | #################################################################### |
---|
674 | # Asynchronously propagate the sdrfs file to the rest of the nodes |
---|
675 | # if there were any changes made. |
---|
676 | # Any nodes that are unreachable now will pick up the changes the |
---|
677 | # next time GPFS is started or some other mm command is executed. |
---|
678 | #################################################################### |
---|
679 | [[ -n $deletedDisks ]] && \ |
---|
680 | propagateSdrfsFile async $nodefile $newsdrfs $newGenNumber rereadnsd |
---|
681 | |
---|
682 | |
---|
683 | ################################################### |
---|
684 | # If installed, invoke the syncfsconfig user exit. |
---|
685 | ################################################### |
---|
686 | if [[ -x $syncfsconfig && -n $deletedDisks ]] |
---|
687 | then |
---|
688 | print -- "$mmcmd: Starting $syncfsconfig ..." |
---|
689 | $syncfsconfig |
---|
690 | print -- "$mmcmd: $syncfsconfig finished." |
---|
691 | fi |
---|
692 | |
---|
693 | cleanupAndExit 0 |
---|
694 | |
---|