powerpc: Use lwarx/ldarx hint in bit locks
[linux-2.6.git] / include / linux / dm-dirty-log.h
blob7084503c3405f80cd94f9fc261f9b7cd1530f499
1 /*
2 * Copyright (C) 2003 Sistina Software
3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
5 * Device-Mapper dirty region log.
7 * This file is released under the LGPL.
8 */
10 #ifndef _LINUX_DM_DIRTY_LOG
11 #define _LINUX_DM_DIRTY_LOG
13 #ifdef __KERNEL__
15 #include <linux/types.h>
16 #include <linux/device-mapper.h>
18 typedef sector_t region_t;
20 struct dm_dirty_log_type;
22 struct dm_dirty_log {
23 struct dm_dirty_log_type *type;
24 int (*flush_callback_fn)(struct dm_target *ti);
25 void *context;
28 struct dm_dirty_log_type {
29 const char *name;
30 struct module *module;
32 /* For internal device-mapper use */
33 struct list_head list;
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);
40 * There are times when we don't want the log to touch
41 * the disk.
43 int (*presuspend)(struct dm_dirty_log *log);
44 int (*postsuspend)(struct dm_dirty_log *log);
45 int (*resume)(struct dm_dirty_log *log);
48 * Retrieves the smallest size of region that the log can
49 * deal with.
51 uint32_t (*get_region_size)(struct dm_dirty_log *log);
54 * A predicate to say whether a region is clean or not.
55 * May block.
57 int (*is_clean)(struct dm_dirty_log *log, region_t region);
60 * Returns: 0, 1, -EWOULDBLOCK, < 0
62 * A predicate function to check the area given by
63 * [sector, sector + len) is in sync.
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.
70 int (*in_sync)(struct dm_dirty_log *log, region_t region,
71 int can_block);
74 * Flush the current log state (eg, to disk). This
75 * function may block.
77 int (*flush)(struct dm_dirty_log *log);
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).
85 void (*mark_region)(struct dm_dirty_log *log, region_t region);
86 void (*clear_region)(struct dm_dirty_log *log, region_t region);
89 * Returns: <0 (error), 0 (no region), 1 (region)
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.
96 * Do not confuse this function with 'in_sync()', one
97 * tells you if an area is synchronised, the other
98 * assigns recovery work.
100 int (*get_resync_work)(struct dm_dirty_log *log, region_t *region);
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).
107 void (*set_region_sync)(struct dm_dirty_log *log,
108 region_t region, int in_sync);
111 * Returns the number of regions that are in sync.
113 region_t (*get_sync_count)(struct dm_dirty_log *log);
116 * Support function for mirror status requests.
118 int (*status)(struct dm_dirty_log *log, status_type_t status_type,
119 char *result, unsigned maxlen);
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).
127 * Returns: 0, 1
129 int (*is_remote_recovering)(struct dm_dirty_log *log, region_t region);
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);
136 * Make sure you use these two functions, rather than calling
137 * type->constructor/destructor() directly.
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);
145 #endif /* __KERNEL__ */
146 #endif /* _LINUX_DM_DIRTY_LOG_H */