databuf bugfixes
[cor_2_6_31.git] / include / linux / dm-log-userspace.h
blob642e3017b51f9415db90bd968c00484ed4a3def3
1 /*
2 * Copyright (C) 2006-2009 Red Hat, Inc.
4 * This file is released under the LGPL.
5 */
7 #ifndef __DM_LOG_USERSPACE_H__
8 #define __DM_LOG_USERSPACE_H__
10 #include <linux/dm-ioctl.h> /* For DM_UUID_LEN */
13 * The device-mapper userspace log module consists of a kernel component and
14 * a user-space component. The kernel component implements the API defined
15 * in dm-dirty-log.h. Its purpose is simply to pass the parameters and
16 * return values of those API functions between kernel and user-space.
18 * Below are defined the 'request_types' - DM_ULOG_CTR, DM_ULOG_DTR, etc.
19 * These request types represent the different functions in the device-mapper
20 * dirty log API. Each of these is described in more detail below.
22 * The user-space program must listen for requests from the kernel (representing
23 * the various API functions) and process them.
25 * User-space begins by setting up the communication link (error checking
26 * removed for clarity):
27 * fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR);
28 * addr.nl_family = AF_NETLINK;
29 * addr.nl_groups = CN_IDX_DM;
30 * addr.nl_pid = 0;
31 * r = bind(fd, (struct sockaddr *) &addr, sizeof(addr));
32 * opt = addr.nl_groups;
33 * setsockopt(fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, &opt, sizeof(opt));
35 * User-space will then wait to receive requests form the kernel, which it
36 * will process as described below. The requests are received in the form,
37 * ((struct dm_ulog_request) + (additional data)). Depending on the request
38 * type, there may or may not be 'additional data'. In the descriptions below,
39 * you will see 'Payload-to-userspace' and 'Payload-to-kernel'. The
40 * 'Payload-to-userspace' is what the kernel sends in 'additional data' as
41 * necessary parameters to complete the request. The 'Payload-to-kernel' is
42 * the 'additional data' returned to the kernel that contains the necessary
43 * results of the request. The 'data_size' field in the dm_ulog_request
44 * structure denotes the availability and amount of payload data.
48 * DM_ULOG_CTR corresponds to (found in dm-dirty-log.h):
49 * int (*ctr)(struct dm_dirty_log *log, struct dm_target *ti,
50 * unsigned argc, char **argv);
52 * Payload-to-userspace:
53 * A single string containing all the argv arguments separated by ' 's
54 * Payload-to-kernel:
55 * None. ('data_size' in the dm_ulog_request struct should be 0.)
57 * The UUID contained in the dm_ulog_request structure is the reference that
58 * will be used by all request types to a specific log. The constructor must
59 * record this assotiation with instance created.
61 * When the request has been processed, user-space must return the
62 * dm_ulog_request to the kernel - setting the 'error' field and
63 * 'data_size' appropriately.
65 #define DM_ULOG_CTR 1
68 * DM_ULOG_DTR corresponds to (found in dm-dirty-log.h):
69 * void (*dtr)(struct dm_dirty_log *log);
71 * Payload-to-userspace:
72 * A single string containing all the argv arguments separated by ' 's
73 * Payload-to-kernel:
74 * None. ('data_size' in the dm_ulog_request struct should be 0.)
76 * The UUID contained in the dm_ulog_request structure is all that is
77 * necessary to identify the log instance being destroyed. There is no
78 * payload data.
80 * When the request has been processed, user-space must return the
81 * dm_ulog_request to the kernel - setting the 'error' field and clearing
82 * 'data_size' appropriately.
84 #define DM_ULOG_DTR 2
87 * DM_ULOG_PRESUSPEND corresponds to (found in dm-dirty-log.h):
88 * int (*presuspend)(struct dm_dirty_log *log);
90 * Payload-to-userspace:
91 * None.
92 * Payload-to-kernel:
93 * None.
95 * The UUID contained in the dm_ulog_request structure is all that is
96 * necessary to identify the log instance being presuspended. There is no
97 * payload data.
99 * When the request has been processed, user-space must return the
100 * dm_ulog_request to the kernel - setting the 'error' field and
101 * 'data_size' appropriately.
103 #define DM_ULOG_PRESUSPEND 3
106 * DM_ULOG_POSTSUSPEND corresponds to (found in dm-dirty-log.h):
107 * int (*postsuspend)(struct dm_dirty_log *log);
109 * Payload-to-userspace:
110 * None.
111 * Payload-to-kernel:
112 * None.
114 * The UUID contained in the dm_ulog_request structure is all that is
115 * necessary to identify the log instance being postsuspended. There is no
116 * payload data.
118 * When the request has been processed, user-space must return the
119 * dm_ulog_request to the kernel - setting the 'error' field and
120 * 'data_size' appropriately.
122 #define DM_ULOG_POSTSUSPEND 4
125 * DM_ULOG_RESUME corresponds to (found in dm-dirty-log.h):
126 * int (*resume)(struct dm_dirty_log *log);
128 * Payload-to-userspace:
129 * None.
130 * Payload-to-kernel:
131 * None.
133 * The UUID contained in the dm_ulog_request structure is all that is
134 * necessary to identify the log instance being resumed. There is no
135 * payload data.
137 * When the request has been processed, user-space must return the
138 * dm_ulog_request to the kernel - setting the 'error' field and
139 * 'data_size' appropriately.
141 #define DM_ULOG_RESUME 5
144 * DM_ULOG_GET_REGION_SIZE corresponds to (found in dm-dirty-log.h):
145 * uint32_t (*get_region_size)(struct dm_dirty_log *log);
147 * Payload-to-userspace:
148 * None.
149 * Payload-to-kernel:
150 * uint64_t - contains the region size
152 * The region size is something that was determined at constructor time.
153 * It is returned in the payload area and 'data_size' is set to
154 * reflect this.
156 * When the request has been processed, user-space must return the
157 * dm_ulog_request to the kernel - setting the 'error' field appropriately.
159 #define DM_ULOG_GET_REGION_SIZE 6
162 * DM_ULOG_IS_CLEAN corresponds to (found in dm-dirty-log.h):
163 * int (*is_clean)(struct dm_dirty_log *log, region_t region);
165 * Payload-to-userspace:
166 * uint64_t - the region to get clean status on
167 * Payload-to-kernel:
168 * int64_t - 1 if clean, 0 otherwise
170 * Payload is sizeof(uint64_t) and contains the region for which the clean
171 * status is being made.
173 * When the request has been processed, user-space must return the
174 * dm_ulog_request to the kernel - filling the payload with 0 (not clean) or
175 * 1 (clean), setting 'data_size' and 'error' appropriately.
177 #define DM_ULOG_IS_CLEAN 7
180 * DM_ULOG_IN_SYNC corresponds to (found in dm-dirty-log.h):
181 * int (*in_sync)(struct dm_dirty_log *log, region_t region,
182 * int can_block);
184 * Payload-to-userspace:
185 * uint64_t - the region to get sync status on
186 * Payload-to-kernel:
187 * int64_t - 1 if in-sync, 0 otherwise
189 * Exactly the same as 'is_clean' above, except this time asking "has the
190 * region been recovered?" vs. "is the region not being modified?"
192 #define DM_ULOG_IN_SYNC 8
195 * DM_ULOG_FLUSH corresponds to (found in dm-dirty-log.h):
196 * int (*flush)(struct dm_dirty_log *log);
198 * Payload-to-userspace:
199 * None.
200 * Payload-to-kernel:
201 * None.
203 * No incoming or outgoing payload. Simply flush log state to disk.
205 * When the request has been processed, user-space must return the
206 * dm_ulog_request to the kernel - setting the 'error' field and clearing
207 * 'data_size' appropriately.
209 #define DM_ULOG_FLUSH 9
212 * DM_ULOG_MARK_REGION corresponds to (found in dm-dirty-log.h):
213 * void (*mark_region)(struct dm_dirty_log *log, region_t region);
215 * Payload-to-userspace:
216 * uint64_t [] - region(s) to mark
217 * Payload-to-kernel:
218 * None.
220 * Incoming payload contains the one or more regions to mark dirty.
221 * The number of regions contained in the payload can be determined from
222 * 'data_size/sizeof(uint64_t)'.
224 * When the request has been processed, user-space must return the
225 * dm_ulog_request to the kernel - setting the 'error' field and clearing
226 * 'data_size' appropriately.
228 #define DM_ULOG_MARK_REGION 10
231 * DM_ULOG_CLEAR_REGION corresponds to (found in dm-dirty-log.h):
232 * void (*clear_region)(struct dm_dirty_log *log, region_t region);
234 * Payload-to-userspace:
235 * uint64_t [] - region(s) to clear
236 * Payload-to-kernel:
237 * None.
239 * Incoming payload contains the one or more regions to mark clean.
240 * The number of regions contained in the payload can be determined from
241 * 'data_size/sizeof(uint64_t)'.
243 * When the request has been processed, user-space must return the
244 * dm_ulog_request to the kernel - setting the 'error' field and clearing
245 * 'data_size' appropriately.
247 #define DM_ULOG_CLEAR_REGION 11
250 * DM_ULOG_GET_RESYNC_WORK corresponds to (found in dm-dirty-log.h):
251 * int (*get_resync_work)(struct dm_dirty_log *log, region_t *region);
253 * Payload-to-userspace:
254 * None.
255 * Payload-to-kernel:
257 * int64_t i; -- 1 if recovery necessary, 0 otherwise
258 * uint64_t r; -- The region to recover if i=1
260 * 'data_size' should be set appropriately.
262 * When the request has been processed, user-space must return the
263 * dm_ulog_request to the kernel - setting the 'error' field appropriately.
265 #define DM_ULOG_GET_RESYNC_WORK 12
268 * DM_ULOG_SET_REGION_SYNC corresponds to (found in dm-dirty-log.h):
269 * void (*set_region_sync)(struct dm_dirty_log *log,
270 * region_t region, int in_sync);
272 * Payload-to-userspace:
274 * uint64_t - region to set sync state on
275 * int64_t - 0 if not-in-sync, 1 if in-sync
277 * Payload-to-kernel:
278 * None.
280 * When the request has been processed, user-space must return the
281 * dm_ulog_request to the kernel - setting the 'error' field and clearing
282 * 'data_size' appropriately.
284 #define DM_ULOG_SET_REGION_SYNC 13
287 * DM_ULOG_GET_SYNC_COUNT corresponds to (found in dm-dirty-log.h):
288 * region_t (*get_sync_count)(struct dm_dirty_log *log);
290 * Payload-to-userspace:
291 * None.
292 * Payload-to-kernel:
293 * uint64_t - the number of in-sync regions
295 * No incoming payload. Kernel-bound payload contains the number of
296 * regions that are in-sync (in a size_t).
298 * When the request has been processed, user-space must return the
299 * dm_ulog_request to the kernel - setting the 'error' field and
300 * 'data_size' appropriately.
302 #define DM_ULOG_GET_SYNC_COUNT 14
305 * DM_ULOG_STATUS_INFO corresponds to (found in dm-dirty-log.h):
306 * int (*status)(struct dm_dirty_log *log, STATUSTYPE_INFO,
307 * char *result, unsigned maxlen);
309 * Payload-to-userspace:
310 * None.
311 * Payload-to-kernel:
312 * Character string containing STATUSTYPE_INFO
314 * When the request has been processed, user-space must return the
315 * dm_ulog_request to the kernel - setting the 'error' field and
316 * 'data_size' appropriately.
318 #define DM_ULOG_STATUS_INFO 15
321 * DM_ULOG_STATUS_TABLE corresponds to (found in dm-dirty-log.h):
322 * int (*status)(struct dm_dirty_log *log, STATUSTYPE_TABLE,
323 * char *result, unsigned maxlen);
325 * Payload-to-userspace:
326 * None.
327 * Payload-to-kernel:
328 * Character string containing STATUSTYPE_TABLE
330 * When the request has been processed, user-space must return the
331 * dm_ulog_request to the kernel - setting the 'error' field and
332 * 'data_size' appropriately.
334 #define DM_ULOG_STATUS_TABLE 16
337 * DM_ULOG_IS_REMOTE_RECOVERING corresponds to (found in dm-dirty-log.h):
338 * int (*is_remote_recovering)(struct dm_dirty_log *log, region_t region);
340 * Payload-to-userspace:
341 * uint64_t - region to determine recovery status on
342 * Payload-to-kernel:
344 * int64_t is_recovering; -- 0 if no, 1 if yes
345 * uint64_t in_sync_hint; -- lowest region still needing resync
348 * When the request has been processed, user-space must return the
349 * dm_ulog_request to the kernel - setting the 'error' field and
350 * 'data_size' appropriately.
352 #define DM_ULOG_IS_REMOTE_RECOVERING 17
355 * (DM_ULOG_REQUEST_MASK & request_type) to get the request type
357 * Payload-to-userspace:
358 * A single string containing all the argv arguments separated by ' 's
359 * Payload-to-kernel:
360 * None. ('data_size' in the dm_ulog_request struct should be 0.)
362 * We are reserving 8 bits of the 32-bit 'request_type' field for the
363 * various request types above. The remaining 24-bits are currently
364 * set to zero and are reserved for future use and compatibility concerns.
366 * User-space should always use DM_ULOG_REQUEST_TYPE to aquire the
367 * request type from the 'request_type' field to maintain forward compatibility.
369 #define DM_ULOG_REQUEST_MASK 0xFF
370 #define DM_ULOG_REQUEST_TYPE(request_type) \
371 (DM_ULOG_REQUEST_MASK & (request_type))
373 struct dm_ulog_request {
374 char uuid[DM_UUID_LEN]; /* Ties a request to a specific mirror log */
375 char padding[7]; /* Padding because DM_UUID_LEN = 129 */
377 int32_t error; /* Used to report back processing errors */
379 uint32_t seq; /* Sequence number for request */
380 uint32_t request_type; /* DM_ULOG_* defined above */
381 uint32_t data_size; /* How much data (not including this struct) */
383 char data[0];
386 #endif /* __DM_LOG_USERSPACE_H__ */