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