]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/md/dm-snap.c
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4
[linux-2.6-omap-h63xx.git] / drivers / md / dm-snap.c
index 4ceedd4f22afc849d91ab92ac1ea96f22e40871c..65ff82ff124e29a3c7cfedf276df89646fcbc2ac 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/log2.h>
 #include <linux/dm-kcopyd.h>
 
+#include "dm-exception-store.h"
 #include "dm-snap.h"
 #include "dm-bio-list.h"
 
@@ -429,8 +430,13 @@ out:
        list_add(&new_e->hash_list, e ? &e->hash_list : l);
 }
 
-int dm_add_exception(struct dm_snapshot *s, chunk_t old, chunk_t new)
+/*
+ * Callback used by the exception stores to load exceptions when
+ * initialising.
+ */
+static int dm_add_exception(void *context, chunk_t old, chunk_t new)
 {
+       struct dm_snapshot *s = context;
        struct dm_snap_exception *e;
 
        e = alloc_exception();
@@ -659,7 +665,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
        spin_lock_init(&s->tracked_chunk_lock);
 
        /* Metadata must only be loaded into one table at once */
-       r = s->store.read_metadata(&s->store);
+       r = s->store.read_metadata(&s->store, dm_add_exception, (void *)s);
        if (r < 0) {
                ti->error = "Failed to read snapshot metadata";
                goto bad_load_and_register;
@@ -1405,6 +1411,12 @@ static int __init dm_snapshot_init(void)
 {
        int r;
 
+       r = dm_exception_store_init();
+       if (r) {
+               DMERR("Failed to initialize exception stores");
+               return r;
+       }
+
        r = dm_register_target(&snapshot_target);
        if (r) {
                DMERR("snapshot target register failed %d", r);
@@ -1453,39 +1465,34 @@ static int __init dm_snapshot_init(void)
 
        return 0;
 
-      bad_pending_pool:
+bad_pending_pool:
        kmem_cache_destroy(tracked_chunk_cache);
-      bad5:
+bad5:
        kmem_cache_destroy(pending_cache);
-      bad4:
+bad4:
        kmem_cache_destroy(exception_cache);
-      bad3:
+bad3:
        exit_origin_hash();
-      bad2:
+bad2:
        dm_unregister_target(&origin_target);
-      bad1:
+bad1:
        dm_unregister_target(&snapshot_target);
        return r;
 }
 
 static void __exit dm_snapshot_exit(void)
 {
-       int r;
-
        destroy_workqueue(ksnapd);
 
-       r = dm_unregister_target(&snapshot_target);
-       if (r)
-               DMERR("snapshot unregister failed %d", r);
-
-       r = dm_unregister_target(&origin_target);
-       if (r)
-               DMERR("origin unregister failed %d", r);
+       dm_unregister_target(&snapshot_target);
+       dm_unregister_target(&origin_target);
 
        exit_origin_hash();
        kmem_cache_destroy(pending_cache);
        kmem_cache_destroy(exception_cache);
        kmem_cache_destroy(tracked_chunk_cache);
+
+       dm_exception_store_exit();
 }
 
 /* Module hooks */