Commit | Line | Data |
---|---|---|
3bd94003 | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
1da177e4 LT |
2 | /* |
3 | * Copyright (C) 2003 Sistina Software | |
22a1ceb1 HM |
4 | * Copyright (C) 2004 - 2008 Red Hat, Inc. All rights reserved. |
5 | * | |
6 | * Device-Mapper low-level I/O. | |
1da177e4 LT |
7 | * |
8 | * This file is released under the GPL. | |
9 | */ | |
10 | ||
22a1ceb1 HM |
11 | #ifndef _LINUX_DM_IO_H |
12 | #define _LINUX_DM_IO_H | |
13 | ||
14 | #ifdef __KERNEL__ | |
1da177e4 | 15 | |
22a1ceb1 | 16 | #include <linux/types.h> |
581075e4 | 17 | #include <linux/blk_types.h> |
1da177e4 | 18 | |
22a1ceb1 | 19 | struct dm_io_region { |
1da177e4 LT |
20 | struct block_device *bdev; |
21 | sector_t sector; | |
bf17ce3a | 22 | sector_t count; /* If this is zero the region is ignored. */ |
1da177e4 LT |
23 | }; |
24 | ||
25 | struct page_list { | |
26 | struct page_list *next; | |
27 | struct page *page; | |
28 | }; | |
29 | ||
86a3238c | 30 | typedef void (*io_notify_fn)(unsigned int long error, void *context); |
1da177e4 | 31 | |
c8b03afe HM |
32 | enum dm_io_mem_type { |
33 | DM_IO_PAGE_LIST,/* Page list */ | |
003b5c57 | 34 | DM_IO_BIO, /* Bio vector */ |
c8b03afe HM |
35 | DM_IO_VMA, /* Virtual memory area */ |
36 | DM_IO_KMEM, /* Kernel memory */ | |
37 | }; | |
38 | ||
39 | struct dm_io_memory { | |
40 | enum dm_io_mem_type type; | |
41 | ||
86a3238c | 42 | unsigned int offset; |
924e600d | 43 | |
c8b03afe HM |
44 | union { |
45 | struct page_list *pl; | |
003b5c57 | 46 | struct bio *bio; |
c8b03afe HM |
47 | void *vma; |
48 | void *addr; | |
49 | } ptr; | |
c8b03afe HM |
50 | }; |
51 | ||
52 | struct dm_io_notify { | |
53 | io_notify_fn fn; /* Callback for asynchronous requests */ | |
54 | void *context; /* Passed to callback */ | |
55 | }; | |
56 | ||
57 | /* | |
58 | * IO request structure | |
59 | */ | |
60 | struct dm_io_client; | |
61 | struct dm_io_request { | |
581075e4 | 62 | blk_opf_t bi_opf; /* Request type and flags */ |
c8b03afe HM |
63 | struct dm_io_memory mem; /* Memory to use for io */ |
64 | struct dm_io_notify notify; /* Synchronous if notify.fn is NULL */ | |
65 | struct dm_io_client *client; /* Client memory handler */ | |
66 | }; | |
1da177e4 | 67 | |
c8b03afe HM |
68 | /* |
69 | * For async io calls, users can alternatively use the dm_io() function below | |
70 | * and dm_io_client_create() to create private mempools for the client. | |
71 | * | |
72 | * Create/destroy may block. | |
73 | */ | |
bda8efec | 74 | struct dm_io_client *dm_io_client_create(void); |
c8b03afe HM |
75 | void dm_io_client_destroy(struct dm_io_client *client); |
76 | ||
c8b03afe HM |
77 | /* |
78 | * IO interface using private per-client pools. | |
bf17ce3a MB |
79 | * Each bit in the optional 'sync_error_bits' bitset indicates whether an |
80 | * error occurred doing io to the corresponding region. | |
c8b03afe | 81 | */ |
86a3238c HM |
82 | int dm_io(struct dm_io_request *io_req, unsigned int num_regions, |
83 | struct dm_io_region *region, unsigned int long *sync_error_bits); | |
c8b03afe | 84 | |
22a1ceb1 HM |
85 | #endif /* __KERNEL__ */ |
86 | #endif /* _LINUX_DM_IO_H */ |