From nobody Fri Oct 18 06:22:17 2024 Received: from out-183.mta0.migadu.com (out-183.mta0.migadu.com [91.218.175.183]) (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 7A37415B551 for ; Wed, 24 Jul 2024 16:11:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.183 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721837495; cv=none; b=Qa6/2PFIUs4IU6z1dlv48kX2NKxpGGykSlVful4EdxIlIa67zzS3ngn3kb4jijYJlr1OsoTsHj1ESihPJIZnR+sjQtlN/wNS9IIlpaJn6Hi6/6wKN8o8tyu5HzAPh30zxvVMhcrcN3qBBI4EEkCDew0G5lg8bA9LpEbnFOzLouw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721837495; c=relaxed/simple; bh=PZMSdd5O+wZR6bDKU7Sz+d5ZYUTuW61Rr7dJPfO1bYk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lHqgGM8z/x3CfaTqkSKpI3iL5tub1oO1Pi2w/gn1HiJoJ3v7HVB+BM22GHJxfeBuXOaOlijMyMxt2NbapbVGGgj9JphBOu2HZdqpu2BklmwYuIiOT5zXhdbzIjxoiV6U99itti65xaw4Ok6/ysZyfHCd5EXTci1GkrjKWOdQdhM= 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=AOYmxGl0; arc=none smtp.client-ip=91.218.175.183 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="AOYmxGl0" 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=1721837490; 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=/8eUEiMtXmowiLjgwuyQYnrkesxiYhQ4jTAv0qVnggo=; b=AOYmxGl00clGEmPjqA5s+BtPbn28FSWxU68Z2zn7ZT9XTY4Z26jgw0F+nDEm4T4FO4yGEr zp3UXmvp87pRuokHlN+9blxP5WqiZiGs2XDHut6wVwqRSzJjx50kOlBhUyyqU/Odt0CybQ +TtAGxzI8KNB6x7kLAmfPeIlf/YoWqs= 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 1/4] ext4: fix incorrect tid assumption in ext4_wait_for_tail_page_commit() Date: Wed, 24 Jul 2024 17:11:15 +0100 Message-ID: <20240724161119.13448-2-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 ext4_wait_for_tail_page_commit() assumes that '0' is not a valid value for transaction IDs, which is incorrect. Don't assume that and invoke jbd2_log_wait_commit() if the journal had a committing transaction instead. Signed-off-by: Luis Henriques (SUSE) Reviewed-by: Jan Kara --- fs/ext4/inode.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 941c1c0d5c6e..a0fa5192db8e 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -5279,8 +5279,9 @@ static void ext4_wait_for_tail_page_commit(struct ino= de *inode) { unsigned offset; journal_t *journal =3D EXT4_SB(inode->i_sb)->s_journal; - tid_t commit_tid =3D 0; + tid_t commit_tid; int ret; + bool has_transaction; =20 offset =3D inode->i_size & (PAGE_SIZE - 1); /* @@ -5305,12 +5306,14 @@ static void ext4_wait_for_tail_page_commit(struct i= node *inode) folio_put(folio); if (ret !=3D -EBUSY) return; - commit_tid =3D 0; + has_transaction =3D false; read_lock(&journal->j_state_lock); - if (journal->j_committing_transaction) + if (journal->j_committing_transaction) { commit_tid =3D journal->j_committing_transaction->t_tid; + has_transaction =3D true; + } read_unlock(&journal->j_state_lock); - if (commit_tid) + if (has_transaction) jbd2_log_wait_commit(journal, commit_tid); } }