Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3516529imu; Mon, 7 Jan 2019 04:57:56 -0800 (PST) X-Google-Smtp-Source: ALg8bN5E1SVrJAOJ81ExNfEE8kXqb98sjPPrLdloBnNr46NOTPagkUKJCgv6o3uaobkDcu0swkAy X-Received: by 2002:a63:2507:: with SMTP id l7mr28547199pgl.22.1546865876411; Mon, 07 Jan 2019 04:57:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546865876; cv=none; d=google.com; s=arc-20160816; b=YU8Kak1fl8aEIyBZ9SbF0AE+AjOKDiBfT97OuTojeVErgH4C3EbyFIB59Au1f4q2Is +7ZNVmaFpC4lLQLDo3JPVchAvVk4u9eaNahmKTgI1+Bbi/Ud+d3LFdvQ9nJ6US7pG2B9 4RT5N57T6spIx/mb/Dn5yL0aQC7haSXfoyGNq8Ir0sPupMC1hJREBxthDssWi9bsbsYv th5mv/SjBu4gN5nn7fPGqe5MWT4NTCOvjtsCp9cjGZ52V01Ogm14Nbor8lhMa0wUx5SO uNqeaKJodi1O84KcHb/auF+RRSO5GdqUvZBH0jAkP9kZ5986qg7z/32yKghlHIzCqClC UjTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MgMHHinadhfZJREeCJT3NCO71hma2anJGD7/G+jBnd4=; b=w5VAyY+HocjRmZsrtADv+WvTimGdyC4fCQqcr0JBe8+6fllWXMBXvFFXAAYjtGcfIJ bPUpZtPHDICSx9ObYvI7TM93wsx4wbIXXZLnGbqHbF+/QIKNoUzsp0f7phTcv7IlqjQh HZRP9xRWBxoNFQqUA0gr5AZqlKZAx7iDY+8lbAQiIBvA8WyzGo50FQcCDYGdGZMh9vI8 1YhTAg99vPzVR2BSz8lbclTadiTXwgxzTo6fC477W9cOhWvrR1ooq0gztYYCz32czDZo BuUofgQQyZs3abjoj81CiSCZH2Pz5M2uwlixiI/pRMLlz6U9uyOQ8Wu63VnB4jR4hP3t xDuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VWCMl4ab; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g124si989369pgc.568.2019.01.07.04.57.40; Mon, 07 Jan 2019 04:57:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VWCMl4ab; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729163AbfAGMy5 (ORCPT + 99 others); Mon, 7 Jan 2019 07:54:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:43550 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728296AbfAGMy4 (ORCPT ); Mon, 7 Jan 2019 07:54:56 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 8E37C20651; Mon, 7 Jan 2019 12:54:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546865695; bh=ilpU2SFC+YuobzqR68Wu1a8YG5vvE0NW5LgluEe2u4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VWCMl4ab/2cpugjiaNUkfvS06rqyZ+B1xlvyOOlPdFc/TRdtc2VUEbSUM0NMMGnbu psK/Dx6SCvo2USQfR8rffqJq3SKTs64Uv1J/CW6rQnj3/9ZfDHqRYRguPwv+UEJfKb TvxTbs86YZYSrnPPtQkU4N1ta1uEsha9p6qRvJ2w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Theodore Tso , stable@kernel.org Subject: [PATCH 4.19 114/170] ext4: check for shutdown and r/o file system in ext4_write_inode() Date: Mon, 7 Jan 2019 13:32:21 +0100 Message-Id: <20190107104506.405947594@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190107104452.953560660@linuxfoundation.org> References: <20190107104452.953560660@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Theodore Ts'o commit 18f2c4fcebf2582f96cbd5f2238f4f354a0e4847 upstream. If the file system has been shut down or is read-only, then ext4_write_inode() needs to bail out early. Also use jbd2_complete_transaction() instead of ext4_force_commit() so we only force a commit if it is needed. Signed-off-by: Theodore Ts'o Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/ext4/inode.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -5369,9 +5369,13 @@ int ext4_write_inode(struct inode *inode { int err; - if (WARN_ON_ONCE(current->flags & PF_MEMALLOC)) + if (WARN_ON_ONCE(current->flags & PF_MEMALLOC) || + sb_rdonly(inode->i_sb)) return 0; + if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) + return -EIO; + if (EXT4_SB(inode->i_sb)->s_journal) { if (ext4_journal_current_handle()) { jbd_debug(1, "called recursively, non-PF_MEMALLOC!\n"); @@ -5387,7 +5391,8 @@ int ext4_write_inode(struct inode *inode if (wbc->sync_mode != WB_SYNC_ALL || wbc->for_sync) return 0; - err = ext4_force_commit(inode->i_sb); + err = jbd2_complete_transaction(EXT4_SB(inode->i_sb)->s_journal, + EXT4_I(inode)->i_sync_tid); } else { struct ext4_iloc iloc;