Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1930595ybv; Fri, 14 Feb 2020 08:25:12 -0800 (PST) X-Google-Smtp-Source: APXvYqzeVzQaOs6vnmwLzAIk1Vu5bcq7Bi7un4SUL/omXi7WivRdD30Q94ZJLlHKulBNAMgjqE3t X-Received: by 2002:a05:6808:319:: with SMTP id i25mr2465704oie.128.1581697511967; Fri, 14 Feb 2020 08:25:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581697511; cv=none; d=google.com; s=arc-20160816; b=vJ77Nv78DQp46U/5nvTsFEy46HWpHA6XF7GLck14yAL7bGSrW/+5Up1HxzSKv5LPJh OQuMPoiPNL8U6Zlk2hzMCqk10QdaM9ZBb9H3u05t9qsbzcdKORjGiK2nQ8rk+owNPyOV G3PBKL3vza1xROK87T75kcUEbwjSpwoxnn1wKxCbB+9PhLpPX8Y8cuGoxRtGvkJIaUA/ N3PZYifbQo4MK46BLmFnCQb521OZ6zzpbT776c2U+ZXJOsII0Kom7pzINLXxDHtjETzu 6u+PCWOFlKXsUVpKsmTpBp0J6Ov9d/CGQ8j4Fq9u1oh24UgkBT0Z2NUZR2sWHGprda/Z Qx9g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NmqYlVEVZCfgh82nN6FeKZBRBY5OhsL+aWfb5a1e5qU=; b=avBzCdPrhrhKomuCTZ2vi7ffF9DAVfwmaVywh+QqJkWujGrzjfGnKYLuyOFMu+fVrV /1SP1f0rhetsWtEOFhxm/MVHrbhVHdG9mvnRBJe7l1G6p6xP2QRO61ssuHqpJbgL35BO 3aTE3LMcE6u/RPhvdaE6lWq55ltA3YnmnSa//ENm3r2/f6jmuU+xKPlfOq36oA2cXxSm ei5AUsziDf1DAlS0fKitAqsYEU0RSzxVqDKZQ7LrKKGpksS74ZIhKQ480qZV/i8gyLum H4aooPlbmcGSuB+7JaliBEXpr1n+FHsxs+WMWuCzE4wbo8bQojjn8U5T+Gcc8n2hIdGL RQvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="HMUC7m/D"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b10si2610463oiy.254.2020.02.14.08.24.59; Fri, 14 Feb 2020 08:25:11 -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="HMUC7m/D"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405618AbgBNQXV (ORCPT + 99 others); Fri, 14 Feb 2020 11:23:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:56782 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393100AbgBNQVv (ORCPT ); Fri, 14 Feb 2020 11:21:51 -0500 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 01C96246AC; Fri, 14 Feb 2020 16:21:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581697310; bh=ocdjRBdF3SWbCeWgrak9y4X6hDQvhe0i5iBNvmefeNU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HMUC7m/DihzXHniIG7eJSj78Pwp7HgYrAw33KKRUWrxb1W5Pomi+DbKiVtiIpD0YF 8OyI6JcIyWvMkuZyBvFnczuOJCntWCIz37XWz/z1U1vy3qZuMQ9050Rg/9CaBTmsXm y12rQdhPprINA36KQOI8FBCZJIO4uCQ2dBZ7Q1Yk= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kai Li , Theodore Ts'o , Sasha Levin , linux-ext4@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 022/141] jbd2: clear JBD2_ABORT flag before journal_reset to update log tail info when load journal Date: Fri, 14 Feb 2020 11:19:22 -0500 Message-Id: <20200214162122.19794-22-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200214162122.19794-1-sashal@kernel.org> References: <20200214162122.19794-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: Kai Li [ Upstream commit a09decff5c32060639a685581c380f51b14e1fc2 ] If the journal is dirty when the filesystem is mounted, jbd2 will replay the journal but the journal superblock will not be updated by journal_reset() because JBD2_ABORT flag is still set (it was set in journal_init_common()). This is problematic because when a new transaction is then committed, it will be recorded in block 1 (journal->j_tail was set to 1 in journal_reset()). If unclean shutdown happens again before the journal superblock is updated, the new recorded transaction will not be replayed during the next mount (because of stale sb->s_start and sb->s_sequence values) which can lead to filesystem corruption. Fixes: 85e0c4e89c1b ("jbd2: if the journal is aborted then don't allow update of the log tail") Signed-off-by: Kai Li Link: https://lore.kernel.org/r/20200111022542.5008-1-li.kai4@h3c.com Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin --- fs/jbd2/journal.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 3cbcf649ac660..40c754854b29e 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -1670,6 +1670,11 @@ int jbd2_journal_load(journal_t *journal) journal->j_devname); return -EFSCORRUPTED; } + /* + * clear JBD2_ABORT flag initialized in journal_init_common + * here to update log tail information with the newest seq. + */ + journal->j_flags &= ~JBD2_ABORT; /* OK, we've finished with the dynamic journal bits: * reinitialise the dynamic contents of the superblock in memory @@ -1677,7 +1682,6 @@ int jbd2_journal_load(journal_t *journal) if (journal_reset(journal)) goto recovery_error; - journal->j_flags &= ~JBD2_ABORT; journal->j_flags |= JBD2_LOADED; return 0; -- 2.20.1