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

Commit 0764147b authored by Milan Broz's avatar Milan Broz Committed by Linus Torvalds
Browse files

dm snapshot: permit invalid activation



Allow invalid snapshots to be activated instead of failing.

This allows userspace to reinstate any given snapshot state - for
example after an unscheduled reboot - and clean up the invalid snapshot
at its leisure.

Cc: stable@kernel.org
Signed-off-by: default avatarMilan Broz <mbroz@redhat.com>
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent fcac03ab
Loading
Loading
Loading
Loading
+6 −5
Original line number Original line Diff line number Diff line
@@ -489,17 +489,18 @@ static int persistent_read_metadata(struct exception_store *store)
		/*
		/*
		 * Sanity checks.
		 * Sanity checks.
		 */
		 */
		if (!ps->valid) {
			DMWARN("snapshot is marked invalid");
			return -EINVAL;
		}

		if (ps->version != SNAPSHOT_DISK_VERSION) {
		if (ps->version != SNAPSHOT_DISK_VERSION) {
			DMWARN("unable to handle snapshot disk version %d",
			DMWARN("unable to handle snapshot disk version %d",
			       ps->version);
			       ps->version);
			return -EINVAL;
			return -EINVAL;
		}
		}


		/*
		 * Metadata are valid, but snapshot is invalidated
		 */
		if (!ps->valid)
			return 1;

		/*
		/*
		 * Read the metadata.
		 * Read the metadata.
		 */
		 */
+4 −1
Original line number Original line Diff line number Diff line
@@ -523,9 +523,12 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)


	/* Metadata must only be loaded into one table at once */
	/* Metadata must only be loaded into one table at once */
	r = s->store.read_metadata(&s->store);
	r = s->store.read_metadata(&s->store);
	if (r) {
	if (r < 0) {
		ti->error = "Failed to read snapshot metadata";
		ti->error = "Failed to read snapshot metadata";
		goto bad6;
		goto bad6;
	} else if (r > 0) {
		s->valid = 0;
		DMWARN("Snapshot is marked invalid.");
	}
	}


	bio_list_init(&s->queued_bios);
	bio_list_init(&s->queued_bios);