source: gpfs_3.1_ker2.6.20/lpp/mmfs/bin/mmvaryonvg @ 152

Last change on this file since 152 was 16, checked in by rock, 17 years ago
  • Property svn:executable set to *
File size: 6.1 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. 2003,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# @(#)24 1.16 src/avs/fs/mmfs/ts/admin/mmvaryonvg.sh, mmfs, avs_rgpfs24, rgpfs240610b 12/9/05 09:56:42
17###################################################################
18#
19#  Usage:
20#    mmvaryonvg [diskName]
21#
22#  If diskName is passed, find the file system to which the disk
23#  belongs and activate all disks that belong to that file system.
24#  Otherwise, activate all disks in all file systems in the nodeset.
25#
26#  This script is used by the daemon's devOpen() function when
27#  a disk cannot be opened.
28#
29#  The script is a no-op in Linux.
30#  The script should not be used for VSD type disks.
31#
32###################################################################
33
34# Include global declarations and service routines.
35. /usr/lpp/mmfs/bin/mmglobfuncs
36. /usr/lpp/mmfs/bin/mmsdrfsdef
37. /usr/lpp/mmfs/bin/mmfsfuncs
38
39[[ -n $DEBUG || -n $DEBUGmmvaryonvg ]] && set -x
40$mmTRACE_ENTER "$*"
41
42diskName=""
43fsName=""
44integer found=0
45
46
47#######################################################################
48#                                                                     #
49# This function activates a volume group when disk leasing is in use. #
50#                                                                     #
51#######################################################################
52function activateVg
53{
54  typeset vgname=$1
55
56  # Activate the disk.
57  $varyonvg -u $vgname
58  if [[ $? = 0 ]]
59  then
60    # The varyon of the volume group succeeded.
61    printErrorMsg 520 $mmcmd "$(date)" $vgname
62  else
63    # We were unable to varyon the volume group.
64    printErrorMsg 535 $mmcmd "$(date)" $vgname
65  fi
66
67}    # ---- end of function activateVg ----------
68
69
70#####################################################################
71#
72# Main function
73#
74#####################################################################
75
76# Get disk name from input, if any.
77diskName=$arg1
78
79# Set up trap exception handling.
80trap pretrap2 HUP INT QUIT KILL
81
82# Get the node number for this node.
83[[ -z $MMMODE ]] && determineMode
84getLocalNodeData
85
86# This function is not needed in Linux.
87[[ $osName = Linux ]] &&  \
88  cleanupAndExit 0
89
90# Get a list containing the physical disk name, pvid, and vgname
91# for all known volume groups on this node.
92LC_ALL=C $lspv > $volGroupFile
93
94# Get the name of the filesystem to which the disk belongs.
95if [[ -n $diskName ]]
96then
97  fsName=$($mmcommon getSGDevice $diskName)
98fi
99
100# Create a temp file containing the disks (along with their
101# types, subtypes, pvids, and name sources) to be varied on.
102getDiskData $tmpfile $fsName
103
104
105exec 3<&-
106exec 3< $tmpfile
107while read -u3 diskLine
108do
109  # Extract the lvname, disk type, disk subtype, pvid, name source,
110  # and underlying lv name (if applicable) for each disk.
111  IFS=':'
112  set -f ; set -- $diskLine ; set +f
113  lvname=$1
114  diskType=$2
115  diskSubtype=$3
116  pvid=$4
117  nameSource=$5
118  nsdSubtype=$6
119  nsdSubtypeDiskname=$7
120  IFS="$IFS_sv"
121
122  # If the underlying disk is not a logical volume, skip it.
123  [[ $nsdSubtype != lv ]] && continue
124
125  # This is an nsd with an underlying logical volume;
126  # use that logical volume name.
127  [[ -n $nsdSubtypeDiskname ]] && lvname=$nsdSubtypeDiskname
128
129  # Try to determine the vg name for this logical volume.
130  vgname=""
131  if [[ $nameSource = $userSpecified ]]
132  then
133    # The disk name was specified by the user; in this case,
134    # obtain the vgname by appending "vg" to the lvname.
135    vgname=${lvname}vg
136  elif [[ $lvname = gpfs*lv ]]
137  then
138    # The disk name appears to have been created by mmcrlv;
139    # obtain the vgname by changing the "lv" suffix to "vg".
140    vgname=${lvname%lv}vg
141  else
142    # The disk was not created by mmcrlv;
143    # try to obtain the vgname by using the lslv command.
144    vgname=$(LC_ALL=C $lslv -L $lvname 2>/dev/null | $awk '/VOLUME GROUP:/ {print $6}')
145  fi
146
147  # If the vg name is not known, skip the disk.
148  # Note that further down we will try one more time to process the input disk.
149  if [[ -z $vgname ]]
150  then
151    [[ $diskName != $lvname ]] &&  \
152      printErrorMsg 547 $mmcmd $lvname $ourNodeName
153    continue
154  fi
155
156  # If the disk is not known on this node, try to import it.
157  lspvLine=$($grep -w $vgname $volGroupFile)
158  if [[ $? = 1 ]]
159  then
160    importDisk $lvname $vgname $pvid $volGroupFile
161    # If we couldn't make the disk known on this node, skip to the next disk.
162    if [[ $? = 1 ]]
163    then
164      printErrorMsg 547 $mmcmd $lvname $ourNodeName
165      continue
166    fi
167    lspvLine=$($grep -w $vgname $volGroupFile)
168  fi
169
170  # Use the lslv command to check whether the volume group is active or not.
171  vgstate=$(LC_ALL=C $lslv -L $lvname 2>/dev/null |  \
172     $awk '/VG STATE:/ { {split($3,state,"/")} {print state[1]} }')
173
174  [[ $diskName = $lvname ]] && found=1
175
176  # Activate the volume group if needed.
177  [[ $vgstate != "active" ]] && activateVg $vgname
178done
179
180# If a disk was passed but it was not found in the mmsdrfs file,
181# then try to activate that disk also.  We will not be able to handle
182# the case where the disk has not been imported yet, since we have no way
183# to obtain the pvid of the disk if it is not listed in the mmsdrfs file.
184if [[ -n $diskName && $found = 0 ]]
185then
186  # Determine the name of the volume group and whether it is active or not.
187  lslvLine=$(LC_ALL=C $lslv -L $diskName 2>/dev/null | \
188    $awk '                                            \
189      /VOLUME GROUP:/  { group = $6 }                 \
190      /VG STATE:/      { split($3, state, "/") }      \
191      END              { print group " " state[1] }   \
192    ')
193  set -f ; set -- $lslvLine ; set +f
194  vgname=$1
195  vgstate=$2
196  if [[ -n $vgstate ]]
197  then
198    # Activate the volume group if needed.
199    [[ $vgstate != "active" ]] && activateVg $vgname
200  else
201    print -u2 "Disk $diskName is not known on node $ourNodeName."
202  fi  # end if [[ -n $vgstate ]]
203fi  # end if [[ -n $diskName && $found = 0 ]]
204
205# Always return zero.
206cleanupAndExit 0
207
Note: See TracBrowser for help on using the repository browser.