Kobject: rename kobject_init_ng() to kobject_init()
[safe/jmp/linux-2.6] / drivers / md / dm-io.h
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
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. */
16 };
17
18 struct page_list {
19         struct page_list *next;
20         struct page *page;
21 };
22
23 typedef void (*io_notify_fn)(unsigned long error, void *context);
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 };
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 };
60
61 /*
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 /*
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.
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
79 #endif