2 * Copyright (C) 2003 Sistina Software
4 * This file is released under the LGPL.
13 * Values returned by get_failure_response()
14 * DMLOG_IOERR_IGNORE: ignore device failures
15 * DMLOG_IOERR_BLOCK: issue dm event, and do not complete
16 * I/O until presuspend is recieved.
18 #define DMLOG_IOERR_IGNORE 0
19 #define DMLOG_IOERR_BLOCK 1
21 typedef sector_t region_t;
23 struct dirty_log_type;
26 struct dirty_log_type *type;
30 struct dirty_log_type {
31 struct list_head list;
33 struct module *module;
34 unsigned int use_count;
37 int (*ctr)(struct dirty_log *log, struct dm_target *ti,
38 unsigned int argc, char **argv);
39 void (*dtr)(struct dirty_log *log);
42 * There are times when we don't want the log to touch
45 int (*presuspend)(struct dirty_log *log);
46 int (*postsuspend)(struct dirty_log *log);
47 int (*resume)(struct dirty_log *log);
50 * Retrieves the smallest size of region that the log can
53 uint32_t (*get_region_size)(struct dirty_log *log);
56 * A predicate to say whether a region is clean or not.
59 int (*is_clean)(struct dirty_log *log, region_t region);
62 * Returns: 0, 1, -EWOULDBLOCK, < 0
64 * A predicate function to check the area given by
65 * [sector, sector + len) is in sync.
67 * If -EWOULDBLOCK is returned the state of the region is
68 * unknown, typically this will result in a read being
69 * passed to a daemon to deal with, since a daemon is
72 int (*in_sync)(struct dirty_log *log, region_t region, int can_block);
75 * Flush the current log state (eg, to disk). This
78 int (*flush)(struct dirty_log *log);
81 * Mark an area as clean or dirty. These functions may
82 * block, though for performance reasons blocking should
83 * be extremely rare (eg, allocating another chunk of
84 * memory for some reason).
86 void (*mark_region)(struct dirty_log *log, region_t region);
87 void (*clear_region)(struct dirty_log *log, region_t region);
90 * Returns: <0 (error), 0 (no region), 1 (region)
92 * The mirrord will need perform recovery on regions of
93 * the mirror that are in the NOSYNC state. This
94 * function asks the log to tell the caller about the
95 * next region that this machine should recover.
97 * Do not confuse this function with 'in_sync()', one
98 * tells you if an area is synchronised, the other
99 * assigns recovery work.
101 int (*get_resync_work)(struct dirty_log *log, region_t *region);
104 * This notifies the log that the resync status of a region
105 * has changed. It also clears the region from the recovering
108 void (*set_region_sync)(struct dirty_log *log,
109 region_t region, int in_sync);
112 * Returns the number of regions that are in sync.
114 region_t (*get_sync_count)(struct dirty_log *log);
117 * Support function for mirror status requests.
119 int (*status)(struct dirty_log *log, status_type_t status_type,
120 char *result, unsigned int maxlen);
123 * Return the code describing what to do in the event
124 * of a device failure.
126 int (*get_failure_response)(struct dirty_log *log);
131 * This is necessary for cluster mirroring. It provides
132 * a way to detect recovery on another node, so we
133 * aren't writing concurrently. This function is likely
134 * to block (when a cluster log is used).
136 int (*is_remote_recovering)(struct dirty_log *log, region_t region);
138 int (*reserved[5])(int a);
141 int dm_register_dirty_log_type(struct dirty_log_type *type);
142 int dm_unregister_dirty_log_type(struct dirty_log_type *type);
146 * Make sure you use these two functions, rather than calling
147 * type->constructor/destructor() directly.
149 struct dirty_log *dm_create_dirty_log(const char *type_name, struct dm_target *ti,
150 unsigned int argc, char **argv);
151 void dm_destroy_dirty_log(struct dirty_log *log);
154 * init/exit functions.
156 int dm_dirty_log_init(void);
157 void dm_dirty_log_exit(void);