enhancement to filp macro

Steven Dake <[email protected]>
Newsgroups gmane.linux.kernel.debugging
Organization MontaVista Software, Inc.
Message-ID <[email protected]>
Here is an enhancement Montavista used to debug a race condition in the
kernel.  Someone may find it useful here.

MR: 17281
Type: Enhancement
Disposition: submitted to [email protected]
Signed-off-by: Steven Dake <[email protected]>
Signed-off-by: Mark Bellon <[email protected]>
Description:
	If f_dentry is null, this KDB module will not print out any information.
	This patch changes that behavior to print out as much data as possible
	in the filp structure.

diff -a -u -r1.1.4.1.50.2 kdbm_vm.c
--- kdb/modules/kdbm_vm.c	4 Feb 2005 01:18:12 -0000	1.1.4.1.50.2
+++ kdb/modules/kdbm_vm.c	27 Feb 2006 17:18:58 -0000
@@ -341,18 +341,8 @@
 
 	nextarg = 1;
 	if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs)) ||
-	    (diag = kdb_getarea(f, addr)) ||
-	    (diag = kdb_getarea(d, (unsigned long)f.f_dentry)))
+	    (diag = kdb_getarea(f, addr)))
 		goto out;
-	if (!(i = kmalloc(sizeof(*i), GFP_ATOMIC))) {
-		kdb_printf("kdbm_fp: cannot kmalloc inode\n");
-		goto out;
-	}
-	if ((diag = kdb_getarea(*i, (unsigned long)d.d_inode)))
-		goto out;
-	
-	kdb_printf("name.name 0x%p  name.len  %d\n",
-		    d.d_name.name, d.d_name.len);
 
 	kdb_printf("File Pointer at 0x%lx\n", addr);
 
@@ -363,21 +353,27 @@
 					f.f_dentry, f.f_op);
 
 	kdb_printf(" f_count = %d f_flags = 0x%x f_mode = 0x%x\n",
-					f.f_count.counter, f.f_flags, f.f_mode);
+				atomic_read(&f.f_count), f.f_flags, f.f_mode);
 
 	kdb_printf(" f_pos = %Ld f_reada = %ld f_ramax = %ld\n",
 					f.f_pos, f.f_reada, f.f_ramax);
 
-	kdb_printf(" f_raend = %ld f_ralen = %ld f_rawin = %ld\n\n",
+	kdb_printf(" f_raend = %ld f_ralen = %ld f_rawin = %ld\n",
 					f.f_raend, f.f_ralen, f.f_rawin);
 
+	kdb_printf(" f_vfsmnt = 0x%p\n\n",
+					f.f_vfsmnt);
+
+	if (!f.f_dentry || (diag = kdb_getarea(d, (unsigned long)f.f_dentry)))
+		goto out;
 
 	kdb_printf("\nDirectory Entry at 0x%p\n", f.f_dentry);
+
 	kdb_printf(" d_name.len = %d d_name.name = 0x%p>\n",
 					d.d_name.len, d.d_name.name);
 
 	kdb_printf(" d_count = %d d_flags = 0x%x d_inode = 0x%p\n",
-					atomic_read(&d.d_count), d.d_flags, d.d_inode);
+				atomic_read(&d.d_count), d.d_flags, d.d_inode);
 
 	kdb_printf(" d_hash.nxt = 0x%p d_hash.prv = 0x%p\n",
 					d.d_hash.next, d.d_hash.prev);
@@ -397,6 +393,13 @@
 	kdb_printf(" d_op = 0x%p d_sb = 0x%p\n\n",
 					d.d_op, d.d_sb);
 
+	if (!(i = kmalloc(sizeof(*i), GFP_ATOMIC))) {
+		kdb_printf("kdbm_fp: cannot kmalloc inode\n");
+		goto out;
+	}
+
+	if (!d.d_inode || (diag = kdb_getarea(*i, (unsigned long)d.d_inode)))
+		goto out;
 
 	kdb_printf("\nInode Entry at 0x%p\n", d.d_inode);
 
@@ -412,7 +415,7 @@
 	kdb_printf(" i_list.nxt = 0x%p i_list.prv = 0x%p\n",
 					i->i_list.next, i->i_list.prev);
 
-	kdb_printf(" i_dentry.nxt = 0x%p i_dentry.prv = 0x%p\n",
+	kdb_printf(" i_dentry.nxt = 0x%p i_dentry.prv = 0x%p\n\n",
 					i->i_dentry.next, i->i_dentry.prev);
 
 out:


---------------------------
Use http://oss.sgi.com/ecartis to modify your settings or to unsubscribe.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.