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 EFC8B1DE8BA; Tue, 8 Oct 2024 12:29:54 +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=1728390595; cv=none; b=LzW1opxQ7Bn9uiLh/nB6zGsGEPzNl2cr7/7k+qs7GW2pabtUZ61Y5uUq+7g6JZY2SBbqrfIE+xgxA54nsjugAJYmXg07C+9UPieF/45ZsAvzj86XzRJ35hnFHTlGFEKQCpMtO/y5Vqe1V1w9g5ci9KN8UKLf8Cve+V0iMKfTelk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728390595; c=relaxed/simple; bh=XQ+oFBvatmknhmcxeIdiUYXvukXOsj1+8ZAvJbsKU5s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y2e+owPjEVYq3ojTErrLABQHHfQGR6M5lqyNoHzpxNMyJidgb1OYwTDBE9tOXJtkw0SG2L4+LKONzxr2in5KKffFh2b3ZqFCsSTJFt2I2oNlMpze9r72NwxhKP0+6DnbAeOA3bApEE5H6zbeH5vza8jAuoctgN95F+wR8+6NERo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ym8io02k; 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="ym8io02k" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10A74C4CEC7; Tue, 8 Oct 2024 12:29:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728390594; bh=XQ+oFBvatmknhmcxeIdiUYXvukXOsj1+8ZAvJbsKU5s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ym8io02kJpnCfEnJJ3HUNHydWplaMZlv6H10b5+t/fl3uqpLphvtENB/Ylx/pxlOr 1AjmWD9g11HirHpNq3dplu6x5u9I48BL7clWQSYploHgA0JFtt5WsYLIgn+TpzDXL4 DWt5IndeoO5t+92qRyyDiO/PA5/J5oasYJWCEwjs= 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.10 326/482] ext4: fix incorrect tid assumption in ext4_fc_mark_ineligible() Date: Tue, 8 Oct 2024 14:06:29 +0200 Message-ID: <20241008115701.255979050@linuxfoundation.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241008115648.280954295@linuxfoundation.org> References: <20241008115648.280954295@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.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Luis Henriques (SUSE) commit ebc4b2c1ac92fc0f8bf3f5a9c285a871d5084a6b upstream. Function jbd2_journal_shrink_checkpoint_list() assumes that '0' is not a valid value for transaction IDs, which is incorrect. Furthermore, the sbi->s_fc_ineligible_tid handling also makes the same assumption by being initialised to '0'. Fortunately, the sb flag EXT4_MF_FC_INELIGIBLE can be used to check whether sbi->s_fc_ineligible_tid has been previously set instead of comparing it with '0'. Signed-off-by: Luis Henriques (SUSE) Reviewed-by: Jan Kara Link: https://patch.msgid.link/20240724161119.13448-5-luis.henriques@linux.dev Signed-off-by: Theodore Ts'o Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/ext4/fast_commit.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -339,22 +339,29 @@ void ext4_fc_mark_ineligible(struct supe { struct ext4_sb_info *sbi = EXT4_SB(sb); tid_t tid; + bool has_transaction = true; + bool is_ineligible; if (ext4_fc_disabled(sb)) return; - ext4_set_mount_flag(sb, EXT4_MF_FC_INELIGIBLE); if (handle && !IS_ERR(handle)) tid = handle->h_transaction->t_tid; else { read_lock(&sbi->s_journal->j_state_lock); - tid = sbi->s_journal->j_running_transaction ? - sbi->s_journal->j_running_transaction->t_tid : 0; + if (sbi->s_journal->j_running_transaction) + tid = sbi->s_journal->j_running_transaction->t_tid; + else + has_transaction = false; read_unlock(&sbi->s_journal->j_state_lock); } spin_lock(&sbi->s_fc_lock); - if (tid_gt(tid, sbi->s_fc_ineligible_tid)) + is_ineligible = ext4_test_mount_flag(sb, EXT4_MF_FC_INELIGIBLE); + if (has_transaction && + (!is_ineligible || + (is_ineligible && tid_gt(tid, sbi->s_fc_ineligible_tid)))) sbi->s_fc_ineligible_tid = tid; + ext4_set_mount_flag(sb, EXT4_MF_FC_INELIGIBLE); spin_unlock(&sbi->s_fc_lock); WARN_ON(reason >= EXT4_FC_REASON_MAX); sbi->s_fc_stats.fc_ineligible_reason_count[reason]++;