From patchwork Fri Jan 1 16:40:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinoh Kang X-Patchwork-Id: 355969 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41A48C433DB for ; Fri, 1 Jan 2021 16:42:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F2382221F2 for ; Fri, 1 Jan 2021 16:42:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727088AbhAAQlq (ORCPT ); Fri, 1 Jan 2021 11:41:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726798AbhAAQlp (ORCPT ); Fri, 1 Jan 2021 11:41:45 -0500 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6085CC061573 for ; Fri, 1 Jan 2021 08:41:05 -0800 (PST) Received: by mail-pg1-x536.google.com with SMTP id c132so3395059pga.3 for ; Fri, 01 Jan 2021 08:41:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:references:autocrypt:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=a27rHu4d8lntwVdZ++/xZempEfmxB12JDx16Z8JU+6c=; b=FUcWmsA2iD1HEXTKfRyR9j14bLiwFyt2ek8nidUuEHnqgywdq5OvscKgq25RVYPlFy vnYTN5W68phQxaCs5lhlIQslszA+zRT9OhTRtDculpg5wylNY/y6F3Dwhc6/jo4WnI10 SKK33ItpEzUOch3W9uwD/4EIuLWAggLKvwwrSkVBDxljQKC85LhPdTzsr5ERg/R+MBoQ 5e+MkfTgCCG12VO+bAFitm9+YhCO0tzkuG4tceVwE5plG+L+9lM6PcdekraNPfhb7M7V MI2h5jtSaqtUYmgkX/wSwG496Fy+/B9Xyw0A/exNbhT236107RVFMAN/T09ycs2G4bWM M+sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=a27rHu4d8lntwVdZ++/xZempEfmxB12JDx16Z8JU+6c=; b=uK4MEG7+0yEqohVhtUhR+SeghoQNCbDjlKzHrvPNf3rzxZmX3RLWZNfVhPzLtqgcS4 T7BMUgCZPupGyqlfQA0BBp/6QIbQ8nr0TaSNO3CBRpUxwklC9MY0qg6uLaiOZn3lL9S1 MQOBZDM7M2NdjseblsB1Xs5843Hw8hk7cJV8fl1z8VdnftwzCn3Kv24KfreJUoKIv/md GmGhK5g9E5a3idO1eMmRNyVRunbpiAmSfEDwBb7ZH9LPeDs3SAEDiySnZvYoDqwo/z8F WmplyVOZz8MXuhcZUXkg/rzttezr/fJUlGHJmpYHbB6ey1nXHevMQRTKSX/4nYYeGowW mi4A== X-Gm-Message-State: AOAM5333CC41gmSSGDMKTQflV85JT82A17Z+giinmPN8k9JhfrRjtRpn SBBNszu97pLU2YIAj3bp71uxDp0ityOsUBoA X-Google-Smtp-Source: ABdhPJyeUcYm+GV68NPeTWnzwIl7VLGEqlUzUNxJeoV0pKBwuPTRFgBN4MWLoQ8M4js4LFszArXTFQ== X-Received: by 2002:a62:f943:0:b029:1a5:43f9:9023 with SMTP id g3-20020a62f9430000b02901a543f99023mr55982512pfm.75.1609519264148; Fri, 01 Jan 2021 08:41:04 -0800 (PST) Received: from [127.0.0.1] ([118.34.233.180]) by smtp.gmail.com with ESMTPSA id t25sm52785042pgv.30.2021.01.01.08.41.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 01 Jan 2021 08:41:03 -0800 (PST) From: Jinoh Kang Subject: [PATCH 4.19 bp v2] ext4: don't remount read-only with errors=continue on reboot To: Greg Kroah-Hartman Cc: Jan Kara , Andreas Dilger , Theodore Ts'o , stable@vger.kernel.org References: <16091470451704@kroah.com> <2c1466be-7b5d-1e50-bcc2-3bcb9478fba2@gmail.com> Autocrypt: addr=jinoh.kang.kr@gmail.com; keydata= xsFNBF/Q7MUBEADVIU6g5ui3gcTQV9jbneUb6xdUQJtEDOWG6pThD+nKAwQFYtZpCUSWgGVg osMQTyZu7HpEMvxoYNmO+1ZHtARugq2tl6BH11vEJgTsoF8IFrgyXNlinS+Kq6I8s6py96Pl Fk2b9Y3ok64DJUrmFjfgCAxO0RY/ZFS1vXMqibExzMLODTChrXal0Z9tjxQBkARPXeDmVg8c qW0121/3ODyi04jri34f5luRQe2PMJsqKAmd6Ok9zNkvc3wQZw7t3MiMEJjf1/eZa/He4OoI CO0zQY9dRhQBqgO67lnVziCRfRb4WCHxO03zE7C8ud/UOmuMM4Qh8rAyW3sJ2TbIqwvQepuc vC/Q+Av0GtuUCArUw4GbOibUDxhe1eTZViIYAghkzOxUWeDs1PXRPVnRu6PAGsQP39/2ZPAB wune9t2SEs4o2Js0Vx0c2O/vMXt3uHqtaGNdCJgqlBkNXHlrv47wF7bBMQSf4SepAg+1ZqfI wGgEWmWhBV+8Kqyb1zYIAPsqyvl/2E//XcvKk/70q0Q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e545-e0b7-4f71-1cb1c383e472@gmail.com> Date: Fri, 1 Jan 2021 16:40:58 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0 MIME-Version: 1.0 In-Reply-To: <2c1466be-7b5d-1e50-bcc2-3bcb9478fba2@gmail.com> Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jan Kara commit b08070eca9e247f60ab39d79b2c25d274750441f upstream. ext4_handle_error() with errors=continue mount option can accidentally remount the filesystem read-only when the system is rebooting. Fix that. Fixes: 1dc1097ff60e ("ext4: avoid panic during forced reboot") Signed-off-by: Jan Kara Reviewed-by: Andreas Dilger Cc: stable@kernel.org Link: https://lore.kernel.org/r/20201127113405.26867-2-jack@suse.cz Signed-off-by: Theodore Ts'o [jinoh: backport accounting for missing commit 9b5f6c9b83d9 ("ext4: make s_mount_flags modifications atomic")] Signed-off-by: Jinoh Kang --- v1 --> v2: added missing comment and signoff Apologies for wasted traffic... --- fs/ext4/super.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index ee96f504ed78..e9e9f09f5370 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -454,19 +454,17 @@ static bool system_going_down(void) static void ext4_handle_error(struct super_block *sb) { + journal_t *journal = EXT4_SB(sb)->s_journal; + if (test_opt(sb, WARN_ON_ERROR)) WARN_ON_ONCE(1); - if (sb_rdonly(sb)) + if (sb_rdonly(sb) || test_opt(sb, ERRORS_CONT)) return; - if (!test_opt(sb, ERRORS_CONT)) { - journal_t *journal = EXT4_SB(sb)->s_journal; - - EXT4_SB(sb)->s_mount_flags |= EXT4_MF_FS_ABORTED; - if (journal) - jbd2_journal_abort(journal, -EIO); - } + EXT4_SB(sb)->s_mount_flags |= EXT4_MF_FS_ABORTED; + if (journal) + jbd2_journal_abort(journal, -EIO); /* * We force ERRORS_RO behavior when system is rebooting. Otherwise we * could panic during 'reboot -f' as the underlying device got already