diff options
author | NeilBrown <neilb@suse.de> | 2009-12-13 20:49:53 -0500 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2009-12-13 20:51:41 -0500 |
commit | 42a04b5078ce73a32f85762551d5703c5bd646a1 (patch) | |
tree | 3ef384933cd33d000516c292712da9a99e273360 /drivers/md/bitmap.c | |
parent | c3d9714e88c8685cf9bc837c3241fc005f95fb82 (diff) |
md: move offset, daemon_sleep and chunksize out of bitmap structure
... and into bitmap_info. These are all configuration parameters
that need to be set before the bitmap is created.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/bitmap.c')
-rw-r--r-- | drivers/md/bitmap.c | 51 |
1 files changed, 28 insertions, 23 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 | ||