From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796386491; b=KTWsAN63v5+F+1bRRitCKXwfjToF+200YyxdRCbbpOgoLxRBGnDaWZblV71oRXSc0LNA oNfctOnJJxgIf3aKwfXanZEcBIhLYqdINHyCcPXfWIwFGiPUUUWfVNfRLNE198SHYUL6/ GfDdy2fdrbs/QeefXaeLhV5vOJRoiz7/NsouG8K/NDQfUl6hexaIpVdWMXUIYBrkYylH8 BEGq+E2XDmXBFwnvPUDw8ldiiyKlFx7lZfLVIDItBwzv21Ft1tlzQ3E92yXBBzlZbgpNS cFlqdz0SHdfwWwKtg4IChh/AVSTV1uk/c1BIqMTQQgG7XBZ/iWoL/b36vZQ9FV/k7GQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386491; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=v3v2avLulBJiEtpkOd3roQ4eopYa8d2Iv/fIVANJp0s=; b=19gRMiXbWD0dinqAph8DcqMQ7Lw5UjV2VjqW2sQR96axkkkb+j6FoDoGlxeh7qWTumM5 nwEn2Y1hqrCyQU4+/GKRpUFH/fDzSlxuVYE+Yg63mbRNq9IBknXVe82IszuBCtzCm5BC+ 2oY9oCFrHJlvpejHpZ6uMu79UTZBHxCg0zrtjO64mN5HyLeKWT0a75DcpwVjvpQqTE7uI C0SgLmKRpUfTd4SPHoiWJ5HuYyaztTHm1nVJcGUHUXrWvU2v9K1ixkKRnWMo7KIGXniZm CGAbJ+ijxNAcQU9XCszfLovlh/iVibqvAhmNJm/GnoSkYTsm6XjiV5NUdtuglUO4pag== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=wy5fPytJ; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C825F606A336; Fri, 4 Dec 2026 12:14:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=wy5fPytJ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FF8E1F0092C; Fri, 4 Dec 2026 12:14:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796386491; bh=v3v2avLulBJiEtpkOd3roQ4eopYa8d2Iv/fIVANJp0s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=wy5fPytJdHJokYB9xyqn5A4GltvQyZS4rnASw8YgIyYyPp05+mVRzu8GlX6asIgr5 Im+eYzQslZiOBQWKhbtgjV0vtqtPjh/mlBVjheoJoA8OBtN15mEUZ0D83rqR01wjf2 HD/GT7Y65ikz/qYS/ohsyywgPfF7r/kS0P/Yj2Ec= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Qu Wenruo , Filipe Manana , David Sterba , Sasha Levin Subject: [PATCH 6.6 0945/1167] btrfs: abort transaction on failure to update inode after hole punching Date: Fri, 4 Dec 2026 19:06:12 +0900 Message-ID: <20261204100726.804451128@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Filipe Manana [ Upstream commit 6cd72166183bfc290fd853470232020c4b807aa2 ] If we fail to update the inode we simply release the transaction and don't abort the transaction. This means the transaction can get committed and we will not persist important updates to the inode item such as nbytes (which gets reduced after punching holes) and the timestamps. Fix this by adding the missing abort. Link: https://sashiko.dev/#/bug/linux-d8b4cb7a-8dfe-454f-9b19-a67af28b81bd Fixes: 2aaa66558172 ("Btrfs: add hole punching") Reviewed-by: Qu Wenruo Signed-off-by: Filipe Manana Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/file.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index fe742200154e8..7fce2f0d04207 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -2740,7 +2740,10 @@ static int btrfs_punch_hole(struct file *file, loff_t offset, loff_t len) inode_inc_iversion(inode); inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); ret = btrfs_update_inode(trans, BTRFS_I(inode)); - updated_inode = true; + if (ret) + btrfs_abort_transaction(trans, ret); + else + updated_inode = true; btrfs_end_transaction(trans); btrfs_btree_balance_dirty(fs_info); out: @@ -2766,6 +2769,8 @@ static int btrfs_punch_hole(struct file *file, loff_t offset, loff_t len) int ret2; ret = btrfs_update_inode(trans, BTRFS_I(inode)); + if (ret) + btrfs_abort_transaction(trans, ret); ret2 = btrfs_end_transaction(trans); if (!ret) ret = ret2; -- 2.53.0