diff options
Diffstat (limited to 'drivers/md/bitmap.c')
-rw-r--r-- | drivers/md/bitmap.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index ed2346ddf4c9..e51de52eeb94 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c | |||
@@ -494,7 +494,7 @@ static int bitmap_new_disk_sb(struct bitmap *bitmap) | |||
494 | bitmap_super_t *sb; | 494 | bitmap_super_t *sb; |
495 | unsigned long chunksize, daemon_sleep, write_behind; | 495 | unsigned long chunksize, daemon_sleep, write_behind; |
496 | 496 | ||
497 | bitmap->storage.sb_page = alloc_page(GFP_KERNEL); | 497 | bitmap->storage.sb_page = alloc_page(GFP_KERNEL | __GFP_ZERO); |
498 | if (bitmap->storage.sb_page == NULL) | 498 | if (bitmap->storage.sb_page == NULL) |
499 | return -ENOMEM; | 499 | return -ENOMEM; |
500 | bitmap->storage.sb_page->index = 0; | 500 | bitmap->storage.sb_page->index = 0; |
@@ -541,6 +541,7 @@ static int bitmap_new_disk_sb(struct bitmap *bitmap) | |||
541 | sb->state = cpu_to_le32(bitmap->flags); | 541 | sb->state = cpu_to_le32(bitmap->flags); |
542 | bitmap->events_cleared = bitmap->mddev->events; | 542 | bitmap->events_cleared = bitmap->mddev->events; |
543 | sb->events_cleared = cpu_to_le64(bitmap->mddev->events); | 543 | sb->events_cleared = cpu_to_le64(bitmap->mddev->events); |
544 | bitmap->mddev->bitmap_info.nodes = 0; | ||
544 | 545 | ||
545 | kunmap_atomic(sb); | 546 | kunmap_atomic(sb); |
546 | 547 | ||
@@ -558,6 +559,7 @@ static int bitmap_read_sb(struct bitmap *bitmap) | |||
558 | unsigned long sectors_reserved = 0; | 559 | unsigned long sectors_reserved = 0; |
559 | int err = -EINVAL; | 560 | int err = -EINVAL; |
560 | struct page *sb_page; | 561 | struct page *sb_page; |
562 | loff_t offset = bitmap->mddev->bitmap_info.offset; | ||
561 | 563 | ||
562 | if (!bitmap->storage.file && !bitmap->mddev->bitmap_info.offset) { | 564 | if (!bitmap->storage.file && !bitmap->mddev->bitmap_info.offset) { |
563 | chunksize = 128 * 1024 * 1024; | 565 | chunksize = 128 * 1024 * 1024; |
@@ -584,9 +586,9 @@ re_read: | |||
584 | bm_blocks = ((bm_blocks+7) >> 3) + sizeof(bitmap_super_t); | 586 | bm_blocks = ((bm_blocks+7) >> 3) + sizeof(bitmap_super_t); |
585 | /* to 4k blocks */ | 587 | /* to 4k blocks */ |
586 | bm_blocks = DIV_ROUND_UP_SECTOR_T(bm_blocks, 4096); | 588 | bm_blocks = DIV_ROUND_UP_SECTOR_T(bm_blocks, 4096); |
587 | bitmap->mddev->bitmap_info.offset += bitmap->cluster_slot * (bm_blocks << 3); | 589 | offset = bitmap->mddev->bitmap_info.offset + (bitmap->cluster_slot * (bm_blocks << 3)); |
588 | pr_info("%s:%d bm slot: %d offset: %llu\n", __func__, __LINE__, | 590 | pr_info("%s:%d bm slot: %d offset: %llu\n", __func__, __LINE__, |
589 | bitmap->cluster_slot, (unsigned long long)bitmap->mddev->bitmap_info.offset); | 591 | bitmap->cluster_slot, offset); |
590 | } | 592 | } |
591 | 593 | ||
592 | if (bitmap->storage.file) { | 594 | if (bitmap->storage.file) { |
@@ -597,7 +599,7 @@ re_read: | |||
597 | bitmap, bytes, sb_page); | 599 | bitmap, bytes, sb_page); |
598 | } else { | 600 | } else { |
599 | err = read_sb_page(bitmap->mddev, | 601 | err = read_sb_page(bitmap->mddev, |
600 | bitmap->mddev->bitmap_info.offset, | 602 | offset, |
601 | sb_page, | 603 | sb_page, |
602 | 0, sizeof(bitmap_super_t)); | 604 | 0, sizeof(bitmap_super_t)); |
603 | } | 605 | } |
@@ -611,8 +613,16 @@ re_read: | |||
611 | daemon_sleep = le32_to_cpu(sb->daemon_sleep) * HZ; | 613 | daemon_sleep = le32_to_cpu(sb->daemon_sleep) * HZ; |
612 | write_behind = le32_to_cpu(sb->write_behind); | 614 | write_behind = le32_to_cpu(sb->write_behind); |
613 | sectors_reserved = le32_to_cpu(sb->sectors_reserved); | 615 | sectors_reserved = le32_to_cpu(sb->sectors_reserved); |
614 | nodes = le32_to_cpu(sb->nodes); | 616 | /* XXX: This is a hack to ensure that we don't use clustering |
615 | strlcpy(bitmap->mddev->bitmap_info.cluster_name, sb->cluster_name, 64); | 617 | * in case: |
618 | * - dm-raid is in use and | ||
619 | * - the nodes written in bitmap_sb is erroneous. | ||
620 | */ | ||
621 | if (!bitmap->mddev->sync_super) { | ||
622 | nodes = le32_to_cpu(sb->nodes); | ||
623 | strlcpy(bitmap->mddev->bitmap_info.cluster_name, | ||
624 | sb->cluster_name, 64); | ||
625 | } | ||
616 | 626 | ||
617 | /* verify that the bitmap-specific fields are valid */ | 627 | /* verify that the bitmap-specific fields are valid */ |
618 | if (sb->magic != cpu_to_le32(BITMAP_MAGIC)) | 628 | if (sb->magic != cpu_to_le32(BITMAP_MAGIC)) |
@@ -671,7 +681,7 @@ out: | |||
671 | kunmap_atomic(sb); | 681 | kunmap_atomic(sb); |
672 | /* Assiging chunksize is required for "re_read" */ | 682 | /* Assiging chunksize is required for "re_read" */ |
673 | bitmap->mddev->bitmap_info.chunksize = chunksize; | 683 | bitmap->mddev->bitmap_info.chunksize = chunksize; |
674 | if (nodes && (bitmap->cluster_slot < 0)) { | 684 | if (err == 0 && nodes && (bitmap->cluster_slot < 0)) { |
675 | err = md_setup_cluster(bitmap->mddev, nodes); | 685 | err = md_setup_cluster(bitmap->mddev, nodes); |
676 | if (err) { | 686 | if (err) { |
677 | pr_err("%s: Could not setup cluster service (%d)\n", | 687 | pr_err("%s: Could not setup cluster service (%d)\n", |
@@ -1866,10 +1876,6 @@ int bitmap_copy_from_slot(struct mddev *mddev, int slot, | |||
1866 | if (IS_ERR(bitmap)) | 1876 | if (IS_ERR(bitmap)) |
1867 | return PTR_ERR(bitmap); | 1877 | return PTR_ERR(bitmap); |
1868 | 1878 | ||
1869 | rv = bitmap_read_sb(bitmap); | ||
1870 | if (rv) | ||
1871 | goto err; | ||
1872 | |||
1873 | rv = bitmap_init_from_disk(bitmap, 0); | 1879 | rv = bitmap_init_from_disk(bitmap, 0); |
1874 | if (rv) | 1880 | if (rv) |
1875 | goto err; | 1881 | goto err; |