From patchwork Mon Nov 19 08:07:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junxiao Bi X-Patchwork-Id: 10688259 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C488515A7 for ; Mon, 19 Nov 2018 08:09:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B340129A55 for ; Mon, 19 Nov 2018 08:09:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A779F29A60; Mon, 19 Nov 2018 08:09:50 +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=-5.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4581429A55 for ; Mon, 19 Nov 2018 08:09:50 +0000 (UTC) Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wAJ88W0r109063; Mon, 19 Nov 2018 08:09:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : date : message-id : in-reply-to : references : subject : list-id : list-unsubscribe : list-archive : list-post : list-help : list-subscribe : mime-version : content-type : content-transfer-encoding : sender; s=corp-2018-07-02; bh=ufkgZu2ErJRdWpIROse3NzY/NLgjpRU6ywYBOczuAs4=; b=IM73QciPqAGz+pPT2G+R+eoYMiGFHKT0Xs95BwYczB/v8vxxLT0ManYWltRORYbLKPfP xQBOHf+fKGCmcs2j5XwTX/7ZhcejMhoMPD5Nh2ewO66TaGldP0epHudE6PX6Hghy89yT v3hQXhL02Fcm06DYKTfWWchoyjLY1HjH4xH7MjAHz1wfofGnWDIP+9V+ATW/azr840ii w/3avKPyfTFdttDozyBlxQwKWwGCf+XfTLCLOyFO+gHzsQtPKaqInAUHQLFHkWhdY9jk fUOk2izB2PsdjnOuCLLLc8QmXhL4Xgisnd6Rn2vy9lxJsc4ha5wTW6wUMdPtR/If2jkw ag== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2ntaxpvk3r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 19 Nov 2018 08:09:35 +0000 Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wAJ89Z1C017488 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 19 Nov 2018 08:09:35 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 1gOech-0003LX-Cv; Mon, 19 Nov 2018 00:09:35 -0800 Received: from userv0021.oracle.com ([156.151.31.71]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1gOebr-0003J6-5V for ocfs2-devel@oss.oracle.com; Mon, 19 Nov 2018 00:08:43 -0800 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wAJ88gNr027966 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 19 Nov 2018 08:08:42 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wAJ88fkR002339; Mon, 19 Nov 2018 08:08:42 GMT Received: from jubi-laptop.cn.oracle.com (/10.8.169.172) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 19 Nov 2018 00:08:41 -0800 From: Junxiao Bi To: ocfs2-devel@oss.oracle.com Date: Mon, 19 Nov 2018 16:07:25 +0800 Message-Id: <20181119080725.13059-2-junxiao.bi@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181119080725.13059-1-junxiao.bi@oracle.com> References: <20181119080725.13059-1-junxiao.bi@oracle.com> Subject: [Ocfs2-devel] [PATCH V2 2/2] ocfs2: clear journal dirty flag after shutdown journal 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: , MIME-Version: 1.0 Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9081 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811190078 X-Virus-Scanned: ClamAV using ClamSMTP Dirty flag of the journal should be cleared at the last stage of umount, if do it before jbd2_journal_destroy(), then some metadata in uncommitted transaction could be lost due to io error, but as dirty flag of journal was already cleared, we can't find that until run a full fsck. This may cause system panic or other corruption. Signed-off-by: Junxiao Bi Cc: Yiwen Jiang Cc: Jun Piao Reviewed-by: Yiwen Jiang Reviewed-by: Joseph Qi --- fs/ocfs2/journal.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) V1 -> V2: pointed by Yiwen, need check return value of jbd2_journal_destroy diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index 13f8e097babf..b51bb873441f 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c @@ -986,7 +986,8 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb) mlog_errno(status); } - if (status == 0) { + /* Shutdown the kernel journal system */ + if (!jbd2_journal_destroy(journal->j_journal) && !status) { /* * Do not toggle if flush was unsuccessful otherwise * will leave dirty metadata in a "clean" journal @@ -995,9 +996,6 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb) if (status < 0) mlog_errno(status); } - - /* Shutdown the kernel journal system */ - jbd2_journal_destroy(journal->j_journal); journal->j_journal = NULL; OCFS2_I(inode)->ip_open_count--;