1*4882a593Smuzhiyun /* SPDX-License-Identifier: LGPL-2.0+ WITH Linux-syscall-note */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * Copyright (C) 2006-2009 Red Hat, Inc. 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * This file is released under the LGPL. 6*4882a593Smuzhiyun */ 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun #ifndef __DM_LOG_USERSPACE_H__ 9*4882a593Smuzhiyun #define __DM_LOG_USERSPACE_H__ 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun #include <linux/types.h> 12*4882a593Smuzhiyun #include <linux/dm-ioctl.h> /* For DM_UUID_LEN */ 13*4882a593Smuzhiyun 14*4882a593Smuzhiyun /* 15*4882a593Smuzhiyun * The device-mapper userspace log module consists of a kernel component and 16*4882a593Smuzhiyun * a user-space component. The kernel component implements the API defined 17*4882a593Smuzhiyun * in dm-dirty-log.h. Its purpose is simply to pass the parameters and 18*4882a593Smuzhiyun * return values of those API functions between kernel and user-space. 19*4882a593Smuzhiyun * 20*4882a593Smuzhiyun * Below are defined the 'request_types' - DM_ULOG_CTR, DM_ULOG_DTR, etc. 21*4882a593Smuzhiyun * These request types represent the different functions in the device-mapper 22*4882a593Smuzhiyun * dirty log API. Each of these is described in more detail below. 23*4882a593Smuzhiyun * 24*4882a593Smuzhiyun * The user-space program must listen for requests from the kernel (representing 25*4882a593Smuzhiyun * the various API functions) and process them. 26*4882a593Smuzhiyun * 27*4882a593Smuzhiyun * User-space begins by setting up the communication link (error checking 28*4882a593Smuzhiyun * removed for clarity): 29*4882a593Smuzhiyun * fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR); 30*4882a593Smuzhiyun * addr.nl_family = AF_NETLINK; 31*4882a593Smuzhiyun * addr.nl_groups = CN_IDX_DM; 32*4882a593Smuzhiyun * addr.nl_pid = 0; 33*4882a593Smuzhiyun * r = bind(fd, (struct sockaddr *) &addr, sizeof(addr)); 34*4882a593Smuzhiyun * opt = addr.nl_groups; 35*4882a593Smuzhiyun * setsockopt(fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, &opt, sizeof(opt)); 36*4882a593Smuzhiyun * 37*4882a593Smuzhiyun * User-space will then wait to receive requests form the kernel, which it 38*4882a593Smuzhiyun * will process as described below. The requests are received in the form, 39*4882a593Smuzhiyun * ((struct dm_ulog_request) + (additional data)). Depending on the request 40*4882a593Smuzhiyun * type, there may or may not be 'additional data'. In the descriptions below, 41*4882a593Smuzhiyun * you will see 'Payload-to-userspace' and 'Payload-to-kernel'. The 42*4882a593Smuzhiyun * 'Payload-to-userspace' is what the kernel sends in 'additional data' as 43*4882a593Smuzhiyun * necessary parameters to complete the request. The 'Payload-to-kernel' is 44*4882a593Smuzhiyun * the 'additional data' returned to the kernel that contains the necessary 45*4882a593Smuzhiyun * results of the request. The 'data_size' field in the dm_ulog_request 46*4882a593Smuzhiyun * structure denotes the availability and amount of payload data. 47*4882a593Smuzhiyun */ 48*4882a593Smuzhiyun 49*4882a593Smuzhiyun /* 50*4882a593Smuzhiyun * DM_ULOG_CTR corresponds to (found in dm-dirty-log.h): 51*4882a593Smuzhiyun * int (*ctr)(struct dm_dirty_log *log, struct dm_target *ti, 52*4882a593Smuzhiyun * unsigned argc, char **argv); 53*4882a593Smuzhiyun * 54*4882a593Smuzhiyun * Payload-to-userspace: 55*4882a593Smuzhiyun * A single string containing all the argv arguments separated by ' 's 56*4882a593Smuzhiyun * Payload-to-kernel: 57*4882a593Smuzhiyun * A NUL-terminated string that is the name of the device that is used 58*4882a593Smuzhiyun * as the backing store for the log data. 'dm_get_device' will be called 59*4882a593Smuzhiyun * on this device. ('dm_put_device' will be called on this device 60*4882a593Smuzhiyun * automatically after calling DM_ULOG_DTR.) If there is no device needed 61*4882a593Smuzhiyun * for log data, 'data_size' in the dm_ulog_request struct should be 0. 62*4882a593Smuzhiyun * 63*4882a593Smuzhiyun * The UUID contained in the dm_ulog_request structure is the reference that 64*4882a593Smuzhiyun * will be used by all request types to a specific log. The constructor must 65*4882a593Smuzhiyun * record this association with the instance created. 66*4882a593Smuzhiyun * 67*4882a593Smuzhiyun * When the request has been processed, user-space must return the 68*4882a593Smuzhiyun * dm_ulog_request to the kernel - setting the 'error' field, filling the 69*4882a593Smuzhiyun * data field with the log device if necessary, and setting 'data_size' 70*4882a593Smuzhiyun * appropriately. 71*4882a593Smuzhiyun */ 72*4882a593Smuzhiyun #define DM_ULOG_CTR 1 73*4882a593Smuzhiyun 74*4882a593Smuzhiyun /* 75*4882a593Smuzhiyun * DM_ULOG_DTR corresponds to (found in dm-dirty-log.h): 76*4882a593Smuzhiyun * void (*dtr)(struct dm_dirty_log *log); 77*4882a593Smuzhiyun * 78*4882a593Smuzhiyun * Payload-to-userspace: 79*4882a593Smuzhiyun * A single string containing all the argv arguments separated by ' 's 80*4882a593Smuzhiyun * Payload-to-kernel: 81*4882a593Smuzhiyun * None. ('data_size' in the dm_ulog_request struct should be 0.) 82*4882a593Smuzhiyun * 83*4882a593Smuzhiyun * The UUID contained in the dm_ulog_request structure is all that is 84*4882a593Smuzhiyun * necessary to identify the log instance being destroyed. There is no 85*4882a593Smuzhiyun * payload data. 86*4882a593Smuzhiyun * 87*4882a593Smuzhiyun * When the request has been processed, user-space must return the 88*4882a593Smuzhiyun * dm_ulog_request to the kernel - setting the 'error' field and clearing 89*4882a593Smuzhiyun * 'data_size' appropriately. 90*4882a593Smuzhiyun */ 91*4882a593Smuzhiyun #define DM_ULOG_DTR 2 92*4882a593Smuzhiyun 93*4882a593Smuzhiyun /* 94*4882a593Smuzhiyun * DM_ULOG_PRESUSPEND corresponds to (found in dm-dirty-log.h): 95*4882a593Smuzhiyun * int (*presuspend)(struct dm_dirty_log *log); 96*4882a593Smuzhiyun * 97*4882a593Smuzhiyun * Payload-to-userspace: 98*4882a593Smuzhiyun * None. 99*4882a593Smuzhiyun * Payload-to-kernel: 100*4882a593Smuzhiyun * None. 101*4882a593Smuzhiyun * 102*4882a593Smuzhiyun * The UUID contained in the dm_ulog_request structure is all that is 103*4882a593Smuzhiyun * necessary to identify the log instance being presuspended. There is no 104*4882a593Smuzhiyun * payload data. 105*4882a593Smuzhiyun * 106*4882a593Smuzhiyun * When the request has been processed, user-space must return the 107*4882a593Smuzhiyun * dm_ulog_request to the kernel - setting the 'error' field and 108*4882a593Smuzhiyun * 'data_size' appropriately. 109*4882a593Smuzhiyun */ 110*4882a593Smuzhiyun #define DM_ULOG_PRESUSPEND 3 111*4882a593Smuzhiyun 112*4882a593Smuzhiyun /* 113*4882a593Smuzhiyun * DM_ULOG_POSTSUSPEND corresponds to (found in dm-dirty-log.h): 114*4882a593Smuzhiyun * int (*postsuspend)(struct dm_dirty_log *log); 115*4882a593Smuzhiyun * 116*4882a593Smuzhiyun * Payload-to-userspace: 117*4882a593Smuzhiyun * None. 118*4882a593Smuzhiyun * Payload-to-kernel: 119*4882a593Smuzhiyun * None. 120*4882a593Smuzhiyun * 121*4882a593Smuzhiyun * The UUID contained in the dm_ulog_request structure is all that is 122*4882a593Smuzhiyun * necessary to identify the log instance being postsuspended. There is no 123*4882a593Smuzhiyun * payload data. 124*4882a593Smuzhiyun * 125*4882a593Smuzhiyun * When the request has been processed, user-space must return the 126*4882a593Smuzhiyun * dm_ulog_request to the kernel - setting the 'error' field and 127*4882a593Smuzhiyun * 'data_size' appropriately. 128*4882a593Smuzhiyun */ 129*4882a593Smuzhiyun #define DM_ULOG_POSTSUSPEND 4 130*4882a593Smuzhiyun 131*4882a593Smuzhiyun /* 132*4882a593Smuzhiyun * DM_ULOG_RESUME corresponds to (found in dm-dirty-log.h): 133*4882a593Smuzhiyun * int (*resume)(struct dm_dirty_log *log); 134*4882a593Smuzhiyun * 135*4882a593Smuzhiyun * Payload-to-userspace: 136*4882a593Smuzhiyun * None. 137*4882a593Smuzhiyun * Payload-to-kernel: 138*4882a593Smuzhiyun * None. 139*4882a593Smuzhiyun * 140*4882a593Smuzhiyun * The UUID contained in the dm_ulog_request structure is all that is 141*4882a593Smuzhiyun * necessary to identify the log instance being resumed. There is no 142*4882a593Smuzhiyun * payload data. 143*4882a593Smuzhiyun * 144*4882a593Smuzhiyun * When the request has been processed, user-space must return the 145*4882a593Smuzhiyun * dm_ulog_request to the kernel - setting the 'error' field and 146*4882a593Smuzhiyun * 'data_size' appropriately. 147*4882a593Smuzhiyun */ 148*4882a593Smuzhiyun #define DM_ULOG_RESUME 5 149*4882a593Smuzhiyun 150*4882a593Smuzhiyun /* 151*4882a593Smuzhiyun * DM_ULOG_GET_REGION_SIZE corresponds to (found in dm-dirty-log.h): 152*4882a593Smuzhiyun * __u32 (*get_region_size)(struct dm_dirty_log *log); 153*4882a593Smuzhiyun * 154*4882a593Smuzhiyun * Payload-to-userspace: 155*4882a593Smuzhiyun * None. 156*4882a593Smuzhiyun * Payload-to-kernel: 157*4882a593Smuzhiyun * __u64 - contains the region size 158*4882a593Smuzhiyun * 159*4882a593Smuzhiyun * The region size is something that was determined at constructor time. 160*4882a593Smuzhiyun * It is returned in the payload area and 'data_size' is set to 161*4882a593Smuzhiyun * reflect this. 162*4882a593Smuzhiyun * 163*4882a593Smuzhiyun * When the request has been processed, user-space must return the 164*4882a593Smuzhiyun * dm_ulog_request to the kernel - setting the 'error' field appropriately. 165*4882a593Smuzhiyun */ 166*4882a593Smuzhiyun #define DM_ULOG_GET_REGION_SIZE 6 167*4882a593Smuzhiyun 168*4882a593Smuzhiyun /* 169*4882a593Smuzhiyun * DM_ULOG_IS_CLEAN corresponds to (found in dm-dirty-log.h): 170*4882a593Smuzhiyun * int (*is_clean)(struct dm_dirty_log *log, region_t region); 171*4882a593Smuzhiyun * 172*4882a593Smuzhiyun * Payload-to-userspace: 173*4882a593Smuzhiyun * __u64 - the region to get clean status on 174*4882a593Smuzhiyun * Payload-to-kernel: 175*4882a593Smuzhiyun * __s64 - 1 if clean, 0 otherwise 176*4882a593Smuzhiyun * 177*4882a593Smuzhiyun * Payload is sizeof(__u64) and contains the region for which the clean 178*4882a593Smuzhiyun * status is being made. 179*4882a593Smuzhiyun * 180*4882a593Smuzhiyun * When the request has been processed, user-space must return the 181*4882a593Smuzhiyun * dm_ulog_request to the kernel - filling the payload with 0 (not clean) or 182*4882a593Smuzhiyun * 1 (clean), setting 'data_size' and 'error' appropriately. 183*4882a593Smuzhiyun */ 184*4882a593Smuzhiyun #define DM_ULOG_IS_CLEAN 7 185*4882a593Smuzhiyun 186*4882a593Smuzhiyun /* 187*4882a593Smuzhiyun * DM_ULOG_IN_SYNC corresponds to (found in dm-dirty-log.h): 188*4882a593Smuzhiyun * int (*in_sync)(struct dm_dirty_log *log, region_t region, 189*4882a593Smuzhiyun * int can_block); 190*4882a593Smuzhiyun * 191*4882a593Smuzhiyun * Payload-to-userspace: 192*4882a593Smuzhiyun * __u64 - the region to get sync status on 193*4882a593Smuzhiyun * Payload-to-kernel: 194*4882a593Smuzhiyun * __s64 - 1 if in-sync, 0 otherwise 195*4882a593Smuzhiyun * 196*4882a593Smuzhiyun * Exactly the same as 'is_clean' above, except this time asking "has the 197*4882a593Smuzhiyun * region been recovered?" vs. "is the region not being modified?" 198*4882a593Smuzhiyun */ 199*4882a593Smuzhiyun #define DM_ULOG_IN_SYNC 8 200*4882a593Smuzhiyun 201*4882a593Smuzhiyun /* 202*4882a593Smuzhiyun * DM_ULOG_FLUSH corresponds to (found in dm-dirty-log.h): 203*4882a593Smuzhiyun * int (*flush)(struct dm_dirty_log *log); 204*4882a593Smuzhiyun * 205*4882a593Smuzhiyun * Payload-to-userspace: 206*4882a593Smuzhiyun * If the 'integrated_flush' directive is present in the constructor 207*4882a593Smuzhiyun * table, the payload is as same as DM_ULOG_MARK_REGION: 208*4882a593Smuzhiyun * __u64 [] - region(s) to mark 209*4882a593Smuzhiyun * else 210*4882a593Smuzhiyun * None 211*4882a593Smuzhiyun * Payload-to-kernel: 212*4882a593Smuzhiyun * None. 213*4882a593Smuzhiyun * 214*4882a593Smuzhiyun * If the 'integrated_flush' option was used during the creation of the 215*4882a593Smuzhiyun * log, mark region requests are carried as payload in the flush request. 216*4882a593Smuzhiyun * Piggybacking the mark requests in this way allows for fewer communications 217*4882a593Smuzhiyun * between kernel and userspace. 218*4882a593Smuzhiyun * 219*4882a593Smuzhiyun * When the request has been processed, user-space must return the 220*4882a593Smuzhiyun * dm_ulog_request to the kernel - setting the 'error' field and clearing 221*4882a593Smuzhiyun * 'data_size' appropriately. 222*4882a593Smuzhiyun */ 223*4882a593Smuzhiyun #define DM_ULOG_FLUSH 9 224*4882a593Smuzhiyun 225*4882a593Smuzhiyun /* 226*4882a593Smuzhiyun * DM_ULOG_MARK_REGION corresponds to (found in dm-dirty-log.h): 227*4882a593Smuzhiyun * void (*mark_region)(struct dm_dirty_log *log, region_t region); 228*4882a593Smuzhiyun * 229*4882a593Smuzhiyun * Payload-to-userspace: 230*4882a593Smuzhiyun * __u64 [] - region(s) to mark 231*4882a593Smuzhiyun * Payload-to-kernel: 232*4882a593Smuzhiyun * None. 233*4882a593Smuzhiyun * 234*4882a593Smuzhiyun * Incoming payload contains the one or more regions to mark dirty. 235*4882a593Smuzhiyun * The number of regions contained in the payload can be determined from 236*4882a593Smuzhiyun * 'data_size/sizeof(__u64)'. 237*4882a593Smuzhiyun * 238*4882a593Smuzhiyun * When the request has been processed, user-space must return the 239*4882a593Smuzhiyun * dm_ulog_request to the kernel - setting the 'error' field and clearing 240*4882a593Smuzhiyun * 'data_size' appropriately. 241*4882a593Smuzhiyun */ 242*4882a593Smuzhiyun #define DM_ULOG_MARK_REGION 10 243*4882a593Smuzhiyun 244*4882a593Smuzhiyun /* 245*4882a593Smuzhiyun * DM_ULOG_CLEAR_REGION corresponds to (found in dm-dirty-log.h): 246*4882a593Smuzhiyun * void (*clear_region)(struct dm_dirty_log *log, region_t region); 247*4882a593Smuzhiyun * 248*4882a593Smuzhiyun * Payload-to-userspace: 249*4882a593Smuzhiyun * __u64 [] - region(s) to clear 250*4882a593Smuzhiyun * Payload-to-kernel: 251*4882a593Smuzhiyun * None. 252*4882a593Smuzhiyun * 253*4882a593Smuzhiyun * Incoming payload contains the one or more regions to mark clean. 254*4882a593Smuzhiyun * The number of regions contained in the payload can be determined from 255*4882a593Smuzhiyun * 'data_size/sizeof(__u64)'. 256*4882a593Smuzhiyun * 257*4882a593Smuzhiyun * When the request has been processed, user-space must return the 258*4882a593Smuzhiyun * dm_ulog_request to the kernel - setting the 'error' field and clearing 259*4882a593Smuzhiyun * 'data_size' appropriately. 260*4882a593Smuzhiyun */ 261*4882a593Smuzhiyun #define DM_ULOG_CLEAR_REGION 11 262*4882a593Smuzhiyun 263*4882a593Smuzhiyun /* 264*4882a593Smuzhiyun * DM_ULOG_GET_RESYNC_WORK corresponds to (found in dm-dirty-log.h): 265*4882a593Smuzhiyun * int (*get_resync_work)(struct dm_dirty_log *log, region_t *region); 266*4882a593Smuzhiyun * 267*4882a593Smuzhiyun * Payload-to-userspace: 268*4882a593Smuzhiyun * None. 269*4882a593Smuzhiyun * Payload-to-kernel: 270*4882a593Smuzhiyun * { 271*4882a593Smuzhiyun * __s64 i; -- 1 if recovery necessary, 0 otherwise 272*4882a593Smuzhiyun * __u64 r; -- The region to recover if i=1 273*4882a593Smuzhiyun * } 274*4882a593Smuzhiyun * 'data_size' should be set appropriately. 275*4882a593Smuzhiyun * 276*4882a593Smuzhiyun * When the request has been processed, user-space must return the 277*4882a593Smuzhiyun * dm_ulog_request to the kernel - setting the 'error' field appropriately. 278*4882a593Smuzhiyun */ 279*4882a593Smuzhiyun #define DM_ULOG_GET_RESYNC_WORK 12 280*4882a593Smuzhiyun 281*4882a593Smuzhiyun /* 282*4882a593Smuzhiyun * DM_ULOG_SET_REGION_SYNC corresponds to (found in dm-dirty-log.h): 283*4882a593Smuzhiyun * void (*set_region_sync)(struct dm_dirty_log *log, 284*4882a593Smuzhiyun * region_t region, int in_sync); 285*4882a593Smuzhiyun * 286*4882a593Smuzhiyun * Payload-to-userspace: 287*4882a593Smuzhiyun * { 288*4882a593Smuzhiyun * __u64 - region to set sync state on 289*4882a593Smuzhiyun * __s64 - 0 if not-in-sync, 1 if in-sync 290*4882a593Smuzhiyun * } 291*4882a593Smuzhiyun * Payload-to-kernel: 292*4882a593Smuzhiyun * None. 293*4882a593Smuzhiyun * 294*4882a593Smuzhiyun * When the request has been processed, user-space must return the 295*4882a593Smuzhiyun * dm_ulog_request to the kernel - setting the 'error' field and clearing 296*4882a593Smuzhiyun * 'data_size' appropriately. 297*4882a593Smuzhiyun */ 298*4882a593Smuzhiyun #define DM_ULOG_SET_REGION_SYNC 13 299*4882a593Smuzhiyun 300*4882a593Smuzhiyun /* 301*4882a593Smuzhiyun * DM_ULOG_GET_SYNC_COUNT corresponds to (found in dm-dirty-log.h): 302*4882a593Smuzhiyun * region_t (*get_sync_count)(struct dm_dirty_log *log); 303*4882a593Smuzhiyun * 304*4882a593Smuzhiyun * Payload-to-userspace: 305*4882a593Smuzhiyun * None. 306*4882a593Smuzhiyun * Payload-to-kernel: 307*4882a593Smuzhiyun * __u64 - the number of in-sync regions 308*4882a593Smuzhiyun * 309*4882a593Smuzhiyun * No incoming payload. Kernel-bound payload contains the number of 310*4882a593Smuzhiyun * regions that are in-sync (in a size_t). 311*4882a593Smuzhiyun * 312*4882a593Smuzhiyun * When the request has been processed, user-space must return the 313*4882a593Smuzhiyun * dm_ulog_request to the kernel - setting the 'error' field and 314*4882a593Smuzhiyun * 'data_size' appropriately. 315*4882a593Smuzhiyun */ 316*4882a593Smuzhiyun #define DM_ULOG_GET_SYNC_COUNT 14 317*4882a593Smuzhiyun 318*4882a593Smuzhiyun /* 319*4882a593Smuzhiyun * DM_ULOG_STATUS_INFO corresponds to (found in dm-dirty-log.h): 320*4882a593Smuzhiyun * int (*status)(struct dm_dirty_log *log, STATUSTYPE_INFO, 321*4882a593Smuzhiyun * char *result, unsigned maxlen); 322*4882a593Smuzhiyun * 323*4882a593Smuzhiyun * Payload-to-userspace: 324*4882a593Smuzhiyun * None. 325*4882a593Smuzhiyun * Payload-to-kernel: 326*4882a593Smuzhiyun * Character string containing STATUSTYPE_INFO 327*4882a593Smuzhiyun * 328*4882a593Smuzhiyun * When the request has been processed, user-space must return the 329*4882a593Smuzhiyun * dm_ulog_request to the kernel - setting the 'error' field and 330*4882a593Smuzhiyun * 'data_size' appropriately. 331*4882a593Smuzhiyun */ 332*4882a593Smuzhiyun #define DM_ULOG_STATUS_INFO 15 333*4882a593Smuzhiyun 334*4882a593Smuzhiyun /* 335*4882a593Smuzhiyun * DM_ULOG_STATUS_TABLE corresponds to (found in dm-dirty-log.h): 336*4882a593Smuzhiyun * int (*status)(struct dm_dirty_log *log, STATUSTYPE_TABLE, 337*4882a593Smuzhiyun * char *result, unsigned maxlen); 338*4882a593Smuzhiyun * 339*4882a593Smuzhiyun * Payload-to-userspace: 340*4882a593Smuzhiyun * None. 341*4882a593Smuzhiyun * Payload-to-kernel: 342*4882a593Smuzhiyun * Character string containing STATUSTYPE_TABLE 343*4882a593Smuzhiyun * 344*4882a593Smuzhiyun * When the request has been processed, user-space must return the 345*4882a593Smuzhiyun * dm_ulog_request to the kernel - setting the 'error' field and 346*4882a593Smuzhiyun * 'data_size' appropriately. 347*4882a593Smuzhiyun */ 348*4882a593Smuzhiyun #define DM_ULOG_STATUS_TABLE 16 349*4882a593Smuzhiyun 350*4882a593Smuzhiyun /* 351*4882a593Smuzhiyun * DM_ULOG_IS_REMOTE_RECOVERING corresponds to (found in dm-dirty-log.h): 352*4882a593Smuzhiyun * int (*is_remote_recovering)(struct dm_dirty_log *log, region_t region); 353*4882a593Smuzhiyun * 354*4882a593Smuzhiyun * Payload-to-userspace: 355*4882a593Smuzhiyun * __u64 - region to determine recovery status on 356*4882a593Smuzhiyun * Payload-to-kernel: 357*4882a593Smuzhiyun * { 358*4882a593Smuzhiyun * __s64 is_recovering; -- 0 if no, 1 if yes 359*4882a593Smuzhiyun * __u64 in_sync_hint; -- lowest region still needing resync 360*4882a593Smuzhiyun * } 361*4882a593Smuzhiyun * 362*4882a593Smuzhiyun * When the request has been processed, user-space must return the 363*4882a593Smuzhiyun * dm_ulog_request to the kernel - setting the 'error' field and 364*4882a593Smuzhiyun * 'data_size' appropriately. 365*4882a593Smuzhiyun */ 366*4882a593Smuzhiyun #define DM_ULOG_IS_REMOTE_RECOVERING 17 367*4882a593Smuzhiyun 368*4882a593Smuzhiyun /* 369*4882a593Smuzhiyun * (DM_ULOG_REQUEST_MASK & request_type) to get the request type 370*4882a593Smuzhiyun * 371*4882a593Smuzhiyun * Payload-to-userspace: 372*4882a593Smuzhiyun * A single string containing all the argv arguments separated by ' 's 373*4882a593Smuzhiyun * Payload-to-kernel: 374*4882a593Smuzhiyun * None. ('data_size' in the dm_ulog_request struct should be 0.) 375*4882a593Smuzhiyun * 376*4882a593Smuzhiyun * We are reserving 8 bits of the 32-bit 'request_type' field for the 377*4882a593Smuzhiyun * various request types above. The remaining 24-bits are currently 378*4882a593Smuzhiyun * set to zero and are reserved for future use and compatibility concerns. 379*4882a593Smuzhiyun * 380*4882a593Smuzhiyun * User-space should always use DM_ULOG_REQUEST_TYPE to acquire the 381*4882a593Smuzhiyun * request type from the 'request_type' field to maintain forward compatibility. 382*4882a593Smuzhiyun */ 383*4882a593Smuzhiyun #define DM_ULOG_REQUEST_MASK 0xFF 384*4882a593Smuzhiyun #define DM_ULOG_REQUEST_TYPE(request_type) \ 385*4882a593Smuzhiyun (DM_ULOG_REQUEST_MASK & (request_type)) 386*4882a593Smuzhiyun 387*4882a593Smuzhiyun /* 388*4882a593Smuzhiyun * DM_ULOG_REQUEST_VERSION is incremented when there is a 389*4882a593Smuzhiyun * change to the way information is passed between kernel 390*4882a593Smuzhiyun * and userspace. This could be a structure change of 391*4882a593Smuzhiyun * dm_ulog_request or a change in the way requests are 392*4882a593Smuzhiyun * issued/handled. Changes are outlined here: 393*4882a593Smuzhiyun * version 1: Initial implementation 394*4882a593Smuzhiyun * version 2: DM_ULOG_CTR allowed to return a string containing a 395*4882a593Smuzhiyun * device name that is to be registered with DM via 396*4882a593Smuzhiyun * 'dm_get_device'. 397*4882a593Smuzhiyun * version 3: DM_ULOG_FLUSH is capable of carrying payload for marking 398*4882a593Smuzhiyun * regions. This "integrated flush" reduces the number of 399*4882a593Smuzhiyun * requests between the kernel and userspace by effectively 400*4882a593Smuzhiyun * merging 'mark' and 'flush' requests. A constructor table 401*4882a593Smuzhiyun * argument ('integrated_flush') is required to turn this 402*4882a593Smuzhiyun * feature on, so it is backwards compatible with older 403*4882a593Smuzhiyun * userspace versions. 404*4882a593Smuzhiyun */ 405*4882a593Smuzhiyun #define DM_ULOG_REQUEST_VERSION 3 406*4882a593Smuzhiyun 407*4882a593Smuzhiyun struct dm_ulog_request { 408*4882a593Smuzhiyun /* 409*4882a593Smuzhiyun * The local unique identifier (luid) and the universally unique 410*4882a593Smuzhiyun * identifier (uuid) are used to tie a request to a specific 411*4882a593Smuzhiyun * mirror log. A single machine log could probably make due with 412*4882a593Smuzhiyun * just the 'luid', but a cluster-aware log must use the 'uuid' and 413*4882a593Smuzhiyun * the 'luid'. The uuid is what is required for node to node 414*4882a593Smuzhiyun * communication concerning a particular log, but the 'luid' helps 415*4882a593Smuzhiyun * differentiate between logs that are being swapped and have the 416*4882a593Smuzhiyun * same 'uuid'. (Think "live" and "inactive" device-mapper tables.) 417*4882a593Smuzhiyun */ 418*4882a593Smuzhiyun __u64 luid; 419*4882a593Smuzhiyun char uuid[DM_UUID_LEN]; 420*4882a593Smuzhiyun char padding[3]; /* Padding because DM_UUID_LEN = 129 */ 421*4882a593Smuzhiyun 422*4882a593Smuzhiyun __u32 version; /* See DM_ULOG_REQUEST_VERSION */ 423*4882a593Smuzhiyun __s32 error; /* Used to report back processing errors */ 424*4882a593Smuzhiyun 425*4882a593Smuzhiyun __u32 seq; /* Sequence number for request */ 426*4882a593Smuzhiyun __u32 request_type; /* DM_ULOG_* defined above */ 427*4882a593Smuzhiyun __u32 data_size; /* How much data (not including this struct) */ 428*4882a593Smuzhiyun 429*4882a593Smuzhiyun char data[0]; 430*4882a593Smuzhiyun }; 431*4882a593Smuzhiyun 432*4882a593Smuzhiyun #endif /* __DM_LOG_USERSPACE_H__ */ 433