btrfs: increment extent count once when logging extents during fast fsync

In btrfs_log_changed_extents() we increment the extent count twice, and
we then fallback to a transaction commit if the count reaches a threshold
of 32K. However we increment the count twice, which is confusing and
pointless. So increment the count only once and reduce the threshold to
half (16K).

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Filipe Manana 2026-09-09 12:26:30 +01:00 committed by David Sterba
parent d8fb1db2db
commit 4ef2c403d2

View File

@ -5350,7 +5350,7 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans,
* have a bunch of extents we just want to commit since it will
* be faster.
*/
if (++num > 32768) {
if (++num > SZ_16K) {
list_del_init(&tree->modified_extents);
ret = -EFBIG;
goto process;
@ -5368,7 +5368,6 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans,
refcount_inc(&em->refs);
em->flags |= EXTENT_FLAG_LOGGING;
list_add_tail(&em->list, &extents);
num++;
}
list_sort(NULL, &extents, extent_cmp);