1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _SYS_MD_RENAME_H 28 #define _SYS_MD_RENAME_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #include <sys/types.h> 33 #include <sys/param.h> 34 #include <sys/systm.h> 35 #ifdef DEBUG 36 #include <sys/thread.h> 37 #endif 38 #include <sys/kstat.h> 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 #include <sys/lvm/mdvar.h> 45 46 /* 47 * rename/exchange common definitions 48 */ 49 #define MD_RENAME_VERSION_OFFLINE (1) /* top-level must be offline */ 50 #define MD_RENAME_VERSION_ONLINE (2) /* includes offline too */ 51 52 /* 53 * current protocol only allows offline exchange 54 */ 55 #define MD_RENAME_VERSION MD_RENAME_VERSION_OFFLINE 56 57 /* 58 * The rename (aka. exchange) function is implemented as the 59 * following set of named services. Many of these are implemented 60 * generically and only overridden when a specific driver needs 61 * special care. 62 */ 63 64 #if defined(_KERNEL) 65 66 #define MDRNM_LIST_URFOLKS "rename svc: list your parents" 67 #define MDRNM_LIST_URSELF "rename svc: list your self" 68 #define MDRNM_LIST_URKIDS "rename svc: list your children" 69 70 #define MDRNM_LOCK "rename svc: lock" 71 #define MDRNM_UNLOCK "rename svc: unlock" 72 #define MDRNM_CHECK "rename svc: check state" 73 74 /* role swappers */ 75 #define MDRNM_UPDATE_KIDS "rename svc: parent update children" 76 #define MDRNM_PARENT_UPDATE_TO "rename svc: parent update to" 77 #define MDRNM_SELF_UPDATE_FROM_UP "rename svc: self update from up" 78 #define MDRNM_UPDATE_SELF "rename svc: self update self" 79 #define MDRNM_SELF_UPDATE_FROM_DOWN "rename svc: self update from down" 80 #define MDRNM_CHILD_UPDATE_TO "rename svc: child update to" 81 #define MDRNM_UPDATE_FOLKS "rename svc: child update parents" 82 83 typedef enum md_rename_role_t { 84 MDRR_UNK = 0, 85 MDRR_PARENT = 1, 86 MDRR_SELF = 2, 87 MDRR_CHILD = 3, 88 MDRR_NROLES = MDRR_CHILD 89 } md_renrole_t; 90 91 typedef struct md_rendelta_status { 92 uint_t spare_beg :1; 93 uint_t locked :1; 94 uint_t checked :1; 95 uint_t role_swapped :1; 96 uint_t unlocked :1; 97 uint_t spacer :2; 98 uint_t is_open :1; 99 uint_t spare_end; 100 } md_rendstat_t; 101 102 typedef struct md_rentxn_status { 103 uint_t spare_beg :1; 104 uint_t trans_in_stack :1; 105 uint_t spare_end; 106 } md_rentstat_t; 107 108 typedef struct md_rename_transaction { 109 u_longlong_t beginning; 110 md_error_t mde; 111 md_renop_t op; 112 int revision; 113 uint_t uflags; 114 int rec_idx; 115 mddb_recid_t *recids; 116 int n_recids; 117 md_rentstat_t stat; 118 119 struct md_rename_txn_unit_state { 120 u_longlong_t beginning; 121 minor_t mnum; 122 mdi_unit_t *uip; 123 md_unit_t *unp; 124 key_t key; 125 kstat_t *kstatp; 126 u_longlong_t end; 127 128 } from, to; 129 u_longlong_t end; 130 } md_rentxn_t; 131 132 typedef struct md_rendelta md_rendelta_t; 133 134 typedef void md_ren_void_svc_t(md_rendelta_t *, md_rentxn_t *); 135 typedef intptr_t md_ren_svc_t(md_rendelta_t *, md_rentxn_t *); 136 typedef int md_ren_list_svc_t(md_rendelta_t **, md_rentxn_t *); 137 138 typedef md_ren_void_svc_t md_ren_roleswap_svc_t; 139 140 struct md_rendelta { 141 u_longlong_t beginning; 142 md_rendelta_t *next, *prev; 143 md_dev64_t dev; 144 md_renrole_t old_role, new_role; 145 md_unit_t *unp; 146 mdi_unit_t *uip; 147 148 md_ren_svc_t *lock; 149 md_ren_void_svc_t *unlock; 150 md_ren_svc_t *check; 151 md_ren_roleswap_svc_t *role_swap; 152 153 md_rendstat_t txn_stat; 154 u_longlong_t end; 155 }; 156 157 /* Externals from md_rename.c */ 158 extern int md_rename(md_rename_t *, IOLOCK *); 159 extern md_rendelta_t *md_build_rendelta(md_renrole_t, md_renrole_t, 160 md_dev64_t, md_rendelta_t *, md_unit_t *, mdi_unit_t *, md_error_t *); 161 extern void md_store_recid(int *, mddb_recid_t *, md_unit_t *); 162 163 #endif /* _KERNEL */ 164 165 #ifdef __cplusplus 166 } 167 #endif 168 169 #endif /* _SYS_MD_RENAME_H */ 170