btrfs: refactor allocation size calculation in alloc_btrfs_io_context()

Use struct_size() to replace the open-coded calculation, remove the
comment as use of the helper is self explanatory.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Mehdi Ben Hadj Khelifa <mehdi.benhadjkhelifa@gmail.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Mehdi Ben Hadj Khelifa
2025-09-30 11:03:44 +01:00
committed by David Sterba
parent aebe2bb0b8
commit 2346b966c6

View File

@@ -6076,12 +6076,7 @@ struct btrfs_io_context *alloc_btrfs_io_context(struct btrfs_fs_info *fs_info,
{
struct btrfs_io_context *bioc;
bioc = kzalloc(
/* The size of btrfs_io_context */
sizeof(struct btrfs_io_context) +
/* Plus the variable array for the stripes */
sizeof(struct btrfs_io_stripe) * (total_stripes),
GFP_NOFS);
bioc = kzalloc(struct_size(bioc, stripes, total_stripes), GFP_NOFS);
if (!bioc)
return NULL;