diff options
author | Jonathan Brassow <jbrassow@redhat.com> | 2009-04-02 14:55:31 -0400 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2009-04-02 14:55:31 -0400 |
commit | 493df71c6420b211a68ae82b889c1e8a5fe701be (patch) | |
tree | 2738295190c1b3c5f72d85059aae3c96f162afa6 /drivers/md/dm-snap-persistent.c | |
parent | 7513c2a761d69d2a93f17146b3563527d3618ba0 (diff) |
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.c | 67 |
1 files changed, 57 insertions, 10 deletions
diff --git a/drivers/md/dm-snap-persistent.c b/drivers/md/dm-snap-persistent.c index 0bbbe3b7431e..e85b7a186a13 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, | |||
478 | *denominator = get_dev_size(store->snap->cow->bdev); | 478 | *denominator = get_dev_size(store->snap->cow->bdev); |
479 | } | 479 | } |
480 | 480 | ||
481 | static void persistent_destroy(struct dm_exception_store *store) | 481 | static void persistent_dtr(struct dm_exception_store *store) |
482 | { | 482 | { |
483 | struct pstore *ps = get_info(store); | 483 | struct pstore *ps = get_info(store); |
484 | 484 | ||
@@ -656,7 +656,8 @@ static void persistent_drop_snapshot(struct dm_exception_store *store) | |||
656 | DMWARN("write header failed"); | 656 | DMWARN("write header failed"); |
657 | } | 657 | } |
658 | 658 | ||
659 | int dm_create_persistent(struct dm_exception_store *store) | 659 | static int persistent_ctr(struct dm_exception_store *store, |
660 | unsigned argc, char **argv) | ||
660 | { | 661 | { |
661 | struct pstore *ps; | 662 | struct pstore *ps; |
662 | 663 | ||
@@ -683,23 +684,69 @@ int dm_create_persistent(struct dm_exception_store *store) | |||
683 | return -ENOMEM; | 684 | return -ENOMEM; |
684 | } | 685 | } |
685 | 686 | ||
686 | store->type.dtr = persistent_destroy; | ||
687 | store->type.read_metadata = persistent_read_metadata; | ||
688 | store->type.prepare_exception = persistent_prepare_exception; | ||
689 | store->type.commit_exception = persistent_commit_exception; | ||
690 | store->type.drop_snapshot = persistent_drop_snapshot; | ||
691 | store->type.fraction_full = persistent_fraction_full; | ||
692 | |||
693 | store->context = ps; | 687 | store->context = ps; |
694 | 688 | ||
695 | return 0; | 689 | return 0; |
696 | } | 690 | } |
697 | 691 | ||
692 | static int persistent_status(struct dm_exception_store *store, | ||
693 | status_type_t status, char *result, | ||
694 | unsigned int maxlen) | ||
695 | { | ||
696 | int sz = 0; | ||
697 | |||
698 | return sz; | ||
699 | } | ||
700 | |||
701 | static struct dm_exception_store_type _persistent_type = { | ||
702 | .name = "persistent", | ||
703 | .module = THIS_MODULE, | ||
704 | .ctr = persistent_ctr, | ||
705 | .dtr = persistent_dtr, | ||
706 | .read_metadata = persistent_read_metadata, | ||
707 | .prepare_exception = persistent_prepare_exception, | ||
708 | .commit_exception = persistent_commit_exception, | ||
709 | .drop_snapshot = persistent_drop_snapshot, | ||
710 | .fraction_full = persistent_fraction_full, | ||
711 | .status = persistent_status, | ||
712 | }; | ||
713 | |||
714 | static struct dm_exception_store_type _persistent_compat_type = { | ||
715 | .name = "P", | ||
716 | .module = THIS_MODULE, | ||
717 | .ctr = persistent_ctr, | ||
718 | .dtr = persistent_dtr, | ||
719 | .read_metadata = persistent_read_metadata, | ||
720 | .prepare_exception = persistent_prepare_exception, | ||
721 | .commit_exception = persistent_commit_exception, | ||
722 | .drop_snapshot = persistent_drop_snapshot, | ||
723 | .fraction_full = persistent_fraction_full, | ||
724 | .status = persistent_status, | ||
725 | }; | ||
726 | |||
698 | int dm_persistent_snapshot_init(void) | 727 | int dm_persistent_snapshot_init(void) |
699 | { | 728 | { |
700 | return 0; | 729 | int r; |
730 | |||
731 | r = dm_exception_store_type_register(&_persistent_type); | ||
732 | if (r) { | ||
733 | DMERR("Unable to register persistent exception store type"); | ||
734 | return r; | ||
735 | } | ||
736 | |||
737 | r = dm_exception_store_type_register(&_persistent_compat_type); | ||
738 | if (r) { | ||
739 | DMERR("Unable to register old-style persistent exception " | ||
740 | "store type"); | ||
741 | dm_exception_store_type_unregister(&_persistent_type); | ||
742 | return r; | ||
743 | } | ||
744 | |||
745 | return r; | ||
701 | } | 746 | } |
702 | 747 | ||
703 | void dm_persistent_snapshot_exit(void) | 748 | void dm_persistent_snapshot_exit(void) |
704 | { | 749 | { |
750 | dm_exception_store_type_unregister(&_persistent_type); | ||
751 | dm_exception_store_type_unregister(&_persistent_compat_type); | ||
705 | } | 752 | } |