1*0Sstevel@tonic-gate /*- 2*0Sstevel@tonic-gate * See the file LICENSE for redistribution information. 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * Copyright (c) 1996, 1997, 1998 5*0Sstevel@tonic-gate * Sleepycat Software. All rights reserved. 6*0Sstevel@tonic-gate * 7*0Sstevel@tonic-gate * @(#)db_int.h 10.77 (Sleepycat) 1/3/99 8*0Sstevel@tonic-gate */ 9*0Sstevel@tonic-gate 10*0Sstevel@tonic-gate #ifndef _DB_INTERNAL_H_ 11*0Sstevel@tonic-gate #define _DB_INTERNAL_H_ 12*0Sstevel@tonic-gate 13*0Sstevel@tonic-gate #include "db.h" /* Standard DB include file. */ 14*0Sstevel@tonic-gate #include "queue.h" 15*0Sstevel@tonic-gate #include "shqueue.h" 16*0Sstevel@tonic-gate 17*0Sstevel@tonic-gate /******************************************************* 18*0Sstevel@tonic-gate * General purpose constants and macros. 19*0Sstevel@tonic-gate *******************************************************/ 20*0Sstevel@tonic-gate #define UINT16_T_MAX 0xffff /* Maximum 16 bit unsigned. */ 21*0Sstevel@tonic-gate #define UINT32_T_MAX 0xffffffff /* Maximum 32 bit unsigned. */ 22*0Sstevel@tonic-gate 23*0Sstevel@tonic-gate #define DB_MIN_PGSIZE 0x000200 /* Minimum page size. */ 24*0Sstevel@tonic-gate #define DB_MAX_PGSIZE 0x010000 /* Maximum page size. */ 25*0Sstevel@tonic-gate 26*0Sstevel@tonic-gate #define DB_MINCACHE 10 /* Minimum cached pages */ 27*0Sstevel@tonic-gate 28*0Sstevel@tonic-gate #define MEGABYTE 1048576 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate /* 31*0Sstevel@tonic-gate * If we are unable to determine the underlying filesystem block size, use 32*0Sstevel@tonic-gate * 8K on the grounds that most OS's use less than 8K as their VM page size. 33*0Sstevel@tonic-gate */ 34*0Sstevel@tonic-gate #define DB_DEF_IOSIZE (8 * 1024) 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate /* 37*0Sstevel@tonic-gate * Aligning items to particular sizes or in pages or memory. ALIGNP is a 38*0Sstevel@tonic-gate * separate macro, as we've had to cast the pointer to different integral 39*0Sstevel@tonic-gate * types on different architectures. 40*0Sstevel@tonic-gate * 41*0Sstevel@tonic-gate * We cast pointers into unsigned longs when manipulating them because C89 42*0Sstevel@tonic-gate * guarantees that u_long is the largest available integral type and further, 43*0Sstevel@tonic-gate * to never generate overflows. However, neither C89 or C9X requires that 44*0Sstevel@tonic-gate * any integer type be large enough to hold a pointer, although C9X created 45*0Sstevel@tonic-gate * the intptr_t type, which is guaranteed to hold a pointer but may or may 46*0Sstevel@tonic-gate * not exist. At some point in the future, we should test for intptr_t and 47*0Sstevel@tonic-gate * use it where available. 48*0Sstevel@tonic-gate */ 49*0Sstevel@tonic-gate #undef ALIGNTYPE 50*0Sstevel@tonic-gate #define ALIGNTYPE u_long 51*0Sstevel@tonic-gate #undef ALIGNP 52*0Sstevel@tonic-gate #define ALIGNP(value, bound) ALIGN((ALIGNTYPE)value, bound) 53*0Sstevel@tonic-gate #undef ALIGN 54*0Sstevel@tonic-gate #define ALIGN(value, bound) (((value) + (bound) - 1) & ~((bound) - 1)) 55*0Sstevel@tonic-gate 56*0Sstevel@tonic-gate /* 57*0Sstevel@tonic-gate * There are several on-page structures that are declared to have a number of 58*0Sstevel@tonic-gate * fields followed by a variable length array of items. The structure size 59*0Sstevel@tonic-gate * without including the variable length array or the address of the first of 60*0Sstevel@tonic-gate * those elements can be found using SSZ. 61*0Sstevel@tonic-gate * 62*0Sstevel@tonic-gate * This macro can also be used to find the offset of a structure element in a 63*0Sstevel@tonic-gate * structure. This is used in various places to copy structure elements from 64*0Sstevel@tonic-gate * unaligned memory references, e.g., pointers into a packed page. 65*0Sstevel@tonic-gate * 66*0Sstevel@tonic-gate * There are two versions because compilers object if you take the address of 67*0Sstevel@tonic-gate * an array. 68*0Sstevel@tonic-gate */ 69*0Sstevel@tonic-gate #undef SSZ 70*0Sstevel@tonic-gate #define SSZ(name, field) ((int)&(((name *)0)->field)) 71*0Sstevel@tonic-gate 72*0Sstevel@tonic-gate #undef SSZA 73*0Sstevel@tonic-gate #define SSZA(name, field) ((int)&(((name *)0)->field[0])) 74*0Sstevel@tonic-gate 75*0Sstevel@tonic-gate /* Macros to return per-process address, offsets based on shared regions. */ 76*0Sstevel@tonic-gate #define R_ADDR(base, offset) ((void *)((u_int8_t *)((base)->addr) + offset)) 77*0Sstevel@tonic-gate #define R_OFFSET(base, p) ((u_int8_t *)(p) - (u_int8_t *)(base)->addr) 78*0Sstevel@tonic-gate 79*0Sstevel@tonic-gate #define DB_DEFAULT 0x000000 /* No flag was specified. */ 80*0Sstevel@tonic-gate 81*0Sstevel@tonic-gate /* Structure used to print flag values. */ 82*0Sstevel@tonic-gate typedef struct __fn { 83*0Sstevel@tonic-gate u_int32_t mask; /* Flag value. */ 84*0Sstevel@tonic-gate const char *name; /* Flag name. */ 85*0Sstevel@tonic-gate } FN; 86*0Sstevel@tonic-gate 87*0Sstevel@tonic-gate /* Set, clear and test flags. */ 88*0Sstevel@tonic-gate #define F_SET(p, f) (p)->flags |= (f) 89*0Sstevel@tonic-gate #define F_CLR(p, f) (p)->flags &= ~(f) 90*0Sstevel@tonic-gate #define F_ISSET(p, f) ((p)->flags & (f)) 91*0Sstevel@tonic-gate #define LF_SET(f) (flags |= (f)) 92*0Sstevel@tonic-gate #define LF_CLR(f) (flags &= ~(f)) 93*0Sstevel@tonic-gate #define LF_ISSET(f) (flags & (f)) 94*0Sstevel@tonic-gate 95*0Sstevel@tonic-gate /* 96*0Sstevel@tonic-gate * Panic check: 97*0Sstevel@tonic-gate * All interfaces check the panic flag, if it's set, the tree is dead. 98*0Sstevel@tonic-gate */ 99*0Sstevel@tonic-gate #define DB_PANIC_CHECK(dbp) { \ 100*0Sstevel@tonic-gate if ((dbp)->dbenv != NULL && (dbp)->dbenv->db_panic != 0) \ 101*0Sstevel@tonic-gate return (DB_RUNRECOVERY); \ 102*0Sstevel@tonic-gate } 103*0Sstevel@tonic-gate 104*0Sstevel@tonic-gate /* Display separator string. */ 105*0Sstevel@tonic-gate #undef DB_LINE 106*0Sstevel@tonic-gate #define DB_LINE "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" 107*0Sstevel@tonic-gate 108*0Sstevel@tonic-gate /* Unused, or not-used-yet variable. "Shut that bloody compiler up!" */ 109*0Sstevel@tonic-gate #define COMPQUIET(n, v) (n) = (v) 110*0Sstevel@tonic-gate 111*0Sstevel@tonic-gate /* 112*0Sstevel@tonic-gate * Purify and similar run-time tools complain about unitialized reads/writes 113*0Sstevel@tonic-gate * for structure fields whose only purpose is padding. 114*0Sstevel@tonic-gate */ 115*0Sstevel@tonic-gate #define UMRW(v) (v) = 0 116*0Sstevel@tonic-gate 117*0Sstevel@tonic-gate /* 118*0Sstevel@tonic-gate * Win16 needs specific syntax on callback functions. Nobody else cares. 119*0Sstevel@tonic-gate */ 120*0Sstevel@tonic-gate #ifndef DB_CALLBACK 121*0Sstevel@tonic-gate #define DB_CALLBACK /* Nothing. */ 122*0Sstevel@tonic-gate #endif 123*0Sstevel@tonic-gate 124*0Sstevel@tonic-gate /******************************************************* 125*0Sstevel@tonic-gate * Files. 126*0Sstevel@tonic-gate *******************************************************/ 127*0Sstevel@tonic-gate /* 128*0Sstevel@tonic-gate * We use 1024 as the maximum path length. It's too hard to figure out what 129*0Sstevel@tonic-gate * the real path length is, as it was traditionally stored in <sys/param.h>, 130*0Sstevel@tonic-gate * and that file isn't always available. 131*0Sstevel@tonic-gate */ 132*0Sstevel@tonic-gate #undef MAXPATHLEN 133*0Sstevel@tonic-gate #define MAXPATHLEN 1024 134*0Sstevel@tonic-gate 135*0Sstevel@tonic-gate #define PATH_DOT "." /* Current working directory. */ 136*0Sstevel@tonic-gate #define PATH_SEPARATOR "/" /* Path separator character. */ 137*0Sstevel@tonic-gate 138*0Sstevel@tonic-gate /******************************************************* 139*0Sstevel@tonic-gate * Mutex support. 140*0Sstevel@tonic-gate *******************************************************/ 141*0Sstevel@tonic-gate #include <sys/machlock.h> 142*0Sstevel@tonic-gate typedef lock_t tsl_t; 143*0Sstevel@tonic-gate 144*0Sstevel@tonic-gate 145*0Sstevel@tonic-gate /* 146*0Sstevel@tonic-gate * !!! 147*0Sstevel@tonic-gate * Various systems require different alignments for mutexes (the worst we've 148*0Sstevel@tonic-gate * seen so far is 16-bytes on some HP architectures). The mutex (tsl_t) must 149*0Sstevel@tonic-gate * be first in the db_mutex_t structure, which must itself be first in the 150*0Sstevel@tonic-gate * region. This ensures the alignment is as returned by mmap(2), which should 151*0Sstevel@tonic-gate * be sufficient. All other mutex users must ensure proper alignment locally. 152*0Sstevel@tonic-gate */ 153*0Sstevel@tonic-gate #define MUTEX_ALIGNMENT sizeof(int) 154*0Sstevel@tonic-gate 155*0Sstevel@tonic-gate /* 156*0Sstevel@tonic-gate * The offset of a mutex in memory. 157*0Sstevel@tonic-gate * 158*0Sstevel@tonic-gate * !!! 159*0Sstevel@tonic-gate * Not an off_t, so backing file offsets MUST be less than 4Gb. See the 160*0Sstevel@tonic-gate * off field of the db_mutex_t as well. 161*0Sstevel@tonic-gate */ 162*0Sstevel@tonic-gate #define MUTEX_LOCK_OFFSET(a, b) ((u_int32_t)((u_int8_t *)b - (u_int8_t *)a)) 163*0Sstevel@tonic-gate 164*0Sstevel@tonic-gate typedef struct _db_mutex_t { 165*0Sstevel@tonic-gate #ifdef HAVE_SPINLOCKS 166*0Sstevel@tonic-gate tsl_t tsl_resource; /* Resource test and set. */ 167*0Sstevel@tonic-gate #ifdef DIAGNOSTIC 168*0Sstevel@tonic-gate u_int32_t pid; /* Lock holder: 0 or process pid. */ 169*0Sstevel@tonic-gate #endif 170*0Sstevel@tonic-gate #else 171*0Sstevel@tonic-gate u_int32_t off; /* Backing file offset. */ 172*0Sstevel@tonic-gate u_int32_t pid; /* Lock holder: 0 or process pid. */ 173*0Sstevel@tonic-gate #endif 174*0Sstevel@tonic-gate u_int32_t spins; /* Spins before block. */ 175*0Sstevel@tonic-gate u_int32_t mutex_set_wait; /* Granted after wait. */ 176*0Sstevel@tonic-gate u_int32_t mutex_set_nowait; /* Granted without waiting. */ 177*0Sstevel@tonic-gate } db_mutex_t; 178*0Sstevel@tonic-gate 179*0Sstevel@tonic-gate #include "mutex_ext.h" 180*0Sstevel@tonic-gate 181*0Sstevel@tonic-gate /******************************************************* 182*0Sstevel@tonic-gate * Access methods. 183*0Sstevel@tonic-gate *******************************************************/ 184*0Sstevel@tonic-gate /* Lock/unlock a DB thread. */ 185*0Sstevel@tonic-gate #define DB_THREAD_LOCK(dbp) \ 186*0Sstevel@tonic-gate if (F_ISSET(dbp, DB_AM_THREAD)) \ 187*0Sstevel@tonic-gate (void)__db_mutex_lock((db_mutex_t *)(dbp)->mutexp, -1); 188*0Sstevel@tonic-gate #define DB_THREAD_UNLOCK(dbp) \ 189*0Sstevel@tonic-gate if (F_ISSET(dbp, DB_AM_THREAD)) \ 190*0Sstevel@tonic-gate (void)__db_mutex_unlock((db_mutex_t *)(dbp)->mutexp, -1); 191*0Sstevel@tonic-gate 192*0Sstevel@tonic-gate /******************************************************* 193*0Sstevel@tonic-gate * Environment. 194*0Sstevel@tonic-gate *******************************************************/ 195*0Sstevel@tonic-gate /* Type passed to __db_appname(). */ 196*0Sstevel@tonic-gate typedef enum { 197*0Sstevel@tonic-gate DB_APP_NONE=0, /* No type (region). */ 198*0Sstevel@tonic-gate DB_APP_DATA, /* Data file. */ 199*0Sstevel@tonic-gate DB_APP_LOG, /* Log file. */ 200*0Sstevel@tonic-gate DB_APP_TMP /* Temporary file. */ 201*0Sstevel@tonic-gate } APPNAME; 202*0Sstevel@tonic-gate 203*0Sstevel@tonic-gate /******************************************************* 204*0Sstevel@tonic-gate * Shared memory regions. 205*0Sstevel@tonic-gate *******************************************************/ 206*0Sstevel@tonic-gate /* 207*0Sstevel@tonic-gate * The shared memory regions share an initial structure so that the general 208*0Sstevel@tonic-gate * region code can handle races between the region being deleted and other 209*0Sstevel@tonic-gate * processes waiting on the region mutex. 210*0Sstevel@tonic-gate * 211*0Sstevel@tonic-gate * !!! 212*0Sstevel@tonic-gate * Note, the mutex must be the first entry in the region; see comment above. 213*0Sstevel@tonic-gate */ 214*0Sstevel@tonic-gate typedef struct _rlayout { 215*0Sstevel@tonic-gate db_mutex_t lock; /* Region mutex. */ 216*0Sstevel@tonic-gate #define DB_REGIONMAGIC 0x120897 217*0Sstevel@tonic-gate u_int32_t valid; /* Valid magic number. */ 218*0Sstevel@tonic-gate u_int32_t refcnt; /* Region reference count. */ 219*0Sstevel@tonic-gate size_t size; /* Region length. */ 220*0Sstevel@tonic-gate int majver; /* Major version number. */ 221*0Sstevel@tonic-gate int minver; /* Minor version number. */ 222*0Sstevel@tonic-gate int patch; /* Patch version number. */ 223*0Sstevel@tonic-gate int panic; /* Region is dead. */ 224*0Sstevel@tonic-gate #define INVALID_SEGID -1 225*0Sstevel@tonic-gate int segid; /* shmget(2) ID, or Win16 segment ID. */ 226*0Sstevel@tonic-gate 227*0Sstevel@tonic-gate #define REGION_ANONYMOUS 0x01 /* Region is/should be in anon mem. */ 228*0Sstevel@tonic-gate u_int32_t flags; 229*0Sstevel@tonic-gate } RLAYOUT; 230*0Sstevel@tonic-gate 231*0Sstevel@tonic-gate /* 232*0Sstevel@tonic-gate * DB creates all regions on 4K boundaries out of sheer paranoia, so that 233*0Sstevel@tonic-gate * we don't make the underlying VM unhappy. 234*0Sstevel@tonic-gate */ 235*0Sstevel@tonic-gate #define DB_VMPAGESIZE (4 * 1024) 236*0Sstevel@tonic-gate #define DB_ROUNDOFF(n, round) { \ 237*0Sstevel@tonic-gate (n) += (round) - 1; \ 238*0Sstevel@tonic-gate (n) -= (n) % (round); \ 239*0Sstevel@tonic-gate } 240*0Sstevel@tonic-gate 241*0Sstevel@tonic-gate /* 242*0Sstevel@tonic-gate * The interface to region attach is nasty, there is a lot of complex stuff 243*0Sstevel@tonic-gate * going on, which has to be retained between create/attach and detach. The 244*0Sstevel@tonic-gate * REGINFO structure keeps track of it. 245*0Sstevel@tonic-gate */ 246*0Sstevel@tonic-gate struct __db_reginfo; typedef struct __db_reginfo REGINFO; 247*0Sstevel@tonic-gate struct __db_reginfo { 248*0Sstevel@tonic-gate /* Arguments. */ 249*0Sstevel@tonic-gate DB_ENV *dbenv; /* Region naming info. */ 250*0Sstevel@tonic-gate APPNAME appname; /* Region naming info. */ 251*0Sstevel@tonic-gate char *path; /* Region naming info. */ 252*0Sstevel@tonic-gate const char *file; /* Region naming info. */ 253*0Sstevel@tonic-gate int mode; /* Region mode, if a file. */ 254*0Sstevel@tonic-gate size_t size; /* Region size. */ 255*0Sstevel@tonic-gate u_int32_t dbflags; /* Region file open flags, if a file. */ 256*0Sstevel@tonic-gate 257*0Sstevel@tonic-gate /* Results. */ 258*0Sstevel@tonic-gate char *name; /* Region name. */ 259*0Sstevel@tonic-gate void *addr; /* Region address. */ 260*0Sstevel@tonic-gate int fd; /* Fcntl(2) locking file descriptor. 261*0Sstevel@tonic-gate NB: this is only valid if a regular 262*0Sstevel@tonic-gate file is backing the shared region, 263*0Sstevel@tonic-gate and mmap(2) is being used to map it 264*0Sstevel@tonic-gate into our address space. */ 265*0Sstevel@tonic-gate int segid; /* shmget(2) ID, or Win16 segment ID. */ 266*0Sstevel@tonic-gate void *wnt_handle; /* Win/NT HANDLE. */ 267*0Sstevel@tonic-gate 268*0Sstevel@tonic-gate /* Shared flags. */ 269*0Sstevel@tonic-gate /* 0x0001 COMMON MASK with RLAYOUT structure. */ 270*0Sstevel@tonic-gate #define REGION_CANGROW 0x0002 /* Can grow. */ 271*0Sstevel@tonic-gate #define REGION_CREATED 0x0004 /* Created. */ 272*0Sstevel@tonic-gate #define REGION_HOLDINGSYS 0x0008 /* Holding system resources. */ 273*0Sstevel@tonic-gate #define REGION_LASTDETACH 0x0010 /* Delete on last detach. */ 274*0Sstevel@tonic-gate #define REGION_MALLOC 0x0020 /* Created in malloc'd memory. */ 275*0Sstevel@tonic-gate #define REGION_PRIVATE 0x0040 /* Private to thread/process. */ 276*0Sstevel@tonic-gate #define REGION_REMOVED 0x0080 /* Already deleted. */ 277*0Sstevel@tonic-gate #define REGION_SIZEDEF 0x0100 /* Use default region size if exists. */ 278*0Sstevel@tonic-gate u_int32_t flags; 279*0Sstevel@tonic-gate }; 280*0Sstevel@tonic-gate 281*0Sstevel@tonic-gate /******************************************************* 282*0Sstevel@tonic-gate * Mpool. 283*0Sstevel@tonic-gate *******************************************************/ 284*0Sstevel@tonic-gate /* 285*0Sstevel@tonic-gate * File types for DB access methods. Negative numbers are reserved to DB. 286*0Sstevel@tonic-gate */ 287*0Sstevel@tonic-gate #define DB_FTYPE_BTREE -1 /* Btree. */ 288*0Sstevel@tonic-gate #define DB_FTYPE_HASH -2 /* Hash. */ 289*0Sstevel@tonic-gate 290*0Sstevel@tonic-gate /* Structure used as the DB pgin/pgout pgcookie. */ 291*0Sstevel@tonic-gate typedef struct __dbpginfo { 292*0Sstevel@tonic-gate size_t db_pagesize; /* Underlying page size. */ 293*0Sstevel@tonic-gate int needswap; /* If swapping required. */ 294*0Sstevel@tonic-gate } DB_PGINFO; 295*0Sstevel@tonic-gate 296*0Sstevel@tonic-gate /******************************************************* 297*0Sstevel@tonic-gate * Log. 298*0Sstevel@tonic-gate *******************************************************/ 299*0Sstevel@tonic-gate /* Initialize an LSN to 'zero'. */ 300*0Sstevel@tonic-gate #define ZERO_LSN(LSN) { \ 301*0Sstevel@tonic-gate (LSN).file = 0; \ 302*0Sstevel@tonic-gate (LSN).offset = 0; \ 303*0Sstevel@tonic-gate } 304*0Sstevel@tonic-gate 305*0Sstevel@tonic-gate /* Return 1 if LSN is a 'zero' lsn, otherwise return 0. */ 306*0Sstevel@tonic-gate #define IS_ZERO_LSN(LSN) ((LSN).file == 0) 307*0Sstevel@tonic-gate 308*0Sstevel@tonic-gate /* Test if we need to log a change. */ 309*0Sstevel@tonic-gate #define DB_LOGGING(dbc) \ 310*0Sstevel@tonic-gate (F_ISSET((dbc)->dbp, DB_AM_LOGGING) && !F_ISSET(dbc, DBC_RECOVER)) 311*0Sstevel@tonic-gate 312*0Sstevel@tonic-gate #ifdef DIAGNOSTIC 313*0Sstevel@tonic-gate /* 314*0Sstevel@tonic-gate * Debugging macro to log operations. 315*0Sstevel@tonic-gate * If DEBUG_WOP is defined, log operations that modify the database. 316*0Sstevel@tonic-gate * If DEBUG_ROP is defined, log operations that read the database. 317*0Sstevel@tonic-gate * 318*0Sstevel@tonic-gate * D dbp 319*0Sstevel@tonic-gate * T txn 320*0Sstevel@tonic-gate * O operation (string) 321*0Sstevel@tonic-gate * K key 322*0Sstevel@tonic-gate * A data 323*0Sstevel@tonic-gate * F flags 324*0Sstevel@tonic-gate */ 325*0Sstevel@tonic-gate #define LOG_OP(C, T, O, K, A, F) { \ 326*0Sstevel@tonic-gate DB_LSN _lsn; \ 327*0Sstevel@tonic-gate DBT _op; \ 328*0Sstevel@tonic-gate if (DB_LOGGING((C))) { \ 329*0Sstevel@tonic-gate memset(&_op, 0, sizeof(_op)); \ 330*0Sstevel@tonic-gate _op.data = O; \ 331*0Sstevel@tonic-gate _op.size = strlen(O) + 1; \ 332*0Sstevel@tonic-gate (void)__db_debug_log((C)->dbp->dbenv->lg_info, \ 333*0Sstevel@tonic-gate T, &_lsn, 0, &_op, (C)->dbp->log_fileid, K, A, F); \ 334*0Sstevel@tonic-gate } \ 335*0Sstevel@tonic-gate } 336*0Sstevel@tonic-gate #ifdef DEBUG_ROP 337*0Sstevel@tonic-gate #define DEBUG_LREAD(C, T, O, K, A, F) LOG_OP(C, T, O, K, A, F) 338*0Sstevel@tonic-gate #else 339*0Sstevel@tonic-gate #define DEBUG_LREAD(C, T, O, K, A, F) 340*0Sstevel@tonic-gate #endif 341*0Sstevel@tonic-gate #ifdef DEBUG_WOP 342*0Sstevel@tonic-gate #define DEBUG_LWRITE(C, T, O, K, A, F) LOG_OP(C, T, O, K, A, F) 343*0Sstevel@tonic-gate #else 344*0Sstevel@tonic-gate #define DEBUG_LWRITE(C, T, O, K, A, F) 345*0Sstevel@tonic-gate #endif 346*0Sstevel@tonic-gate #else 347*0Sstevel@tonic-gate #define DEBUG_LREAD(C, T, O, K, A, F) 348*0Sstevel@tonic-gate #define DEBUG_LWRITE(C, T, O, K, A, F) 349*0Sstevel@tonic-gate #endif /* DIAGNOSTIC */ 350*0Sstevel@tonic-gate 351*0Sstevel@tonic-gate /******************************************************* 352*0Sstevel@tonic-gate * Transactions and recovery. 353*0Sstevel@tonic-gate *******************************************************/ 354*0Sstevel@tonic-gate /* 355*0Sstevel@tonic-gate * Out of band value for a lock. The locks are returned to callers as offsets 356*0Sstevel@tonic-gate * into the lock regions. Since the RLAYOUT structure begins all regions, an 357*0Sstevel@tonic-gate * offset of 0 is guaranteed not to be a valid lock. 358*0Sstevel@tonic-gate */ 359*0Sstevel@tonic-gate #define LOCK_INVALID 0 360*0Sstevel@tonic-gate 361*0Sstevel@tonic-gate /* The structure allocated for every transaction. */ 362*0Sstevel@tonic-gate struct __db_txn { 363*0Sstevel@tonic-gate DB_TXNMGR *mgrp; /* Pointer to transaction manager. */ 364*0Sstevel@tonic-gate DB_TXN *parent; /* Pointer to transaction's parent. */ 365*0Sstevel@tonic-gate DB_LSN last_lsn; /* Lsn of last log write. */ 366*0Sstevel@tonic-gate u_int32_t txnid; /* Unique transaction id. */ 367*0Sstevel@tonic-gate size_t off; /* Detail structure within region. */ 368*0Sstevel@tonic-gate TAILQ_ENTRY(__db_txn) links; /* Links transactions off manager. */ 369*0Sstevel@tonic-gate TAILQ_HEAD(__kids, __db_txn) kids; /* Child transactions. */ 370*0Sstevel@tonic-gate TAILQ_ENTRY(__db_txn) klinks; /* Links child transactions. */ 371*0Sstevel@tonic-gate 372*0Sstevel@tonic-gate #define TXN_MALLOC 0x01 /* Structure allocated by TXN system. */ 373*0Sstevel@tonic-gate u_int32_t flags; 374*0Sstevel@tonic-gate }; 375*0Sstevel@tonic-gate 376*0Sstevel@tonic-gate /******************************************************* 377*0Sstevel@tonic-gate * Global variables. 378*0Sstevel@tonic-gate *******************************************************/ 379*0Sstevel@tonic-gate /* 380*0Sstevel@tonic-gate * !!! 381*0Sstevel@tonic-gate * Initialized in os/os_config.c, don't change this unless you change it 382*0Sstevel@tonic-gate * as well. 383*0Sstevel@tonic-gate */ 384*0Sstevel@tonic-gate 385*0Sstevel@tonic-gate struct __rmname { 386*0Sstevel@tonic-gate char *dbhome; 387*0Sstevel@tonic-gate int rmid; 388*0Sstevel@tonic-gate TAILQ_ENTRY(__rmname) links; 389*0Sstevel@tonic-gate }; 390*0Sstevel@tonic-gate 391*0Sstevel@tonic-gate typedef struct __db_globals { 392*0Sstevel@tonic-gate int db_mutexlocks; /* DB_MUTEXLOCKS */ 393*0Sstevel@tonic-gate int db_pageyield; /* DB_PAGEYIELD */ 394*0Sstevel@tonic-gate int db_region_anon; /* DB_REGION_ANON, DB_REGION_NAME */ 395*0Sstevel@tonic-gate int db_region_init; /* DB_REGION_INIT */ 396*0Sstevel@tonic-gate int db_tsl_spins; /* DB_TSL_SPINS */ 397*0Sstevel@tonic-gate /* XA: list of opened environments. */ 398*0Sstevel@tonic-gate TAILQ_HEAD(__db_envq, __db_env) db_envq; 399*0Sstevel@tonic-gate /* XA: list of id to dbhome mappings. */ 400*0Sstevel@tonic-gate TAILQ_HEAD(__db_nameq, __rmname) db_nameq; 401*0Sstevel@tonic-gate } DB_GLOBALS; 402*0Sstevel@tonic-gate 403*0Sstevel@tonic-gate extern DB_GLOBALS __db_global_values; 404*0Sstevel@tonic-gate #define DB_GLOBAL(v) __db_global_values.v 405*0Sstevel@tonic-gate 406*0Sstevel@tonic-gate #include "os.h" 407*0Sstevel@tonic-gate #include "os_ext.h" 408*0Sstevel@tonic-gate 409*0Sstevel@tonic-gate #endif /* !_DB_INTERNAL_H_ */ 410