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 DFB661DED6F; Tue, 8 Oct 2024 12:59:26 +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=1728392367; cv=none; b=sb8eMIuOXzMSX/4YAksqPTFQ0RtcriXAKnMsthioTGvmSLM7se2wnJovV1seDAgLhWF6NnoGTknupF/FHsIL1MC1A9I61jDrCdUtq24h+7MmrGGQqE1L49kK/jix9YncAn9IezMef0Pnnf5PBjc3sm9IWY8750HxfqC3iN+LdnM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728392367; c=relaxed/simple; bh=MpZ8v9uAL98KOI7exp8nrt6NOn/CUi3SnzRlGu59JOs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kod4vCuytd08SigIAYKV+Y3MVNIK5PpnzbjndCmolKw/jYK5lF+MM0WawctDcdeFAhpkNXIVm4GB/DEYrFEQ2TfWy4Zq1cbWoJdanzkwvC9+xF/XC+M7oayIKAOBy6KSDYTcF1+sc5zBpW1Sb6zay/xJpS50Ptgm+VJ4cLe+kzI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=wLF0T8gb; 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="wLF0T8gb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F27FC4CEC7; Tue, 8 Oct 2024 12:59:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728392366; bh=MpZ8v9uAL98KOI7exp8nrt6NOn/CUi3SnzRlGu59JOs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wLF0T8gb4nwPUcMEcToJCO15bQWRrxAie9+zem5cNwPZey1gzDeMYh93xp2Cgso4N x5EEQJ1a4BedYC2i2WbkIqoQjh+pDz57jlr/FB6Ex2NjnJlVT6FCzA1yKYaQo2Yrqw DwwMpKR3iMWoU6Xjzy+fg1PLbG1mmZyvYPSRvqEQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Luis Henriques (SUSE)" , Jan Kara , Theodore Tso , stable@kernel.org Subject: [PATCH 6.11 394/558] ext4: fix incorrect tid assumption in jbd2_journal_shrink_checkpoint_list() Date: Tue, 8 Oct 2024 14:07:04 +0200 Message-ID: <20241008115717.787431830@linuxfoundation.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241008115702.214071228@linuxfoundation.org> References: <20241008115702.214071228@linuxfoundation.org> User-Agent: quilt/0.67 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.11-stable review patch. If anyone has any objections, please let me know. ------------------ From: Luis Henriques (SUSE) commit 7a6443e1dad70281f99f0bd394d7fd342481a632 upstream. Function jbd2_journal_shrink_checkpoint_list() assumes that '0' is not a valid value for transaction IDs, which is incorrect. Don't assume that and use two extra boolean variables to control the loop iterations and keep track of the first and last tid. Signed-off-by: Luis Henriques (SUSE) Reviewed-by: Jan Kara Link: https://patch.msgid.link/20240724161119.13448-4-luis.henriques@linux.dev Signed-off-by: Theodore Ts'o Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/jbd2/checkpoint.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/fs/jbd2/checkpoint.c +++ b/fs/jbd2/checkpoint.c @@ -410,6 +410,7 @@ unsigned long jbd2_journal_shrink_checkp tid_t tid = 0; unsigned long nr_freed = 0; unsigned long freed; + bool first_set = false; again: spin_lock(&journal->j_list_lock); @@ -429,8 +430,10 @@ again: else transaction = journal->j_checkpoint_transactions; - if (!first_tid) + if (!first_set) { first_tid = transaction->t_tid; + first_set = true; + } last_transaction = journal->j_checkpoint_transactions->t_cpprev; next_transaction = transaction; last_tid = last_transaction->t_tid; @@ -460,7 +463,7 @@ again: spin_unlock(&journal->j_list_lock); cond_resched(); - if (*nr_to_scan && next_tid) + if (*nr_to_scan && journal->j_shrink_transaction) goto again; out: trace_jbd2_shrink_checkpoint_list(journal, first_tid, tid, last_tid,