]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
btrfs: introduce a common helper to calculate the size of a bio
authorQu Wenruo <wqu@suse.com>
Fri, 20 Feb 2026 03:41:50 +0000 (14:11 +1030)
committerDavid Sterba <dsterba@suse.com>
Tue, 7 Apr 2026 16:55:59 +0000 (18:55 +0200)
commitc4bc2dd32c63a70ed948ed9927ea2c46f7c5b454
treec6a2e2573351ba9d4d15f6b61d4066d7e7b05ce3
parent8c0b917d78fc2a1fb4afac90a597b75e0a5b7223
btrfs: introduce a common helper to calculate the size of a bio

We have several call sites doing the same work to calculate the size of
a bio:

struct bio_vec *bvec;
u32 bio_size = 0;
int i;

bio_for_each_bvec_all(bvec, bio, i)
bio_size += bvec->bv_len;

We can use a common helper instead of open-coding it everywhere.

This also allows us to constify the @bio_size variables used in all the
call sites.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/misc.h
fs/btrfs/raid56.c
fs/btrfs/scrub.c