1*7836SJohn.Forte@Sun.COM /* 2*7836SJohn.Forte@Sun.COM * CDDL HEADER START 3*7836SJohn.Forte@Sun.COM * 4*7836SJohn.Forte@Sun.COM * The contents of this file are subject to the terms of the 5*7836SJohn.Forte@Sun.COM * Common Development and Distribution License (the "License"). 6*7836SJohn.Forte@Sun.COM * You may not use this file except in compliance with the License. 7*7836SJohn.Forte@Sun.COM * 8*7836SJohn.Forte@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*7836SJohn.Forte@Sun.COM * or http://www.opensolaris.org/os/licensing. 10*7836SJohn.Forte@Sun.COM * See the License for the specific language governing permissions 11*7836SJohn.Forte@Sun.COM * and limitations under the License. 12*7836SJohn.Forte@Sun.COM * 13*7836SJohn.Forte@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 14*7836SJohn.Forte@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*7836SJohn.Forte@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 16*7836SJohn.Forte@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 17*7836SJohn.Forte@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 18*7836SJohn.Forte@Sun.COM * 19*7836SJohn.Forte@Sun.COM * CDDL HEADER END 20*7836SJohn.Forte@Sun.COM */ 21*7836SJohn.Forte@Sun.COM /* 22*7836SJohn.Forte@Sun.COM * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23*7836SJohn.Forte@Sun.COM * Use is subject to license terms. 24*7836SJohn.Forte@Sun.COM */ 25*7836SJohn.Forte@Sun.COM 26*7836SJohn.Forte@Sun.COM #ifndef _DSW_DEV_H 27*7836SJohn.Forte@Sun.COM #define _DSW_DEV_H 28*7836SJohn.Forte@Sun.COM 29*7836SJohn.Forte@Sun.COM #ifdef __cplusplus 30*7836SJohn.Forte@Sun.COM extern "C" { 31*7836SJohn.Forte@Sun.COM #endif 32*7836SJohn.Forte@Sun.COM 33*7836SJohn.Forte@Sun.COM /* 34*7836SJohn.Forte@Sun.COM * Definitions for kstats 35*7836SJohn.Forte@Sun.COM */ 36*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_SIZE "size" 37*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_MTIME "latest modified time" 38*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_FLAGS "flags" 39*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_THROTTLE_UNIT "ii_throttle_unit" 40*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_THROTTLE_DELAY "ii_throttle_delay" 41*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_SHDCHKS "shdchks" 42*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_SHDCHKUSED "shdchkused" 43*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_SHDBITS "shdbits" 44*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_COPYBITS "copybits" 45*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_MSTA "mst-a" 46*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_MSTB "mst-b" 47*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_MSTC "mst-c" 48*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_MSTD "mst-d" 49*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_SETA "set-a" 50*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_SETB "set-b" 51*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_SETC "set-c" 52*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_SETD "set-d" 53*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_BMPA "bmp-a" 54*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_BMPB "bmp-b" 55*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_BMPC "bmp-c" 56*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_BMPD "bmp-d" 57*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_OVRA "ovr-a" 58*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_OVRB "ovr-b" 59*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_OVRC "ovr-c" 60*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_OVRD "ovr-d" 61*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_MSTIO "mst-io" 62*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_SHDIO "shd-io" 63*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_BMPIO "bmp-io" 64*7836SJohn.Forte@Sun.COM #define DSW_SKSTAT_OVRIO "ovr-io" 65*7836SJohn.Forte@Sun.COM 66*7836SJohn.Forte@Sun.COM /* 67*7836SJohn.Forte@Sun.COM * Bitmap macros 68*7836SJohn.Forte@Sun.COM */ 69*7836SJohn.Forte@Sun.COM 70*7836SJohn.Forte@Sun.COM #define DSW_BIT_CLR(bmap, bit) (bmap &= (char)~(1 << bit)) 71*7836SJohn.Forte@Sun.COM #define DSW_BIT_SET(bmap, bit) (bmap |= (char)(1 << bit)) 72*7836SJohn.Forte@Sun.COM #define DSW_BIT_ISSET(bmap, bit) ((bmap & (1 << bit)) != 0) 73*7836SJohn.Forte@Sun.COM 74*7836SJohn.Forte@Sun.COM #define DSW_CBLK_FBA 16 /* cache blocks in fba's */ 75*7836SJohn.Forte@Sun.COM #define DSW_SHD_BM_OFFSET DSW_CBLK_FBA /* offset to allow for header */ 76*7836SJohn.Forte@Sun.COM #define DSW_COPY_BM_OFFSET (DSW_SHD_BM_OFFSET + \ 77*7836SJohn.Forte@Sun.COM DSW_BM_FBA_LEN(ip->bi_size)) 78*7836SJohn.Forte@Sun.COM #define DSW_BM_FBA_LEN(mst_size) ((mst_size) / FBA_SIZE(DSW_SIZE*DSW_BITS) + \ 79*7836SJohn.Forte@Sun.COM DSW_CBLK_FBA) 80*7836SJohn.Forte@Sun.COM 81*7836SJohn.Forte@Sun.COM #define DSW_BM_SIZE_CHUNKS(ip) ((ip->bi_size + DSW_SIZE - 1) / DSW_SIZE) 82*7836SJohn.Forte@Sun.COM #define DSW_BM_SIZE_BYTES(ip) ((DSW_BM_SIZE_CHUNKS(ip) + DSW_BITS - 1) / \ 83*7836SJohn.Forte@Sun.COM DSW_BITS) 84*7836SJohn.Forte@Sun.COM 85*7836SJohn.Forte@Sun.COM #define DSW_CHK2FBA(chunk) (((nsc_off_t)(chunk)) * DSW_SIZE) 86*7836SJohn.Forte@Sun.COM 87*7836SJohn.Forte@Sun.COM #if defined(_KERNEL) || defined(_KMEMUSER) 88*7836SJohn.Forte@Sun.COM 89*7836SJohn.Forte@Sun.COM /* 90*7836SJohn.Forte@Sun.COM * Shadow types. 91*7836SJohn.Forte@Sun.COM */ 92*7836SJohn.Forte@Sun.COM 93*7836SJohn.Forte@Sun.COM #define DSW_GOLDEN_TYPE 0x1000 94*7836SJohn.Forte@Sun.COM #define DSW_QUICK_TYPE 0x2000 95*7836SJohn.Forte@Sun.COM 96*7836SJohn.Forte@Sun.COM /* 97*7836SJohn.Forte@Sun.COM * Miscellaneous defines 98*7836SJohn.Forte@Sun.COM */ 99*7836SJohn.Forte@Sun.COM 100*7836SJohn.Forte@Sun.COM #define II_INTERNAL 0x1 101*7836SJohn.Forte@Sun.COM #define II_EXTERNAL 0x2 102*7836SJohn.Forte@Sun.COM 103*7836SJohn.Forte@Sun.COM #define II_EXISTING 0x01 /* Internal dsw_ioctl()/dsw_config() flags */ 104*7836SJohn.Forte@Sun.COM #define II_IMPORT 0x02 105*7836SJohn.Forte@Sun.COM 106*7836SJohn.Forte@Sun.COM /* 107*7836SJohn.Forte@Sun.COM * defines for _ii_nsc_io and _ii_write, used by kstats 108*7836SJohn.Forte@Sun.COM */ 109*7836SJohn.Forte@Sun.COM 110*7836SJohn.Forte@Sun.COM #define KS_NA 0 111*7836SJohn.Forte@Sun.COM #define KS_MST 1 112*7836SJohn.Forte@Sun.COM #define KS_SHD 2 113*7836SJohn.Forte@Sun.COM #define KS_BMP 3 114*7836SJohn.Forte@Sun.COM #define KS_OVR 4 115*7836SJohn.Forte@Sun.COM 116*7836SJohn.Forte@Sun.COM /* 117*7836SJohn.Forte@Sun.COM * global kstats 118*7836SJohn.Forte@Sun.COM */ 119*7836SJohn.Forte@Sun.COM 120*7836SJohn.Forte@Sun.COM typedef struct _iigkstat_s { 121*7836SJohn.Forte@Sun.COM /* static */ 122*7836SJohn.Forte@Sun.COM kstat_named_t ii_debug; 123*7836SJohn.Forte@Sun.COM kstat_named_t ii_bitmap; 124*7836SJohn.Forte@Sun.COM kstat_named_t ii_throttle_unit; 125*7836SJohn.Forte@Sun.COM kstat_named_t ii_throttle_delay; 126*7836SJohn.Forte@Sun.COM kstat_named_t ii_copy_direct; 127*7836SJohn.Forte@Sun.COM 128*7836SJohn.Forte@Sun.COM /* dynamic */ 129*7836SJohn.Forte@Sun.COM kstat_named_t num_sets; 130*7836SJohn.Forte@Sun.COM kstat_named_t assoc_over; 131*7836SJohn.Forte@Sun.COM kstat_named_t spilled_over; 132*7836SJohn.Forte@Sun.COM } iigkstat_t; 133*7836SJohn.Forte@Sun.COM 134*7836SJohn.Forte@Sun.COM extern iigkstat_t iigkstat; 135*7836SJohn.Forte@Sun.COM 136*7836SJohn.Forte@Sun.COM /* 137*7836SJohn.Forte@Sun.COM * set-specific kstats 138*7836SJohn.Forte@Sun.COM */ 139*7836SJohn.Forte@Sun.COM typedef struct _ii_kstat_set_s { 140*7836SJohn.Forte@Sun.COM kstat_named_t size; /* from _ii_stat() */ 141*7836SJohn.Forte@Sun.COM kstat_named_t mtime; /* from _ii_stat() */ 142*7836SJohn.Forte@Sun.COM kstat_named_t flags; /* from _ii_stat() */ 143*7836SJohn.Forte@Sun.COM kstat_named_t unit; /* ii_throttle_unit */ 144*7836SJohn.Forte@Sun.COM kstat_named_t delay; /* ii_throttle_delay */ 145*7836SJohn.Forte@Sun.COM kstat_named_t shdchks; /* from _ii_stat() */ 146*7836SJohn.Forte@Sun.COM kstat_named_t shdchkused; /* from _ii_stat() */ 147*7836SJohn.Forte@Sun.COM kstat_named_t shdbits; /* # bits set shadow bitmap */ 148*7836SJohn.Forte@Sun.COM kstat_named_t copybits; /* # bits set copy bitmap */ 149*7836SJohn.Forte@Sun.COM kstat_named_t mst_a; /* name */ 150*7836SJohn.Forte@Sun.COM kstat_named_t mst_b; /* .. of */ 151*7836SJohn.Forte@Sun.COM kstat_named_t mst_c; /* .. master */ 152*7836SJohn.Forte@Sun.COM kstat_named_t mst_d; /* .. volume */ 153*7836SJohn.Forte@Sun.COM kstat_named_t set_a; /* name */ 154*7836SJohn.Forte@Sun.COM kstat_named_t set_b; /* .. of */ 155*7836SJohn.Forte@Sun.COM kstat_named_t set_c; /* .. the */ 156*7836SJohn.Forte@Sun.COM kstat_named_t set_d; /* .. set */ 157*7836SJohn.Forte@Sun.COM kstat_named_t bmp_a; /* name */ 158*7836SJohn.Forte@Sun.COM kstat_named_t bmp_b; /* .. of */ 159*7836SJohn.Forte@Sun.COM kstat_named_t bmp_c; /* .. bitmap */ 160*7836SJohn.Forte@Sun.COM kstat_named_t bmp_d; /* .. volume */ 161*7836SJohn.Forte@Sun.COM kstat_named_t ovr_a; /* name */ 162*7836SJohn.Forte@Sun.COM kstat_named_t ovr_b; /* .. of */ 163*7836SJohn.Forte@Sun.COM kstat_named_t ovr_c; /* .. overflow */ 164*7836SJohn.Forte@Sun.COM kstat_named_t ovr_d; /* .. volume */ 165*7836SJohn.Forte@Sun.COM kstat_named_t mst_io; /* kstat_io of master */ 166*7836SJohn.Forte@Sun.COM kstat_named_t shd_io; /* kstat_io of shadow */ 167*7836SJohn.Forte@Sun.COM kstat_named_t bmp_io; /* kstat_io of bitmap */ 168*7836SJohn.Forte@Sun.COM kstat_named_t ovr_io; /* kstat_io of overflow */ 169*7836SJohn.Forte@Sun.COM } ii_kstat_set_t; 170*7836SJohn.Forte@Sun.COM 171*7836SJohn.Forte@Sun.COM extern ii_kstat_set_t ii_kstat_set; 172*7836SJohn.Forte@Sun.COM #define IOSTAT_NAME_LEN 10 173*7836SJohn.Forte@Sun.COM 174*7836SJohn.Forte@Sun.COM /* Basic types */ 175*7836SJohn.Forte@Sun.COM #ifdef II_MULTIMULTI_TERABYTE 176*7836SJohn.Forte@Sun.COM typedef int64_t chunkid_t; 177*7836SJohn.Forte@Sun.COM typedef int32_t chunkid32_t; 178*7836SJohn.Forte@Sun.COM #else 179*7836SJohn.Forte@Sun.COM typedef int32_t chunkid_t; 180*7836SJohn.Forte@Sun.COM #endif 181*7836SJohn.Forte@Sun.COM 182*7836SJohn.Forte@Sun.COM /* 183*7836SJohn.Forte@Sun.COM * OV_HEADER_VERSION 184*7836SJohn.Forte@Sun.COM * 0 = original OV header version 185*7836SJohn.Forte@Sun.COM * 1 = flags support 186*7836SJohn.Forte@Sun.COM */ 187*7836SJohn.Forte@Sun.COM #define OV_HEADER_VERSION 1 188*7836SJohn.Forte@Sun.COM 189*7836SJohn.Forte@Sun.COM /* Overflow disk volume header */ 190*7836SJohn.Forte@Sun.COM typedef struct _ii_doverflow_s { 191*7836SJohn.Forte@Sun.COM char ii_dvolname[DSW_NAMELEN]; /* this volumes name */ 192*7836SJohn.Forte@Sun.COM uint32_t ii_dhmagic; /* sanity check */ 193*7836SJohn.Forte@Sun.COM uint32_t ii_dhversion; /* volume format */ 194*7836SJohn.Forte@Sun.COM int32_t ii_ddrefcnt; /* total number of users */ 195*7836SJohn.Forte@Sun.COM int32_t ii_dflags; /* status flags */ 196*7836SJohn.Forte@Sun.COM int64_t ii_dfreehead; /* chain of freed chunks */ 197*7836SJohn.Forte@Sun.COM int64_t ii_dnchunks; /* total number of chunks */ 198*7836SJohn.Forte@Sun.COM int64_t ii_dunused; /* number of chunks available */ 199*7836SJohn.Forte@Sun.COM int64_t ii_dused; /* number of chunks allocated */ 200*7836SJohn.Forte@Sun.COM int32_t ii_urefcnt; /* # shadows needing update */ 201*7836SJohn.Forte@Sun.COM int32_t ii_dcrefcnt; /* current number of users */ 202*7836SJohn.Forte@Sun.COM } _ii_doverflow_t; 203*7836SJohn.Forte@Sun.COM 204*7836SJohn.Forte@Sun.COM /* Overflow volume in core structure */ 205*7836SJohn.Forte@Sun.COM typedef struct _ii_overflow_s { 206*7836SJohn.Forte@Sun.COM _ii_doverflow_t ii_do; 207*7836SJohn.Forte@Sun.COM kmutex_t ii_mutex; /* Mutex */ 208*7836SJohn.Forte@Sun.COM kmutex_t ii_kstat_mutex; /* Mutex for overflow kstat */ 209*7836SJohn.Forte@Sun.COM int ii_detachcnt; /* users detaching on disable */ 210*7836SJohn.Forte@Sun.COM struct _ii_overflow_s *ii_next; /* chain of incore structs */ 211*7836SJohn.Forte@Sun.COM struct _ii_info_dev_s *ii_dev; /* pointer to device details */ 212*7836SJohn.Forte@Sun.COM kstat_t *ii_overflow; /* kstats data for this vol */ 213*7836SJohn.Forte@Sun.COM char ii_ioname[KSTAT_DATA_CHAR_LEN]; /* name for iostat -x */ 214*7836SJohn.Forte@Sun.COM } _ii_overflow_t; 215*7836SJohn.Forte@Sun.COM 216*7836SJohn.Forte@Sun.COM #define ii_volname ii_do.ii_dvolname 217*7836SJohn.Forte@Sun.COM #define ii_hmagic ii_do.ii_dhmagic 218*7836SJohn.Forte@Sun.COM #define ii_drefcnt ii_do.ii_ddrefcnt 219*7836SJohn.Forte@Sun.COM #define ii_freehead ii_do.ii_dfreehead 220*7836SJohn.Forte@Sun.COM #define ii_nchunks ii_do.ii_dnchunks 221*7836SJohn.Forte@Sun.COM #define ii_unused ii_do.ii_dunused 222*7836SJohn.Forte@Sun.COM #define ii_used ii_do.ii_dused 223*7836SJohn.Forte@Sun.COM #define ii_hversion ii_do.ii_dhversion 224*7836SJohn.Forte@Sun.COM #define ii_flags ii_do.ii_dflags 225*7836SJohn.Forte@Sun.COM #define ii_urefcnt ii_do.ii_urefcnt 226*7836SJohn.Forte@Sun.COM #define ii_crefcnt ii_do.ii_dcrefcnt 227*7836SJohn.Forte@Sun.COM 228*7836SJohn.Forte@Sun.COM #define II_OHEADER_FBA 0 /* overflow header location */ 229*7836SJohn.Forte@Sun.COM /* 230*7836SJohn.Forte@Sun.COM * logging of kstat_io 231*7836SJohn.Forte@Sun.COM */ 232*7836SJohn.Forte@Sun.COM #ifdef DISABLE_KSTATS 233*7836SJohn.Forte@Sun.COM #define II_READ_START(ip, type) 234*7836SJohn.Forte@Sun.COM #define II_READ_END(ip, type, rc, blocks) 235*7836SJohn.Forte@Sun.COM #define II_WRITE_START(ip, type) 236*7836SJohn.Forte@Sun.COM #define II_WRITE_END(ip, type, rc, blocks) 237*7836SJohn.Forte@Sun.COM #else 238*7836SJohn.Forte@Sun.COM 239*7836SJohn.Forte@Sun.COM #define II_KS(ip, x) KSTAT_IO_PTR(ip->bi_kstat_io.x) 240*7836SJohn.Forte@Sun.COM #define II_MUTEX(ip, x) ip->bi_kstat_io.x->ks_lock 241*7836SJohn.Forte@Sun.COM #define II_BLKSIZE 512 242*7836SJohn.Forte@Sun.COM 243*7836SJohn.Forte@Sun.COM #define II_READ_START(ip, type) \ 244*7836SJohn.Forte@Sun.COM if (ip->bi_kstat_io.type) { \ 245*7836SJohn.Forte@Sun.COM mutex_enter(II_MUTEX(ip, type)); \ 246*7836SJohn.Forte@Sun.COM kstat_runq_enter(II_KS(ip, type)); \ 247*7836SJohn.Forte@Sun.COM mutex_exit(II_MUTEX(ip, type)); \ 248*7836SJohn.Forte@Sun.COM } 249*7836SJohn.Forte@Sun.COM #define II_READ_END(ip, type, rc, blocks) \ 250*7836SJohn.Forte@Sun.COM if (ip->bi_kstat_io.type) { \ 251*7836SJohn.Forte@Sun.COM mutex_enter(II_MUTEX(ip, type)); \ 252*7836SJohn.Forte@Sun.COM if (II_SUCCESS(rc)) { \ 253*7836SJohn.Forte@Sun.COM II_KS(ip, type)->reads++; \ 254*7836SJohn.Forte@Sun.COM II_KS(ip, type)->nread += II_BLKSIZE * (blocks);\ 255*7836SJohn.Forte@Sun.COM } \ 256*7836SJohn.Forte@Sun.COM kstat_runq_exit(II_KS(ip, type)); \ 257*7836SJohn.Forte@Sun.COM mutex_exit(II_MUTEX(ip, type)); \ 258*7836SJohn.Forte@Sun.COM } 259*7836SJohn.Forte@Sun.COM 260*7836SJohn.Forte@Sun.COM #define II_WRITE_START(ip, type) \ 261*7836SJohn.Forte@Sun.COM if (ip->bi_kstat_io.type) { \ 262*7836SJohn.Forte@Sun.COM mutex_enter(II_MUTEX(ip, type)); \ 263*7836SJohn.Forte@Sun.COM kstat_runq_enter(II_KS(ip, type)); \ 264*7836SJohn.Forte@Sun.COM mutex_exit(II_MUTEX(ip, type)); \ 265*7836SJohn.Forte@Sun.COM } 266*7836SJohn.Forte@Sun.COM #define II_WRITE_END(ip, type, rc, blocks) \ 267*7836SJohn.Forte@Sun.COM if (ip->bi_kstat_io.type) { \ 268*7836SJohn.Forte@Sun.COM mutex_enter(II_MUTEX(ip, type)); \ 269*7836SJohn.Forte@Sun.COM if (II_SUCCESS(rc)) { \ 270*7836SJohn.Forte@Sun.COM II_KS(ip, type)->writes++; \ 271*7836SJohn.Forte@Sun.COM II_KS(ip, type)->nwritten += II_BLKSIZE * (blocks);\ 272*7836SJohn.Forte@Sun.COM } \ 273*7836SJohn.Forte@Sun.COM kstat_runq_exit(II_KS(ip, type)); \ 274*7836SJohn.Forte@Sun.COM mutex_exit(II_MUTEX(ip, type)); \ 275*7836SJohn.Forte@Sun.COM } 276*7836SJohn.Forte@Sun.COM #endif 277*7836SJohn.Forte@Sun.COM 278*7836SJohn.Forte@Sun.COM #define II_NSC_READ(ip, type, rc, buf, pos, len, flag) \ 279*7836SJohn.Forte@Sun.COM II_READ_START(ip, type); \ 280*7836SJohn.Forte@Sun.COM rc = nsc_read(buf, pos, len, flag); \ 281*7836SJohn.Forte@Sun.COM II_READ_END(ip, type, rc, len); 282*7836SJohn.Forte@Sun.COM 283*7836SJohn.Forte@Sun.COM #define II_NSC_WRITE(ip, type, rc, buf, pos, len, flag) \ 284*7836SJohn.Forte@Sun.COM II_WRITE_START(ip, type); \ 285*7836SJohn.Forte@Sun.COM rc = nsc_write(buf, pos, len, flag); \ 286*7836SJohn.Forte@Sun.COM II_WRITE_END(ip, type, rc, len); 287*7836SJohn.Forte@Sun.COM 288*7836SJohn.Forte@Sun.COM #define II_NSC_COPY_DIRECT(ip, t1, t2, rc, buf1, buf2, pos1, pos2, len) \ 289*7836SJohn.Forte@Sun.COM II_WRITE_START(ip, t2); \ 290*7836SJohn.Forte@Sun.COM rc = nsc_copy_direct(buf1, buf2, pos1, pos2, len); \ 291*7836SJohn.Forte@Sun.COM II_WRITE_END(ip, t2, rc, len); 292*7836SJohn.Forte@Sun.COM 293*7836SJohn.Forte@Sun.COM #define II_ALLOC_BUF(ip, type, rc, fd, pos, len, flag, tmp) \ 294*7836SJohn.Forte@Sun.COM if (flag & NSC_READ) { \ 295*7836SJohn.Forte@Sun.COM II_READ_START(ip, type); \ 296*7836SJohn.Forte@Sun.COM } \ 297*7836SJohn.Forte@Sun.COM rc = nsc_alloc_buf(fd, pos, len, flag, tmp); \ 298*7836SJohn.Forte@Sun.COM if (flag & NSC_READ) { \ 299*7836SJohn.Forte@Sun.COM II_READ_END(ip, type, rc, len); \ 300*7836SJohn.Forte@Sun.COM } 301*7836SJohn.Forte@Sun.COM 302*7836SJohn.Forte@Sun.COM /* 303*7836SJohn.Forte@Sun.COM * All kstat_io associated with a set. NOTE: only one mutex for all 304*7836SJohn.Forte@Sun.COM * of the kstats for a given set; all master/shadow/bmp/overflow mutexes 305*7836SJohn.Forte@Sun.COM * point back to the statmutex 306*7836SJohn.Forte@Sun.COM */ 307*7836SJohn.Forte@Sun.COM 308*7836SJohn.Forte@Sun.COM typedef struct _ii_kstat_info_s { 309*7836SJohn.Forte@Sun.COM kstat_t *master; 310*7836SJohn.Forte@Sun.COM kstat_t *shadow; 311*7836SJohn.Forte@Sun.COM kstat_t *bitmap; 312*7836SJohn.Forte@Sun.COM kstat_t *overflow; 313*7836SJohn.Forte@Sun.COM kmutex_t statmutex; 314*7836SJohn.Forte@Sun.COM char mstio[KSTAT_DATA_CHAR_LEN]; /* name of mst in iostat -x */ 315*7836SJohn.Forte@Sun.COM char shdio[KSTAT_DATA_CHAR_LEN]; /* name of shd in iostat -x */ 316*7836SJohn.Forte@Sun.COM char bmpio[KSTAT_DATA_CHAR_LEN]; /* name of bmp in iostat -x */ 317*7836SJohn.Forte@Sun.COM char ovrio[KSTAT_DATA_CHAR_LEN]; /* name of ovr in iostat -x */ 318*7836SJohn.Forte@Sun.COM } ii_kstat_info_t; 319*7836SJohn.Forte@Sun.COM 320*7836SJohn.Forte@Sun.COM /* 321*7836SJohn.Forte@Sun.COM * II device info structure 322*7836SJohn.Forte@Sun.COM */ 323*7836SJohn.Forte@Sun.COM 324*7836SJohn.Forte@Sun.COM typedef struct _ii_info_dev_s { 325*7836SJohn.Forte@Sun.COM nsc_fd_t *bi_fd; /* Bitmap file descriptor */ 326*7836SJohn.Forte@Sun.COM nsc_iodev_t *bi_iodev; /* I/O device structure */ 327*7836SJohn.Forte@Sun.COM nsc_path_t *bi_tok; /* Register path token */ 328*7836SJohn.Forte@Sun.COM int bi_ref; /* Count of fd's referencing */ 329*7836SJohn.Forte@Sun.COM int bi_rsrv; /* Count of reserves held */ 330*7836SJohn.Forte@Sun.COM int bi_orsrv; /* Reserves for other io prov */ 331*7836SJohn.Forte@Sun.COM int bi_flag; /* Internal/External reserve */ 332*7836SJohn.Forte@Sun.COM } _ii_info_dev_t; 333*7836SJohn.Forte@Sun.COM 334*7836SJohn.Forte@Sun.COM typedef struct _ii_info_s { 335*7836SJohn.Forte@Sun.COM struct _ii_info_s *bi_next; /* Chain of all groups */ 336*7836SJohn.Forte@Sun.COM struct _ii_info_s *bi_head; /* head of sibling chain */ 337*7836SJohn.Forte@Sun.COM struct _ii_info_s *bi_sibling; /* Chain of groups with same */ 338*7836SJohn.Forte@Sun.COM /* master */ 339*7836SJohn.Forte@Sun.COM struct _ii_info_s *bi_master; /* location of master */ 340*7836SJohn.Forte@Sun.COM struct _ii_info_s *bi_nextmst; /* next multimaster */ 341*7836SJohn.Forte@Sun.COM kmutex_t bi_mutex; /* Mutex */ 342*7836SJohn.Forte@Sun.COM _ii_info_dev_t *bi_mstdev; 343*7836SJohn.Forte@Sun.COM _ii_info_dev_t *bi_mstrdev; 344*7836SJohn.Forte@Sun.COM _ii_info_dev_t bi_shddev; 345*7836SJohn.Forte@Sun.COM _ii_info_dev_t bi_shdrdev; 346*7836SJohn.Forte@Sun.COM _ii_info_dev_t bi_bmpdev; 347*7836SJohn.Forte@Sun.COM char bi_keyname[DSW_NAMELEN]; 348*7836SJohn.Forte@Sun.COM unsigned char *bi_bitmap; /* Master device bitmap */ 349*7836SJohn.Forte@Sun.COM char *bi_cluster; /* cluster name */ 350*7836SJohn.Forte@Sun.COM char *bi_group; /* group name */ 351*7836SJohn.Forte@Sun.COM char *bi_busy; /* Busy bitmap */ 352*7836SJohn.Forte@Sun.COM nsc_off_t bi_shdfba; /* location of shadow bitmap */ 353*7836SJohn.Forte@Sun.COM nsc_size_t bi_shdbits; /* shadow bitmap counter */ 354*7836SJohn.Forte@Sun.COM nsc_off_t bi_copyfba; /* location of copy bitmap */ 355*7836SJohn.Forte@Sun.COM nsc_size_t bi_copybits; /* copy bitmap counter */ 356*7836SJohn.Forte@Sun.COM nsc_size_t bi_size; /* Size of mst device */ 357*7836SJohn.Forte@Sun.COM uint_t bi_flags; /* Flags */ 358*7836SJohn.Forte@Sun.COM uint_t bi_state; /* State flags */ 359*7836SJohn.Forte@Sun.COM int bi_disabled; /* Disable has started */ 360*7836SJohn.Forte@Sun.COM int bi_ioctl; /* Number of active ioctls */ 361*7836SJohn.Forte@Sun.COM int bi_release; /* Do a release in copyvol */ 362*7836SJohn.Forte@Sun.COM int bi_rsrvcnt; /* reserve count */ 363*7836SJohn.Forte@Sun.COM kcondvar_t bi_copydonecv; /* Copy operation condvar */ 364*7836SJohn.Forte@Sun.COM kcondvar_t bi_reservecv; /* Reserve condvar */ 365*7836SJohn.Forte@Sun.COM kcondvar_t bi_releasecv; /* Release condvar */ 366*7836SJohn.Forte@Sun.COM kcondvar_t bi_closingcv; /* Shadow closing condvar */ 367*7836SJohn.Forte@Sun.COM kcondvar_t bi_ioctlcv; /* Ioctls complete condvar */ 368*7836SJohn.Forte@Sun.COM kcondvar_t bi_busycv; /* Busy bitmap condvar */ 369*7836SJohn.Forte@Sun.COM krwlock_t bi_busyrw; /* Busy bitmap rwlock */ 370*7836SJohn.Forte@Sun.COM struct _ii_bmp_ops_s *bi_bitmap_ops; /* Functions for bitmap ops */ 371*7836SJohn.Forte@Sun.COM kmutex_t bi_rsrvmutex; /* Reserve operation mutex */ 372*7836SJohn.Forte@Sun.COM kmutex_t bi_rlsemutex; /* Release operation mutex */ 373*7836SJohn.Forte@Sun.COM kmutex_t bi_bmpmutex; /* mutex for bi_bitmap_ops */ 374*7836SJohn.Forte@Sun.COM chunkid_t bi_mstchks; 375*7836SJohn.Forte@Sun.COM chunkid_t bi_shdchks; /* # of chunks on shadow vol */ 376*7836SJohn.Forte@Sun.COM chunkid_t bi_shdchkused; /* # of allocated */ 377*7836SJohn.Forte@Sun.COM chunkid_t bi_shdfchk; /* start of shd chunk flst */ 378*7836SJohn.Forte@Sun.COM _ii_overflow_t *bi_overflow; 379*7836SJohn.Forte@Sun.COM struct ii_fd_s *bi_iifd; /* fd holding master's ip */ 380*7836SJohn.Forte@Sun.COM int32_t bi_throttle_unit; 381*7836SJohn.Forte@Sun.COM int32_t bi_throttle_delay; 382*7836SJohn.Forte@Sun.COM krwlock_t bi_linkrw; /* altering linkage rwlock */ 383*7836SJohn.Forte@Sun.COM kmutex_t bi_chksmutex; /* Mutex for bi_???chks */ 384*7836SJohn.Forte@Sun.COM pid_t bi_locked_pid; /* lock pid for update/copy */ 385*7836SJohn.Forte@Sun.COM kstat_t *bi_kstat; /* kstat data for set */ 386*7836SJohn.Forte@Sun.COM ii_kstat_info_t bi_kstat_io; /* kstat I/O data for set */ 387*7836SJohn.Forte@Sun.COM time_t bi_mtime; 388*7836SJohn.Forte@Sun.COM } _ii_info_t; 389*7836SJohn.Forte@Sun.COM 390*7836SJohn.Forte@Sun.COM #define bi_bmpfd bi_bmpdev.bi_fd 391*7836SJohn.Forte@Sun.COM #define bi_mstfd bi_mstdev->bi_fd 392*7836SJohn.Forte@Sun.COM #define bi_mstrfd bi_mstrdev->bi_fd 393*7836SJohn.Forte@Sun.COM #define bi_shdfd bi_shddev.bi_fd 394*7836SJohn.Forte@Sun.COM #define bi_shdrfd bi_shdrdev.bi_fd 395*7836SJohn.Forte@Sun.COM #define bi_mst_iodev bi_mstdev->bi_iodev 396*7836SJohn.Forte@Sun.COM #define bi_mstr_iodev bi_mstrdev->bi_iodev 397*7836SJohn.Forte@Sun.COM #define bi_shd_iodev bi_shddev.bi_iodev 398*7836SJohn.Forte@Sun.COM #define bi_shdr_iodev bi_shdrdev.bi_iodev 399*7836SJohn.Forte@Sun.COM #define bi_bmp_iodev bi_bmpdev.bi_iodev 400*7836SJohn.Forte@Sun.COM #define bi_mst_tok bi_mstdev->bi_tok 401*7836SJohn.Forte@Sun.COM #define bi_mstr_tok bi_mstrdev->bi_tok 402*7836SJohn.Forte@Sun.COM #define bi_shd_tok bi_shddev.bi_tok 403*7836SJohn.Forte@Sun.COM #define bi_shdr_tok bi_shdrdev.bi_tok 404*7836SJohn.Forte@Sun.COM #define bi_bmp_tok bi_bmpdev.bi_tok 405*7836SJohn.Forte@Sun.COM #define bi_mstref bi_mstdev->bi_ref 406*7836SJohn.Forte@Sun.COM #define bi_mstrref bi_mstrdev->bi_ref 407*7836SJohn.Forte@Sun.COM #define bi_shdref bi_shddev.bi_ref 408*7836SJohn.Forte@Sun.COM #define bi_shdrref bi_shdrdev.bi_ref 409*7836SJohn.Forte@Sun.COM #define bi_bmpref bi_bmpdev.bi_ref 410*7836SJohn.Forte@Sun.COM #define bi_mstrsrv bi_mstdev->bi_rsrv 411*7836SJohn.Forte@Sun.COM #define bi_mstrrsrv bi_mstrdev->bi_rsrv 412*7836SJohn.Forte@Sun.COM #define bi_shdrsrv bi_shddev.bi_rsrv 413*7836SJohn.Forte@Sun.COM #define bi_shdrrsrv bi_shdrdev.bi_rsrv 414*7836SJohn.Forte@Sun.COM #define bi_bmprsrv bi_bmpdev.bi_rsrv 415*7836SJohn.Forte@Sun.COM #define bi_mstrflag bi_mstrdev->bi_flag 416*7836SJohn.Forte@Sun.COM #define bi_shdrflag bi_shdrdev.bi_flag 417*7836SJohn.Forte@Sun.COM /* 418*7836SJohn.Forte@Sun.COM * Cluster and group linked lists 419*7836SJohn.Forte@Sun.COM */ 420*7836SJohn.Forte@Sun.COM typedef struct _ii_lstinfo_s { 421*7836SJohn.Forte@Sun.COM _ii_info_t *lst_ip; /* ptr to info_t */ 422*7836SJohn.Forte@Sun.COM struct _ii_lstinfo_s *lst_next; /* ptr to next in chain */ 423*7836SJohn.Forte@Sun.COM } _ii_lstinfo_t; 424*7836SJohn.Forte@Sun.COM 425*7836SJohn.Forte@Sun.COM typedef struct _ii_lsthead_s { 426*7836SJohn.Forte@Sun.COM uint64_t lst_hash; /* from nsc_strhash */ 427*7836SJohn.Forte@Sun.COM char lst_name[DSW_NAMELEN]; /* resource group */ 428*7836SJohn.Forte@Sun.COM _ii_lstinfo_t *lst_start; /* start of set list */ 429*7836SJohn.Forte@Sun.COM struct _ii_lsthead_s *lst_next; /* next list head */ 430*7836SJohn.Forte@Sun.COM } _ii_lsthead_t; 431*7836SJohn.Forte@Sun.COM 432*7836SJohn.Forte@Sun.COM /* 433*7836SJohn.Forte@Sun.COM * Flag set and clear macros and function. 434*7836SJohn.Forte@Sun.COM */ 435*7836SJohn.Forte@Sun.COM 436*7836SJohn.Forte@Sun.COM void _ii_flag_op(int and, int or, _ii_info_t *ip, int update); 437*7836SJohn.Forte@Sun.COM 438*7836SJohn.Forte@Sun.COM #define II_FLAG_SET(f, ip) _ii_flag_op(~0, (f), ip, TRUE) 439*7836SJohn.Forte@Sun.COM #define II_FLAG_CLR(f, ip) _ii_flag_op(~(f), 0, ip, TRUE) 440*7836SJohn.Forte@Sun.COM 441*7836SJohn.Forte@Sun.COM #define II_FLAG_SETX(f, ip) _ii_flag_op(~0, (f), ip, FALSE) 442*7836SJohn.Forte@Sun.COM #define II_FLAG_CLRX(f, ip) _ii_flag_op(~(f), 0, ip, FALSE) 443*7836SJohn.Forte@Sun.COM #define II_FLAG_ASSIGN(f, ip) _ii_flag_op(0, (f), ip, FALSE); 444*7836SJohn.Forte@Sun.COM #define LOG_EVENT(msg, level) \ 445*7836SJohn.Forte@Sun.COM nsc_do_sysevent("ii", msg, level, level, component, ii_dip); 446*7836SJohn.Forte@Sun.COM 447*7836SJohn.Forte@Sun.COM /* Reserve and release macros */ 448*7836SJohn.Forte@Sun.COM 449*7836SJohn.Forte@Sun.COM /* also used by ii_volume() volume identification, hence NONE & OVR */ 450*7836SJohn.Forte@Sun.COM #define NONE 0x0000 /* no volume type */ 451*7836SJohn.Forte@Sun.COM #define MST 0x0001 /* master reserve/release flag */ 452*7836SJohn.Forte@Sun.COM #define MSTR 0x0010 /* raw master reserve/release flag */ 453*7836SJohn.Forte@Sun.COM #define SHD 0x0002 /* shadow reserve/release flag */ 454*7836SJohn.Forte@Sun.COM #define SHDR 0x0020 /* raw shadow reserve/release flag */ 455*7836SJohn.Forte@Sun.COM #define BMP 0x0100 /* bitmap reserve/release flag */ 456*7836SJohn.Forte@Sun.COM #define OVR 0x0400 /* overflow volume */ 457*7836SJohn.Forte@Sun.COM 458*7836SJohn.Forte@Sun.COM #define RSRV(ip) ((ip)->bi_rsrv > 0 || (ip)->bi_orsrv > 0) 459*7836SJohn.Forte@Sun.COM 460*7836SJohn.Forte@Sun.COM #define MSTRSRV(ip) (RSRV(((ip)->bi_mstdev))) 461*7836SJohn.Forte@Sun.COM #define SHDRSRV(ip) (RSRV(&((ip)->bi_shddev))) 462*7836SJohn.Forte@Sun.COM 463*7836SJohn.Forte@Sun.COM #define MSTFD(ip) (MSTRSRV(ip) ? (ip)->bi_mstfd : (ip)->bi_mstrfd) 464*7836SJohn.Forte@Sun.COM #define SHDFD(ip) (SHDRSRV(ip) ? (ip)->bi_shdfd : (ip)->bi_shdrfd) 465*7836SJohn.Forte@Sun.COM #define OVRFD(ip) (ip->bi_overflow->ii_dev->bi_fd) 466*7836SJohn.Forte@Sun.COM 467*7836SJohn.Forte@Sun.COM #define II_RAW(ii) (((ii)->ii_oflags&NSC_DEVICE) != 0) 468*7836SJohn.Forte@Sun.COM #define II_FD(ii) ((ii)->ii_shd ? SHDFD((ii)->ii_info) : \ 469*7836SJohn.Forte@Sun.COM MSTFD((ii)->ii_info)) 470*7836SJohn.Forte@Sun.COM 471*7836SJohn.Forte@Sun.COM /* are there multiple shadows of ip's master volume? */ 472*7836SJohn.Forte@Sun.COM #define NSHADOWS(ip) ((ip)->bi_head != (ip) || (ip)->bi_sibling) 473*7836SJohn.Forte@Sun.COM 474*7836SJohn.Forte@Sun.COM typedef struct _ii_bmp_ops_s { 475*7836SJohn.Forte@Sun.COM int (*co_bmp)(_ii_info_t *, nsc_off_t, unsigned char *, int); 476*7836SJohn.Forte@Sun.COM int (*ci_bmp)(_ii_info_t *, nsc_off_t, unsigned char *, int); 477*7836SJohn.Forte@Sun.COM int (*zerobm)(_ii_info_t *); 478*7836SJohn.Forte@Sun.COM int (*copybm)(_ii_info_t *); 479*7836SJohn.Forte@Sun.COM int (*orbm)(_ii_info_t *); 480*7836SJohn.Forte@Sun.COM int (*tst_shd_bit)(_ii_info_t *, chunkid_t); 481*7836SJohn.Forte@Sun.COM int (*set_shd_bit)(_ii_info_t *, chunkid_t); 482*7836SJohn.Forte@Sun.COM int (*tst_copy_bit)(_ii_info_t *, chunkid_t); 483*7836SJohn.Forte@Sun.COM int (*set_copy_bit)(_ii_info_t *, chunkid_t); 484*7836SJohn.Forte@Sun.COM int (*clr_copy_bits)(_ii_info_t *, chunkid_t, int); 485*7836SJohn.Forte@Sun.COM chunkid_t (*next_copy_bit)(_ii_info_t *, chunkid_t, chunkid_t, 486*7836SJohn.Forte@Sun.COM int, int *); 487*7836SJohn.Forte@Sun.COM int (*fill_copy_bmp)(_ii_info_t *); 488*7836SJohn.Forte@Sun.COM int (*load_bmp)(_ii_info_t *, int); 489*7836SJohn.Forte@Sun.COM int (*save_bmp)(_ii_info_t *, int); 490*7836SJohn.Forte@Sun.COM int (*change_bmp)(_ii_info_t *, unsigned char *); 491*7836SJohn.Forte@Sun.COM int (*cnt_bits)(_ii_info_t *, nsc_off_t, nsc_size_t *, int); 492*7836SJohn.Forte@Sun.COM int (*join_bmp)(_ii_info_t *, _ii_info_t *); 493*7836SJohn.Forte@Sun.COM } _ii_bmp_ops_t; 494*7836SJohn.Forte@Sun.COM 495*7836SJohn.Forte@Sun.COM #define II_CO_BMP(ip, a, b, c) (*(ip)->bi_bitmap_ops->co_bmp)(ip, a, b, c) 496*7836SJohn.Forte@Sun.COM #define II_CI_BMP(ip, a, b, c) (*(ip)->bi_bitmap_ops->ci_bmp)(ip, a, b, c) 497*7836SJohn.Forte@Sun.COM #define II_ZEROBM(ip) (*(ip)->bi_bitmap_ops->zerobm)(ip) 498*7836SJohn.Forte@Sun.COM #define II_COPYBM(ip) (*(ip)->bi_bitmap_ops->copybm)(ip) 499*7836SJohn.Forte@Sun.COM #define II_ORBM(ip) (*(ip)->bi_bitmap_ops->orbm)(ip) 500*7836SJohn.Forte@Sun.COM #define II_TST_SHD_BIT(ip, c) (*(ip)->bi_bitmap_ops->tst_shd_bit)(ip, c) 501*7836SJohn.Forte@Sun.COM #define II_SET_SHD_BIT(ip, c) (*(ip)->bi_bitmap_ops->set_shd_bit)(ip, c) 502*7836SJohn.Forte@Sun.COM #define II_TST_COPY_BIT(ip, c) (*(ip)->bi_bitmap_ops->tst_copy_bit)(ip, c) 503*7836SJohn.Forte@Sun.COM #define II_SET_COPY_BIT(ip, c) (*(ip)->bi_bitmap_ops->set_copy_bit)(ip, c) 504*7836SJohn.Forte@Sun.COM #define II_CLR_COPY_BITS(ip, c, n) (*(ip)->bi_bitmap_ops->clr_copy_bits) \ 505*7836SJohn.Forte@Sun.COM (ip, c, n) 506*7836SJohn.Forte@Sun.COM #define II_CLR_COPY_BIT(ip, c) (*(ip)->bi_bitmap_ops->clr_copy_bits)(ip, c, 1) 507*7836SJohn.Forte@Sun.COM #define II_NEXT_COPY_BIT(ip, c, m, w, g) \ 508*7836SJohn.Forte@Sun.COM (*(ip)->bi_bitmap_ops->next_copy_bit)(ip, c, m, w, g) 509*7836SJohn.Forte@Sun.COM #define II_FILL_COPY_BMP(ip) (*(ip)->bi_bitmap_ops->fill_copy_bmp)(ip) 510*7836SJohn.Forte@Sun.COM #define II_LOAD_BMP(ip, f) (*(ip)->bi_bitmap_ops->load_bmp)(ip, f) 511*7836SJohn.Forte@Sun.COM #define II_SAVE_BMP(ip, f) (*(ip)->bi_bitmap_ops->save_bmp)(ip, f) 512*7836SJohn.Forte@Sun.COM #define II_CHANGE_BMP(ip, p) (*(ip)->bi_bitmap_ops->change_bmp)(ip, p) 513*7836SJohn.Forte@Sun.COM #define II_CNT_BITS(ip, a, b, c) (*(ip)->bi_bitmap_ops->cnt_bits)(ip, a, b, c) 514*7836SJohn.Forte@Sun.COM #define II_JOIN_BMP(dip, sip) (*(ip)->bi_bitmap_ops->join_bmp)(dip, sip) 515*7836SJohn.Forte@Sun.COM 516*7836SJohn.Forte@Sun.COM /* 517*7836SJohn.Forte@Sun.COM * State flags 518*7836SJohn.Forte@Sun.COM */ 519*7836SJohn.Forte@Sun.COM #define DSW_IOCTL 0x0001 /* Waiting for ioctl to complete */ 520*7836SJohn.Forte@Sun.COM #define DSW_CLOSING 0x0002 /* Waiting for shadow to close */ 521*7836SJohn.Forte@Sun.COM #define DSW_MSTTARGET 0x0004 /* Master is target of update */ 522*7836SJohn.Forte@Sun.COM #define DSW_MULTIMST 0x0008 /* disabled set is multi master */ 523*7836SJohn.Forte@Sun.COM #define DSW_CNTSHDBITS 0x0010 /* need to count # of shd bits set */ 524*7836SJohn.Forte@Sun.COM #define DSW_CNTCPYBITS 0x0020 /* need to count # of copy bits set */ 525*7836SJohn.Forte@Sun.COM 526*7836SJohn.Forte@Sun.COM /* 527*7836SJohn.Forte@Sun.COM * DSW file descriptor structure 528*7836SJohn.Forte@Sun.COM */ 529*7836SJohn.Forte@Sun.COM 530*7836SJohn.Forte@Sun.COM typedef struct ii_fd_s { 531*7836SJohn.Forte@Sun.COM _ii_info_t *ii_info; /* Info structure */ 532*7836SJohn.Forte@Sun.COM int ii_bmp; /* This fd is for the bmp device */ 533*7836SJohn.Forte@Sun.COM int ii_shd; /* This fd is for the shadow device */ 534*7836SJohn.Forte@Sun.COM int ii_ovr; /* This fd is for the overflow device */ 535*7836SJohn.Forte@Sun.COM _ii_overflow_t *ii_optr; /* pointer to overflow structure */ 536*7836SJohn.Forte@Sun.COM int ii_oflags; /* raw or cached open type */ 537*7836SJohn.Forte@Sun.COM } ii_fd_t; 538*7836SJohn.Forte@Sun.COM 539*7836SJohn.Forte@Sun.COM 540*7836SJohn.Forte@Sun.COM /* 541*7836SJohn.Forte@Sun.COM * II buffer header 542*7836SJohn.Forte@Sun.COM */ 543*7836SJohn.Forte@Sun.COM 544*7836SJohn.Forte@Sun.COM typedef struct ii_buf_s { 545*7836SJohn.Forte@Sun.COM nsc_buf_t ii_bufh; /* exported buffer header */ 546*7836SJohn.Forte@Sun.COM nsc_buf_t *ii_bufp; /* main underlying buffer */ 547*7836SJohn.Forte@Sun.COM nsc_buf_t *ii_bufp2; /* second underlying buffer */ 548*7836SJohn.Forte@Sun.COM nsc_buf_t *ii_abufp; /* anonymous underlying buffer */ 549*7836SJohn.Forte@Sun.COM ii_fd_t *ii_fd; /* back link */ 550*7836SJohn.Forte@Sun.COM int ii_rsrv; /* fd to release in free_buf */ 551*7836SJohn.Forte@Sun.COM } ii_buf_t; 552*7836SJohn.Forte@Sun.COM #endif /* _KERNEL || _KMEMUSER */ 553*7836SJohn.Forte@Sun.COM 554*7836SJohn.Forte@Sun.COM 555*7836SJohn.Forte@Sun.COM /* 556*7836SJohn.Forte@Sun.COM * Valid magic numbers in the bitmap volume header 557*7836SJohn.Forte@Sun.COM */ 558*7836SJohn.Forte@Sun.COM 559*7836SJohn.Forte@Sun.COM #define DSW_DIRTY 0x44495254 560*7836SJohn.Forte@Sun.COM #define DSW_CLEAN 0x434C4541 561*7836SJohn.Forte@Sun.COM #define DSW_INVALID 0x00000000 562*7836SJohn.Forte@Sun.COM 563*7836SJohn.Forte@Sun.COM /* 564*7836SJohn.Forte@Sun.COM * II_HEADER_VERSION 565*7836SJohn.Forte@Sun.COM * 1 = original II header version 566*7836SJohn.Forte@Sun.COM * 2 = Compact Dependent Shadows (DSW_TREEMAP) 567*7836SJohn.Forte@Sun.COM * 3 = Persistance of throttle parameters 568*7836SJohn.Forte@Sun.COM * 4 = add cluster & group information 569*7836SJohn.Forte@Sun.COM * 5 = add time string to hold last modify time 570*7836SJohn.Forte@Sun.COM */ 571*7836SJohn.Forte@Sun.COM #define II_HEADER_VERSION 5 572*7836SJohn.Forte@Sun.COM 573*7836SJohn.Forte@Sun.COM /* 574*7836SJohn.Forte@Sun.COM * DSW bitmap volume header structure 575*7836SJohn.Forte@Sun.COM */ 576*7836SJohn.Forte@Sun.COM 577*7836SJohn.Forte@Sun.COM typedef struct ii_header_s { 578*7836SJohn.Forte@Sun.COM int32_t ii_magic; /* magic number */ 579*7836SJohn.Forte@Sun.COM int32_t ii_type; /* bitmap or independent copy */ 580*7836SJohn.Forte@Sun.COM int32_t ii_state; /* State of the master/shadow/bitmap tuple */ 581*7836SJohn.Forte@Sun.COM int32_t ii_version; /* version or format of bitmap volume */ 582*7836SJohn.Forte@Sun.COM int32_t ii_shdfba; /* location of shadow bitmap */ 583*7836SJohn.Forte@Sun.COM int32_t ii_copyfba; /* location of copy bitmap */ 584*7836SJohn.Forte@Sun.COM char master_vol[DSW_NAMELEN]; 585*7836SJohn.Forte@Sun.COM char shadow_vol[DSW_NAMELEN]; 586*7836SJohn.Forte@Sun.COM char bitmap_vol[DSW_NAMELEN]; 587*7836SJohn.Forte@Sun.COM /* II_HEADER_VERSION 2 */ 588*7836SJohn.Forte@Sun.COM char overflow_vol[DSW_NAMELEN]; 589*7836SJohn.Forte@Sun.COM int64_t ii_mstchks; /* # of chunks in master volume */ 590*7836SJohn.Forte@Sun.COM int64_t ii_shdchks; /* # of chunks in shadow volume */ 591*7836SJohn.Forte@Sun.COM int64_t ii_shdchkused; /* # of shd chunks allocated or on free list */ 592*7836SJohn.Forte@Sun.COM int64_t ii_shdfchk; /* list of free shadow chunks */ 593*7836SJohn.Forte@Sun.COM /* II_HEADER_VERSION 3 */ 594*7836SJohn.Forte@Sun.COM int32_t ii_throttle_unit; /* Last setting of throttle unit */ 595*7836SJohn.Forte@Sun.COM int32_t ii_throttle_delay; /* Last setting of throttle delay */ 596*7836SJohn.Forte@Sun.COM /* II_HEADER_VERSION 4 */ 597*7836SJohn.Forte@Sun.COM char clstr_name[DSW_NAMELEN]; 598*7836SJohn.Forte@Sun.COM char group_name[DSW_NAMELEN]; 599*7836SJohn.Forte@Sun.COM /* II_HEADER_VERSION 5 */ 600*7836SJohn.Forte@Sun.COM time_t ii_mtime; 601*7836SJohn.Forte@Sun.COM } ii_header_t; 602*7836SJohn.Forte@Sun.COM 603*7836SJohn.Forte@Sun.COM #define II_SUCCESS(rc) (((rc) == NSC_DONE) || ((rc) == NSC_HIT)) 604*7836SJohn.Forte@Sun.COM 605*7836SJohn.Forte@Sun.COM /* 606*7836SJohn.Forte@Sun.COM * Overflow volume defines. 607*7836SJohn.Forte@Sun.COM */ 608*7836SJohn.Forte@Sun.COM 609*7836SJohn.Forte@Sun.COM #define II_OMAGIC 0x476F6C64 /* "Gold" */ 610*7836SJohn.Forte@Sun.COM #define II_ISOVERFLOW(n) ((n) < 0 && (n) != II_NULLCHUNK) 611*7836SJohn.Forte@Sun.COM #define II_2OVERFLOW(n) (-(n)) 612*7836SJohn.Forte@Sun.COM /* -tive node id's are in overflow volume */ 613*7836SJohn.Forte@Sun.COM 614*7836SJohn.Forte@Sun.COM #ifdef _SunOS_5_6 615*7836SJohn.Forte@Sun.COM #define II_NULLNODE (INT_MIN) 616*7836SJohn.Forte@Sun.COM #define II_NULLCHUNK (INT_MIN) 617*7836SJohn.Forte@Sun.COM #else 618*7836SJohn.Forte@Sun.COM #ifdef II_MULTIMULTI_TERABYTE 619*7836SJohn.Forte@Sun.COM #define II_NULLNODE (INT64_MIN) 620*7836SJohn.Forte@Sun.COM #define II_NULLCHUNK (INT64_MIN) 621*7836SJohn.Forte@Sun.COM #define II_NULL32NODE (INT32_MIN) 622*7836SJohn.Forte@Sun.COM #define II_NULL32CHUNK (INT32_MIN) 623*7836SJohn.Forte@Sun.COM #else 624*7836SJohn.Forte@Sun.COM #define II_NULLNODE (INT32_MIN) 625*7836SJohn.Forte@Sun.COM #define II_NULLCHUNK (INT32_MIN) 626*7836SJohn.Forte@Sun.COM #endif /* II_MULTIMULTI_TERABYTE */ 627*7836SJohn.Forte@Sun.COM #endif 628*7836SJohn.Forte@Sun.COM 629*7836SJohn.Forte@Sun.COM #ifdef __cplusplus 630*7836SJohn.Forte@Sun.COM } 631*7836SJohn.Forte@Sun.COM #endif 632*7836SJohn.Forte@Sun.COM 633*7836SJohn.Forte@Sun.COM #endif /* _DSW_DEV_H */ 634