aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/bitmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/bitmap.c')
-rw-r--r--drivers/md/bitmap.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index f8a9f7ab2cb8..47c68bc75a17 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -986,6 +986,9 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
986 oldindex = index; 986 oldindex = index;
987 oldpage = page; 987 oldpage = page;
988 988
989 bitmap->filemap[bitmap->file_pages++] = page;
990 bitmap->last_page_size = count;
991
989 if (outofdate) { 992 if (outofdate) {
990 /* 993 /*
991 * if bitmap is out of date, dirty the 994 * if bitmap is out of date, dirty the
@@ -998,15 +1001,9 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
998 write_page(bitmap, page, 1); 1001 write_page(bitmap, page, 1);
999 1002
1000 ret = -EIO; 1003 ret = -EIO;
1001 if (bitmap->flags & BITMAP_WRITE_ERROR) { 1004 if (bitmap->flags & BITMAP_WRITE_ERROR)
1002 /* release, page not in filemap yet */
1003 put_page(page);
1004 goto err; 1005 goto err;
1005 }
1006 } 1006 }
1007
1008 bitmap->filemap[bitmap->file_pages++] = page;
1009 bitmap->last_page_size = count;
1010 } 1007 }
1011 paddr = kmap_atomic(page, KM_USER0); 1008 paddr = kmap_atomic(page, KM_USER0);
1012 if (bitmap->flags & BITMAP_HOSTENDIAN) 1009 if (bitmap->flags & BITMAP_HOSTENDIAN)
@@ -1016,9 +1013,11 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
1016 kunmap_atomic(paddr, KM_USER0); 1013 kunmap_atomic(paddr, KM_USER0);
1017 if (b) { 1014 if (b) {
1018 /* if the disk bit is set, set the memory bit */ 1015 /* if the disk bit is set, set the memory bit */
1019 bitmap_set_memory_bits(bitmap, i << CHUNK_BLOCK_SHIFT(bitmap), 1016 int needed = ((sector_t)(i+1) << (CHUNK_BLOCK_SHIFT(bitmap))
1020 ((i+1) << (CHUNK_BLOCK_SHIFT(bitmap)) >= start) 1017 >= start);
1021 ); 1018 bitmap_set_memory_bits(bitmap,
1019 (sector_t)i << CHUNK_BLOCK_SHIFT(bitmap),
1020 needed);
1022 bit_cnt++; 1021 bit_cnt++;
1023 set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN); 1022 set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN);
1024 } 1023 }
@@ -1154,8 +1153,9 @@ void bitmap_daemon_work(struct bitmap *bitmap)
1154 spin_lock_irqsave(&bitmap->lock, flags); 1153 spin_lock_irqsave(&bitmap->lock, flags);
1155 clear_page_attr(bitmap, page, BITMAP_PAGE_CLEAN); 1154 clear_page_attr(bitmap, page, BITMAP_PAGE_CLEAN);
1156 } 1155 }
1157 bmc = bitmap_get_counter(bitmap, j << CHUNK_BLOCK_SHIFT(bitmap), 1156 bmc = bitmap_get_counter(bitmap,
1158 &blocks, 0); 1157 (sector_t)j << CHUNK_BLOCK_SHIFT(bitmap),
1158 &blocks, 0);
1159 if (bmc) { 1159 if (bmc) {
1160/* 1160/*
1161 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);
@@ -1169,7 +1169,8 @@ void bitmap_daemon_work(struct bitmap *bitmap)
1169 } else if (*bmc == 1) { 1169 } else if (*bmc == 1) {
1170 /* we can clear the bit */ 1170 /* we can clear the bit */
1171 *bmc = 0; 1171 *bmc = 0;
1172 bitmap_count_page(bitmap, j << CHUNK_BLOCK_SHIFT(bitmap), 1172 bitmap_count_page(bitmap,
1173 (sector_t)j << CHUNK_BLOCK_SHIFT(bitmap),
1173 -1); 1174 -1);
1174 1175
1175 /* clear the bit */ 1176 /* clear the bit */
@@ -1479,6 +1480,7 @@ void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector)
1479 s += blocks; 1480 s += blocks;
1480 } 1481 }
1481 bitmap->last_end_sync = jiffies; 1482 bitmap->last_end_sync = jiffies;
1483 sysfs_notify(&bitmap->mddev->kobj, NULL, "sync_completed");
1482} 1484}
1483 1485
1484static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int needed) 1486static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int needed)
@@ -1513,7 +1515,7 @@ void bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e)
1513 unsigned long chunk; 1515 unsigned long chunk;
1514 1516
1515 for (chunk = s; chunk <= e; chunk++) { 1517 for (chunk = s; chunk <= e; chunk++) {
1516 sector_t sec = chunk << CHUNK_BLOCK_SHIFT(bitmap); 1518 sector_t sec = (sector_t)chunk << CHUNK_BLOCK_SHIFT(bitmap);
1517 bitmap_set_memory_bits(bitmap, sec, 1); 1519 bitmap_set_memory_bits(bitmap, sec, 1);
1518 bitmap_file_set_bit(bitmap, sec); 1520 bitmap_file_set_bit(bitmap, sec);
1519 } 1521 }
@@ -1589,7 +1591,7 @@ void bitmap_destroy(mddev_t *mddev)
1589int bitmap_create(mddev_t *mddev) 1591int bitmap_create(mddev_t *mddev)
1590{ 1592{
1591 struct bitmap *bitmap; 1593 struct bitmap *bitmap;
1592 unsigned long blocks = mddev->resync_max_sectors; 1594 sector_t blocks = mddev->resync_max_sectors;
1593 unsigned long chunks; 1595 unsigned long chunks;
1594 unsigned long pages; 1596 unsigned long pages;
1595 struct file *file = mddev->bitmap_file; 1597 struct file *file = mddev->bitmap_file;
@@ -1631,8 +1633,8 @@ int bitmap_create(mddev_t *mddev)
1631 bitmap->chunkshift = ffz(~bitmap->chunksize); 1633 bitmap->chunkshift = ffz(~bitmap->chunksize);
1632 1634
1633 /* now that chunksize and chunkshift are set, we can use these macros */ 1635 /* now that chunksize and chunkshift are set, we can use these macros */
1634 chunks = (blocks + CHUNK_BLOCK_RATIO(bitmap) - 1) / 1636 chunks = (blocks + CHUNK_BLOCK_RATIO(bitmap) - 1) >>
1635 CHUNK_BLOCK_RATIO(bitmap); 1637 CHUNK_BLOCK_SHIFT(bitmap);
1636 pages = (chunks + PAGE_COUNTER_RATIO - 1) / PAGE_COUNTER_RATIO; 1638 pages = (chunks + PAGE_COUNTER_RATIO - 1) / PAGE_COUNTER_RATIO;
1637 1639
1638 BUG_ON(!pages); 1640 BUG_ON(!pages);