Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1081717ybl; Tue, 3 Dec 2019 01:08:47 -0800 (PST) X-Google-Smtp-Source: APXvYqyDPj8l1KqTAkL24/y3+sduaIxTbUJMHxxQZHGNGxWRY8M0aZmDRSgkjuET44kTKwwyjsyd X-Received: by 2002:a05:6830:1498:: with SMTP id s24mr2445464otq.208.1575364127091; Tue, 03 Dec 2019 01:08:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575364127; cv=none; d=google.com; s=arc-20160816; b=o4JeBSO7Dn3Zq6o20shpyzPZ+6eLCzqwOn1V7NZ3d2BNVSBIu5Zlp3kqtOERyg9+WA GTrVu0q3PMnvlqsDR4236b2RWF2J7gdsdoK0qXbI5uta664mbCvmb9SzG3EReVRqmPth 7ugB1v42Lq2qlzmFR4wQvzPIZC0EN/sjwT46r6/k83TAqOvceyH1WTjlzm+Pn+1NZ9cH PHPFi/WCv4Z4XA4rr+ROob4aZWsaSlvJVOArYdFTesVYtPx4QZBibtmBqfrFK4Lih9/h dgXdq/ASaE8JB2UmMfwyCV5zKwrvisEVDlGsxqTB+l1cQOcm0ulPtLcl/7R4tlBLhp/4 5oUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=Y20fe06HRE29fNGaN1g8zNpFyMSOmBwkYidxPZExvVU=; b=WPwY7cYukmPKxsg/p2s7R5WoZiTkwT1jkrmQWFziFhB6i/cOGuzeQ9n4f9UBZywxb7 YJsBv6h6vhlIEJSJsHELQt8k4VAN5NpA0r0WkqLhT2CPGh9BCHADMmUcqW5WrMrA/A/X XNDZLSrGGnwYFzi/UzoIYnuRKVMIsEJo3x1oeSRwWC9J7no8xaXLJxzvWZsVUAmParWc IAUB/GIlkcAFOvESmiFuXBxfDjWzB7zoF2Uhv1cubeeMOh8TL6Lv4zpl/J52ZWGdcL57 wJqGEazYtwYNvm61SQUEeUSmpEMmmQzRpYxxFwLp8WRBqA3zflVVN4XWmrv+vbYFdMP6 hUWA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f19si952217oti.192.2019.12.03.01.08.36; Tue, 03 Dec 2019 01:08:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726182AbfLCJG4 (ORCPT + 99 others); Tue, 3 Dec 2019 04:06:56 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:32966 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726086AbfLCJGz (ORCPT ); Tue, 3 Dec 2019 04:06:55 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id A2D401B315D0F6C06F56; Tue, 3 Dec 2019 17:06:52 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.439.0; Tue, 3 Dec 2019 17:06:45 +0800 From: "zhangyi (F)" To: CC: , , , , , Subject: [PATCH v2 2/4] ext4, jbd2: ensure panic when journal aborting with zero errno Date: Tue, 3 Dec 2019 17:27:54 +0800 Message-ID: <20191203092756.26129-3-yi.zhang@huawei.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20191203092756.26129-1-yi.zhang@huawei.com> References: <20191203092756.26129-1-yi.zhang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.124.28] X-CFilter-Loop: Reflected Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org JBD2_REC_ERR flag used to indicate the errno has been updated when jbd2 aborted, and then __ext4_abort() and ext4_handle_error() can invoke panic if ERRORS_PANIC is specified. But if the journal has been aborted with zero errno, jbd2_journal_abort() didn't set this flag so we can no longer panic. Fix this by rename JBD2_REC_ERR to JBD2_ABORT_DONE and set such flag even if there is no need to record errno in the jbd2 super block. Fixes: 4327ba52afd03 ("ext4, jbd2: ensure entering into panic after recording an error in superblock") Signed-off-by: zhangyi (F) --- fs/ext4/super.c | 4 ++-- fs/jbd2/journal.c | 10 +++++----- include/linux/jbd2.h | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index dd654e53ba3d..25b0c883bd15 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -482,7 +482,7 @@ static void ext4_handle_error(struct super_block *sb) sb->s_flags |= SB_RDONLY; } else if (test_opt(sb, ERRORS_PANIC)) { if (EXT4_SB(sb)->s_journal && - !(EXT4_SB(sb)->s_journal->j_flags & JBD2_REC_ERR)) + !(EXT4_SB(sb)->s_journal->j_flags & JBD2_ABORT_DONE)) return; panic("EXT4-fs (device %s): panic forced after error\n", sb->s_id); @@ -701,7 +701,7 @@ void __ext4_abort(struct super_block *sb, const char *function, } if (test_opt(sb, ERRORS_PANIC) && !system_going_down()) { if (EXT4_SB(sb)->s_journal && - !(EXT4_SB(sb)->s_journal->j_flags & JBD2_REC_ERR)) + !(EXT4_SB(sb)->s_journal->j_flags & JBD2_ABORT_DONE)) return; panic("EXT4-fs panic from previous error\n"); } diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 1c58859aa592..a78b07841080 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -2118,12 +2118,12 @@ static void __journal_abort_soft (journal_t *journal, int errno) __jbd2_journal_abort_hard(journal); - if (errno) { + if (errno) jbd2_journal_update_sb_errno(journal); - write_lock(&journal->j_state_lock); - journal->j_flags |= JBD2_REC_ERR; - write_unlock(&journal->j_state_lock); - } + + write_lock(&journal->j_state_lock); + journal->j_flags |= JBD2_ABORT_DONE; + write_unlock(&journal->j_state_lock); } /** diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h index 603fbc4e2f70..71cab887fb98 100644 --- a/include/linux/jbd2.h +++ b/include/linux/jbd2.h @@ -1248,7 +1248,8 @@ JBD2_FEATURE_INCOMPAT_FUNCS(csum3, CSUM_V3) #define JBD2_ABORT_ON_SYNCDATA_ERR 0x040 /* Abort the journal on file * data write error in ordered * mode */ -#define JBD2_REC_ERR 0x080 /* The errno in the sb has been recorded */ +#define JBD2_ABORT_DONE 0x080 /* Abort done, the errno in the sb has been + * recorded if necessary */ /* * Function declarations for the journaling transaction and buffer -- 2.17.2