Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] dm: add exports

Move definitions of core device-mapper functions for manipulating mapped
devices and their tables to <linux/device-mapper.h> advertising their
availability for use elsewhere in the kernel.

Protect the contents of device-mapper.h with ifdef __KERNEL__. And throw
in a few formatting clean-ups and extra comments.

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>

authored by

Alasdair G Kergon and committed by
Linus Torvalds
17b2f66f 2b06cfff

+109 -82
+6 -6
drivers/md/dm.c
··· 50 50 51 51 union map_info *dm_get_mapinfo(struct bio *bio) 52 52 { 53 - if (bio && bio->bi_private) 54 - return &((struct target_io *)bio->bi_private)->info; 55 - return NULL; 53 + if (bio && bio->bi_private) 54 + return &((struct target_io *)bio->bi_private)->info; 55 + return NULL; 56 56 } 57 57 58 58 #define MINOR_ALLOCED ((void *)-1) ··· 474 474 if (r > 0) { 475 475 /* the bio has been remapped so dispatch it */ 476 476 477 - blk_add_trace_remap(bdev_get_queue(clone->bi_bdev), clone, 478 - tio->io->bio->bi_bdev->bd_dev, sector, 477 + blk_add_trace_remap(bdev_get_queue(clone->bi_bdev), clone, 478 + tio->io->bio->bi_bdev->bd_dev, sector, 479 479 clone->bi_sector); 480 480 481 481 generic_make_request(clone); ··· 1042 1042 md = idr_find(&_minor_idr, minor); 1043 1043 if (md && (md == MINOR_ALLOCED || 1044 1044 (dm_disk(md)->first_minor != minor) || 1045 - test_bit(DMF_FREEING, &md->flags))) { 1045 + test_bit(DMF_FREEING, &md->flags))) { 1046 1046 md = NULL; 1047 1047 goto out; 1048 1048 }
+1 -74
drivers/md/dm.h
··· 39 39 }; 40 40 41 41 struct dm_table; 42 - struct mapped_device; 43 42 44 43 /*----------------------------------------------------------------- 45 - * Functions for manipulating a struct mapped_device. 46 - * Drop the reference with dm_put when you finish with the object. 44 + * Internal table functions. 47 45 *---------------------------------------------------------------*/ 48 - 49 - /* 50 - * DM_ANY_MINOR allocates any available minor number. 51 - */ 52 - #define DM_ANY_MINOR (-1) 53 - int dm_create(int minor, struct mapped_device **md); 54 - 55 - void dm_set_mdptr(struct mapped_device *md, void *ptr); 56 - void *dm_get_mdptr(struct mapped_device *md); 57 - 58 - /* 59 - * Reference counting for md. 60 - */ 61 - void dm_get(struct mapped_device *md); 62 - struct mapped_device *dm_get_md(dev_t dev); 63 - void dm_put(struct mapped_device *md); 64 - 65 - /* 66 - * A device can still be used while suspended, but I/O is deferred. 67 - */ 68 - int dm_suspend(struct mapped_device *md, int with_lockfs); 69 - int dm_resume(struct mapped_device *md); 70 - 71 - /* 72 - * The device must be suspended before calling this method. 73 - */ 74 - int dm_swap_table(struct mapped_device *md, struct dm_table *t); 75 - 76 - /* 77 - * Drop a reference on the table when you've finished with the 78 - * result. 79 - */ 80 - struct dm_table *dm_get_table(struct mapped_device *md); 81 - 82 - /* 83 - * Event functions. 84 - */ 85 - uint32_t dm_get_event_nr(struct mapped_device *md); 86 - int dm_wait_event(struct mapped_device *md, int event_nr); 87 - 88 - /* 89 - * Info functions. 90 - */ 91 - struct gendisk *dm_disk(struct mapped_device *md); 92 - int dm_suspended(struct mapped_device *md); 93 - 94 - /* 95 - * Geometry functions. 96 - */ 97 - int dm_get_geometry(struct mapped_device *md, struct hd_geometry *geo); 98 - int dm_set_geometry(struct mapped_device *md, struct hd_geometry *geo); 99 - 100 - /*----------------------------------------------------------------- 101 - * Functions for manipulating a table. Tables are also reference 102 - * counted. 103 - *---------------------------------------------------------------*/ 104 - int dm_table_create(struct dm_table **result, int mode, 105 - unsigned num_targets, struct mapped_device *md); 106 - 107 - void dm_table_get(struct dm_table *t); 108 - void dm_table_put(struct dm_table *t); 109 - 110 - int dm_table_add_target(struct dm_table *t, const char *type, 111 - sector_t start, sector_t len, char *params); 112 - int dm_table_complete(struct dm_table *t); 113 46 void dm_table_event_callback(struct dm_table *t, 114 47 void (*fn)(void *), void *context); 115 - void dm_table_event(struct dm_table *t); 116 - sector_t dm_table_get_size(struct dm_table *t); 117 48 struct dm_target *dm_table_get_target(struct dm_table *t, unsigned int index); 118 49 struct dm_target *dm_table_find_target(struct dm_table *t, sector_t sector); 119 50 void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q); 120 - unsigned int dm_table_get_num_targets(struct dm_table *t); 121 51 struct list_head *dm_table_get_devices(struct dm_table *t); 122 - int dm_table_get_mode(struct dm_table *t); 123 - struct mapped_device *dm_table_get_md(struct dm_table *t); 124 52 void dm_table_presuspend_targets(struct dm_table *t); 125 53 void dm_table_postsuspend_targets(struct dm_table *t); 126 54 void dm_table_resume_targets(struct dm_table *t); ··· 65 137 void dm_put_target_type(struct target_type *t); 66 138 int dm_target_iterate(void (*iter_func)(struct target_type *tt, 67 139 void *param), void *param); 68 - 69 140 70 141 /*----------------------------------------------------------------- 71 142 * Useful inlines.
+102 -2
include/linux/device-mapper.h
··· 8 8 #ifndef _LINUX_DEVICE_MAPPER_H 9 9 #define _LINUX_DEVICE_MAPPER_H 10 10 11 + #ifdef __KERNEL__ 12 + 11 13 struct dm_target; 12 14 struct dm_table; 13 15 struct dm_dev; 16 + struct mapped_device; 14 17 15 18 typedef enum { STATUSTYPE_INFO, STATUSTYPE_TABLE } status_type_t; 16 19 ··· 81 78 struct target_type { 82 79 const char *name; 83 80 struct module *module; 84 - unsigned version[3]; 81 + unsigned version[3]; 85 82 dm_ctr_fn ctr; 86 83 dm_dtr_fn dtr; 87 84 dm_map_fn map; ··· 131 128 int dm_register_target(struct target_type *t); 132 129 int dm_unregister_target(struct target_type *t); 133 130 134 - #endif /* _LINUX_DEVICE_MAPPER_H */ 131 + 132 + /*----------------------------------------------------------------- 133 + * Functions for creating and manipulating mapped devices. 134 + * Drop the reference with dm_put when you finish with the object. 135 + *---------------------------------------------------------------*/ 136 + 137 + /* 138 + * DM_ANY_MINOR chooses the next available minor number. 139 + */ 140 + #define DM_ANY_MINOR (-1) 141 + int dm_create(int minor, struct mapped_device **md); 142 + 143 + /* 144 + * Reference counting for md. 145 + */ 146 + struct mapped_device *dm_get_md(dev_t dev); 147 + void dm_get(struct mapped_device *md); 148 + void dm_put(struct mapped_device *md); 149 + 150 + /* 151 + * An arbitrary pointer may be stored alongside a mapped device. 152 + */ 153 + void dm_set_mdptr(struct mapped_device *md, void *ptr); 154 + void *dm_get_mdptr(struct mapped_device *md); 155 + 156 + /* 157 + * A device can still be used while suspended, but I/O is deferred. 158 + */ 159 + int dm_suspend(struct mapped_device *md, int with_lockfs); 160 + int dm_resume(struct mapped_device *md); 161 + 162 + /* 163 + * Event functions. 164 + */ 165 + uint32_t dm_get_event_nr(struct mapped_device *md); 166 + int dm_wait_event(struct mapped_device *md, int event_nr); 167 + 168 + /* 169 + * Info functions. 170 + */ 171 + struct gendisk *dm_disk(struct mapped_device *md); 172 + int dm_suspended(struct mapped_device *md); 173 + 174 + /* 175 + * Geometry functions. 176 + */ 177 + int dm_get_geometry(struct mapped_device *md, struct hd_geometry *geo); 178 + int dm_set_geometry(struct mapped_device *md, struct hd_geometry *geo); 179 + 180 + 181 + /*----------------------------------------------------------------- 182 + * Functions for manipulating device-mapper tables. 183 + *---------------------------------------------------------------*/ 184 + 185 + /* 186 + * First create an empty table. 187 + */ 188 + int dm_table_create(struct dm_table **result, int mode, 189 + unsigned num_targets, struct mapped_device *md); 190 + 191 + /* 192 + * Then call this once for each target. 193 + */ 194 + int dm_table_add_target(struct dm_table *t, const char *type, 195 + sector_t start, sector_t len, char *params); 196 + 197 + /* 198 + * Finally call this to make the table ready for use. 199 + */ 200 + int dm_table_complete(struct dm_table *t); 201 + 202 + /* 203 + * Table reference counting. 204 + */ 205 + struct dm_table *dm_get_table(struct mapped_device *md); 206 + void dm_table_get(struct dm_table *t); 207 + void dm_table_put(struct dm_table *t); 208 + 209 + /* 210 + * Queries 211 + */ 212 + sector_t dm_table_get_size(struct dm_table *t); 213 + unsigned int dm_table_get_num_targets(struct dm_table *t); 214 + int dm_table_get_mode(struct dm_table *t); 215 + struct mapped_device *dm_table_get_md(struct dm_table *t); 216 + 217 + /* 218 + * Trigger an event. 219 + */ 220 + void dm_table_event(struct dm_table *t); 221 + 222 + /* 223 + * The device must be suspended before calling this method. 224 + */ 225 + int dm_swap_table(struct mapped_device *md, struct dm_table *t); 226 + 227 + #endif /* __KERNEL__ */ 228 + #endif /* _LINUX_DEVICE_MAPPER_H */