lkml.org 
[lkml]   [1997]   [Sep]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subjectupdated magic sysreq show inodes
I've attached an updated (2.1.55) patch for the magic sysreq "show
inodes" function. Anyone who wants to check out the state of their
inodes (how many, what types, which dirty list, how many unused, etc.)
will find this very handy.

Regards,
Bill--- linux-2.1.55/fs/inode.c.old Wed Sep 10 09:21:27 1997
+++ linux-2.1.55/fs/inode.c Fri Sep 12 17:06:21 1997
@@ -607,4 +749,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)
+{
+ extern struct inode_operations pipe_inode_operations;
+ 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 (inode->i_state & I_LOCK)
+ locked++;
+ if (inode->i_state & I_DIRTY)
+ dirty++;
+ if (inode->i_op == &pipe_inode_operations)
+ 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.55/drivers/char/sysrq.c.old Tue Aug 12 07:45:33 1997
+++ linux-2.1.55/drivers/char/sysrq.c Wed Sep 10 10:33:18 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;
\
 
 \ /
  Last update: 2005-03-22 13:40    [W:0.852 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site