From patchwork Wed Apr 22 09:57:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 227207 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=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable 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 9BC3FC55186 for ; Wed, 22 Apr 2020 10:33:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 76F2720776 for ; Wed, 22 Apr 2020 10:33:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587551628; bh=RTJLLgqTnbnCMl1VdHM3dpJjnkyNc45JkLJJssNcMy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=1J8zw11pDPNlRoOYxgGwbZhmQ2U/QsTjC21q5WiM3VC1HDIDqds8+ZEfKHNVPrMlQ u3ngNprA/voFeHuhEXWzIwnoLf8Y177Pw8K/9KRxfydCnesgDAbtuOuYoJbgusr1t3 jjJTu443SZuw0jdiJ+ZdRkFIHEIPnkejnpNmBCks= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730722AbgDVKdk (ORCPT ); Wed, 22 Apr 2020 06:33:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:33112 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730451AbgDVKYm (ORCPT ); Wed, 22 Apr 2020 06:24:42 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 25DDF20776; Wed, 22 Apr 2020 10:24:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587551081; bh=RTJLLgqTnbnCMl1VdHM3dpJjnkyNc45JkLJJssNcMy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yT8bmjmtnfyZ3ZOfeK/g36X2VljrM1K27Bwc2uMt3osmhY9Bagi1wnhAje5i4KjR/ EiNHwDO4gxB398SumzufbNVJnbs9nb7A8LlDEklgU99zwrbc6WIxCh0zlKMKyYBLnY X8XsiI4gKtXIkgRPHxaJvllZn2lljjfBIdw3jGF4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ritesh Harjani , Eric Sandeen , Andreas Dilger , Theodore Tso , Sasha Levin Subject: [PATCH 5.6 093/166] ext4: do not commit super on read-only bdev Date: Wed, 22 Apr 2020 11:57:00 +0200 Message-Id: <20200422095058.841343019@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200422095047.669225321@linuxfoundation.org> References: <20200422095047.669225321@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Eric Sandeen [ Upstream commit c96e2b8564adfb8ac14469ebc51ddc1bfecb3ae2 ] Under some circumstances we may encounter a filesystem error on a read-only block device, and if we try to save the error info to the superblock and commit it, we'll wind up with a noisy error and backtrace, i.e.: [ 3337.146838] EXT4-fs error (device pmem1p2): ext4_get_journal_inode:4634: comm mount: inode #0: comm mount: iget: illegal inode # ------------[ cut here ]------------ generic_make_request: Trying to write to read-only block-device pmem1p2 (partno 2) WARNING: CPU: 107 PID: 115347 at block/blk-core.c:788 generic_make_request_checks+0x6b4/0x7d0 ... To avoid this, commit the error info in the superblock only if the block device is writable. Reported-by: Ritesh Harjani Signed-off-by: Eric Sandeen Reviewed-by: Andreas Dilger Link: https://lore.kernel.org/r/4b6e774d-cc00-3469-7abb-108eb151071a@sandeen.net Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin --- fs/ext4/super.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index a985b2c585d24..16da3b3481a4d 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -372,7 +372,8 @@ static void save_error_info(struct super_block *sb, const char *func, unsigned int line) { __save_error_info(sb, func, line); - ext4_commit_super(sb, 1); + if (!bdev_read_only(sb->s_bdev)) + ext4_commit_super(sb, 1); } /*