提交 94efbe19 编写于 作者: Q Qu Wenruo 提交者: David Sterba

btrfs: raid56: introduce new cached members for btrfs_raid_bio

The new members are all related to number of sectors, but the existing
number of pages members are kept as is:

- nr_sectors
  Total sectors of the full stripe including P/Q.

- stripe_nsectors
  The sectors of a single stripe.
Signed-off-by: NQu Wenruo <wqu@suse.com>
Reviewed-by: NDavid Sterba <dsterba@suse.com>
Signed-off-by: NDavid Sterba <dsterba@suse.com>
上级 29b06838
...@@ -115,6 +115,9 @@ struct btrfs_raid_bio { ...@@ -115,6 +115,9 @@ struct btrfs_raid_bio {
/* How many pages there are for the full stripe including P/Q */ /* How many pages there are for the full stripe including P/Q */
u16 nr_pages; u16 nr_pages;
/* How many sectors there are for the full stripe including P/Q */
u16 nr_sectors;
/* Number of data stripes (no p/q) */ /* Number of data stripes (no p/q) */
u8 nr_data; u8 nr_data;
...@@ -124,6 +127,9 @@ struct btrfs_raid_bio { ...@@ -124,6 +127,9 @@ struct btrfs_raid_bio {
/* How many pages there are for each stripe */ /* How many pages there are for each stripe */
u8 stripe_npages; u8 stripe_npages;
/* How many sectors there are for each stripe */
u8 stripe_nsectors;
/* First bad stripe, -1 means no corruption */ /* First bad stripe, -1 means no corruption */
s8 faila; s8 faila;
...@@ -172,7 +178,7 @@ struct btrfs_raid_bio { ...@@ -172,7 +178,7 @@ struct btrfs_raid_bio {
/* allocated with real_stripes-many pointers for finish_*() calls */ /* allocated with real_stripes-many pointers for finish_*() calls */
void **finish_pointers; void **finish_pointers;
/* allocated with stripe_npages-many bits for finish_*() calls */ /* Allocated with stripe_nsectors-many bits for finish_*() calls */
unsigned long *finish_pbitmap; unsigned long *finish_pbitmap;
}; };
...@@ -958,19 +964,22 @@ static struct btrfs_raid_bio *alloc_rbio(struct btrfs_fs_info *fs_info, ...@@ -958,19 +964,22 @@ static struct btrfs_raid_bio *alloc_rbio(struct btrfs_fs_info *fs_info,
const unsigned int real_stripes = bioc->num_stripes - bioc->num_tgtdevs; const unsigned int real_stripes = bioc->num_stripes - bioc->num_tgtdevs;
const unsigned int stripe_npages = stripe_len >> PAGE_SHIFT; const unsigned int stripe_npages = stripe_len >> PAGE_SHIFT;
const unsigned int num_pages = stripe_npages * real_stripes; const unsigned int num_pages = stripe_npages * real_stripes;
const unsigned int stripe_nsectors = stripe_len >> fs_info->sectorsize_bits;
const unsigned int num_sectors = stripe_nsectors * real_stripes;
struct btrfs_raid_bio *rbio; struct btrfs_raid_bio *rbio;
int nr_data = 0; int nr_data = 0;
void *p; void *p;
ASSERT(IS_ALIGNED(stripe_len, PAGE_SIZE)); ASSERT(IS_ALIGNED(stripe_len, PAGE_SIZE));
/* PAGE_SIZE must also be aligned to sectorsize for subpage support */
ASSERT(IS_ALIGNED(PAGE_SIZE, fs_info->sectorsize));
rbio = kzalloc(sizeof(*rbio) + rbio = kzalloc(sizeof(*rbio) +
sizeof(*rbio->stripe_pages) * num_pages + sizeof(*rbio->stripe_pages) * num_pages +
sizeof(*rbio->bio_pages) * num_pages + sizeof(*rbio->bio_pages) * num_pages +
sizeof(*rbio->finish_pointers) * real_stripes + sizeof(*rbio->finish_pointers) * real_stripes +
sizeof(*rbio->dbitmap) * BITS_TO_LONGS(stripe_npages) + sizeof(*rbio->dbitmap) * BITS_TO_LONGS(stripe_nsectors) +
sizeof(*rbio->finish_pbitmap) * sizeof(*rbio->finish_pbitmap) * BITS_TO_LONGS(stripe_nsectors),
BITS_TO_LONGS(stripe_npages),
GFP_NOFS); GFP_NOFS);
if (!rbio) if (!rbio)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -983,8 +992,10 @@ static struct btrfs_raid_bio *alloc_rbio(struct btrfs_fs_info *fs_info, ...@@ -983,8 +992,10 @@ static struct btrfs_raid_bio *alloc_rbio(struct btrfs_fs_info *fs_info,
rbio->bioc = bioc; rbio->bioc = bioc;
rbio->stripe_len = stripe_len; rbio->stripe_len = stripe_len;
rbio->nr_pages = num_pages; rbio->nr_pages = num_pages;
rbio->nr_sectors = num_sectors;
rbio->real_stripes = real_stripes; rbio->real_stripes = real_stripes;
rbio->stripe_npages = stripe_npages; rbio->stripe_npages = stripe_npages;
rbio->stripe_nsectors = stripe_nsectors;
rbio->faila = -1; rbio->faila = -1;
rbio->failb = -1; rbio->failb = -1;
refcount_set(&rbio->refs, 1); refcount_set(&rbio->refs, 1);
...@@ -1003,8 +1014,8 @@ static struct btrfs_raid_bio *alloc_rbio(struct btrfs_fs_info *fs_info, ...@@ -1003,8 +1014,8 @@ static struct btrfs_raid_bio *alloc_rbio(struct btrfs_fs_info *fs_info,
CONSUME_ALLOC(rbio->stripe_pages, num_pages); CONSUME_ALLOC(rbio->stripe_pages, num_pages);
CONSUME_ALLOC(rbio->bio_pages, num_pages); CONSUME_ALLOC(rbio->bio_pages, num_pages);
CONSUME_ALLOC(rbio->finish_pointers, real_stripes); CONSUME_ALLOC(rbio->finish_pointers, real_stripes);
CONSUME_ALLOC(rbio->dbitmap, BITS_TO_LONGS(stripe_npages)); CONSUME_ALLOC(rbio->dbitmap, BITS_TO_LONGS(stripe_nsectors));
CONSUME_ALLOC(rbio->finish_pbitmap, BITS_TO_LONGS(stripe_npages)); CONSUME_ALLOC(rbio->finish_pbitmap, BITS_TO_LONGS(stripe_nsectors));
#undef CONSUME_ALLOC #undef CONSUME_ALLOC
if (bioc->map_type & BTRFS_BLOCK_GROUP_RAID5) if (bioc->map_type & BTRFS_BLOCK_GROUP_RAID5)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册