xref: /linux/include/uapi/linux/dm-log-userspace.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: LGPL-2.0+ WITH Linux-syscall-note */
2607ca46eSDavid Howells /*
3607ca46eSDavid Howells  * Copyright (C) 2006-2009 Red Hat, Inc.
4607ca46eSDavid Howells  *
5607ca46eSDavid Howells  * This file is released under the LGPL.
6607ca46eSDavid Howells  */
7607ca46eSDavid Howells 
8607ca46eSDavid Howells #ifndef __DM_LOG_USERSPACE_H__
9607ca46eSDavid Howells #define __DM_LOG_USERSPACE_H__
10607ca46eSDavid Howells 
11209e2367SMikko Rapeli #include <linux/types.h>
12607ca46eSDavid Howells #include <linux/dm-ioctl.h> /* For DM_UUID_LEN */
13607ca46eSDavid Howells 
14607ca46eSDavid Howells /*
15607ca46eSDavid Howells  * The device-mapper userspace log module consists of a kernel component and
16607ca46eSDavid Howells  * a user-space component.  The kernel component implements the API defined
17607ca46eSDavid Howells  * in dm-dirty-log.h.  Its purpose is simply to pass the parameters and
18607ca46eSDavid Howells  * return values of those API functions between kernel and user-space.
19607ca46eSDavid Howells  *
20607ca46eSDavid Howells  * Below are defined the 'request_types' - DM_ULOG_CTR, DM_ULOG_DTR, etc.
21607ca46eSDavid Howells  * These request types represent the different functions in the device-mapper
22607ca46eSDavid Howells  * dirty log API.  Each of these is described in more detail below.
23607ca46eSDavid Howells  *
24607ca46eSDavid Howells  * The user-space program must listen for requests from the kernel (representing
25607ca46eSDavid Howells  * the various API functions) and process them.
26607ca46eSDavid Howells  *
27607ca46eSDavid Howells  * User-space begins by setting up the communication link (error checking
28607ca46eSDavid Howells  * removed for clarity):
29607ca46eSDavid Howells  *	fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR);
30607ca46eSDavid Howells  *	addr.nl_family = AF_NETLINK;
31607ca46eSDavid Howells  *	addr.nl_groups = CN_IDX_DM;
32607ca46eSDavid Howells  *	addr.nl_pid = 0;
33607ca46eSDavid Howells  *	r = bind(fd, (struct sockaddr *) &addr, sizeof(addr));
34607ca46eSDavid Howells  *	opt = addr.nl_groups;
35607ca46eSDavid Howells  *	setsockopt(fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, &opt, sizeof(opt));
36607ca46eSDavid Howells  *
37607ca46eSDavid Howells  * User-space will then wait to receive requests form the kernel, which it
38607ca46eSDavid Howells  * will process as described below.  The requests are received in the form,
39607ca46eSDavid Howells  * ((struct dm_ulog_request) + (additional data)).  Depending on the request
40607ca46eSDavid Howells  * type, there may or may not be 'additional data'.  In the descriptions below,
41607ca46eSDavid Howells  * you will see 'Payload-to-userspace' and 'Payload-to-kernel'.  The
42607ca46eSDavid Howells  * 'Payload-to-userspace' is what the kernel sends in 'additional data' as
43607ca46eSDavid Howells  * necessary parameters to complete the request.  The 'Payload-to-kernel' is
44607ca46eSDavid Howells  * the 'additional data' returned to the kernel that contains the necessary
45607ca46eSDavid Howells  * results of the request.  The 'data_size' field in the dm_ulog_request
46607ca46eSDavid Howells  * structure denotes the availability and amount of payload data.
47607ca46eSDavid Howells  */
48607ca46eSDavid Howells 
49607ca46eSDavid Howells /*
50607ca46eSDavid Howells  * DM_ULOG_CTR corresponds to (found in dm-dirty-log.h):
51607ca46eSDavid Howells  * int (*ctr)(struct dm_dirty_log *log, struct dm_target *ti,
52607ca46eSDavid Howells  *	      unsigned argc, char **argv);
53607ca46eSDavid Howells  *
54607ca46eSDavid Howells  * Payload-to-userspace:
55607ca46eSDavid Howells  *	A single string containing all the argv arguments separated by ' 's
56607ca46eSDavid Howells  * Payload-to-kernel:
57607ca46eSDavid Howells  *	A NUL-terminated string that is the name of the device that is used
58607ca46eSDavid Howells  *	as the backing store for the log data.  'dm_get_device' will be called
59607ca46eSDavid Howells  *	on this device.  ('dm_put_device' will be called on this device
60607ca46eSDavid Howells  *	automatically after calling DM_ULOG_DTR.)  If there is no device needed
61607ca46eSDavid Howells  *	for log data, 'data_size' in the dm_ulog_request struct should be 0.
62607ca46eSDavid Howells  *
63607ca46eSDavid Howells  * The UUID contained in the dm_ulog_request structure is the reference that
64607ca46eSDavid Howells  * will be used by all request types to a specific log.  The constructor must
65607ca46eSDavid Howells  * record this association with the instance created.
66607ca46eSDavid Howells  *
67607ca46eSDavid Howells  * When the request has been processed, user-space must return the
68607ca46eSDavid Howells  * dm_ulog_request to the kernel - setting the 'error' field, filling the
69607ca46eSDavid Howells  * data field with the log device if necessary, and setting 'data_size'
70607ca46eSDavid Howells  * appropriately.
71607ca46eSDavid Howells  */
72607ca46eSDavid Howells #define DM_ULOG_CTR                    1
73607ca46eSDavid Howells 
74607ca46eSDavid Howells /*
75607ca46eSDavid Howells  * DM_ULOG_DTR corresponds to (found in dm-dirty-log.h):
76607ca46eSDavid Howells  * void (*dtr)(struct dm_dirty_log *log);
77607ca46eSDavid Howells  *
78607ca46eSDavid Howells  * Payload-to-userspace:
79607ca46eSDavid Howells  *	A single string containing all the argv arguments separated by ' 's
80607ca46eSDavid Howells  * Payload-to-kernel:
81607ca46eSDavid Howells  *	None.  ('data_size' in the dm_ulog_request struct should be 0.)
82607ca46eSDavid Howells  *
83607ca46eSDavid Howells  * The UUID contained in the dm_ulog_request structure is all that is
84607ca46eSDavid Howells  * necessary to identify the log instance being destroyed.  There is no
85607ca46eSDavid Howells  * payload data.
86607ca46eSDavid Howells  *
87607ca46eSDavid Howells  * When the request has been processed, user-space must return the
88607ca46eSDavid Howells  * dm_ulog_request to the kernel - setting the 'error' field and clearing
89607ca46eSDavid Howells  * 'data_size' appropriately.
90607ca46eSDavid Howells  */
91607ca46eSDavid Howells #define DM_ULOG_DTR                    2
92607ca46eSDavid Howells 
93607ca46eSDavid Howells /*
94607ca46eSDavid Howells  * DM_ULOG_PRESUSPEND corresponds to (found in dm-dirty-log.h):
95607ca46eSDavid Howells  * int (*presuspend)(struct dm_dirty_log *log);
96607ca46eSDavid Howells  *
97607ca46eSDavid Howells  * Payload-to-userspace:
98607ca46eSDavid Howells  *	None.
99607ca46eSDavid Howells  * Payload-to-kernel:
100607ca46eSDavid Howells  *	None.
101607ca46eSDavid Howells  *
102607ca46eSDavid Howells  * The UUID contained in the dm_ulog_request structure is all that is
103607ca46eSDavid Howells  * necessary to identify the log instance being presuspended.  There is no
104607ca46eSDavid Howells  * payload data.
105607ca46eSDavid Howells  *
106607ca46eSDavid Howells  * When the request has been processed, user-space must return the
107607ca46eSDavid Howells  * dm_ulog_request to the kernel - setting the 'error' field and
108607ca46eSDavid Howells  * 'data_size' appropriately.
109607ca46eSDavid Howells  */
110607ca46eSDavid Howells #define DM_ULOG_PRESUSPEND             3
111607ca46eSDavid Howells 
112607ca46eSDavid Howells /*
113607ca46eSDavid Howells  * DM_ULOG_POSTSUSPEND corresponds to (found in dm-dirty-log.h):
114607ca46eSDavid Howells  * int (*postsuspend)(struct dm_dirty_log *log);
115607ca46eSDavid Howells  *
116607ca46eSDavid Howells  * Payload-to-userspace:
117607ca46eSDavid Howells  *	None.
118607ca46eSDavid Howells  * Payload-to-kernel:
119607ca46eSDavid Howells  *	None.
120607ca46eSDavid Howells  *
121607ca46eSDavid Howells  * The UUID contained in the dm_ulog_request structure is all that is
122607ca46eSDavid Howells  * necessary to identify the log instance being postsuspended.  There is no
123607ca46eSDavid Howells  * payload data.
124607ca46eSDavid Howells  *
125607ca46eSDavid Howells  * When the request has been processed, user-space must return the
126607ca46eSDavid Howells  * dm_ulog_request to the kernel - setting the 'error' field and
127607ca46eSDavid Howells  * 'data_size' appropriately.
128607ca46eSDavid Howells  */
129607ca46eSDavid Howells #define DM_ULOG_POSTSUSPEND            4
130607ca46eSDavid Howells 
131607ca46eSDavid Howells /*
132607ca46eSDavid Howells  * DM_ULOG_RESUME corresponds to (found in dm-dirty-log.h):
133607ca46eSDavid Howells  * int (*resume)(struct dm_dirty_log *log);
134607ca46eSDavid Howells  *
135607ca46eSDavid Howells  * Payload-to-userspace:
136607ca46eSDavid Howells  *	None.
137607ca46eSDavid Howells  * Payload-to-kernel:
138607ca46eSDavid Howells  *	None.
139607ca46eSDavid Howells  *
140607ca46eSDavid Howells  * The UUID contained in the dm_ulog_request structure is all that is
141607ca46eSDavid Howells  * necessary to identify the log instance being resumed.  There is no
142607ca46eSDavid Howells  * payload data.
143607ca46eSDavid Howells  *
144607ca46eSDavid Howells  * When the request has been processed, user-space must return the
145607ca46eSDavid Howells  * dm_ulog_request to the kernel - setting the 'error' field and
146607ca46eSDavid Howells  * 'data_size' appropriately.
147607ca46eSDavid Howells  */
148607ca46eSDavid Howells #define DM_ULOG_RESUME                 5
149607ca46eSDavid Howells 
150607ca46eSDavid Howells /*
151607ca46eSDavid Howells  * DM_ULOG_GET_REGION_SIZE corresponds to (found in dm-dirty-log.h):
152209e2367SMikko Rapeli  * __u32 (*get_region_size)(struct dm_dirty_log *log);
153607ca46eSDavid Howells  *
154607ca46eSDavid Howells  * Payload-to-userspace:
155607ca46eSDavid Howells  *	None.
156607ca46eSDavid Howells  * Payload-to-kernel:
157209e2367SMikko Rapeli  *	__u64 - contains the region size
158607ca46eSDavid Howells  *
159607ca46eSDavid Howells  * The region size is something that was determined at constructor time.
160607ca46eSDavid Howells  * It is returned in the payload area and 'data_size' is set to
161607ca46eSDavid Howells  * reflect this.
162607ca46eSDavid Howells  *
163607ca46eSDavid Howells  * When the request has been processed, user-space must return the
164607ca46eSDavid Howells  * dm_ulog_request to the kernel - setting the 'error' field appropriately.
165607ca46eSDavid Howells  */
166607ca46eSDavid Howells #define DM_ULOG_GET_REGION_SIZE        6
167607ca46eSDavid Howells 
168607ca46eSDavid Howells /*
169607ca46eSDavid Howells  * DM_ULOG_IS_CLEAN corresponds to (found in dm-dirty-log.h):
170607ca46eSDavid Howells  * int (*is_clean)(struct dm_dirty_log *log, region_t region);
171607ca46eSDavid Howells  *
172607ca46eSDavid Howells  * Payload-to-userspace:
173209e2367SMikko Rapeli  *	__u64 - the region to get clean status on
174607ca46eSDavid Howells  * Payload-to-kernel:
175209e2367SMikko Rapeli  *	__s64  - 1 if clean, 0 otherwise
176607ca46eSDavid Howells  *
177209e2367SMikko Rapeli  * Payload is sizeof(__u64) and contains the region for which the clean
178607ca46eSDavid Howells  * status is being made.
179607ca46eSDavid Howells  *
180607ca46eSDavid Howells  * When the request has been processed, user-space must return the
181607ca46eSDavid Howells  * dm_ulog_request to the kernel - filling the payload with 0 (not clean) or
182607ca46eSDavid Howells  * 1 (clean), setting 'data_size' and 'error' appropriately.
183607ca46eSDavid Howells  */
184607ca46eSDavid Howells #define DM_ULOG_IS_CLEAN               7
185607ca46eSDavid Howells 
186607ca46eSDavid Howells /*
187607ca46eSDavid Howells  * DM_ULOG_IN_SYNC corresponds to (found in dm-dirty-log.h):
188607ca46eSDavid Howells  * int (*in_sync)(struct dm_dirty_log *log, region_t region,
189607ca46eSDavid Howells  *		  int can_block);
190607ca46eSDavid Howells  *
191607ca46eSDavid Howells  * Payload-to-userspace:
192209e2367SMikko Rapeli  *	__u64 - the region to get sync status on
193607ca46eSDavid Howells  * Payload-to-kernel:
194209e2367SMikko Rapeli  *	__s64 - 1 if in-sync, 0 otherwise
195607ca46eSDavid Howells  *
196607ca46eSDavid Howells  * Exactly the same as 'is_clean' above, except this time asking "has the
197607ca46eSDavid Howells  * region been recovered?" vs. "is the region not being modified?"
198607ca46eSDavid Howells  */
199607ca46eSDavid Howells #define DM_ULOG_IN_SYNC                8
200607ca46eSDavid Howells 
201607ca46eSDavid Howells /*
202607ca46eSDavid Howells  * DM_ULOG_FLUSH corresponds to (found in dm-dirty-log.h):
203607ca46eSDavid Howells  * int (*flush)(struct dm_dirty_log *log);
204607ca46eSDavid Howells  *
205607ca46eSDavid Howells  * Payload-to-userspace:
2065066a4dfSDongmao Zhang  *	If the 'integrated_flush' directive is present in the constructor
2075066a4dfSDongmao Zhang  *	table, the payload is as same as DM_ULOG_MARK_REGION:
208209e2367SMikko Rapeli  *		__u64 [] - region(s) to mark
2095066a4dfSDongmao Zhang  *	else
2105066a4dfSDongmao Zhang  *		None
211607ca46eSDavid Howells  * Payload-to-kernel:
212607ca46eSDavid Howells  *	None.
213607ca46eSDavid Howells  *
2145066a4dfSDongmao Zhang  * If the 'integrated_flush' option was used during the creation of the
2155066a4dfSDongmao Zhang  * log, mark region requests are carried as payload in the flush request.
2165066a4dfSDongmao Zhang  * Piggybacking the mark requests in this way allows for fewer communications
2175066a4dfSDongmao Zhang  * between kernel and userspace.
218607ca46eSDavid Howells  *
219607ca46eSDavid Howells  * When the request has been processed, user-space must return the
220607ca46eSDavid Howells  * dm_ulog_request to the kernel - setting the 'error' field and clearing
221607ca46eSDavid Howells  * 'data_size' appropriately.
222607ca46eSDavid Howells  */
223607ca46eSDavid Howells #define DM_ULOG_FLUSH                  9
224607ca46eSDavid Howells 
225607ca46eSDavid Howells /*
226607ca46eSDavid Howells  * DM_ULOG_MARK_REGION corresponds to (found in dm-dirty-log.h):
227607ca46eSDavid Howells  * void (*mark_region)(struct dm_dirty_log *log, region_t region);
228607ca46eSDavid Howells  *
229607ca46eSDavid Howells  * Payload-to-userspace:
230209e2367SMikko Rapeli  *	__u64 [] - region(s) to mark
231607ca46eSDavid Howells  * Payload-to-kernel:
232607ca46eSDavid Howells  *	None.
233607ca46eSDavid Howells  *
234607ca46eSDavid Howells  * Incoming payload contains the one or more regions to mark dirty.
235607ca46eSDavid Howells  * The number of regions contained in the payload can be determined from
236209e2367SMikko Rapeli  * 'data_size/sizeof(__u64)'.
237607ca46eSDavid Howells  *
238607ca46eSDavid Howells  * When the request has been processed, user-space must return the
239607ca46eSDavid Howells  * dm_ulog_request to the kernel - setting the 'error' field and clearing
240607ca46eSDavid Howells  * 'data_size' appropriately.
241607ca46eSDavid Howells  */
242607ca46eSDavid Howells #define DM_ULOG_MARK_REGION           10
243607ca46eSDavid Howells 
244607ca46eSDavid Howells /*
245607ca46eSDavid Howells  * DM_ULOG_CLEAR_REGION corresponds to (found in dm-dirty-log.h):
246607ca46eSDavid Howells  * void (*clear_region)(struct dm_dirty_log *log, region_t region);
247607ca46eSDavid Howells  *
248607ca46eSDavid Howells  * Payload-to-userspace:
249209e2367SMikko Rapeli  *	__u64 [] - region(s) to clear
250607ca46eSDavid Howells  * Payload-to-kernel:
251607ca46eSDavid Howells  *	None.
252607ca46eSDavid Howells  *
253607ca46eSDavid Howells  * Incoming payload contains the one or more regions to mark clean.
254607ca46eSDavid Howells  * The number of regions contained in the payload can be determined from
255209e2367SMikko Rapeli  * 'data_size/sizeof(__u64)'.
256607ca46eSDavid Howells  *
257607ca46eSDavid Howells  * When the request has been processed, user-space must return the
258607ca46eSDavid Howells  * dm_ulog_request to the kernel - setting the 'error' field and clearing
259607ca46eSDavid Howells  * 'data_size' appropriately.
260607ca46eSDavid Howells  */
261607ca46eSDavid Howells #define DM_ULOG_CLEAR_REGION          11
262607ca46eSDavid Howells 
263607ca46eSDavid Howells /*
264607ca46eSDavid Howells  * DM_ULOG_GET_RESYNC_WORK corresponds to (found in dm-dirty-log.h):
265607ca46eSDavid Howells  * int (*get_resync_work)(struct dm_dirty_log *log, region_t *region);
266607ca46eSDavid Howells  *
267607ca46eSDavid Howells  * Payload-to-userspace:
268607ca46eSDavid Howells  *	None.
269607ca46eSDavid Howells  * Payload-to-kernel:
270607ca46eSDavid Howells  *	{
271209e2367SMikko Rapeli  *		__s64 i; -- 1 if recovery necessary, 0 otherwise
272209e2367SMikko Rapeli  *		__u64 r; -- The region to recover if i=1
273607ca46eSDavid Howells  *	}
274607ca46eSDavid Howells  * 'data_size' should be set appropriately.
275607ca46eSDavid Howells  *
276607ca46eSDavid Howells  * When the request has been processed, user-space must return the
277607ca46eSDavid Howells  * dm_ulog_request to the kernel - setting the 'error' field appropriately.
278607ca46eSDavid Howells  */
279607ca46eSDavid Howells #define DM_ULOG_GET_RESYNC_WORK       12
280607ca46eSDavid Howells 
281607ca46eSDavid Howells /*
282607ca46eSDavid Howells  * DM_ULOG_SET_REGION_SYNC corresponds to (found in dm-dirty-log.h):
283607ca46eSDavid Howells  * void (*set_region_sync)(struct dm_dirty_log *log,
284607ca46eSDavid Howells  *			   region_t region, int in_sync);
285607ca46eSDavid Howells  *
286607ca46eSDavid Howells  * Payload-to-userspace:
287607ca46eSDavid Howells  *	{
288209e2367SMikko Rapeli  *		__u64 - region to set sync state on
289209e2367SMikko Rapeli  *		__s64  - 0 if not-in-sync, 1 if in-sync
290607ca46eSDavid Howells  *	}
291607ca46eSDavid Howells  * Payload-to-kernel:
292607ca46eSDavid Howells  *	None.
293607ca46eSDavid Howells  *
294607ca46eSDavid Howells  * When the request has been processed, user-space must return the
295607ca46eSDavid Howells  * dm_ulog_request to the kernel - setting the 'error' field and clearing
296607ca46eSDavid Howells  * 'data_size' appropriately.
297607ca46eSDavid Howells  */
298607ca46eSDavid Howells #define DM_ULOG_SET_REGION_SYNC       13
299607ca46eSDavid Howells 
300607ca46eSDavid Howells /*
301607ca46eSDavid Howells  * DM_ULOG_GET_SYNC_COUNT corresponds to (found in dm-dirty-log.h):
302607ca46eSDavid Howells  * region_t (*get_sync_count)(struct dm_dirty_log *log);
303607ca46eSDavid Howells  *
304607ca46eSDavid Howells  * Payload-to-userspace:
305607ca46eSDavid Howells  *	None.
306607ca46eSDavid Howells  * Payload-to-kernel:
307209e2367SMikko Rapeli  *	__u64 - the number of in-sync regions
308607ca46eSDavid Howells  *
309607ca46eSDavid Howells  * No incoming payload.  Kernel-bound payload contains the number of
310607ca46eSDavid Howells  * regions that are in-sync (in a size_t).
311607ca46eSDavid Howells  *
312607ca46eSDavid Howells  * When the request has been processed, user-space must return the
313607ca46eSDavid Howells  * dm_ulog_request to the kernel - setting the 'error' field and
314607ca46eSDavid Howells  * 'data_size' appropriately.
315607ca46eSDavid Howells  */
316607ca46eSDavid Howells #define DM_ULOG_GET_SYNC_COUNT        14
317607ca46eSDavid Howells 
318607ca46eSDavid Howells /*
319607ca46eSDavid Howells  * DM_ULOG_STATUS_INFO corresponds to (found in dm-dirty-log.h):
320607ca46eSDavid Howells  * int (*status)(struct dm_dirty_log *log, STATUSTYPE_INFO,
321607ca46eSDavid Howells  *		 char *result, unsigned maxlen);
322607ca46eSDavid Howells  *
323607ca46eSDavid Howells  * Payload-to-userspace:
324607ca46eSDavid Howells  *	None.
325607ca46eSDavid Howells  * Payload-to-kernel:
326607ca46eSDavid Howells  *	Character string containing STATUSTYPE_INFO
327607ca46eSDavid Howells  *
328607ca46eSDavid Howells  * When the request has been processed, user-space must return the
329607ca46eSDavid Howells  * dm_ulog_request to the kernel - setting the 'error' field and
330607ca46eSDavid Howells  * 'data_size' appropriately.
331607ca46eSDavid Howells  */
332607ca46eSDavid Howells #define DM_ULOG_STATUS_INFO           15
333607ca46eSDavid Howells 
334607ca46eSDavid Howells /*
335607ca46eSDavid Howells  * DM_ULOG_STATUS_TABLE corresponds to (found in dm-dirty-log.h):
336607ca46eSDavid Howells  * int (*status)(struct dm_dirty_log *log, STATUSTYPE_TABLE,
337607ca46eSDavid Howells  *		 char *result, unsigned maxlen);
338607ca46eSDavid Howells  *
339607ca46eSDavid Howells  * Payload-to-userspace:
340607ca46eSDavid Howells  *	None.
341607ca46eSDavid Howells  * Payload-to-kernel:
342607ca46eSDavid Howells  *	Character string containing STATUSTYPE_TABLE
343607ca46eSDavid Howells  *
344607ca46eSDavid Howells  * When the request has been processed, user-space must return the
345607ca46eSDavid Howells  * dm_ulog_request to the kernel - setting the 'error' field and
346607ca46eSDavid Howells  * 'data_size' appropriately.
347607ca46eSDavid Howells  */
348607ca46eSDavid Howells #define DM_ULOG_STATUS_TABLE          16
349607ca46eSDavid Howells 
350607ca46eSDavid Howells /*
351607ca46eSDavid Howells  * DM_ULOG_IS_REMOTE_RECOVERING corresponds to (found in dm-dirty-log.h):
352607ca46eSDavid Howells  * int (*is_remote_recovering)(struct dm_dirty_log *log, region_t region);
353607ca46eSDavid Howells  *
354607ca46eSDavid Howells  * Payload-to-userspace:
355209e2367SMikko Rapeli  *	__u64 - region to determine recovery status on
356607ca46eSDavid Howells  * Payload-to-kernel:
357607ca46eSDavid Howells  *	{
358209e2367SMikko Rapeli  *		__s64 is_recovering;  -- 0 if no, 1 if yes
359209e2367SMikko Rapeli  *		__u64 in_sync_hint;  -- lowest region still needing resync
360607ca46eSDavid Howells  *	}
361607ca46eSDavid Howells  *
362607ca46eSDavid Howells  * When the request has been processed, user-space must return the
363607ca46eSDavid Howells  * dm_ulog_request to the kernel - setting the 'error' field and
364607ca46eSDavid Howells  * 'data_size' appropriately.
365607ca46eSDavid Howells  */
366607ca46eSDavid Howells #define DM_ULOG_IS_REMOTE_RECOVERING  17
367607ca46eSDavid Howells 
368607ca46eSDavid Howells /*
369607ca46eSDavid Howells  * (DM_ULOG_REQUEST_MASK & request_type) to get the request type
370607ca46eSDavid Howells  *
371607ca46eSDavid Howells  * Payload-to-userspace:
372607ca46eSDavid Howells  *	A single string containing all the argv arguments separated by ' 's
373607ca46eSDavid Howells  * Payload-to-kernel:
374607ca46eSDavid Howells  *	None.  ('data_size' in the dm_ulog_request struct should be 0.)
375607ca46eSDavid Howells  *
376607ca46eSDavid Howells  * We are reserving 8 bits of the 32-bit 'request_type' field for the
377607ca46eSDavid Howells  * various request types above.  The remaining 24-bits are currently
378607ca46eSDavid Howells  * set to zero and are reserved for future use and compatibility concerns.
379607ca46eSDavid Howells  *
380607ca46eSDavid Howells  * User-space should always use DM_ULOG_REQUEST_TYPE to acquire the
381607ca46eSDavid Howells  * request type from the 'request_type' field to maintain forward compatibility.
382607ca46eSDavid Howells  */
383607ca46eSDavid Howells #define DM_ULOG_REQUEST_MASK 0xFF
384607ca46eSDavid Howells #define DM_ULOG_REQUEST_TYPE(request_type) \
385607ca46eSDavid Howells 	(DM_ULOG_REQUEST_MASK & (request_type))
386607ca46eSDavid Howells 
387607ca46eSDavid Howells /*
388607ca46eSDavid Howells  * DM_ULOG_REQUEST_VERSION is incremented when there is a
389607ca46eSDavid Howells  * change to the way information is passed between kernel
390607ca46eSDavid Howells  * and userspace.  This could be a structure change of
391607ca46eSDavid Howells  * dm_ulog_request or a change in the way requests are
392607ca46eSDavid Howells  * issued/handled.  Changes are outlined here:
393607ca46eSDavid Howells  *	version 1:  Initial implementation
394607ca46eSDavid Howells  *	version 2:  DM_ULOG_CTR allowed to return a string containing a
395607ca46eSDavid Howells  *	            device name that is to be registered with DM via
396607ca46eSDavid Howells  *	            'dm_get_device'.
3975066a4dfSDongmao Zhang  *	version 3:  DM_ULOG_FLUSH is capable of carrying payload for marking
3985066a4dfSDongmao Zhang  *		    regions.  This "integrated flush" reduces the number of
3995066a4dfSDongmao Zhang  *		    requests between the kernel and userspace by effectively
4005066a4dfSDongmao Zhang  *		    merging 'mark' and 'flush' requests.  A constructor table
4015066a4dfSDongmao Zhang  *		    argument ('integrated_flush') is required to turn this
4025066a4dfSDongmao Zhang  *		    feature on, so it is backwards compatible with older
4035066a4dfSDongmao Zhang  *		    userspace versions.
404607ca46eSDavid Howells  */
4055066a4dfSDongmao Zhang #define DM_ULOG_REQUEST_VERSION 3
406607ca46eSDavid Howells 
407607ca46eSDavid Howells struct dm_ulog_request {
408607ca46eSDavid Howells 	/*
409607ca46eSDavid Howells 	 * The local unique identifier (luid) and the universally unique
410607ca46eSDavid Howells 	 * identifier (uuid) are used to tie a request to a specific
411607ca46eSDavid Howells 	 * mirror log.  A single machine log could probably make due with
412607ca46eSDavid Howells 	 * just the 'luid', but a cluster-aware log must use the 'uuid' and
413607ca46eSDavid Howells 	 * the 'luid'.  The uuid is what is required for node to node
414607ca46eSDavid Howells 	 * communication concerning a particular log, but the 'luid' helps
415607ca46eSDavid Howells 	 * differentiate between logs that are being swapped and have the
416607ca46eSDavid Howells 	 * same 'uuid'.  (Think "live" and "inactive" device-mapper tables.)
417607ca46eSDavid Howells 	 */
418209e2367SMikko Rapeli 	__u64 luid;
419607ca46eSDavid Howells 	char uuid[DM_UUID_LEN];
420607ca46eSDavid Howells 	char padding[3];        /* Padding because DM_UUID_LEN = 129 */
421607ca46eSDavid Howells 
422209e2367SMikko Rapeli 	__u32 version;       /* See DM_ULOG_REQUEST_VERSION */
423209e2367SMikko Rapeli 	__s32 error;          /* Used to report back processing errors */
424607ca46eSDavid Howells 
425209e2367SMikko Rapeli 	__u32 seq;           /* Sequence number for request */
426209e2367SMikko Rapeli 	__u32 request_type;  /* DM_ULOG_* defined above */
427209e2367SMikko Rapeli 	__u32 data_size;     /* How much data (not including this struct) */
428607ca46eSDavid Howells 
429*94dfc73eSGustavo A. R. Silva 	char data[];
430607ca46eSDavid Howells };
431607ca46eSDavid Howells 
432607ca46eSDavid Howells #endif /* __DM_LOG_USERSPACE_H__ */
433