MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / include / linux / device-mapper.h
blob7abe54e3ee7049e177d1664a273d874b852bce5d
1 /*
2 * Copyright (C) 2001 Sistina Software (UK) Limited.
4 * This file is released under the LGPL.
5 */
7 #ifndef _LINUX_DEVICE_MAPPER_H
8 #define _LINUX_DEVICE_MAPPER_H
10 struct dm_target;
11 struct dm_table;
12 struct dm_dev;
14 typedef enum { STATUSTYPE_INFO, STATUSTYPE_TABLE } status_type_t;
16 union map_info {
17 void *ptr;
18 unsigned long long ll;
22 * In the constructor the target parameter will already have the
23 * table, type, begin and len fields filled in.
25 typedef int (*dm_ctr_fn) (struct dm_target *target,
26 unsigned int argc, char **argv);
29 * The destructor doesn't need to free the dm_target, just
30 * anything hidden ti->private.
32 typedef void (*dm_dtr_fn) (struct dm_target *ti);
35 * The map function must return:
36 * < 0: error
37 * = 0: The target will handle the io by resubmitting it later
38 * > 0: simple remap complete
40 typedef int (*dm_map_fn) (struct dm_target *ti, struct bio *bio,
41 union map_info *map_context);
44 * Returns:
45 * < 0 : error (currently ignored)
46 * 0 : ended successfully
47 * 1 : for some reason the io has still not completed (eg,
48 * multipath target might want to requeue a failed io).
50 typedef int (*dm_endio_fn) (struct dm_target *ti,
51 struct bio *bio, int error,
52 union map_info *map_context);
54 typedef void (*dm_suspend_fn) (struct dm_target *ti);
55 typedef void (*dm_resume_fn) (struct dm_target *ti);
57 typedef int (*dm_status_fn) (struct dm_target *ti, status_type_t status_type,
58 char *result, unsigned int maxlen);
60 void dm_error(const char *message);
63 * Constructors should call these functions to ensure destination devices
64 * are opened/closed correctly.
65 * FIXME: too many arguments.
67 int dm_get_device(struct dm_target *ti, const char *path, sector_t start,
68 sector_t len, int mode, struct dm_dev **result);
69 void dm_put_device(struct dm_target *ti, struct dm_dev *d);
72 * Information about a target type
74 struct target_type {
75 const char *name;
76 struct module *module;
77 unsigned version[3];
78 dm_ctr_fn ctr;
79 dm_dtr_fn dtr;
80 dm_map_fn map;
81 dm_endio_fn end_io;
82 dm_suspend_fn suspend;
83 dm_resume_fn resume;
84 dm_status_fn status;
87 struct io_restrictions {
88 unsigned short max_sectors;
89 unsigned short max_phys_segments;
90 unsigned short max_hw_segments;
91 unsigned short hardsect_size;
92 unsigned int max_segment_size;
93 unsigned long seg_boundary_mask;
96 struct dm_target {
97 struct dm_table *table;
98 struct target_type *type;
100 /* target limits */
101 sector_t begin;
102 sector_t len;
104 /* FIXME: turn this into a mask, and merge with io_restrictions */
105 sector_t split_io;
108 * These are automatically filled in by
109 * dm_table_get_device.
111 struct io_restrictions limits;
113 /* target specific data */
114 void *private;
116 /* Used to provide an error string from the ctr */
117 char *error;
120 int dm_register_target(struct target_type *t);
121 int dm_unregister_target(struct target_type *t);
123 #endif /* _LINUX_DEVICE_MAPPER_H */