| 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. 2004,2005 | 
|---|
| 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 | # @(#)54 1.8 src/avs/fs/mmfs/ts/admin/mmdevdiscover.sh, mmfs, avs_rgpfs24, rgpfs240610b 8/8/05 19:09:02 | 
|---|
| 17 | ############################################################################## | 
|---|
| 18 | # | 
|---|
| 19 | # This script is invoked by GPFS to discover the disk devices on the | 
|---|
| 20 | # local machine that will subsequently be opened for NSD volume identifier | 
|---|
| 21 | # mapping.  We open each of the devices listed and examine sector 2 for a | 
|---|
| 22 | # volume identifier that correlates to a volume identifier recorded in our | 
|---|
| 23 | # configuration database.  If a match is found then this machine has local | 
|---|
| 24 | # access to the underlying NSD device and local I/O occurs through the local | 
|---|
| 25 | # device interface.  This script will also invoke | 
|---|
| 26 | # | 
|---|
| 27 | #   /var/mmfs/etc/nsddevices | 
|---|
| 28 | # | 
|---|
| 29 | # if it is supplied by the user.  If the nsddevices script exits with | 
|---|
| 30 | # a return code of zero, then no other disk discovery is performed. | 
|---|
| 31 | # If nsddevices does not exist, or returns with a non-zero return | 
|---|
| 32 | # code, then this script performs its normal disk discovery steps. | 
|---|
| 33 | # | 
|---|
| 34 | # The output from both this script and nsddevices is a number of lines | 
|---|
| 35 | # with the following format: | 
|---|
| 36 | # | 
|---|
| 37 | #   deviceName deviceType | 
|---|
| 38 | # | 
|---|
| 39 | # where | 
|---|
| 40 | #   deviceName is a device name ("hdisk1", "sda", etc.) | 
|---|
| 41 | #   deviceType is a known disk types. | 
|---|
| 42 | # | 
|---|
| 43 | # Known disk types currently are: | 
|---|
| 44 | # | 
|---|
| 45 | #   powerdisk  - EMC power path disk | 
|---|
| 46 | #   vpath      - IBM virtual path disk | 
|---|
| 47 | #   dlmfdrv    - Hitachi dlm | 
|---|
| 48 | #   hdisk      - AIX hard disk | 
|---|
| 49 | #   lv         - AIX logical volume.  Historical usage only. | 
|---|
| 50 | #                Not allowed as a new device to mmcrnsd. | 
|---|
| 51 | #   generic    - Device having no unique failover or multipathing | 
|---|
| 52 | #                characteristic (predominantly Linux devices). | 
|---|
| 53 | # | 
|---|
| 54 | # Example: | 
|---|
| 55 | # | 
|---|
| 56 | #   hdisk1  hdisk | 
|---|
| 57 | #   hdisk2  hdisk | 
|---|
| 58 | # | 
|---|
| 59 | ############################################################################## | 
|---|
| 60 |  | 
|---|
| 61 | # Include global declarations and service routines. | 
|---|
| 62 | . /usr/lpp/mmfs/bin/mmglobfuncs | 
|---|
| 63 |  | 
|---|
| 64 | sourceFile="mmdevdiscover.sh" | 
|---|
| 65 | [[ -n $DEBUG || -n $DEBUGmmdevdiscover ]] && set -x | 
|---|
| 66 | $mmTRACE_ENTER "$*" | 
|---|
| 67 |  | 
|---|
| 68 | # Change this if you want stderr to go elsewhere. | 
|---|
| 69 | STDERR=/dev/null | 
|---|
| 70 |  | 
|---|
| 71 |  | 
|---|
| 72 | ######################################################## | 
|---|
| 73 | # Invoke the nsddevices user exit, if it was activated. | 
|---|
| 74 | # If the script exits with a zero return code then we | 
|---|
| 75 | # use it exclusively and will not do anything more. | 
|---|
| 76 | # If nsddevices does not exist, or if it returns with | 
|---|
| 77 | # a non-zero return code, then we will perform normal | 
|---|
| 78 | # GPFS disk discovery. | 
|---|
| 79 | ######################################################## | 
|---|
| 80 | if [[ -x $nsddevices ]] | 
|---|
| 81 | then | 
|---|
| 82 | $nsddevices | 
|---|
| 83 | [[ $? -eq 0 ]] && cleanupAndExit 0 | 
|---|
| 84 | fi | 
|---|
| 85 |  | 
|---|
| 86 |  | 
|---|
| 87 | ################################################## | 
|---|
| 88 | # Perform the normal GPFS disk discovery process. | 
|---|
| 89 | ################################################## | 
|---|
| 90 | if [[ $osName = AIX ]] | 
|---|
| 91 | then | 
|---|
| 92 | # Get the names of Virtual Shared Disks, if any. | 
|---|
| 93 | if [[ -x $lsvsd ]] | 
|---|
| 94 | then | 
|---|
| 95 | $lsvsd 2>$STDERR | $awk '{ if (NF > 0) print $1 " vsd" }' | 
|---|
| 96 | fi | 
|---|
| 97 |  | 
|---|
| 98 | # Get all defined and available vpaths, hdisks, etc. | 
|---|
| 99 | LC_ALL=C $getlvodm -F 2>$STDERR |                   \ | 
|---|
| 100 | $awk '                                            \ | 
|---|
| 101 | /hdiskpower/  { print $1 " powerdisk" ; next }  \ | 
|---|
| 102 | /dlmfdrv/     { print $1 " dlmfdrv"   ; next }  \ | 
|---|
| 103 | /vpath/       { print $1 " vpath"     ; next }  \ | 
|---|
| 104 | /hdisk/       { print $1 " hdisk"     ; next }  \ | 
|---|
| 105 | ' | 
|---|
| 106 |  | 
|---|
| 107 | # Get all logical volume names. | 
|---|
| 108 | # LVs are supported in older file systems only.  Not allowed as a new device. | 
|---|
| 109 | LC_ALL=C $lsvg -o 2>$STDERR | LC_ALL=C $lsvg -i -l 2>$STDERR | \ | 
|---|
| 110 | $awk '                                  \ | 
|---|
| 111 | /LV NAME/ || /:/  { next }            \ | 
|---|
| 112 | { print $1 " lv" }  \ | 
|---|
| 113 | ' | 
|---|
| 114 |  | 
|---|
| 115 | elif [[ $osName = Linux ]] | 
|---|
| 116 | then | 
|---|
| 117 | # Get the names of all disks, vpaths, etc. | 
|---|
| 118 | $awk '                                                                 \ | 
|---|
| 119 | /emcpower/   { if (NF > 3 && $3 > 1) print $4 " powerdisk" ; next }  \ | 
|---|
| 120 | /vpath/      { if (NF > 3 && $3 > 1) print $4 " vpath"     ; next }  \ | 
|---|
| 121 | /[sh]d/      { if (NF > 3 && $3 > 1) print $4 " generic"   ; next }  \ | 
|---|
| 122 | ' /proc/partitions 2>$STDERR | 
|---|
| 123 |  | 
|---|
| 124 | else | 
|---|
| 125 | print -u2  " Unknown operating system $osName " | 
|---|
| 126 | cleanupAndExit | 
|---|
| 127 | fi | 
|---|
| 128 |  | 
|---|
| 129 | # Search for the disk type of "file" in the mmsdrfs file. | 
|---|
| 130 | # Note:  This is used for testing during development only. | 
|---|
| 131 | possiblefiles=$($awk -F: '                      \ | 
|---|
| 132 | /':$SG_DISKS:'/ {                             \ | 
|---|
| 133 | if ($'$NSD_SUBTYPE_Field' == "file") {      \ | 
|---|
| 134 | { print $'$NSD_SUBTYPE_DISKNAME_Field' }  \ | 
|---|
| 135 | }                                           \ | 
|---|
| 136 | }                                             \ | 
|---|
| 137 | ' $mmsdrfsFile) | 
|---|
| 138 | for testfile in $possiblefiles | 
|---|
| 139 | do | 
|---|
| 140 | [[ -f $testfile ]] && print -- "$testfile file" | 
|---|
| 141 | done | 
|---|
| 142 |  | 
|---|
| 143 | cleanupAndExit 0 | 
|---|
| 144 |  | 
|---|