source: gpfs_3.1_ker2.6.20/lpp/mmfs/bin/mmlsmount @ 108

Last change on this file since 108 was 16, checked in by rock, 17 years ago
  • Property svn:executable set to *
File size: 8.6 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. 2005,2007
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# @(#)41 1.4.1.2 src/avs/fs/mmfs/ts/admin/mmlsmount.sh, mmfs, avs_rgpfs24, rgpfs24s011a 3/28/07 19:15:31
17##############################################################################
18#
19#  Display how many nodes have a given GPFS file system mounted,
20#  and optionally list the nodes that have the file system mounted.
21#
22#  Usage:
23#
24#    mmlsmount {Device | all | all_local | all_remote} [-L]
25#              [-C {all | all_remote | ClusterName[,ClusterName...]}]
26#
27#  where:
28#
29#    Device | all | all_local | all_remote
30#       specifies the device(s) for which mount information is sought.
31#       all denotes "all file systems known to this cluster".
32#       all_local denotes "all file systems owned by this cluster".
33#       all_remote denotes "all file systems not owned by this cluster".
34#
35#    -C {all | all_remote | ClusterName[,ClusterName...]}
36#       specifies the clusters for which mount information is requested.
37#       If one or more ClusterName is specified, only the names of nodes
38#       that belong to these clusters and have the file system mounted
39#       will be displayed.  The dot character (".") can be used in place
40#       of the cluster name to denote the local cluster.
41#
42#       -C all_remote denotes all clusters other than the one from which
43#       the command is ussued (this cluster).
44#
45#       -C all refers to all clusters, local and remote, that can have
46#       the file system mounted.  -C all is the default.
47#
48#    -L specifies "list the nodes that have the device(s) mounted".
49#
50#  Note:
51#    If invoked by a non-root user, the command is executed on the local
52#    node "as-is".  In particular, the local configuration information may
53#    not be up-to-date.  There is no attempt to find an active GPFS daemon
54#    on another node.  Non-root users are not allowed to invoke commands on
55#    other nodes.
56#
57##############################################################################
58
59# Include global declarations and service routines.
60. /usr/lpp/mmfs/bin/mmglobfuncs
61if [[ $ourUid -eq 0 ]]
62then
63  . /usr/lpp/mmfs/bin/mmsdrfsdef
64  . /usr/lpp/mmfs/bin/mmfsfuncs
65fi
66
67sourceFile="mmlsmount.sh"
68[[ -n $DEBUG || -n $DEBUGmmlsmount ]] && set -x
69$mmTRACE_ENTER "$*"
70
71# Local work files.  Names should be of the form:
72#   fn=${tmpDir}fn.${mmcmd}.$$
73
74LOCAL_FILES=" "
75
76
77# Local variables
78
79usageMsg=540
80rc=0
81Lflag=""
82
83
84
85#######################
86# Mainline processing
87#######################
88
89
90##################################
91# Process each of the arguments.
92##################################
93[[ $arg1 = '-?' || $arg1 = '-h' || $arg1 = '--help' || $arg1 = '--' ]] &&  \
94  syntaxError "help" $usageMsg
95
96[[ $argc -lt 1  ]] &&  \
97  syntaxError "missingArgs" $usageMsg
98
99device=$arg1                       # Save the file system device name.
100deviceName=${device##+(/)dev+(/)}  # Name stripped of /dev/ prefix.
101shift 1                            # Drop the name from the parameter list.
102
103while getopts :C:LY OPT
104do
105  case $OPT in
106
107    C) [[ -n $Cflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
108       Cflag="-$OPT"
109       clusterList="$OPTARG"
110       ;;
111
112    L) [[ -n $Lflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
113       Lflag=yes
114       ;;
115
116    Y) [[ -n $Yflag ]] && syntaxError "multiple" $noUsageMsg "-$OPT"
117       Yflag=yes
118       ;;
119
120    :) syntaxError "missingValue" $usageMsg $OPTARG
121       ;;
122
123    +[CLY])
124       syntaxError "invalidOption" $usageMsg "$OPT"
125       ;;
126
127    *) syntaxError "invalidOption" $usageMsg $OPTARG
128       ;;
129
130  esac
131done
132
133shift OPTIND-1
134[[ $# != 0 ]] && syntaxError "extraArg" $usageMsg $1
135
136[[ -z $clusterList ]] && clusterList=NULL
137
138[[ -z $Lflag ]] && Lflag=no
139[[ -n $Yflag ]] && Lflag=unformatted
140
141
142###################################
143# Set up trap exception handling.
144###################################
145trap pretrap2 HUP INT QUIT KILL
146
147
148####################################################################
149# If invoked by a root user, call the gpfsInit function to ensure
150# that the local copy of the mmsdrfs file and the rest of the GPFS
151# system files are up-to-date.  There is no need to lock the sdr.
152# Non-root users are not allowed to invoke commands on other nodes.
153####################################################################
154if [[ $ourUid -eq 0 ]]
155then
156  gpfsInitOutput=$(gpfsInit nolock)
157  setGlobalVar $? $gpfsInitOutput
158fi
159
160
161###########################################################################
162# If device is one of the keywords (all, all_local, or all_remote), do not
163# do anything right now.  The list of file systems will be created by the
164# lsmount function.  Otherwise, ensure the specified file system exists
165# and create the fully-qualified name for the lsmount call.
166###########################################################################
167if [[ $device != all && $device != all_local && $device != all_remote ]]
168then
169  if [[ $device = *:* ]]
170  then
171    # If this is an explicit invocation for a remote file system,
172    # find out the home cluster and the local and remote device
173    # names for the file system.
174    IFS=":"
175    set -f ; set -- $device ; set +f
176    IFS="$IFS_sv"
177    fsHomeCluster=$1
178    remoteDevice=$2
179    localDevice=$($awk -F: '                                 \
180      $'$NODESETID_Field'       == "'$fsHomeCluster'"  &&    \
181      $'$LINE_TYPE_Field'       == "'$SG_HEADR'"       &&    \
182      $'$REMOTE_DEV_NAME_Field' == "'$remoteDevice'"   {     \
183        { print $'$DEV_NAME_Field' }                         \
184        { exit }                                             \
185      }                                                      \
186    ' $mmsdrfsFile)
187    checkForErrors awk $?
188
189    # Create the fully-qualified name for the lsmount call.
190    fsToShow="${fsHomeCluster}:${remoteDevice}:${localDevice}"
191
192  else
193    # If this a simple device name for a local or remote file system,
194    # find the needed information about the file system.
195    findFSoutput=$(findFS "$deviceName" $mmsdrfsFile)
196    [[ -z $findFSoutput ]] && cleanupAndExit
197
198    set -f ; set -- $findFSoutput ; set +f
199    localDevice=$2
200    fsHomeCluster=$3
201    remoteDevice=$4
202
203    # Create the fully-qualified name for the lsmount call.
204    if [[ $fsHomeCluster = $HOME_CLUSTER ]]
205    then
206      fsToShow=":${localDevice}:"
207    else
208      fsToShow="${fsHomeCluster}:${remoteDevice}:${localDevice}"
209    fi
210  fi  # end of if [[ $device = *:* ]]
211
212else
213  # Just pass the keyword to the lsmount function.
214  fsToShow=$device
215fi  # end of if [[ $device != all && $device != all_local ...
216
217
218################################################################
219# First, try to run the lsmount function on the local node.
220#
221# Note:  The lsmount invocation must be done in a subshell,
222#        by enclosing it in parens.  If this is not done,
223#        there will be left over work files in /var/mmfs/tmp.
224################################################################
225(lsmount "$fsToShow" "$clusterList" $Lflag norefresh 2>$errMsg2)
226rc=$?
227if [[ ($rc -ne $MM_DaemonDown && $rc -ne $MM_QuorumWait) ||
228      $ourUid -ne 0                                      ||
229      $MMMODE = single ]]
230then
231  if [[ $rc -eq $MM_DaemonDown ]]
232  then
233    # GPFS is down on this node.
234    printErrorMsg 109 $mmcmd
235  elif [[ $rc -eq $MM_QuorumWait ]]
236  then
237    # GPFS is not ready for commands.
238    printErrorMsg 110 $mmcmd
239  elif [[ $rc -eq $MM_ConnectionReset ]]
240  then
241    # An internode connection was reset.
242    printErrorMsg 257 $mmcmd
243  elif [[ $rc -ne 0 ]]
244  then
245    # Something else went wrong.
246    # Show error messages, if any.
247    [[ -s $errMsg2 ]] && $cat $errMsg2 1>&2
248  else
249    :  # The command must have worked.
250  fi  # end of if [[ $rc -eq $MM_DaemonDown ]]
251  cleanupAndExit $rc
252fi  # end of if [[ ($rc -ne $MM_DaemonDown && ... ]]
253$rm -f $errMsg2
254
255
256########################################################################
257# If GPFS is down on the local node, find a node with an active daemon.
258########################################################################
259# Create a file containing all of the nodes in the cluster.
260getNodeList $REL_HOSTNAME_Field $GLOBAL_ID $mmsdrfsFile > $nodefile
261
262# Ensure we have the proper credentials.
263[[ $getCredCalled = no ]] && getCred
264
265# Find out who has the file systems mounted.
266$mmcommon onactive $ourNodeName $nodefile        \
267    $NO_FILE_COPY $NO_MOUNT_CHECK NULL $NO_LINK  \
268    mmremote lsmount "$fsToShow" "$clusterList" $Lflag
269rc=$?
270
271cleanupAndExit $rc
272
Note: See TracBrowser for help on using the repository browser.