#!/bin/ksh # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # # # Licensed Materials - Property of IBM # # (C) COPYRIGHT International Business Machines Corp. 2005,2006 # All Rights Reserved # # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # # IBM_PROLOG_END_TAG # @(#)46 1.9.1.1 src/avs/fs/mmfs/ts/admin/mmunlinkfileset.sh, mmfs, avs_rgpfs24, rgpfs24s007a 10/18/06 12:03:01 ############################################################################### # # Usage: # mmunlinkfileset Device {FilesetName | -J JunctionPath} [-f] # # where: # Device is the device name of the file system. # FilesetName is the fileset name. # JunctionPath is the fileset junction path name. # -f forcibly closes any open files and unlinks the fileset. # # Undocumented option: # -a unlink the fileset from all of its snapshots in the # top-level snapshot directories. # ############################################################################### # Include global declarations and service routines. . /usr/lpp/mmfs/bin/mmglobfuncs . /usr/lpp/mmfs/bin/mmsdrfsdef . /usr/lpp/mmfs/bin/mmfsfuncs sourceFile="mmunlinkfileset.sh" [[ -n $DEBUG || -n $DEBUGmmunlinkfileset ]] && set -x $mmTRACE_ENTER "$*" # Local work files. Names should be of the form: # fn=${tmpDir}fn.${mmcmd}.$$ LOCAL_FILES=" " # Local variables usageMsg=516 # Local functions ####################### # Mainline processing ####################### ####################################### # Process the command line arguments. ####################################### [[ $arg1 = '-?' || $arg1 = '-h' || $arg1 = '--help' || $arg1 = '--' ]] && \ syntaxError "help" $usageMsg [[ $argc -lt 2 ]] && \ syntaxError "missingArgs" $usageMsg # The first argument is always the file system name. device=$arg1 deviceName=${device##+(/)dev+(/)} # name stripped of /dev/ prefix fqDeviceName="/dev/$deviceName" # fully-qualified name (with /dev/ prefix) # The device name must be followed by a fileset name or -J and a junction path. if [[ $arg2 = "-J"* ]] then junctionName=${arg2#-J} if [[ -z $junctionName ]] then [[ $argc -lt 3 ]] && syntaxError "missingArgs" $usageMsg junctionName=$arg3 shift 3 else shift 2 fi else filesetName=$arg2 [[ $arg3 = "-J"* ]] && \ syntaxError "invalidCombination" $usageMsg "-J" "FilesetName" checkName filesetName 255 "$filesetName" [[ $? -ne 0 ]] && cleanupAndExit shift 2 fi # Process the rest of the parameters. while getopts :af OPT do case $OPT in a) # Unlink from all snapshots. [[ -n $aflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT" aflag="-$OPT" ;; f) # Close all files. [[ -n $fflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT" fflag="-$OPT" ;; +[af]) # Invalid option. syntaxError "invalidOption" $usageMsg $OPT ;; :) # Missing argument. syntaxError "missingValue" $usageMsg $OPTARG ;; *) # Invalid option. syntaxError "invalidOption" $usageMsg $OPTARG ;; esac done # end of while getopts :af OPT do shift OPTIND-1 [[ $# != 0 ]] && syntaxError "extraArg" $usageMsg $1 ##################################################################### # Set up trap exception handling and ensure that the local copy of # the mmsdrfs is up-to-date. There is no need to lock the mmsdrfs. ##################################################################### trap pretrap2 HUP INT QUIT KILL gpfsInitOutput=$(gpfsInit nolock) setGlobalVar $? $gpfsInitOutput ########################################################### # Make sure the specified file system exists and is local. ########################################################### findFSoutput=$(findFS "$device" $mmsdrfsFile) [[ -z $findFSoutput ]] && cleanupAndExit # Parse the output from the findFS function. set -f ; set -- $findFSoutput ; set +f fqDeviceName=$1 deviceName=$2 fsHomeCluster=$3 # Exit if the command was invoked for a remote file system. if [[ $fsHomeCluster != $HOME_CLUSTER ]] then # Command is not allowed for remote file systems. printErrorMsg 106 $mmcmd $device $fsHomeCluster cleanupAndExit fi ############################# # Verify the junction name. ############################# if [[ -n $junctionName ]] then # The file system must be mounted. mountPoint=$(findMountpoint $deviceName) if [[ -z $mountPoint ]] then # File system is not mounted. printErrorMsg 552 $mmcmd $device cleanupAndExit fi # Find the device ID of the mounted GPFS file system. gpfsDeviceID=$($perl -e '($dev) = stat "'$mountPoint'"; printf "%u", $dev;') # Ensure the junction path name is fully qualified. [[ $junctionName != /* ]] && junctionName="${PWD%/}/${junctionName}" junctionName=${junctionName%%/} # Strip any trailing slashes. # Find the device ID and inode number of the junction. # The result is a colon-separated device and inode numbers. junctionDevAndIno=$($perl -e ' ($dev,$ino) = stat "'$junctionName'"; if ($dev ne "") { printf "%u:%u", $dev,$ino }') # The junction must be within the mounted file system. if [[ $gpfsDeviceID != ${junctionDevAndIno%:*} ]] then printErrorMsg 550 $mmcmd "$junctionName" "$device" cleanupAndExit fi # Create the extended junction path name. junctionName="-J /GPFS:${junctionDevAndIno#*:}${junctionName}" fi # end of if [[ -n $junctionName ]] ######################################################################## # Invoke the tsunlinkfileset command on the local node. # Display any error messages and exit if any of the following are true: # - the command completed successfully # - a junction path name is specified # - there is an unacceptable error # (anything other than daemon down or quorum wait) # - the fileset name contains path name expansion triggers # - this is a single node cluster ######################################################################## set -f $tsunlinkfileset $fqDeviceName $filesetName $junctionName $aflag $fflag 2>$errMsg rc=$(remapRC $?) set +f if [[ $rc -ne $MM_DaemonDown && $rc -ne $MM_QuorumWait || -n $junctionName || $MMMODE = single ]] then if [[ $rc -eq $MM_DaemonDown ]] then # GPFS is down on this node. printErrorMsg 109 $mmcmd elif [[ $rc -eq $MM_QuorumWait ]] then # GPFS is not ready for commands. printErrorMsg 110 $mmcmd elif [[ $rc -eq $MM_ConnectionReset ]] then # An internode connection was reset. printErrorMsg 257 $mmcmd else # Either the command worked, or it is an unexpected error. [[ -s $errMsg ]] && $cat $errMsg 1>&2 # [[ $rc -ne 0 ]] && printErrorMsg 113 "$mmcmd" "tsunlinkfileset" $rc fi # end of if [[ $rc -eq $MM_FsNotFound ]] cleanupAndExit $rc fi # end of if [[ ($rc -ne $MM_DaemonDown && ... ]] $rm -f $errMsg #################################################################### # We come here if the local GPFS daemon is not ready for commands. # Find an active node and send the command there. #################################################################### # Create a file with the reliable names of the nodes in the cluster. getNodeList $REL_HOSTNAME_Field $GLOBAL_ID $mmsdrfsFile > $nodefile preferredNode=$ourNodeName # Try the nodes one by one until you find a node that can execute the command. $mmcommon onactive $preferredNode $nodefile \ $NO_FILE_COPY $NO_MOUNT_CHECK NULL $NO_LINK \ tsunlinkfileset "$fqDeviceName $filesetName $aflag $fflag" rc=$? # if [[ $rc -ne 0 ]] # then # # tsunlinkfileset failed. # printErrorMsg 104 $mmcmd tsunlinkfileset # cleanupAndExit $rc # fi cleanupAndExit $rc