summaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-snap-persistent.c
diff options
context:
space:
mode:
authorJonathan Brassow <jbrassow@redhat.com>2009-04-02 19:55:31 +0100
committerAlasdair G Kergon <agk@redhat.com>2009-04-02 19:55:31 +0100
commit493df71c6420b211a68ae82b889c1e8a5fe701be (patch)
tree2738295190c1b3c5f72d85059aae3c96f162afa6 /drivers/md/dm-snap-persistent.c
parent7513c2a761d69d2a93f17146b3563527d3618ba0 (diff)
downloadop-kernel-dev-493df71c6420b211a68ae82b889c1e8a5fe701be.zip
op-kernel-dev-493df71c6420b211a68ae82b889c1e8a5fe701be.tar.gz
dm exception store: introduce registry
Move exception stores into a registry. Signed-off-by: Jonathan Brassow <jbrassow@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md/dm-snap-persistent.c')
-rw-r--r--drivers/md/dm-snap-persistent.c67
1 files changed, 57 insertions, 10 deletions
diff --git a/drivers/md/dm-snap-persistent.c b/drivers/md/dm-snap-persistent.c
index 0bbbe3b..e85b7a1 100644
--- a/drivers/md/dm-snap-persistent.c
+++ b/drivers/md/dm-snap-persistent.c
@@ -478,7 +478,7 @@ static void persistent_fraction_full(struct dm_exception_store *store,
*denominator = get_dev_size(store->snap->cow->bdev);
}
-static void persistent_destroy(struct dm_exception_store *store)
+static void persistent_dtr(struct dm_exception_store *store)
{
struct pstore *ps = get_info(store);
@@ -656,7 +656,8 @@ static void persistent_drop_snapshot(struct dm_exception_store *store)
DMWARN("write header failed");
}
-int dm_create_persistent(struct dm_exception_store *store)
+static int persistent_ctr(struct dm_exception_store *store,
+ unsigned argc, char **argv)
{
struct pstore *ps;
@@ -683,23 +684,69 @@ int dm_create_persistent(struct dm_exception_store *store)
return -ENOMEM;
}
- store->type.dtr = persistent_destroy;
- store->type.read_metadata = persistent_read_metadata;
- store->type.prepare_exception = persistent_prepare_exception;
- store->type.commit_exception = persistent_commit_exception;
- store->type.drop_snapshot = persistent_drop_snapshot;
- store->type.fraction_full = persistent_fraction_full;
-
store->context = ps;
return 0;
}
+static int persistent_status(struct dm_exception_store *store,
+ status_type_t status, char *result,
+ unsigned int maxlen)
+{
+ int sz = 0;
+
+ return sz;
+}
+
+static struct dm_exception_store_type _persistent_type = {
+ .name = "persistent",
+ .module = THIS_MODULE,
+ .ctr = persistent_ctr,
+ .dtr = persistent_dtr,
+ .read_metadata = persistent_read_metadata,
+ .prepare_exception = persistent_prepare_exception,
+ .commit_exception = persistent_commit_exception,
+ .drop_snapshot = persistent_drop_snapshot,
+ .fraction_full = persistent_fraction_full,
+ .status = persistent_status,
+};
+
+static struct dm_exception_store_type _persistent_compat_type = {
+ .name = "P",
+ .module = THIS_MODULE,
+ .ctr = persistent_ctr,
+ .dtr = persistent_dtr,
+ .read_metadata = persistent_read_metadata,
+ .prepare_exception = persistent_prepare_exception,
+ .commit_exception = persistent_commit_exception,
+ .drop_snapshot = persistent_drop_snapshot,
+ .fraction_full = persistent_fraction_full,
+ .status = persistent_status,
+};
+
int dm_persistent_snapshot_init(void)
{
- return 0;
+ int r;
+
+ r = dm_exception_store_type_register(&_persistent_type);
+ if (r) {
+ DMERR("Unable to register persistent exception store type");
+ return r;
+ }
+
+ r = dm_exception_store_type_register(&_persistent_compat_type);
+ if (r) {
+ DMERR("Unable to register old-style persistent exception "
+ "store type");
+ dm_exception_store_type_unregister(&_persistent_type);
+ return r;
+ }
+
+ return r;
}
void dm_persistent_snapshot_exit(void)
{
+ dm_exception_store_type_unregister(&_persistent_type);
+ dm_exception_store_type_unregister(&_persistent_compat_type);
}
OpenPOWER on IntegriCloud