Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1135074ybf; Thu, 27 Feb 2020 05:41:56 -0800 (PST) X-Google-Smtp-Source: APXvYqwkeR0SYdXnIhWQDcxHdndYCIKJAoVacbN8XVFu8HuCEtLs2NZcKN6MIBY6P1XBATqYUTKm X-Received: by 2002:a05:6808:aac:: with SMTP id r12mr3372434oij.59.1582810915968; Thu, 27 Feb 2020 05:41:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582810915; cv=none; d=google.com; s=arc-20160816; b=gRqzFlaSe5DJdP6u4npPPzsvqOw7FuJCvOnknd1iAdx5WbGIZeuedy+pins7+naMgH 1k3pNesdrpUcR5l0kZUjTGZonjiI48+hyv8TVlQ7dZzrFDee9D21Cp+XGrTPc1TsSRdm uGOzUIaaTb71X5Q9x9a9gKN8D+QeavKHC01lV/+9yeTERwgEfK3Kk+AI249LgtiOzUnX QBKRKI0/77g/3FFc4T2sZSwCpa7LT9RjF+JqQpO7lIu0I1j/y0AbFdI+Y9h0Maiu7/Lj Gz83yslCuF1D3sqP16kuOcTljVtTmJcs0kpVMyqDj7k1PYVvzmfzBKCci+gc3hu5zIUM 0dRw== 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=4sQpCFLqVztVaAzLgtMLABvVKj1cIv8oSq8t34ZoDBA=; b=jN+x/avhUvsLVKIHGQCDta86OtdLhtBh08EsajDHbwR8ZAl2eVUuiq5dkupKGy/dcl ueaqFnWxXNk3XNz/7QtAEDLVyVbIe6onsIoLVCt8r/4eZf0r4s7hJum8IIJEUiOlYSz1 ihOoyssVte+C0kfMaGZiV2a9gyudaP4LHLbyQrTblNaG3YYLu5m/1zVlkm+uWVysO5WE XGnTwCjSrbQYXDigKdHYWgu4IsdsNmIV9jBQsb/DMKCNzJ9rJ7HkN7cwvlFIVHKhrRkg MUrjenqTRU8euRkdftVh7mTAHtbOdlY4HrBNbGXQs24R0WnNeTD3dLGcFdN4LoQ6giN3 KCgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=t3Txlvoe; 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 i5si1344925oif.211.2020.02.27.05.41.43; Thu, 27 Feb 2020 05:41:55 -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=t3Txlvoe; 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 S1729535AbgB0NlO (ORCPT + 99 others); Thu, 27 Feb 2020 08:41:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:35730 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729517AbgB0NlK (ORCPT ); Thu, 27 Feb 2020 08:41:10 -0500 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 D4FC321D7E; Thu, 27 Feb 2020 13:41:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582810870; bh=dO8xwNUMWfiDMM1KGW8bWZI+laE6+d2er+ZLiyojtyY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t3TxlvoeanN1JZOIRWfK4RyqNEakmohyrEP9jFwkD/rbFgnoCr47FAPEWIILPY036 4z4BfIXwT641VDllQGmXrkHQWeJtC2DPqxGCPTxmPLbcCGXF/dmG8uXYt/P95ygbL9 ZwoBQ9o5lUEUlD2D8KumVeCSPb1T0Kj26+zy5ltw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kai Li , Theodore Tso , Sasha Levin Subject: [PATCH 4.4 030/113] jbd2: clear JBD2_ABORT flag before journal_reset to update log tail info when load journal Date: Thu, 27 Feb 2020 14:35:46 +0100 Message-Id: <20200227132216.540635114@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200227132211.791484803@linuxfoundation.org> References: <20200227132211.791484803@linuxfoundation.org> User-Agent: quilt/0.66 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 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 9398d1b70545c..deb3300299709 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -1656,6 +1656,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 @@ -1663,7 +1668,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