From mboxrd@z Thu Jan 1 00:00:00 1970 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=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 B5E94C3815B for ; Wed, 15 Apr 2020 12:27:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8AA1E2137B for ; Wed, 15 Apr 2020 12:27:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586953665; bh=WK6PI55FunTNr/JYm4AJc5j5XPkmbtyiqnzP8rvCP8E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Mtn3fAXMGbMZl/EY6+hLIMqPY9uPv/npH2SUa7FVChLrwS4XHRw+AlHmL8sbeGSm3 FsEIdnr9aOS4gu3lbYANgXqfaamVkSw2tLTUbpD5GRCx0pl++3O2nsjZcTfI4vOazn as37wqQfu1waRebRYFPUlV2HunXgOHda8P6kIZlE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2409906AbgDOM1m (ORCPT ); Wed, 15 Apr 2020 08:27:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:38850 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406253AbgDOLpV (ORCPT ); Wed, 15 Apr 2020 07:45:21 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 27AF920732; Wed, 15 Apr 2020 11:45:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586951121; bh=WK6PI55FunTNr/JYm4AJc5j5XPkmbtyiqnzP8rvCP8E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LcsPvsaru+YnpIFy+8XaNfzJva5qKA6919aiPU1dODnQSX4xrBsOhYSCvcV/yeGG4 HTMFCDizt6Y1EEmekXfHD1yIvTePuBQBLjIpurTMTtOU6RzDrnNiYP6Rx0x6xQQKSq rRYKmk6p9FeRvu/6l7K9D7GPv6yGJIcGBVDaocRs= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Eric Sandeen , Ritesh Harjani , Andreas Dilger , Theodore Ts'o , Sasha Levin , linux-ext4@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 34/84] ext4: do not commit super on read-only bdev Date: Wed, 15 Apr 2020 07:43:51 -0400 Message-Id: <20200415114442.14166-34-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200415114442.14166-1-sashal@kernel.org> References: <20200415114442.14166-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 8bd806a03a90c..ff3f300dbd642 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -389,7 +389,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); } /* -- 2.20.1