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

Commit a6793684 authored by NeilBrown's avatar NeilBrown Committed by Greg Kroah-Hartman
Browse files

md: forbid a RAID5 from having both a bitmap and a journal.



commit 230b55fa upstream.

Having both a bitmap and a journal is pointless.
Attempting to do so can corrupt the bitmap if the journal
replay happens before the bitmap is initialized.
Rather than try to avoid this corruption, simply
refuse to allow arrays with both a bitmap and a journal.
So:
 - if raid5_run sees both are present, fail.
 - if adding a bitmap finds a journal is present, fail
 - if adding a journal finds a bitmap is present, fail.

Signed-off-by: default avatarNeilBrown <neilb@suse.com>
Tested-by: default avatarJoshua Kinard <kumba@gentoo.org>
Acked-by: default avatarJoshua Kinard <kumba@gentoo.org>
Signed-off-by: default avatarShaohua Li <shli@fb.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 635526b8
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1816,6 +1816,12 @@ struct bitmap *bitmap_create(struct mddev *mddev, int slot)

	BUG_ON(file && mddev->bitmap_info.offset);

	if (test_bit(MD_HAS_JOURNAL, &mddev->flags)) {
		pr_notice("md/raid:%s: array with journal cannot have bitmap\n",
			  mdname(mddev));
		return ERR_PTR(-EBUSY);
	}

	bitmap = kzalloc(sizeof(*bitmap), GFP_KERNEL);
	if (!bitmap)
		return ERR_PTR(-ENOMEM);
+1 −1
Original line number Diff line number Diff line
@@ -6362,7 +6362,7 @@ static int add_new_disk(struct mddev *mddev, mdu_disk_info_t *info)
					break;
				}
			}
			if (has_journal) {
			if (has_journal || mddev->bitmap) {
				export_rdev(rdev);
				return -EBUSY;
			}
+7 −0
Original line number Diff line number Diff line
@@ -7156,6 +7156,13 @@ static int raid5_run(struct mddev *mddev)
			min_offset_diff = diff;
	}

	if ((test_bit(MD_HAS_JOURNAL, &mddev->flags) || journal_dev) &&
	    (mddev->bitmap_info.offset || mddev->bitmap_info.file)) {
		pr_notice("md/raid:%s: array cannot have both journal and bitmap\n",
			  mdname(mddev));
		return -EINVAL;
	}

	if (mddev->reshape_position != MaxSector) {
		/* Check that we can continue the reshape.
		 * Difficulties arise if the stripe we would write to