diff options
Diffstat (limited to 'drivers/md/dm-io.h')
-rw-r--r-- | drivers/md/dm-io.h | 83 |
1 files changed, 44 insertions, 39 deletions
diff --git a/drivers/md/dm-io.h b/drivers/md/dm-io.h index f9035bfd1a9f..f647e2cceaa6 100644 --- a/drivers/md/dm-io.h +++ b/drivers/md/dm-io.h | |||
@@ -12,7 +12,7 @@ | |||
12 | struct io_region { | 12 | struct io_region { |
13 | struct block_device *bdev; | 13 | struct block_device *bdev; |
14 | sector_t sector; | 14 | sector_t sector; |
15 | sector_t count; | 15 | sector_t count; /* If this is zero the region is ignored. */ |
16 | }; | 16 | }; |
17 | 17 | ||
18 | struct page_list { | 18 | struct page_list { |
@@ -20,55 +20,60 @@ struct page_list { | |||
20 | struct page *page; | 20 | struct page *page; |
21 | }; | 21 | }; |
22 | 22 | ||
23 | |||
24 | /* | ||
25 | * 'error' is a bitset, with each bit indicating whether an error | ||
26 | * occurred doing io to the corresponding region. | ||
27 | */ | ||
28 | typedef void (*io_notify_fn)(unsigned long error, void *context); | 23 | typedef void (*io_notify_fn)(unsigned long error, void *context); |
29 | 24 | ||
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 | }; | ||
30 | 49 | ||
31 | /* | 50 | /* |
32 | * Before anyone uses the IO interface they should call | 51 | * IO request structure |
33 | * dm_io_get(), specifying roughly how many pages they are | ||
34 | * expecting to perform io on concurrently. | ||
35 | * | ||
36 | * This function may block. | ||
37 | */ | 52 | */ |
38 | int dm_io_get(unsigned int num_pages); | 53 | struct dm_io_client; |
39 | void dm_io_put(unsigned int num_pages); | 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 | }; | ||
40 | 60 | ||
41 | /* | 61 | /* |
42 | * Synchronous IO. | 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. | ||
43 | * | 64 | * |
44 | * Please ensure that the rw flag in the next two functions is | 65 | * Create/destroy may block. |
45 | * either READ or WRITE, ie. we don't take READA. Any | ||
46 | * regions with a zero count field will be ignored. | ||
47 | */ | 66 | */ |
48 | int dm_io_sync(unsigned int num_regions, struct io_region *where, int rw, | 67 | struct dm_io_client *dm_io_client_create(unsigned num_pages); |
49 | struct page_list *pl, unsigned int offset, | 68 | int dm_io_client_resize(unsigned num_pages, struct dm_io_client *client); |
50 | unsigned long *error_bits); | 69 | void dm_io_client_destroy(struct dm_io_client *client); |
51 | |||
52 | int dm_io_sync_bvec(unsigned int num_regions, struct io_region *where, int rw, | ||
53 | struct bio_vec *bvec, unsigned long *error_bits); | ||
54 | |||
55 | int dm_io_sync_vm(unsigned int num_regions, struct io_region *where, int rw, | ||
56 | void *data, unsigned long *error_bits); | ||
57 | 70 | ||
58 | /* | 71 | /* |
59 | * Aynchronous IO. | 72 | * IO interface using private per-client pools. |
60 | * | 73 | * Each bit in the optional 'sync_error_bits' bitset indicates whether an |
61 | * The 'where' array may be safely allocated on the stack since | 74 | * error occurred doing io to the corresponding region. |
62 | * the function takes a copy. | ||
63 | */ | 75 | */ |
64 | int dm_io_async(unsigned int num_regions, struct io_region *where, int rw, | 76 | int dm_io(struct dm_io_request *io_req, unsigned num_regions, |
65 | struct page_list *pl, unsigned int offset, | 77 | struct io_region *region, unsigned long *sync_error_bits); |
66 | io_notify_fn fn, void *context); | ||
67 | |||
68 | int dm_io_async_bvec(unsigned int num_regions, struct io_region *where, int rw, | ||
69 | struct bio_vec *bvec, io_notify_fn fn, void *context); | ||
70 | |||
71 | int dm_io_async_vm(unsigned int num_regions, struct io_region *where, int rw, | ||
72 | void *data, io_notify_fn fn, void *context); | ||
73 | 78 | ||
74 | #endif | 79 | #endif |