📄 db.in
字号:
#define DB_LOCK_SWITCH 0x020 /* Internal: switch existing lock. */#define DB_LOCK_UPGRADE 0x040 /* Internal: upgrade existing lock. *//* * Simple R/W lock modes and for multi-granularity intention locking. * * !!! * These values are NOT random, as they are used as an index into the lock * conflicts arrays, i.e., DB_LOCK_IWRITE must be == 3, and DB_LOCK_IREAD * must be == 4. */typedef enum { DB_LOCK_NG=0, /* Not granted. */ DB_LOCK_READ=1, /* Shared/read. */ DB_LOCK_WRITE=2, /* Exclusive/write. */ DB_LOCK_WAIT=3, /* Wait for event */ DB_LOCK_IWRITE=4, /* Intent exclusive/write. */ DB_LOCK_IREAD=5, /* Intent to share/read. */ DB_LOCK_IWR=6, /* Intent to read and write. */ DB_LOCK_DIRTY=7, /* Dirty Read. */ DB_LOCK_WWRITE=8 /* Was Written. */} db_lockmode_t;/* * Request types. */typedef enum { DB_LOCK_DUMP=0, /* Display held locks. */ DB_LOCK_GET=1, /* Get the lock. */ DB_LOCK_GET_TIMEOUT=2, /* Get lock with a timeout. */ DB_LOCK_INHERIT=3, /* Pass locks to parent. */ DB_LOCK_PUT=4, /* Release the lock. */ DB_LOCK_PUT_ALL=5, /* Release locker's locks. */ DB_LOCK_PUT_OBJ=6, /* Release locker's locks on obj. */ DB_LOCK_PUT_READ=7, /* Release locker's read locks. */ DB_LOCK_TIMEOUT=8, /* Force a txn to timeout. */ DB_LOCK_TRADE=9, /* Trade locker ids on a lock. */ DB_LOCK_UPGRADE_WRITE=10 /* Upgrade writes for dirty reads. */} db_lockop_t;/* * Status of a lock. */typedef enum { DB_LSTAT_ABORTED=1, /* Lock belongs to an aborted txn. */ DB_LSTAT_ERR=2, /* Lock is bad. */ DB_LSTAT_EXPIRED=3, /* Lock has expired. */ DB_LSTAT_FREE=4, /* Lock is unallocated. */ DB_LSTAT_HELD=5, /* Lock is currently held. */ DB_LSTAT_NOTEXIST=6, /* Object on which lock was waiting * was removed */ DB_LSTAT_PENDING=7, /* Lock was waiting and has been * promoted; waiting for the owner * to run and upgrade it to held. */ DB_LSTAT_WAITING=8 /* Lock is on the wait queue. */}db_status_t;/* Lock statistics structure. */struct __db_lock_stat { u_int32_t st_id; /* Last allocated locker ID. */ u_int32_t st_cur_maxid; /* Current maximum unused ID. */ u_int32_t st_maxlocks; /* Maximum number of locks in table. */ u_int32_t st_maxlockers; /* Maximum num of lockers in table. */ u_int32_t st_maxobjects; /* Maximum num of objects in table. */ u_int32_t st_nmodes; /* Number of lock modes. */ u_int32_t st_nlocks; /* Current number of locks. */ u_int32_t st_maxnlocks; /* Maximum number of locks so far. */ u_int32_t st_nlockers; /* Current number of lockers. */ u_int32_t st_maxnlockers; /* Maximum number of lockers so far. */ u_int32_t st_nobjects; /* Current number of objects. */ u_int32_t st_maxnobjects; /* Maximum number of objects so far. */ u_int32_t st_nconflicts; /* Number of lock conflicts. */ u_int32_t st_nrequests; /* Number of lock gets. */ u_int32_t st_nreleases; /* Number of lock puts. */ u_int32_t st_nnowaits; /* Number of requests that would have waited, but NOWAIT was set. */ u_int32_t st_ndeadlocks; /* Number of lock deadlocks. */ db_timeout_t st_locktimeout; /* Lock timeout. */ u_int32_t st_nlocktimeouts; /* Number of lock timeouts. */ db_timeout_t st_txntimeout; /* Transaction timeout. */ u_int32_t st_ntxntimeouts; /* Number of transaction timeouts. */ u_int32_t st_region_wait; /* Region lock granted after wait. */ u_int32_t st_region_nowait; /* Region lock granted without wait. */ u_int32_t st_regsize; /* Region size. */};/* * DB_LOCK_ILOCK -- * Internal DB access method lock. */struct __db_ilock { db_pgno_t pgno; /* Page being locked. */ u_int8_t fileid[DB_FILE_ID_LEN];/* File id. */#define DB_HANDLE_LOCK 1#define DB_RECORD_LOCK 2#define DB_PAGE_LOCK 3#define DB_TXN_LOCK 4 u_int32_t type; /* Type of lock. */};/* * DB_LOCK -- * The structure is allocated by the caller and filled in during a * lock_get request (or a lock_vec/DB_LOCK_GET). */struct __db_lock_u { size_t off; /* Offset of the lock in the region */ u_int32_t ndx; /* Index of the object referenced by * this lock; used for locking. */ u_int32_t gen; /* Generation number of this lock. */ db_lockmode_t mode; /* mode of this lock. */};/* Lock request structure. */struct __db_lockreq { db_lockop_t op; /* Operation. */ db_lockmode_t mode; /* Requested mode. */ db_timeout_t timeout; /* Time to expire lock. */ DBT *obj; /* Object being locked. */ DB_LOCK lock; /* Lock returned. */};/******************************************************* * Logging. *******************************************************/#define DB_LOGVERSION 7 /* Current log version. */#define DB_LOGOLDVER 7 /* Oldest log version supported. */#define DB_LOGMAGIC 0x040988/* Flag values for log_archive(). */#define DB_ARCH_ABS 0x001 /* Absolute pathnames. */#define DB_ARCH_DATA 0x002 /* Data files. */#define DB_ARCH_LOG 0x004 /* Log files. *//* * A DB_LSN has two parts, a fileid which identifies a specific file, and an * offset within that file. The fileid is an unsigned 4-byte quantity that * uniquely identifies a file within the log directory -- currently a simple * counter inside the log. The offset is also an unsigned 4-byte value. The * log manager guarantees the offset is never more than 4 bytes by switching * to a new log file before the maximum length imposed by an unsigned 4-byte * offset is reached. */struct __db_lsn { u_int32_t file; /* File ID. */ u_int32_t offset; /* File offset. */};/* * DB_LOGC -- * Log cursor. */struct __db_log_cursor { DB_ENV *dbenv; /* Enclosing dbenv. */ DB_FH *c_fh; /* File handle. */ DB_LSN c_lsn; /* Cursor: LSN */ u_int32_t c_len; /* Cursor: record length */ u_int32_t c_prev; /* Cursor: previous record's offset */ DBT c_dbt; /* Return DBT. */#define DB_LOGC_BUF_SIZE (32 * 1024) u_int8_t *bp; /* Allocated read buffer. */ u_int32_t bp_size; /* Read buffer length in bytes. */ u_int32_t bp_rlen; /* Read buffer valid data length. */ DB_LSN bp_lsn; /* Read buffer first byte LSN. */ u_int32_t bp_maxrec; /* Max record length in the log file. */ /* Methods. */ int (*close) __P((DB_LOGC *, u_int32_t)); int (*get) __P((DB_LOGC *, DB_LSN *, DBT *, u_int32_t));#define DB_LOG_DISK 0x01 /* Log record came from disk. */#define DB_LOG_LOCKED 0x02 /* Log region already locked */#define DB_LOG_SILENT_ERR 0x04 /* Turn-off error messages. */ u_int32_t flags;};/* Log statistics structure. */struct __db_log_stat { u_int32_t st_magic; /* Log file magic number. */ u_int32_t st_version; /* Log file version number. */ int st_mode; /* Log file mode. */ u_int32_t st_lg_bsize; /* Log buffer size. */ u_int32_t st_lg_size; /* Log file size. */ u_int32_t st_w_bytes; /* Bytes to log. */ u_int32_t st_w_mbytes; /* Megabytes to log. */ u_int32_t st_wc_bytes; /* Bytes to log since checkpoint. */ u_int32_t st_wc_mbytes; /* Megabytes to log since checkpoint. */ u_int32_t st_wcount; /* Total writes to the log. */ u_int32_t st_wcount_fill; /* Overflow writes to the log. */ u_int32_t st_scount; /* Total syncs to the log. */ u_int32_t st_region_wait; /* Region lock granted after wait. */ u_int32_t st_region_nowait; /* Region lock granted without wait. */ u_int32_t st_cur_file; /* Current log file number. */ u_int32_t st_cur_offset; /* Current log file offset. */ u_int32_t st_disk_file; /* Known on disk log file number. */ u_int32_t st_disk_offset; /* Known on disk log file offset. */ u_int32_t st_regsize; /* Region size. */ u_int32_t st_maxcommitperflush; /* Max number of commits in a flush. */ u_int32_t st_mincommitperflush; /* Min number of commits in a flush. */};/******************************************************* * Shared buffer cache (mpool). *******************************************************//* Flag values for DB_MPOOLFILE->get. */#define DB_MPOOL_CREATE 0x001 /* Create a page. */#define DB_MPOOL_LAST 0x002 /* Return the last page. */#define DB_MPOOL_NEW 0x004 /* Create a new page. *//* Flag values for DB_MPOOLFILE->put, DB_MPOOLFILE->set. */#define DB_MPOOL_CLEAN 0x001 /* Page is not modified. */#define DB_MPOOL_DIRTY 0x002 /* Page is modified. */#define DB_MPOOL_DISCARD 0x004 /* Don't cache the page. *//* Priority values for DB_MPOOLFILE->set_priority. */typedef enum { DB_PRIORITY_VERY_LOW=1, DB_PRIORITY_LOW=2, DB_PRIORITY_DEFAULT=3, DB_PRIORITY_HIGH=4, DB_PRIORITY_VERY_HIGH=5} DB_CACHE_PRIORITY;/* Per-process DB_MPOOLFILE information. */struct __db_mpoolfile { /* These fields need to be protected for multi-threaded support. */ DB_MUTEX *mutexp; /* Structure thread lock. */ DB_FH *fhp; /* Underlying file handle. */ u_int32_t ref; /* Reference count. */ /* * !!! * The pinref and q fields are protected by the region lock, not the * DB_MPOOLFILE structure mutex. We don't use the structure mutex * because then I/O (which holds the structure lock held because of * the race between the seek and write of the file descriptor) would * block any other put/get calls using this DB_MPOOLFILE structure. */ u_int32_t pinref; /* Pinned block reference count. */ /* * !!! * Explicit representations of structures from queue.h. * TAILQ_ENTRY(__db_mpoolfile) q; */ struct { struct __db_mpoolfile *tqe_next; struct __db_mpoolfile **tqe_prev; } q; /* Linked list of DB_MPOOLFILE's. */ /* * These fields are not thread-protected because they are initialized * when the file is opened and never modified. */ int ftype; /* File type. */ DBT *pgcookie; /* Byte-string passed to pgin/pgout. */ u_int8_t *fileid; /* Unique file ID. */ int32_t lsn_offset; /* LSN offset in page. */ u_int32_t clear_len; /* Cleared length on created pages. */ DB_MPOOL *dbmp; /* Overlying DB_MPOOL. */ MPOOLFILE *mfp; /* Underlying MPOOLFILE. */ void *addr; /* Address of mmap'd region. */ size_t len; /* Length of mmap'd region. */ /* Methods. */ int (*close) __P((DB_MPOOLFILE *, u_int32_t)); int (*get) __P((DB_MPOOLFILE *, db_pgno_t *, u_int32_t, void *)); void (*get_fileid) __P((DB_MPOOLFILE *, u_int8_t *)); void (*last_pgno) __P((DB_MPOOLFILE *, db_pgno_t *)); int (*open)__P((DB_MPOOLFILE *, const char *, u_int32_t, int, size_t)); int (*put) __P((DB_MPOOLFILE *, void *, u_int32_t)); void (*refcnt) __P((DB_MPOOLFILE *, db_pgno_t *)); int (*set) __P((DB_MPOOLFILE *, void *, u_int32_t)); int (*set_clear_len) __P((DB_MPOOLFILE *, u_int32_t)); int (*set_fileid) __P((DB_MPOOLFILE *, u_int8_t *)); int (*set_ftype) __P((DB_MPOOLFILE *, int)); int (*set_lsn_offset) __P((DB_MPOOLFILE *, int32_t)); int (*set_pgcookie) __P((DB_MPOOLFILE *, DBT *)); int (*set_priority) __P((DB_MPOOLFILE *, DB_CACHE_PRIORITY)); void (*set_unlink) __P((DB_MPOOLFILE *, int)); int (*sync) __P((DB_MPOOLFILE *)); /* * MP_OPEN_CALLED and MP_READONLY do not need to be thread protected * because they are initialized when the file is opened, and never * modified. * * MP_FLUSH, MP_UPGRADE and MP_UPGRADE_FAIL are thread protected * becase they are potentially read by multiple threads of control. */#define MP_FLUSH 0x001 /* Was opened to flush a buffer. */#define MP_OPEN_CALLED 0x002 /* File opened. */#define MP_READONLY 0x004 /* File is readonly. */#define MP_UPGRADE 0x008 /* File descriptor is readwrite. */#define MP_UPGRADE_FAIL 0x010 /* Upgrade wasn't possible. */ u_int32_t flags;};/* * Mpool statistics structure. */struct __db_mpool_stat { u_int32_t st_gbytes; /* Total cache size: GB. */ u_int32_t st_bytes; /* Total cache size: B. */ u_int32_t st_ncache; /* Number of caches. */ u_int32_t st_regsize; /* Cache size. */ u_int32_t st_map; /* Pages from mapped files. */ u_int32_t st_cache_hit; /* Pages found in the cache. */ u_int32_t st_cache_miss; /* Pages not found in the cache. */ u_int32_t st_page_create; /* Pages created in the cache. */ u_int32_t st_page_in; /* Pages read in. */ u_int32_t st_page_out; /* Pages written out. */ u_int32_t st_ro_evict; /* Clean pages forced from the cache. */ u_int32_t st_rw_evict; /* Dirty pages forced from the cache. */ u_int32_t st_page_trickle; /* Pages written by memp_trickle. */ u_int32_t st_pages; /* Total number of pages. */ u_int32_t st_page_clean; /* Clean pages. */ u_int32_t st_page_dirty; /* Dirty pages. */ u_int32_t st_hash_buckets; /* Number of hash buckets. */ u_int32_t st_hash_searches; /* Total hash chain searches. */ u_int32_t st_hash_longest; /* Longest hash chain searched. */ u_int32_t st_hash_examined; /* Total hash entries searched. */ u_int32_t st_hash_nowait; /* Hash lock granted with nowait. */ u_int32_t st_hash_wait; /* Hash lock granted after wait. */ u_int32_t st_hash_max_wait; /* Max hash lock granted after wait. */ u_int32_t st_region_nowait; /* Region lock granted with nowait. */ u_int32_t st_region_wait; /* Region lock granted after wait. */ u_int32_t st_alloc; /* Number of page allocations. */ u_int32_t st_alloc_buckets; /* Buckets checked during allocation. */ u_int32_t st_alloc_max_buckets; /* Max checked during allocation. */ u_int32_t st_alloc_pages; /* Pages checked during allocation. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -