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=1796387839; b=NtuAOxGm5CdPfTfld5KuGqvdXI0oR+XpTnRio43I7bbElAYy83PWAz2LXogpkdh9EVbJ yXy9M63zLlZ8ZJn5scz8Y7TYw5y1IGAcliyDQk0tpTzvo2bW53Y02A/FZ9GK0Dh1P54a/ 3qJjCZ2Rgw4N8izEZ6zasmq3wqt6v5nRct9kGxl4nw+43LpQ7tw4qudKd8h9ynMIwEFbO nJYBdtqGbdwxMd0R9mdQ+Kbe8IQEjZjkaKLL3L3DbWpcm3gbGidtD8yefXtJ7cZZ0YnpY 89P2owbZGJHYyTMWJCFmTkEjHc+B8nyQVfJGCUp/xRon5Rim9kE25Vh9FLQH7XYhBYQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387839; 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=zxD49Wf4Ezc2jpDBksXB+uXfJqo663yKAlt7QmnAxM0=; b=hhqT7SA4aSM2OWPtng6zIkUJZg8rLaYkb+kDM/PqV8l9iOUouWh0B4IH/l/MTaZbhzMp EHtKNudFQR+sBPW5SOWuDuSuQLW+UJUKr9JjQxKmY4nguOZV3dbTqLtRCojeG7nRX9SkO nKiWQ3au7ZhBK1C2T5OpNQvnN+mv5e6LT2j/fd2PClkm7rbsHDPV1Ytciu2rDZNfLYp5S qT3aRkQgm6aDsAcCh8TCrwaf9RFUgBVyKiUzZxrpcg4ITLvokkMDQVjLgxpgdrh0D75RT 6f9ZqMeMVcfZVUb+GnRZdW1EeRULrE9UrNMRZTxHWef5ioNv4kzBrXpUErXMVoYX/CQ== 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=HrQ3yR7N; 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 DB887606A335; Fri, 4 Dec 2026 12:37:19 +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=HrQ3yR7N Received: by smtp.kernel.org (Postfix) with ESMTPSA id 586C41F000C2; Fri, 4 Dec 2026 12:37:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387839; bh=zxD49Wf4Ezc2jpDBksXB+uXfJqo663yKAlt7QmnAxM0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HrQ3yR7N79POhyj9HPPII2u9brHEYiSUP8PfSdeuaWbsa8M9BDR3x473tm/sgjL6q MSae0NpfaeHVZ4zVmWj3ySPnXkFUws2D+0TaQUAe6shQtdkiHPsRk8f0pgAJ6xMkuc IjO6IpsraemzRU5dpBzSHOsJL3x3vDmgqRIiwxyA= 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.1 0380/1059] btrfs: defrag: fix check to see if next extent can be defragged too Date: Fri, 4 Dec 2026 18:58:31 +0900 Message-ID: <20261204100654.137020827@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Filipe Manana [ Upstream commit eb55bc2bfe204e6bfccfe179226d7fb5024cb010 ] We want to check if the next extent is at maximum capacity but we are passing the current extent map to get_extent_max_capacity() and not the next extent map. For example if the current extent is compressed (its maximum capacity is 128K) and the next extent is uncompressed (its maximum capacity is 128M), then we can bail out and not defrag the next extent too - when for example the next extent as a size of 128K, is uncompressed, and the extent threshold is >= 256K. Fixes: 979b25c300db ("btrfs: defrag: don't defrag extents which are already at max capacity") Reviewed-by: Qu Wenruo Signed-off-by: Filipe Manana Signed-off-by: David Sterba [ sashal: Applied the one-line change to defrag_check_next_extent() in ioctl.c, since the defrag code has not yet been split out into its own file here. ] Signed-off-by: Sasha Levin --- fs/btrfs/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 1b0dd3228aa1e..42aef738c867e 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -1308,7 +1308,7 @@ static bool defrag_check_next_extent(struct inode *inode, struct extent_map *em, * If the next extent is at its max capacity, defragging current extent * makes no sense, as the total number of extents won't change. */ - if (next->len >= get_extent_max_capacity(fs_info, em)) + if (next->len >= get_extent_max_capacity(fs_info, next)) goto out; /* Skip older extent */ if (next->generation < newer_than) -- 2.53.0