diff options
author | Goldwyn Rodrigues <rgoldwyn@suse.de> | 2015-06-30 22:19:56 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.com> | 2015-07-23 23:37:55 -0400 |
commit | 33e38ac6887d975fe2635c7fcaefb6d5495cb2e1 (patch) | |
tree | 453697d25fb88f8d55d720cddf3a3df0a1c696f5 /drivers/md/bitmap.c | |
parent | b0c26a79d6993b280931f8e2b406ca4b220bb58f (diff) |
md-cluster: fix bitmap sub-offset in bitmap_read_sb
bitmap_read_sb is modifying mddev->bitmap_info.offset. This works for
the first bitmap read. However, when multiple bitmaps need to be opened
by the same node, it ends up corrupting the offset. Fix it by using a
local variable.
Also, bitmap_read_sb is not required in bitmap_copy_from_slot since
it is called in bitmap_create. Remove bitmap_read_sb().
Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Signed-off-by: NeilBrown <neilb@suse.com>
Diffstat (limited to 'drivers/md/bitmap.c')
-rw-r--r-- | drivers/md/bitmap.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index a4ab51350f40..1b9c2df718c6 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c | |||
@@ -559,6 +559,7 @@ static int bitmap_read_sb(struct bitmap *bitmap) | |||
559 | unsigned long sectors_reserved = 0; | 559 | unsigned long sectors_reserved = 0; |
560 | int err = -EINVAL; | 560 | int err = -EINVAL; |
561 | struct page *sb_page; | 561 | struct page *sb_page; |
562 | loff_t offset = bitmap->mddev->bitmap_info.offset; | ||
562 | 563 | ||
563 | if (!bitmap->storage.file && !bitmap->mddev->bitmap_info.offset) { | 564 | if (!bitmap->storage.file && !bitmap->mddev->bitmap_info.offset) { |
564 | chunksize = 128 * 1024 * 1024; | 565 | chunksize = 128 * 1024 * 1024; |
@@ -585,9 +586,9 @@ re_read: | |||
585 | bm_blocks = ((bm_blocks+7) >> 3) + sizeof(bitmap_super_t); | 586 | bm_blocks = ((bm_blocks+7) >> 3) + sizeof(bitmap_super_t); |
586 | /* to 4k blocks */ | 587 | /* to 4k blocks */ |
587 | bm_blocks = DIV_ROUND_UP_SECTOR_T(bm_blocks, 4096); | 588 | bm_blocks = DIV_ROUND_UP_SECTOR_T(bm_blocks, 4096); |
588 | bitmap->mddev->bitmap_info.offset += bitmap->cluster_slot * (bm_blocks << 3); | 589 | offset = bitmap->mddev->bitmap_info.offset + (bitmap->cluster_slot * (bm_blocks << 3)); |
589 | 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__, |
590 | bitmap->cluster_slot, (unsigned long long)bitmap->mddev->bitmap_info.offset); | 591 | bitmap->cluster_slot, offset); |
591 | } | 592 | } |
592 | 593 | ||
593 | if (bitmap->storage.file) { | 594 | if (bitmap->storage.file) { |
@@ -598,7 +599,7 @@ re_read: | |||
598 | bitmap, bytes, sb_page); | 599 | bitmap, bytes, sb_page); |
599 | } else { | 600 | } else { |
600 | err = read_sb_page(bitmap->mddev, | 601 | err = read_sb_page(bitmap->mddev, |
601 | bitmap->mddev->bitmap_info.offset, | 602 | offset, |
602 | sb_page, | 603 | sb_page, |
603 | 0, sizeof(bitmap_super_t)); | 604 | 0, sizeof(bitmap_super_t)); |
604 | } | 605 | } |
@@ -1875,10 +1876,6 @@ int bitmap_copy_from_slot(struct mddev *mddev, int slot, | |||
1875 | if (IS_ERR(bitmap)) | 1876 | if (IS_ERR(bitmap)) |
1876 | return PTR_ERR(bitmap); | 1877 | return PTR_ERR(bitmap); |
1877 | 1878 | ||
1878 | rv = bitmap_read_sb(bitmap); | ||
1879 | if (rv) | ||
1880 | goto err; | ||
1881 | |||
1882 | rv = bitmap_init_from_disk(bitmap, 0); | 1879 | rv = bitmap_init_from_disk(bitmap, 0); |
1883 | if (rv) | 1880 | if (rv) |
1884 | goto err; | 1881 | goto err; |