2 * Copyright (C) 2001 Sistina Software (UK) Limited.
3 * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
5 * This file is released under the LGPL.
8 #ifndef _LINUX_DEVICE_MAPPER_H
9 #define _LINUX_DEVICE_MAPPER_H
15 typedef enum { STATUSTYPE_INFO
, STATUSTYPE_TABLE
} status_type_t
;
19 unsigned long long ll
;
23 * In the constructor the target parameter will already have the
24 * table, type, begin and len fields filled in.
26 typedef int (*dm_ctr_fn
) (struct dm_target
*target
,
27 unsigned int argc
, char **argv
);
30 * The destructor doesn't need to free the dm_target, just
31 * anything hidden ti->private.
33 typedef void (*dm_dtr_fn
) (struct dm_target
*ti
);
36 * The map function must return:
38 * = 0: The target will handle the io by resubmitting it later
39 * > 0: simple remap complete
41 typedef int (*dm_map_fn
) (struct dm_target
*ti
, struct bio
*bio
,
42 union map_info
*map_context
);
46 * < 0 : error (currently ignored)
47 * 0 : ended successfully
48 * 1 : for some reason the io has still not completed (eg,
49 * multipath target might want to requeue a failed io).
51 typedef int (*dm_endio_fn
) (struct dm_target
*ti
,
52 struct bio
*bio
, int error
,
53 union map_info
*map_context
);
55 typedef void (*dm_presuspend_fn
) (struct dm_target
*ti
);
56 typedef void (*dm_postsuspend_fn
) (struct dm_target
*ti
);
57 typedef void (*dm_resume_fn
) (struct dm_target
*ti
);
59 typedef int (*dm_status_fn
) (struct dm_target
*ti
, status_type_t status_type
,
60 char *result
, unsigned int maxlen
);
62 typedef int (*dm_message_fn
) (struct dm_target
*ti
, unsigned argc
, char **argv
);
64 void dm_error(const char *message
);
67 * Constructors should call these functions to ensure destination devices
68 * are opened/closed correctly.
69 * FIXME: too many arguments.
71 int dm_get_device(struct dm_target
*ti
, const char *path
, sector_t start
,
72 sector_t len
, int mode
, struct dm_dev
**result
);
73 void dm_put_device(struct dm_target
*ti
, struct dm_dev
*d
);
76 * Information about a target type
80 struct module
*module
;
86 dm_presuspend_fn presuspend
;
87 dm_postsuspend_fn postsuspend
;
90 dm_message_fn message
;
93 struct io_restrictions
{
94 unsigned int max_sectors
;
95 unsigned short max_phys_segments
;
96 unsigned short max_hw_segments
;
97 unsigned short hardsect_size
;
98 unsigned int max_segment_size
;
99 unsigned long seg_boundary_mask
;
100 unsigned char no_cluster
; /* inverted so that 0 is default */
104 struct dm_table
*table
;
105 struct target_type
*type
;
111 /* FIXME: turn this into a mask, and merge with io_restrictions */
112 /* Always a power of 2 */
116 * These are automatically filled in by
117 * dm_table_get_device.
119 struct io_restrictions limits
;
121 /* target specific data */
124 /* Used to provide an error string from the ctr */
128 int dm_register_target(struct target_type
*t
);
129 int dm_unregister_target(struct target_type
*t
);
131 #endif /* _LINUX_DEVICE_MAPPER_H */