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