aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-io.h
diff options
context:
space:
mode:
authorHeinz Mauelshagen <hjm@redhat.com>2007-05-09 05:33:01 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-09 15:30:47 -0400
commitc8b03afe3d38a635861e4bfa5c563d844e754a91 (patch)
treed23d2aa8d6cec93bab6e23ffd2199509e7d85113 /drivers/md/dm-io.h
parent891ce207011d3d9219f79fd5114c8594bbacc653 (diff)
dm io: new interface
Add a new API to dm-io.c that uses a private mempool and bio_set for each client. The new functions to use are dm_io_client_create(), dm_io_client_destroy(), dm_io_client_resize() and dm_io(). Signed-off-by: Heinz Mauelshagen <hjm@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com> Cc: Milan Broz <mbroz@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/md/dm-io.h')
-rw-r--r--drivers/md/dm-io.h52
1 files changed, 51 insertions, 1 deletions
diff --git a/drivers/md/dm-io.h b/drivers/md/dm-io.h
index f9035bfd1a9f..05b133825580 100644
--- a/drivers/md/dm-io.h
+++ b/drivers/md/dm-io.h
@@ -20,13 +20,47 @@ struct page_list {
20 struct page *page; 20 struct page *page;
21}; 21};
22 22
23
24/* 23/*
25 * 'error' is a bitset, with each bit indicating whether an error 24 * 'error' is a bitset, with each bit indicating whether an error
26 * occurred doing io to the corresponding region. 25 * occurred doing io to the corresponding region.
27 */ 26 */
28typedef void (*io_notify_fn)(unsigned long error, void *context); 27typedef void (*io_notify_fn)(unsigned long error, void *context);
29 28
29enum dm_io_mem_type {
30 DM_IO_PAGE_LIST,/* Page list */
31 DM_IO_BVEC, /* Bio vector */
32 DM_IO_VMA, /* Virtual memory area */
33 DM_IO_KMEM, /* Kernel memory */
34};
35
36struct dm_io_memory {
37 enum dm_io_mem_type type;
38
39 union {
40 struct page_list *pl;
41 struct bio_vec *bvec;
42 void *vma;
43 void *addr;
44 } ptr;
45
46 unsigned offset;
47};
48
49struct dm_io_notify {
50 io_notify_fn fn; /* Callback for asynchronous requests */
51 void *context; /* Passed to callback */
52};
53
54/*
55 * IO request structure
56 */
57struct dm_io_client;
58struct dm_io_request {
59 int bi_rw; /* READ|WRITE - not READA */
60 struct dm_io_memory mem; /* Memory to use for io */
61 struct dm_io_notify notify; /* Synchronous if notify.fn is NULL */
62 struct dm_io_client *client; /* Client memory handler */
63};
30 64
31/* 65/*
32 * Before anyone uses the IO interface they should call 66 * Before anyone uses the IO interface they should call
@@ -39,6 +73,16 @@ int dm_io_get(unsigned int num_pages);
39void dm_io_put(unsigned int num_pages); 73void dm_io_put(unsigned int num_pages);
40 74
41/* 75/*
76 * For async io calls, users can alternatively use the dm_io() function below
77 * and dm_io_client_create() to create private mempools for the client.
78 *
79 * Create/destroy may block.
80 */
81struct dm_io_client *dm_io_client_create(unsigned num_pages);
82int dm_io_client_resize(unsigned num_pages, struct dm_io_client *client);
83void dm_io_client_destroy(struct dm_io_client *client);
84
85/*
42 * Synchronous IO. 86 * Synchronous IO.
43 * 87 *
44 * Please ensure that the rw flag in the next two functions is 88 * Please ensure that the rw flag in the next two functions is
@@ -71,4 +115,10 @@ int dm_io_async_bvec(unsigned int num_regions, struct io_region *where, int rw,
71int dm_io_async_vm(unsigned int num_regions, struct io_region *where, int rw, 115int dm_io_async_vm(unsigned int num_regions, struct io_region *where, int rw,
72 void *data, io_notify_fn fn, void *context); 116 void *data, io_notify_fn fn, void *context);
73 117
118/*
119 * IO interface using private per-client pools.
120 */
121int dm_io(struct dm_io_request *io_req, unsigned num_regions,
122 struct io_region *region, unsigned long *sync_error_bits);
123
74#endif 124#endif