From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD3EF248BA6; Wed, 15 Jan 2025 10:44:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736937883; cv=none; b=ZOPlTFU864Xq5FKAjbMzcSiYLF8a0gwbztxYdS0lT09HCIdUD5pYk19KnG8H+7aUzHam9mgq0bckU0Q+FyCjGS141Tys53zTaHwQy9yAUjVbjqboztRquWRLPwwh36PEhixCYwOYKzKJSNgGVp1tYgVqMkqoEIW7g6yrPnSf1MQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736937883; c=relaxed/simple; bh=szNkovM+tVlWjXEQLLm7whqFMgCB0Ipd2v7Fw7MB3PM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bErjbmKXENwoh9mO7i7NA5rOqJm4t/kSpUNLIuP1LsJ7SclR6qMWmmKqM4c5b5Ei7S9Nl3Asb30UrzhqFlwCugHj284BKuhu19HHSVVvptVeisOEpaGBLBpEHShdrwAPNVaz7QdDPEKc6gBeKswszLF2Bmb6pX1smlAKAycJdEk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=t8+NhLgo; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="t8+NhLgo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30554C4CEDF; Wed, 15 Jan 2025 10:44:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1736937883; bh=szNkovM+tVlWjXEQLLm7whqFMgCB0Ipd2v7Fw7MB3PM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t8+NhLgoKU0q6K5OOGfEt3/zN3TTLlfs30ka9gS+vEqENK4u8ouFipMUWjAocLGf3 uIg65A7tkbNyQdCgBeMoADoy50RSZjqDAHOnrTFDruaAPUO+8y+rAzSLHIYZJAS751 yd9KBjwMwHUxby/1gZNO3HmnlNsaimCBi5YS9cX4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zhang Yi , Jan Kara , Christian Brauner , Sasha Levin Subject: [PATCH 6.12 002/189] jbd2: flush filesystem device before updating tail sequence Date: Wed, 15 Jan 2025 11:34:58 +0100 Message-ID: <20250115103606.458107477@linuxfoundation.org> X-Mailer: git-send-email 2.48.0 In-Reply-To: <20250115103606.357764746@linuxfoundation.org> References: <20250115103606.357764746@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zhang Yi [ Upstream commit a0851ea9cd555c333795b85ddd908898b937c4e1 ] When committing transaction in jbd2_journal_commit_transaction(), the disk caches for the filesystem device should be flushed before updating the journal tail sequence. However, this step is missed if the journal is not located on the filesystem device. As a result, the filesystem may become inconsistent following a power failure or system crash. Fix it by ensuring that the filesystem device is flushed appropriately. Fixes: 3339578f0578 ("jbd2: cleanup journal tail after transaction commit") Signed-off-by: Zhang Yi Link: https://lore.kernel.org/r/20241203014407.805916-3-yi.zhang@huaweicloud.com Reviewed-by: Jan Kara Signed-off-by: Christian Brauner Signed-off-by: Sasha Levin --- fs/jbd2/commit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c index 4305a1ac808a..f95cf272a1b5 100644 --- a/fs/jbd2/commit.c +++ b/fs/jbd2/commit.c @@ -776,9 +776,9 @@ void jbd2_journal_commit_transaction(journal_t *journal) /* * If the journal is not located on the file system device, * then we must flush the file system device before we issue - * the commit record + * the commit record and update the journal tail sequence. */ - if (commit_transaction->t_need_data_flush && + if ((commit_transaction->t_need_data_flush || update_tail) && (journal->j_fs_dev != journal->j_dev) && (journal->j_flags & JBD2_BARRIER)) blkdev_issue_flush(journal->j_fs_dev); -- 2.39.5