source: gpfs_3.1_ker2.6.20/lpp/mmfs/bin/mmdefragfs @ 223

Last change on this file since 223 was 16, checked in by rock, 17 years ago
  • Property svn:executable set to *
File size: 4.2 KB
RevLine 
[16]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,2004
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# @(#)80 1.26 src/avs/fs/mmfs/ts/admin/mmdefragfs.sh, mmfs, avs_rgpfs24, rgpfs240610b 11/15/04 02:34:50
17#######################################################################
18#
19#  Usage:  mmdefragfs Device [-i] [-v] [-u BlkUtilPct]
20#
21#######################################################################
22
23# Include global declarations and service routines.
24. /usr/lpp/mmfs/bin/mmglobfuncs
25. /usr/lpp/mmfs/bin/mmsdrfsdef
26. /usr/lpp/mmfs/bin/mmfsfuncs
27
28sourceFile="mmdefragfs.sh"
29[[ -n $DEBUG || -n $DEBUGmmdefragfs ]] && set -x
30$mmTRACE_ENTER "$*"
31
32usageMsg=299
33integer rc=0
34integer nodeCount=0
35
36
37#####################################################################
38# Process the command arguments.
39# The detailed syntax checking is left for the ts command.
40# Here we make sure that we have the minimum needed to continue.
41#####################################################################
42[[ $arg1 = '-?' || $arg1 = '-h' || $arg1 = '--help' || $arg1 = '--' ]] && \
43  syntaxError "help" $usageMsg
44
45[[ $argc -lt 1  ]] && \
46  syntaxError "missingArgs" $usageMsg
47
48device=$arg1     # Save stripe group device (always the first parameter).
49shift 1          # Drop the device name from the parameter list.
50argList=$@       # Save the remainder of the argument list.
51
52
53########################################################################
54# Set up trap exception handling and call the gpfsInit function.
55# It will ensure that the local copy of the mmsdrfs and the rest of the
56# GPFS system files are up-to-date.  There is no need to lock the sdr.
57########################################################################
58trap pretrap2 HUP INT QUIT KILL
59gpfsInitOutput=$(gpfsInit nolock)
60setGlobalVar $? $gpfsInitOutput
61
62
63###########################################################
64# Make sure the specified file system exists and is local.
65###########################################################
66findFSoutput=$(findFS "$device" $mmsdrfsFile)
67[[ -z $findFSoutput ]] && cleanupAndExit
68
69# Parse the output from the findFS function.
70set -f ; set -- $findFSoutput ; set +f
71fqDeviceName=$1
72deviceName=$2
73fsHomeCluster=$3
74
75# Exit with a message if the command was invoked for a remote file system.
76if [[ $fsHomeCluster != $HOME_CLUSTER ]]
77then
78  # Command is not allowed for remote file systems.
79  printErrorMsg 106 $mmcmd $device $fsHomeCluster
80  cleanupAndExit 1
81fi
82
83
84##########################################################
85# If the cluster to which this node belongs is the same
86# as the cluster in which the file system resides,
87# invoke the command directly.
88##########################################################
89if [[ $nsId = $fsHomeCluster ]]
90then
91  ${mmcmdDir}/${links}/mmdefragfs $fqDeviceName $argList
92  rc=$(remapRC $?)
93
94  # If the command completed successfully, or if there is an
95  # unacceptable error, display any error messages and get out.
96  if [[ $rc -ne $MM_DaemonDown && $rc -ne $MM_QuorumWait ]]
97  then
98    [[ -s $errMsg ]] && $cat $errMsg 1>&2
99    if [[ $rc -eq $MM_ConnectionReset ]]
100    then
101      # An internode connection was reset.
102      printErrorMsg 257 $mmcmd
103    fi
104    cleanupAndExit $rc
105  fi
106fi
107$rm -f $errMsg
108
109
110###################################################
111# Find an active node and send the command there.
112###################################################
113
114# Create a file with the reliable names that form
115# the cluster to which the file system belongs.
116nodeCount=$(getNodeFile $REL_HOSTNAME_Field $fsHomeCluster $mmsdrfsFile $nodefile)
117if [[ $nodeCount -eq 0 ]]
118then
119  # The nodeset is empty; there is nobody to run the command.
120  printErrorMsg 171 $mmcmd "getNodeFile (nodeCount=0)" 1
121  cleanupAndExit
122fi
123
124# Try the nodes one by one until you find a node that can execute the command.
125preferredNode=0     # We have no idea where to go first; let mmcommon decide.
126$mmcommon linkCommand $preferredNode $nodefile mmdefragfs $fqDeviceName $argList
127rc=$?
128
129cleanupAndExit $rc
130
Note: See TracBrowser for help on using the repository browser.