diff options
author | NeilBrown <neilb@suse.de> | 2012-05-04 03:03:18 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2012-05-04 03:03:18 -0400 |
commit | b16b1b6cd052acbacc0a15f934bca9b354534d48 (patch) | |
tree | ba5b2e72e04a18a4bd83429f089d16637b9a6343 /drivers | |
parent | 69964ea4c7b68c9399f7977aa5b9aa6539a6a98a (diff) |
md/bitmap: fix calculation of 'chunks' - missing shift.
commit 61a0d80c "md/bitmap: discard CHUNK_BLOCK_SHIFT macro"
replaced CHUNK_BLOCK_RATIO() by the same text that was
replacing CHUNK_BLOCK_SHIFT() - which is clearly wrong.
The result is that 'chunks' is often too small by 1,
which can sometimes result in a crash (not sure how).
So use the correct replacement, and get rid of CHUNK_BLOCK_RATIO
which is no longe used.
Reported-by: Karl Newman <siliconfiend@gmail.com>
Tested-by: Karl Newman <siliconfiend@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/md/bitmap.c | 3 | ||||
-rw-r--r-- | drivers/md/bitmap.h | 3 |
2 files changed, 1 insertions, 5 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index 97e73e555d11..17e2b472e16d 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c | |||
@@ -1727,8 +1727,7 @@ int bitmap_create(struct mddev *mddev) | |||
1727 | bitmap->chunkshift = (ffz(~mddev->bitmap_info.chunksize) | 1727 | bitmap->chunkshift = (ffz(~mddev->bitmap_info.chunksize) |
1728 | - BITMAP_BLOCK_SHIFT); | 1728 | - BITMAP_BLOCK_SHIFT); |
1729 | 1729 | ||
1730 | /* now that chunksize and chunkshift are set, we can use these macros */ | 1730 | chunks = (blocks + (1 << bitmap->chunkshift) - 1) >> |
1731 | chunks = (blocks + bitmap->chunkshift - 1) >> | ||
1732 | bitmap->chunkshift; | 1731 | bitmap->chunkshift; |
1733 | pages = (chunks + PAGE_COUNTER_RATIO - 1) / PAGE_COUNTER_RATIO; | 1732 | pages = (chunks + PAGE_COUNTER_RATIO - 1) / PAGE_COUNTER_RATIO; |
1734 | 1733 | ||
diff --git a/drivers/md/bitmap.h b/drivers/md/bitmap.h index 55ca5aec84e4..b44b0aba2d47 100644 --- a/drivers/md/bitmap.h +++ b/drivers/md/bitmap.h | |||
@@ -101,9 +101,6 @@ typedef __u16 bitmap_counter_t; | |||
101 | 101 | ||
102 | #define BITMAP_BLOCK_SHIFT 9 | 102 | #define BITMAP_BLOCK_SHIFT 9 |
103 | 103 | ||
104 | /* how many blocks per chunk? (this is variable) */ | ||
105 | #define CHUNK_BLOCK_RATIO(bitmap) ((bitmap)->mddev->bitmap_info.chunksize >> BITMAP_BLOCK_SHIFT) | ||
106 | |||
107 | #endif | 104 | #endif |
108 | 105 | ||
109 | /* | 106 | /* |