]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - include/linux/dm-dirty-log.h
Merge branch 'drm-radeon-linus' of ../drm-next
[mirror_ubuntu-artful-kernel.git] / include / linux / dm-dirty-log.h
1 /*
2 * Copyright (C) 2003 Sistina Software
3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
4 *
5 * Device-Mapper dirty region log.
6 *
7 * This file is released under the LGPL.
8 */
9
10 #ifndef _LINUX_DM_DIRTY_LOG
11 #define _LINUX_DM_DIRTY_LOG
12
13 #ifdef __KERNEL__
14
15 #include <linux/types.h>
16 #include <linux/device-mapper.h>
17
18 typedef sector_t region_t;
19
20 struct dm_dirty_log_type;
21
22 struct dm_dirty_log {
23 struct dm_dirty_log_type *type;
24 int (*flush_callback_fn)(struct dm_target *ti);
25 void *context;
26 };
27
28 struct dm_dirty_log_type {
29 const char *name;
30 struct module *module;
31
32 /* For internal device-mapper use */
33 struct list_head list;
34
35 int (*ctr)(struct dm_dirty_log *log, struct dm_target *ti,
36 unsigned argc, char **argv);
37 void (*dtr)(struct dm_dirty_log *log);
38
39 /*
40 * There are times when we don't want the log to touch
41 * the disk.
42 */
43 int (*presuspend)(struct dm_dirty_log *log);
44 int (*postsuspend)(struct dm_dirty_log *log);
45 int (*resume)(struct dm_dirty_log *log);
46
47 /*
48 * Retrieves the smallest size of region that the log can
49 * deal with.
50 */
51 uint32_t (*get_region_size)(struct dm_dirty_log *log);
52
53 /*
54 * A predicate to say whether a region is clean or not.
55 * May block.
56 */
57 int (*is_clean)(struct dm_dirty_log *log, region_t region);
58
59 /*
60 * Returns: 0, 1, -EWOULDBLOCK, < 0
61 *
62 * A predicate function to check the area given by
63 * [sector, sector + len) is in sync.
64 *
65 * If -EWOULDBLOCK is returned the state of the region is
66 * unknown, typically this will result in a read being
67 * passed to a daemon to deal with, since a daemon is
68 * allowed to block.
69 */
70 int (*in_sync)(struct dm_dirty_log *log, region_t region,
71 int can_block);
72
73 /*
74 * Flush the current log state (eg, to disk). This
75 * function may block.
76 */
77 int (*flush)(struct dm_dirty_log *log);
78
79 /*
80 * Mark an area as clean or dirty. These functions may
81 * block, though for performance reasons blocking should
82 * be extremely rare (eg, allocating another chunk of
83 * memory for some reason).
84 */
85 void (*mark_region)(struct dm_dirty_log *log, region_t region);
86 void (*clear_region)(struct dm_dirty_log *log, region_t region);
87
88 /*
89 * Returns: <0 (error), 0 (no region), 1 (region)
90 *
91 * The mirrord will need perform recovery on regions of
92 * the mirror that are in the NOSYNC state. This
93 * function asks the log to tell the caller about the
94 * next region that this machine should recover.
95 *
96 * Do not confuse this function with 'in_sync()', one
97 * tells you if an area is synchronised, the other
98 * assigns recovery work.
99 */
100 int (*get_resync_work)(struct dm_dirty_log *log, region_t *region);
101
102 /*
103 * This notifies the log that the resync status of a region
104 * has changed. It also clears the region from the recovering
105 * list (if present).
106 */
107 void (*set_region_sync)(struct dm_dirty_log *log,
108 region_t region, int in_sync);
109
110 /*
111 * Returns the number of regions that are in sync.
112 */
113 region_t (*get_sync_count)(struct dm_dirty_log *log);
114
115 /*
116 * Support function for mirror status requests.
117 */
118 int (*status)(struct dm_dirty_log *log, status_type_t status_type,
119 char *result, unsigned maxlen);
120
121 /*
122 * is_remote_recovering is necessary for cluster mirroring. It provides
123 * a way to detect recovery on another node, so we aren't writing
124 * concurrently. This function is likely to block (when a cluster log
125 * is used).
126 *
127 * Returns: 0, 1
128 */
129 int (*is_remote_recovering)(struct dm_dirty_log *log, region_t region);
130 };
131
132 int dm_dirty_log_type_register(struct dm_dirty_log_type *type);
133 int dm_dirty_log_type_unregister(struct dm_dirty_log_type *type);
134
135 /*
136 * Make sure you use these two functions, rather than calling
137 * type->constructor/destructor() directly.
138 */
139 struct dm_dirty_log *dm_dirty_log_create(const char *type_name,
140 struct dm_target *ti,
141 int (*flush_callback_fn)(struct dm_target *ti),
142 unsigned argc, char **argv);
143 void dm_dirty_log_destroy(struct dm_dirty_log *log);
144
145 #endif /* __KERNEL__ */
146 #endif /* _LINUX_DM_DIRTY_LOG_H */