source: gpfs_3.1_ker2.6.20/lpp/mmfs/bin/mmrestorefs @ 134

Last change on this file since 134 was 16, checked in by rock, 17 years ago
  • Property svn:executable set to *
File size: 4.2 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. 2001,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# @(#)73 1.13 src/avs/fs/mmfs/ts/admin/mmrestorefs.sh, mmfs, avs_rgpfs24, rgpfs240610b 11/15/04 02:35:50
17#######################################################################
18#
19#  Usage:  mmrestorefs Device Directory
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="mmrestorefs.sh"
29[[ -n $DEBUG || -n $DEBUGmmrestorefs ]] && set -x
30$mmTRACE_ENTER "$*"
31
32usageMsg=419
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 ensure that the local copy of
55# the mmsdrfs is up-to-date.  There is no need to lock mmsdrfs file.
56#####################################################################
57trap pretrap2 HUP INT QUIT KILL
58gpfsInitOutput=$(gpfsInit nolock)
59setGlobalVar $? $gpfsInitOutput
60
61
62###########################################################
63# Make sure the specified file system exists and is local.
64###########################################################
65findFSoutput=$(findFS "$device" $mmsdrfsFile)
66[[ -z $findFSoutput ]] && cleanupAndExit
67
68# Parse the output from the findFS function.
69set -f ; set -- $findFSoutput ; set +f
70fqDeviceName=$1
71deviceName=$2
72fsHomeCluster=$3
73
74# Exit with a message if the command was invoked for a remote file system.
75if [[ $fsHomeCluster != $HOME_CLUSTER ]]
76then
77  # Command is not allowed for remote file systems.
78  printErrorMsg 106 $mmcmd $device $fsHomeCluster
79  cleanupAndExit 1
80fi
81
82
83##########################################################
84# If the cluster to which this node belongs is the same
85# as the cluster in which the file system resides,
86# invoke the command directly.
87##########################################################
88if [[ $nsId = $fsHomeCluster ]]
89then
90  ${mmcmdDir}/${links}/mmrestorefs $fqDeviceName $argList 2>$errMsg
91  rc=$(remapRC $?)
92
93  # If the command completed successfully, or if there is an
94  # unacceptable error, display any error messages and get out.
95  if [[ $rc -ne $MM_DaemonDown && $rc -ne $MM_QuorumWait ]]
96  then
97    [[ -s $errMsg ]] && $cat $errMsg 1>&2
98    if [[ $rc -eq $MM_ConnectionReset ]]
99    then
100      # An internode connection was reset.
101      printErrorMsg 257 $mmcmd
102    fi
103    cleanupAndExit $rc
104  fi
105fi
106$rm -f $errMsg
107
108
109############################################################################
110# If the local daemon is not available, send the command to an active node.
111############################################################################
112
113# Create a file with the reliable names that form the
114# cluster to which the file system belongs.
115nodeCount=$(getNodeFile $REL_HOSTNAME_Field $fsHomeCluster $mmsdrfsFile $nodefile)
116if [[ $nodeCount -eq 0 ]]
117then
118  # The cluster is empty; there is nobody to run the command.
119  printErrorMsg 171 $mmcmd "getNodeFile (nodeCount=0)" 1
120  cleanupAndExit
121fi
122
123# Try the nodes one by one until you find a node that can execute the command.
124preferredNode=0     # We have no idea where to go first; let mmcommon decide.
125$mmcommon linkCommand $preferredNode $nodefile mmrestorefs $fqDeviceName $argList
126rc=$?
127
128cleanupAndExit $rc
129
Note: See TracBrowser for help on using the repository browser.