btrfs: raid56: open code rbio_nr_pages()
authorQu Wenruo <wqu@suse.com>
Fri, 1 Apr 2022 11:23:16 +0000 (19:23 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 16 May 2022 15:03:14 +0000 (17:03 +0200)
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>
fs/btrfs/raid56.c

index 1db4395..06d303e 100644 (file)
@@ -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 +