Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (C) 2003 Sistina Software
0003  * Copyright (C) 2004 - 2008 Red Hat, Inc. All rights reserved.
0004  *
0005  * Device-Mapper low-level I/O.
0006  *
0007  * This file is released under the GPL.
0008  */
0009 
0010 #ifndef _LINUX_DM_IO_H
0011 #define _LINUX_DM_IO_H
0012 
0013 #ifdef __KERNEL__
0014 
0015 #include <linux/types.h>
0016 #include <linux/blk_types.h>
0017 
0018 struct dm_io_region {
0019     struct block_device *bdev;
0020     sector_t sector;
0021     sector_t count;     /* If this is zero the region is ignored. */
0022 };
0023 
0024 struct page_list {
0025     struct page_list *next;
0026     struct page *page;
0027 };
0028 
0029 typedef void (*io_notify_fn)(unsigned long error, void *context);
0030 
0031 enum dm_io_mem_type {
0032     DM_IO_PAGE_LIST,/* Page list */
0033     DM_IO_BIO,  /* Bio vector */
0034     DM_IO_VMA,  /* Virtual memory area */
0035     DM_IO_KMEM, /* Kernel memory */
0036 };
0037 
0038 struct dm_io_memory {
0039     enum dm_io_mem_type type;
0040 
0041     unsigned offset;
0042 
0043     union {
0044         struct page_list *pl;
0045         struct bio *bio;
0046         void *vma;
0047         void *addr;
0048     } ptr;
0049 };
0050 
0051 struct dm_io_notify {
0052     io_notify_fn fn;    /* Callback for asynchronous requests */
0053     void *context;      /* Passed to callback */
0054 };
0055 
0056 /*
0057  * IO request structure
0058  */
0059 struct dm_io_client;
0060 struct dm_io_request {
0061     blk_opf_t       bi_opf; /* Request type and flags */
0062     struct dm_io_memory mem;    /* Memory to use for io */
0063     struct dm_io_notify notify; /* Synchronous if notify.fn is NULL */
0064     struct dm_io_client *client;    /* Client memory handler */
0065 };
0066 
0067 /*
0068  * For async io calls, users can alternatively use the dm_io() function below
0069  * and dm_io_client_create() to create private mempools for the client.
0070  *
0071  * Create/destroy may block.
0072  */
0073 struct dm_io_client *dm_io_client_create(void);
0074 void dm_io_client_destroy(struct dm_io_client *client);
0075 
0076 /*
0077  * IO interface using private per-client pools.
0078  * Each bit in the optional 'sync_error_bits' bitset indicates whether an
0079  * error occurred doing io to the corresponding region.
0080  */
0081 int dm_io(struct dm_io_request *io_req, unsigned num_regions,
0082       struct dm_io_region *region, unsigned long *sync_error_bits);
0083 
0084 #endif  /* __KERNEL__ */
0085 #endif  /* _LINUX_DM_IO_H */