diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/md/dm-log.h |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'drivers/md/dm-log.h')
-rw-r--r-- | drivers/md/dm-log.h | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/drivers/md/dm-log.h b/drivers/md/dm-log.h new file mode 100644 index 000000000000..5ae5309ebf28 --- /dev/null +++ b/drivers/md/dm-log.h | |||
@@ -0,0 +1,130 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2003 Sistina Software | ||
3 | * | ||
4 | * This file is released under the LGPL. | ||
5 | */ | ||
6 | |||
7 | #ifndef DM_DIRTY_LOG | ||
8 | #define DM_DIRTY_LOG | ||
9 | |||
10 | #include "dm.h" | ||
11 | |||
12 | typedef sector_t region_t; | ||
13 | |||
14 | struct dirty_log_type; | ||
15 | |||
16 | struct dirty_log { | ||
17 | struct dirty_log_type *type; | ||
18 | void *context; | ||
19 | }; | ||
20 | |||
21 | struct dirty_log_type { | ||
22 | struct list_head list; | ||
23 | const char *name; | ||
24 | struct module *module; | ||
25 | unsigned int use_count; | ||
26 | |||
27 | int (*ctr)(struct dirty_log *log, struct dm_target *ti, | ||
28 | unsigned int argc, char **argv); | ||
29 | void (*dtr)(struct dirty_log *log); | ||
30 | |||
31 | /* | ||
32 | * There are times when we don't want the log to touch | ||
33 | * the disk. | ||
34 | */ | ||
35 | int (*suspend)(struct dirty_log *log); | ||
36 | int (*resume)(struct dirty_log *log); | ||
37 | |||
38 | /* | ||
39 | * Retrieves the smallest size of region that the log can | ||
40 | * deal with. | ||
41 | */ | ||
42 | uint32_t (*get_region_size)(struct dirty_log *log); | ||
43 | |||
44 | /* | ||
45 | * A predicate to say whether a region is clean or not. | ||
46 | * May block. | ||
47 | */ | ||
48 | int (*is_clean)(struct dirty_log *log, region_t region); | ||
49 | |||
50 | /* | ||
51 | * Returns: 0, 1, -EWOULDBLOCK, < 0 | ||
52 | * | ||
53 | * A predicate function to check the area given by | ||
54 | * [sector, sector + len) is in sync. | ||
55 | * | ||
56 | * If -EWOULDBLOCK is returned the state of the region is | ||
57 | * unknown, typically this will result in a read being | ||
58 | * passed to a daemon to deal with, since a daemon is | ||
59 | * allowed to block. | ||
60 | */ | ||
61 | int (*in_sync)(struct dirty_log *log, region_t region, int can_block); | ||
62 | |||
63 | /* | ||
64 | * Flush the current log state (eg, to disk). This | ||
65 | * function may block. | ||
66 | */ | ||
67 | int (*flush)(struct dirty_log *log); | ||
68 | |||
69 | /* | ||
70 | * Mark an area as clean or dirty. These functions may | ||
71 | * block, though for performance reasons blocking should | ||
72 | * be extremely rare (eg, allocating another chunk of | ||
73 | * memory for some reason). | ||
74 | */ | ||
75 | void (*mark_region)(struct dirty_log *log, region_t region); | ||
76 | void (*clear_region)(struct dirty_log *log, region_t region); | ||
77 | |||
78 | /* | ||
79 | * Returns: <0 (error), 0 (no region), 1 (region) | ||
80 | * | ||
81 | * The mirrord will need perform recovery on regions of | ||
82 | * the mirror that are in the NOSYNC state. This | ||
83 | * function asks the log to tell the caller about the | ||
84 | * next region that this machine should recover. | ||
85 | * | ||
86 | * Do not confuse this function with 'in_sync()', one | ||
87 | * tells you if an area is synchronised, the other | ||
88 | * assigns recovery work. | ||
89 | */ | ||
90 | int (*get_resync_work)(struct dirty_log *log, region_t *region); | ||
91 | |||
92 | /* | ||
93 | * This notifies the log that the resync of an area has | ||
94 | * been completed. The log should then mark this region | ||
95 | * as CLEAN. | ||
96 | */ | ||
97 | void (*complete_resync_work)(struct dirty_log *log, | ||
98 | region_t region, int success); | ||
99 | |||
100 | /* | ||
101 | * Returns the number of regions that are in sync. | ||
102 | */ | ||
103 | region_t (*get_sync_count)(struct dirty_log *log); | ||
104 | |||
105 | /* | ||
106 | * Support function for mirror status requests. | ||
107 | */ | ||
108 | int (*status)(struct dirty_log *log, status_type_t status_type, | ||
109 | char *result, unsigned int maxlen); | ||
110 | }; | ||
111 | |||
112 | int dm_register_dirty_log_type(struct dirty_log_type *type); | ||
113 | int dm_unregister_dirty_log_type(struct dirty_log_type *type); | ||
114 | |||
115 | |||
116 | /* | ||
117 | * Make sure you use these two functions, rather than calling | ||
118 | * type->constructor/destructor() directly. | ||
119 | */ | ||
120 | struct dirty_log *dm_create_dirty_log(const char *type_name, struct dm_target *ti, | ||
121 | unsigned int argc, char **argv); | ||
122 | void dm_destroy_dirty_log(struct dirty_log *log); | ||
123 | |||
124 | /* | ||
125 | * init/exit functions. | ||
126 | */ | ||
127 | int dm_dirty_log_init(void); | ||
128 | void dm_dirty_log_exit(void); | ||
129 | |||
130 | #endif | ||