source: gpfs_3.1_ker2.6.20/lpp/mmfs/bin/mmdelfileset @ 148

Last change on this file since 148 was 16, checked in by rock, 17 years ago
  • Property svn:executable set to *
File size: 5.7 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. 2005,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# @(#)43 1.5.1.1 src/avs/fs/mmfs/ts/admin/mmdelfileset.sh, mmfs, avs_rgpfs24, rgpfs24s007a 10/18/06 12:02:58
17#########################################################################
18#
19# Usage:
20#   mmdelfileset Device FilesetName [-f]
21#
22# where:
23#   Device        is the device name of the file system.
24#   FilesetName   is the fileset name.
25#   -f            deletes the contents of the filesets and unlinks
26#                   any child filesets prior to deleting the fileset.
27#
28#########################################################################
29
30# Include global declarations and service routines.
31. /usr/lpp/mmfs/bin/mmglobfuncs
32. /usr/lpp/mmfs/bin/mmsdrfsdef
33. /usr/lpp/mmfs/bin/mmfsfuncs
34
35sourceFile="mmdelfileset.sh"
36[[ -n $DEBUG || -n $DEBUGmmdelfileset ]] && set -x
37$mmTRACE_ENTER "$*"
38
39# Local work files.  Names should be of the form:
40#   fn=${tmpDir}fn.${mmcmd}.$$
41
42LOCAL_FILES=" "
43
44
45# Local variables
46usageMsg=517
47
48
49# Local functions
50
51
52
53#######################
54# Mainline processing
55#######################
56
57
58#######################################
59# Process the command line arguments.
60#######################################
61[[ $arg1 = '-?' || $arg1 = '-h' || $arg1 = '--help' || $arg1 = '--' ]] &&  \
62  syntaxError "help" $usageMsg
63
64[[ $argc -lt 2  ]] &&  \
65  syntaxError "missingArgs" $usageMsg
66
67# The first argument is always the file system name.
68device=$arg1
69deviceName=${device##+(/)dev+(/)}  # name stripped of /dev/ prefix
70fqDeviceName="/dev/$deviceName"    # fully-qualified name (with /dev/ prefix)
71
72# The second argument is always the fileset name.
73filesetName=$arg2
74checkName filesetName 255 "$filesetName"
75[[ $? -ne 0 ]] && cleanupAndExit
76
77# Move past the positional parameters.
78shift 2
79
80# Process the rest of the parameters.
81while getopts :f OPT
82do
83  case $OPT in
84    f) # Delete the contents of the fileset.
85       [[ -n $fflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
86       fflag="-$OPT"
87       ;;
88    +[f]) # Invalid option.
89       syntaxError "invalidOption" $usageMsg $OPT
90       ;;
91    :) # Missing argument.
92       syntaxError "missingValue" $usageMsg $OPTARG
93       ;;
94    *) # Invalid option.
95       syntaxError "invalidOption" $usageMsg $OPTARG
96       ;;
97  esac
98done  # end of while getopts :t OPT do
99shift OPTIND-1
100
101[[ $# != 0 ]] && syntaxError "extraArg" $usageMsg $1
102
103
104######################################################################
105# Set up trap exception handling and ensure that the local copy of
106# the mmsdrfs file is up-to-date.  There is no need to lock the file.
107######################################################################
108trap pretrap2 HUP INT QUIT KILL
109gpfsInitOutput=$(gpfsInit nolock)
110setGlobalVar $? $gpfsInitOutput
111
112
113###########################################################
114# Make sure the specified file system exists and is local.
115###########################################################
116findFSoutput=$(findFS "$device" $mmsdrfsFile)
117[[ -z $findFSoutput ]] && cleanupAndExit
118
119# Parse the output from the findFS function.
120set -f ; set -- $findFSoutput ; set +f
121fqDeviceName=$1
122deviceName=$2
123fsHomeCluster=$3
124
125# Exit if the command was invoked for a remote file system.
126if [[ $fsHomeCluster != $HOME_CLUSTER ]]
127then
128  # Command is not allowed for remote file systems.
129  printErrorMsg 106 $mmcmd $device $fsHomeCluster
130  cleanupAndExit
131fi
132
133
134########################################################################
135# Invoke the tsdelfileset command on the local node.
136# Display any error messages and exit if any of the following are true:
137#   - the command completed successfully
138#   - there is an unacceptable error
139#       (anything other than daemon down or quorum wait)
140#   - the fileset name contains path name expansion triggers
141#   - this is a single node cluster
142########################################################################
143$tsdelfileset $fqDeviceName "$filesetName" $fflag 2>$errMsg
144rc=$(remapRC $?)
145if [[ $rc -ne $MM_DaemonDown && $rc -ne $MM_QuorumWait ||
146      $MMMODE = single ]]
147then
148  if [[ $rc -eq $MM_DaemonDown ]]
149  then
150    # GPFS is down on this node.
151    printErrorMsg 109 $mmcmd
152  elif [[ $rc -eq $MM_QuorumWait ]]
153  then
154    # GPFS is not ready for commands.
155    printErrorMsg 110 $mmcmd
156  elif [[ $rc -eq $MM_ConnectionReset ]]
157  then
158    # An internode connection was reset.
159    printErrorMsg 257 $mmcmd
160  else
161    # Either the command worked, or it is an unexpected error.
162    [[ -s $errMsg ]] && $cat $errMsg 1>&2
163#   [[ $rc -ne 0 ]] && printErrorMsg 113 "$mmcmd" "tsdelfileset" $rc
164  fi  # end of if [[ $rc -eq $MM_FsNotFound ]]
165  cleanupAndExit $rc
166fi  # end of if [[ ($rc -ne $MM_DaemonDown && ... ]]
167$rm -f $errMsg
168
169
170#####################################################################
171# We come here if the local GPFS daemon is not ready for commands.
172# Find an active node and send the command there.
173#####################################################################
174
175# Create a file with the reliable names of the nodes in the cluster.
176getNodeList $REL_HOSTNAME_Field $GLOBAL_ID $mmsdrfsFile > $nodefile
177preferredNode=$ourNodeName
178
179# Try the nodes one by one until you find a node that can execute the command.
180$mmcommon onactive $preferredNode $nodefile     \
181   $NO_FILE_COPY $NO_MOUNT_CHECK NULL $NO_LINK  \
182   tsdelfileset "$fqDeviceName $filesetName $fflag"
183rc=$?
184
185# if [[ $rc -ne 0 ]]
186# then
187#   # tsdelfileset failed.
188#   printErrorMsg 104 $mmcmd tsdelfileset
189#   cleanupAndExit $rc
190# fi
191
192cleanupAndExit $rc
193
Note: See TracBrowser for help on using the repository browser.