From patchwork Wed Apr 22 09:56:57 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: 227028 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 D5424C55189 for ; Wed, 22 Apr 2020 10:59:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A6DD32076E for ; Wed, 22 Apr 2020 10:59:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587553191; bh=X9HBAE7um4G0ptqpX5Qsm4LusA/DgtNqcQ5No6tm0ek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=iedOMDcguc1pBbdZrWBbiuYTio2LvSc1HvXvLZhVrF2+t7DgvgvR4E3KhCBH1nCd+ 3DqtTQwQJhyOIoXmmvn2wQxb0933yVrMIdyB7LBEN6j1FTza46aqvKlGslzl71SPfj xEClKhGtixxPXmydTetV0BLIQpETKdXSSST31bEs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726981AbgDVKCW (ORCPT ); Wed, 22 Apr 2020 06:02:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:51340 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726976AbgDVKCU (ORCPT ); Wed, 22 Apr 2020 06:02:20 -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 9CD2420780; Wed, 22 Apr 2020 10:02:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587549740; bh=X9HBAE7um4G0ptqpX5Qsm4LusA/DgtNqcQ5No6tm0ek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F8vxlb/wEU1j3dLPfom2TWaiTyuqXxvG0WilfVym0jmNOg2ByWOgUub6Z9S/U26lY /av/uBEy4OIlETRwvi8XJu2TMymiY71gWIGrcV/UAVH8NQQ1vWXleCAx7PQ2ZST2Nf OgCNi7IIhEBzJ0hQJzDvjAbCkq4O+YURrzBfYKgw= 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 4.4 087/100] ext4: do not commit super on read-only bdev Date: Wed, 22 Apr 2020 11:56:57 +0200 Message-Id: <20200422095038.681491542@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200422095022.476101261@linuxfoundation.org> References: <20200422095022.476101261@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 f778eb4b3e5b6..67faf147bade1 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -313,7 +313,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); } /*