Remove inc_nlink in debugfs_create_automount, or this inode will never
be free.
Signed-off-by: yangerkun <[email protected]>
---
fs/debugfs/inode.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 13b0135..9e6e225 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -516,8 +516,6 @@ struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
inode->i_op = &simple_dir_inode_operations;
inode->i_fop = &simple_dir_operations;
- /* 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);
--
2.9.5
On Sat, Dec 22, 2018 at 11:41:11AM +0800, yangerkun wrote:
> Remove inc_nlink in debugfs_create_automount, or this inode will never
> be free.
>
> Signed-off-by: yangerkun <[email protected]>
> ---
> fs/debugfs/inode.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
> index 13b0135..9e6e225 100644
> --- a/fs/debugfs/inode.c
> +++ b/fs/debugfs/inode.c
> @@ -516,8 +516,6 @@ struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
> inode->i_op = &simple_dir_inode_operations;
> inode->i_fop = &simple_dir_operations;
>
> - /* directory inodes start off with i_nlink == 2 (for "." entry) */
> - inc_nlink(inode);
Really? How did you test this and why does removing this line directly
go against what the comment says?
this feels really wrong...
greg k-h
Greg KH wrote on 2018/12/22 15:32:
> On Sat, Dec 22, 2018 at 11:41:11AM +0800, yangerkun wrote:
>> Remove inc_nlink in debugfs_create_automount, or this inode will never
>> be free.
>>
>> Signed-off-by: yangerkun <[email protected]>
>> ---
>> fs/debugfs/inode.c | 2 --
>> 1 file changed, 2 deletions(-)
>>
>> diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
>> index 13b0135..9e6e225 100644
>> --- a/fs/debugfs/inode.c
>> +++ b/fs/debugfs/inode.c
>> @@ -516,8 +516,6 @@ struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
>> inode->i_op = &simple_dir_inode_operations;
>> inode->i_fop = &simple_dir_operations;
>>
>> - /* directory inodes start off with i_nlink == 2 (for "." entry) */
>> - inc_nlink(inode);
>
> Really? How did you test this and why does removing this line directly
> go against what the comment says?
So sorry for this, the fuction should be modify is
debugfs_create_automount. Patch will coming soon.
Thanks,
Kun.
>
> this feels really wrong...
>
> greg k-h
>
> .
>
FYI, we noticed the following commit (built with gcc-7):
commit: a1e6b3dc1c6fadc388e71815c4d85b9a2100ad3f ("[PATCH] debugfs: remove no need inc_nlink")
url: https://github.com/0day-ci/linux/commits/yangerkun/debugfs-remove-no-need-inc_nlink/20181222-210250
in testcase: boot
on test machine: qemu-system-x86_64 -enable-kvm -cpu SandyBridge -smp 2 -m 8G
caused below changes (please refer to attached dmesg/kmsg for entire log/backtrace):
+-----------------------------------+------------+------------+
| | 16df1456aa | a1e6b3dc1c |
+-----------------------------------+------------+------------+
| boot_successes | 10 | 0 |
| boot_failures | 0 | 6 |
| WARNING:at_fs/inode.c:#drop_nlink | 0 | 6 |
| RIP:drop_nlink | 0 | 6 |
+-----------------------------------+------------+------------+
[ 89.144904] WARNING: CPU: 1 PID: 404 at fs/inode.c:285 drop_nlink+0x24/0x30
[ 89.162978] Modules linked in: sr_mod cdrom sg ppdev crct10dif_pclmul crc32_pclmul crc32c_intel ghash_clmulni_intel snd_pcm ata_generic snd_timer pata_acpi aesni_intel crypto_simd snd cryptd glue_helper soundcore pcspkr serio_raw ata_piix libata i2c_piix4 parport_pc floppy parport ip_tables
[ 89.201228] CPU: 1 PID: 404 Comm: mount.nfs Not tainted 4.20.0-rc5-00017-ga1e6b3d #1
[ 89.220491] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014
[ 89.230741] RIP: 0010:drop_nlink+0x24/0x30
[ 89.238571] Code: 84 00 00 00 00 00 66 66 66 66 90 8b 47 48 85 c0 8d 50 ff 74 15 85 d2 89 57 48 75 0c 48 8b 47 28 f0 48 ff 80 a0 04 00 00 f3 c3 <0f> 0b c7 47 48 ff ff ff ff c3 66 90 66 66 66 66 90 8b 47 48 85 c0
[ 89.266513] RSP: 0000:ffffc9000123ba18 EFLAGS: 00010246
[ 89.272470] RAX: 0000000000000000 RBX: ffff88821cc6a250 RCX: 0000000000000000
[ 89.278356] RDX: 00000000ffffffff RSI: 0000000016694e00 RDI: ffff88821cc6a250
[ 89.290053] RBP: ffffc9000123ba40 R08: 0000000000000000 R09: 0000000000000000
[ 89.298101] R10: ffffea00089296c0 R11: 0000000000000545 R12: ffff8881f72e8000
[ 89.307078] R13: ffff88822ac05bc0 R14: ffff8881f72e8d60 R15: ffff8881f72e80a0
[ 89.313889] FS: 00007fc0e6bae480(0000) GS:ffff88823fd00000(0000) knlGS:0000000000000000
[ 89.323184] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 89.332486] CR2: 00007fc0e56082f0 CR3: 00000001f2fe6000 CR4: 00000000000406e0
[ 89.341276] Call Trace:
[ 89.346649] simple_unlink+0x48/0x60
[ 89.351926] simple_rmdir+0x2d/0x50
[ 89.357466] __debugfs_remove+0x45/0xc0
[ 89.364558] debugfs_remove_recursive+0x185/0x1c0
[ 89.370362] rpc_clnt_debugfs_unregister+0x15/0x30
[ 89.377695] rpc_free_client+0x34/0xf0
[ 89.383292] rpc_release_client+0x54/0x90
[ 89.387923] rpc_shutdown_client+0x89/0x170
[ 89.392889] ? rpc_call_sync+0x65/0x90
[ 89.400248] nfs_mount+0x148/0x2a0
[ 89.404366] nfs_request_mount+0xf4/0x1c0
[ 89.410765] nfs_try_mount+0xba/0x2c0
[ 89.415208] ? _cond_resched+0x19/0x30
[ 89.418969] ? __kmalloc_track_caller+0x58/0x240
[ 89.423842] ? _cond_resched+0x19/0x30
[ 89.427552] nfs_fs_mount+0x63f/0xd10
[ 89.431874] ? pcpu_alloc_area+0xc0/0x130
[ 89.435924] ? nfs_clone_super+0x70/0x70
[ 89.439891] ? param_set_portnr+0x70/0x70
[ 89.444260] ? mount_fs+0x35/0x150
[ 89.447301] ? nfs_remount+0x350/0x350
[ 89.450778] mount_fs+0x35/0x150
[ 89.454335] vfs_kern_mount+0x54/0x120
[ 89.458249] do_mount+0x5e8/0xcb0
[ 89.461669] ? kmem_cache_alloc_trace+0x3e/0x1e0
[ 89.467487] ksys_mount+0x80/0xd0
[ 89.471994] __x64_sys_mount+0x21/0x30
[ 89.476396] do_syscall_64+0x5b/0x180
[ 89.480757] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[ 89.485757] RIP: 0033:0x7fc0e626a24a
[ 89.489684] Code: 48 8b 0d 51 fc 2a 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 1e fc 2a 00 f7 d8 64 89 01 48
[ 89.513383] RSP: 002b:00007fffc13beeb8 EFLAGS: 00000206 ORIG_RAX: 00000000000000a5
[ 89.522200] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fc0e626a24a
[ 89.530213] RDX: 000055c80420af90 RSI: 000055c80420af70 RDI: 000055c804209230
[ 89.537245] RBP: 00007fffc13bf0b0 R08: 000055c804216340 R09: 0000000000000060
[ 89.544541] R10: 0000000000000000 R11: 0000000000000206 R12: 00007fc0e6bae410
[ 89.552178] R13: 00007fffc13bf0b0 R14: 00007fffc13befb0 R15: 000055c804216320
[ 89.560460] ---[ end trace 55911a8453dafee2 ]---
To reproduce:
git clone https://github.com/intel/lkp-tests.git
cd lkp-tests
bin/lkp qemu -k <bzImage> job-script # job-script is attached in this email
Thanks,
lkp