diff options
author | Qu Wenruo <wqu@suse.com> | 2022-04-01 14:23:16 +0300 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2022-05-16 18:03:14 +0300 |
commit | 843de58b3e317fc51d4a1643f3641401ecf1d941 (patch) | |
tree | 6c2f9794f04928504ba7cb032cf54e03b84210f2 /fs/btrfs | |
parent | cc353a8be2fd3e585c09f0eba23fa3ca1905f253 (diff) | |
download | linux-843de58b3e317fc51d4a1643f3641401ecf1d941.tar.xz |
btrfs: raid56: open code rbio_nr_pages()
The function rbio_nr_pages() is only called once inside alloc_rbio(),
there is no reason to make it dedicated helper.
Furthermore, the return type doesn't match, the function return "unsigned
long" which may not be necessary, while the only caller only uses "int".
Since we're doing cleaning up here, also fix the type to "const unsigned
int" for all involved local variables.
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/raid56.c | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c index 1db4395df21d..06d303ea3ebf 100644 --- a/fs/btrfs/raid56.c +++ b/fs/btrfs/raid56.c @@ -946,16 +946,6 @@ static struct page *page_in_rbio(struct btrfs_raid_bio *rbio, } /* - * number of pages we need for the entire stripe across all the - * drives - */ -static unsigned long rbio_nr_pages(u32 stripe_len, int nr_stripes) -{ - ASSERT(IS_ALIGNED(stripe_len, PAGE_SIZE)); - return (stripe_len >> PAGE_SHIFT) * nr_stripes; -} - -/* * allocation and initial setup for the btrfs_raid_bio. Not * this does not allocate any pages for rbio->pages. */ @@ -963,13 +953,15 @@ static struct btrfs_raid_bio *alloc_rbio(struct btrfs_fs_info *fs_info, struct btrfs_io_context *bioc, u32 stripe_len) { + const unsigned int real_stripes = bioc->num_stripes - bioc->num_tgtdevs; + const unsigned int stripe_npages = stripe_len >> PAGE_SHIFT; + const unsigned int num_pages = stripe_npages * real_stripes; struct btrfs_raid_bio *rbio; int nr_data = 0; - int real_stripes = bioc->num_stripes - bioc->num_tgtdevs; - int num_pages = rbio_nr_pages(stripe_len, real_stripes); - int stripe_npages = stripe_len >> PAGE_SHIFT; void *p; + ASSERT(IS_ALIGNED(stripe_len, PAGE_SIZE)); + rbio = kzalloc(sizeof(*rbio) + sizeof(*rbio->stripe_pages) * num_pages + sizeof(*rbio->bio_pages) * num_pages + |