Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 33e38ac6 authored by Goldwyn Rodrigues's avatar Goldwyn Rodrigues Committed by NeilBrown
Browse files

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: default avatarGoldwyn Rodrigues <rgoldwyn@suse.com>
Signed-off-by: default avatarNeilBrown <neilb@suse.com>
parent b0c26a79
Loading
Loading
Loading
Loading
+4 −7
Original line number Original line Diff line number Diff line
@@ -559,6 +559,7 @@ static int bitmap_read_sb(struct bitmap *bitmap)
	unsigned long sectors_reserved = 0;
	unsigned long sectors_reserved = 0;
	int err = -EINVAL;
	int err = -EINVAL;
	struct page *sb_page;
	struct page *sb_page;
	loff_t offset = bitmap->mddev->bitmap_info.offset;


	if (!bitmap->storage.file && !bitmap->mddev->bitmap_info.offset) {
	if (!bitmap->storage.file && !bitmap->mddev->bitmap_info.offset) {
		chunksize = 128 * 1024 * 1024;
		chunksize = 128 * 1024 * 1024;
@@ -585,9 +586,9 @@ static int bitmap_read_sb(struct bitmap *bitmap)
		bm_blocks = ((bm_blocks+7) >> 3) + sizeof(bitmap_super_t);
		bm_blocks = ((bm_blocks+7) >> 3) + sizeof(bitmap_super_t);
		/* to 4k blocks */
		/* to 4k blocks */
		bm_blocks = DIV_ROUND_UP_SECTOR_T(bm_blocks, 4096);
		bm_blocks = DIV_ROUND_UP_SECTOR_T(bm_blocks, 4096);
		bitmap->mddev->bitmap_info.offset += bitmap->cluster_slot * (bm_blocks << 3);
		offset = bitmap->mddev->bitmap_info.offset + (bitmap->cluster_slot * (bm_blocks << 3));
		pr_info("%s:%d bm slot: %d offset: %llu\n", __func__, __LINE__,
		pr_info("%s:%d bm slot: %d offset: %llu\n", __func__, __LINE__,
			bitmap->cluster_slot, (unsigned long long)bitmap->mddev->bitmap_info.offset);
			bitmap->cluster_slot, offset);
	}
	}


	if (bitmap->storage.file) {
	if (bitmap->storage.file) {
@@ -598,7 +599,7 @@ static int bitmap_read_sb(struct bitmap *bitmap)
				bitmap, bytes, sb_page);
				bitmap, bytes, sb_page);
	} else {
	} else {
		err = read_sb_page(bitmap->mddev,
		err = read_sb_page(bitmap->mddev,
				   bitmap->mddev->bitmap_info.offset,
				   offset,
				   sb_page,
				   sb_page,
				   0, sizeof(bitmap_super_t));
				   0, sizeof(bitmap_super_t));
	}
	}
@@ -1875,10 +1876,6 @@ int bitmap_copy_from_slot(struct mddev *mddev, int slot,
	if (IS_ERR(bitmap))
	if (IS_ERR(bitmap))
		return PTR_ERR(bitmap);
		return PTR_ERR(bitmap);


	rv = bitmap_read_sb(bitmap);
	if (rv)
		goto err;

	rv = bitmap_init_from_disk(bitmap, 0);
	rv = bitmap_init_from_disk(bitmap, 0);
	if (rv)
	if (rv)
		goto err;
		goto err;