diff options
Diffstat (limited to 'include/linux/device-mapper.h')
| -rw-r--r-- | include/linux/device-mapper.h | 96 |
1 files changed, 92 insertions, 4 deletions
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index cb784579956b..ad3b787479a4 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h | |||
| @@ -1,6 +1,6 @@ | |||
| 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-2008 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 | */ |
| @@ -10,6 +10,8 @@ | |||
| 10 | 10 | ||
| 11 | #ifdef __KERNEL__ | 11 | #ifdef __KERNEL__ |
| 12 | 12 | ||
| 13 | #include <linux/bio.h> | ||
| 14 | |||
| 13 | struct dm_target; | 15 | struct dm_target; |
| 14 | struct dm_table; | 16 | struct dm_table; |
| 15 | struct dm_dev; | 17 | struct dm_dev; |
| @@ -250,11 +252,97 @@ void dm_table_event(struct dm_table *t); | |||
| 250 | */ | 252 | */ |
| 251 | int dm_swap_table(struct mapped_device *md, struct dm_table *t); | 253 | int dm_swap_table(struct mapped_device *md, struct dm_table *t); |
| 252 | 254 | ||
| 255 | /*----------------------------------------------------------------- | ||
| 256 | * Macros. | ||
| 257 | *---------------------------------------------------------------*/ | ||
| 258 | #define DM_NAME "device-mapper" | ||
| 259 | |||
| 260 | #define DMERR(f, arg...) \ | ||
| 261 | printk(KERN_ERR DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg) | ||
| 262 | #define DMERR_LIMIT(f, arg...) \ | ||
| 263 | do { \ | ||
| 264 | if (printk_ratelimit()) \ | ||
| 265 | printk(KERN_ERR DM_NAME ": " DM_MSG_PREFIX ": " \ | ||
| 266 | f "\n", ## arg); \ | ||
| 267 | } while (0) | ||
| 268 | |||
| 269 | #define DMWARN(f, arg...) \ | ||
| 270 | printk(KERN_WARNING DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg) | ||
| 271 | #define DMWARN_LIMIT(f, arg...) \ | ||
| 272 | do { \ | ||
| 273 | if (printk_ratelimit()) \ | ||
| 274 | printk(KERN_WARNING DM_NAME ": " DM_MSG_PREFIX ": " \ | ||
| 275 | f "\n", ## arg); \ | ||
| 276 | } while (0) | ||
| 277 | |||
| 278 | #define DMINFO(f, arg...) \ | ||
| 279 | printk(KERN_INFO DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg) | ||
| 280 | #define DMINFO_LIMIT(f, arg...) \ | ||
| 281 | do { \ | ||
| 282 | if (printk_ratelimit()) \ | ||
| 283 | printk(KERN_INFO DM_NAME ": " DM_MSG_PREFIX ": " f \ | ||
| 284 | "\n", ## arg); \ | ||
| 285 | } while (0) | ||
| 286 | |||
| 287 | #ifdef CONFIG_DM_DEBUG | ||
| 288 | # define DMDEBUG(f, arg...) \ | ||
| 289 | printk(KERN_DEBUG DM_NAME ": " DM_MSG_PREFIX " DEBUG: " f "\n", ## arg) | ||
| 290 | # define DMDEBUG_LIMIT(f, arg...) \ | ||
| 291 | do { \ | ||
| 292 | if (printk_ratelimit()) \ | ||
| 293 | printk(KERN_DEBUG DM_NAME ": " DM_MSG_PREFIX ": " f \ | ||
| 294 | "\n", ## arg); \ | ||
| 295 | } while (0) | ||
| 296 | #else | ||
| 297 | # define DMDEBUG(f, arg...) do {} while (0) | ||
| 298 | # define DMDEBUG_LIMIT(f, arg...) do {} while (0) | ||
| 299 | #endif | ||
| 300 | |||
| 301 | #define DMEMIT(x...) sz += ((sz >= maxlen) ? \ | ||
| 302 | 0 : scnprintf(result + sz, maxlen - sz, x)) | ||
| 303 | |||
| 304 | #define SECTOR_SHIFT 9 | ||
| 305 | |||
| 306 | /* | ||
| 307 | * Definitions of return values from target end_io function. | ||
| 308 | */ | ||
| 309 | #define DM_ENDIO_INCOMPLETE 1 | ||
| 310 | #define DM_ENDIO_REQUEUE 2 | ||
| 311 | |||
| 312 | /* | ||
| 313 | * Definitions of return values from target map function. | ||
| 314 | */ | ||
| 315 | #define DM_MAPIO_SUBMITTED 0 | ||
| 316 | #define DM_MAPIO_REMAPPED 1 | ||
| 317 | #define DM_MAPIO_REQUEUE DM_ENDIO_REQUEUE | ||
| 318 | |||
| 319 | /* | ||
| 320 | * Ceiling(n / sz) | ||
| 321 | */ | ||
| 322 | #define dm_div_up(n, sz) (((n) + (sz) - 1) / (sz)) | ||
| 323 | |||
| 324 | #define dm_sector_div_up(n, sz) ( \ | ||
| 325 | { \ | ||
| 326 | sector_t _r = ((n) + (sz) - 1); \ | ||
| 327 | sector_div(_r, (sz)); \ | ||
| 328 | _r; \ | ||
| 329 | } \ | ||
| 330 | ) | ||
| 331 | |||
| 253 | /* | 332 | /* |
| 254 | * Prepare a table for a device that will error all I/O. | 333 | * ceiling(n / size) * size |
| 255 | * To make it active, call dm_suspend(), dm_swap_table() then dm_resume(). | ||
| 256 | */ | 334 | */ |
| 257 | int dm_create_error_table(struct dm_table **result, struct mapped_device *md); | 335 | #define dm_round_up(n, sz) (dm_div_up((n), (sz)) * (sz)) |
| 336 | |||
| 337 | static inline sector_t to_sector(unsigned long n) | ||
| 338 | { | ||
| 339 | return (n >> SECTOR_SHIFT); | ||
| 340 | } | ||
| 341 | |||
| 342 | static inline unsigned long to_bytes(sector_t n) | ||
| 343 | { | ||
| 344 | return (n << SECTOR_SHIFT); | ||
| 345 | } | ||
| 258 | 346 | ||
| 259 | #endif /* __KERNEL__ */ | 347 | #endif /* __KERNEL__ */ |
| 260 | #endif /* _LINUX_DEVICE_MAPPER_H */ | 348 | #endif /* _LINUX_DEVICE_MAPPER_H */ |
