Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2003 Sistina Software |
Heinz Mauelshagen | 22a1ceb | 2008-04-24 21:43:17 +0100 | [diff] [blame] | 3 | * Copyright (C) 2004 - 2008 Red Hat, Inc. All rights reserved. |
| 4 | * |
| 5 | * Device-Mapper low-level I/O. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * |
| 7 | * This file is released under the GPL. |
| 8 | */ |
| 9 | |
Heinz Mauelshagen | 22a1ceb | 2008-04-24 21:43:17 +0100 | [diff] [blame] | 10 | #ifndef _LINUX_DM_IO_H |
| 11 | #define _LINUX_DM_IO_H |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | |
Heinz Mauelshagen | 22a1ceb | 2008-04-24 21:43:17 +0100 | [diff] [blame] | 13 | #ifdef __KERNEL__ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | |
Heinz Mauelshagen | 22a1ceb | 2008-04-24 21:43:17 +0100 | [diff] [blame] | 15 | #include <linux/types.h> |
| 16 | |
| 17 | struct dm_io_region { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | struct block_device *bdev; |
| 19 | sector_t sector; |
Milan Broz | bf17ce3 | 2007-05-09 02:33:05 -0700 | [diff] [blame] | 20 | sector_t count; /* If this is zero the region is ignored. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | }; |
| 22 | |
| 23 | struct page_list { |
| 24 | struct page_list *next; |
| 25 | struct page *page; |
| 26 | }; |
| 27 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | typedef void (*io_notify_fn)(unsigned long error, void *context); |
| 29 | |
Heinz Mauelshagen | c8b03af | 2007-05-09 02:33:01 -0700 | [diff] [blame] | 30 | enum dm_io_mem_type { |
| 31 | DM_IO_PAGE_LIST,/* Page list */ |
Kent Overstreet | 003b5c5 | 2013-10-11 15:45:43 -0700 | [diff] [blame] | 32 | DM_IO_BIO, /* Bio vector */ |
Heinz Mauelshagen | c8b03af | 2007-05-09 02:33:01 -0700 | [diff] [blame] | 33 | DM_IO_VMA, /* Virtual memory area */ |
| 34 | DM_IO_KMEM, /* Kernel memory */ |
| 35 | }; |
| 36 | |
| 37 | struct dm_io_memory { |
| 38 | enum dm_io_mem_type type; |
| 39 | |
Mike Snitzer | 924e600 | 2010-03-06 02:32:33 +0000 | [diff] [blame] | 40 | unsigned offset; |
| 41 | |
Heinz Mauelshagen | c8b03af | 2007-05-09 02:33:01 -0700 | [diff] [blame] | 42 | union { |
| 43 | struct page_list *pl; |
Kent Overstreet | 003b5c5 | 2013-10-11 15:45:43 -0700 | [diff] [blame] | 44 | struct bio *bio; |
Heinz Mauelshagen | c8b03af | 2007-05-09 02:33:01 -0700 | [diff] [blame] | 45 | void *vma; |
| 46 | void *addr; |
| 47 | } ptr; |
Heinz Mauelshagen | c8b03af | 2007-05-09 02:33:01 -0700 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | struct dm_io_notify { |
| 51 | io_notify_fn fn; /* Callback for asynchronous requests */ |
| 52 | void *context; /* Passed to callback */ |
| 53 | }; |
| 54 | |
| 55 | /* |
| 56 | * IO request structure |
| 57 | */ |
| 58 | struct dm_io_client; |
| 59 | struct dm_io_request { |
Mike Christie | e604714 | 2016-06-05 14:32:04 -0500 | [diff] [blame] | 60 | int bi_op; /* REQ_OP */ |
| 61 | int bi_op_flags; /* rq_flag_bits */ |
Heinz Mauelshagen | c8b03af | 2007-05-09 02:33:01 -0700 | [diff] [blame] | 62 | struct dm_io_memory mem; /* Memory to use for io */ |
| 63 | struct dm_io_notify notify; /* Synchronous if notify.fn is NULL */ |
| 64 | struct dm_io_client *client; /* Client memory handler */ |
| 65 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | |
| 67 | /* |
Heinz Mauelshagen | c8b03af | 2007-05-09 02:33:01 -0700 | [diff] [blame] | 68 | * For async io calls, users can alternatively use the dm_io() function below |
| 69 | * and dm_io_client_create() to create private mempools for the client. |
| 70 | * |
| 71 | * Create/destroy may block. |
| 72 | */ |
Mikulas Patocka | bda8efe | 2011-05-29 13:03:09 +0100 | [diff] [blame] | 73 | struct dm_io_client *dm_io_client_create(void); |
Heinz Mauelshagen | c8b03af | 2007-05-09 02:33:01 -0700 | [diff] [blame] | 74 | void dm_io_client_destroy(struct dm_io_client *client); |
| 75 | |
| 76 | /* |
Heinz Mauelshagen | c8b03af | 2007-05-09 02:33:01 -0700 | [diff] [blame] | 77 | * IO interface using private per-client pools. |
Milan Broz | bf17ce3 | 2007-05-09 02:33:05 -0700 | [diff] [blame] | 78 | * Each bit in the optional 'sync_error_bits' bitset indicates whether an |
| 79 | * error occurred doing io to the corresponding region. |
Heinz Mauelshagen | c8b03af | 2007-05-09 02:33:01 -0700 | [diff] [blame] | 80 | */ |
| 81 | int dm_io(struct dm_io_request *io_req, unsigned num_regions, |
Heinz Mauelshagen | 22a1ceb | 2008-04-24 21:43:17 +0100 | [diff] [blame] | 82 | struct dm_io_region *region, unsigned long *sync_error_bits); |
Heinz Mauelshagen | c8b03af | 2007-05-09 02:33:01 -0700 | [diff] [blame] | 83 | |
Heinz Mauelshagen | 22a1ceb | 2008-04-24 21:43:17 +0100 | [diff] [blame] | 84 | #endif /* __KERNEL__ */ |
| 85 | #endif /* _LINUX_DM_IO_H */ |