Skip to contentSkip to conversation

btrfs: align max_zone_append_size to the sector size

PATCH In review Christoph Hellwig 3 participants 5 messages Jul 14, 2022 – Jul 18, 2022 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: align max_zone_append_size to the sector size

max_zone_append_size and thus the maximum extent size needs to be aligned to the sector size, else a lot code becomes rather unhappy and various alignment asserts trigger.

Fixes 385ea2aea011 ("btrfs: replace BTRFS_MAX_EXTENT_SIZE with fs_info->max_extent_size")
---
 fs/btrfs/zoned.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/zoned.c +2 -1
index 3b45b35aa945c..fbad2e489dc80 100644
@@ -739,7 +739,8 @@ int btrfs_check_zoned_mode(struct btrfs_fs_info *fs_info)
 	}
 
 	fs_info->zone_size = zone_size;
-	fs_info->max_zone_append_size = max_zone_append_size;
+	fs_info->max_zone_append_size =
+		ALIGN(max_zone_append_size, fs_info->sectorsize);
 	fs_info->fs_devices->chunk_alloc_policy = BTRFS_CHUNK_ALLOC_ZONED;
 	if (fs_info->max_zone_append_size < fs_info->max_extent_size)
 		fs_info->max_extent_size = fs_info->max_zone_append_size;
Signature · 1 line
2.30.2
#2 lore raw
In reply to Christoph Hellwig
Quoted 6 lines · Christoph Hellwig

max_zone_append_size and thus the maximum extent size needs to be aligned to the sector size, else a lot code becomes rather unhappy and various alignment asserts trigger.

Fixes 385ea2aea011 ("btrfs: replace BTRFS_MAX_EXTENT_SIZE with fs_info->max_extent_size")

Folded to the patch, thanks.

#3 lore raw
Quoted 4 lines · David Sterba
Quoted 2 lines
Fixes 385ea2aea011 ("btrfs: replace BTRFS_MAX_EXTENT_SIZE with fs_info->max_extent_size")

Folded to the patch, thanks.

Turns out this is still broken as I was misled by the fancy ALIGN macro. We need the incremental change below. Do you want to fold this in again or should I sent it as a separate patch:

fs/btrfs/zoned.c +1 -1
index 606cd4aab3902..fb335e87b2212 100644
@@ -740,7 +740,7 @@ int btrfs_check_zoned_mode(struct btrfs_fs_info *fs_info)
 
 	fs_info->zone_size = zone_size;
 	fs_info->max_zone_append_size =
-		ALIGN(max_zone_append_size, fs_info->sectorsize);
+		ALIGN_DOWN(max_zone_append_size, fs_info->sectorsize);
 	fs_info->fs_devices->chunk_alloc_policy = BTRFS_CHUNK_ALLOC_ZONED;
 	if (fs_info->max_zone_append_size < fs_info->max_extent_size)
 		fs_info->max_extent_size = fs_info->max_zone_append_size;
#4 lore raw
Quoted 9 lines · Christoph Hellwig
Quoted 4 lines · David Sterba
Quoted 2 lines
Fixes 385ea2aea011 ("btrfs: replace BTRFS_MAX_EXTENT_SIZE with fs_info->max_extent_size")

Folded to the patch, thanks.

Turns out this is still broken as I was misled by the fancy ALIGN macro. We need the incremental change below. Do you want to fold this in again or should I sent it as a separate patch:

Folding small fixups is easier for me, no need to resend, thanks.