Remove the error causing #include "../fs/mount.h" statement#1
Conversation
The include seems not to be necessary and causes problems when compiling the module not in kernel source tree.
|
This pull request is the same as the one in #2 but only for branch "aufs4.6" |
|
Hello JanLuca, JanLuca:
It is necessary when you enable CONFIG_AUFS_BR_FUSE. J. R. Okajima |
The plain i_mutex lock under si_rwsem acquired may cause a lockdep
message. I've seen it on aufs4.1 for linux-v4.1-rc1, and I am afraid it
is a false positive. The message shows the lockdep chain of
namespace_sem -- si_resem -- i_mutex. Investigating the changes between
v4.0 and v4.1-rc1, I could not find the related commit in it. It may be
related to automount too. I'm afraid it could happen before v4.1-rc1.
======================================================
[ INFO: possible circular locking dependency detected ]
4.1.0aufsD+ #363 Not tainted
-------------------------------------------------------
perf/4110 is trying to acquire lock:
(namespace_sem){++++++}, at: [<ffffffff811f597e>] lock_mount+0x8e/0x1e0
but task is already holding lock:
(&sb->s_type->i_mutex_key#2){+.+.+.}, at: [<ffffffff811f5927>] lock_mount+0x37/0x1e0
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #2 (&sb->s_type->i_mutex_key#2){+.+.+.}:
[<ffffffff810b4248>] lock_acquire+0xc8/0x2a0
[<ffffffff8179b563>] mutex_lock_nested+0x63/0x510
[<ffffffff8130f900>] start_creating+0xa0/0x1a0
[<ffffffff8130fa5d>] debugfs_create_file+0x5d/0x1f0
[<ffffffffa00dc74c>] dbgaufs_brs_add+0x9c/0x240 [aufs]
[<ffffffffa00db705>] sysaufs_brs_add+0x25/0x200 [aufs]
[<ffffffffa009ee7c>] aufs_mount+0x8c/0x1b0 [aufs]
[<ffffffff811ced88>] mount_fs+0x48/0x260
[<ffffffff811f434b>] vfs_kern_mount+0x7b/0x190
[<ffffffff811f6f88>] do_mount+0x228/0xca0
[<ffffffff811f7e39>] SyS_mount+0xe9/0x110
[<ffffffff8179fed7>] system_call_fastpath+0x12/0x6f
-> #1 (&sbinfo->si_rwsem){++++++}:
[<ffffffff810b4248>] lock_acquire+0xc8/0x2a0
[<ffffffff8179d4d7>] down_read+0x47/0x60
[<ffffffffa009efe7>] aufs_show_options+0x47/0x7e0 [aufs]
[<ffffffff8121b670>] show_vfsmnt+0x110/0x160
[<ffffffff811f2b56>] m_show+0x16/0x20
[<ffffffff811f9c61>] seq_read+0x3b1/0x4a0
[<ffffffff811c9fb8>] __vfs_read+0x18/0x40
[<ffffffff811cb392>] vfs_read+0x122/0x190
[<ffffffff811cb452>] SyS_read+0x52/0xb0
[<ffffffff8179fed7>] system_call_fastpath+0x12/0x6f
-> #0 (namespace_sem){++++++}:
[<ffffffff810b349b>] __lock_acquire+0x181b/0x1e30
[<ffffffff810b4248>] lock_acquire+0xc8/0x2a0
[<ffffffff8179d454>] down_write+0x44/0x80
[<ffffffff811f597e>] lock_mount+0x8e/0x1e0
[<ffffffff811f6012>] do_add_mount+0x32/0x130
[<ffffffff811f6afc>] finish_automount+0x6c/0xe0
[<ffffffff811d78f6>] follow_managed+0x1c6/0x320
[<ffffffff811d987f>] lookup_fast+0x4ff/0x560
[<ffffffff811dbf37>] path_lookupat+0xc7/0x8a0
[<ffffffff811dc745>] filename_lookup+0x35/0x170
[<ffffffff811dfd46>] user_path_at_empty+0x96/0xe0
[<ffffffff811dfda1>] user_path_at+0x11/0x20
[<ffffffff8120c034>] user_statfs+0x34/0x90
[<ffffffff8120c10b>] SYSC_statfs+0x1b/0x40
[<ffffffff8120c24e>] SyS_statfs+0xe/0x10
[<ffffffff8179fed7>] system_call_fastpath+0x12/0x6f
other info that might help us debug this:
Chain exists of:
namespace_sem --> &sbinfo->si_rwsem --> &sb->s_type->i_mutex_key#2
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&sb->s_type->i_mutex_key#2);
lock(&sbinfo->si_rwsem);
lock(&sb->s_type->i_mutex_key#2);
lock(namespace_sem);
*** DEADLOCK ***
1 lock held by perf/4110:
#0: (&sb->s_type->i_mutex_key#2){+.+.+.}, at: [<ffffffff811f5927>] lock_mount+0x37/0x1e0
stack backtrace:
CPU: 0 PID: 4110 Comm: perf Not tainted 4.1.0aufsD+ #363
Hardware name: Pegatron Pegatron/IPM41, BIOS 0001 02/05/2009
ffffffff85f22880 ffff880021e93908 ffffffff81793ee6 0000000000000000
ffffffff85eed2a0 ffff880021e93958 ffffffff8178fece ffff880021e93958
ffff880021e939c8 ffff880021e8e510 ffff880021e8ec58 ffff880021e8e510
Call Trace:
[<ffffffff81793ee6>] dump_stack+0x4f/0xa2
[<ffffffff8178fece>] print_circular_bug+0x1fb/0x20c
[<ffffffff810b349b>] __lock_acquire+0x181b/0x1e30
[<ffffffff810b4248>] lock_acquire+0xc8/0x2a0
[<ffffffff811f597e>] ? lock_mount+0x8e/0x1e0
[<ffffffff8179d454>] down_write+0x44/0x80
[<ffffffff811f597e>] ? lock_mount+0x8e/0x1e0
[<ffffffff811f597e>] lock_mount+0x8e/0x1e0
[<ffffffff811f6012>] do_add_mount+0x32/0x130
[<ffffffff813b7708>] ? find_next_bit+0x18/0x20
[<ffffffff811f6afc>] finish_automount+0x6c/0xe0
[<ffffffff811d78f6>] follow_managed+0x1c6/0x320
[<ffffffff811d987f>] lookup_fast+0x4ff/0x560
[<ffffffff811da64f>] ? path_init+0xbf/0x8d0
[<ffffffff811dbe00>] ? complete_walk+0x1e0/0x250
[<ffffffff811dbf37>] path_lookupat+0xc7/0x8a0
[<ffffffff811dc745>] filename_lookup+0x35/0x170
[<ffffffff811dfd46>] user_path_at_empty+0x96/0xe0
[<ffffffff8118dce8>] ? might_fault+0xa8/0xb0
[<ffffffff8118dc9f>] ? might_fault+0x5f/0xb0
[<ffffffff8120bf27>] ? do_statfs_native+0xa7/0xc0
[<ffffffff811dfda1>] user_path_at+0x11/0x20
[<ffffffff8120c034>] user_statfs+0x34/0x90
[<ffffffff8120c10b>] SYSC_statfs+0x1b/0x40
[<ffffffff813ae808>] ? lockdep_sys_exit_thunk+0x12/0x14
[<ffffffff8120c24e>] SyS_statfs+0xe/0x10
[<ffffffff8179fed7>] system_call_fastpath+0x12/0x6f
Signed-off-by: J. R. Okajima <hooanon05g@gmail.com>
(cherry picked from commit f440be7d4ac14d1ae004adaee072114fd31e8d83)
|
Sorry for the response delay. The problem is that the include causes a build error when you try to build the module out-of-kernel-tree. I am packaging the aufs4 module for Debian at the moment and I have to remove this include statement to build the code successfully. Maybe you can add a #if-statement around the code to avoid this problem. |
|
Jan Luca Naumann:
Adding #if is possible. J. R. Okajima |
|
I use method 2 to build the module and there is no "../fs/mount.h" that can be included in vfsub.c. |
|
Jan Luca Naumann:
So you didn't specify nor change KDIR make variable, right? J. R. Okajima |
This commit is very similar to a1e4589 2016-08-13 aufs: possible bugfix, temporary lockdep_off for debugfs_create_file but the trigger is debugfs_remove instead of debugfs_create_file. ====================================================== [ INFO: possible circular locking dependency detected ] 4.6.0aufsD+ #370 Not tainted ------------------------------------------------------- mount/11486 is trying to acquire lock: (&sb->s_type->i_mutex_key#2){+.+.+.}, at: [<ffffffff813720d9>] debugfs_remove+0x79/0xc0 but task is already holding lock: (&iinfo->ii_rwsem#2){+++++.}, at: [<ffffffffa00b9530>] do_ii_write_lock+0x170/0x190 [aufs] which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #3 (&iinfo->ii_rwsem#2){+++++.}: [<ffffffff810bf72e>] lock_acquire+0xbe/0x220 [<ffffffff810b96d2>] down_read_nested+0x52/0x70 [<ffffffffa00cdbbb>] aufs_permission+0x9b/0x760 [aufs] [<ffffffff811f7550>] __inode_permission+0xb0/0x140 [<ffffffff811f765a>] inode_permission+0x7a/0xa0 [<ffffffff811e780a>] SyS_access+0xda/0x220 [<ffffffff8182a725>] entry_SYSCALL_64_fastpath+0x18/0xa8 -> #2 (&sbinfo->si_rwsem){++++++}: [<ffffffff810bf72e>] lock_acquire+0xbe/0x220 [<ffffffff818282e7>] down_read+0x47/0x60 [<ffffffffa00a1797>] aufs_show_options+0x47/0x770 [aufs] [<ffffffff8123b0fc>] show_vfsmnt+0x10c/0x150 [<ffffffff812120b7>] m_show+0x17/0x20 [<ffffffff81218dd8>] seq_read+0x398/0x490 [<ffffffff811e9378>] __vfs_read+0x18/0x40 [<ffffffff811eb0e3>] vfs_read+0x143/0x1b0 [<ffffffff811eb1a2>] SyS_read+0x52/0xa0 [<ffffffff8182a725>] entry_SYSCALL_64_fastpath+0x18/0xa8 -> #1 (namespace_sem){++++++}: [<ffffffff810bf72e>] lock_acquire+0xbe/0x220 [<ffffffff81828264>] down_write+0x44/0x80 [<ffffffff81214ece>] lock_mount+0x8e/0x1e0 [<ffffffff81215522>] do_add_mount+0x32/0x130 [<ffffffff81215f7c>] finish_automount+0x6c/0xe0 [<ffffffff811f6f3a>] follow_managed+0x1aa/0x350 [<ffffffff811f87f2>] lookup_fast+0x3f2/0x530 [<ffffffff811f9557>] walk_component+0x87/0x360 [<ffffffff811faaf0>] path_lookupat+0x70/0x150 [<ffffffff811fd9e5>] filename_lookup.part.43+0xd5/0x230 [<ffffffff811fdba8>] filename_lookup+0x68/0x80 [<ffffffff811fdfb1>] user_path_at_empty+0x41/0x50 [<ffffffff8122b017>] user_statfs+0x37/0x90 [<ffffffff8122b0db>] SYSC_statfs+0x1b/0x40 [<ffffffff8122b20e>] SyS_statfs+0xe/0x10 [<ffffffff8182a725>] entry_SYSCALL_64_fastpath+0x18/0xa8 -> #0 (&sb->s_type->i_mutex_key#2){+.+.+.}: [<ffffffff810beb48>] __lock_acquire+0x1738/0x1dc0 [<ffffffff810bf72e>] lock_acquire+0xbe/0x220 [<ffffffff8182580e>] mutex_lock_nested+0x6e/0x500 [<ffffffff813720d9>] debugfs_remove+0x79/0xc0 [<ffffffffa00dd2f2>] dbgaufs_brs_del+0xe2/0x100 [aufs] [<ffffffffa00dc27f>] sysaufs_brs_del+0x2f/0x140 [aufs] [<ffffffffa00a4b27>] au_br_add+0x997/0xd00 [aufs] [<ffffffffa00abd27>] au_opt_br.isra.14+0x57/0x120 [aufs] [<ffffffffa00af044>] au_opts_remount+0xb4/0x290 [aufs] [<ffffffffa00a3762>] aufs_remount_fs+0x252/0x300 [aufs] [<ffffffff811ee3e1>] do_remount_sb+0x71/0x1c0 [<ffffffff81216b11>] do_mount+0x941/0xea0 [<ffffffff8121747a>] SyS_mount+0x10a/0x120 [<ffffffff8182a725>] entry_SYSCALL_64_fastpath+0x18/0xa8 other info that might help us debug this: Chain exists of: &sb->s_type->i_mutex_key#2 --> &sbinfo->si_rwsem --> &iinfo->ii_rwsem#2 Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&iinfo->ii_rwsem#2); lock(&sbinfo->si_rwsem); lock(&iinfo->ii_rwsem#2); lock(&sb->s_type->i_mutex_key#2); *** DEADLOCK *** 5 locks held by mount/11486: #0: (&type->s_umount_key#57){+.+.+.}, at: [<ffffffff812165a9>] do_mount+0x3d9/0xea0 #1: (&type->i_mutex_dir_key#7){+.+.+.}, at: [<ffffffffa00a3713>] aufs_remount_fs+0x203/0x300 [aufs] #2: (&sbinfo->si_rwsem){++++++}, at: [<ffffffffa009fd62>] si_write_lock+0x42/0x1e0 [aufs] #3: (&dinfo->di_rwsem){+++++.}, at: [<ffffffffa00b9fbf>] di_write_lock+0x2f/0x60 [aufs] #4: (&iinfo->ii_rwsem#2){+++++.}, at: [<ffffffffa00b9530>] do_ii_write_lock+0x170/0x190 [aufs] stack backtrace: CPU: 0 PID: 11486 Comm: mount Not tainted 4.6.0aufsD+ #370 Hardware name: Pegatron Pegatron/IPM41, BIOS 0001 02/05/2009 0000000000000000 ffff88002b793908 ffffffff814084e7 ffffffff86111170 ffffffff86178580 ffff88002b793958 ffffffff8116b125 ffff88002b793948 ffff88002b7939e8 ffff88002d543108 ffff88002d542940 ffff88002d543108 Call Trace: [<ffffffff814084e7>] dump_stack+0x67/0x90 [<ffffffff8116b125>] print_circular_bug+0x202/0x213 [<ffffffff810beb48>] __lock_acquire+0x1738/0x1dc0 [<ffffffff81827e3e>] ? mutex_unlock+0xe/0x10 [<ffffffff810bf72e>] lock_acquire+0xbe/0x220 [<ffffffff813720d9>] ? debugfs_remove+0x79/0xc0 [<ffffffff813720d9>] ? debugfs_remove+0x79/0xc0 [<ffffffff813720d9>] ? debugfs_remove+0x79/0xc0 [<ffffffff8182580e>] mutex_lock_nested+0x6e/0x500 [<ffffffff813720d9>] ? debugfs_remove+0x79/0xc0 [<ffffffff81418ff1>] ? lockref_get+0x11/0x30 [<ffffffff813720d9>] debugfs_remove+0x79/0xc0 [<ffffffffa00dd2f2>] dbgaufs_brs_del+0xe2/0x100 [aufs] [<ffffffffa00dc27f>] sysaufs_brs_del+0x2f/0x140 [aufs] [<ffffffffa00a4b27>] au_br_add+0x997/0xd00 [aufs] [<ffffffffa00abd27>] au_opt_br.isra.14+0x57/0x120 [aufs] [<ffffffffa00af044>] au_opts_remount+0xb4/0x290 [aufs] [<ffffffffa00b9530>] ? do_ii_write_lock+0x170/0x190 [aufs] [<ffffffffa00a3762>] aufs_remount_fs+0x252/0x300 [aufs] [<ffffffff811ee3e1>] do_remount_sb+0x71/0x1c0 [<ffffffff81216b11>] do_mount+0x941/0xea0 [<ffffffff812160ed>] ? copy_mount_options+0xfd/0x1c0 [<ffffffff812160d9>] ? copy_mount_options+0xe9/0x1c0 [<ffffffff8121747a>] SyS_mount+0x10a/0x120 [<ffffffff8182a725>] entry_SYSCALL_64_fastpath+0x18/0xa8 (cherry picked from commit 3148d7ee2d491f9db12393f4b3102c36acce80a6)
|
I use DKMS to build the module. I do not change KDIR and the modules builds without problems if I remove the include. DKMS has a variable "$kernel_source_dir" that could be passed to the Makefile as e.g. KDIR, anyway. If you can add a way so the include can be found, even if the module is built out-of-tree, this would be nice :-) |
|
Btw, you can find the DKMS file I use for building here: https://github.com/JanLuca/aufs4-debian/blob/master/debian/aufs4-dkms.dkms |
|
Jan Luca Naumann:
Then I'd ask again. J. R. Okajima |
|
I have "/lib/modules/$(shell uname -r)/source" as kernel source dir on my machine. The KDIR variable in the Makefile is OK as it is. |
|
Jan Luca Naumann:
I am confused now. ~$ mkdir /tmp/w Notice these points.
Finally fs/aufs/vfsub.c is compiled successfully. I'd suggest you to try "make" instead of "dkms" and see the difference J. R. Okajima |
|
So I had some time today to debug the problem a little bit more in detail: The problem is that the header file "fs/mount.h" seems not to be part of the (public) header file generated by the kernel Makefile (only linux/mount.h is exported). Thus it is not included in e.g. the header package of Debian which is used to build e.g. DKMS modules. How important is it to include the header file? (For completeness the gcc-line when the compilation failed:
) |
|
Jan Luca Naumann:
Without fs/mount.h, some features won't be compiled such as exporting I understand that your build system DKMS (which I have never tried) J. R. Okajima |
|
------- Blind-Carbon-Copy From: sfjro@users.sourceforge.net Philipp Marek:
Sorry for the long delay. Thanx for reporting, two of you. commit 348da45314afe6fc88e6f91a74da4587ec6555af diff --git a/fs/aufs/export.c b/fs/aufs/export.c
------- End of Blind-Carbon-Copy |
linux/fs/mount.h is included from two aufs source files, fs/aufs/export.c and fs/aufs/vfsub.c. For export.c, it is unnecessary which means a build dependency bug. The bug was born back in 2012. c70a5cf 2012-01-13 aufs: tiny for 3.3, arg for iterate_mounts() For vfsub.c, it is necessary and it is not a bug. But it is just for CONFIG_AUFS_BR_FUSE only. So it should be refined by "#ifdef CONFIG_AUFS_BR_FUSE". Reported-by: Jan Luca Naumann <j.naumann@fu-berlin.de> See-also: sfjro/aufs4-standalone#1 Reported-by: Philipp Marek <philipp.marek@linbit.com> See-also: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=843846 Signed-off-by: J. R. Okajima <hooanon05g@gmail.com>
The include seems not to be necessary and causes problems when
compiling the module not in kernel source tree.