Messages in this thread Patch in this message | | | Date | Wed, 13 Aug 1997 10:18:39 -0400 | From | Bill Hawes <> | Subject | sysrq show_inodes patch |
| |
If you've always wondered what your inodes are doing, this is the patch for you. It adds an entry to sysrq.c so that sysrq-i gives a report like:
Inodes Allocated: 464 List Inodes Used Hash Lock Dirt Link Pipe Sock Cnt<0 Pages UNUSED 20 0 0 0 0 0 0 0 0 0 CLEAN 431 139 391 1 0 391 2 38 0 199 03:06 3 3 3 0 3 3 0 0 0 7 03:07 10 7 10 0 10 10 0 0 0 253 00:01 0 0 0 0 0 0 0 0 0 0 Inodes Accounted: 464 Total Pages: 459
The "pages" column refers to the page cache associated with the inode.
Patch is against 2.1.49.
Regards, Bill--- linux-2.1.49/fs/inode.c.old Tue Aug 12 07:49:18 1997 +++ linux-2.1.49/fs/inode.c Tue Aug 12 10:50:22 1997 @@ -622,4 +684,84 @@ return 0; } return 1; /* Tis' cool bro. */ +} + +extern void show_inodes(void); +/* + * Displays the attributes for the inodes in the specified list. + */ +static int show_inode_list(struct list_head *head, char *label, int *tot_pages) +{ + struct list_head *tmp; + struct inode *inode; + int found = 0, pages = 0; + int used, hashed, linked, locked, dirty, pipe, socket, negative; + + used = hashed = linked = locked = dirty = pipe = socket = negative = 0; + for (tmp = head->next; tmp != head; tmp = tmp->next) { + found++; + + inode = list_entry(tmp, struct inode, i_list); + if (inode->i_count > 0) + used++; + if (!list_empty(&inode->i_hash)) + hashed++; + if (inode->i_nlink) + linked++; + if (test_bit(I_LOCK, &inode->i_state)) + locked++; + if (!inode->i_pipe && + test_bit(I_DIRTY, &inode->i_state)) + dirty++; + if (inode->i_pipe) + pipe++; + if (inode->i_sock) + socket++; + /* + * Count the number of cache pages. + */ + pages += inode->i_nrpages; + + /* + * Check for problems ... these shouldn't happen. + */ + if (inode->i_count >= (1 << 15)) + negative++; + } + + printk("%6s %6d%6d%6d%6d%6d%6d%6d%6d%6d %6d\n", + label, found, used, hashed, linked, locked, dirty, pipe, socket, + negative, pages); + *tot_pages += pages; + return found; +} + +/* + * Displays a table of attributes for the inodes in each list. + */ +void show_inodes(void) +{ + struct super_block * sb = &super_blocks[0]; + int i, accounted = 0, tot_pages = 0; + static char *list_types[2] = {"UNUSED", "CLEAN "}; + + printk("Inodes Allocated: %d\n", inodes_stat.nr_inodes); + printk("List Inodes Used Hash Link Lock Dirt Pipe Sock" + " Cnt<0 Pages\n"); + + spin_lock(&inode_lock); + accounted += show_inode_list(&inode_unused, list_types[0], &tot_pages); + accounted += show_inode_list(&inode_in_use, list_types[1], &tot_pages); + /* + * Loop through super blocks + */ + for (i = NR_SUPER; i--; sb++) { + if (!sb->s_dev) + continue; + accounted += show_inode_list(&sb->s_dirty, kdevname(sb->s_dev), + &tot_pages); + } + spin_unlock(&inode_lock); + + printk("Inodes Accounted: %d Total Pages: %d\n", accounted, tot_pages); } --- linux-2.1.49/drivers/char/sysrq.c.old Tue Aug 12 07:45:33 1997 +++ linux-2.1.49/drivers/char/sysrq.c Tue Aug 12 10:32:40 1997 @@ -27,6 +27,7 @@ #endif extern void wakeup_bdflush(int); +extern void show_inodes(void); extern void reset_vc(unsigned int); extern int console_loglevel; extern struct vfsmount *vfsmntlist; @@ -110,7 +111,11 @@ printk("Show State\n"); show_state(); break; - case 'm': /* M -- show memory info */ + case 'i': /* I -- show inodes */ + printk("Show Inodes\n"); + show_inodes(); + break; + case 'm': /* M -- show memory info */ printk("Show Memory\n"); show_mem(); break; | |