Commit 3ee247ebce93a526f482d6bc714ce796fa85a81a
Committed by
Linus Torvalds
1 parent
4aac0a63fe
Exists in
master
and in
7 other branches
[PATCH] dm: dm-table warning fix
drivers/md/dm-table.c:500: warning: comparison of distinct pointer types lacks a cast Signed-off-by: Alasdair G Kergon <agk@redhat.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Showing 2 changed files with 2 additions and 2 deletions Inline Diff
drivers/md/dm-table.c
1 | /* | 1 | /* |
2 | * Copyright (C) 2001 Sistina Software (UK) Limited. | 2 | * Copyright (C) 2001 Sistina Software (UK) Limited. |
3 | * Copyright (C) 2004 Red Hat, Inc. All rights reserved. | 3 | * Copyright (C) 2004 Red Hat, Inc. All rights reserved. |
4 | * | 4 | * |
5 | * This file is released under the GPL. | 5 | * This file is released under the GPL. |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include "dm.h" | 8 | #include "dm.h" |
9 | 9 | ||
10 | #include <linux/module.h> | 10 | #include <linux/module.h> |
11 | #include <linux/vmalloc.h> | 11 | #include <linux/vmalloc.h> |
12 | #include <linux/blkdev.h> | 12 | #include <linux/blkdev.h> |
13 | #include <linux/namei.h> | 13 | #include <linux/namei.h> |
14 | #include <linux/ctype.h> | 14 | #include <linux/ctype.h> |
15 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
16 | #include <linux/interrupt.h> | 16 | #include <linux/interrupt.h> |
17 | #include <asm/atomic.h> | 17 | #include <asm/atomic.h> |
18 | 18 | ||
19 | #define MAX_DEPTH 16 | 19 | #define MAX_DEPTH 16 |
20 | #define NODE_SIZE L1_CACHE_BYTES | 20 | #define NODE_SIZE L1_CACHE_BYTES |
21 | #define KEYS_PER_NODE (NODE_SIZE / sizeof(sector_t)) | 21 | #define KEYS_PER_NODE (NODE_SIZE / sizeof(sector_t)) |
22 | #define CHILDREN_PER_NODE (KEYS_PER_NODE + 1) | 22 | #define CHILDREN_PER_NODE (KEYS_PER_NODE + 1) |
23 | 23 | ||
24 | struct dm_table { | 24 | struct dm_table { |
25 | atomic_t holders; | 25 | atomic_t holders; |
26 | 26 | ||
27 | /* btree table */ | 27 | /* btree table */ |
28 | unsigned int depth; | 28 | unsigned int depth; |
29 | unsigned int counts[MAX_DEPTH]; /* in nodes */ | 29 | unsigned int counts[MAX_DEPTH]; /* in nodes */ |
30 | sector_t *index[MAX_DEPTH]; | 30 | sector_t *index[MAX_DEPTH]; |
31 | 31 | ||
32 | unsigned int num_targets; | 32 | unsigned int num_targets; |
33 | unsigned int num_allocated; | 33 | unsigned int num_allocated; |
34 | sector_t *highs; | 34 | sector_t *highs; |
35 | struct dm_target *targets; | 35 | struct dm_target *targets; |
36 | 36 | ||
37 | /* | 37 | /* |
38 | * Indicates the rw permissions for the new logical | 38 | * Indicates the rw permissions for the new logical |
39 | * device. This should be a combination of FMODE_READ | 39 | * device. This should be a combination of FMODE_READ |
40 | * and FMODE_WRITE. | 40 | * and FMODE_WRITE. |
41 | */ | 41 | */ |
42 | int mode; | 42 | int mode; |
43 | 43 | ||
44 | /* a list of devices used by this table */ | 44 | /* a list of devices used by this table */ |
45 | struct list_head devices; | 45 | struct list_head devices; |
46 | 46 | ||
47 | /* | 47 | /* |
48 | * These are optimistic limits taken from all the | 48 | * These are optimistic limits taken from all the |
49 | * targets, some targets will need smaller limits. | 49 | * targets, some targets will need smaller limits. |
50 | */ | 50 | */ |
51 | struct io_restrictions limits; | 51 | struct io_restrictions limits; |
52 | 52 | ||
53 | /* events get handed up using this callback */ | 53 | /* events get handed up using this callback */ |
54 | void (*event_fn)(void *); | 54 | void (*event_fn)(void *); |
55 | void *event_context; | 55 | void *event_context; |
56 | }; | 56 | }; |
57 | 57 | ||
58 | /* | 58 | /* |
59 | * Similar to ceiling(log_size(n)) | 59 | * Similar to ceiling(log_size(n)) |
60 | */ | 60 | */ |
61 | static unsigned int int_log(unsigned int n, unsigned int base) | 61 | static unsigned int int_log(unsigned int n, unsigned int base) |
62 | { | 62 | { |
63 | int result = 0; | 63 | int result = 0; |
64 | 64 | ||
65 | while (n > 1) { | 65 | while (n > 1) { |
66 | n = dm_div_up(n, base); | 66 | n = dm_div_up(n, base); |
67 | result++; | 67 | result++; |
68 | } | 68 | } |
69 | 69 | ||
70 | return result; | 70 | return result; |
71 | } | 71 | } |
72 | 72 | ||
73 | /* | 73 | /* |
74 | * Returns the minimum that is _not_ zero, unless both are zero. | 74 | * Returns the minimum that is _not_ zero, unless both are zero. |
75 | */ | 75 | */ |
76 | #define min_not_zero(l, r) (l == 0) ? r : ((r == 0) ? l : min(l, r)) | 76 | #define min_not_zero(l, r) (l == 0) ? r : ((r == 0) ? l : min(l, r)) |
77 | 77 | ||
78 | /* | 78 | /* |
79 | * Combine two io_restrictions, always taking the lower value. | 79 | * Combine two io_restrictions, always taking the lower value. |
80 | */ | 80 | */ |
81 | static void combine_restrictions_low(struct io_restrictions *lhs, | 81 | static void combine_restrictions_low(struct io_restrictions *lhs, |
82 | struct io_restrictions *rhs) | 82 | struct io_restrictions *rhs) |
83 | { | 83 | { |
84 | lhs->max_sectors = | 84 | lhs->max_sectors = |
85 | min_not_zero(lhs->max_sectors, rhs->max_sectors); | 85 | min_not_zero(lhs->max_sectors, rhs->max_sectors); |
86 | 86 | ||
87 | lhs->max_phys_segments = | 87 | lhs->max_phys_segments = |
88 | min_not_zero(lhs->max_phys_segments, rhs->max_phys_segments); | 88 | min_not_zero(lhs->max_phys_segments, rhs->max_phys_segments); |
89 | 89 | ||
90 | lhs->max_hw_segments = | 90 | lhs->max_hw_segments = |
91 | min_not_zero(lhs->max_hw_segments, rhs->max_hw_segments); | 91 | min_not_zero(lhs->max_hw_segments, rhs->max_hw_segments); |
92 | 92 | ||
93 | lhs->hardsect_size = max(lhs->hardsect_size, rhs->hardsect_size); | 93 | lhs->hardsect_size = max(lhs->hardsect_size, rhs->hardsect_size); |
94 | 94 | ||
95 | lhs->max_segment_size = | 95 | lhs->max_segment_size = |
96 | min_not_zero(lhs->max_segment_size, rhs->max_segment_size); | 96 | min_not_zero(lhs->max_segment_size, rhs->max_segment_size); |
97 | 97 | ||
98 | lhs->seg_boundary_mask = | 98 | lhs->seg_boundary_mask = |
99 | min_not_zero(lhs->seg_boundary_mask, rhs->seg_boundary_mask); | 99 | min_not_zero(lhs->seg_boundary_mask, rhs->seg_boundary_mask); |
100 | } | 100 | } |
101 | 101 | ||
102 | /* | 102 | /* |
103 | * Calculate the index of the child node of the n'th node k'th key. | 103 | * Calculate the index of the child node of the n'th node k'th key. |
104 | */ | 104 | */ |
105 | static inline unsigned int get_child(unsigned int n, unsigned int k) | 105 | static inline unsigned int get_child(unsigned int n, unsigned int k) |
106 | { | 106 | { |
107 | return (n * CHILDREN_PER_NODE) + k; | 107 | return (n * CHILDREN_PER_NODE) + k; |
108 | } | 108 | } |
109 | 109 | ||
110 | /* | 110 | /* |
111 | * Return the n'th node of level l from table t. | 111 | * Return the n'th node of level l from table t. |
112 | */ | 112 | */ |
113 | static inline sector_t *get_node(struct dm_table *t, | 113 | static inline sector_t *get_node(struct dm_table *t, |
114 | unsigned int l, unsigned int n) | 114 | unsigned int l, unsigned int n) |
115 | { | 115 | { |
116 | return t->index[l] + (n * KEYS_PER_NODE); | 116 | return t->index[l] + (n * KEYS_PER_NODE); |
117 | } | 117 | } |
118 | 118 | ||
119 | /* | 119 | /* |
120 | * Return the highest key that you could lookup from the n'th | 120 | * Return the highest key that you could lookup from the n'th |
121 | * node on level l of the btree. | 121 | * node on level l of the btree. |
122 | */ | 122 | */ |
123 | static sector_t high(struct dm_table *t, unsigned int l, unsigned int n) | 123 | static sector_t high(struct dm_table *t, unsigned int l, unsigned int n) |
124 | { | 124 | { |
125 | for (; l < t->depth - 1; l++) | 125 | for (; l < t->depth - 1; l++) |
126 | n = get_child(n, CHILDREN_PER_NODE - 1); | 126 | n = get_child(n, CHILDREN_PER_NODE - 1); |
127 | 127 | ||
128 | if (n >= t->counts[l]) | 128 | if (n >= t->counts[l]) |
129 | return (sector_t) - 1; | 129 | return (sector_t) - 1; |
130 | 130 | ||
131 | return get_node(t, l, n)[KEYS_PER_NODE - 1]; | 131 | return get_node(t, l, n)[KEYS_PER_NODE - 1]; |
132 | } | 132 | } |
133 | 133 | ||
134 | /* | 134 | /* |
135 | * Fills in a level of the btree based on the highs of the level | 135 | * Fills in a level of the btree based on the highs of the level |
136 | * below it. | 136 | * below it. |
137 | */ | 137 | */ |
138 | static int setup_btree_index(unsigned int l, struct dm_table *t) | 138 | static int setup_btree_index(unsigned int l, struct dm_table *t) |
139 | { | 139 | { |
140 | unsigned int n, k; | 140 | unsigned int n, k; |
141 | sector_t *node; | 141 | sector_t *node; |
142 | 142 | ||
143 | for (n = 0U; n < t->counts[l]; n++) { | 143 | for (n = 0U; n < t->counts[l]; n++) { |
144 | node = get_node(t, l, n); | 144 | node = get_node(t, l, n); |
145 | 145 | ||
146 | for (k = 0U; k < KEYS_PER_NODE; k++) | 146 | for (k = 0U; k < KEYS_PER_NODE; k++) |
147 | node[k] = high(t, l + 1, get_child(n, k)); | 147 | node[k] = high(t, l + 1, get_child(n, k)); |
148 | } | 148 | } |
149 | 149 | ||
150 | return 0; | 150 | return 0; |
151 | } | 151 | } |
152 | 152 | ||
153 | void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size) | 153 | void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size) |
154 | { | 154 | { |
155 | unsigned long size; | 155 | unsigned long size; |
156 | void *addr; | 156 | void *addr; |
157 | 157 | ||
158 | /* | 158 | /* |
159 | * Check that we're not going to overflow. | 159 | * Check that we're not going to overflow. |
160 | */ | 160 | */ |
161 | if (nmemb > (ULONG_MAX / elem_size)) | 161 | if (nmemb > (ULONG_MAX / elem_size)) |
162 | return NULL; | 162 | return NULL; |
163 | 163 | ||
164 | size = nmemb * elem_size; | 164 | size = nmemb * elem_size; |
165 | addr = vmalloc(size); | 165 | addr = vmalloc(size); |
166 | if (addr) | 166 | if (addr) |
167 | memset(addr, 0, size); | 167 | memset(addr, 0, size); |
168 | 168 | ||
169 | return addr; | 169 | return addr; |
170 | } | 170 | } |
171 | 171 | ||
172 | /* | 172 | /* |
173 | * highs, and targets are managed as dynamic arrays during a | 173 | * highs, and targets are managed as dynamic arrays during a |
174 | * table load. | 174 | * table load. |
175 | */ | 175 | */ |
176 | static int alloc_targets(struct dm_table *t, unsigned int num) | 176 | static int alloc_targets(struct dm_table *t, unsigned int num) |
177 | { | 177 | { |
178 | sector_t *n_highs; | 178 | sector_t *n_highs; |
179 | struct dm_target *n_targets; | 179 | struct dm_target *n_targets; |
180 | int n = t->num_targets; | 180 | int n = t->num_targets; |
181 | 181 | ||
182 | /* | 182 | /* |
183 | * Allocate both the target array and offset array at once. | 183 | * Allocate both the target array and offset array at once. |
184 | */ | 184 | */ |
185 | n_highs = (sector_t *) dm_vcalloc(num, sizeof(struct dm_target) + | 185 | n_highs = (sector_t *) dm_vcalloc(num, sizeof(struct dm_target) + |
186 | sizeof(sector_t)); | 186 | sizeof(sector_t)); |
187 | if (!n_highs) | 187 | if (!n_highs) |
188 | return -ENOMEM; | 188 | return -ENOMEM; |
189 | 189 | ||
190 | n_targets = (struct dm_target *) (n_highs + num); | 190 | n_targets = (struct dm_target *) (n_highs + num); |
191 | 191 | ||
192 | if (n) { | 192 | if (n) { |
193 | memcpy(n_highs, t->highs, sizeof(*n_highs) * n); | 193 | memcpy(n_highs, t->highs, sizeof(*n_highs) * n); |
194 | memcpy(n_targets, t->targets, sizeof(*n_targets) * n); | 194 | memcpy(n_targets, t->targets, sizeof(*n_targets) * n); |
195 | } | 195 | } |
196 | 196 | ||
197 | memset(n_highs + n, -1, sizeof(*n_highs) * (num - n)); | 197 | memset(n_highs + n, -1, sizeof(*n_highs) * (num - n)); |
198 | vfree(t->highs); | 198 | vfree(t->highs); |
199 | 199 | ||
200 | t->num_allocated = num; | 200 | t->num_allocated = num; |
201 | t->highs = n_highs; | 201 | t->highs = n_highs; |
202 | t->targets = n_targets; | 202 | t->targets = n_targets; |
203 | 203 | ||
204 | return 0; | 204 | return 0; |
205 | } | 205 | } |
206 | 206 | ||
207 | int dm_table_create(struct dm_table **result, int mode, unsigned num_targets) | 207 | int dm_table_create(struct dm_table **result, int mode, unsigned num_targets) |
208 | { | 208 | { |
209 | struct dm_table *t = kmalloc(sizeof(*t), GFP_KERNEL); | 209 | struct dm_table *t = kmalloc(sizeof(*t), GFP_KERNEL); |
210 | 210 | ||
211 | if (!t) | 211 | if (!t) |
212 | return -ENOMEM; | 212 | return -ENOMEM; |
213 | 213 | ||
214 | memset(t, 0, sizeof(*t)); | 214 | memset(t, 0, sizeof(*t)); |
215 | INIT_LIST_HEAD(&t->devices); | 215 | INIT_LIST_HEAD(&t->devices); |
216 | atomic_set(&t->holders, 1); | 216 | atomic_set(&t->holders, 1); |
217 | 217 | ||
218 | if (!num_targets) | 218 | if (!num_targets) |
219 | num_targets = KEYS_PER_NODE; | 219 | num_targets = KEYS_PER_NODE; |
220 | 220 | ||
221 | num_targets = dm_round_up(num_targets, KEYS_PER_NODE); | 221 | num_targets = dm_round_up(num_targets, KEYS_PER_NODE); |
222 | 222 | ||
223 | if (alloc_targets(t, num_targets)) { | 223 | if (alloc_targets(t, num_targets)) { |
224 | kfree(t); | 224 | kfree(t); |
225 | t = NULL; | 225 | t = NULL; |
226 | return -ENOMEM; | 226 | return -ENOMEM; |
227 | } | 227 | } |
228 | 228 | ||
229 | t->mode = mode; | 229 | t->mode = mode; |
230 | *result = t; | 230 | *result = t; |
231 | return 0; | 231 | return 0; |
232 | } | 232 | } |
233 | 233 | ||
234 | static void free_devices(struct list_head *devices) | 234 | static void free_devices(struct list_head *devices) |
235 | { | 235 | { |
236 | struct list_head *tmp, *next; | 236 | struct list_head *tmp, *next; |
237 | 237 | ||
238 | for (tmp = devices->next; tmp != devices; tmp = next) { | 238 | for (tmp = devices->next; tmp != devices; tmp = next) { |
239 | struct dm_dev *dd = list_entry(tmp, struct dm_dev, list); | 239 | struct dm_dev *dd = list_entry(tmp, struct dm_dev, list); |
240 | next = tmp->next; | 240 | next = tmp->next; |
241 | kfree(dd); | 241 | kfree(dd); |
242 | } | 242 | } |
243 | } | 243 | } |
244 | 244 | ||
245 | static void table_destroy(struct dm_table *t) | 245 | static void table_destroy(struct dm_table *t) |
246 | { | 246 | { |
247 | unsigned int i; | 247 | unsigned int i; |
248 | 248 | ||
249 | /* free the indexes (see dm_table_complete) */ | 249 | /* free the indexes (see dm_table_complete) */ |
250 | if (t->depth >= 2) | 250 | if (t->depth >= 2) |
251 | vfree(t->index[t->depth - 2]); | 251 | vfree(t->index[t->depth - 2]); |
252 | 252 | ||
253 | /* free the targets */ | 253 | /* free the targets */ |
254 | for (i = 0; i < t->num_targets; i++) { | 254 | for (i = 0; i < t->num_targets; i++) { |
255 | struct dm_target *tgt = t->targets + i; | 255 | struct dm_target *tgt = t->targets + i; |
256 | 256 | ||
257 | if (tgt->type->dtr) | 257 | if (tgt->type->dtr) |
258 | tgt->type->dtr(tgt); | 258 | tgt->type->dtr(tgt); |
259 | 259 | ||
260 | dm_put_target_type(tgt->type); | 260 | dm_put_target_type(tgt->type); |
261 | } | 261 | } |
262 | 262 | ||
263 | vfree(t->highs); | 263 | vfree(t->highs); |
264 | 264 | ||
265 | /* free the device list */ | 265 | /* free the device list */ |
266 | if (t->devices.next != &t->devices) { | 266 | if (t->devices.next != &t->devices) { |
267 | DMWARN("devices still present during destroy: " | 267 | DMWARN("devices still present during destroy: " |
268 | "dm_table_remove_device calls missing"); | 268 | "dm_table_remove_device calls missing"); |
269 | 269 | ||
270 | free_devices(&t->devices); | 270 | free_devices(&t->devices); |
271 | } | 271 | } |
272 | 272 | ||
273 | kfree(t); | 273 | kfree(t); |
274 | } | 274 | } |
275 | 275 | ||
276 | void dm_table_get(struct dm_table *t) | 276 | void dm_table_get(struct dm_table *t) |
277 | { | 277 | { |
278 | atomic_inc(&t->holders); | 278 | atomic_inc(&t->holders); |
279 | } | 279 | } |
280 | 280 | ||
281 | void dm_table_put(struct dm_table *t) | 281 | void dm_table_put(struct dm_table *t) |
282 | { | 282 | { |
283 | if (!t) | 283 | if (!t) |
284 | return; | 284 | return; |
285 | 285 | ||
286 | if (atomic_dec_and_test(&t->holders)) | 286 | if (atomic_dec_and_test(&t->holders)) |
287 | table_destroy(t); | 287 | table_destroy(t); |
288 | } | 288 | } |
289 | 289 | ||
290 | /* | 290 | /* |
291 | * Checks to see if we need to extend highs or targets. | 291 | * Checks to see if we need to extend highs or targets. |
292 | */ | 292 | */ |
293 | static inline int check_space(struct dm_table *t) | 293 | static inline int check_space(struct dm_table *t) |
294 | { | 294 | { |
295 | if (t->num_targets >= t->num_allocated) | 295 | if (t->num_targets >= t->num_allocated) |
296 | return alloc_targets(t, t->num_allocated * 2); | 296 | return alloc_targets(t, t->num_allocated * 2); |
297 | 297 | ||
298 | return 0; | 298 | return 0; |
299 | } | 299 | } |
300 | 300 | ||
301 | /* | 301 | /* |
302 | * Convert a device path to a dev_t. | 302 | * Convert a device path to a dev_t. |
303 | */ | 303 | */ |
304 | static int lookup_device(const char *path, dev_t *dev) | 304 | static int lookup_device(const char *path, dev_t *dev) |
305 | { | 305 | { |
306 | int r; | 306 | int r; |
307 | struct nameidata nd; | 307 | struct nameidata nd; |
308 | struct inode *inode; | 308 | struct inode *inode; |
309 | 309 | ||
310 | if ((r = path_lookup(path, LOOKUP_FOLLOW, &nd))) | 310 | if ((r = path_lookup(path, LOOKUP_FOLLOW, &nd))) |
311 | return r; | 311 | return r; |
312 | 312 | ||
313 | inode = nd.dentry->d_inode; | 313 | inode = nd.dentry->d_inode; |
314 | if (!inode) { | 314 | if (!inode) { |
315 | r = -ENOENT; | 315 | r = -ENOENT; |
316 | goto out; | 316 | goto out; |
317 | } | 317 | } |
318 | 318 | ||
319 | if (!S_ISBLK(inode->i_mode)) { | 319 | if (!S_ISBLK(inode->i_mode)) { |
320 | r = -ENOTBLK; | 320 | r = -ENOTBLK; |
321 | goto out; | 321 | goto out; |
322 | } | 322 | } |
323 | 323 | ||
324 | *dev = inode->i_rdev; | 324 | *dev = inode->i_rdev; |
325 | 325 | ||
326 | out: | 326 | out: |
327 | path_release(&nd); | 327 | path_release(&nd); |
328 | return r; | 328 | return r; |
329 | } | 329 | } |
330 | 330 | ||
331 | /* | 331 | /* |
332 | * See if we've already got a device in the list. | 332 | * See if we've already got a device in the list. |
333 | */ | 333 | */ |
334 | static struct dm_dev *find_device(struct list_head *l, dev_t dev) | 334 | static struct dm_dev *find_device(struct list_head *l, dev_t dev) |
335 | { | 335 | { |
336 | struct dm_dev *dd; | 336 | struct dm_dev *dd; |
337 | 337 | ||
338 | list_for_each_entry (dd, l, list) | 338 | list_for_each_entry (dd, l, list) |
339 | if (dd->bdev->bd_dev == dev) | 339 | if (dd->bdev->bd_dev == dev) |
340 | return dd; | 340 | return dd; |
341 | 341 | ||
342 | return NULL; | 342 | return NULL; |
343 | } | 343 | } |
344 | 344 | ||
345 | /* | 345 | /* |
346 | * Open a device so we can use it as a map destination. | 346 | * Open a device so we can use it as a map destination. |
347 | */ | 347 | */ |
348 | static int open_dev(struct dm_dev *d, dev_t dev) | 348 | static int open_dev(struct dm_dev *d, dev_t dev) |
349 | { | 349 | { |
350 | static char *_claim_ptr = "I belong to device-mapper"; | 350 | static char *_claim_ptr = "I belong to device-mapper"; |
351 | struct block_device *bdev; | 351 | struct block_device *bdev; |
352 | 352 | ||
353 | int r; | 353 | int r; |
354 | 354 | ||
355 | if (d->bdev) | 355 | if (d->bdev) |
356 | BUG(); | 356 | BUG(); |
357 | 357 | ||
358 | bdev = open_by_devnum(dev, d->mode); | 358 | bdev = open_by_devnum(dev, d->mode); |
359 | if (IS_ERR(bdev)) | 359 | if (IS_ERR(bdev)) |
360 | return PTR_ERR(bdev); | 360 | return PTR_ERR(bdev); |
361 | r = bd_claim(bdev, _claim_ptr); | 361 | r = bd_claim(bdev, _claim_ptr); |
362 | if (r) | 362 | if (r) |
363 | blkdev_put(bdev); | 363 | blkdev_put(bdev); |
364 | else | 364 | else |
365 | d->bdev = bdev; | 365 | d->bdev = bdev; |
366 | return r; | 366 | return r; |
367 | } | 367 | } |
368 | 368 | ||
369 | /* | 369 | /* |
370 | * Close a device that we've been using. | 370 | * Close a device that we've been using. |
371 | */ | 371 | */ |
372 | static void close_dev(struct dm_dev *d) | 372 | static void close_dev(struct dm_dev *d) |
373 | { | 373 | { |
374 | if (!d->bdev) | 374 | if (!d->bdev) |
375 | return; | 375 | return; |
376 | 376 | ||
377 | bd_release(d->bdev); | 377 | bd_release(d->bdev); |
378 | blkdev_put(d->bdev); | 378 | blkdev_put(d->bdev); |
379 | d->bdev = NULL; | 379 | d->bdev = NULL; |
380 | } | 380 | } |
381 | 381 | ||
382 | /* | 382 | /* |
383 | * If possible (ie. blk_size[major] is set), this checks an area | 383 | * If possible (ie. blk_size[major] is set), this checks an area |
384 | * of a destination device is valid. | 384 | * of a destination device is valid. |
385 | */ | 385 | */ |
386 | static int check_device_area(struct dm_dev *dd, sector_t start, sector_t len) | 386 | static int check_device_area(struct dm_dev *dd, sector_t start, sector_t len) |
387 | { | 387 | { |
388 | sector_t dev_size; | 388 | sector_t dev_size; |
389 | dev_size = dd->bdev->bd_inode->i_size >> SECTOR_SHIFT; | 389 | dev_size = dd->bdev->bd_inode->i_size >> SECTOR_SHIFT; |
390 | return ((start < dev_size) && (len <= (dev_size - start))); | 390 | return ((start < dev_size) && (len <= (dev_size - start))); |
391 | } | 391 | } |
392 | 392 | ||
393 | /* | 393 | /* |
394 | * This upgrades the mode on an already open dm_dev. Being | 394 | * This upgrades the mode on an already open dm_dev. Being |
395 | * careful to leave things as they were if we fail to reopen the | 395 | * careful to leave things as they were if we fail to reopen the |
396 | * device. | 396 | * device. |
397 | */ | 397 | */ |
398 | static int upgrade_mode(struct dm_dev *dd, int new_mode) | 398 | static int upgrade_mode(struct dm_dev *dd, int new_mode) |
399 | { | 399 | { |
400 | int r; | 400 | int r; |
401 | struct dm_dev dd_copy; | 401 | struct dm_dev dd_copy; |
402 | dev_t dev = dd->bdev->bd_dev; | 402 | dev_t dev = dd->bdev->bd_dev; |
403 | 403 | ||
404 | dd_copy = *dd; | 404 | dd_copy = *dd; |
405 | 405 | ||
406 | dd->mode |= new_mode; | 406 | dd->mode |= new_mode; |
407 | dd->bdev = NULL; | 407 | dd->bdev = NULL; |
408 | r = open_dev(dd, dev); | 408 | r = open_dev(dd, dev); |
409 | if (!r) | 409 | if (!r) |
410 | close_dev(&dd_copy); | 410 | close_dev(&dd_copy); |
411 | else | 411 | else |
412 | *dd = dd_copy; | 412 | *dd = dd_copy; |
413 | 413 | ||
414 | return r; | 414 | return r; |
415 | } | 415 | } |
416 | 416 | ||
417 | /* | 417 | /* |
418 | * Add a device to the list, or just increment the usage count if | 418 | * Add a device to the list, or just increment the usage count if |
419 | * it's already present. | 419 | * it's already present. |
420 | */ | 420 | */ |
421 | static int __table_get_device(struct dm_table *t, struct dm_target *ti, | 421 | static int __table_get_device(struct dm_table *t, struct dm_target *ti, |
422 | const char *path, sector_t start, sector_t len, | 422 | const char *path, sector_t start, sector_t len, |
423 | int mode, struct dm_dev **result) | 423 | int mode, struct dm_dev **result) |
424 | { | 424 | { |
425 | int r; | 425 | int r; |
426 | dev_t dev; | 426 | dev_t dev; |
427 | struct dm_dev *dd; | 427 | struct dm_dev *dd; |
428 | unsigned int major, minor; | 428 | unsigned int major, minor; |
429 | 429 | ||
430 | if (!t) | 430 | if (!t) |
431 | BUG(); | 431 | BUG(); |
432 | 432 | ||
433 | if (sscanf(path, "%u:%u", &major, &minor) == 2) { | 433 | if (sscanf(path, "%u:%u", &major, &minor) == 2) { |
434 | /* Extract the major/minor numbers */ | 434 | /* Extract the major/minor numbers */ |
435 | dev = MKDEV(major, minor); | 435 | dev = MKDEV(major, minor); |
436 | if (MAJOR(dev) != major || MINOR(dev) != minor) | 436 | if (MAJOR(dev) != major || MINOR(dev) != minor) |
437 | return -EOVERFLOW; | 437 | return -EOVERFLOW; |
438 | } else { | 438 | } else { |
439 | /* convert the path to a device */ | 439 | /* convert the path to a device */ |
440 | if ((r = lookup_device(path, &dev))) | 440 | if ((r = lookup_device(path, &dev))) |
441 | return r; | 441 | return r; |
442 | } | 442 | } |
443 | 443 | ||
444 | dd = find_device(&t->devices, dev); | 444 | dd = find_device(&t->devices, dev); |
445 | if (!dd) { | 445 | if (!dd) { |
446 | dd = kmalloc(sizeof(*dd), GFP_KERNEL); | 446 | dd = kmalloc(sizeof(*dd), GFP_KERNEL); |
447 | if (!dd) | 447 | if (!dd) |
448 | return -ENOMEM; | 448 | return -ENOMEM; |
449 | 449 | ||
450 | dd->mode = mode; | 450 | dd->mode = mode; |
451 | dd->bdev = NULL; | 451 | dd->bdev = NULL; |
452 | 452 | ||
453 | if ((r = open_dev(dd, dev))) { | 453 | if ((r = open_dev(dd, dev))) { |
454 | kfree(dd); | 454 | kfree(dd); |
455 | return r; | 455 | return r; |
456 | } | 456 | } |
457 | 457 | ||
458 | format_dev_t(dd->name, dev); | 458 | format_dev_t(dd->name, dev); |
459 | 459 | ||
460 | atomic_set(&dd->count, 0); | 460 | atomic_set(&dd->count, 0); |
461 | list_add(&dd->list, &t->devices); | 461 | list_add(&dd->list, &t->devices); |
462 | 462 | ||
463 | } else if (dd->mode != (mode | dd->mode)) { | 463 | } else if (dd->mode != (mode | dd->mode)) { |
464 | r = upgrade_mode(dd, mode); | 464 | r = upgrade_mode(dd, mode); |
465 | if (r) | 465 | if (r) |
466 | return r; | 466 | return r; |
467 | } | 467 | } |
468 | atomic_inc(&dd->count); | 468 | atomic_inc(&dd->count); |
469 | 469 | ||
470 | if (!check_device_area(dd, start, len)) { | 470 | if (!check_device_area(dd, start, len)) { |
471 | DMWARN("device %s too small for target", path); | 471 | DMWARN("device %s too small for target", path); |
472 | dm_put_device(ti, dd); | 472 | dm_put_device(ti, dd); |
473 | return -EINVAL; | 473 | return -EINVAL; |
474 | } | 474 | } |
475 | 475 | ||
476 | *result = dd; | 476 | *result = dd; |
477 | 477 | ||
478 | return 0; | 478 | return 0; |
479 | } | 479 | } |
480 | 480 | ||
481 | 481 | ||
482 | int dm_get_device(struct dm_target *ti, const char *path, sector_t start, | 482 | int dm_get_device(struct dm_target *ti, const char *path, sector_t start, |
483 | sector_t len, int mode, struct dm_dev **result) | 483 | sector_t len, int mode, struct dm_dev **result) |
484 | { | 484 | { |
485 | int r = __table_get_device(ti->table, ti, path, | 485 | int r = __table_get_device(ti->table, ti, path, |
486 | start, len, mode, result); | 486 | start, len, mode, result); |
487 | if (!r) { | 487 | if (!r) { |
488 | request_queue_t *q = bdev_get_queue((*result)->bdev); | 488 | request_queue_t *q = bdev_get_queue((*result)->bdev); |
489 | struct io_restrictions *rs = &ti->limits; | 489 | struct io_restrictions *rs = &ti->limits; |
490 | 490 | ||
491 | /* | 491 | /* |
492 | * Combine the device limits low. | 492 | * Combine the device limits low. |
493 | * | 493 | * |
494 | * FIXME: if we move an io_restriction struct | 494 | * FIXME: if we move an io_restriction struct |
495 | * into q this would just be a call to | 495 | * into q this would just be a call to |
496 | * combine_restrictions_low() | 496 | * combine_restrictions_low() |
497 | */ | 497 | */ |
498 | rs->max_sectors = | 498 | rs->max_sectors = |
499 | min_not_zero(rs->max_sectors, q->max_sectors); | 499 | min_not_zero(rs->max_sectors, q->max_sectors); |
500 | 500 | ||
501 | /* FIXME: Device-Mapper on top of RAID-0 breaks because DM | 501 | /* FIXME: Device-Mapper on top of RAID-0 breaks because DM |
502 | * currently doesn't honor MD's merge_bvec_fn routine. | 502 | * currently doesn't honor MD's merge_bvec_fn routine. |
503 | * In this case, we'll force DM to use PAGE_SIZE or | 503 | * In this case, we'll force DM to use PAGE_SIZE or |
504 | * smaller I/O, just to be safe. A better fix is in the | 504 | * smaller I/O, just to be safe. A better fix is in the |
505 | * works, but add this for the time being so it will at | 505 | * works, but add this for the time being so it will at |
506 | * least operate correctly. | 506 | * least operate correctly. |
507 | */ | 507 | */ |
508 | if (q->merge_bvec_fn) | 508 | if (q->merge_bvec_fn) |
509 | rs->max_sectors = | 509 | rs->max_sectors = |
510 | min_not_zero(rs->max_sectors, | 510 | min_not_zero(rs->max_sectors, |
511 | (unsigned short)(PAGE_SIZE >> 9)); | 511 | (unsigned int) (PAGE_SIZE >> 9)); |
512 | 512 | ||
513 | rs->max_phys_segments = | 513 | rs->max_phys_segments = |
514 | min_not_zero(rs->max_phys_segments, | 514 | min_not_zero(rs->max_phys_segments, |
515 | q->max_phys_segments); | 515 | q->max_phys_segments); |
516 | 516 | ||
517 | rs->max_hw_segments = | 517 | rs->max_hw_segments = |
518 | min_not_zero(rs->max_hw_segments, q->max_hw_segments); | 518 | min_not_zero(rs->max_hw_segments, q->max_hw_segments); |
519 | 519 | ||
520 | rs->hardsect_size = max(rs->hardsect_size, q->hardsect_size); | 520 | rs->hardsect_size = max(rs->hardsect_size, q->hardsect_size); |
521 | 521 | ||
522 | rs->max_segment_size = | 522 | rs->max_segment_size = |
523 | min_not_zero(rs->max_segment_size, q->max_segment_size); | 523 | min_not_zero(rs->max_segment_size, q->max_segment_size); |
524 | 524 | ||
525 | rs->seg_boundary_mask = | 525 | rs->seg_boundary_mask = |
526 | min_not_zero(rs->seg_boundary_mask, | 526 | min_not_zero(rs->seg_boundary_mask, |
527 | q->seg_boundary_mask); | 527 | q->seg_boundary_mask); |
528 | } | 528 | } |
529 | 529 | ||
530 | return r; | 530 | return r; |
531 | } | 531 | } |
532 | 532 | ||
533 | /* | 533 | /* |
534 | * Decrement a devices use count and remove it if necessary. | 534 | * Decrement a devices use count and remove it if necessary. |
535 | */ | 535 | */ |
536 | void dm_put_device(struct dm_target *ti, struct dm_dev *dd) | 536 | void dm_put_device(struct dm_target *ti, struct dm_dev *dd) |
537 | { | 537 | { |
538 | if (atomic_dec_and_test(&dd->count)) { | 538 | if (atomic_dec_and_test(&dd->count)) { |
539 | close_dev(dd); | 539 | close_dev(dd); |
540 | list_del(&dd->list); | 540 | list_del(&dd->list); |
541 | kfree(dd); | 541 | kfree(dd); |
542 | } | 542 | } |
543 | } | 543 | } |
544 | 544 | ||
545 | /* | 545 | /* |
546 | * Checks to see if the target joins onto the end of the table. | 546 | * Checks to see if the target joins onto the end of the table. |
547 | */ | 547 | */ |
548 | static int adjoin(struct dm_table *table, struct dm_target *ti) | 548 | static int adjoin(struct dm_table *table, struct dm_target *ti) |
549 | { | 549 | { |
550 | struct dm_target *prev; | 550 | struct dm_target *prev; |
551 | 551 | ||
552 | if (!table->num_targets) | 552 | if (!table->num_targets) |
553 | return !ti->begin; | 553 | return !ti->begin; |
554 | 554 | ||
555 | prev = &table->targets[table->num_targets - 1]; | 555 | prev = &table->targets[table->num_targets - 1]; |
556 | return (ti->begin == (prev->begin + prev->len)); | 556 | return (ti->begin == (prev->begin + prev->len)); |
557 | } | 557 | } |
558 | 558 | ||
559 | /* | 559 | /* |
560 | * Used to dynamically allocate the arg array. | 560 | * Used to dynamically allocate the arg array. |
561 | */ | 561 | */ |
562 | static char **realloc_argv(unsigned *array_size, char **old_argv) | 562 | static char **realloc_argv(unsigned *array_size, char **old_argv) |
563 | { | 563 | { |
564 | char **argv; | 564 | char **argv; |
565 | unsigned new_size; | 565 | unsigned new_size; |
566 | 566 | ||
567 | new_size = *array_size ? *array_size * 2 : 64; | 567 | new_size = *array_size ? *array_size * 2 : 64; |
568 | argv = kmalloc(new_size * sizeof(*argv), GFP_KERNEL); | 568 | argv = kmalloc(new_size * sizeof(*argv), GFP_KERNEL); |
569 | if (argv) { | 569 | if (argv) { |
570 | memcpy(argv, old_argv, *array_size * sizeof(*argv)); | 570 | memcpy(argv, old_argv, *array_size * sizeof(*argv)); |
571 | *array_size = new_size; | 571 | *array_size = new_size; |
572 | } | 572 | } |
573 | 573 | ||
574 | kfree(old_argv); | 574 | kfree(old_argv); |
575 | return argv; | 575 | return argv; |
576 | } | 576 | } |
577 | 577 | ||
578 | /* | 578 | /* |
579 | * Destructively splits up the argument list to pass to ctr. | 579 | * Destructively splits up the argument list to pass to ctr. |
580 | */ | 580 | */ |
581 | int dm_split_args(int *argc, char ***argvp, char *input) | 581 | int dm_split_args(int *argc, char ***argvp, char *input) |
582 | { | 582 | { |
583 | char *start, *end = input, *out, **argv = NULL; | 583 | char *start, *end = input, *out, **argv = NULL; |
584 | unsigned array_size = 0; | 584 | unsigned array_size = 0; |
585 | 585 | ||
586 | *argc = 0; | 586 | *argc = 0; |
587 | argv = realloc_argv(&array_size, argv); | 587 | argv = realloc_argv(&array_size, argv); |
588 | if (!argv) | 588 | if (!argv) |
589 | return -ENOMEM; | 589 | return -ENOMEM; |
590 | 590 | ||
591 | while (1) { | 591 | while (1) { |
592 | start = end; | 592 | start = end; |
593 | 593 | ||
594 | /* Skip whitespace */ | 594 | /* Skip whitespace */ |
595 | while (*start && isspace(*start)) | 595 | while (*start && isspace(*start)) |
596 | start++; | 596 | start++; |
597 | 597 | ||
598 | if (!*start) | 598 | if (!*start) |
599 | break; /* success, we hit the end */ | 599 | break; /* success, we hit the end */ |
600 | 600 | ||
601 | /* 'out' is used to remove any back-quotes */ | 601 | /* 'out' is used to remove any back-quotes */ |
602 | end = out = start; | 602 | end = out = start; |
603 | while (*end) { | 603 | while (*end) { |
604 | /* Everything apart from '\0' can be quoted */ | 604 | /* Everything apart from '\0' can be quoted */ |
605 | if (*end == '\\' && *(end + 1)) { | 605 | if (*end == '\\' && *(end + 1)) { |
606 | *out++ = *(end + 1); | 606 | *out++ = *(end + 1); |
607 | end += 2; | 607 | end += 2; |
608 | continue; | 608 | continue; |
609 | } | 609 | } |
610 | 610 | ||
611 | if (isspace(*end)) | 611 | if (isspace(*end)) |
612 | break; /* end of token */ | 612 | break; /* end of token */ |
613 | 613 | ||
614 | *out++ = *end++; | 614 | *out++ = *end++; |
615 | } | 615 | } |
616 | 616 | ||
617 | /* have we already filled the array ? */ | 617 | /* have we already filled the array ? */ |
618 | if ((*argc + 1) > array_size) { | 618 | if ((*argc + 1) > array_size) { |
619 | argv = realloc_argv(&array_size, argv); | 619 | argv = realloc_argv(&array_size, argv); |
620 | if (!argv) | 620 | if (!argv) |
621 | return -ENOMEM; | 621 | return -ENOMEM; |
622 | } | 622 | } |
623 | 623 | ||
624 | /* we know this is whitespace */ | 624 | /* we know this is whitespace */ |
625 | if (*end) | 625 | if (*end) |
626 | end++; | 626 | end++; |
627 | 627 | ||
628 | /* terminate the string and put it in the array */ | 628 | /* terminate the string and put it in the array */ |
629 | *out = '\0'; | 629 | *out = '\0'; |
630 | argv[*argc] = start; | 630 | argv[*argc] = start; |
631 | (*argc)++; | 631 | (*argc)++; |
632 | } | 632 | } |
633 | 633 | ||
634 | *argvp = argv; | 634 | *argvp = argv; |
635 | return 0; | 635 | return 0; |
636 | } | 636 | } |
637 | 637 | ||
638 | static void check_for_valid_limits(struct io_restrictions *rs) | 638 | static void check_for_valid_limits(struct io_restrictions *rs) |
639 | { | 639 | { |
640 | if (!rs->max_sectors) | 640 | if (!rs->max_sectors) |
641 | rs->max_sectors = SAFE_MAX_SECTORS; | 641 | rs->max_sectors = SAFE_MAX_SECTORS; |
642 | if (!rs->max_phys_segments) | 642 | if (!rs->max_phys_segments) |
643 | rs->max_phys_segments = MAX_PHYS_SEGMENTS; | 643 | rs->max_phys_segments = MAX_PHYS_SEGMENTS; |
644 | if (!rs->max_hw_segments) | 644 | if (!rs->max_hw_segments) |
645 | rs->max_hw_segments = MAX_HW_SEGMENTS; | 645 | rs->max_hw_segments = MAX_HW_SEGMENTS; |
646 | if (!rs->hardsect_size) | 646 | if (!rs->hardsect_size) |
647 | rs->hardsect_size = 1 << SECTOR_SHIFT; | 647 | rs->hardsect_size = 1 << SECTOR_SHIFT; |
648 | if (!rs->max_segment_size) | 648 | if (!rs->max_segment_size) |
649 | rs->max_segment_size = MAX_SEGMENT_SIZE; | 649 | rs->max_segment_size = MAX_SEGMENT_SIZE; |
650 | if (!rs->seg_boundary_mask) | 650 | if (!rs->seg_boundary_mask) |
651 | rs->seg_boundary_mask = -1; | 651 | rs->seg_boundary_mask = -1; |
652 | } | 652 | } |
653 | 653 | ||
654 | int dm_table_add_target(struct dm_table *t, const char *type, | 654 | int dm_table_add_target(struct dm_table *t, const char *type, |
655 | sector_t start, sector_t len, char *params) | 655 | sector_t start, sector_t len, char *params) |
656 | { | 656 | { |
657 | int r = -EINVAL, argc; | 657 | int r = -EINVAL, argc; |
658 | char **argv; | 658 | char **argv; |
659 | struct dm_target *tgt; | 659 | struct dm_target *tgt; |
660 | 660 | ||
661 | if ((r = check_space(t))) | 661 | if ((r = check_space(t))) |
662 | return r; | 662 | return r; |
663 | 663 | ||
664 | tgt = t->targets + t->num_targets; | 664 | tgt = t->targets + t->num_targets; |
665 | memset(tgt, 0, sizeof(*tgt)); | 665 | memset(tgt, 0, sizeof(*tgt)); |
666 | 666 | ||
667 | if (!len) { | 667 | if (!len) { |
668 | tgt->error = "zero-length target"; | 668 | tgt->error = "zero-length target"; |
669 | DMERR("%s", tgt->error); | 669 | DMERR("%s", tgt->error); |
670 | return -EINVAL; | 670 | return -EINVAL; |
671 | } | 671 | } |
672 | 672 | ||
673 | tgt->type = dm_get_target_type(type); | 673 | tgt->type = dm_get_target_type(type); |
674 | if (!tgt->type) { | 674 | if (!tgt->type) { |
675 | tgt->error = "unknown target type"; | 675 | tgt->error = "unknown target type"; |
676 | DMERR("%s", tgt->error); | 676 | DMERR("%s", tgt->error); |
677 | return -EINVAL; | 677 | return -EINVAL; |
678 | } | 678 | } |
679 | 679 | ||
680 | tgt->table = t; | 680 | tgt->table = t; |
681 | tgt->begin = start; | 681 | tgt->begin = start; |
682 | tgt->len = len; | 682 | tgt->len = len; |
683 | tgt->error = "Unknown error"; | 683 | tgt->error = "Unknown error"; |
684 | 684 | ||
685 | /* | 685 | /* |
686 | * Does this target adjoin the previous one ? | 686 | * Does this target adjoin the previous one ? |
687 | */ | 687 | */ |
688 | if (!adjoin(t, tgt)) { | 688 | if (!adjoin(t, tgt)) { |
689 | tgt->error = "Gap in table"; | 689 | tgt->error = "Gap in table"; |
690 | r = -EINVAL; | 690 | r = -EINVAL; |
691 | goto bad; | 691 | goto bad; |
692 | } | 692 | } |
693 | 693 | ||
694 | r = dm_split_args(&argc, &argv, params); | 694 | r = dm_split_args(&argc, &argv, params); |
695 | if (r) { | 695 | if (r) { |
696 | tgt->error = "couldn't split parameters (insufficient memory)"; | 696 | tgt->error = "couldn't split parameters (insufficient memory)"; |
697 | goto bad; | 697 | goto bad; |
698 | } | 698 | } |
699 | 699 | ||
700 | r = tgt->type->ctr(tgt, argc, argv); | 700 | r = tgt->type->ctr(tgt, argc, argv); |
701 | kfree(argv); | 701 | kfree(argv); |
702 | if (r) | 702 | if (r) |
703 | goto bad; | 703 | goto bad; |
704 | 704 | ||
705 | t->highs[t->num_targets++] = tgt->begin + tgt->len - 1; | 705 | t->highs[t->num_targets++] = tgt->begin + tgt->len - 1; |
706 | 706 | ||
707 | /* FIXME: the plan is to combine high here and then have | 707 | /* FIXME: the plan is to combine high here and then have |
708 | * the merge fn apply the target level restrictions. */ | 708 | * the merge fn apply the target level restrictions. */ |
709 | combine_restrictions_low(&t->limits, &tgt->limits); | 709 | combine_restrictions_low(&t->limits, &tgt->limits); |
710 | return 0; | 710 | return 0; |
711 | 711 | ||
712 | bad: | 712 | bad: |
713 | DMERR("%s", tgt->error); | 713 | DMERR("%s", tgt->error); |
714 | dm_put_target_type(tgt->type); | 714 | dm_put_target_type(tgt->type); |
715 | return r; | 715 | return r; |
716 | } | 716 | } |
717 | 717 | ||
718 | static int setup_indexes(struct dm_table *t) | 718 | static int setup_indexes(struct dm_table *t) |
719 | { | 719 | { |
720 | int i; | 720 | int i; |
721 | unsigned int total = 0; | 721 | unsigned int total = 0; |
722 | sector_t *indexes; | 722 | sector_t *indexes; |
723 | 723 | ||
724 | /* allocate the space for *all* the indexes */ | 724 | /* allocate the space for *all* the indexes */ |
725 | for (i = t->depth - 2; i >= 0; i--) { | 725 | for (i = t->depth - 2; i >= 0; i--) { |
726 | t->counts[i] = dm_div_up(t->counts[i + 1], CHILDREN_PER_NODE); | 726 | t->counts[i] = dm_div_up(t->counts[i + 1], CHILDREN_PER_NODE); |
727 | total += t->counts[i]; | 727 | total += t->counts[i]; |
728 | } | 728 | } |
729 | 729 | ||
730 | indexes = (sector_t *) dm_vcalloc(total, (unsigned long) NODE_SIZE); | 730 | indexes = (sector_t *) dm_vcalloc(total, (unsigned long) NODE_SIZE); |
731 | if (!indexes) | 731 | if (!indexes) |
732 | return -ENOMEM; | 732 | return -ENOMEM; |
733 | 733 | ||
734 | /* set up internal nodes, bottom-up */ | 734 | /* set up internal nodes, bottom-up */ |
735 | for (i = t->depth - 2, total = 0; i >= 0; i--) { | 735 | for (i = t->depth - 2, total = 0; i >= 0; i--) { |
736 | t->index[i] = indexes; | 736 | t->index[i] = indexes; |
737 | indexes += (KEYS_PER_NODE * t->counts[i]); | 737 | indexes += (KEYS_PER_NODE * t->counts[i]); |
738 | setup_btree_index(i, t); | 738 | setup_btree_index(i, t); |
739 | } | 739 | } |
740 | 740 | ||
741 | return 0; | 741 | return 0; |
742 | } | 742 | } |
743 | 743 | ||
744 | /* | 744 | /* |
745 | * Builds the btree to index the map. | 745 | * Builds the btree to index the map. |
746 | */ | 746 | */ |
747 | int dm_table_complete(struct dm_table *t) | 747 | int dm_table_complete(struct dm_table *t) |
748 | { | 748 | { |
749 | int r = 0; | 749 | int r = 0; |
750 | unsigned int leaf_nodes; | 750 | unsigned int leaf_nodes; |
751 | 751 | ||
752 | check_for_valid_limits(&t->limits); | 752 | check_for_valid_limits(&t->limits); |
753 | 753 | ||
754 | /* how many indexes will the btree have ? */ | 754 | /* how many indexes will the btree have ? */ |
755 | leaf_nodes = dm_div_up(t->num_targets, KEYS_PER_NODE); | 755 | leaf_nodes = dm_div_up(t->num_targets, KEYS_PER_NODE); |
756 | t->depth = 1 + int_log(leaf_nodes, CHILDREN_PER_NODE); | 756 | t->depth = 1 + int_log(leaf_nodes, CHILDREN_PER_NODE); |
757 | 757 | ||
758 | /* leaf layer has already been set up */ | 758 | /* leaf layer has already been set up */ |
759 | t->counts[t->depth - 1] = leaf_nodes; | 759 | t->counts[t->depth - 1] = leaf_nodes; |
760 | t->index[t->depth - 1] = t->highs; | 760 | t->index[t->depth - 1] = t->highs; |
761 | 761 | ||
762 | if (t->depth >= 2) | 762 | if (t->depth >= 2) |
763 | r = setup_indexes(t); | 763 | r = setup_indexes(t); |
764 | 764 | ||
765 | return r; | 765 | return r; |
766 | } | 766 | } |
767 | 767 | ||
768 | static DECLARE_MUTEX(_event_lock); | 768 | static DECLARE_MUTEX(_event_lock); |
769 | void dm_table_event_callback(struct dm_table *t, | 769 | void dm_table_event_callback(struct dm_table *t, |
770 | void (*fn)(void *), void *context) | 770 | void (*fn)(void *), void *context) |
771 | { | 771 | { |
772 | down(&_event_lock); | 772 | down(&_event_lock); |
773 | t->event_fn = fn; | 773 | t->event_fn = fn; |
774 | t->event_context = context; | 774 | t->event_context = context; |
775 | up(&_event_lock); | 775 | up(&_event_lock); |
776 | } | 776 | } |
777 | 777 | ||
778 | void dm_table_event(struct dm_table *t) | 778 | void dm_table_event(struct dm_table *t) |
779 | { | 779 | { |
780 | /* | 780 | /* |
781 | * You can no longer call dm_table_event() from interrupt | 781 | * You can no longer call dm_table_event() from interrupt |
782 | * context, use a bottom half instead. | 782 | * context, use a bottom half instead. |
783 | */ | 783 | */ |
784 | BUG_ON(in_interrupt()); | 784 | BUG_ON(in_interrupt()); |
785 | 785 | ||
786 | down(&_event_lock); | 786 | down(&_event_lock); |
787 | if (t->event_fn) | 787 | if (t->event_fn) |
788 | t->event_fn(t->event_context); | 788 | t->event_fn(t->event_context); |
789 | up(&_event_lock); | 789 | up(&_event_lock); |
790 | } | 790 | } |
791 | 791 | ||
792 | sector_t dm_table_get_size(struct dm_table *t) | 792 | sector_t dm_table_get_size(struct dm_table *t) |
793 | { | 793 | { |
794 | return t->num_targets ? (t->highs[t->num_targets - 1] + 1) : 0; | 794 | return t->num_targets ? (t->highs[t->num_targets - 1] + 1) : 0; |
795 | } | 795 | } |
796 | 796 | ||
797 | struct dm_target *dm_table_get_target(struct dm_table *t, unsigned int index) | 797 | struct dm_target *dm_table_get_target(struct dm_table *t, unsigned int index) |
798 | { | 798 | { |
799 | if (index > t->num_targets) | 799 | if (index > t->num_targets) |
800 | return NULL; | 800 | return NULL; |
801 | 801 | ||
802 | return t->targets + index; | 802 | return t->targets + index; |
803 | } | 803 | } |
804 | 804 | ||
805 | /* | 805 | /* |
806 | * Search the btree for the correct target. | 806 | * Search the btree for the correct target. |
807 | */ | 807 | */ |
808 | struct dm_target *dm_table_find_target(struct dm_table *t, sector_t sector) | 808 | struct dm_target *dm_table_find_target(struct dm_table *t, sector_t sector) |
809 | { | 809 | { |
810 | unsigned int l, n = 0, k = 0; | 810 | unsigned int l, n = 0, k = 0; |
811 | sector_t *node; | 811 | sector_t *node; |
812 | 812 | ||
813 | for (l = 0; l < t->depth; l++) { | 813 | for (l = 0; l < t->depth; l++) { |
814 | n = get_child(n, k); | 814 | n = get_child(n, k); |
815 | node = get_node(t, l, n); | 815 | node = get_node(t, l, n); |
816 | 816 | ||
817 | for (k = 0; k < KEYS_PER_NODE; k++) | 817 | for (k = 0; k < KEYS_PER_NODE; k++) |
818 | if (node[k] >= sector) | 818 | if (node[k] >= sector) |
819 | break; | 819 | break; |
820 | } | 820 | } |
821 | 821 | ||
822 | return &t->targets[(KEYS_PER_NODE * n) + k]; | 822 | return &t->targets[(KEYS_PER_NODE * n) + k]; |
823 | } | 823 | } |
824 | 824 | ||
825 | void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q) | 825 | void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q) |
826 | { | 826 | { |
827 | /* | 827 | /* |
828 | * Make sure we obey the optimistic sub devices | 828 | * Make sure we obey the optimistic sub devices |
829 | * restrictions. | 829 | * restrictions. |
830 | */ | 830 | */ |
831 | blk_queue_max_sectors(q, t->limits.max_sectors); | 831 | blk_queue_max_sectors(q, t->limits.max_sectors); |
832 | q->max_phys_segments = t->limits.max_phys_segments; | 832 | q->max_phys_segments = t->limits.max_phys_segments; |
833 | q->max_hw_segments = t->limits.max_hw_segments; | 833 | q->max_hw_segments = t->limits.max_hw_segments; |
834 | q->hardsect_size = t->limits.hardsect_size; | 834 | q->hardsect_size = t->limits.hardsect_size; |
835 | q->max_segment_size = t->limits.max_segment_size; | 835 | q->max_segment_size = t->limits.max_segment_size; |
836 | q->seg_boundary_mask = t->limits.seg_boundary_mask; | 836 | q->seg_boundary_mask = t->limits.seg_boundary_mask; |
837 | } | 837 | } |
838 | 838 | ||
839 | unsigned int dm_table_get_num_targets(struct dm_table *t) | 839 | unsigned int dm_table_get_num_targets(struct dm_table *t) |
840 | { | 840 | { |
841 | return t->num_targets; | 841 | return t->num_targets; |
842 | } | 842 | } |
843 | 843 | ||
844 | struct list_head *dm_table_get_devices(struct dm_table *t) | 844 | struct list_head *dm_table_get_devices(struct dm_table *t) |
845 | { | 845 | { |
846 | return &t->devices; | 846 | return &t->devices; |
847 | } | 847 | } |
848 | 848 | ||
849 | int dm_table_get_mode(struct dm_table *t) | 849 | int dm_table_get_mode(struct dm_table *t) |
850 | { | 850 | { |
851 | return t->mode; | 851 | return t->mode; |
852 | } | 852 | } |
853 | 853 | ||
854 | static void suspend_targets(struct dm_table *t, unsigned postsuspend) | 854 | static void suspend_targets(struct dm_table *t, unsigned postsuspend) |
855 | { | 855 | { |
856 | int i = t->num_targets; | 856 | int i = t->num_targets; |
857 | struct dm_target *ti = t->targets; | 857 | struct dm_target *ti = t->targets; |
858 | 858 | ||
859 | while (i--) { | 859 | while (i--) { |
860 | if (postsuspend) { | 860 | if (postsuspend) { |
861 | if (ti->type->postsuspend) | 861 | if (ti->type->postsuspend) |
862 | ti->type->postsuspend(ti); | 862 | ti->type->postsuspend(ti); |
863 | } else if (ti->type->presuspend) | 863 | } else if (ti->type->presuspend) |
864 | ti->type->presuspend(ti); | 864 | ti->type->presuspend(ti); |
865 | 865 | ||
866 | ti++; | 866 | ti++; |
867 | } | 867 | } |
868 | } | 868 | } |
869 | 869 | ||
870 | void dm_table_presuspend_targets(struct dm_table *t) | 870 | void dm_table_presuspend_targets(struct dm_table *t) |
871 | { | 871 | { |
872 | if (!t) | 872 | if (!t) |
873 | return; | 873 | return; |
874 | 874 | ||
875 | return suspend_targets(t, 0); | 875 | return suspend_targets(t, 0); |
876 | } | 876 | } |
877 | 877 | ||
878 | void dm_table_postsuspend_targets(struct dm_table *t) | 878 | void dm_table_postsuspend_targets(struct dm_table *t) |
879 | { | 879 | { |
880 | if (!t) | 880 | if (!t) |
881 | return; | 881 | return; |
882 | 882 | ||
883 | return suspend_targets(t, 1); | 883 | return suspend_targets(t, 1); |
884 | } | 884 | } |
885 | 885 | ||
886 | void dm_table_resume_targets(struct dm_table *t) | 886 | void dm_table_resume_targets(struct dm_table *t) |
887 | { | 887 | { |
888 | int i; | 888 | int i; |
889 | 889 | ||
890 | for (i = 0; i < t->num_targets; i++) { | 890 | for (i = 0; i < t->num_targets; i++) { |
891 | struct dm_target *ti = t->targets + i; | 891 | struct dm_target *ti = t->targets + i; |
892 | 892 | ||
893 | if (ti->type->resume) | 893 | if (ti->type->resume) |
894 | ti->type->resume(ti); | 894 | ti->type->resume(ti); |
895 | } | 895 | } |
896 | } | 896 | } |
897 | 897 | ||
898 | int dm_table_any_congested(struct dm_table *t, int bdi_bits) | 898 | int dm_table_any_congested(struct dm_table *t, int bdi_bits) |
899 | { | 899 | { |
900 | struct list_head *d, *devices; | 900 | struct list_head *d, *devices; |
901 | int r = 0; | 901 | int r = 0; |
902 | 902 | ||
903 | devices = dm_table_get_devices(t); | 903 | devices = dm_table_get_devices(t); |
904 | for (d = devices->next; d != devices; d = d->next) { | 904 | for (d = devices->next; d != devices; d = d->next) { |
905 | struct dm_dev *dd = list_entry(d, struct dm_dev, list); | 905 | struct dm_dev *dd = list_entry(d, struct dm_dev, list); |
906 | request_queue_t *q = bdev_get_queue(dd->bdev); | 906 | request_queue_t *q = bdev_get_queue(dd->bdev); |
907 | r |= bdi_congested(&q->backing_dev_info, bdi_bits); | 907 | r |= bdi_congested(&q->backing_dev_info, bdi_bits); |
908 | } | 908 | } |
909 | 909 | ||
910 | return r; | 910 | return r; |
911 | } | 911 | } |
912 | 912 | ||
913 | void dm_table_unplug_all(struct dm_table *t) | 913 | void dm_table_unplug_all(struct dm_table *t) |
914 | { | 914 | { |
915 | struct list_head *d, *devices = dm_table_get_devices(t); | 915 | struct list_head *d, *devices = dm_table_get_devices(t); |
916 | 916 | ||
917 | for (d = devices->next; d != devices; d = d->next) { | 917 | for (d = devices->next; d != devices; d = d->next) { |
918 | struct dm_dev *dd = list_entry(d, struct dm_dev, list); | 918 | struct dm_dev *dd = list_entry(d, struct dm_dev, list); |
919 | request_queue_t *q = bdev_get_queue(dd->bdev); | 919 | request_queue_t *q = bdev_get_queue(dd->bdev); |
920 | 920 | ||
921 | if (q->unplug_fn) | 921 | if (q->unplug_fn) |
922 | q->unplug_fn(q); | 922 | q->unplug_fn(q); |
923 | } | 923 | } |
924 | } | 924 | } |
925 | 925 | ||
926 | int dm_table_flush_all(struct dm_table *t) | 926 | int dm_table_flush_all(struct dm_table *t) |
927 | { | 927 | { |
928 | struct list_head *d, *devices = dm_table_get_devices(t); | 928 | struct list_head *d, *devices = dm_table_get_devices(t); |
929 | int ret = 0; | 929 | int ret = 0; |
930 | 930 | ||
931 | for (d = devices->next; d != devices; d = d->next) { | 931 | for (d = devices->next; d != devices; d = d->next) { |
932 | struct dm_dev *dd = list_entry(d, struct dm_dev, list); | 932 | struct dm_dev *dd = list_entry(d, struct dm_dev, list); |
933 | request_queue_t *q = bdev_get_queue(dd->bdev); | 933 | request_queue_t *q = bdev_get_queue(dd->bdev); |
934 | int err; | 934 | int err; |
935 | 935 | ||
936 | if (!q->issue_flush_fn) | 936 | if (!q->issue_flush_fn) |
937 | err = -EOPNOTSUPP; | 937 | err = -EOPNOTSUPP; |
938 | else | 938 | else |
939 | err = q->issue_flush_fn(q, dd->bdev->bd_disk, NULL); | 939 | err = q->issue_flush_fn(q, dd->bdev->bd_disk, NULL); |
940 | 940 | ||
941 | if (!ret) | 941 | if (!ret) |
942 | ret = err; | 942 | ret = err; |
943 | } | 943 | } |
944 | 944 | ||
945 | return ret; | 945 | return ret; |
946 | } | 946 | } |
947 | 947 | ||
948 | EXPORT_SYMBOL(dm_vcalloc); | 948 | EXPORT_SYMBOL(dm_vcalloc); |
949 | EXPORT_SYMBOL(dm_get_device); | 949 | EXPORT_SYMBOL(dm_get_device); |
950 | EXPORT_SYMBOL(dm_put_device); | 950 | EXPORT_SYMBOL(dm_put_device); |
951 | EXPORT_SYMBOL(dm_table_event); | 951 | EXPORT_SYMBOL(dm_table_event); |
952 | EXPORT_SYMBOL(dm_table_get_size); | 952 | EXPORT_SYMBOL(dm_table_get_size); |
953 | EXPORT_SYMBOL(dm_table_get_mode); | 953 | EXPORT_SYMBOL(dm_table_get_mode); |
954 | EXPORT_SYMBOL(dm_table_put); | 954 | EXPORT_SYMBOL(dm_table_put); |
955 | EXPORT_SYMBOL(dm_table_get); | 955 | EXPORT_SYMBOL(dm_table_get); |
956 | EXPORT_SYMBOL(dm_table_unplug_all); | 956 | EXPORT_SYMBOL(dm_table_unplug_all); |
957 | EXPORT_SYMBOL(dm_table_flush_all); | 957 | EXPORT_SYMBOL(dm_table_flush_all); |
958 | 958 |
include/linux/device-mapper.h
1 | /* | 1 | /* |
2 | * Copyright (C) 2001 Sistina Software (UK) Limited. | 2 | * Copyright (C) 2001 Sistina Software (UK) Limited. |
3 | * Copyright (C) 2004 Red Hat, Inc. All rights reserved. | 3 | * Copyright (C) 2004 Red Hat, Inc. All rights reserved. |
4 | * | 4 | * |
5 | * This file is released under the LGPL. | 5 | * This file is released under the LGPL. |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #ifndef _LINUX_DEVICE_MAPPER_H | 8 | #ifndef _LINUX_DEVICE_MAPPER_H |
9 | #define _LINUX_DEVICE_MAPPER_H | 9 | #define _LINUX_DEVICE_MAPPER_H |
10 | 10 | ||
11 | struct dm_target; | 11 | struct dm_target; |
12 | struct dm_table; | 12 | struct dm_table; |
13 | struct dm_dev; | 13 | struct dm_dev; |
14 | 14 | ||
15 | typedef enum { STATUSTYPE_INFO, STATUSTYPE_TABLE } status_type_t; | 15 | typedef enum { STATUSTYPE_INFO, STATUSTYPE_TABLE } status_type_t; |
16 | 16 | ||
17 | union map_info { | 17 | union map_info { |
18 | void *ptr; | 18 | void *ptr; |
19 | unsigned long long ll; | 19 | unsigned long long ll; |
20 | }; | 20 | }; |
21 | 21 | ||
22 | /* | 22 | /* |
23 | * In the constructor the target parameter will already have the | 23 | * In the constructor the target parameter will already have the |
24 | * table, type, begin and len fields filled in. | 24 | * table, type, begin and len fields filled in. |
25 | */ | 25 | */ |
26 | typedef int (*dm_ctr_fn) (struct dm_target *target, | 26 | typedef int (*dm_ctr_fn) (struct dm_target *target, |
27 | unsigned int argc, char **argv); | 27 | unsigned int argc, char **argv); |
28 | 28 | ||
29 | /* | 29 | /* |
30 | * The destructor doesn't need to free the dm_target, just | 30 | * The destructor doesn't need to free the dm_target, just |
31 | * anything hidden ti->private. | 31 | * anything hidden ti->private. |
32 | */ | 32 | */ |
33 | typedef void (*dm_dtr_fn) (struct dm_target *ti); | 33 | typedef void (*dm_dtr_fn) (struct dm_target *ti); |
34 | 34 | ||
35 | /* | 35 | /* |
36 | * The map function must return: | 36 | * The map function must return: |
37 | * < 0: error | 37 | * < 0: error |
38 | * = 0: The target will handle the io by resubmitting it later | 38 | * = 0: The target will handle the io by resubmitting it later |
39 | * > 0: simple remap complete | 39 | * > 0: simple remap complete |
40 | */ | 40 | */ |
41 | typedef int (*dm_map_fn) (struct dm_target *ti, struct bio *bio, | 41 | typedef int (*dm_map_fn) (struct dm_target *ti, struct bio *bio, |
42 | union map_info *map_context); | 42 | union map_info *map_context); |
43 | 43 | ||
44 | /* | 44 | /* |
45 | * Returns: | 45 | * Returns: |
46 | * < 0 : error (currently ignored) | 46 | * < 0 : error (currently ignored) |
47 | * 0 : ended successfully | 47 | * 0 : ended successfully |
48 | * 1 : for some reason the io has still not completed (eg, | 48 | * 1 : for some reason the io has still not completed (eg, |
49 | * multipath target might want to requeue a failed io). | 49 | * multipath target might want to requeue a failed io). |
50 | */ | 50 | */ |
51 | typedef int (*dm_endio_fn) (struct dm_target *ti, | 51 | typedef int (*dm_endio_fn) (struct dm_target *ti, |
52 | struct bio *bio, int error, | 52 | struct bio *bio, int error, |
53 | union map_info *map_context); | 53 | union map_info *map_context); |
54 | 54 | ||
55 | typedef void (*dm_presuspend_fn) (struct dm_target *ti); | 55 | typedef void (*dm_presuspend_fn) (struct dm_target *ti); |
56 | typedef void (*dm_postsuspend_fn) (struct dm_target *ti); | 56 | typedef void (*dm_postsuspend_fn) (struct dm_target *ti); |
57 | typedef void (*dm_resume_fn) (struct dm_target *ti); | 57 | typedef void (*dm_resume_fn) (struct dm_target *ti); |
58 | 58 | ||
59 | typedef int (*dm_status_fn) (struct dm_target *ti, status_type_t status_type, | 59 | typedef int (*dm_status_fn) (struct dm_target *ti, status_type_t status_type, |
60 | char *result, unsigned int maxlen); | 60 | char *result, unsigned int maxlen); |
61 | 61 | ||
62 | typedef int (*dm_message_fn) (struct dm_target *ti, unsigned argc, char **argv); | 62 | typedef int (*dm_message_fn) (struct dm_target *ti, unsigned argc, char **argv); |
63 | 63 | ||
64 | void dm_error(const char *message); | 64 | void dm_error(const char *message); |
65 | 65 | ||
66 | /* | 66 | /* |
67 | * Constructors should call these functions to ensure destination devices | 67 | * Constructors should call these functions to ensure destination devices |
68 | * are opened/closed correctly. | 68 | * are opened/closed correctly. |
69 | * FIXME: too many arguments. | 69 | * FIXME: too many arguments. |
70 | */ | 70 | */ |
71 | int dm_get_device(struct dm_target *ti, const char *path, sector_t start, | 71 | int dm_get_device(struct dm_target *ti, const char *path, sector_t start, |
72 | sector_t len, int mode, struct dm_dev **result); | 72 | sector_t len, int mode, struct dm_dev **result); |
73 | void dm_put_device(struct dm_target *ti, struct dm_dev *d); | 73 | void dm_put_device(struct dm_target *ti, struct dm_dev *d); |
74 | 74 | ||
75 | /* | 75 | /* |
76 | * Information about a target type | 76 | * Information about a target type |
77 | */ | 77 | */ |
78 | struct target_type { | 78 | struct target_type { |
79 | const char *name; | 79 | const char *name; |
80 | struct module *module; | 80 | struct module *module; |
81 | unsigned version[3]; | 81 | unsigned version[3]; |
82 | dm_ctr_fn ctr; | 82 | dm_ctr_fn ctr; |
83 | dm_dtr_fn dtr; | 83 | dm_dtr_fn dtr; |
84 | dm_map_fn map; | 84 | dm_map_fn map; |
85 | dm_endio_fn end_io; | 85 | dm_endio_fn end_io; |
86 | dm_presuspend_fn presuspend; | 86 | dm_presuspend_fn presuspend; |
87 | dm_postsuspend_fn postsuspend; | 87 | dm_postsuspend_fn postsuspend; |
88 | dm_resume_fn resume; | 88 | dm_resume_fn resume; |
89 | dm_status_fn status; | 89 | dm_status_fn status; |
90 | dm_message_fn message; | 90 | dm_message_fn message; |
91 | }; | 91 | }; |
92 | 92 | ||
93 | struct io_restrictions { | 93 | struct io_restrictions { |
94 | unsigned short max_sectors; | 94 | unsigned int max_sectors; |
95 | unsigned short max_phys_segments; | 95 | unsigned short max_phys_segments; |
96 | unsigned short max_hw_segments; | 96 | unsigned short max_hw_segments; |
97 | unsigned short hardsect_size; | 97 | unsigned short hardsect_size; |
98 | unsigned int max_segment_size; | 98 | unsigned int max_segment_size; |
99 | unsigned long seg_boundary_mask; | 99 | unsigned long seg_boundary_mask; |
100 | }; | 100 | }; |
101 | 101 | ||
102 | struct dm_target { | 102 | struct dm_target { |
103 | struct dm_table *table; | 103 | struct dm_table *table; |
104 | struct target_type *type; | 104 | struct target_type *type; |
105 | 105 | ||
106 | /* target limits */ | 106 | /* target limits */ |
107 | sector_t begin; | 107 | sector_t begin; |
108 | sector_t len; | 108 | sector_t len; |
109 | 109 | ||
110 | /* FIXME: turn this into a mask, and merge with io_restrictions */ | 110 | /* FIXME: turn this into a mask, and merge with io_restrictions */ |
111 | /* Always a power of 2 */ | 111 | /* Always a power of 2 */ |
112 | sector_t split_io; | 112 | sector_t split_io; |
113 | 113 | ||
114 | /* | 114 | /* |
115 | * These are automatically filled in by | 115 | * These are automatically filled in by |
116 | * dm_table_get_device. | 116 | * dm_table_get_device. |
117 | */ | 117 | */ |
118 | struct io_restrictions limits; | 118 | struct io_restrictions limits; |
119 | 119 | ||
120 | /* target specific data */ | 120 | /* target specific data */ |
121 | void *private; | 121 | void *private; |
122 | 122 | ||
123 | /* Used to provide an error string from the ctr */ | 123 | /* Used to provide an error string from the ctr */ |
124 | char *error; | 124 | char *error; |
125 | }; | 125 | }; |
126 | 126 | ||
127 | int dm_register_target(struct target_type *t); | 127 | int dm_register_target(struct target_type *t); |
128 | int dm_unregister_target(struct target_type *t); | 128 | int dm_unregister_target(struct target_type *t); |
129 | 129 | ||
130 | #endif /* _LINUX_DEVICE_MAPPER_H */ | 130 | #endif /* _LINUX_DEVICE_MAPPER_H */ |
131 | 131 |