dm-io.h 1.9 KB

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