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