Rev 422 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
422 | giacomo | 1 | /* |
2 | * Copyright (C) 2001 Sistina Software (UK) Limited. |
||
3 | * |
||
4 | * This file is released under the LGPL. |
||
5 | */ |
||
6 | |||
7 | #ifndef _LINUX_DEVICE_MAPPER_H |
||
8 | #define _LINUX_DEVICE_MAPPER_H |
||
9 | |||
10 | struct dm_target; |
||
11 | struct dm_table; |
||
12 | struct dm_dev; |
||
13 | |||
14 | typedef enum { STATUSTYPE_INFO, STATUSTYPE_TABLE } status_type_t; |
||
15 | |||
16 | /* |
||
17 | * In the constructor the target parameter will already have the |
||
18 | * table, type, begin and len fields filled in. |
||
19 | */ |
||
20 | typedef int (*dm_ctr_fn) (struct dm_target *target, |
||
21 | unsigned int argc, char **argv); |
||
22 | |||
23 | /* |
||
24 | * The destructor doesn't need to free the dm_target, just |
||
25 | * anything hidden ti->private. |
||
26 | */ |
||
27 | typedef void (*dm_dtr_fn) (struct dm_target *ti); |
||
28 | |||
29 | /* |
||
30 | * The map function must return: |
||
31 | * < 0: error |
||
32 | * = 0: The target will handle the io by resubmitting it later |
||
33 | * > 0: simple remap complete |
||
34 | */ |
||
35 | typedef int (*dm_map_fn) (struct dm_target *ti, struct bio *bio); |
||
36 | |||
37 | typedef void (*dm_suspend_fn) (struct dm_target *ti); |
||
38 | typedef void (*dm_resume_fn) (struct dm_target *ti); |
||
39 | |||
40 | typedef int (*dm_status_fn) (struct dm_target *ti, status_type_t status_type, |
||
41 | char *result, unsigned int maxlen); |
||
42 | |||
43 | void dm_error(const char *message); |
||
44 | |||
45 | /* |
||
46 | * Constructors should call these functions to ensure destination devices |
||
47 | * are opened/closed correctly. |
||
48 | * FIXME: too many arguments. |
||
49 | */ |
||
50 | int dm_get_device(struct dm_target *ti, const char *path, sector_t start, |
||
51 | sector_t len, int mode, struct dm_dev **result); |
||
52 | void dm_put_device(struct dm_target *ti, struct dm_dev *d); |
||
53 | |||
54 | /* |
||
55 | * Information about a target type |
||
56 | */ |
||
57 | struct target_type { |
||
58 | const char *name; |
||
59 | struct module *module; |
||
60 | dm_ctr_fn ctr; |
||
61 | dm_dtr_fn dtr; |
||
62 | dm_map_fn map; |
||
63 | dm_suspend_fn suspend; |
||
64 | dm_resume_fn resume; |
||
65 | dm_status_fn status; |
||
66 | }; |
||
67 | |||
68 | struct io_restrictions { |
||
69 | unsigned short max_sectors; |
||
70 | unsigned short max_phys_segments; |
||
71 | unsigned short max_hw_segments; |
||
72 | unsigned short hardsect_size; |
||
73 | unsigned int max_segment_size; |
||
74 | unsigned long seg_boundary_mask; |
||
75 | }; |
||
76 | |||
77 | struct dm_target { |
||
78 | struct dm_table *table; |
||
79 | struct target_type *type; |
||
80 | |||
81 | /* target limits */ |
||
82 | sector_t begin; |
||
83 | sector_t len; |
||
84 | |||
85 | /* FIXME: turn this into a mask, and merge with io_restrictions */ |
||
86 | sector_t split_io; |
||
87 | |||
88 | /* |
||
89 | * These are automaticall filled in by |
||
90 | * dm_table_get_device. |
||
91 | */ |
||
92 | struct io_restrictions limits; |
||
93 | |||
94 | /* target specific data */ |
||
95 | void *private; |
||
96 | |||
97 | /* Used to provide an error string from the ctr */ |
||
98 | char *error; |
||
99 | }; |
||
100 | |||
101 | int dm_register_target(struct target_type *t); |
||
102 | int dm_unregister_target(struct target_type *t); |
||
103 | |||
104 | #endif /* _LINUX_DEVICE_MAPPER_H */ |