Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751425AbbK0FXS (ORCPT ); Fri, 27 Nov 2015 00:23:18 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:54927 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750764AbbK0FXP (ORCPT ); Fri, 27 Nov 2015 00:23:15 -0500 X-AuditID: cbfee690-f79e96d0000073db-bf-5657e8c174cd Date: Fri, 27 Nov 2015 05:23:13 +0000 (GMT) From: Daeho Jeong Subject: Re: [PATCH 3.2 16/52] ext4, jbd2: ensure entering into panic after recording an error in superblock To: Ben Hutchings , "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" Cc: "akpm@linux-foundation.org" , "Theodore Ts'o" , =?utf-8?Q?=EC=9A=B0=ED=98=B8=EB=B9=88?= , =?utf-8?Q?=EC=A0=95=EB=8C=80=ED=98=B8?= Reply-to: daeho.jeong@samsung.com MIME-version: 1.0 X-MTR: 20151127052223823@daeho.jeong Msgkey: 20151127052223823@daeho.jeong X-EPLocale: ko_KR.utf-8 X-Priority: 3 X-EPWebmail-Msg-Type: personal X-EPWebmail-Reply-Demand: 0 X-EPApproval-Locale: X-EPHeader: ML X-MLAttribute: X-RootMTR: 20151127052223823@daeho.jeong X-ParentMTR: X-ArchiveUser: EV X-CPGSPASS: N X-ConfirmMail: N,general Content-type: text/plain; charset=utf-8 MIME-version: 1.0 Message-id: <1706295348.341771448601793066.JavaMail.weblogic@epmlwas07a> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprFJsWRmVeSWpSXmKPExsVy+t8zbd2DL8LDDL616Flc3jWHzYHR4/Mm uQDGqAZGm8Si5IzMslSF1Lzk/JTMvHRbpdAQN10LJYWM/OISW6VoIwNjPSNTEz0jE3M9S4NY KyNTJYW8xNxUW6UKXaheJYWi5AKg2tzKYqABOal6UHG94tS8FIes/FKQS/SKE3OLS/PS9ZLz c5UUyhJzSoFGKOknTGXMaOwIKX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lPjf+Ya9i5GDg0VAVeJhSxhIDZuAjsTKyR+YQWxhgRyJ31s/MYLUiwjMZ5To/niHGcRhFnjF KPH0wFJmiG2KEme2fQTbwCsgKHFy5hMWiG0qElumfoKKq0rMar7OBhEXl7gw9xI7hM0rMaP9 KVS9nMS0r2uYIWxpifOzNjDCXL34+2OoOL/Esds7oD4TkJh65iBUjabE+rnToebzSaxZ+BZq pqDE6WvdzDC77m+ZC9UrIbG15QnYbcxA90/pfggOCGaQObv00b3CK+Ah8WLHHZYJjLKzkKRm IemehdCNrGQBI8sqRtHUguSC4qT0CmO94sTc4tK8dL3k/NxNjOBE9GzxDsb/560PMQpwMCrx 8Eqkh4cJsSaWFVfmHmKU4GBWEuFlvAYU4k1JrKxKLcqPLyrNSS0+xGgKjLSJzFKiyfnAJJlX Em9obGBsaGhpbmBqaGShJM57e59fmJBAemJJanZqakFqEUwfEwenVANj1/moGd8tWA9PDF1b 3Jd2UmJl6XnZI6GcM6Jy/X4XeqlIffTbmm7R7vjudtv+5JWffZy8fP5kutzee+dmiZmoxK9p d+9usPV03+jJlPEkXyJI/PofLfl7nQJ2e37lNYbNy42X3H7ztkvc5+dpE+w6r2b8uLa97Mx0 1hd3j91vO/eSaZ+i625NJZbijERDLeai4kQAdNOiHloDAAA= DLP-Filter: Pass X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id tAR5NMnq006684 Content-Length: 3680 Lines: 109 It looks good. Thank you. :-) ------- Original Message ------- Sender : Ben Hutchings Date : 2015-11-25 07:33 (GMT+09:00) Title : [PATCH 3.2 16/52] ext4, jbd2: ensure entering into panic after recording an error in superblock 3.2.74-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Daeho Jeong commit 4327ba52afd03fc4b5afa0ee1d774c9c5b0e85c5 upstream. If a EXT4 filesystem utilizes JBD2 journaling and an error occurs, the journaling will be aborted first and the error number will be recorded into JBD2 superblock and, finally, the system will enter into the panic state in "errors=panic" option. But, in the rare case, this sequence is little twisted like the below figure and it will happen that the system enters into panic state, which means the system reset in mobile environment, before completion of recording an error in the journal superblock. In this case, e2fsck cannot recognize that the filesystem failure occurred in the previous run and the corruption wouldn't be fixed. Task A Task B ext4_handle_error() -> jbd2_journal_abort() -> __journal_abort_soft() -> __jbd2_journal_abort_hard() | -> journal->j_flags |= JBD2_ABORT; | | __ext4_abort() | -> jbd2_journal_abort() | | -> __journal_abort_soft() | | -> if (journal->j_flags & JBD2_ABORT) | | return; | -> panic() | -> jbd2_journal_update_sb_errno() Tested-by: Hobin Woo Signed-off-by: Daeho Jeong Signed-off-by: Theodore Ts'o Signed-off-by: Ben Hutchings --- fs/ext4/super.c | 12 ++++++++++-- fs/jbd2/journal.c | 6 +++++- include/linux/jbd2.h | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -463,9 +463,13 @@ static void ext4_handle_error(struct sup ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only"); sb->s_flags |= MS_RDONLY; } - if (test_opt(sb, ERRORS_PANIC)) + if (test_opt(sb, ERRORS_PANIC)) { + if (EXT4_SB(sb)->s_journal && + !(EXT4_SB(sb)->s_journal->j_flags & JBD2_REC_ERR)) + return; panic("EXT4-fs (device %s): panic forced after error\n", sb->s_id); + } } void __ext4_error(struct super_block *sb, const char *function, @@ -628,8 +632,12 @@ void __ext4_abort(struct super_block *sb jbd2_journal_abort(EXT4_SB(sb)->s_journal, -EIO); save_error_info(sb, function, line); } - if (test_opt(sb, ERRORS_PANIC)) + if (test_opt(sb, ERRORS_PANIC)) { + if (EXT4_SB(sb)->s_journal && + !(EXT4_SB(sb)->s_journal->j_flags & JBD2_REC_ERR)) + return; panic("EXT4-fs panic from previous error\n"); + } } void ext4_msg(struct super_block *sb, const char *prefix, const char *fmt, ...) --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -1956,8 +1956,12 @@ static void __journal_abort_soft (journa __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); + } } /** --- a/include/linux/jbd2.h +++ b/include/linux/jbd2.h @@ -954,6 +954,7 @@ struct journal_s #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 */ /* * Function declarations for the journaling transaction and buffer????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?