aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/bitmap.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2009-05-06 22:49:06 -0400
committerNeilBrown <neilb@suse.de>2009-05-06 22:49:06 -0400
commitdb305e507d554430a69ede901a6308e6ecb72349 (patch)
treeb3ad8266ff05ae9059de551cdf8a8965bd27bcb1 /drivers/md/bitmap.c
parent18055569127253755d01733f6ecc004ed02f88d0 (diff)
md: fix some (more) errors with bitmaps on devices larger than 2TB.
If a write intent bitmap covers more than 2TB, we sometimes work with values beyond 32bit, so these need to be sector_t. This patches add the required casts to some unsigned longs that are being shifted up. This will affect any raid10 larger than 2TB, or any raid1/4/5/6 with member devices that are larger than 2TB. Signed-off-by: NeilBrown <neilb@suse.de> Reported-by: "Mario 'BitKoenig' Holbe" <Mario.Holbe@TU-Ilmenau.DE> Cc: stable@kernel.org
Diffstat (limited to 'drivers/md/bitmap.c')
-rw-r--r--drivers/md/bitmap.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index bc1d64b7b63b..47c68bc75a17 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -1013,9 +1013,11 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
1013 kunmap_atomic(paddr, KM_USER0); 1013 kunmap_atomic(paddr, KM_USER0);
1014 if (b) { 1014 if (b) {
1015 /* if the disk bit is set, set the memory bit */ 1015 /* if the disk bit is set, set the memory bit */
1016 bitmap_set_memory_bits(bitmap, i << CHUNK_BLOCK_SHIFT(bitmap), 1016 int needed = ((sector_t)(i+1) << (CHUNK_BLOCK_SHIFT(bitmap))
1017 ((i+1) << (CHUNK_BLOCK_SHIFT(bitmap)) >= start) 1017 >= start);
1018 ); 1018 bitmap_set_memory_bits(bitmap,
1019 (sector_t)i << CHUNK_BLOCK_SHIFT(bitmap),
1020 needed);
1019 bit_cnt++; 1021 bit_cnt++;
1020 set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN); 1022 set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN);
1021 } 1023 }
@@ -1151,8 +1153,9 @@ void bitmap_daemon_work(struct bitmap *bitmap)
1151 spin_lock_irqsave(&bitmap->lock, flags); 1153 spin_lock_irqsave(&bitmap->lock, flags);
1152 clear_page_attr(bitmap, page, BITMAP_PAGE_CLEAN); 1154 clear_page_attr(bitmap, page, BITMAP_PAGE_CLEAN);
1153 } 1155 }
1154 bmc = bitmap_get_counter(bitmap, j << CHUNK_BLOCK_SHIFT(bitmap), 1156 bmc = bitmap_get_counter(bitmap,
1155 &blocks, 0); 1157 (sector_t)j << CHUNK_BLOCK_SHIFT(bitmap),
1158 &blocks, 0);
1156 if (bmc) { 1159 if (bmc) {
1157/* 1160/*
1158 if (j < 100) printk("bitmap: j=%lu, *bmc = 0x%x\n", j, *bmc); 1161 if (j < 100) printk("bitmap: j=%lu, *bmc = 0x%x\n", j, *bmc);
@@ -1166,7 +1169,8 @@ void bitmap_daemon_work(struct bitmap *bitmap)
1166 } else if (*bmc == 1) { 1169 } else if (*bmc == 1) {
1167 /* we can clear the bit */ 1170 /* we can clear the bit */
1168 *bmc = 0; 1171 *bmc = 0;
1169 bitmap_count_page(bitmap, j << CHUNK_BLOCK_SHIFT(bitmap), 1172 bitmap_count_page(bitmap,
1173 (sector_t)j << CHUNK_BLOCK_SHIFT(bitmap),
1170 -1); 1174 -1);
1171 1175
1172 /* clear the bit */ 1176 /* clear the bit */
@@ -1511,7 +1515,7 @@ void bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e)
1511 unsigned long chunk; 1515 unsigned long chunk;
1512 1516
1513 for (chunk = s; chunk <= e; chunk++) { 1517 for (chunk = s; chunk <= e; chunk++) {
1514 sector_t sec = chunk << CHUNK_BLOCK_SHIFT(bitmap); 1518 sector_t sec = (sector_t)chunk << CHUNK_BLOCK_SHIFT(bitmap);
1515 bitmap_set_memory_bits(bitmap, sec, 1); 1519 bitmap_set_memory_bits(bitmap, sec, 1);
1516 bitmap_file_set_bit(bitmap, sec); 1520 bitmap_file_set_bit(bitmap, sec);
1517 } 1521 }