diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-03 13:02:45 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-03 13:02:45 -0400 |
commit | d9b9be024a6628a01d8730d1fd0b5f25658a2794 (patch) | |
tree | 9f8e606f975f6dff4213747e85fedaccd148eb60 /drivers/md/dm-snap-transient.c | |
parent | 9b59f0316bc556a1b63518f0b1224cf9be48467b (diff) | |
parent | 99360b4c18f7675b50d283301d46d755affe75fd (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/agk/linux-2.6-dm
* git://git.kernel.org/pub/scm/linux/kernel/git/agk/linux-2.6-dm: (36 commits)
dm: set queue ordered mode
dm: move wait queue declaration
dm: merge pushback and deferred bio lists
dm: allow uninterruptible wait for pending io
dm: merge __flush_deferred_io into caller
dm: move bio_io_error into __split_and_process_bio
dm: rename __split_bio
dm: remove unnecessary struct dm_wq_req
dm: remove unnecessary work queue context field
dm: remove unnecessary work queue type field
dm: bio list add bio_list_add_head
dm snapshot: persistent fix dtr cleanup
dm snapshot: move status to exception store
dm snapshot: move ctr parsing to exception store
dm snapshot: use DMEMIT macro for status
dm snapshot: remove dm_snap header
dm snapshot: remove dm_snap header use
dm exception store: move cow pointer
dm exception store: move chunk_fields
dm exception store: move dm_target pointer
...
Diffstat (limited to 'drivers/md/dm-snap-transient.c')
-rw-r--r-- | drivers/md/dm-snap-transient.c | 86 |
1 files changed, 69 insertions, 17 deletions
diff --git a/drivers/md/dm-snap-transient.c b/drivers/md/dm-snap-transient.c index 7f6e2e6dcb0d..cde5aa558e6d 100644 --- a/drivers/md/dm-snap-transient.c +++ b/drivers/md/dm-snap-transient.c | |||
@@ -6,7 +6,6 @@ | |||
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include "dm-exception-store.h" | 8 | #include "dm-exception-store.h" |
9 | #include "dm-snap.h" | ||
10 | 9 | ||
11 | #include <linux/mm.h> | 10 | #include <linux/mm.h> |
12 | #include <linux/pagemap.h> | 11 | #include <linux/pagemap.h> |
@@ -23,7 +22,7 @@ struct transient_c { | |||
23 | sector_t next_free; | 22 | sector_t next_free; |
24 | }; | 23 | }; |
25 | 24 | ||
26 | static void transient_destroy(struct dm_exception_store *store) | 25 | static void transient_dtr(struct dm_exception_store *store) |
27 | { | 26 | { |
28 | kfree(store->context); | 27 | kfree(store->context); |
29 | } | 28 | } |
@@ -39,14 +38,14 @@ static int transient_read_metadata(struct dm_exception_store *store, | |||
39 | static int transient_prepare_exception(struct dm_exception_store *store, | 38 | static int transient_prepare_exception(struct dm_exception_store *store, |
40 | struct dm_snap_exception *e) | 39 | struct dm_snap_exception *e) |
41 | { | 40 | { |
42 | struct transient_c *tc = (struct transient_c *) store->context; | 41 | struct transient_c *tc = store->context; |
43 | sector_t size = get_dev_size(store->snap->cow->bdev); | 42 | sector_t size = get_dev_size(store->cow->bdev); |
44 | 43 | ||
45 | if (size < (tc->next_free + store->snap->chunk_size)) | 44 | if (size < (tc->next_free + store->chunk_size)) |
46 | return -1; | 45 | return -1; |
47 | 46 | ||
48 | e->new_chunk = sector_to_chunk(store->snap, tc->next_free); | 47 | e->new_chunk = sector_to_chunk(store, tc->next_free); |
49 | tc->next_free += store->snap->chunk_size; | 48 | tc->next_free += store->chunk_size; |
50 | 49 | ||
51 | return 0; | 50 | return 0; |
52 | } | 51 | } |
@@ -64,20 +63,14 @@ static void transient_fraction_full(struct dm_exception_store *store, | |||
64 | sector_t *numerator, sector_t *denominator) | 63 | sector_t *numerator, sector_t *denominator) |
65 | { | 64 | { |
66 | *numerator = ((struct transient_c *) store->context)->next_free; | 65 | *numerator = ((struct transient_c *) store->context)->next_free; |
67 | *denominator = get_dev_size(store->snap->cow->bdev); | 66 | *denominator = get_dev_size(store->cow->bdev); |
68 | } | 67 | } |
69 | 68 | ||
70 | int dm_create_transient(struct dm_exception_store *store) | 69 | static int transient_ctr(struct dm_exception_store *store, |
70 | unsigned argc, char **argv) | ||
71 | { | 71 | { |
72 | struct transient_c *tc; | 72 | struct transient_c *tc; |
73 | 73 | ||
74 | store->destroy = transient_destroy; | ||
75 | store->read_metadata = transient_read_metadata; | ||
76 | store->prepare_exception = transient_prepare_exception; | ||
77 | store->commit_exception = transient_commit_exception; | ||
78 | store->drop_snapshot = NULL; | ||
79 | store->fraction_full = transient_fraction_full; | ||
80 | |||
81 | tc = kmalloc(sizeof(struct transient_c), GFP_KERNEL); | 74 | tc = kmalloc(sizeof(struct transient_c), GFP_KERNEL); |
82 | if (!tc) | 75 | if (!tc) |
83 | return -ENOMEM; | 76 | return -ENOMEM; |
@@ -88,11 +81,70 @@ int dm_create_transient(struct dm_exception_store *store) | |||
88 | return 0; | 81 | return 0; |
89 | } | 82 | } |
90 | 83 | ||
84 | static unsigned transient_status(struct dm_exception_store *store, | ||
85 | status_type_t status, char *result, | ||
86 | unsigned maxlen) | ||
87 | { | ||
88 | unsigned sz = 0; | ||
89 | |||
90 | switch (status) { | ||
91 | case STATUSTYPE_INFO: | ||
92 | break; | ||
93 | case STATUSTYPE_TABLE: | ||
94 | DMEMIT(" %s N %llu", store->cow->name, | ||
95 | (unsigned long long)store->chunk_size); | ||
96 | } | ||
97 | |||
98 | return sz; | ||
99 | } | ||
100 | |||
101 | static struct dm_exception_store_type _transient_type = { | ||
102 | .name = "transient", | ||
103 | .module = THIS_MODULE, | ||
104 | .ctr = transient_ctr, | ||
105 | .dtr = transient_dtr, | ||
106 | .read_metadata = transient_read_metadata, | ||
107 | .prepare_exception = transient_prepare_exception, | ||
108 | .commit_exception = transient_commit_exception, | ||
109 | .fraction_full = transient_fraction_full, | ||
110 | .status = transient_status, | ||
111 | }; | ||
112 | |||
113 | static struct dm_exception_store_type _transient_compat_type = { | ||
114 | .name = "N", | ||
115 | .module = THIS_MODULE, | ||
116 | .ctr = transient_ctr, | ||
117 | .dtr = transient_dtr, | ||
118 | .read_metadata = transient_read_metadata, | ||
119 | .prepare_exception = transient_prepare_exception, | ||
120 | .commit_exception = transient_commit_exception, | ||
121 | .fraction_full = transient_fraction_full, | ||
122 | .status = transient_status, | ||
123 | }; | ||
124 | |||
91 | int dm_transient_snapshot_init(void) | 125 | int dm_transient_snapshot_init(void) |
92 | { | 126 | { |
93 | return 0; | 127 | int r; |
128 | |||
129 | r = dm_exception_store_type_register(&_transient_type); | ||
130 | if (r) { | ||
131 | DMWARN("Unable to register transient exception store type"); | ||
132 | return r; | ||
133 | } | ||
134 | |||
135 | r = dm_exception_store_type_register(&_transient_compat_type); | ||
136 | if (r) { | ||
137 | DMWARN("Unable to register old-style transient " | ||
138 | "exception store type"); | ||
139 | dm_exception_store_type_unregister(&_transient_type); | ||
140 | return r; | ||
141 | } | ||
142 | |||
143 | return r; | ||
94 | } | 144 | } |
95 | 145 | ||
96 | void dm_transient_snapshot_exit(void) | 146 | void dm_transient_snapshot_exit(void) |
97 | { | 147 | { |
148 | dm_exception_store_type_unregister(&_transient_type); | ||
149 | dm_exception_store_type_unregister(&_transient_compat_type); | ||
98 | } | 150 | } |