]> git.hungrycats.org Git - linux/commitdiff
btrfs: Fix calculation of rbio->dbitmap's size calculation
authorZhao Lei <zhaolei@cn.fujitsu.com>
Mon, 8 Dec 2014 11:55:57 +0000 (19:55 +0800)
committerZygo Blaxell <zblaxell@thirteen.furryterror.org>
Sun, 24 Jan 2016 04:34:40 +0000 (23:34 -0500)
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>
(cherry picked from commit bfca9a6d4b1322ba36235e8a652f05a9668ef59b)

fs/btrfs/raid56.c
fs/btrfs/scrub.c

index 1c30c852e99300eea0aa6a9b7ed07c145f597152..aaa4b27318aa49bb847e8552c080453f334cee60 100644 (file)
@@ -954,8 +954,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);
 
index 415150131a85597174e2363b79844db668cacb28..76ae2fbec18f72927cc07bb03ef06316ebbf6c04 100644 (file)
@@ -2690,7 +2690,7 @@ out:
 
 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)