瀏覽代碼

btrfs: Fix calculation of rbio->dbitmap's size calculation

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>
Zhao Lei 10 年之前
父節點
當前提交
bfca9a6d4b
共有 2 個文件被更改,包括 3 次插入3 次删除
  1. 2 2
      fs/btrfs/raid56.c
  2. 1 1
      fs/btrfs/scrub.c

+ 2 - 2
fs/btrfs/raid56.c

@@ -966,8 +966,8 @@ static struct btrfs_raid_bio *alloc_rbio(struct btrfs_root *root,
 	void *p;
 	void *p;
 
 
 	rbio = kzalloc(sizeof(*rbio) + num_pages * sizeof(struct page *) * 2 +
 	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)
 	if (!rbio)
 		return ERR_PTR(-ENOMEM);
 		return ERR_PTR(-ENOMEM);
 
 

+ 1 - 1
fs/btrfs/scrub.c

@@ -2813,7 +2813,7 @@ out:
 
 
 static inline int scrub_calc_parity_bitmap_len(int nsectors)
 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)
 static void scrub_parity_get(struct scrub_parity *sparity)