All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: defrag: fix check to see if next extent can be defragged too
@ 2026-10-07 15:20 fdmanana
  2026-10-07 21:06 ` Qu Wenruo
  0 siblings, 1 reply; 2+ messages in thread
From: fdmanana @ 2026-10-07 15:20 UTC (permalink / raw)
  To: linux-btrfs

From: Filipe Manana <fdmanana@suse.com>

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")
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/defrag.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/defrag.c b/fs/btrfs/defrag.c
index 75c87aee5de9..7010d714cfe1 100644
--- a/fs/btrfs/defrag.c
+++ b/fs/btrfs/defrag.c
@@ -811,7 +811,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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] btrfs: defrag: fix check to see if next extent can be defragged too
  2026-10-07 15:20 [PATCH] btrfs: defrag: fix check to see if next extent can be defragged too fdmanana
@ 2026-10-07 21:06 ` Qu Wenruo
  0 siblings, 0 replies; 2+ messages in thread
From: Qu Wenruo @ 2026-10-07 21:06 UTC (permalink / raw)
  To: fdmanana, linux-btrfs



在 2026/10/8 01:50, fdmanana@kernel.org 写道:
> From: Filipe Manana <fdmanana@suse.com>
> 
> 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")
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu

> ---
>   fs/btrfs/defrag.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/defrag.c b/fs/btrfs/defrag.c
> index 75c87aee5de9..7010d714cfe1 100644
> --- a/fs/btrfs/defrag.c
> +++ b/fs/btrfs/defrag.c
> @@ -811,7 +811,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)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-07 21:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-07 15:20 [PATCH] btrfs: defrag: fix check to see if next extent can be defragged too fdmanana
2026-10-07 21:06 ` Qu Wenruo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.