From: Dmitry Monakhov Date: Tue, 16 Sep 2014 18:50:50 +0000 (-0400) Subject: jbd2: jbd2_log_wait_for_space improve error detetcion X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1245799f752fa817a030b3b4448466e83ee7d61d;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git jbd2: jbd2_log_wait_for_space improve error detetcion If EIO happens after we have dropped j_state_lock, we won't notice that the journal has been aborted. So it is reasonable to move this check after we have grabbed the j_checkpoint_mutex and re-grabbed the j_state_lock. This patch helps to prevent false positive complain after EIO. #DMESG: __jbd2_log_wait_for_space: needed 8448 blocks and only had 8386 space available __jbd2_log_wait_for_space: no way to get more journal space in ram1-8 ------------[ cut here ]------------ WARNING: CPU: 15 PID: 6739 at fs/jbd2/checkpoint.c:168 __jbd2_log_wait_for_space+0x188/0x200() Modules linked in: brd iTCO_wdt lpc_ich mfd_core igb ptp dm_mirror dm_region_hash dm_log dm_mod CPU: 15 PID: 6739 Comm: fsstress Tainted: G W 3.17.0-rc2-00429-g684de57 #139 Hardware name: Intel Corporation W2600CR/W2600CR, BIOS SE5C600.86B.99.99.x028.061320111235 06/13/2011 00000000000000a8 ffff88077aaab878 ffffffff815c1a8c 00000000000000a8 0000000000000000 ffff88077aaab8b8 ffffffff8106ce8c ffff88077aaab898 ffff8807c57e6000 ffff8807c57e6028 0000000000002100 ffff8807c57e62f0 Call Trace: [] dump_stack+0x51/0x6d [] warn_slowpath_common+0x8c/0xc0 [] warn_slowpath_null+0x1a/0x20 [] __jbd2_log_wait_for_space+0x188/0x200 [] start_this_handle+0x4da/0x7b0 [] ? local_clock+0x25/0x30 [] ? lockdep_init_map+0xe7/0x180 [] jbd2__journal_start+0xdc/0x1d0 [] ? __ext4_new_inode+0x7f4/0x1330 [] __ext4_journal_start_sb+0xf8/0x110 [] __ext4_new_inode+0x7f4/0x1330 [] ? lock_release_holdtime+0x29/0x190 [] ext4_create+0x8b/0x150 [] vfs_create+0x7b/0xb0 [] do_last+0x7db/0xcf0 [] ? inode_permission+0x4d/0x50 [] path_openat+0x242/0x590 [] ? __alloc_fd+0x36/0x140 [] do_filp_open+0x4a/0xb0 [] ? __alloc_fd+0x121/0x140 [] do_sys_open+0x170/0x220 [] SyS_open+0x1e/0x20 [] SyS_creat+0x16/0x20 [] system_call_fastpath+0x16/0x1b ---[ end trace cd71c831f82059db ]--- Signed-off-by: Dmitry Monakhov Signed-off-by: Theodore Ts'o --- diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c index 9ffb19cf376b..1fbf59938cc0 100644 --- a/fs/jbd2/checkpoint.c +++ b/fs/jbd2/checkpoint.c @@ -115,8 +115,6 @@ void __jbd2_log_wait_for_space(journal_t *journal) nblocks = jbd2_space_needed(journal); while (jbd2_log_space_left(journal) < nblocks) { - if (journal->j_flags & JBD2_ABORT) - return; write_unlock(&journal->j_state_lock); mutex_lock(&journal->j_checkpoint_mutex); @@ -132,6 +130,10 @@ void __jbd2_log_wait_for_space(journal_t *journal) * trace for forensic evidence. */ write_lock(&journal->j_state_lock); + if (journal->j_flags & JBD2_ABORT) { + mutex_unlock(&journal->j_checkpoint_mutex); + return; + } spin_lock(&journal->j_list_lock); nblocks = jbd2_space_needed(journal); space_left = jbd2_log_space_left(journal);