dm-io.h 1.93 KB
Newer Older
Linus Torvalds's avatar
Linus Torvalds committed
1 2
/*
 * Copyright (C) 2003 Sistina Software
3 4 5
 * Copyright (C) 2004 - 2008 Red Hat, Inc. All rights reserved.
 *
 * Device-Mapper low-level I/O.
Linus Torvalds's avatar
Linus Torvalds committed
6 7 8 9
 *
 * This file is released under the GPL.
 */

10 11 12 13
#ifndef _LINUX_DM_IO_H
#define _LINUX_DM_IO_H

#ifdef __KERNEL__
Linus Torvalds's avatar
Linus Torvalds committed
14

15
#include <linux/types.h>
Linus Torvalds's avatar
Linus Torvalds committed
16

17
struct dm_io_region {
Linus Torvalds's avatar
Linus Torvalds committed
18 19
	struct block_device *bdev;
	sector_t sector;
Milan Broz's avatar
Milan Broz committed
20
	sector_t count;		/* If this is zero the region is ignored. */
Linus Torvalds's avatar
Linus Torvalds committed
21 22 23 24 25 26 27 28 29
};

struct page_list {
	struct page_list *next;
	struct page *page;
};

typedef void (*io_notify_fn)(unsigned long error, void *context);

Heinz Mauelshagen's avatar
Heinz Mauelshagen committed
30 31
enum dm_io_mem_type {
	DM_IO_PAGE_LIST,/* Page list */
32
	DM_IO_BIO,	/* Bio vector */
Heinz Mauelshagen's avatar
Heinz Mauelshagen committed
33 34 35 36 37 38 39
	DM_IO_VMA,	/* Virtual memory area */
	DM_IO_KMEM,	/* Kernel memory */
};

struct dm_io_memory {
	enum dm_io_mem_type type;

40 41
	unsigned offset;

Heinz Mauelshagen's avatar
Heinz Mauelshagen committed
42 43
	union {
		struct page_list *pl;
44
		struct bio *bio;
Heinz Mauelshagen's avatar
Heinz Mauelshagen committed
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
		void *vma;
		void *addr;
	} ptr;
};

struct dm_io_notify {
	io_notify_fn fn;	/* Callback for asynchronous requests */
	void *context;		/* Passed to callback */
};

/*
 * IO request structure
 */
struct dm_io_client;
struct dm_io_request {
Mike Christie's avatar
Mike Christie committed
60
	int bi_op;			/* REQ_OP */
61
	int bi_op_flags;		/* req_flag_bits */
Heinz Mauelshagen's avatar
Heinz Mauelshagen committed
62 63 64 65
	struct dm_io_memory mem;	/* Memory to use for io */
	struct dm_io_notify notify;	/* Synchronous if notify.fn is NULL */
	struct dm_io_client *client;	/* Client memory handler */
};
Linus Torvalds's avatar
Linus Torvalds committed
66

Heinz Mauelshagen's avatar
Heinz Mauelshagen committed
67 68 69 70 71 72
/*
 * For async io calls, users can alternatively use the dm_io() function below
 * and dm_io_client_create() to create private mempools for the client.
 *
 * Create/destroy may block.
 */
73
struct dm_io_client *dm_io_client_create(void);
Heinz Mauelshagen's avatar
Heinz Mauelshagen committed
74 75 76 77
void dm_io_client_destroy(struct dm_io_client *client);

/*
 * IO interface using private per-client pools.
Milan Broz's avatar
Milan Broz committed
78 79
 * Each bit in the optional 'sync_error_bits' bitset indicates whether an
 * error occurred doing io to the corresponding region.
Heinz Mauelshagen's avatar
Heinz Mauelshagen committed
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);
Heinz Mauelshagen's avatar
Heinz Mauelshagen committed
83

84 85
#endif	/* __KERNEL__ */
#endif	/* _LINUX_DM_IO_H */