Skip to content

Commit

Permalink
btrfs: Fix calculation of rbio->dbitmap's size calculation
Browse files Browse the repository at this point in the history
Current code is trying to calculate rbio->dbitmap's size to make it
align to sizeof(long), but implement haven't achived this object,
it is align to sizeof(char) instead.
This patch fixed above calculation, and use sizeof(long) instead of
fixed "8" to increate compatibility.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: Chris Mason <clm@fb.com>
  • Loading branch information
Zhao Lei authored and Chris Mason committed Jan 20, 2016
1 parent e1746e8 commit bfca9a6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions fs/btrfs/raid56.c
Original file line number Diff line number Diff line change
Expand Up @@ -966,8 +966,8 @@ static struct btrfs_raid_bio *alloc_rbio(struct btrfs_root *root,
void *p;

rbio = kzalloc(sizeof(*rbio) + num_pages * sizeof(struct page *) * 2 +
DIV_ROUND_UP(stripe_npages, BITS_PER_LONG / 8),
GFP_NOFS);
DIV_ROUND_UP(stripe_npages, BITS_PER_LONG) *
sizeof(long), GFP_NOFS);
if (!rbio)
return ERR_PTR(-ENOMEM);

Expand Down
2 changes: 1 addition & 1 deletion fs/btrfs/scrub.c
Original file line number Diff line number Diff line change
Expand Up @@ -2813,7 +2813,7 @@ static void scrub_parity_check_and_repair(struct scrub_parity *sparity)

static inline int scrub_calc_parity_bitmap_len(int nsectors)
{
return DIV_ROUND_UP(nsectors, BITS_PER_LONG) * (BITS_PER_LONG / 8);
return DIV_ROUND_UP(nsectors, BITS_PER_LONG) * sizeof(long);
}

static void scrub_parity_get(struct scrub_parity *sparity)
Expand Down

0 comments on commit bfca9a6

Please sign in to comment.