1 /* 2 * Copyright (C) 2003 Sistina Software 3 * Copyright (C) 2004 - 2008 Red Hat, Inc. All rights reserved. 4 * 5 * Device-Mapper low-level I/O. 6 * 7 * This file is released under the GPL. 8 */ 9 10 #ifndef _LINUX_DM_IO_H 11 #define _LINUX_DM_IO_H 12 13 #ifdef __KERNEL__ 14 15 #include <linux/types.h> 16 #include <linux/blk_types.h> 17 18 struct dm_io_region { 19 struct block_device *bdev; 20 sector_t sector; 21 sector_t count; /* If this is zero the region is ignored. */ 22 }; 23 24 struct page_list { 25 struct page_list *next; 26 struct page *page; 27 }; 28 29 typedef void (*io_notify_fn)(unsigned long error, void *context); 30 31 enum dm_io_mem_type { 32 DM_IO_PAGE_LIST,/* Page list */ 33 DM_IO_BIO, /* Bio vector */ 34 DM_IO_VMA, /* Virtual memory area */ 35 DM_IO_KMEM, /* Kernel memory */ 36 }; 37 38 struct dm_io_memory { 39 enum dm_io_mem_type type; 40 41 unsigned offset; 42 43 union { 44 struct page_list *pl; 45 struct bio *bio; 46 void *vma; 47 void *addr; 48 } ptr; 49 }; 50 51 struct dm_io_notify { 52 io_notify_fn fn; /* Callback for asynchronous requests */ 53 void *context; /* Passed to callback */ 54 }; 55 56 /* 57 * IO request structure 58 */ 59 struct dm_io_client; 60 struct dm_io_request { 61 blk_opf_t bi_opf; /* Request type and flags */ 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 }; 66 67 /* 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 */ 73 struct dm_io_client *dm_io_client_create(void); 74 void dm_io_client_destroy(struct dm_io_client *client); 75 76 /* 77 * IO interface using private per-client pools. 78 * Each bit in the optional 'sync_error_bits' bitset indicates whether an 79 * error occurred doing io to the corresponding region. 80 */ 81 int dm_io(struct dm_io_request *io_req, unsigned num_regions, 82 struct dm_io_region *region, unsigned long *sync_error_bits); 83 84 #endif /* __KERNEL__ */ 85 #endif /* _LINUX_DM_IO_H */ 86