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

NeilBrown db305e50 18055569

+11 -7
+11 -7
drivers/md/bitmap.c
··· 1013 1013 kunmap_atomic(paddr, KM_USER0); 1014 1014 if (b) { 1015 1015 /* if the disk bit is set, set the memory bit */ 1016 - bitmap_set_memory_bits(bitmap, i << CHUNK_BLOCK_SHIFT(bitmap), 1017 - ((i+1) << (CHUNK_BLOCK_SHIFT(bitmap)) >= start) 1018 - ); 1016 + int needed = ((sector_t)(i+1) << (CHUNK_BLOCK_SHIFT(bitmap)) 1017 + >= start); 1018 + bitmap_set_memory_bits(bitmap, 1019 + (sector_t)i << CHUNK_BLOCK_SHIFT(bitmap), 1020 + needed); 1019 1021 bit_cnt++; 1020 1022 set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN); 1021 1023 } ··· 1153 1151 spin_lock_irqsave(&bitmap->lock, flags); 1154 1152 clear_page_attr(bitmap, page, BITMAP_PAGE_CLEAN); 1155 1153 } 1156 - bmc = bitmap_get_counter(bitmap, j << CHUNK_BLOCK_SHIFT(bitmap), 1157 - &blocks, 0); 1154 + bmc = bitmap_get_counter(bitmap, 1155 + (sector_t)j << CHUNK_BLOCK_SHIFT(bitmap), 1156 + &blocks, 0); 1158 1157 if (bmc) { 1159 1158 /* 1160 1159 if (j < 100) printk("bitmap: j=%lu, *bmc = 0x%x\n", j, *bmc); ··· 1169 1166 } else if (*bmc == 1) { 1170 1167 /* we can clear the bit */ 1171 1168 *bmc = 0; 1172 - bitmap_count_page(bitmap, j << CHUNK_BLOCK_SHIFT(bitmap), 1169 + bitmap_count_page(bitmap, 1170 + (sector_t)j << CHUNK_BLOCK_SHIFT(bitmap), 1173 1171 -1); 1174 1172 1175 1173 /* clear the bit */ ··· 1515 1511 unsigned long chunk; 1516 1512 1517 1513 for (chunk = s; chunk <= e; chunk++) { 1518 - sector_t sec = chunk << CHUNK_BLOCK_SHIFT(bitmap); 1514 + sector_t sec = (sector_t)chunk << CHUNK_BLOCK_SHIFT(bitmap); 1519 1515 bitmap_set_memory_bits(bitmap, sec, 1); 1520 1516 bitmap_file_set_bit(bitmap, sec); 1521 1517 }