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-transient.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-transient.c')
-rw-r--r-- | drivers/md/dm-snap-transient.c | 65 |
1 files changed, 55 insertions, 10 deletions
diff --git a/drivers/md/dm-snap-transient.c b/drivers/md/dm-snap-transient.c index b558176ff020..51bc4a78ce9a 100644 --- a/drivers/md/dm-snap-transient.c +++ b/drivers/md/dm-snap-transient.c | |||
@@ -23,7 +23,7 @@ struct transient_c { | |||
23 | sector_t next_free; | 23 | sector_t next_free; |
24 | }; | 24 | }; |
25 | 25 | ||
26 | static void transient_destroy(struct dm_exception_store *store) | 26 | static void transient_dtr(struct dm_exception_store *store) |
27 | { | 27 | { |
28 | kfree(store->context); | 28 | kfree(store->context); |
29 | } | 29 | } |
@@ -67,17 +67,11 @@ static void transient_fraction_full(struct dm_exception_store *store, | |||
67 | *denominator = get_dev_size(store->snap->cow->bdev); | 67 | *denominator = get_dev_size(store->snap->cow->bdev); |
68 | } | 68 | } |
69 | 69 | ||
70 | int dm_create_transient(struct dm_exception_store *store) | 70 | static int transient_ctr(struct dm_exception_store *store, |
71 | unsigned argc, char **argv) | ||
71 | { | 72 | { |
72 | struct transient_c *tc; | 73 | struct transient_c *tc; |
73 | 74 | ||
74 | store->type.dtr = transient_destroy; | ||
75 | store->type.read_metadata = transient_read_metadata; | ||
76 | store->type.prepare_exception = transient_prepare_exception; | ||
77 | store->type.commit_exception = transient_commit_exception; | ||
78 | store->type.drop_snapshot = NULL; | ||
79 | store->type.fraction_full = transient_fraction_full; | ||
80 | |||
81 | tc = kmalloc(sizeof(struct transient_c), GFP_KERNEL); | 75 | tc = kmalloc(sizeof(struct transient_c), GFP_KERNEL); |
82 | if (!tc) | 76 | if (!tc) |
83 | return -ENOMEM; | 77 | return -ENOMEM; |
@@ -88,11 +82,62 @@ int dm_create_transient(struct dm_exception_store *store) | |||
88 | return 0; | 82 | return 0; |
89 | } | 83 | } |
90 | 84 | ||
85 | static int transient_status(struct dm_exception_store *store, | ||
86 | status_type_t status, char *result, | ||
87 | unsigned maxlen) | ||
88 | { | ||
89 | int sz = 0; | ||
90 | |||
91 | return sz; | ||
92 | } | ||
93 | |||
94 | static struct dm_exception_store_type _transient_type = { | ||
95 | .name = "transient", | ||
96 | .module = THIS_MODULE, | ||
97 | .ctr = transient_ctr, | ||
98 | .dtr = transient_dtr, | ||
99 | .read_metadata = transient_read_metadata, | ||
100 | .prepare_exception = transient_prepare_exception, | ||
101 | .commit_exception = transient_commit_exception, | ||
102 | .fraction_full = transient_fraction_full, | ||
103 | .status = transient_status, | ||
104 | }; | ||
105 | |||
106 | static struct dm_exception_store_type _transient_compat_type = { | ||
107 | .name = "N", | ||
108 | .module = THIS_MODULE, | ||
109 | .ctr = transient_ctr, | ||
110 | .dtr = transient_dtr, | ||
111 | .read_metadata = transient_read_metadata, | ||
112 | .prepare_exception = transient_prepare_exception, | ||
113 | .commit_exception = transient_commit_exception, | ||
114 | .fraction_full = transient_fraction_full, | ||
115 | .status = transient_status, | ||
116 | }; | ||
117 | |||
91 | int dm_transient_snapshot_init(void) | 118 | int dm_transient_snapshot_init(void) |
92 | { | 119 | { |
93 | return 0; | 120 | int r; |
121 | |||
122 | r = dm_exception_store_type_register(&_transient_type); | ||
123 | if (r) { | ||
124 | DMWARN("Unable to register transient exception store type"); | ||
125 | return r; | ||
126 | } | ||
127 | |||
128 | r = dm_exception_store_type_register(&_transient_compat_type); | ||
129 | if (r) { | ||
130 | DMWARN("Unable to register old-style transient " | ||
131 | "exception store type"); | ||
132 | dm_exception_store_type_unregister(&_transient_type); | ||
133 | return r; | ||
134 | } | ||
135 | |||
136 | return r; | ||
94 | } | 137 | } |
95 | 138 | ||
96 | void dm_transient_snapshot_exit(void) | 139 | void dm_transient_snapshot_exit(void) |
97 | { | 140 | { |
141 | dm_exception_store_type_unregister(&_transient_type); | ||
142 | dm_exception_store_type_unregister(&_transient_compat_type); | ||
98 | } | 143 | } |