diff options
-rw-r--r-- | drivers/md/bitmap.c | 51 | ||||
-rw-r--r-- | drivers/md/bitmap.h | 6 | ||||
-rw-r--r-- | drivers/md/md.c | 7 | ||||
-rw-r--r-- | drivers/md/md.h | 3 | ||||
-rw-r--r-- | drivers/md/raid1.c | 3 | ||||
-rw-r--r-- | drivers/md/raid10.c | 2 |
6 files changed, 40 insertions, 32 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index c9270f2c9ecd..1a5ada084487 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c | |||
@@ -287,27 +287,28 @@ static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait) | |||
287 | 287 | ||
288 | while ((rdev = next_active_rdev(rdev, mddev)) != NULL) { | 288 | while ((rdev = next_active_rdev(rdev, mddev)) != NULL) { |
289 | int size = PAGE_SIZE; | 289 | int size = PAGE_SIZE; |
290 | long offset = mddev->bitmap_info.offset; | ||
290 | if (page->index == bitmap->file_pages-1) | 291 | if (page->index == bitmap->file_pages-1) |
291 | size = roundup(bitmap->last_page_size, | 292 | size = roundup(bitmap->last_page_size, |
292 | bdev_logical_block_size(rdev->bdev)); | 293 | bdev_logical_block_size(rdev->bdev)); |
293 | /* Just make sure we aren't corrupting data or | 294 | /* Just make sure we aren't corrupting data or |
294 | * metadata | 295 | * metadata |
295 | */ | 296 | */ |
296 | if (bitmap->offset < 0) { | 297 | if (offset < 0) { |
297 | /* DATA BITMAP METADATA */ | 298 | /* DATA BITMAP METADATA */ |
298 | if (bitmap->offset | 299 | if (offset |
299 | + (long)(page->index * (PAGE_SIZE/512)) | 300 | + (long)(page->index * (PAGE_SIZE/512)) |
300 | + size/512 > 0) | 301 | + size/512 > 0) |
301 | /* bitmap runs in to metadata */ | 302 | /* bitmap runs in to metadata */ |
302 | goto bad_alignment; | 303 | goto bad_alignment; |
303 | if (rdev->data_offset + mddev->dev_sectors | 304 | if (rdev->data_offset + mddev->dev_sectors |
304 | > rdev->sb_start + bitmap->offset) | 305 | > rdev->sb_start + offset) |
305 | /* data runs in to bitmap */ | 306 | /* data runs in to bitmap */ |
306 | goto bad_alignment; | 307 | goto bad_alignment; |
307 | } else if (rdev->sb_start < rdev->data_offset) { | 308 | } else if (rdev->sb_start < rdev->data_offset) { |
308 | /* METADATA BITMAP DATA */ | 309 | /* METADATA BITMAP DATA */ |
309 | if (rdev->sb_start | 310 | if (rdev->sb_start |
310 | + bitmap->offset | 311 | + offset |
311 | + page->index*(PAGE_SIZE/512) + size/512 | 312 | + page->index*(PAGE_SIZE/512) + size/512 |
312 | > rdev->data_offset) | 313 | > rdev->data_offset) |
313 | /* bitmap runs in to data */ | 314 | /* bitmap runs in to data */ |
@@ -316,7 +317,7 @@ static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait) | |||
316 | /* DATA METADATA BITMAP - no problems */ | 317 | /* DATA METADATA BITMAP - no problems */ |
317 | } | 318 | } |
318 | md_super_write(mddev, rdev, | 319 | md_super_write(mddev, rdev, |
319 | rdev->sb_start + bitmap->offset | 320 | rdev->sb_start + offset |
320 | + page->index * (PAGE_SIZE/512), | 321 | + page->index * (PAGE_SIZE/512), |
321 | size, | 322 | size, |
322 | page); | 323 | page); |
@@ -550,7 +551,8 @@ static int bitmap_read_sb(struct bitmap *bitmap) | |||
550 | 551 | ||
551 | bitmap->sb_page = read_page(bitmap->file, 0, bitmap, bytes); | 552 | bitmap->sb_page = read_page(bitmap->file, 0, bitmap, bytes); |
552 | } else { | 553 | } else { |
553 | bitmap->sb_page = read_sb_page(bitmap->mddev, bitmap->offset, | 554 | bitmap->sb_page = read_sb_page(bitmap->mddev, |
555 | bitmap->mddev->bitmap_info.offset, | ||
554 | NULL, | 556 | NULL, |
555 | 0, sizeof(bitmap_super_t)); | 557 | 0, sizeof(bitmap_super_t)); |
556 | } | 558 | } |
@@ -610,10 +612,10 @@ static int bitmap_read_sb(struct bitmap *bitmap) | |||
610 | } | 612 | } |
611 | success: | 613 | success: |
612 | /* assign fields using values from superblock */ | 614 | /* assign fields using values from superblock */ |
613 | bitmap->chunksize = chunksize; | 615 | bitmap->mddev->bitmap_info.chunksize = chunksize; |
614 | bitmap->daemon_sleep = daemon_sleep; | 616 | bitmap->mddev->bitmap_info.daemon_sleep = daemon_sleep; |
615 | bitmap->daemon_lastrun = jiffies; | 617 | bitmap->daemon_lastrun = jiffies; |
616 | bitmap->max_write_behind = write_behind; | 618 | bitmap->mddev->bitmap_info.max_write_behind = write_behind; |
617 | bitmap->flags |= le32_to_cpu(sb->state); | 619 | bitmap->flags |= le32_to_cpu(sb->state); |
618 | if (le32_to_cpu(sb->version) == BITMAP_MAJOR_HOSTENDIAN) | 620 | if (le32_to_cpu(sb->version) == BITMAP_MAJOR_HOSTENDIAN) |
619 | bitmap->flags |= BITMAP_HOSTENDIAN; | 621 | bitmap->flags |= BITMAP_HOSTENDIAN; |
@@ -907,7 +909,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) | |||
907 | chunks = bitmap->chunks; | 909 | chunks = bitmap->chunks; |
908 | file = bitmap->file; | 910 | file = bitmap->file; |
909 | 911 | ||
910 | BUG_ON(!file && !bitmap->offset); | 912 | BUG_ON(!file && !bitmap->mddev->bitmap_info.offset); |
911 | 913 | ||
912 | #ifdef INJECT_FAULTS_3 | 914 | #ifdef INJECT_FAULTS_3 |
913 | outofdate = 1; | 915 | outofdate = 1; |
@@ -967,14 +969,15 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) | |||
967 | offset = sizeof(bitmap_super_t); | 969 | offset = sizeof(bitmap_super_t); |
968 | if (!file) | 970 | if (!file) |
969 | read_sb_page(bitmap->mddev, | 971 | read_sb_page(bitmap->mddev, |
970 | bitmap->offset, | 972 | bitmap->mddev->bitmap_info.offset, |
971 | page, | 973 | page, |
972 | index, count); | 974 | index, count); |
973 | } else if (file) { | 975 | } else if (file) { |
974 | page = read_page(file, index, bitmap, count); | 976 | page = read_page(file, index, bitmap, count); |
975 | offset = 0; | 977 | offset = 0; |
976 | } else { | 978 | } else { |
977 | page = read_sb_page(bitmap->mddev, bitmap->offset, | 979 | page = read_sb_page(bitmap->mddev, |
980 | bitmap->mddev->bitmap_info.offset, | ||
978 | NULL, | 981 | NULL, |
979 | index, count); | 982 | index, count); |
980 | offset = 0; | 983 | offset = 0; |
@@ -1096,7 +1099,8 @@ void bitmap_daemon_work(mddev_t *mddev) | |||
1096 | mutex_unlock(&mddev->bitmap_info.mutex); | 1099 | mutex_unlock(&mddev->bitmap_info.mutex); |
1097 | return; | 1100 | return; |
1098 | } | 1101 | } |
1099 | if (time_before(jiffies, bitmap->daemon_lastrun + bitmap->daemon_sleep*HZ)) | 1102 | if (time_before(jiffies, bitmap->daemon_lastrun |
1103 | + bitmap->mddev->bitmap_info.daemon_sleep*HZ)) | ||
1100 | goto done; | 1104 | goto done; |
1101 | 1105 | ||
1102 | bitmap->daemon_lastrun = jiffies; | 1106 | bitmap->daemon_lastrun = jiffies; |
@@ -1210,7 +1214,8 @@ void bitmap_daemon_work(mddev_t *mddev) | |||
1210 | 1214 | ||
1211 | done: | 1215 | done: |
1212 | if (bitmap->allclean == 0) | 1216 | if (bitmap->allclean == 0) |
1213 | bitmap->mddev->thread->timeout = bitmap->daemon_sleep * HZ; | 1217 | bitmap->mddev->thread->timeout = |
1218 | bitmap->mddev->bitmap_info.daemon_sleep * HZ; | ||
1214 | mutex_unlock(&mddev->bitmap_info.mutex); | 1219 | mutex_unlock(&mddev->bitmap_info.mutex); |
1215 | } | 1220 | } |
1216 | 1221 | ||
@@ -1479,7 +1484,7 @@ void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector) | |||
1479 | return; | 1484 | return; |
1480 | } | 1485 | } |
1481 | if (time_before(jiffies, (bitmap->last_end_sync | 1486 | if (time_before(jiffies, (bitmap->last_end_sync |
1482 | + bitmap->daemon_sleep * HZ))) | 1487 | + bitmap->mddev->bitmap_info.daemon_sleep * HZ))) |
1483 | return; | 1488 | return; |
1484 | wait_event(bitmap->mddev->recovery_wait, | 1489 | wait_event(bitmap->mddev->recovery_wait, |
1485 | atomic_read(&bitmap->mddev->recovery_active) == 0); | 1490 | atomic_read(&bitmap->mddev->recovery_active) == 0); |
@@ -1540,7 +1545,7 @@ void bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e) | |||
1540 | void bitmap_flush(mddev_t *mddev) | 1545 | void bitmap_flush(mddev_t *mddev) |
1541 | { | 1546 | { |
1542 | struct bitmap *bitmap = mddev->bitmap; | 1547 | struct bitmap *bitmap = mddev->bitmap; |
1543 | int sleep; | 1548 | long sleep; |
1544 | 1549 | ||
1545 | if (!bitmap) /* there was no bitmap */ | 1550 | if (!bitmap) /* there was no bitmap */ |
1546 | return; | 1551 | return; |
@@ -1548,12 +1553,13 @@ void bitmap_flush(mddev_t *mddev) | |||
1548 | /* run the daemon_work three time to ensure everything is flushed | 1553 | /* run the daemon_work three time to ensure everything is flushed |
1549 | * that can be | 1554 | * that can be |
1550 | */ | 1555 | */ |
1551 | sleep = bitmap->daemon_sleep; | 1556 | sleep = mddev->bitmap_info.daemon_sleep * HZ * 2; |
1552 | bitmap->daemon_sleep = 0; | 1557 | bitmap->daemon_lastrun -= sleep; |
1553 | bitmap_daemon_work(mddev); | 1558 | bitmap_daemon_work(mddev); |
1559 | bitmap->daemon_lastrun -= sleep; | ||
1554 | bitmap_daemon_work(mddev); | 1560 | bitmap_daemon_work(mddev); |
1561 | bitmap->daemon_lastrun -= sleep; | ||
1555 | bitmap_daemon_work(mddev); | 1562 | bitmap_daemon_work(mddev); |
1556 | bitmap->daemon_sleep = sleep; | ||
1557 | bitmap_update_sb(bitmap); | 1563 | bitmap_update_sb(bitmap); |
1558 | } | 1564 | } |
1559 | 1565 | ||
@@ -1633,7 +1639,6 @@ int bitmap_create(mddev_t *mddev) | |||
1633 | bitmap->mddev = mddev; | 1639 | bitmap->mddev = mddev; |
1634 | 1640 | ||
1635 | bitmap->file = file; | 1641 | bitmap->file = file; |
1636 | bitmap->offset = mddev->bitmap_info.offset; | ||
1637 | if (file) { | 1642 | if (file) { |
1638 | get_file(file); | 1643 | get_file(file); |
1639 | /* As future accesses to this file will use bmap, | 1644 | /* As future accesses to this file will use bmap, |
@@ -1642,12 +1647,12 @@ int bitmap_create(mddev_t *mddev) | |||
1642 | */ | 1647 | */ |
1643 | vfs_fsync(file, file->f_dentry, 1); | 1648 | vfs_fsync(file, file->f_dentry, 1); |
1644 | } | 1649 | } |
1645 | /* read superblock from bitmap file (this sets bitmap->chunksize) */ | 1650 | /* read superblock from bitmap file (this sets mddev->bitmap_info.chunksize) */ |
1646 | err = bitmap_read_sb(bitmap); | 1651 | err = bitmap_read_sb(bitmap); |
1647 | if (err) | 1652 | if (err) |
1648 | goto error; | 1653 | goto error; |
1649 | 1654 | ||
1650 | bitmap->chunkshift = ffz(~bitmap->chunksize); | 1655 | bitmap->chunkshift = ffz(~mddev->bitmap_info.chunksize); |
1651 | 1656 | ||
1652 | /* now that chunksize and chunkshift are set, we can use these macros */ | 1657 | /* now that chunksize and chunkshift are set, we can use these macros */ |
1653 | chunks = (blocks + CHUNK_BLOCK_RATIO(bitmap) - 1) >> | 1658 | chunks = (blocks + CHUNK_BLOCK_RATIO(bitmap) - 1) >> |
@@ -1689,7 +1694,7 @@ int bitmap_create(mddev_t *mddev) | |||
1689 | 1694 | ||
1690 | mddev->bitmap = bitmap; | 1695 | mddev->bitmap = bitmap; |
1691 | 1696 | ||
1692 | mddev->thread->timeout = bitmap->daemon_sleep * HZ; | 1697 | mddev->thread->timeout = mddev->bitmap_info.daemon_sleep * HZ; |
1693 | 1698 | ||
1694 | bitmap_update_sb(bitmap); | 1699 | bitmap_update_sb(bitmap); |
1695 | 1700 | ||
diff --git a/drivers/md/bitmap.h b/drivers/md/bitmap.h index 7e38d13ddcac..50ee4240f5db 100644 --- a/drivers/md/bitmap.h +++ b/drivers/md/bitmap.h | |||
@@ -106,7 +106,7 @@ typedef __u16 bitmap_counter_t; | |||
106 | #define BITMAP_BLOCK_SHIFT 9 | 106 | #define BITMAP_BLOCK_SHIFT 9 |
107 | 107 | ||
108 | /* how many blocks per chunk? (this is variable) */ | 108 | /* how many blocks per chunk? (this is variable) */ |
109 | #define CHUNK_BLOCK_RATIO(bitmap) ((bitmap)->chunksize >> BITMAP_BLOCK_SHIFT) | 109 | #define CHUNK_BLOCK_RATIO(bitmap) ((bitmap)->mddev->bitmap_info.chunksize >> BITMAP_BLOCK_SHIFT) |
110 | #define CHUNK_BLOCK_SHIFT(bitmap) ((bitmap)->chunkshift - BITMAP_BLOCK_SHIFT) | 110 | #define CHUNK_BLOCK_SHIFT(bitmap) ((bitmap)->chunkshift - BITMAP_BLOCK_SHIFT) |
111 | #define CHUNK_BLOCK_MASK(bitmap) (CHUNK_BLOCK_RATIO(bitmap) - 1) | 111 | #define CHUNK_BLOCK_MASK(bitmap) (CHUNK_BLOCK_RATIO(bitmap) - 1) |
112 | 112 | ||
@@ -209,7 +209,6 @@ struct bitmap { | |||
209 | int counter_bits; /* how many bits per block counter */ | 209 | int counter_bits; /* how many bits per block counter */ |
210 | 210 | ||
211 | /* bitmap chunksize -- how much data does each bit represent? */ | 211 | /* bitmap chunksize -- how much data does each bit represent? */ |
212 | unsigned long chunksize; | ||
213 | unsigned long chunkshift; /* chunksize = 2^chunkshift (for bitops) */ | 212 | unsigned long chunkshift; /* chunksize = 2^chunkshift (for bitops) */ |
214 | unsigned long chunks; /* total number of data chunks for the array */ | 213 | unsigned long chunks; /* total number of data chunks for the array */ |
215 | 214 | ||
@@ -226,7 +225,6 @@ struct bitmap { | |||
226 | /* bitmap spinlock */ | 225 | /* bitmap spinlock */ |
227 | spinlock_t lock; | 226 | spinlock_t lock; |
228 | 227 | ||
229 | long offset; /* offset from superblock if file is NULL */ | ||
230 | struct file *file; /* backing disk file */ | 228 | struct file *file; /* backing disk file */ |
231 | struct page *sb_page; /* cached copy of the bitmap file superblock */ | 229 | struct page *sb_page; /* cached copy of the bitmap file superblock */ |
232 | struct page **filemap; /* list of cache pages for the file */ | 230 | struct page **filemap; /* list of cache pages for the file */ |
@@ -238,7 +236,6 @@ struct bitmap { | |||
238 | 236 | ||
239 | int allclean; | 237 | int allclean; |
240 | 238 | ||
241 | unsigned long max_write_behind; /* write-behind mode */ | ||
242 | atomic_t behind_writes; | 239 | atomic_t behind_writes; |
243 | 240 | ||
244 | /* | 241 | /* |
@@ -246,7 +243,6 @@ struct bitmap { | |||
246 | * file, cleaning up bits and flushing out pages to disk as necessary | 243 | * file, cleaning up bits and flushing out pages to disk as necessary |
247 | */ | 244 | */ |
248 | unsigned long daemon_lastrun; /* jiffies of last run */ | 245 | unsigned long daemon_lastrun; /* jiffies of last run */ |
249 | unsigned long daemon_sleep; /* how many seconds between updates? */ | ||
250 | unsigned long last_end_sync; /* when we lasted called end_sync to | 246 | unsigned long last_end_sync; /* when we lasted called end_sync to |
251 | * update bitmap with resync progress */ | 247 | * update bitmap with resync progress */ |
252 | 248 | ||
diff --git a/drivers/md/md.c b/drivers/md/md.c index 63da0a51852d..c56c64d13075 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -4557,6 +4557,9 @@ out: | |||
4557 | mddev->safemode = 0; | 4557 | mddev->safemode = 0; |
4558 | mddev->bitmap_info.offset = 0; | 4558 | mddev->bitmap_info.offset = 0; |
4559 | mddev->bitmap_info.default_offset = 0; | 4559 | mddev->bitmap_info.default_offset = 0; |
4560 | mddev->bitmap_info.chunksize = 0; | ||
4561 | mddev->bitmap_info.daemon_sleep = 0; | ||
4562 | mddev->bitmap_info.max_write_behind = 0; | ||
4560 | kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE); | 4563 | kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE); |
4561 | if (mddev->hold_active == UNTIL_STOP) | 4564 | if (mddev->hold_active == UNTIL_STOP) |
4562 | mddev->hold_active = 0; | 4565 | mddev->hold_active = 0; |
@@ -6089,14 +6092,14 @@ static int md_seq_show(struct seq_file *seq, void *v) | |||
6089 | unsigned long chunk_kb; | 6092 | unsigned long chunk_kb; |
6090 | unsigned long flags; | 6093 | unsigned long flags; |
6091 | spin_lock_irqsave(&bitmap->lock, flags); | 6094 | spin_lock_irqsave(&bitmap->lock, flags); |
6092 | chunk_kb = bitmap->chunksize >> 10; | 6095 | chunk_kb = mddev->bitmap_info.chunksize >> 10; |
6093 | seq_printf(seq, "bitmap: %lu/%lu pages [%luKB], " | 6096 | seq_printf(seq, "bitmap: %lu/%lu pages [%luKB], " |
6094 | "%lu%s chunk", | 6097 | "%lu%s chunk", |
6095 | bitmap->pages - bitmap->missing_pages, | 6098 | bitmap->pages - bitmap->missing_pages, |
6096 | bitmap->pages, | 6099 | bitmap->pages, |
6097 | (bitmap->pages - bitmap->missing_pages) | 6100 | (bitmap->pages - bitmap->missing_pages) |
6098 | << (PAGE_SHIFT - 10), | 6101 | << (PAGE_SHIFT - 10), |
6099 | chunk_kb ? chunk_kb : bitmap->chunksize, | 6102 | chunk_kb ? chunk_kb : mddev->bitmap_info.chunksize, |
6100 | chunk_kb ? "KB" : "B"); | 6103 | chunk_kb ? "KB" : "B"); |
6101 | if (bitmap->file) { | 6104 | if (bitmap->file) { |
6102 | seq_printf(seq, ", file: "); | 6105 | seq_printf(seq, ", file: "); |
diff --git a/drivers/md/md.h b/drivers/md/md.h index 50e62ef32e9d..4b07e0ab3841 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h | |||
@@ -291,6 +291,9 @@ struct mddev_s | |||
291 | * eventually be settable by sysfs. | 291 | * eventually be settable by sysfs. |
292 | */ | 292 | */ |
293 | struct mutex mutex; | 293 | struct mutex mutex; |
294 | unsigned long chunksize; | ||
295 | unsigned long daemon_sleep; /* how many seconds between updates? */ | ||
296 | unsigned long max_write_behind; /* write-behind mode */ | ||
294 | } bitmap_info; | 297 | } bitmap_info; |
295 | 298 | ||
296 | struct list_head all_mddevs; | 299 | struct list_head all_mddevs; |
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 7549b0bad326..f0949e2bcd6e 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -943,7 +943,8 @@ static int make_request(struct request_queue *q, struct bio * bio) | |||
943 | 943 | ||
944 | /* do behind I/O ? */ | 944 | /* do behind I/O ? */ |
945 | if (bitmap && | 945 | if (bitmap && |
946 | atomic_read(&bitmap->behind_writes) < bitmap->max_write_behind && | 946 | (atomic_read(&bitmap->behind_writes) |
947 | < mddev->bitmap_info.max_write_behind) && | ||
947 | (behind_pages = alloc_behind_pages(bio)) != NULL) | 948 | (behind_pages = alloc_behind_pages(bio)) != NULL) |
948 | set_bit(R1BIO_BehindIO, &r1_bio->state); | 949 | set_bit(R1BIO_BehindIO, &r1_bio->state); |
949 | 950 | ||
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 2fbf867f8b30..2255e33a3ecb 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c | |||
@@ -2277,7 +2277,7 @@ static void raid10_quiesce(mddev_t *mddev, int state) | |||
2277 | } | 2277 | } |
2278 | if (mddev->thread) { | 2278 | if (mddev->thread) { |
2279 | if (mddev->bitmap) | 2279 | if (mddev->bitmap) |
2280 | mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ; | 2280 | mddev->thread->timeout = mddev->bitmap_info.daemon_sleep * HZ; |
2281 | else | 2281 | else |
2282 | mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT; | 2282 | mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT; |
2283 | md_wakeup_thread(mddev->thread); | 2283 | md_wakeup_thread(mddev->thread); |