aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/dm-table.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 10c9439635ca..827b648fac50 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -237,6 +237,44 @@ int dm_table_create(struct dm_table **result, int mode,
237 return 0; 237 return 0;
238} 238}
239 239
240int dm_create_error_table(struct dm_table **result, struct mapped_device *md)
241{
242 struct dm_table *t;
243 sector_t dev_size = 1;
244 int r;
245
246 /*
247 * Find current size of device.
248 * Default to 1 sector if inactive.
249 */
250 t = dm_get_table(md);
251 if (t) {
252 dev_size = dm_table_get_size(t);
253 dm_table_put(t);
254 }
255
256 r = dm_table_create(&t, FMODE_READ, 1, md);
257 if (r)
258 return r;
259
260 r = dm_table_add_target(t, "error", 0, dev_size, NULL);
261 if (r)
262 goto out;
263
264 r = dm_table_complete(t);
265 if (r)
266 goto out;
267
268 *result = t;
269
270out:
271 if (r)
272 dm_table_put(t);
273
274 return r;
275}
276EXPORT_SYMBOL_GPL(dm_create_error_table);
277
240static void free_devices(struct list_head *devices) 278static void free_devices(struct list_head *devices)
241{ 279{
242 struct list_head *tmp, *next; 280 struct list_head *tmp, *next;