dm-io.h 1.9 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. struct dm_io_region {
  14. struct block_device *bdev;
  15. sector_t sector;
  16. sector_t count; /* If this is zero the region is ignored. */
  17. };
  18. struct page_list {
  19. struct page_list *next;
  20. struct page *page;
  21. };
  22. typedef void (*io_notify_fn)(unsigned long error, void *context);
  23. enum dm_io_mem_type {
  24. DM_IO_PAGE_LIST,/* Page list */
  25. DM_IO_BIO, /* Bio vector */
  26. DM_IO_VMA, /* Virtual memory area */
  27. DM_IO_KMEM, /* Kernel memory */
  28. };
  29. struct dm_io_memory {
  30. enum dm_io_mem_type type;
  31. unsigned offset;
  32. union {
  33. struct page_list *pl;
  34. struct bio *bio;
  35. void *vma;
  36. void *addr;
  37. } ptr;
  38. };
  39. struct dm_io_notify {
  40. io_notify_fn fn; /* Callback for asynchronous requests */
  41. void *context; /* Passed to callback */
  42. };
  43. /*
  44. * IO request structure
  45. */
  46. struct dm_io_client;
  47. struct dm_io_request {
  48. int bi_op; /* REQ_OP */
  49. int bi_op_flags; /* req_flag_bits */
  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 num_regions,
  68. struct dm_io_region *region, unsigned long *sync_error_bits);
  69. #endif /* __KERNEL__ */
  70. #endif /* _LINUX_DM_IO_H */