dm-io.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (C) 2003 Sistina Software
  3. *
  4. * This file is released under the GPL.
  5. */
  6. #ifndef _DM_IO_H
  7. #define _DM_IO_H
  8. #include "dm.h"
  9. struct io_region {
  10. struct block_device *bdev;
  11. sector_t sector;
  12. sector_t count; /* If this is zero the region is ignored. */
  13. };
  14. struct page_list {
  15. struct page_list *next;
  16. struct page *page;
  17. };
  18. typedef void (*io_notify_fn)(unsigned long error, void *context);
  19. enum dm_io_mem_type {
  20. DM_IO_PAGE_LIST,/* Page list */
  21. DM_IO_BVEC, /* Bio vector */
  22. DM_IO_VMA, /* Virtual memory area */
  23. DM_IO_KMEM, /* Kernel memory */
  24. };
  25. struct dm_io_memory {
  26. enum dm_io_mem_type type;
  27. union {
  28. struct page_list *pl;
  29. struct bio_vec *bvec;
  30. void *vma;
  31. void *addr;
  32. } ptr;
  33. unsigned offset;
  34. };
  35. struct dm_io_notify {
  36. io_notify_fn fn; /* Callback for asynchronous requests */
  37. void *context; /* Passed to callback */
  38. };
  39. /*
  40. * IO request structure
  41. */
  42. struct dm_io_client;
  43. struct dm_io_request {
  44. int bi_rw; /* READ|WRITE - not READA */
  45. struct dm_io_memory mem; /* Memory to use for io */
  46. struct dm_io_notify notify; /* Synchronous if notify.fn is NULL */
  47. struct dm_io_client *client; /* Client memory handler */
  48. };
  49. /*
  50. * For async io calls, users can alternatively use the dm_io() function below
  51. * and dm_io_client_create() to create private mempools for the client.
  52. *
  53. * Create/destroy may block.
  54. */
  55. struct dm_io_client *dm_io_client_create(unsigned num_pages);
  56. int dm_io_client_resize(unsigned num_pages, struct dm_io_client *client);
  57. void dm_io_client_destroy(struct dm_io_client *client);
  58. /*
  59. * IO interface using private per-client pools.
  60. * Each bit in the optional 'sync_error_bits' bitset indicates whether an
  61. * error occurred doing io to the corresponding region.
  62. */
  63. int dm_io(struct dm_io_request *io_req, unsigned num_regions,
  64. struct io_region *region, unsigned long *sync_error_bits);
  65. #endif