Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=0764147b111b8ca886e4f2e9c9e019106b09b657
Commit:     0764147b111b8ca886e4f2e9c9e019106b09b657
Parent:     fcac03abd325e4f7a4cc8fe05fea2793b1c8eb75
Author:     Milan Broz <[EMAIL PROTECTED]>
AuthorDate: Thu Jul 12 17:28:13 2007 +0100
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Thu Jul 12 15:01:08 2007 -0700

    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: [EMAIL PROTECTED]
    Signed-off-by: Milan Broz <[EMAIL PROTECTED]>
    Signed-off-by: Alasdair G Kergon <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 drivers/md/dm-exception-store.c |   11 ++++++-----
 drivers/md/dm-snap.c            |    5 ++++-
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/md/dm-exception-store.c b/drivers/md/dm-exception-store.c
index 8c25c2f..3d65917 100644
--- a/drivers/md/dm-exception-store.c
+++ b/drivers/md/dm-exception-store.c
@@ -489,11 +489,6 @@ 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);
@@ -501,6 +496,12 @@ static int persistent_read_metadata(struct exception_store 
*store)
                }
 
                /*
+                * Metadata are valid, but snapshot is invalidated
+                */
+               if (!ps->valid)
+                       return 1;
+
+               /*
                 * Read the metadata.
                 */
                r = read_exceptions(ps);
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 1da4122..854891d 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -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 */
        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);
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to