2 * Copyright (C) 2001 Sistina Software (UK) Limited.
4 * This file is released under the LGPL.
7 #ifndef _LINUX_DEVICE_MAPPER_H
8 #define _LINUX_DEVICE_MAPPER_H
14 typedef enum { STATUSTYPE_INFO, STATUSTYPE_TABLE } status_type_t;
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:
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);
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
76 struct module *module;
82 dm_suspend_fn suspend;
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;
97 struct dm_table *table;
98 struct target_type *type;
104 /* FIXME: turn this into a mask, and merge with io_restrictions */
108 * These are automatically filled in by
109 * dm_table_get_device.
111 struct io_restrictions limits;
113 /* target specific data */
116 /* Used to provide an error string from the ctr */
120 int dm_register_target(struct target_type *t);
121 int dm_unregister_target(struct target_type *t);
123 #endif /* _LINUX_DEVICE_MAPPER_H */