[PATCH/RFC] VFS: report the number of busy inodes on unmount

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Here's a small patch I sometimes find useful.  It costs very little in terms
of performance as it gets executed only on unmount; and it uses an integer
that's already defined.  Perhaps others might find this useful too.

Cheers,
Erez.

------------------------------------------------------------------------------

VFS: report the number of busy inodes on unmount

If you unmount but you have busy inodes, often due to a file system bug
(e.g., a refcount leak), then it is a bit more useful to know how many busy
ones there are.  This could help the developer debug "slow" vs. "fast"
reference count leaks.  (Even better would be if you could report the actual
inode numbers/types that have leaked.)

Signed-off-by: Erez Zadok <ezk@xxxxxxxxxxxxx>
diff --git a/fs/inode.c b/fs/inode.c
index 4d8e3be..03d7034 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -405,7 +405,7 @@ static int invalidate_list(struct list_head *head, struct list_head *dispose)
 			count++;
 			continue;
 		}
-		busy = 1;
+		busy++;
 	}
 	/* only unused inodes may be cached with i_count zero */
 	inodes_stat.nr_unused -= count;
diff --git a/fs/super.c b/fs/super.c
index 0c60915..e8576b1 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -300,6 +300,8 @@ void generic_shutdown_super(struct super_block *sb)
 
 
 	if (sb->s_root) {
+		int busy;
+
 		shrink_dcache_for_umount(sb);
 		sync_filesystem(sb);
 		get_fs_excl();
@@ -312,10 +314,11 @@ void generic_shutdown_super(struct super_block *sb)
 			sop->put_super(sb);
 
 		/* Forget any remaining inodes */
-		if (invalidate_inodes(sb)) {
-			printk("VFS: Busy inodes after unmount of %s. "
+		busy = invalidate_inodes(sb);
+		if (busy) {
+			printk("VFS: %d busy inode(s) after unmount of %s. "
 			   "Self-destruct in 5 seconds.  Have a nice day...\n",
-			   sb->s_id);
+			   busy, sb->s_id);
 		}
 		put_fs_excl();
 	}
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux