diff options
author | Alasdair G Kergon <agk@redhat.com> | 2008-04-24 16:43:52 -0400 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2008-04-25 08:26:53 -0400 |
commit | 0da336e5fab75c712ba8c67f3135d5a20528465f (patch) | |
tree | 8907bfc6db07ba73979df23d99424984aa02d3d7 /include/linux/device-mapper.h | |
parent | 945fa4d283a3a472186c11028f6fea1e77a91d14 (diff) |
dm: expose macros
Make dm.h macros and inlines available in include/linux/device-mapper.h
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'include/linux/device-mapper.h')
-rw-r--r-- | include/linux/device-mapper.h | 94 |
1 files changed, 93 insertions, 1 deletions
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index 4db23378cfb1..a68829e274fe 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 | */ |
@@ -258,5 +258,97 @@ int dm_swap_table(struct mapped_device *md, struct dm_table *t); | |||
258 | */ | 258 | */ |
259 | int dm_create_error_table(struct dm_table **result, struct mapped_device *md); | 259 | int dm_create_error_table(struct dm_table **result, struct mapped_device *md); |
260 | 260 | ||
261 | /*----------------------------------------------------------------- | ||
262 | * Macros. | ||
263 | *---------------------------------------------------------------*/ | ||
264 | #define DM_NAME "device-mapper" | ||
265 | |||
266 | #define DMERR(f, arg...) \ | ||
267 | printk(KERN_ERR DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg) | ||
268 | #define DMERR_LIMIT(f, arg...) \ | ||
269 | do { \ | ||
270 | if (printk_ratelimit()) \ | ||
271 | printk(KERN_ERR DM_NAME ": " DM_MSG_PREFIX ": " \ | ||
272 | f "\n", ## arg); \ | ||
273 | } while (0) | ||
274 | |||
275 | #define DMWARN(f, arg...) \ | ||
276 | printk(KERN_WARNING DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg) | ||
277 | #define DMWARN_LIMIT(f, arg...) \ | ||
278 | do { \ | ||
279 | if (printk_ratelimit()) \ | ||
280 | printk(KERN_WARNING DM_NAME ": " DM_MSG_PREFIX ": " \ | ||
281 | f "\n", ## arg); \ | ||
282 | } while (0) | ||
283 | |||
284 | #define DMINFO(f, arg...) \ | ||
285 | printk(KERN_INFO DM_NAME ": " DM_MSG_PREFIX ": " f "\n", ## arg) | ||
286 | #define DMINFO_LIMIT(f, arg...) \ | ||
287 | do { \ | ||
288 | if (printk_ratelimit()) \ | ||
289 | printk(KERN_INFO DM_NAME ": " DM_MSG_PREFIX ": " f \ | ||
290 | "\n", ## arg); \ | ||
291 | } while (0) | ||
292 | |||
293 | #ifdef CONFIG_DM_DEBUG | ||
294 | # define DMDEBUG(f, arg...) \ | ||
295 | printk(KERN_DEBUG DM_NAME ": " DM_MSG_PREFIX " DEBUG: " f "\n", ## arg) | ||
296 | # define DMDEBUG_LIMIT(f, arg...) \ | ||
297 | do { \ | ||
298 | if (printk_ratelimit()) \ | ||
299 | printk(KERN_DEBUG DM_NAME ": " DM_MSG_PREFIX ": " f \ | ||
300 | "\n", ## arg); \ | ||
301 | } while (0) | ||
302 | #else | ||
303 | # define DMDEBUG(f, arg...) do {} while (0) | ||
304 | # define DMDEBUG_LIMIT(f, arg...) do {} while (0) | ||
305 | #endif | ||
306 | |||
307 | #define DMEMIT(x...) sz += ((sz >= maxlen) ? \ | ||
308 | 0 : scnprintf(result + sz, maxlen - sz, x)) | ||
309 | |||
310 | #define SECTOR_SHIFT 9 | ||
311 | |||
312 | /* | ||
313 | * Definitions of return values from target end_io function. | ||
314 | */ | ||
315 | #define DM_ENDIO_INCOMPLETE 1 | ||
316 | #define DM_ENDIO_REQUEUE 2 | ||
317 | |||
318 | /* | ||
319 | * Definitions of return values from target map function. | ||
320 | */ | ||
321 | #define DM_MAPIO_SUBMITTED 0 | ||
322 | #define DM_MAPIO_REMAPPED 1 | ||
323 | #define DM_MAPIO_REQUEUE DM_ENDIO_REQUEUE | ||
324 | |||
325 | /* | ||
326 | * Ceiling(n / sz) | ||
327 | */ | ||
328 | #define dm_div_up(n, sz) (((n) + (sz) - 1) / (sz)) | ||
329 | |||
330 | #define dm_sector_div_up(n, sz) ( \ | ||
331 | { \ | ||
332 | sector_t _r = ((n) + (sz) - 1); \ | ||
333 | sector_div(_r, (sz)); \ | ||
334 | _r; \ | ||
335 | } \ | ||
336 | ) | ||
337 | |||
338 | /* | ||
339 | * ceiling(n / size) * size | ||
340 | */ | ||
341 | #define dm_round_up(n, sz) (dm_div_up((n), (sz)) * (sz)) | ||
342 | |||
343 | static inline sector_t to_sector(unsigned long n) | ||
344 | { | ||
345 | return (n >> SECTOR_SHIFT); | ||
346 | } | ||
347 | |||
348 | static inline unsigned long to_bytes(sector_t n) | ||
349 | { | ||
350 | return (n << SECTOR_SHIFT); | ||
351 | } | ||
352 | |||
261 | #endif /* __KERNEL__ */ | 353 | #endif /* __KERNEL__ */ |
262 | #endif /* _LINUX_DEVICE_MAPPER_H */ | 354 | #endif /* _LINUX_DEVICE_MAPPER_H */ |