blob: 09a57113955e5fb0b04ece6e9d5a30d111b838d6 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Copyright (C) 2001 Sistina Software (UK) Limited.
Mikulas Patockad5816872009-01-06 03:05:10 +00003 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
5 * This file is released under the GPL.
6 */
7
8#include "dm.h"
9
10#include <linux/module.h>
11#include <linux/vmalloc.h>
12#include <linux/blkdev.h>
13#include <linux/namei.h>
14#include <linux/ctype.h>
15#include <linux/slab.h>
16#include <linux/interrupt.h>
Arjan van de Ven48c9c272006-03-27 01:18:20 -080017#include <linux/mutex.h>
Mikulas Patockad5816872009-01-06 03:05:10 +000018#include <linux/delay.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <asm/atomic.h>
20
Alasdair G Kergon72d94862006-06-26 00:27:35 -070021#define DM_MSG_PREFIX "table"
22
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#define MAX_DEPTH 16
24#define NODE_SIZE L1_CACHE_BYTES
25#define KEYS_PER_NODE (NODE_SIZE / sizeof(sector_t))
26#define CHILDREN_PER_NODE (KEYS_PER_NODE + 1)
27
Mikulas Patockad5816872009-01-06 03:05:10 +000028/*
29 * The table has always exactly one reference from either mapped_device->map
30 * or hash_cell->new_map. This reference is not counted in table->holders.
31 * A pair of dm_create_table/dm_destroy_table functions is used for table
32 * creation/destruction.
33 *
34 * Temporary references from the other code increase table->holders. A pair
35 * of dm_table_get/dm_table_put functions is used to manipulate it.
36 *
37 * When the table is about to be destroyed, we wait for table->holders to
38 * drop to zero.
39 */
40
Linus Torvalds1da177e2005-04-16 15:20:36 -070041struct dm_table {
Mike Anderson1134e5a2006-03-27 01:17:54 -080042 struct mapped_device *md;
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 atomic_t holders;
44
45 /* btree table */
46 unsigned int depth;
47 unsigned int counts[MAX_DEPTH]; /* in nodes */
48 sector_t *index[MAX_DEPTH];
49
50 unsigned int num_targets;
51 unsigned int num_allocated;
52 sector_t *highs;
53 struct dm_target *targets;
54
55 /*
56 * Indicates the rw permissions for the new logical
57 * device. This should be a combination of FMODE_READ
58 * and FMODE_WRITE.
59 */
Al Viroaeb5d722008-09-02 15:28:45 -040060 fmode_t mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
62 /* a list of devices used by this table */
63 struct list_head devices;
64
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 /* events get handed up using this callback */
66 void (*event_fn)(void *);
67 void *event_context;
68};
69
70/*
71 * Similar to ceiling(log_size(n))
72 */
73static unsigned int int_log(unsigned int n, unsigned int base)
74{
75 int result = 0;
76
77 while (n > 1) {
78 n = dm_div_up(n, base);
79 result++;
80 }
81
82 return result;
83}
84
85/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070086 * Calculate the index of the child node of the n'th node k'th key.
87 */
88static inline unsigned int get_child(unsigned int n, unsigned int k)
89{
90 return (n * CHILDREN_PER_NODE) + k;
91}
92
93/*
94 * Return the n'th node of level l from table t.
95 */
96static inline sector_t *get_node(struct dm_table *t,
97 unsigned int l, unsigned int n)
98{
99 return t->index[l] + (n * KEYS_PER_NODE);
100}
101
102/*
103 * Return the highest key that you could lookup from the n'th
104 * node on level l of the btree.
105 */
106static sector_t high(struct dm_table *t, unsigned int l, unsigned int n)
107{
108 for (; l < t->depth - 1; l++)
109 n = get_child(n, CHILDREN_PER_NODE - 1);
110
111 if (n >= t->counts[l])
112 return (sector_t) - 1;
113
114 return get_node(t, l, n)[KEYS_PER_NODE - 1];
115}
116
117/*
118 * Fills in a level of the btree based on the highs of the level
119 * below it.
120 */
121static int setup_btree_index(unsigned int l, struct dm_table *t)
122{
123 unsigned int n, k;
124 sector_t *node;
125
126 for (n = 0U; n < t->counts[l]; n++) {
127 node = get_node(t, l, n);
128
129 for (k = 0U; k < KEYS_PER_NODE; k++)
130 node[k] = high(t, l + 1, get_child(n, k));
131 }
132
133 return 0;
134}
135
136void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size)
137{
138 unsigned long size;
139 void *addr;
140
141 /*
142 * Check that we're not going to overflow.
143 */
144 if (nmemb > (ULONG_MAX / elem_size))
145 return NULL;
146
147 size = nmemb * elem_size;
148 addr = vmalloc(size);
149 if (addr)
150 memset(addr, 0, size);
151
152 return addr;
153}
154
155/*
156 * highs, and targets are managed as dynamic arrays during a
157 * table load.
158 */
159static int alloc_targets(struct dm_table *t, unsigned int num)
160{
161 sector_t *n_highs;
162 struct dm_target *n_targets;
163 int n = t->num_targets;
164
165 /*
166 * Allocate both the target array and offset array at once.
Jun'ichi Nomura512875b2007-12-13 14:15:25 +0000167 * Append an empty entry to catch sectors beyond the end of
168 * the device.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169 */
Jun'ichi Nomura512875b2007-12-13 14:15:25 +0000170 n_highs = (sector_t *) dm_vcalloc(num + 1, sizeof(struct dm_target) +
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171 sizeof(sector_t));
172 if (!n_highs)
173 return -ENOMEM;
174
175 n_targets = (struct dm_target *) (n_highs + num);
176
177 if (n) {
178 memcpy(n_highs, t->highs, sizeof(*n_highs) * n);
179 memcpy(n_targets, t->targets, sizeof(*n_targets) * n);
180 }
181
182 memset(n_highs + n, -1, sizeof(*n_highs) * (num - n));
183 vfree(t->highs);
184
185 t->num_allocated = num;
186 t->highs = n_highs;
187 t->targets = n_targets;
188
189 return 0;
190}
191
Al Viroaeb5d722008-09-02 15:28:45 -0400192int dm_table_create(struct dm_table **result, fmode_t mode,
Mike Anderson1134e5a2006-03-27 01:17:54 -0800193 unsigned num_targets, struct mapped_device *md)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194{
Dmitry Monakhov094262d2007-10-19 22:38:51 +0100195 struct dm_table *t = kzalloc(sizeof(*t), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196
197 if (!t)
198 return -ENOMEM;
199
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 INIT_LIST_HEAD(&t->devices);
Mikulas Patockad5816872009-01-06 03:05:10 +0000201 atomic_set(&t->holders, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202
203 if (!num_targets)
204 num_targets = KEYS_PER_NODE;
205
206 num_targets = dm_round_up(num_targets, KEYS_PER_NODE);
207
208 if (alloc_targets(t, num_targets)) {
209 kfree(t);
210 t = NULL;
211 return -ENOMEM;
212 }
213
214 t->mode = mode;
Mike Anderson1134e5a2006-03-27 01:17:54 -0800215 t->md = md;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216 *result = t;
217 return 0;
218}
219
220static void free_devices(struct list_head *devices)
221{
222 struct list_head *tmp, *next;
223
Paul Jimenezafb24522008-02-08 02:09:59 +0000224 list_for_each_safe(tmp, next, devices) {
Mikulas Patocka82b15192008-10-10 13:37:09 +0100225 struct dm_dev_internal *dd =
226 list_entry(tmp, struct dm_dev_internal, list);
Jonthan Brassow1b6da752009-06-22 10:12:29 +0100227 DMWARN("dm_table_destroy: dm_put_device call missing for %s",
228 dd->dm_dev.name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229 kfree(dd);
230 }
231}
232
Mikulas Patockad5816872009-01-06 03:05:10 +0000233void dm_table_destroy(struct dm_table *t)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234{
235 unsigned int i;
236
Mikulas Patockad5816872009-01-06 03:05:10 +0000237 while (atomic_read(&t->holders))
238 msleep(1);
239 smp_mb();
240
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 /* free the indexes (see dm_table_complete) */
242 if (t->depth >= 2)
243 vfree(t->index[t->depth - 2]);
244
245 /* free the targets */
246 for (i = 0; i < t->num_targets; i++) {
247 struct dm_target *tgt = t->targets + i;
248
249 if (tgt->type->dtr)
250 tgt->type->dtr(tgt);
251
252 dm_put_target_type(tgt->type);
253 }
254
255 vfree(t->highs);
256
257 /* free the device list */
Jonthan Brassow1b6da752009-06-22 10:12:29 +0100258 if (t->devices.next != &t->devices)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 free_devices(&t->devices);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260
261 kfree(t);
262}
263
264void dm_table_get(struct dm_table *t)
265{
266 atomic_inc(&t->holders);
267}
268
269void dm_table_put(struct dm_table *t)
270{
271 if (!t)
272 return;
273
Mikulas Patockad5816872009-01-06 03:05:10 +0000274 smp_mb__before_atomic_dec();
275 atomic_dec(&t->holders);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276}
277
278/*
279 * Checks to see if we need to extend highs or targets.
280 */
281static inline int check_space(struct dm_table *t)
282{
283 if (t->num_targets >= t->num_allocated)
284 return alloc_targets(t, t->num_allocated * 2);
285
286 return 0;
287}
288
289/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290 * See if we've already got a device in the list.
291 */
Mikulas Patocka82b15192008-10-10 13:37:09 +0100292static struct dm_dev_internal *find_device(struct list_head *l, dev_t dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293{
Mikulas Patocka82b15192008-10-10 13:37:09 +0100294 struct dm_dev_internal *dd;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295
296 list_for_each_entry (dd, l, list)
Mikulas Patocka82b15192008-10-10 13:37:09 +0100297 if (dd->dm_dev.bdev->bd_dev == dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 return dd;
299
300 return NULL;
301}
302
303/*
304 * Open a device so we can use it as a map destination.
305 */
Mikulas Patocka82b15192008-10-10 13:37:09 +0100306static int open_dev(struct dm_dev_internal *d, dev_t dev,
307 struct mapped_device *md)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308{
309 static char *_claim_ptr = "I belong to device-mapper";
310 struct block_device *bdev;
311
312 int r;
313
Mikulas Patocka82b15192008-10-10 13:37:09 +0100314 BUG_ON(d->dm_dev.bdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315
Mikulas Patocka82b15192008-10-10 13:37:09 +0100316 bdev = open_by_devnum(dev, d->dm_dev.mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 if (IS_ERR(bdev))
318 return PTR_ERR(bdev);
Jun'ichi Nomuraf1659212006-03-27 01:17:59 -0800319 r = bd_claim_by_disk(bdev, _claim_ptr, dm_disk(md));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320 if (r)
Al Viro9a1c3542008-02-22 20:40:24 -0500321 blkdev_put(bdev, d->dm_dev.mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 else
Mikulas Patocka82b15192008-10-10 13:37:09 +0100323 d->dm_dev.bdev = bdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324 return r;
325}
326
327/*
328 * Close a device that we've been using.
329 */
Mikulas Patocka82b15192008-10-10 13:37:09 +0100330static void close_dev(struct dm_dev_internal *d, struct mapped_device *md)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331{
Mikulas Patocka82b15192008-10-10 13:37:09 +0100332 if (!d->dm_dev.bdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 return;
334
Mikulas Patocka82b15192008-10-10 13:37:09 +0100335 bd_release_from_disk(d->dm_dev.bdev, dm_disk(md));
Al Viro9a1c3542008-02-22 20:40:24 -0500336 blkdev_put(d->dm_dev.bdev, d->dm_dev.mode);
Mikulas Patocka82b15192008-10-10 13:37:09 +0100337 d->dm_dev.bdev = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338}
339
340/*
Mike Anderson2cd54d92007-05-09 02:32:57 -0700341 * If possible, this checks an area of a destination device is valid.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 */
Mike Snitzer754c5fc2009-06-22 10:12:34 +0100343static int device_area_is_valid(struct dm_target *ti, struct dm_dev *dev,
344 sector_t start, void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345{
Mike Snitzer754c5fc2009-06-22 10:12:34 +0100346 struct queue_limits *limits = data;
347 struct block_device *bdev = dev->bdev;
348 sector_t dev_size =
349 i_size_read(bdev->bd_inode) >> SECTOR_SHIFT;
Mike Snitzer02acc3a2009-06-22 10:12:30 +0100350 unsigned short logical_block_size_sectors =
Mike Snitzer754c5fc2009-06-22 10:12:34 +0100351 limits->logical_block_size >> SECTOR_SHIFT;
Mike Snitzer02acc3a2009-06-22 10:12:30 +0100352 char b[BDEVNAME_SIZE];
Mike Anderson2cd54d92007-05-09 02:32:57 -0700353
354 if (!dev_size)
355 return 1;
356
Mike Snitzer754c5fc2009-06-22 10:12:34 +0100357 if ((start >= dev_size) || (start + ti->len > dev_size)) {
Mike Snitzer02acc3a2009-06-22 10:12:30 +0100358 DMWARN("%s: %s too small for target",
359 dm_device_name(ti->table->md), bdevname(bdev, b));
360 return 0;
361 }
362
363 if (logical_block_size_sectors <= 1)
364 return 1;
365
366 if (start & (logical_block_size_sectors - 1)) {
367 DMWARN("%s: start=%llu not aligned to h/w "
368 "logical block size %hu of %s",
369 dm_device_name(ti->table->md),
370 (unsigned long long)start,
Mike Snitzer754c5fc2009-06-22 10:12:34 +0100371 limits->logical_block_size, bdevname(bdev, b));
Mike Snitzer02acc3a2009-06-22 10:12:30 +0100372 return 0;
373 }
374
Mike Snitzer754c5fc2009-06-22 10:12:34 +0100375 if (ti->len & (logical_block_size_sectors - 1)) {
Mike Snitzer02acc3a2009-06-22 10:12:30 +0100376 DMWARN("%s: len=%llu not aligned to h/w "
377 "logical block size %hu of %s",
378 dm_device_name(ti->table->md),
Mike Snitzer754c5fc2009-06-22 10:12:34 +0100379 (unsigned long long)ti->len,
380 limits->logical_block_size, bdevname(bdev, b));
Mike Snitzer02acc3a2009-06-22 10:12:30 +0100381 return 0;
382 }
383
384 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385}
386
387/*
Alasdair G Kergon570b9d92009-04-02 19:55:28 +0100388 * This upgrades the mode on an already open dm_dev, being
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389 * careful to leave things as they were if we fail to reopen the
Alasdair G Kergon570b9d92009-04-02 19:55:28 +0100390 * device and not to touch the existing bdev field in case
391 * it is accessed concurrently inside dm_table_any_congested().
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392 */
Al Viroaeb5d722008-09-02 15:28:45 -0400393static int upgrade_mode(struct dm_dev_internal *dd, fmode_t new_mode,
Mikulas Patocka82b15192008-10-10 13:37:09 +0100394 struct mapped_device *md)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395{
396 int r;
Alasdair G Kergon570b9d92009-04-02 19:55:28 +0100397 struct dm_dev_internal dd_new, dd_old;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398
Alasdair G Kergon570b9d92009-04-02 19:55:28 +0100399 dd_new = dd_old = *dd;
400
401 dd_new.dm_dev.mode |= new_mode;
402 dd_new.dm_dev.bdev = NULL;
403
404 r = open_dev(&dd_new, dd->dm_dev.bdev->bd_dev, md);
405 if (r)
406 return r;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407
Mikulas Patocka82b15192008-10-10 13:37:09 +0100408 dd->dm_dev.mode |= new_mode;
Alasdair G Kergon570b9d92009-04-02 19:55:28 +0100409 close_dev(&dd_old, md);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410
Alasdair G Kergon570b9d92009-04-02 19:55:28 +0100411 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412}
413
414/*
415 * Add a device to the list, or just increment the usage count if
416 * it's already present.
417 */
418static int __table_get_device(struct dm_table *t, struct dm_target *ti,
419 const char *path, sector_t start, sector_t len,
Al Viroaeb5d722008-09-02 15:28:45 -0400420 fmode_t mode, struct dm_dev **result)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421{
422 int r;
Andrew Morton69a2ce72008-02-08 02:10:14 +0000423 dev_t uninitialized_var(dev);
Mikulas Patocka82b15192008-10-10 13:37:09 +0100424 struct dm_dev_internal *dd;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 unsigned int major, minor;
426
Eric Sesterhenn547bc922006-03-26 18:22:50 +0200427 BUG_ON(!t);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428
429 if (sscanf(path, "%u:%u", &major, &minor) == 2) {
430 /* Extract the major/minor numbers */
431 dev = MKDEV(major, minor);
432 if (MAJOR(dev) != major || MINOR(dev) != minor)
433 return -EOVERFLOW;
434 } else {
435 /* convert the path to a device */
Christoph Hellwig72e82642008-08-11 00:24:08 +0200436 struct block_device *bdev = lookup_bdev(path);
437
438 if (IS_ERR(bdev))
439 return PTR_ERR(bdev);
440 dev = bdev->bd_dev;
441 bdput(bdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 }
443
444 dd = find_device(&t->devices, dev);
445 if (!dd) {
446 dd = kmalloc(sizeof(*dd), GFP_KERNEL);
447 if (!dd)
448 return -ENOMEM;
449
Mikulas Patocka82b15192008-10-10 13:37:09 +0100450 dd->dm_dev.mode = mode;
451 dd->dm_dev.bdev = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452
Jun'ichi Nomuraf1659212006-03-27 01:17:59 -0800453 if ((r = open_dev(dd, dev, t->md))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454 kfree(dd);
455 return r;
456 }
457
Mikulas Patocka82b15192008-10-10 13:37:09 +0100458 format_dev_t(dd->dm_dev.name, dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459
460 atomic_set(&dd->count, 0);
461 list_add(&dd->list, &t->devices);
462
Mikulas Patocka82b15192008-10-10 13:37:09 +0100463 } else if (dd->dm_dev.mode != (mode | dd->dm_dev.mode)) {
Jun'ichi Nomuraf1659212006-03-27 01:17:59 -0800464 r = upgrade_mode(dd, mode, t->md);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 if (r)
466 return r;
467 }
468 atomic_inc(&dd->count);
469
Mikulas Patocka82b15192008-10-10 13:37:09 +0100470 *result = &dd->dm_dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 return 0;
472}
473
Mike Snitzer5ab97582009-06-22 10:12:32 +0100474/*
475 * Returns the minimum that is _not_ zero, unless both are zero.
476 */
477#define min_not_zero(l, r) (l == 0) ? r : ((r == 0) ? l : min(l, r))
478
Mike Snitzer754c5fc2009-06-22 10:12:34 +0100479int dm_set_device_limits(struct dm_target *ti, struct dm_dev *dev,
480 sector_t start, void *data)
Bryn Reeves3cb40212006-10-03 01:15:42 -0700481{
Mike Snitzer754c5fc2009-06-22 10:12:34 +0100482 struct queue_limits *limits = data;
483 struct block_device *bdev = dev->bdev;
Jens Axboe165125e2007-07-24 09:28:11 +0200484 struct request_queue *q = bdev_get_queue(bdev);
Alasdair G Kergon0c2322e2008-10-10 13:37:13 +0100485 char b[BDEVNAME_SIZE];
486
487 if (unlikely(!q)) {
488 DMWARN("%s: Cannot set limits for nonexistent device %s",
489 dm_device_name(ti->table->md), bdevname(bdev, b));
Mike Snitzer754c5fc2009-06-22 10:12:34 +0100490 return 0;
Alasdair G Kergon0c2322e2008-10-10 13:37:13 +0100491 }
Bryn Reeves3cb40212006-10-03 01:15:42 -0700492
Mike Snitzer754c5fc2009-06-22 10:12:34 +0100493 if (blk_stack_limits(limits, &q->limits, start) < 0)
Mike Snitzer5ab97582009-06-22 10:12:32 +0100494 DMWARN("%s: target device %s is misaligned",
495 dm_device_name(ti->table->md), bdevname(bdev, b));
Bryn Reeves3cb40212006-10-03 01:15:42 -0700496
Milan Broz9980c632008-07-21 12:00:39 +0100497 /*
498 * Check if merge fn is supported.
499 * If not we'll force DM to use PAGE_SIZE or
500 * smaller I/O, just to be safe.
Bryn Reeves3cb40212006-10-03 01:15:42 -0700501 */
Milan Broz9980c632008-07-21 12:00:39 +0100502
503 if (q->merge_bvec_fn && !ti->type->merge)
Mike Snitzer754c5fc2009-06-22 10:12:34 +0100504 limits->max_sectors =
505 min_not_zero(limits->max_sectors,
Bryn Reeves3cb40212006-10-03 01:15:42 -0700506 (unsigned int) (PAGE_SIZE >> 9));
Mike Snitzer754c5fc2009-06-22 10:12:34 +0100507 return 0;
Bryn Reeves3cb40212006-10-03 01:15:42 -0700508}
509EXPORT_SYMBOL_GPL(dm_set_device_limits);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510
511int dm_get_device(struct dm_target *ti, const char *path, sector_t start,
Al Viroaeb5d722008-09-02 15:28:45 -0400512 sector_t len, fmode_t mode, struct dm_dev **result)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513{
Mike Snitzer754c5fc2009-06-22 10:12:34 +0100514 return __table_get_device(ti->table, ti, path,
515 start, len, mode, result);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516}
517
Mike Snitzer754c5fc2009-06-22 10:12:34 +0100518
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519/*
520 * Decrement a devices use count and remove it if necessary.
521 */
Mikulas Patocka82b15192008-10-10 13:37:09 +0100522void dm_put_device(struct dm_target *ti, struct dm_dev *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523{
Mikulas Patocka82b15192008-10-10 13:37:09 +0100524 struct dm_dev_internal *dd = container_of(d, struct dm_dev_internal,
525 dm_dev);
526
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 if (atomic_dec_and_test(&dd->count)) {
Jun'ichi Nomuraf1659212006-03-27 01:17:59 -0800528 close_dev(dd, ti->table->md);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529 list_del(&dd->list);
530 kfree(dd);
531 }
532}
533
534/*
535 * Checks to see if the target joins onto the end of the table.
536 */
537static int adjoin(struct dm_table *table, struct dm_target *ti)
538{
539 struct dm_target *prev;
540
541 if (!table->num_targets)
542 return !ti->begin;
543
544 prev = &table->targets[table->num_targets - 1];
545 return (ti->begin == (prev->begin + prev->len));
546}
547
548/*
549 * Used to dynamically allocate the arg array.
550 */
551static char **realloc_argv(unsigned *array_size, char **old_argv)
552{
553 char **argv;
554 unsigned new_size;
555
556 new_size = *array_size ? *array_size * 2 : 64;
557 argv = kmalloc(new_size * sizeof(*argv), GFP_KERNEL);
558 if (argv) {
559 memcpy(argv, old_argv, *array_size * sizeof(*argv));
560 *array_size = new_size;
561 }
562
563 kfree(old_argv);
564 return argv;
565}
566
567/*
568 * Destructively splits up the argument list to pass to ctr.
569 */
570int dm_split_args(int *argc, char ***argvp, char *input)
571{
572 char *start, *end = input, *out, **argv = NULL;
573 unsigned array_size = 0;
574
575 *argc = 0;
David Teigland814d6862006-06-26 00:27:31 -0700576
577 if (!input) {
578 *argvp = NULL;
579 return 0;
580 }
581
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 argv = realloc_argv(&array_size, argv);
583 if (!argv)
584 return -ENOMEM;
585
586 while (1) {
587 start = end;
588
589 /* Skip whitespace */
590 while (*start && isspace(*start))
591 start++;
592
593 if (!*start)
594 break; /* success, we hit the end */
595
596 /* 'out' is used to remove any back-quotes */
597 end = out = start;
598 while (*end) {
599 /* Everything apart from '\0' can be quoted */
600 if (*end == '\\' && *(end + 1)) {
601 *out++ = *(end + 1);
602 end += 2;
603 continue;
604 }
605
606 if (isspace(*end))
607 break; /* end of token */
608
609 *out++ = *end++;
610 }
611
612 /* have we already filled the array ? */
613 if ((*argc + 1) > array_size) {
614 argv = realloc_argv(&array_size, argv);
615 if (!argv)
616 return -ENOMEM;
617 }
618
619 /* we know this is whitespace */
620 if (*end)
621 end++;
622
623 /* terminate the string and put it in the array */
624 *out = '\0';
625 argv[*argc] = start;
626 (*argc)++;
627 }
628
629 *argvp = argv;
630 return 0;
631}
632
Mike Snitzerbe6d4302009-06-22 10:12:31 +0100633/*
634 * Impose necessary and sufficient conditions on a devices's table such
635 * that any incoming bio which respects its logical_block_size can be
636 * processed successfully. If it falls across the boundary between
637 * two or more targets, the size of each piece it gets split into must
638 * be compatible with the logical_block_size of the target processing it.
639 */
Mike Snitzer754c5fc2009-06-22 10:12:34 +0100640static int validate_hardware_logical_block_alignment(struct dm_table *table,
641 struct queue_limits *limits)
Mike Snitzerbe6d4302009-06-22 10:12:31 +0100642{
643 /*
644 * This function uses arithmetic modulo the logical_block_size
645 * (in units of 512-byte sectors).
646 */
647 unsigned short device_logical_block_size_sects =
Mike Snitzer754c5fc2009-06-22 10:12:34 +0100648 limits->logical_block_size >> SECTOR_SHIFT;
Mike Snitzerbe6d4302009-06-22 10:12:31 +0100649
650 /*
651 * Offset of the start of the next table entry, mod logical_block_size.
652 */
653 unsigned short next_target_start = 0;
654
655 /*
656 * Given an aligned bio that extends beyond the end of a
657 * target, how many sectors must the next target handle?
658 */
659 unsigned short remaining = 0;
660
661 struct dm_target *uninitialized_var(ti);
Mike Snitzer754c5fc2009-06-22 10:12:34 +0100662 struct queue_limits ti_limits;
Mike Snitzerbe6d4302009-06-22 10:12:31 +0100663 unsigned i = 0;
664
665 /*
666 * Check each entry in the table in turn.
667 */
668 while (i < dm_table_get_num_targets(table)) {
669 ti = dm_table_get_target(table, i++);
670
Mike Snitzer754c5fc2009-06-22 10:12:34 +0100671 blk_set_default_limits(&ti_limits);
672
673 /* combine all target devices' limits */
674 if (ti->type->iterate_devices)
675 ti->type->iterate_devices(ti, dm_set_device_limits,
676 &ti_limits);
677
Mike Snitzerbe6d4302009-06-22 10:12:31 +0100678 /*
679 * If the remaining sectors fall entirely within this
680 * table entry are they compatible with its logical_block_size?
681 */
682 if (remaining < ti->len &&
Mike Snitzer754c5fc2009-06-22 10:12:34 +0100683 remaining & ((ti_limits.logical_block_size >>
Mike Snitzerbe6d4302009-06-22 10:12:31 +0100684 SECTOR_SHIFT) - 1))
685 break; /* Error */
686
687 next_target_start =
688 (unsigned short) ((next_target_start + ti->len) &
689 (device_logical_block_size_sects - 1));
690 remaining = next_target_start ?
691 device_logical_block_size_sects - next_target_start : 0;
692 }
693
694 if (remaining) {
695 DMWARN("%s: table line %u (start sect %llu len %llu) "
Mike Snitzer754c5fc2009-06-22 10:12:34 +0100696 "not aligned to h/w logical block size %hu",
Mike Snitzerbe6d4302009-06-22 10:12:31 +0100697 dm_device_name(table->md), i,
698 (unsigned long long) ti->begin,
699 (unsigned long long) ti->len,
Mike Snitzer754c5fc2009-06-22 10:12:34 +0100700 limits->logical_block_size);
Mike Snitzerbe6d4302009-06-22 10:12:31 +0100701 return -EINVAL;
702 }
703
704 return 0;
705}
706
Linus Torvalds1da177e2005-04-16 15:20:36 -0700707int dm_table_add_target(struct dm_table *t, const char *type,
708 sector_t start, sector_t len, char *params)
709{
710 int r = -EINVAL, argc;
711 char **argv;
712 struct dm_target *tgt;
713
714 if ((r = check_space(t)))
715 return r;
716
717 tgt = t->targets + t->num_targets;
718 memset(tgt, 0, sizeof(*tgt));
719
720 if (!len) {
Alasdair G Kergon72d94862006-06-26 00:27:35 -0700721 DMERR("%s: zero-length target", dm_device_name(t->md));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722 return -EINVAL;
723 }
724
725 tgt->type = dm_get_target_type(type);
726 if (!tgt->type) {
Alasdair G Kergon72d94862006-06-26 00:27:35 -0700727 DMERR("%s: %s: unknown target type", dm_device_name(t->md),
728 type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729 return -EINVAL;
730 }
731
732 tgt->table = t;
733 tgt->begin = start;
734 tgt->len = len;
735 tgt->error = "Unknown error";
736
737 /*
738 * Does this target adjoin the previous one ?
739 */
740 if (!adjoin(t, tgt)) {
741 tgt->error = "Gap in table";
742 r = -EINVAL;
743 goto bad;
744 }
745
746 r = dm_split_args(&argc, &argv, params);
747 if (r) {
748 tgt->error = "couldn't split parameters (insufficient memory)";
749 goto bad;
750 }
751
752 r = tgt->type->ctr(tgt, argc, argv);
753 kfree(argv);
754 if (r)
755 goto bad;
756
757 t->highs[t->num_targets++] = tgt->begin + tgt->len - 1;
758
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759 return 0;
760
761 bad:
Alasdair G Kergon72d94862006-06-26 00:27:35 -0700762 DMERR("%s: %s: %s", dm_device_name(t->md), type, tgt->error);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763 dm_put_target_type(tgt->type);
764 return r;
765}
766
767static int setup_indexes(struct dm_table *t)
768{
769 int i;
770 unsigned int total = 0;
771 sector_t *indexes;
772
773 /* allocate the space for *all* the indexes */
774 for (i = t->depth - 2; i >= 0; i--) {
775 t->counts[i] = dm_div_up(t->counts[i + 1], CHILDREN_PER_NODE);
776 total += t->counts[i];
777 }
778
779 indexes = (sector_t *) dm_vcalloc(total, (unsigned long) NODE_SIZE);
780 if (!indexes)
781 return -ENOMEM;
782
783 /* set up internal nodes, bottom-up */
Jun'ichi Nomura82d601dc2008-02-08 02:10:04 +0000784 for (i = t->depth - 2; i >= 0; i--) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785 t->index[i] = indexes;
786 indexes += (KEYS_PER_NODE * t->counts[i]);
787 setup_btree_index(i, t);
788 }
789
790 return 0;
791}
792
793/*
794 * Builds the btree to index the map.
795 */
796int dm_table_complete(struct dm_table *t)
797{
798 int r = 0;
799 unsigned int leaf_nodes;
800
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801 /* how many indexes will the btree have ? */
802 leaf_nodes = dm_div_up(t->num_targets, KEYS_PER_NODE);
803 t->depth = 1 + int_log(leaf_nodes, CHILDREN_PER_NODE);
804
805 /* leaf layer has already been set up */
806 t->counts[t->depth - 1] = leaf_nodes;
807 t->index[t->depth - 1] = t->highs;
808
809 if (t->depth >= 2)
810 r = setup_indexes(t);
811
812 return r;
813}
814
Arjan van de Ven48c9c272006-03-27 01:18:20 -0800815static DEFINE_MUTEX(_event_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816void dm_table_event_callback(struct dm_table *t,
817 void (*fn)(void *), void *context)
818{
Arjan van de Ven48c9c272006-03-27 01:18:20 -0800819 mutex_lock(&_event_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820 t->event_fn = fn;
821 t->event_context = context;
Arjan van de Ven48c9c272006-03-27 01:18:20 -0800822 mutex_unlock(&_event_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700823}
824
825void dm_table_event(struct dm_table *t)
826{
827 /*
828 * You can no longer call dm_table_event() from interrupt
829 * context, use a bottom half instead.
830 */
831 BUG_ON(in_interrupt());
832
Arjan van de Ven48c9c272006-03-27 01:18:20 -0800833 mutex_lock(&_event_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700834 if (t->event_fn)
835 t->event_fn(t->event_context);
Arjan van de Ven48c9c272006-03-27 01:18:20 -0800836 mutex_unlock(&_event_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837}
838
839sector_t dm_table_get_size(struct dm_table *t)
840{
841 return t->num_targets ? (t->highs[t->num_targets - 1] + 1) : 0;
842}
843
844struct dm_target *dm_table_get_target(struct dm_table *t, unsigned int index)
845{
Milan Broz14353532006-06-26 00:27:27 -0700846 if (index >= t->num_targets)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847 return NULL;
848
849 return t->targets + index;
850}
851
852/*
853 * Search the btree for the correct target.
Jun'ichi Nomura512875b2007-12-13 14:15:25 +0000854 *
855 * Caller should check returned pointer with dm_target_is_valid()
856 * to trap I/O beyond end of device.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700857 */
858struct dm_target *dm_table_find_target(struct dm_table *t, sector_t sector)
859{
860 unsigned int l, n = 0, k = 0;
861 sector_t *node;
862
863 for (l = 0; l < t->depth; l++) {
864 n = get_child(n, k);
865 node = get_node(t, l, n);
866
867 for (k = 0; k < KEYS_PER_NODE; k++)
868 if (node[k] >= sector)
869 break;
870 }
871
872 return &t->targets[(KEYS_PER_NODE * n) + k];
873}
874
Martin K. Petersen9c470082009-04-09 00:27:12 +0100875/*
Mike Snitzer754c5fc2009-06-22 10:12:34 +0100876 * Establish the new table's queue_limits and validate them.
877 */
878int dm_calculate_queue_limits(struct dm_table *table,
879 struct queue_limits *limits)
880{
881 struct dm_target *uninitialized_var(ti);
882 struct queue_limits ti_limits;
883 unsigned i = 0;
884
885 blk_set_default_limits(limits);
886
887 while (i < dm_table_get_num_targets(table)) {
888 blk_set_default_limits(&ti_limits);
889
890 ti = dm_table_get_target(table, i++);
891
892 if (!ti->type->iterate_devices)
893 goto combine_limits;
894
895 /*
896 * Combine queue limits of all the devices this target uses.
897 */
898 ti->type->iterate_devices(ti, dm_set_device_limits,
899 &ti_limits);
900
901 /*
902 * Check each device area is consistent with the target's
903 * overall queue limits.
904 */
905 if (!ti->type->iterate_devices(ti, device_area_is_valid,
906 &ti_limits))
907 return -EINVAL;
908
909combine_limits:
910 /*
911 * Merge this target's queue limits into the overall limits
912 * for the table.
913 */
914 if (blk_stack_limits(limits, &ti_limits, 0) < 0)
915 DMWARN("%s: target device "
916 "(start sect %llu len %llu) "
917 "is misaligned",
918 dm_device_name(table->md),
919 (unsigned long long) ti->begin,
920 (unsigned long long) ti->len);
921 }
922
923 return validate_hardware_logical_block_alignment(table, limits);
924}
925
926/*
Martin K. Petersen9c470082009-04-09 00:27:12 +0100927 * Set the integrity profile for this device if all devices used have
928 * matching profiles.
929 */
930static void dm_table_set_integrity(struct dm_table *t)
931{
932 struct list_head *devices = dm_table_get_devices(t);
933 struct dm_dev_internal *prev = NULL, *dd = NULL;
934
935 if (!blk_get_integrity(dm_disk(t->md)))
936 return;
937
938 list_for_each_entry(dd, devices, list) {
939 if (prev &&
940 blk_integrity_compare(prev->dm_dev.bdev->bd_disk,
941 dd->dm_dev.bdev->bd_disk) < 0) {
942 DMWARN("%s: integrity not set: %s and %s mismatch",
943 dm_device_name(t->md),
944 prev->dm_dev.bdev->bd_disk->disk_name,
945 dd->dm_dev.bdev->bd_disk->disk_name);
946 goto no_integrity;
947 }
948 prev = dd;
949 }
950
951 if (!prev || !bdev_get_integrity(prev->dm_dev.bdev))
952 goto no_integrity;
953
954 blk_integrity_register(dm_disk(t->md),
955 bdev_get_integrity(prev->dm_dev.bdev));
956
957 return;
958
959no_integrity:
960 blk_integrity_register(dm_disk(t->md), NULL);
961
962 return;
963}
964
Mike Snitzer754c5fc2009-06-22 10:12:34 +0100965void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
966 struct queue_limits *limits)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700967{
968 /*
Mike Snitzer754c5fc2009-06-22 10:12:34 +0100969 * Each target device in the table has a data area that should normally
970 * be aligned such that the DM device's alignment_offset is 0.
971 * FIXME: Propagate alignment_offsets up the stack and warn of
972 * sub-optimal or inconsistent settings.
973 */
974 limits->alignment_offset = 0;
975 limits->misaligned = 0;
976
977 /*
Mike Snitzer11977642009-06-22 10:12:32 +0100978 * Copy table's limits to the DM device's request_queue
Linus Torvalds1da177e2005-04-16 15:20:36 -0700979 */
Mike Snitzer754c5fc2009-06-22 10:12:34 +0100980 q->limits = *limits;
Jens Axboec9a3f6d2008-04-29 19:12:35 +0200981
Mike Snitzer754c5fc2009-06-22 10:12:34 +0100982 if (limits->no_cluster)
Jens Axboec9a3f6d2008-04-29 19:12:35 +0200983 queue_flag_clear_unlocked(QUEUE_FLAG_CLUSTER, q);
NeilBrown969429b2006-03-27 01:17:49 -0800984 else
Jens Axboec9a3f6d2008-04-29 19:12:35 +0200985 queue_flag_set_unlocked(QUEUE_FLAG_CLUSTER, q);
NeilBrown969429b2006-03-27 01:17:49 -0800986
Martin K. Petersen9c470082009-04-09 00:27:12 +0100987 dm_table_set_integrity(t);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700988}
989
990unsigned int dm_table_get_num_targets(struct dm_table *t)
991{
992 return t->num_targets;
993}
994
995struct list_head *dm_table_get_devices(struct dm_table *t)
996{
997 return &t->devices;
998}
999
Al Viroaeb5d722008-09-02 15:28:45 -04001000fmode_t dm_table_get_mode(struct dm_table *t)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001001{
1002 return t->mode;
1003}
1004
1005static void suspend_targets(struct dm_table *t, unsigned postsuspend)
1006{
1007 int i = t->num_targets;
1008 struct dm_target *ti = t->targets;
1009
1010 while (i--) {
1011 if (postsuspend) {
1012 if (ti->type->postsuspend)
1013 ti->type->postsuspend(ti);
1014 } else if (ti->type->presuspend)
1015 ti->type->presuspend(ti);
1016
1017 ti++;
1018 }
1019}
1020
1021void dm_table_presuspend_targets(struct dm_table *t)
1022{
Alasdair G Kergoncf222b32005-07-28 21:15:57 -07001023 if (!t)
1024 return;
1025
Adrian Bunke8488d02008-04-24 22:10:51 +01001026 suspend_targets(t, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001027}
1028
1029void dm_table_postsuspend_targets(struct dm_table *t)
1030{
Alasdair G Kergoncf222b32005-07-28 21:15:57 -07001031 if (!t)
1032 return;
1033
Adrian Bunke8488d02008-04-24 22:10:51 +01001034 suspend_targets(t, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001035}
1036
Milan Broz8757b772006-10-03 01:15:36 -07001037int dm_table_resume_targets(struct dm_table *t)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001038{
Milan Broz8757b772006-10-03 01:15:36 -07001039 int i, r = 0;
1040
1041 for (i = 0; i < t->num_targets; i++) {
1042 struct dm_target *ti = t->targets + i;
1043
1044 if (!ti->type->preresume)
1045 continue;
1046
1047 r = ti->type->preresume(ti);
1048 if (r)
1049 return r;
1050 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001051
1052 for (i = 0; i < t->num_targets; i++) {
1053 struct dm_target *ti = t->targets + i;
1054
1055 if (ti->type->resume)
1056 ti->type->resume(ti);
1057 }
Milan Broz8757b772006-10-03 01:15:36 -07001058
1059 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001060}
1061
1062int dm_table_any_congested(struct dm_table *t, int bdi_bits)
1063{
Mikulas Patocka82b15192008-10-10 13:37:09 +01001064 struct dm_dev_internal *dd;
Paul Jimenezafb24522008-02-08 02:09:59 +00001065 struct list_head *devices = dm_table_get_devices(t);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001066 int r = 0;
1067
Paul Jimenezafb24522008-02-08 02:09:59 +00001068 list_for_each_entry(dd, devices, list) {
Mikulas Patocka82b15192008-10-10 13:37:09 +01001069 struct request_queue *q = bdev_get_queue(dd->dm_dev.bdev);
Alasdair G Kergon0c2322e2008-10-10 13:37:13 +01001070 char b[BDEVNAME_SIZE];
1071
1072 if (likely(q))
1073 r |= bdi_congested(&q->backing_dev_info, bdi_bits);
1074 else
1075 DMWARN_LIMIT("%s: any_congested: nonexistent device %s",
1076 dm_device_name(t->md),
1077 bdevname(dd->dm_dev.bdev, b));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001078 }
1079
1080 return r;
1081}
1082
1083void dm_table_unplug_all(struct dm_table *t)
1084{
Mikulas Patocka82b15192008-10-10 13:37:09 +01001085 struct dm_dev_internal *dd;
Paul Jimenezafb24522008-02-08 02:09:59 +00001086 struct list_head *devices = dm_table_get_devices(t);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001087
Paul Jimenezafb24522008-02-08 02:09:59 +00001088 list_for_each_entry(dd, devices, list) {
Mikulas Patocka82b15192008-10-10 13:37:09 +01001089 struct request_queue *q = bdev_get_queue(dd->dm_dev.bdev);
Alasdair G Kergon0c2322e2008-10-10 13:37:13 +01001090 char b[BDEVNAME_SIZE];
Linus Torvalds1da177e2005-04-16 15:20:36 -07001091
Alasdair G Kergon0c2322e2008-10-10 13:37:13 +01001092 if (likely(q))
1093 blk_unplug(q);
1094 else
1095 DMWARN_LIMIT("%s: Cannot unplug nonexistent device %s",
1096 dm_device_name(t->md),
1097 bdevname(dd->dm_dev.bdev, b));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001098 }
1099}
1100
Mike Anderson1134e5a2006-03-27 01:17:54 -08001101struct mapped_device *dm_table_get_md(struct dm_table *t)
1102{
1103 dm_get(t->md);
1104
1105 return t->md;
1106}
1107
Linus Torvalds1da177e2005-04-16 15:20:36 -07001108EXPORT_SYMBOL(dm_vcalloc);
1109EXPORT_SYMBOL(dm_get_device);
1110EXPORT_SYMBOL(dm_put_device);
1111EXPORT_SYMBOL(dm_table_event);
Alasdair G Kergond5e404c2005-07-12 15:53:05 -07001112EXPORT_SYMBOL(dm_table_get_size);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001113EXPORT_SYMBOL(dm_table_get_mode);
Mike Anderson1134e5a2006-03-27 01:17:54 -08001114EXPORT_SYMBOL(dm_table_get_md);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001115EXPORT_SYMBOL(dm_table_put);
1116EXPORT_SYMBOL(dm_table_get);
1117EXPORT_SYMBOL(dm_table_unplug_all);