From patchwork Sat Jan 7 12:01:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Changwei Ge X-Patchwork-Id: 9503007 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 868E8606E0 for ; Sat, 7 Jan 2017 12:03:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73C452793B for ; Sat, 7 Jan 2017 12:03:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 64BD8284B1; Sat, 7 Jan 2017 12:03:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,HTML_MESSAGE, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from aserp1040.oracle.com (aserp1040.oracle.com [141.146.126.69]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2F0AC2793B for ; Sat, 7 Jan 2017 12:03:10 +0000 (UTC) Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v07C2L74024048 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 7 Jan 2017 12:02:22 GMT Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v07C2Hd3021818 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 7 Jan 2017 12:02:18 GMT Received: from localhost ([127.0.0.1] helo=lb-oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1cPphR-0007R1-IC; Sat, 07 Jan 2017 04:02:17 -0800 Received: from userv0022.oracle.com ([156.151.31.74]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1cPpgm-0007IH-3q for ocfs2-devel@oss.oracle.com; Sat, 07 Jan 2017 04:01:36 -0800 Received: from userp1030.oracle.com (userp1030.oracle.com [156.151.31.80]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v07C1Zx6011732 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Sat, 7 Jan 2017 12:01:35 GMT Received: from userp2030.oracle.com (userp2030.oracle.com [156.151.31.89]) by userp1030.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v07C1XDt020093 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Sat, 7 Jan 2017 12:01:35 GMT Received: from pps.filterd (userp2030.oracle.com [127.0.0.1]) by userp2030.oracle.com (8.16.0.17/8.16.0.17) with SMTP id v07Bvgtb019786 for ; Sat, 7 Jan 2017 12:01:33 GMT Authentication-Results: oracle.com; spf=none smtp.mailfrom=ge.changwei@h3c.com Received: from h3cmg01-ex.h3c.com (smtp.h3c.com [60.191.123.56]) by userp2030.oracle.com with ESMTP id 27tsnwpd0h-1 for ; Sat, 07 Jan 2017 12:01:32 +0000 Received: from BJHUB02-EX.srv.huawei-3com.com (unknown [10.63.20.170]) by h3cmg01-ex.h3c.com with smtp id 62dc_04b8_777385d9_9892_4fab_903b_78952b0fa0c6; Sat, 07 Jan 2017 20:01:21 +0800 Received: from H3CMLB12-EX.srv.huawei-3com.com ([fe80::10fe:abde:731b:fdde]) by BJHUB02-EX.srv.huawei-3com.com ([::1]) with mapi id 14.03.0248.002; Sat, 7 Jan 2017 20:01:07 +0800 From: Gechangwei To: "ocfs2-devel@oss.oracle.com" , "akpm@linux-foundation.org" Thread-Topic: [PATCH] ocfs2/journal: fix umount hang after flushing journal failure Thread-Index: AdJo3bmHeqQ1s0sSTAKU7YOIQjK5sg== Date: Sat, 7 Jan 2017 12:01:06 +0000 Message-ID: <63ADC13FD55D6546B7DECE290D39E37342E739A1@H3CMLB12-EX.srv.huawei-3com.com> Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.96.76.110] MIME-Version: 1.0 X-PDR: PASS X-ServerName: smtp.h3c.com X-Proofpoint-SPF-Result: None X-Proofpoint-Virus-Version: vendor=nai engine=5800 definitions=8400 signatures=670795 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1701070193 Subject: [Ocfs2-devel] [PATCH] ocfs2/journal: fix umount hang after flushing journal failure X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Source-IP: userv0021.oracle.com [156.151.31.71] X-Virus-Scanned: ClamAV using ClamSMTP Hi, When journal flushing in ocfs2_commit_cache() fails, following umount procedure at stage of shutting journal may be blocked due to non-zero transactions number. Once jbd2_journal_flush() fails, the journal will be marked as ABORT state inner JBD2. There is no way to come back afterwards. So there is no chance to set transactions number to zero, thus, shutting journal may be blocked . ocfs2_commit_thread() ocfs2_commit_cache() jbd2_journal_flush() -> failure takes journal into ABORT state, thus, transaction number will never set to zero The back trace is cited blow: [] kthread_stop+0x4c/0x150 [] ocfs2_journal_shutdown+0xa7/0x400 [ocfs2] [] ocfs2_dismount_volume+0xbe/0x4a0 [ocfs2] [] ocfs2_put_super+0x37/0xb0 [ocfs2] [] generic_shutdown_super+0x7e/0x110 [] kill_block_super+0x30/0x80 [] deactivate_locked_super+0x59/0x90 [] deactivate_super+0x4e/0x70 [] cleanup_mnt+0x43/0x90 [] __cleanup_mnt+0x12/0x20 [] task_work_run+0xb7/0xf0 [] do_notify_resume+0x8c/0xa0 [] int_signal+0x12/0x17 [] 0xffffffffffffffff Through crash debug tool, It can seen that j_num_trans field is set to 2. struct ocfs2_journal { j_state = OCFS2_JOURNAL_IN_SHUTDOWN, j_journal = 0xffff8800b4926000, j_inode = 0xffff880122aba298, j_osb = 0xffff880093caa000, j_bh = 0xffff8800a09df888, j_num_trans = { counter = 0x2 }, j_lock = { { rlock = { raw_lock = { { To solve this issue, I propose a patch. Any comments will be welcomed. Since journal has been marked as ABORT and flushing journal failure will free all corresponding buffer heads, it will be safe to directly set transactions number to zero. From 98f42f5f52851ed84eb372a3e09a413a30ea2664 Mon Sep 17 00:00:00 2001 From: gechangwei Date: Sat, 7 Jan 2017 19:48:13 +0800 Subject: [PATCH] fix umount hang after flushing journal failure Signed-off-by: gechangwei --- fs/ocfs2/journal.c | 1 + 1 file changed, 1 insertion(+) -- 2.5.1.windows.1 ------------------------------------------------------------------------------------------------------------------------------------- 本邮件及其附件含有杭州华三通信技术有限公司的保密信息,仅限于发送给上面地址中列出 的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制、 或散发)本邮件中的信息。如果您错收了本邮件,请您立即电话或邮件通知发件人并删除本 邮件! This e-mail and its attachments contain confidential information from H3C, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it! diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index a244f14..dab2094 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c @@ -326,6 +326,7 @@ static int ocfs2_commit_cache(struct ocfs2_super *osb) status = jbd2_journal_flush(journal->j_journal); jbd2_journal_unlock_updates(journal->j_journal); if (status < 0) { + atomic_set(&journal->j_num_trans, 0); up_write(&journal->j_trans_barrier); mlog_errno(status); goto finally;