dm snapshot: split out exception store implementations
[platform/adaptation/renesas_rcar/renesas_kernel.git] / drivers / md / dm-snap.c
index 6c96db2..018b567 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/blkdev.h>
 #include <linux/ctype.h>
 #include <linux/device-mapper.h>
 #include <linux/blkdev.h>
 #include <linux/ctype.h>
 #include <linux/device-mapper.h>
+#include <linux/delay.h>
 #include <linux/fs.h>
 #include <linux/init.h>
 #include <linux/kdev_t.h>
 #include <linux/fs.h>
 #include <linux/init.h>
 #include <linux/kdev_t.h>
@@ -20,6 +21,7 @@
 #include <linux/log2.h>
 #include <linux/dm-kcopyd.h>
 
 #include <linux/log2.h>
 #include <linux/dm-kcopyd.h>
 
+#include "dm-exception-store.h"
 #include "dm-snap.h"
 #include "dm-bio-list.h"
 
 #include "dm-snap.h"
 #include "dm-bio-list.h"
 
@@ -735,7 +737,7 @@ static void snapshot_dtr(struct dm_target *ti)
        unregister_snapshot(s);
 
        while (atomic_read(&s->pending_exceptions_count))
        unregister_snapshot(s);
 
        while (atomic_read(&s->pending_exceptions_count))
-               yield();
+               msleep(1);
        /*
         * Ensure instructions in mempool_destroy aren't reordered
         * before atomic_read.
        /*
         * Ensure instructions in mempool_destroy aren't reordered
         * before atomic_read.
@@ -888,10 +890,10 @@ static void pending_complete(struct dm_snap_pending_exception *pe, int success)
 
        /*
         * Check for conflicting reads. This is extremely improbable,
 
        /*
         * Check for conflicting reads. This is extremely improbable,
-        * so yield() is sufficient and there is no need for a wait queue.
+        * so msleep(1) is sufficient and there is no need for a wait queue.
         */
        while (__chunk_is_tracked(s, pe->e.old_chunk))
         */
        while (__chunk_is_tracked(s, pe->e.old_chunk))
-               yield();
+               msleep(1);
 
        /*
         * Add a proper exception, and remove the
 
        /*
         * Add a proper exception, and remove the
@@ -1404,6 +1406,12 @@ static int __init dm_snapshot_init(void)
 {
        int r;
 
 {
        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);
        r = dm_register_target(&snapshot_target);
        if (r) {
                DMERR("snapshot target register failed %d", r);
@@ -1452,39 +1460,34 @@ static int __init dm_snapshot_init(void)
 
        return 0;
 
 
        return 0;
 
-      bad_pending_pool:
+bad_pending_pool:
        kmem_cache_destroy(tracked_chunk_cache);
        kmem_cache_destroy(tracked_chunk_cache);
-      bad5:
+bad5:
        kmem_cache_destroy(pending_cache);
        kmem_cache_destroy(pending_cache);
-      bad4:
+bad4:
        kmem_cache_destroy(exception_cache);
        kmem_cache_destroy(exception_cache);
-      bad3:
+bad3:
        exit_origin_hash();
        exit_origin_hash();
-      bad2:
+bad2:
        dm_unregister_target(&origin_target);
        dm_unregister_target(&origin_target);
-      bad1:
+bad1:
        dm_unregister_target(&snapshot_target);
        return r;
 }
 
 static void __exit dm_snapshot_exit(void)
 {
        dm_unregister_target(&snapshot_target);
        return r;
 }
 
 static void __exit dm_snapshot_exit(void)
 {
-       int r;
-
        destroy_workqueue(ksnapd);
 
        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);
 
        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 */
 }
 
 /* Module hooks */