Merge branch 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc
[wrt350n-kernel.git] / drivers / md / dm-io.h
blobf647e2cceaa673f8098fce058832a3cc55ce23c4
1 /*
2 * Copyright (C) 2003 Sistina Software
4 * This file is released under the GPL.
5 */
7 #ifndef _DM_IO_H
8 #define _DM_IO_H
10 #include "dm.h"
12 struct io_region {
13 struct block_device *bdev;
14 sector_t sector;
15 sector_t count; /* If this is zero the region is ignored. */
18 struct page_list {
19 struct page_list *next;
20 struct page *page;
23 typedef void (*io_notify_fn)(unsigned long error, void *context);
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 */
32 struct dm_io_memory {
33 enum dm_io_mem_type type;
35 union {
36 struct page_list *pl;
37 struct bio_vec *bvec;
38 void *vma;
39 void *addr;
40 } ptr;
42 unsigned offset;
45 struct dm_io_notify {
46 io_notify_fn fn; /* Callback for asynchronous requests */
47 void *context; /* Passed to callback */
51 * IO request structure
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 */
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.
65 * Create/destroy may block.
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);
72 * IO interface using private per-client pools.
73 * Each bit in the optional 'sync_error_bits' bitset indicates whether an
74 * error occurred doing io to the corresponding region.
76 int dm_io(struct dm_io_request *io_req, unsigned num_regions,
77 struct io_region *region, unsigned long *sync_error_bits);
79 #endif