diff options
Diffstat (limited to 'include/linux/device-mapper.h')
| -rw-r--r-- | include/linux/device-mapper.h | 111 |
1 files changed, 109 insertions, 2 deletions
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index aee10b2ea4c6..e3d1c33d1558 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h | |||
| @@ -8,9 +8,12 @@ | |||
| 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 | #ifdef __KERNEL__ | ||
| 12 | |||
| 11 | struct dm_target; | 13 | struct dm_target; |
| 12 | struct dm_table; | 14 | struct dm_table; |
| 13 | struct dm_dev; | 15 | struct dm_dev; |
| 16 | struct mapped_device; | ||
| 14 | 17 | ||
| 15 | typedef enum { STATUSTYPE_INFO, STATUSTYPE_TABLE } status_type_t; | 18 | typedef enum { STATUSTYPE_INFO, STATUSTYPE_TABLE } status_type_t; |
| 16 | 19 | ||
| @@ -78,7 +81,7 @@ void dm_put_device(struct dm_target *ti, struct dm_dev *d); | |||
| 78 | struct target_type { | 81 | struct target_type { |
| 79 | const char *name; | 82 | const char *name; |
| 80 | struct module *module; | 83 | struct module *module; |
| 81 | unsigned version[3]; | 84 | unsigned version[3]; |
| 82 | dm_ctr_fn ctr; | 85 | dm_ctr_fn ctr; |
| 83 | dm_dtr_fn dtr; | 86 | dm_dtr_fn dtr; |
| 84 | dm_map_fn map; | 87 | dm_map_fn map; |
| @@ -128,4 +131,108 @@ struct dm_target { | |||
| 128 | int dm_register_target(struct target_type *t); | 131 | int dm_register_target(struct target_type *t); |
| 129 | int dm_unregister_target(struct target_type *t); | 132 | int dm_unregister_target(struct target_type *t); |
| 130 | 133 | ||
| 131 | #endif /* _LINUX_DEVICE_MAPPER_H */ | 134 | |
| 135 | /*----------------------------------------------------------------- | ||
| 136 | * Functions for creating and manipulating mapped devices. | ||
| 137 | * Drop the reference with dm_put when you finish with the object. | ||
| 138 | *---------------------------------------------------------------*/ | ||
| 139 | |||
| 140 | /* | ||
| 141 | * DM_ANY_MINOR chooses the next available minor number. | ||
| 142 | */ | ||
| 143 | #define DM_ANY_MINOR (-1) | ||
| 144 | int dm_create(int minor, struct mapped_device **md); | ||
| 145 | |||
| 146 | /* | ||
| 147 | * Reference counting for md. | ||
| 148 | */ | ||
| 149 | struct mapped_device *dm_get_md(dev_t dev); | ||
| 150 | void dm_get(struct mapped_device *md); | ||
| 151 | void dm_put(struct mapped_device *md); | ||
| 152 | |||
| 153 | /* | ||
| 154 | * An arbitrary pointer may be stored alongside a mapped device. | ||
| 155 | */ | ||
| 156 | void dm_set_mdptr(struct mapped_device *md, void *ptr); | ||
| 157 | void *dm_get_mdptr(struct mapped_device *md); | ||
| 158 | |||
| 159 | /* | ||
| 160 | * A device can still be used while suspended, but I/O is deferred. | ||
| 161 | */ | ||
| 162 | int dm_suspend(struct mapped_device *md, int with_lockfs); | ||
| 163 | int dm_resume(struct mapped_device *md); | ||
| 164 | |||
| 165 | /* | ||
| 166 | * Event functions. | ||
| 167 | */ | ||
| 168 | uint32_t dm_get_event_nr(struct mapped_device *md); | ||
| 169 | int dm_wait_event(struct mapped_device *md, int event_nr); | ||
| 170 | |||
| 171 | /* | ||
| 172 | * Info functions. | ||
| 173 | */ | ||
| 174 | const char *dm_device_name(struct mapped_device *md); | ||
| 175 | struct gendisk *dm_disk(struct mapped_device *md); | ||
| 176 | int dm_suspended(struct mapped_device *md); | ||
| 177 | |||
| 178 | /* | ||
| 179 | * Geometry functions. | ||
| 180 | */ | ||
| 181 | int dm_get_geometry(struct mapped_device *md, struct hd_geometry *geo); | ||
| 182 | int dm_set_geometry(struct mapped_device *md, struct hd_geometry *geo); | ||
| 183 | |||
| 184 | |||
| 185 | /*----------------------------------------------------------------- | ||
| 186 | * Functions for manipulating device-mapper tables. | ||
| 187 | *---------------------------------------------------------------*/ | ||
| 188 | |||
| 189 | /* | ||
| 190 | * First create an empty table. | ||
| 191 | */ | ||
| 192 | int dm_table_create(struct dm_table **result, int mode, | ||
| 193 | unsigned num_targets, struct mapped_device *md); | ||
| 194 | |||
| 195 | /* | ||
| 196 | * Then call this once for each target. | ||
| 197 | */ | ||
| 198 | int dm_table_add_target(struct dm_table *t, const char *type, | ||
| 199 | sector_t start, sector_t len, char *params); | ||
| 200 | |||
| 201 | /* | ||
| 202 | * Finally call this to make the table ready for use. | ||
| 203 | */ | ||
| 204 | int dm_table_complete(struct dm_table *t); | ||
| 205 | |||
| 206 | /* | ||
| 207 | * Table reference counting. | ||
| 208 | */ | ||
| 209 | struct dm_table *dm_get_table(struct mapped_device *md); | ||
| 210 | void dm_table_get(struct dm_table *t); | ||
| 211 | void dm_table_put(struct dm_table *t); | ||
| 212 | |||
| 213 | /* | ||
| 214 | * Queries | ||
| 215 | */ | ||
| 216 | sector_t dm_table_get_size(struct dm_table *t); | ||
| 217 | unsigned int dm_table_get_num_targets(struct dm_table *t); | ||
| 218 | int dm_table_get_mode(struct dm_table *t); | ||
| 219 | struct mapped_device *dm_table_get_md(struct dm_table *t); | ||
| 220 | |||
| 221 | /* | ||
| 222 | * Trigger an event. | ||
| 223 | */ | ||
| 224 | void dm_table_event(struct dm_table *t); | ||
| 225 | |||
| 226 | /* | ||
| 227 | * The device must be suspended before calling this method. | ||
| 228 | */ | ||
| 229 | int dm_swap_table(struct mapped_device *md, struct dm_table *t); | ||
| 230 | |||
| 231 | /* | ||
| 232 | * Prepare a table for a device that will error all I/O. | ||
| 233 | * To make it active, call dm_suspend(), dm_swap_table() then dm_resume(). | ||
| 234 | */ | ||
| 235 | int dm_create_error_table(struct dm_table **result, struct mapped_device *md); | ||
| 236 | |||
| 237 | #endif /* __KERNEL__ */ | ||
| 238 | #endif /* _LINUX_DEVICE_MAPPER_H */ | ||
