dm-io.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. /* FIXME make this configurable */
  10. #define DM_MAX_IO_REGIONS 8
  11. struct io_region {
  12. struct block_device *bdev;
  13. sector_t sector;
  14. sector_t count;
  15. };
  16. struct page_list {
  17. struct page_list *next;
  18. struct page *page;
  19. };
  20. /*
  21. * 'error' is a bitset, with each bit indicating whether an error
  22. * occurred doing io to the corresponding region.
  23. */
  24. typedef void (*io_notify_fn)(unsigned long error, void *context);
  25. /*
  26. * Before anyone uses the IO interface they should call
  27. * dm_io_get(), specifying roughly how many pages they are
  28. * expecting to perform io on concurrently.
  29. *
  30. * This function may block.
  31. */
  32. int dm_io_get(unsigned int num_pages);
  33. void dm_io_put(unsigned int num_pages);
  34. /*
  35. * Synchronous IO.
  36. *
  37. * Please ensure that the rw flag in the next two functions is
  38. * either READ or WRITE, ie. we don't take READA. Any
  39. * regions with a zero count field will be ignored.
  40. */
  41. int dm_io_sync(unsigned int num_regions, struct io_region *where, int rw,
  42. struct page_list *pl, unsigned int offset,
  43. unsigned long *error_bits);
  44. int dm_io_sync_bvec(unsigned int num_regions, struct io_region *where, int rw,
  45. struct bio_vec *bvec, unsigned long *error_bits);
  46. int dm_io_sync_vm(unsigned int num_regions, struct io_region *where, int rw,
  47. void *data, unsigned long *error_bits);
  48. /*
  49. * Aynchronous IO.
  50. *
  51. * The 'where' array may be safely allocated on the stack since
  52. * the function takes a copy.
  53. */
  54. int dm_io_async(unsigned int num_regions, struct io_region *where, int rw,
  55. struct page_list *pl, unsigned int offset,
  56. io_notify_fn fn, void *context);
  57. int dm_io_async_bvec(unsigned int num_regions, struct io_region *where, int rw,
  58. struct bio_vec *bvec, io_notify_fn fn, void *context);
  59. int dm_io_async_vm(unsigned int num_regions, struct io_region *where, int rw,
  60. void *data, io_notify_fn fn, void *context);
  61. #endif