From nobody Fri Oct 18 06:13:39 2024 Received: from out-177.mta1.migadu.com (out-177.mta1.migadu.com [95.215.58.177]) (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 53CF415ECF8 for ; Wed, 24 Jul 2024 16:11:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721837505; cv=none; b=d+SND7B5TwxGFuirx2Z9AHyKl0xz9P9VjaTAv1gNyf4v7ANfKkyQDge9W6s1SZnYC56k9Hq/2wevXHZRuAITA8gO6KwK1AVsYGZ8DG6ap/qH2VU8zlHC5vlWgkFa5bK0cmrfMMxCj+KkGNbMO+TWPFPTyZBih9YA0kcOMXxBBuc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721837505; c=relaxed/simple; bh=G+NetOiA07DsopKThDt7NVtlD4oyFoF/Xr+T8bHrr+M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rui2nvYdnqt63EoL6rePRnvCj/7Hj6DOewZA/5DOAAsxK1dC+ZKxuEXcPNqKXqZd0/9zYDb86IAefeGfc6S4XhZLwnrnv5S9oQ1GCI6u7Ra0zCU0xJebJfCb1sudnMdoY/YGVMvYV9+juP75IJg9HEzBfNpt2uHYjFHEjj9p5R4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=P9owXIbO; arc=none smtp.client-ip=95.215.58.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="P9owXIbO" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1721837501; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qW8LXRG/ucQNNYMkPNdCyzVM3kQHzkMXl1yju9gDpjA=; b=P9owXIbOD+23mcx9P1PUA3yiG/eZQ0Jr/PgZKYLYjOYkHe+P8LUEQlBGUOEfPffSxYyGkb CJFIs0eagDUMXtbx6yxQI1nVlUS8mvk0NU0yI4qE/Hi1LMDvhs5SJ5Hn0Czqqmd6HZCIef fx3LRsIGKIaiapDjy8MdbfRVkRre7Rw= From: "Luis Henriques (SUSE)" To: Theodore Ts'o , Andreas Dilger , Jan Kara , Harshad Shirwadkar Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, "Luis Henriques (SUSE)" Subject: [PATCH v2 3/4] ext4: fix incorrect tid assumption in jbd2_journal_shrink_checkpoint_list() Date: Wed, 24 Jul 2024 17:11:17 +0100 Message-ID: <20240724161119.13448-4-luis.henriques@linux.dev> In-Reply-To: <20240724161119.13448-1-luis.henriques@linux.dev> References: <20240724161119.13448-1-luis.henriques@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" 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 --- fs/jbd2/checkpoint.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c index 77bc522e6821..98a0b2eb84f5 100644 --- a/fs/jbd2/checkpoint.c +++ b/fs/jbd2/checkpoint.c @@ -410,6 +410,7 @@ unsigned long jbd2_journal_shrink_checkpoint_list(journ= al_t *journal, tid_t tid =3D 0; unsigned long nr_freed =3D 0; unsigned long freed; + bool first_set =3D false; =20 again: spin_lock(&journal->j_list_lock); @@ -429,8 +430,10 @@ unsigned long jbd2_journal_shrink_checkpoint_list(jour= nal_t *journal, else transaction =3D journal->j_checkpoint_transactions; =20 - if (!first_tid) + if (!first_set) { first_tid =3D transaction->t_tid; + first_set =3D true; + } last_transaction =3D journal->j_checkpoint_transactions->t_cpprev; next_transaction =3D transaction; last_tid =3D last_transaction->t_tid; @@ -460,7 +463,7 @@ unsigned long jbd2_journal_shrink_checkpoint_list(journ= al_t *journal, spin_unlock(&journal->j_list_lock); cond_resched(); =20 - 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,