From nobody Wed Feb 11 11:28:11 2026 Received: from out-178.mta1.migadu.com (out-178.mta1.migadu.com [95.215.58.178]) (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 5235E18036 for ; Tue, 21 May 2024 15:45:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716306347; cv=none; b=N64nmQPBT1wgUTsvc19XCg56QQtoc+W7L/tUnJM59V4TLCfHXGnqiO8j3pqHoO6ceg6EN5Qfqa2HFvBxIQVzQUq4VTpKWB1M/WDnTVIvK20m9jSts6py6glpJRmlmIEhz91NOttDgD23rv6z95ZdQii4bxZp2TK3lq8la/T/aN4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716306347; c=relaxed/simple; bh=zEAewd0WHCRD6ZIvbc+29IjNVR5duGnthNQq9uGxhvA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GZBLl1wqpkj+379RnxglAiCO8Nx4jKaIkfSxtkctJIMNfZ+IVYAuXX/vmW5CAuso/D04KE5WQWAHV0QdxAlLQOtMqTsyYWYz4orsC6i3W8jcoCdbX7QM76Xj66m1EnUo0Wt7uPa7TEhfbtnK918hSeuU4dzPeuaTKu3FPWqWdNU= 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=jpiFqFJ4; arc=none smtp.client-ip=95.215.58.178 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="jpiFqFJ4" X-Envelope-To: adilger@dilger.ca DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1716306342; 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=OsqhayekR/OGOZBD4jALsLmjWK5JaY20mUwZwJqidv0=; b=jpiFqFJ4H36nzY2+tVgQHTb6bad1hxmNle8Cn+2NNFnqipMUY99NgQFPIVoqXG5gaMrT5h bT+ikor75yvQ6OIKfWs9A0R4gbkuP0EO5EnPNofXf+zsYBqTNzerRjP16jQCZQzAvUnmW/ /cbVRgiwufZYcryJyquLNkWWg63Xwes= X-Envelope-To: luis.henriques@linux.dev X-Envelope-To: linux-kernel@vger.kernel.org X-Envelope-To: tytso@mit.edu X-Envelope-To: linux-ext4@vger.kernel.org X-Envelope-To: jack@suse.com X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: "Luis Henriques (SUSE)" To: Theodore Ts'o , Andreas Dilger , Jan Kara Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, "Luis Henriques (SUSE)" Subject: [RFC PATCH 1/2] ext4: fix fast commit inode enqueueing during a full journal commit Date: Tue, 21 May 2024 16:45:34 +0100 Message-ID: <20240521154535.12911-2-luis.henriques@linux.dev> In-Reply-To: <20240521154535.12911-1-luis.henriques@linux.dev> References: <20240521154535.12911-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" When a full journal commit is on-going, any fast commit has to be enqueued into a different queue: FC_Q_STAGING instead of FC_Q_MAIN. This enqueueing is done only once, i.e. if an inode is already queued in a previous fast commit entry it won't be enqueued again. However, if a full commit starts _after_ the inode is enqueued into FC_Q_MAIN, the next fast commit needs to be done into FC_Q_STAGING. And this is not being done in function ext4_fc_track_template(). This patch fixes the issue by simply re-enqueuing the inode from the MAIN into the STAGING queue. This bug was found using fstest generic/047. This test creates several 32k bytes files, sync'ing each of them after it's creation, and then shutting down the filesystem. Some data may be loss in this operation; for example a file may have it's size truncated to zero. Signed-off-by: Luis Henriques (SUSE) --- fs/ext4/fast_commit.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c index 87c009e0c59a..337b5289cf11 100644 --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -396,12 +396,19 @@ static int ext4_fc_track_template( return ret; =20 spin_lock(&sbi->s_fc_lock); - if (list_empty(&EXT4_I(inode)->i_fc_list)) - list_add_tail(&EXT4_I(inode)->i_fc_list, - (sbi->s_journal->j_flags & JBD2_FULL_COMMIT_ONGOING || - sbi->s_journal->j_flags & JBD2_FAST_COMMIT_ONGOING) ? - &sbi->s_fc_q[FC_Q_STAGING] : - &sbi->s_fc_q[FC_Q_MAIN]); + if (sbi->s_journal->j_flags & JBD2_FULL_COMMIT_ONGOING || + sbi->s_journal->j_flags & JBD2_FAST_COMMIT_ONGOING) { + if (list_empty(&EXT4_I(inode)->i_fc_list)) + list_add_tail(&EXT4_I(inode)->i_fc_list, + &sbi->s_fc_q[FC_Q_STAGING]); + else + list_move_tail(&EXT4_I(inode)->i_fc_list, + &sbi->s_fc_q[FC_Q_STAGING]); + } else { + if (list_empty(&EXT4_I(inode)->i_fc_list)) + list_add_tail(&EXT4_I(inode)->i_fc_list, + &sbi->s_fc_q[FC_Q_MAIN]); + } spin_unlock(&sbi->s_fc_lock); =20 return ret; From nobody Wed Feb 11 11:28:11 2026 Received: from out-173.mta1.migadu.com (out-173.mta1.migadu.com [95.215.58.173]) (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 C659518E1C for ; Tue, 21 May 2024 15:45:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716306346; cv=none; b=jDc9p/OVhHLTwg4zNVh565XzRTfZOG8ahKYOpd3Nb9pAQV/p+xB0w4ei7AToUyCOvSOpo3BNfpnlcDs7GicK5vpmI2zj7u6S558wv/ilH+7MXMEiJuRJd8ROMp28UouKb2txprN7L4pQrks2Nk1AFHBDGoTW1K5khO9axikTRL4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716306346; c=relaxed/simple; bh=VCqHvca1+tEFlZyUswqtYOjRe1WSqx+94tESfnQNFpU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RaxSzR10EgDYJ7ufhnqTtF/CVKfTS9MpVmterDNvcLA2bpGnQc4b+La+IEOVI3cCnd5Fg7cOIE3rZbxO5i5+qDW2gQlENcniZTD8me8rm+NriaKwLRLm5/dY6B8OytqWtxPz1YSrnsGDSfvLgQcnxx07Aa6PD3BtUAdMcDTmTgs= 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=FhBESG7+; arc=none smtp.client-ip=95.215.58.173 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="FhBESG7+" X-Envelope-To: jack@suse.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1716306342; 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=/jizdrh7qFsyQUbpJOd4DGt8jMXMJUYqkogii65S0bU=; b=FhBESG7+EvSkcBMvLFS1hqfsQkaVWwhDx7FtDWOQWAUowX6BNi3g2+zkuKIMy44VfI03fI TQ4RJTQk5QzB9h3385J9sEe24J5L8MgCY/DNnsj901cUtWRR9J0fURDEuId4HdzLY8HZ8s clY/Df20c/d777D/mM3JEKONHVCoYIg= X-Envelope-To: linux-kernel@vger.kernel.org X-Envelope-To: tytso@mit.edu X-Envelope-To: linux-ext4@vger.kernel.org X-Envelope-To: luis.henriques@linux.dev X-Envelope-To: adilger@dilger.ca X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: "Luis Henriques (SUSE)" To: Theodore Ts'o , Andreas Dilger , Jan Kara Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, "Luis Henriques (SUSE)" Subject: [RFC PATCH 2/2] jbd2: reset fast commit offset only after fs cleanup is done Date: Tue, 21 May 2024 16:45:35 +0100 Message-ID: <20240521154535.12911-3-luis.henriques@linux.dev> In-Reply-To: <20240521154535.12911-1-luis.henriques@linux.dev> References: <20240521154535.12911-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" When doing a journal commit, the fast journal offset (journal->j_fc_off) is set to zero too early in the process. Since ext4 filesystem calls function jbd2_fc_release_bufs() in its j_fc_cleanup_callback (ext4_fc_cleanup()), that call will be a no-op exactly because the offset is zero. Move the fast commit offset further down in the journal commit code, until it's mostly done, immediately before clearing the on-going commit flags. Signed-off-by: Luis Henriques (SUSE) --- fs/jbd2/commit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c index 75ea4e9a5cab..88b834c7c9c9 100644 --- a/fs/jbd2/commit.c +++ b/fs/jbd2/commit.c @@ -435,7 +435,6 @@ void jbd2_journal_commit_transaction(journal_t *journal) commit_transaction->t_tid); =20 write_lock(&journal->j_state_lock); - journal->j_fc_off =3D 0; J_ASSERT(commit_transaction->t_state =3D=3D T_RUNNING); commit_transaction->t_state =3D T_LOCKED; =20 @@ -1133,6 +1132,7 @@ void jbd2_journal_commit_transaction(journal_t *journ= al) journal->j_commit_sequence, journal->j_tail_sequence); =20 write_lock(&journal->j_state_lock); + journal->j_fc_off =3D 0; journal->j_flags &=3D ~JBD2_FULL_COMMIT_ONGOING; journal->j_flags &=3D ~JBD2_FAST_COMMIT_ONGOING; spin_lock(&journal->j_list_lock);