aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-log.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/dm-log.h')
-rw-r--r--drivers/md/dm-log.h84
1 files changed, 43 insertions, 41 deletions
diff --git a/drivers/md/dm-log.h b/drivers/md/dm-log.h
index 3fae87eb5963..2da48a857cb9 100644
--- a/drivers/md/dm-log.h
+++ b/drivers/md/dm-log.h
@@ -1,52 +1,58 @@
1/* 1/*
2 * Copyright (C) 2003 Sistina Software 2 * Copyright (C) 2003 Sistina Software
3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
4 *
5 * Device-Mapper dirty region log.
3 * 6 *
4 * This file is released under the LGPL. 7 * This file is released under the LGPL.
5 */ 8 */
6 9
7#ifndef DM_DIRTY_LOG 10#ifndef _LINUX_DM_DIRTY_LOG
8#define DM_DIRTY_LOG 11#define _LINUX_DM_DIRTY_LOG
12
13#ifdef __KERNEL__
9 14
10#include "dm.h" 15#include <linux/types.h>
16#include <linux/device-mapper.h>
11 17
12typedef sector_t region_t; 18typedef sector_t region_t;
13 19
14struct dirty_log_type; 20struct dm_dirty_log_type;
15 21
16struct dirty_log { 22struct dm_dirty_log {
17 struct dirty_log_type *type; 23 struct dm_dirty_log_type *type;
18 void *context; 24 void *context;
19}; 25};
20 26
21struct dirty_log_type { 27struct dm_dirty_log_type {
22 struct list_head list; 28 struct list_head list;
23 const char *name; 29 const char *name;
24 struct module *module; 30 struct module *module;
25 unsigned int use_count; 31 unsigned use_count;
26 32
27 int (*ctr)(struct dirty_log *log, struct dm_target *ti, 33 int (*ctr)(struct dm_dirty_log *log, struct dm_target *ti,
28 unsigned int argc, char **argv); 34 unsigned argc, char **argv);
29 void (*dtr)(struct dirty_log *log); 35 void (*dtr)(struct dm_dirty_log *log);
30 36
31 /* 37 /*
32 * There are times when we don't want the log to touch 38 * There are times when we don't want the log to touch
33 * the disk. 39 * the disk.
34 */ 40 */
35 int (*presuspend)(struct dirty_log *log); 41 int (*presuspend)(struct dm_dirty_log *log);
36 int (*postsuspend)(struct dirty_log *log); 42 int (*postsuspend)(struct dm_dirty_log *log);
37 int (*resume)(struct dirty_log *log); 43 int (*resume)(struct dm_dirty_log *log);
38 44
39 /* 45 /*
40 * Retrieves the smallest size of region that the log can 46 * Retrieves the smallest size of region that the log can
41 * deal with. 47 * deal with.
42 */ 48 */
43 uint32_t (*get_region_size)(struct dirty_log *log); 49 uint32_t (*get_region_size)(struct dm_dirty_log *log);
44 50
45 /* 51 /*
46 * A predicate to say whether a region is clean or not. 52 * A predicate to say whether a region is clean or not.
47 * May block. 53 * May block.
48 */ 54 */
49 int (*is_clean)(struct dirty_log *log, region_t region); 55 int (*is_clean)(struct dm_dirty_log *log, region_t region);
50 56
51 /* 57 /*
52 * Returns: 0, 1, -EWOULDBLOCK, < 0 58 * Returns: 0, 1, -EWOULDBLOCK, < 0
@@ -59,13 +65,14 @@ struct dirty_log_type {
59 * passed to a daemon to deal with, since a daemon is 65 * passed to a daemon to deal with, since a daemon is
60 * allowed to block. 66 * allowed to block.
61 */ 67 */
62 int (*in_sync)(struct dirty_log *log, region_t region, int can_block); 68 int (*in_sync)(struct dm_dirty_log *log, region_t region,
69 int can_block);
63 70
64 /* 71 /*
65 * Flush the current log state (eg, to disk). This 72 * Flush the current log state (eg, to disk). This
66 * function may block. 73 * function may block.
67 */ 74 */
68 int (*flush)(struct dirty_log *log); 75 int (*flush)(struct dm_dirty_log *log);
69 76
70 /* 77 /*
71 * Mark an area as clean or dirty. These functions may 78 * Mark an area as clean or dirty. These functions may
@@ -73,8 +80,8 @@ struct dirty_log_type {
73 * be extremely rare (eg, allocating another chunk of 80 * be extremely rare (eg, allocating another chunk of
74 * memory for some reason). 81 * memory for some reason).
75 */ 82 */
76 void (*mark_region)(struct dirty_log *log, region_t region); 83 void (*mark_region)(struct dm_dirty_log *log, region_t region);
77 void (*clear_region)(struct dirty_log *log, region_t region); 84 void (*clear_region)(struct dm_dirty_log *log, region_t region);
78 85
79 /* 86 /*
80 * Returns: <0 (error), 0 (no region), 1 (region) 87 * Returns: <0 (error), 0 (no region), 1 (region)
@@ -88,44 +95,39 @@ struct dirty_log_type {
88 * tells you if an area is synchronised, the other 95 * tells you if an area is synchronised, the other
89 * assigns recovery work. 96 * assigns recovery work.
90 */ 97 */
91 int (*get_resync_work)(struct dirty_log *log, region_t *region); 98 int (*get_resync_work)(struct dm_dirty_log *log, region_t *region);
92 99
93 /* 100 /*
94 * This notifies the log that the resync status of a region 101 * This notifies the log that the resync status of a region
95 * has changed. It also clears the region from the recovering 102 * has changed. It also clears the region from the recovering
96 * list (if present). 103 * list (if present).
97 */ 104 */
98 void (*set_region_sync)(struct dirty_log *log, 105 void (*set_region_sync)(struct dm_dirty_log *log,
99 region_t region, int in_sync); 106 region_t region, int in_sync);
100 107
101 /* 108 /*
102 * Returns the number of regions that are in sync. 109 * Returns the number of regions that are in sync.
103 */ 110 */
104 region_t (*get_sync_count)(struct dirty_log *log); 111 region_t (*get_sync_count)(struct dm_dirty_log *log);
105 112
106 /* 113 /*
107 * Support function for mirror status requests. 114 * Support function for mirror status requests.
108 */ 115 */
109 int (*status)(struct dirty_log *log, status_type_t status_type, 116 int (*status)(struct dm_dirty_log *log, status_type_t status_type,
110 char *result, unsigned int maxlen); 117 char *result, unsigned maxlen);
111}; 118};
112 119
113int dm_register_dirty_log_type(struct dirty_log_type *type); 120int dm_dirty_log_type_register(struct dm_dirty_log_type *type);
114int dm_unregister_dirty_log_type(struct dirty_log_type *type); 121int dm_dirty_log_type_unregister(struct dm_dirty_log_type *type);
115
116 122
117/* 123/*
118 * Make sure you use these two functions, rather than calling 124 * Make sure you use these two functions, rather than calling
119 * type->constructor/destructor() directly. 125 * type->constructor/destructor() directly.
120 */ 126 */
121struct dirty_log *dm_create_dirty_log(const char *type_name, struct dm_target *ti, 127struct dm_dirty_log *dm_dirty_log_create(const char *type_name,
122 unsigned int argc, char **argv); 128 struct dm_target *ti,
123void dm_destroy_dirty_log(struct dirty_log *log); 129 unsigned argc, char **argv);
124 130void dm_dirty_log_destroy(struct dm_dirty_log *log);
125/*
126 * init/exit functions.
127 */
128int dm_dirty_log_init(void);
129void dm_dirty_log_exit(void);
130 131
131#endif 132#endif /* __KERNEL__ */
133#endif /* _LINUX_DM_DIRTY_LOG_H */