| 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. 2002,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 | # @(#)28 1.3 src/avs/fs/mmfs/ts/admin/mmdumpfilocks.sh, mmfs, avs_rgpfs24, rgpfs240610b 10/16/02 23:26:49 | 
|---|
| 17 |  | 
|---|
| 18 | sourceFile="mmdumpfilocks.sh" | 
|---|
| 19 | [[ -n $DEBUG || -n $DEBUGmmdumpfilocks ]] && set -x | 
|---|
| 20 |  | 
|---|
| 21 | # full pathnames to dump commands | 
|---|
| 22 | crash=/usr/sbin/crash | 
|---|
| 23 | kdb=/usr/sbin/kdb | 
|---|
| 24 | lcrash=/sbin/lcrash | 
|---|
| 25 |  | 
|---|
| 26 | if [[ $1 = '-?' || $1 = '-h' || $1 = '--help' || $1 = '--' ]] | 
|---|
| 27 | then | 
|---|
| 28 | print -u2 "Usage:  mmdumpfilocks [dump [kernelfile]]" | 
|---|
| 29 | exit 1 | 
|---|
| 30 | fi | 
|---|
| 31 |  | 
|---|
| 32 | if [[ -x $lcrash ]] | 
|---|
| 33 | then                               # Linux lcrash debugger | 
|---|
| 34 | # All the smarts are in the sial script | 
|---|
| 35 | print "load /usr/lpp/mmfs/bin/mmdumpfilocks.sial\\nmmdumpfilocks\\nquit" \ | 
|---|
| 36 | | $lcrash 2>/dev/null \ | 
|---|
| 37 | | /bin/awk '{ if (NR>3) { \ | 
|---|
| 38 | print $0; \ | 
|---|
| 39 | } \ | 
|---|
| 40 | }' | 
|---|
| 41 |  | 
|---|
| 42 |  | 
|---|
| 43 | elif [[ -x $crash ]] | 
|---|
| 44 | then                               # AIX pre-rel5 crash debugger | 
|---|
| 45 | # Stage 1: Select the GPFS vnodes, extract the gnode address and | 
|---|
| 46 | #          pass it forward as a comment to the next stage along | 
|---|
| 47 | #          with the offset of gn_filocks. | 
|---|
| 48 | # Stage 2: Extract the value of gn_filocks passing it forward | 
|---|
| 49 | #          along with the gnode pointer. | 
|---|
| 50 | # Stage 3: If gn_filocks is not NULL, display the gnode and use | 
|---|
| 51 | #          the link command to follow the lock chain. | 
|---|
| 52 | print "vnode" | $crash $1 $2 2> /dev/null \ | 
|---|
| 53 | | /usr/bin/awk '{ if ($5=="mmfs") { \ | 
|---|
| 54 | print "! print", "gnode", $8; \ | 
|---|
| 55 | print "calc", $8"+3C"; \ | 
|---|
| 56 | } \ | 
|---|
| 57 | }' \ | 
|---|
| 58 | | $crash $1 $2 2> /dev/null \ | 
|---|
| 59 | | /usr/bin/awk '{ if ($1=="gnode") { \ | 
|---|
| 60 | print "! print", "gnode", $2; \ | 
|---|
| 61 | } else { \ | 
|---|
| 62 | print "od", $1, "1 h"; \ | 
|---|
| 63 | } \ | 
|---|
| 64 | }' \ | 
|---|
| 65 | | $crash $1 $2 2> /dev/null \ | 
|---|
| 66 | | /usr/bin/awk '{ if ($1=="gnode") { \ | 
|---|
| 67 | GNODEP=$2; \ | 
|---|
| 68 | } else if ($2!="00000000") { \ | 
|---|
| 69 | print "! print GNODE"; \ | 
|---|
| 70 | print "od", GNODEP, "24"; \ | 
|---|
| 71 | print "! print FILOCKS"; \ | 
|---|
| 72 | print "link", $2" 15 14 0"; \ | 
|---|
| 73 | } \ | 
|---|
| 74 | }'  \ | 
|---|
| 75 | | $crash $1 $2 2> /dev/null | 
|---|
| 76 |  | 
|---|
| 77 | elif [[ -x $kdb ]] | 
|---|
| 78 | then                               # AIX rel5 kdb debugger | 
|---|
| 79 | # Stage 1: Select the vnode pointers from the file output. | 
|---|
| 80 | #          Note that we could start with "vnode" instead of going | 
|---|
| 81 | #          through the files, but the file list can be substantially | 
|---|
| 82 | #          shorter.  Also, don't start with inodes because they | 
|---|
| 83 | #          can be paged out. | 
|---|
| 84 | # Stage 2: Select the gnode pointers from the vnode output. | 
|---|
| 85 | #          Use "sort -u" to remove duplicates caused by two files | 
|---|
| 86 | #          associated with the same gnode. | 
|---|
| 87 | # Stage 3: It's hard to tell GPFS gnodes from others, but most | 
|---|
| 88 | #          others have symbolic gn_ops values (eg., "jfs_vops"). | 
|---|
| 89 | #          If gn_ops is an address only, continue looking for locks. | 
|---|
| 90 | #          If gn_filocks is not NULL, display the gnode and use | 
|---|
| 91 | #          the "ext" command to follow the lock chain. | 
|---|
| 92 |  | 
|---|
| 93 | print "file " | $kdb $1 $2 2> /dev/null \ | 
|---|
| 94 | | /usr/bin/awk '{ if ($6=="VNODE" && $5!="00000000") { \ | 
|---|
| 95 | print "vnode", $5 } \ | 
|---|
| 96 | }' \ | 
|---|
| 97 | | $kdb $1 $2 2> /dev/null \ | 
|---|
| 98 | | /usr/bin/awk '{ if ($3=="v_gnode..." && $4!="00000000") { \ | 
|---|
| 99 | print "gnode", $4} \ | 
|---|
| 100 | }' \ | 
|---|
| 101 | | /usr/bin/sort -u \ | 
|---|
| 102 | | $kdb $1 $2 2> /dev/null \ | 
|---|
| 103 | | /usr/bin/awk '{ if ($1=="GNODE............") { \ | 
|---|
| 104 | GNODEP=$2; \ | 
|---|
| 105 | getline;   \ | 
|---|
| 106 | } else if ($5=="gn_ops........") { \ | 
|---|
| 107 | VOPS=$6; \ | 
|---|
| 108 | getline;   \ | 
|---|
| 109 | } else if ($3=="gn_filocks...." && $4!="00000000" && \ | 
|---|
| 110 | VOPS !~ /[g-z]/) { \ | 
|---|
| 111 | print "! print GNODE"; \ | 
|---|
| 112 | print "dw", GNODEP" 18"; \ | 
|---|
| 113 | print "! print FILOCKS"; \ | 
|---|
| 114 | print "ext -p", $4, "38 F 10"; \ | 
|---|
| 115 | } \ | 
|---|
| 116 | }' \ | 
|---|
| 117 | | $kdb $1 $2 2> /dev/null \ | 
|---|
| 118 | | /usr/bin/awk '{ if (NR>20 && $1!="(0)>") { \ | 
|---|
| 119 | print $0; \ | 
|---|
| 120 | } \ | 
|---|
| 121 | }' | 
|---|
| 122 |  | 
|---|
| 123 | else | 
|---|
| 124 | print "Could not locate an appropriate dump viewing facility." | 
|---|
| 125 | fi | 
|---|
| 126 | exit 0 | 
|---|