]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
dm snapshot: permit invalid activation
authorMilan Broz <mbroz@redhat.com>
Thu, 12 Jul 2007 16:28:13 +0000 (17:28 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 9 Aug 2007 21:27:44 +0000 (14:27 -0700)
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.

Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/md/dm-exception-store.c
drivers/md/dm-snap.c

index 07e0a0c84f6ef9f8d93da5b914f22dfc0f9c47fc..4264f69b05328f00a4fb2f5221230dbc6f44b470 100644 (file)
@@ -457,17 +457,18 @@ static int persistent_read_metadata(struct exception_store *store)
                /*
                 * Sanity checks.
                 */
-               if (!ps->valid) {
-                       DMWARN("snapshot is marked invalid");
-                       return -EINVAL;
-               }
-
                if (ps->version != SNAPSHOT_DISK_VERSION) {
                        DMWARN("unable to handle snapshot disk version %d",
                               ps->version);
                        return -EINVAL;
                }
 
+               /*
+                * Metadata are valid, but snapshot is invalidated
+                */
+               if (!ps->valid)
+                       return 1;
+
                /*
                 * Read the metadata.
                 */
index 0821a2b68a73a98719cb931c82196a74bfe471d4..9227ba4f19db16ad8d36eb0da3096d9144480f0e 100644 (file)
@@ -522,9 +522,12 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 
        /* Metadata must only be loaded into one table at once */
        r = s->store.read_metadata(&s->store);
-       if (r) {
+       if (r < 0) {
                ti->error = "Failed to read snapshot metadata";
                goto bad6;
+       } else if (r > 0) {
+               s->valid = 0;
+               DMWARN("Snapshot is marked invalid.");
        }
 
        bio_list_init(&s->queued_bios);