dm-io.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Copyright (C) 2003 Sistina Software
  3. * Copyright (C) 2004 - 2008 Red Hat, Inc. All rights reserved.
  4. *
  5. * Device-Mapper low-level I/O.
  6. *
  7. * This file is released under the GPL.
  8. */
  9. #ifndef _LINUX_DM_IO_H
  10. #define _LINUX_DM_IO_H
  11. #ifdef __KERNEL__
  12. #include <linux/types.h>
  13. #include <linux/blk_types.h>
  14. struct dm_io_region {
  15. struct block_device *bdev;
  16. sector_t sector;
  17. sector_t count; /* If this is zero the region is ignored. */
  18. };
  19. struct page_list {
  20. struct page_list *next;
  21. struct page *page;
  22. };
  23. typedef void (*io_notify_fn)(unsigned int long error, void *context);
  24. enum dm_io_mem_type {
  25. DM_IO_PAGE_LIST,/* Page list */
  26. DM_IO_BIO, /* Bio vector */
  27. DM_IO_VMA, /* Virtual memory area */
  28. DM_IO_KMEM, /* Kernel memory */
  29. };
  30. struct dm_io_memory {
  31. enum dm_io_mem_type type;
  32. unsigned int offset;
  33. union {
  34. struct page_list *pl;
  35. struct bio *bio;
  36. void *vma;
  37. void *addr;
  38. } ptr;
  39. };
  40. struct dm_io_notify {
  41. io_notify_fn fn; /* Callback for asynchronous requests */
  42. void *context; /* Passed to callback */
  43. };
  44. /*
  45. * IO request structure
  46. */
  47. struct dm_io_client;
  48. struct dm_io_request {
  49. blk_opf_t bi_opf; /* Request type and flags */
  50. struct dm_io_memory mem; /* Memory to use for io */
  51. struct dm_io_notify notify; /* Synchronous if notify.fn is NULL */
  52. struct dm_io_client *client; /* Client memory handler */
  53. };
  54. /*
  55. * For async io calls, users can alternatively use the dm_io() function below
  56. * and dm_io_client_create() to create private mempools for the client.
  57. *
  58. * Create/destroy may block.
  59. */
  60. struct dm_io_client *dm_io_client_create(void);
  61. void dm_io_client_destroy(struct dm_io_client *client);
  62. /*
  63. * IO interface using private per-client pools.
  64. * Each bit in the optional 'sync_error_bits' bitset indicates whether an
  65. * error occurred doing io to the corresponding region.
  66. */
  67. int dm_io(struct dm_io_request *io_req, unsigned int num_regions,
  68. struct dm_io_region *region, unsigned int long *sync_error_bits);
  69. #endif /* __KERNEL__ */
  70. #endif /* _LINUX_DM_IO_H */