dm-io.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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_rw; /* READ|WRITE - not READA */
  49. struct dm_io_memory mem; /* Memory to use for io */
  50. struct dm_io_notify notify; /* Synchronous if notify.fn is NULL */
  51. struct dm_io_client *client; /* Client memory handler */
  52. };
  53. /*
  54. * For async io calls, users can alternatively use the dm_io() function below
  55. * and dm_io_client_create() to create private mempools for the client.
  56. *
  57. * Create/destroy may block.
  58. */
  59. struct dm_io_client *dm_io_client_create(void);
  60. void dm_io_client_destroy(struct dm_io_client *client);
  61. /*
  62. * IO interface using private per-client pools.
  63. * Each bit in the optional 'sync_error_bits' bitset indicates whether an
  64. * error occurred doing io to the corresponding region.
  65. */
  66. int dm_io(struct dm_io_request *io_req, unsigned num_regions,
  67. struct dm_io_region *region, unsigned long *sync_error_bits);
  68. #endif /* __KERNEL__ */
  69. #endif /* _LINUX_DM_IO_H */