/* @(#)27 1.2 src/avs/fs/mmfs/ts/kernext/gpl-linux/mmdumpfilocks.sial, mmfs, avs_rgpfs24, rgpfs240610b 10/17/02 21:25:23 */ /* lcrash sial script to display file_lock structures. * Loaded and executed from mmdumpfilock.sh to support * the "mmfsadm dump fillocks" command. */ string mmdumpfilocks_help() { return ""; } string mmdumpfilocks_opt() { return ""; } string mmdumpfilocks_usage() { return ""; } typedef struct list_head_t { struct list_head *next, *prev; } list_head_t; int mmdumpfilocks() { char *fsP; int ino, dev, nLocks; int link_offset, block_offset; list_head_t *lhP, *nextP; list_head_t *bhP, *blockP; struct file_lock *flP, *blP; printf("\n"); /* file_lock_list is the anchor of all locks */ if (exists("file_lock_list")) { lhP = (list_head_t *)file_lock_list; flP = (struct file_lock *)lhP->next; link_offset = (int)&flP->fl_link - (int)flP; block_offset = (int)&flP->fl_block - (int)flP; nLocks = 0; /* Loop through the fl_link.next chain (circular) */ while (flP != lhP) { /* Back-up to top of file_lock */ flP = (struct file_lock *) ((int)flP - link_offset); /* Only show GPFS locks */ fsP = flP->fl_file->f_dentry->d_sb->s_type->name; if (fsP[0] == 'g' && fsP[1] == 'p' && fsP[2] == 'f' && fsP[3] == 's') { if (!nLocks++) { /* Header line */ printf("file_lock maj:min inode pid type start end\n"); printf("---------- ------- -------- -------- ----- ---------- ----------\n"); } /* collect inode and dev to easily identify the file */ ino = flP->fl_file->f_dentry->d_inode->i_ino; dev = flP->fl_file->f_dentry->d_inode->i_dev; /* display some of the lock fields. */ printf("0x%8X %0.3d:%0.3d %8d %8d %5s %10d %10d\n", flP, dev>>8, dev & 0xFF, ino, flP->fl_pid, flP->fl_type==0? "READ": (flP->fl_type==1? "WRITE":"?"), flP->fl_start, flP->fl_end); /* Follow fl_block so we can match up "reclockSleepers" */ bhP = (list_head_t *)(&flP->fl_block); blP = (struct file_lock *)bhP->next; /* Loop through the fl_block.next chain (circular) */ while (blP != bhP) { /* Back-up to top of file_lock */ blP = (struct file_lock *) ((int)blP - block_offset); /* display some of the lock fields. One line per lock. */ printf("0x%8X %0.3d:%0.3d %8d %8d %5s %10d %10d waiting\n", blP, dev>>8, dev & 0xFF, ino, blP->fl_pid, blP->fl_type==0? "READ": (blP->fl_type==1? "WRITE":"?"), blP->fl_start, blP->fl_end); /* Move to the next file_lock in the block list. */ blockP = (list_head_t *)(&blP->fl_block); blP = (struct file_lock *)blockP->next; } /* Done with the fl_block chain. */ } /* Move to the next file_lock in the fl_link list and continue. */ nextP = (list_head_t *)(&flP->fl_link); flP = (struct file_lock *)nextP->next; } } else { printf("The \"file_lock_list\" symbol cannot be found in this memory image.\n"); printf("Did you give lcrash a /var/mmfs/tmp/complete.map?\n"); } return 0; }