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>
This commit is contained in:
parent
cc353a8be2
commit
843de58b3e
@ -945,16 +945,6 @@ static struct page *page_in_rbio(struct btrfs_raid_bio *rbio,
|
||||
return rbio->stripe_pages[chunk_page];
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 +
|
||||
|
Loading…
Reference in New Issue
Block a user