Re: [BUG] jbd2: lockdep deadlock warning

From: Jan Kara
Date: Mon Sep 19 2016 - 03:59:21 EST


Hi!

On Fri 16-09-16 15:35:39, Thomas Gleixner wrote:
> Jan,
>
> wer are currently moving the RT patch to 4.8 and on our test runs we
> triggered the following lockdep splat:
>
> [ 153.887910] ======================================================
> [ 153.887911] [ INFO: possible circular locking dependency detected ]
> [ 153.887912] 4.8.0-rc6-rt0+ #679 Tainted: G W
> [ 153.887912] -------------------------------------------------------
> [ 153.887913] find/2537 is trying to acquire lock:
> [ 153.887923] (&journal->j_state_lock){+.+...}, at: [<ffffffff81300ed0>] jbd2_log_start_commit+0x20/0x40
> [ 153.887924]
> [ 153.887924] but task is already holding lock:
> [ 153.887925] (jbd2_handle){++++..}, at: [<ffffffff812f5411>] start_this_handle+0x111/0x470
> [ 153.887925]
> [ 153.887925] which lock already depends on the new lock.
> [ 153.887925]
> [ 153.887926]
> [ 153.887926] the existing dependency chain (in reverse order) is:
> [ 153.887927]
> [ 153.887927] -> #1 (jbd2_handle){++++..}:
> [ 153.887931] [<ffffffff810cfb5f>] lock_acquire+0x12f/0x2c0
> [ 153.887932] [<ffffffff812f4fed>] add_transaction_credits+0x4d/0x310
> [ 153.887933] [<ffffffff812f5409>] start_this_handle+0x109/0x470
> [ 153.887933] [<ffffffff812f5d1b>] jbd2__journal_start+0xdb/0x380
> [ 153.887936] [<ffffffff812d96a0>] __ext4_journal_start_sb+0x90/0x2b0
> [ 153.887940] [<ffffffff8129d10e>] ext4_file_open+0x11e/0x230
> [ 153.887946] [<ffffffff8120c808>] do_dentry_open.isra.16+0x168/0x310
> [ 153.887948] [<ffffffff8120dbe5>] vfs_open+0x45/0x70
> [ 153.887950] [<ffffffff8121f30c>] path_openat+0x48c/0xa20
> [ 153.887951] [<ffffffff81220b9e>] do_filp_open+0x7e/0xe0
> [ 153.887953] [<ffffffff81215164>] do_open_execat+0x64/0x150
> [ 153.887954] [<ffffffff812174a8>] do_execveat_common.isra.43+0x278/0x950
> [ 153.887955] [<ffffffff81217f30>] compat_SyS_execve+0x40/0x50
> [ 153.887956] [<ffffffff810032d2>] do_fast_syscall_32+0xb2/0x2f0
> [ 153.887960] [<ffffffff818e7b31>] entry_SYSENTER_compat+0x51/0x60

Thanks for report! This is a bug in lockdep annotation in
add_transaction_credits() where I mistakenly added a call to
jbd2_might_wait_for_commit() before actually releasing the j_state_lock.
I'll send a fix. I'm surprised this didn't hit in my testing...

Honza
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR