Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754317AbbLJMsO (ORCPT ); Thu, 10 Dec 2015 07:48:14 -0500 Received: from mail-wm0-f43.google.com ([74.125.82.43]:38698 "EHLO mail-wm0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751321AbbLJMrY (ORCPT ); Thu, 10 Dec 2015 07:47:24 -0500 From: Roman Pen Cc: Roman Pen , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: [RFC PATCH 1/3] debugfs: fix automount inode i_nlink references Date: Thu, 10 Dec 2015 13:47:12 +0100 Message-Id: <1449751634-7887-2-git-send-email-r.peniaev@gmail.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1449751634-7887-1-git-send-email-r.peniaev@gmail.com> References: <1449751634-7887-1-git-send-email-r.peniaev@gmail.com> To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4305 Lines: 81 Directory inodes should start off with i_nlink == 2 (for "." entry). Of course the same rule should be applied to automount dentries for child and parent inodes as well. Also now automount dentry does fsnotify_mkdir. Without this patch kernel complains when sees i_nlink == 0: [ 86.288070] WARNING: CPU: 1 PID: 3616 at fs/inode.c:273 drop_nlink+0x3e/0x50() [ 86.288461] Modules linked in: debugfs_example2(O-) [ 86.288745] CPU: 1 PID: 3616 Comm: rmmod Tainted: G O 4.4.0-rc3-next-20151207+ #135 [ 86.289197] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.8.2-20150617_082717-anatol 04/01/2014 [ 86.289696] ffffffff81be05c9 ffff8800b9e6fda0 ffffffff81352e2c 0000000000000000 [ 86.290110] ffff8800b9e6fdd8 ffffffff81065142 ffff8801399175e8 ffff8800bb78b240 [ 86.290507] ffff8801399175e8 ffff8800b73d7898 ffff8800b73d7840 ffff8800b9e6fde8 [ 86.290933] Call Trace: [ 86.291080] [] dump_stack+0x4e/0x82 [ 86.291340] [] warn_slowpath_common+0x82/0xc0 [ 86.291640] [] warn_slowpath_null+0x1a/0x20 [ 86.291932] [] drop_nlink+0x3e/0x50 [ 86.292208] [] simple_unlink+0x4b/0x60 [ 86.292481] [] simple_rmdir+0x37/0x50 [ 86.292748] [] __debugfs_remove.part.16+0xa8/0xd0 [ 86.293082] [] debugfs_remove_recursive+0xdb/0x1c0 [ 86.293406] [] cleanup_module+0x2d/0x3b [debugfs_example2] [ 86.293762] [] SyS_delete_module+0x16b/0x220 [ 86.294077] [] entry_SYSCALL_64_fastpath+0x12/0x6a [ 86.294405] ---[ end trace c9fc53353fe14a36 ]--- [ 86.294639] ------------[ cut here ]------------ [ 86.294871] WARNING: CPU: 1 PID: 3616 at fs/inode.c:273 drop_nlink+0x3e/0x50() [ 86.295249] Modules linked in: debugfs_example2(O-) [ 86.295510] CPU: 1 PID: 3616 Comm: rmmod Tainted: G W O 4.4.0-rc3-next-20151207+ #135 [ 86.295943] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.8.2-20150617_082717-anatol 04/01/2014 [ 86.296450] ffffffff81be05c9 ffff8800b9e6fda0 ffffffff81352e2c 0000000000000000 [ 86.296846] ffff8800b9e6fdd8 ffffffff81065142 ffff880139917810 ffff8800b73d7840 [ 86.297253] ffff880139917810 ffff8800b73d7898 ffff8800b73d7840 ffff8800b9e6fde8 [ 86.297650] Call Trace: [ 86.297777] [] dump_stack+0x4e/0x82 [ 86.298043] [] warn_slowpath_common+0x82/0xc0 [ 86.298344] [] warn_slowpath_null+0x1a/0x20 [ 86.298636] [] drop_nlink+0x3e/0x50 [ 86.298893] [] simple_unlink+0x4b/0x60 [ 86.299174] [] simple_rmdir+0x37/0x50 [ 86.299442] [] __debugfs_remove.part.16+0xa8/0xd0 [ 86.299760] [] debugfs_remove_recursive+0x17f/0x1c0 [ 86.300095] [] cleanup_module+0x2d/0x3b [debugfs_example2] [ 86.300453] [] SyS_delete_module+0x16b/0x220 [ 86.300750] [] entry_SYSCALL_64_fastpath+0x12/0x6a [ 86.301198] ---[ end trace c9fc53353fe14a37 ]--- Signed-off-by: Roman Pen Cc: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org --- fs/debugfs/inode.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index b7fcc0d..7bd7e19 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c @@ -461,7 +461,11 @@ struct dentry *debugfs_create_automount(const char *name, inode->i_flags |= S_AUTOMOUNT; inode->i_private = data; dentry->d_fsdata = (void *)f; + /* directory inodes start off with i_nlink == 2 (for "." entry) */ + inc_nlink(inode); d_instantiate(dentry, inode); + inc_nlink(d_inode(dentry->d_parent)); + fsnotify_mkdir(d_inode(dentry->d_parent), dentry); return end_creating(dentry); } EXPORT_SYMBOL(debugfs_create_automount); -- 2.6.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/