clk: samsung: Fix double add of syscore ops after driver rebind
[deliverable/linux.git] / include / linux / dm-dirty-log.h
CommitLineData
1da177e4
LT
1/*
2 * Copyright (C) 2003 Sistina Software
416cd17b
HM
3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
4 *
5 * Device-Mapper dirty region log.
1da177e4
LT
6 *
7 * This file is released under the LGPL.
8 */
9
416cd17b
HM
10#ifndef _LINUX_DM_DIRTY_LOG
11#define _LINUX_DM_DIRTY_LOG
12
13#ifdef __KERNEL__
1da177e4 14
416cd17b
HM
15#include <linux/types.h>
16#include <linux/device-mapper.h>
1da177e4
LT
17
18typedef sector_t region_t;
19
416cd17b 20struct dm_dirty_log_type;
1da177e4 21
416cd17b
HM
22struct dm_dirty_log {
23 struct dm_dirty_log_type *type;
87a8f240 24 int (*flush_callback_fn)(struct dm_target *ti);
1da177e4
LT
25 void *context;
26};
27
416cd17b 28struct dm_dirty_log_type {
1da177e4
LT
29 const char *name;
30 struct module *module;
1da177e4 31
ec44ab9d
MS
32 /* For internal device-mapper use */
33 struct list_head list;
34
416cd17b
HM
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);
1da177e4
LT
38
39 /*
40 * There are times when we don't want the log to touch
41 * the disk.
42 */
416cd17b
HM
43 int (*presuspend)(struct dm_dirty_log *log);
44 int (*postsuspend)(struct dm_dirty_log *log);
45 int (*resume)(struct dm_dirty_log *log);
1da177e4
LT
46
47 /*
48 * Retrieves the smallest size of region that the log can
49 * deal with.
50 */
416cd17b 51 uint32_t (*get_region_size)(struct dm_dirty_log *log);
1da177e4 52
416cd17b 53 /*
1da177e4
LT
54 * A predicate to say whether a region is clean or not.
55 * May block.
56 */
416cd17b 57 int (*is_clean)(struct dm_dirty_log *log, region_t region);
1da177e4
LT
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 */
416cd17b
HM
70 int (*in_sync)(struct dm_dirty_log *log, region_t region,
71 int can_block);
1da177e4
LT
72
73 /*
74 * Flush the current log state (eg, to disk). This
75 * function may block.
76 */
416cd17b 77 int (*flush)(struct dm_dirty_log *log);
1da177e4
LT
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 */
416cd17b
HM
85 void (*mark_region)(struct dm_dirty_log *log, region_t region);
86 void (*clear_region)(struct dm_dirty_log *log, region_t region);
1da177e4
LT
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 */
416cd17b 100 int (*get_resync_work)(struct dm_dirty_log *log, region_t *region);
1da177e4
LT
101
102 /*
f3ee6b2f
JB
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).
1da177e4 106 */
416cd17b 107 void (*set_region_sync)(struct dm_dirty_log *log,
f3ee6b2f 108 region_t region, int in_sync);
1da177e4 109
416cd17b 110 /*
1da177e4 111 * Returns the number of regions that are in sync.
416cd17b
HM
112 */
113 region_t (*get_sync_count)(struct dm_dirty_log *log);
1da177e4
LT
114
115 /*
116 * Support function for mirror status requests.
117 */
416cd17b
HM
118 int (*status)(struct dm_dirty_log *log, status_type_t status_type,
119 char *result, unsigned maxlen);
7513c2a7
JB
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);
1da177e4
LT
130};
131
416cd17b
HM
132int dm_dirty_log_type_register(struct dm_dirty_log_type *type);
133int dm_dirty_log_type_unregister(struct dm_dirty_log_type *type);
1da177e4
LT
134
135/*
136 * Make sure you use these two functions, rather than calling
137 * type->constructor/destructor() directly.
138 */
416cd17b 139struct dm_dirty_log *dm_dirty_log_create(const char *type_name,
87a8f240
MP
140 struct dm_target *ti,
141 int (*flush_callback_fn)(struct dm_target *ti),
142 unsigned argc, char **argv);
416cd17b 143void dm_dirty_log_destroy(struct dm_dirty_log *log);
1da177e4 144
416cd17b
HM
145#endif /* __KERNEL__ */
146#endif /* _LINUX_DM_DIRTY_LOG_H */
This page took 0.867409 seconds and 5 git commands to generate.