source: gpfs_3.1_ker2.6.20/lpp/mmfs/src/gpl-linux/lxtrace.sial @ 148

Last change on this file since 148 was 16, checked in by rock, 17 years ago
File size: 3.2 KB
RevLine 
[16]1/* @(#)27       1.2  src/avs/fs/mmfs/ts/kernext/gpl-linux/mmdumpfilocks.sial, mmfs, avs_rgpfs24, rgpfs240610b 10/17/02 21:25:23 */
2
3/* lcrash sial script to display file_lock structures.
4 * Loaded and executed from mmdumpfilock.sh to support
5 * the "mmfsadm dump fillocks" command.
6 */
7string mmdumpfilocks_help()  { return ""; }
8string mmdumpfilocks_opt()   { return ""; }
9string mmdumpfilocks_usage() { return ""; }
10
11typedef struct list_head_t {
12  struct list_head *next, *prev;
13} list_head_t;
14
15int
16mmdumpfilocks()
17{
18  char *fsP;
19  int ino, dev, nLocks;
20  int link_offset, block_offset;
21  list_head_t *lhP, *nextP;
22  list_head_t *bhP, *blockP;
23  struct file_lock *flP, *blP;
24
25  printf("\n");
26
27  /* file_lock_list is the anchor of all locks */
28  if (exists("file_lock_list"))
29  {
30    lhP = (list_head_t *)file_lock_list;
31    flP = (struct file_lock *)lhP->next;
32    link_offset = (int)&flP->fl_link - (int)flP;
33    block_offset = (int)&flP->fl_block - (int)flP;
34
35    nLocks = 0;
36
37    /* Loop through the fl_link.next chain (circular) */
38    while (flP != lhP) {
39
40      /* Back-up to top of file_lock */
41      flP = (struct file_lock *) ((int)flP - link_offset);
42
43      /* Only show GPFS locks */
44      fsP = flP->fl_file->f_dentry->d_sb->s_type->name;
45      if (fsP[0] == 'g' && fsP[1] == 'p' && fsP[2] == 'f' && fsP[3] == 's') {
46
47        if (!nLocks++) {
48          /* Header line */
49          printf("file_lock  maj:min    inode      pid  type      start        end\n");
50          printf("---------- ------- -------- -------- ----- ---------- ----------\n");
51        }
52
53        /* collect inode and dev to easily identify the file */
54        ino = flP->fl_file->f_dentry->d_inode->i_ino;
55        dev = flP->fl_file->f_dentry->d_inode->i_dev;
56
57        /* display some of the lock fields. */
58        printf("0x%8X %0.3d:%0.3d %8d %8d %5s %10d %10d\n",
59                flP, dev>>8, dev & 0xFF, ino, flP->fl_pid,
60                flP->fl_type==0? "READ": (flP->fl_type==1? "WRITE":"?"),
61                flP->fl_start, flP->fl_end); 
62
63        /* Follow fl_block so we can match up "reclockSleepers" */
64        bhP = (list_head_t *)(&flP->fl_block);
65        blP = (struct file_lock *)bhP->next;
66
67        /* Loop through the fl_block.next chain (circular) */
68        while (blP != bhP) {
69
70          /* Back-up to top of file_lock */
71          blP = (struct file_lock *) ((int)blP - block_offset);
72
73          /* display some of the lock fields.  One line per lock. */
74          printf("0x%8X %0.3d:%0.3d %8d %8d %5s %10d %10d waiting\n",
75                  blP, dev>>8, dev & 0xFF, ino, blP->fl_pid,
76                  blP->fl_type==0? "READ": (blP->fl_type==1? "WRITE":"?"),
77                  blP->fl_start, blP->fl_end); 
78
79          /* Move to the next file_lock in the block list. */
80          blockP = (list_head_t *)(&blP->fl_block);
81          blP = (struct file_lock *)blockP->next;
82        } /* Done with the fl_block chain. */
83
84      }
85      /* Move to the next file_lock in the fl_link list and continue. */
86      nextP = (list_head_t *)(&flP->fl_link);
87      flP = (struct file_lock *)nextP->next;
88    }
89  }
90  else
91  {
92    printf("The \"file_lock_list\" symbol cannot be found in this memory image.\n");
93    printf("Did you give lcrash a /var/mmfs/tmp/complete.map?\n");
94  }
95  return 0;
96}
Note: See TracBrowser for help on using the repository browser.