Skip to contentSkip to conversation

Improve laptop mode's block_dump output

PATCH New Theodore Ts'o 1 participant 1 message Apr 27, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Improve laptop mode's block_dump output

This patch versus 2.6.6-rc2 improves the output produced by "echo 1 > /proc/sys/vm/block_dump", in the following ways:

1) The messages are printed with KERN_DEBUG, so that even if sysklogd is running, if configured appropriately, it will not need to write to log files.

2) The inode which is dirtied by a process is now identified more precisely by inode number and filesystem ID, and by a dcache name if present.

3) In the generic filesystem sget function, the superblock id (s_id) is filled in with the filesystem type by default. Filesystems which are block-device based will override s_id, but this allows pseudo filesystems such as tmpfs, procfs, etc. to be identified in (2).

- Ted

===== drivers/block/ll_rw_blk.c 1.243 vs edited =====

drivers/block/ll_rw_blk.c +1 -1
@@ -2443,7 +2443,7 @@
 
 	if (unlikely(block_dump)) {
 		char b[BDEVNAME_SIZE];
-		printk("%s(%d): %s block %Lu on %s\n",
+		printk(KERN_DEBUG "%s(%d): %s block %Lu on %s\n",
 			current->comm, current->pid,
 			(rw & WRITE) ? "WRITE" : "READ",
 			(unsigned long long)bio->bi_sector,

===== fs/fs-writeback.c 1.51 vs edited =====

fs/fs-writeback.c +17 -2
@@ -75,8 +75,23 @@
 	if ((inode->i_state & flags) == flags)
 		return;
 
-	if (unlikely(block_dump))
-		printk("%s(%d): dirtied file\n", current->comm, current->pid);
+	if (unlikely(block_dump)) {
+		struct dentry *dentry = NULL;
+		const char *name = "?";
+		
+		if (!list_empty(&inode->i_dentry)) {
+			dentry = list_entry(inode->i_dentry.next, 
+					    struct dentry, d_alias);
+			if (dentry && dentry->d_name.name)
+				name = (const char *) dentry->d_name.name;
+		}
+
+		if (inode->i_ino || strcmp(inode->i_sb->s_id, "bdev"))
+			printk(KERN_DEBUG 
+			       "%s(%d): dirtied inode %lu (%s) on %s\n", 
+			       current->comm, current->pid, inode->i_ino,
+			       name, inode->i_sb->s_id);
+	}
 
 	spin_lock(&inode_lock);
 	if ((inode->i_state & flags) != flags) {

===== fs/super.c 1.118 vs edited =====

fs/super.c +1 -0
@@ -266,6 +266,7 @@
 		return ERR_PTR(err);
 	}
 	s->s_type = type;
+	strlcpy(s->s_id, type->name, sizeof(s->s_id));
 	list_add(&s->s_list, super_blocks.prev);
 	list_add(&s->s_instances, &type->fs_supers);
 	spin_unlock(&sb_lock);