tldm-universe/Ardent/UV/gcidir/include/c_LOG.h

432 lines
14 KiB
C
Raw Permalink Normal View History

2024-09-09 21:51:08 +00:00
#ifndef h_clog
#define h_clog
/******************************************************************************
*
* LOG.h - standard Logging daemon data definitions
*
* Module %M% Version %I% Date %H%
*
* (c) Copyright 1998 Ardent Software Inc. - All Rights Reserved
* This is unpublished proprietary source code of Ardent Software Inc.
* The copyright notice above does not evidence any actual or intented
* publication of such source code.
*
*******************************************************************************
*
* Maintenence log - insert most recent change descriptions at top
*
* Date.... GTAR# WHO Description.........................................
* 10/14/98 23801 SAP Change copyrights.
* 06/26/98 23161 RGA Add 'raw' device support.
* 05/29/97 20607 DJD Added NLS support.
* 03/17/97 20246 DJD Added support for the deadlock process.
* 03/25/96 18212 LAG Windows NT port.
* 03/01/96 18074 CSM Added syncmode bit to shared memory, LGWSTXMSG
* 04/26/95 16198 GMH Add archive tape support
* 02/27/95 16051 AGM Revert name to LOG.h
* 01/23/95 15386 CSM Added LG_STALE_ERR, PRseen for CPD, use of last_log
* 12/13/94 15078 SJM Moved to clog.h
* 10/20/94 15120 CSM Susp/Shut in progress, 15040 new err codes LG*ERR
* 10/06/94 14995 CSM make log number an unsigned int
* 08/24/94 14757 CSM replace staletbl with staletx, use new log tuneables
* 07/07/94 14392 FAI #define SEMUN, if not already defined.
* 07/06/94 14357 EAP Added LOGOP_NOBF
* 07/06/94 14133 CSM Added LOGOP_DLDATA, exit codes, structs for CP, RF
* 06/23/94 14173 EAP Added WARM_START_LOGGING macro
* 06/15/94 13286 DTM Added eof
* 06/07/94 14173 EAP Added LOGOP_TXWARM
* 06/06/94 13286 DTM Added defines for RECIO functionality
* 04/16/94 13511 JKW Add TXPR
* 04/13/94 13524 CSM Changed R8 defines
* 04/08/94 13524 CSM More R8 defines
* 03/04/94 13179 JKW Added R8 defines
* 01/12/94 9404 GMH Added new state CACHE_DUMPED
* 03/18/93 11217 CSM Added a new state IOS_STARTING for lognoio
* 11/07/91 8800 GMH Changed define values
* 11/04/91 8782 GMH Added defines
* 01/19/90 7868 TMC #ifndef semun should be #ifndef SEMUN
* 05/15/90 7025 KIS Initial code.
*
*****************************************************************************/
#define TRUE 1
#define FALSE 0
#define LOGTRYS 10
#define LOGBUFADD 512
/* Message Queue structures */
#define MB (struct msgbuf *)
#define MQ (struct msqid_ds *)
#define LOGQUEUE 0xaced0651 /* Logging Message Queue Key */
#define LMsk 0666 /* Logging protection mask */
#define LOGSHBUF 10 /* Buffer shift */
#define LOGPKTBUF (1<<LOGSHBUF) /* Buffer size for logging packets */
#define Lmax LOGPKTBUF + 1
#define DAEMON_INACTIVE 0
#define PRIMARY_DEVICE 10
#define SECONDARY_DEVICE 20
#define DISK_DEVICE 5
#define IOS_ACTIVE 0
#define IOS_NOT_PERMITTED 100
#define IOS_INACTIVE 200
#define IOS_MANUAL_OFF 300
#define IOS_UPDATE_PRIM 400
#define IOS_FILLED_TAPE 600
#define IOS_STARTING 700
#define CACHE_DUMPED 800
#define ROLLFWD_INACTIVE 0
#define ROLLFWD_ACTIVE 1000
/* Logging Data Structure */
struct LOGQdata {
long MLtype;
int pktamt;
char logdata[LOGPKTBUF + 1];
};
/* Semaphore structure */
#ifndef SEMUN
#define SEMUN
union semun {
int val;
struct semid_ds *buf;
ushort *array;
};
#endif
#define LG_R8
#ifdef LG_R8
struct LG_data {
/* these are set to zero when Universe is booted */
int state; /* 0 = Uninitialized */
/* 1 = Inactive */
/* 2 = Initializing */
/* 3 = Warm start */
/* 4 = Enabled */
/* 5 = Suspended */
/* 7 = Full */
/* 8 = Crashed */
unsigned int
archive:1, /* Archive attribute */
chkpnt:1, /* Checkpoint attribute */
file_flush:1, /* cycle to next file */
chkd_fatal:1, /* set by chkd requesting CRASHED */
last_log:2, /* 0 inactive, 1 full, 2 active, 3 remove stale */
large_rec:1, /* log rec > current buf space */
to_tape:1, /* Archive bit set, 0 disk, 1 tape */
syncmode:1; /* 1 open disk log file in sync mode */
pid_t logd; /* log daemon's pid */
pid_t chkd; /* checkpoint daemon's pid */
unsigned int chkd_syncd;/* last log fsynced */
unsigned int chkd_done; /* last log checkpointed */
pid_t rollfwd; /* rollfwd pid during warm start */
int user_request; /* state change request by user */
unsigned int active_log; /* sequence number of log */
unsigned int next_to_chkp;/* sequence number of log */
/* this is set whenever DBsetup runs */
int low_tx; /* lowest valid TX id */
int stale_tx; /* all txids >= low_tx & <= stale_tx are stale */
/* these are set at the first boot up of Universe */
int semid; /* semaphore id */
char *buf_start; /* start of data buffer */
int buf_size; /* precomputed for ease of use */
int block_size; /* block size of log files */
/* these are set whenever a log file is opened */
int prev_bytes_put; /* used for prev lsn in rec hdr */
int bytes_put; /* bytes in log file
bytes_put modulus buf_size =
current buffer position */
int bytes_written; /* last byte written, always
on a block boundary */
int filesize; /* size of current log file */
};
#define LGCONTROL DBshmseg->LGcontrol
typedef struct {
unsigned int logid;
int attributes;
}LG_files;
typedef struct {
unsigned int log_seqno;
int rba;
}LG_lsn;
typedef struct {
#ifdef MSWIN
HANDLE fdesc; /* OS descriptor */
#else
int fdesc; /* OS descriptor */
#endif
int attributes; /* from header */
unsigned int seqno; /* sequence number */
LG_lsn lsn; /* current lsn, used when reading */
int rdpos; /* current read position */
char *write_start; /* start of active write */
char *write_end; /* end of active write */
int written; /* set if file is written */
int buf_size; /* size for reads */
int eof; /* logical eof */
int file_size;
int NLSflag;
} LG_openfile;
typedef struct {
int version; /* magic number and version */
char name[14]; /* file name */
unsigned int seqno; /* log sequence number */
int eof; /* logical eof */
int peof; /* physical eof */
unsigned int /* log file attributes */
empty:1,
inuse:1,
need_sync:1,
has_tx:1,
need_archive:1,
crashed:1; /* all open tx discarded at end of log */
int NLSflag;
}LG_header;
#define LG_HEADER_SIZE 512
#define LGWSTXMSG 0x1 /* bit indicating a WS tx message */
#define LGCMTXMSG 0x2 /* bit indicating a commit tx message */
#define LGNLSFLAG 0x4 /* bit indicating that NLS was on when record stored */
typedef struct {
LG_lsn prev_lsn;
int size;
char rmid;
char fillerc;
short fillers; /* will contain indication of WS tx message */
char data[1];
}LG_record;
#define LOGOP_TXBG 5 /* TX begin */
#define LOGOP_TXCM 6 /* TX commit */
#define LOGOP_TXRB 7 /* TX rollback */
#define LOGOP_TXWR 8 /* TX write */
#define LOGOP_TXDL 9 /* TX delete */
#define LOGOP_TXCF 10 /* TX clearfile not implemented */
#define LOGOP_TXBF 11 /* TX before image */
#define LOGOP_TXPR 12
#define LOGOP_TXWARM 13 /* Warm Start Transaction */
#define LOGOP_DLDATA 14 /* Delete data part of a file */
#define LOGOP_TXNOBF 15 /* TX NO before image */
#define MAX_LOGOP 15 /* Highest opcode */
#define LG_OK 0
#define LG_FAILURE -1
#define LG_EOF -2
#define LG_STATE_ERR -3
#define LG_TX_ERR -4 /* Low tx or stale tx or tx entry size > log size */
#define LG_SIZE_ERR -5 /* non-tx log entry size > log file size */
#define LG_SEM_ERR -6
#define LG_STALE_ERR -7
#define LG_BADRAW_OFFSET -8 /* creation of new log failed/bad offset */
/* key for log semaphores */
#define LG_SEM_KEY 0xaced0652
/* Log subsystem states */
#define LG_UNINIT 1
#define LG_INACTIVE 2
#define LG_INITING 3
#define LG_WARM_START 4
#define LG_ENABLED 5
#define LG_SUSPENDED 6
#define LG_FULL 8
#define LG_CRASHED 9
#define LG_SHUTDOWN 10
#define LG_SUSP_PROG 11
#define LG_SHUT_PROG 12
/* exit codes */
#define LG_EXIT1 -1 /* unix initialization failed */
#define LG_EXIT2 -2 /* LG_init failed */
#define LG_EXIT3 -3 /* daemon in crashed state */
#define LG_EXIT4 0 /* normal shutdown */
#define LG_EXIT5 -5 /* can't flush log file */
#define LG_EXIT6 -6 /* can't flush log buffer */
#define LG_EXIT7 -7 /* maintenance fcn aborted */
#define LG_EXIT8 -8 /* can't create trace file */
#define LG_EXIT9 -9 /* can't open next log */
#define LG_EXIT10 -10 /* semaphore problem */
#define LG_EXIT11 -11 /* unable to fork */
#define LG_EXIT12 12 /* not superuser */
#define LG_EXIT13 -13 /* No empty logs */
#define LG_EXIT14 -14 /* daemon in crashed state */
#define LG_EXIT15 -15 /* log file open/close/access/info problem */
#define LG_EXIT16 -16 /* same transaction begun more than once */
#define LG_EXIT17 -17 /* log file checksum, opcode problem */
#define LG_EXIT18 -18 /* Process initialization failed */
#define LG_EXIT19 -19 /* error with UV.TRANS, UV.ACCOUNT to get file path */
#define LG_EXIT20 -20 /* can't fsync a data file or sys file table full */
#define LG_EXIT21 -21 /* unused */
#define LG_EXIT22 -22 /* cannot reuse a log file */
#define LG_EXIT23 -23 /* error opening data file */
#define LG_EXIT24 -24 /* RF called with invalid arguments */
#define LG_EXIT25 -25 /* Transaction commit failed */
#define LG_EXIT26 -26 /* Checkpoint daemon disappeared */
#define LG_EXIT27 -27 /* Failure applying warm-start transaction */
#define LG_MAINT_CYCLE 10 /* passes till LG_maintenance */
#define LG_TRACE_DIR "traces"
#define LG_TRACE_FILE "logd.trace"
/* codes for LG_next_log */
#define LG_EMPTY_LOG 0x1
#define LG_NEED_CHKPNT 0x6
#define LG_NEED_ARCHIVE 0x8
/* codes for retrieving attributes */
#define LG_ARCHIVE_ON 0x1
#define LG_CHECKPOINT_ON 0x2
/* Gtar 16198 */
#define LG_ARCHIVE_TAPE 0x4
/* log daemons */
#ifdef MSWIN
#define LG_LOGD "uvlogd.exe"
#define LG_CHKD "uvchkd.exe"
#define LG_ROLLF "uvrolf.exe"
#else
#define LG_LOGD "uvlogd"
#define LG_CHKD "uvchkd"
#define LG_ROLLF "uvrolf"
#endif
/* trace files */
#define LG_LOGD_TRC "uvlogd.info"
#define LG_CHKD_TRC "uvchkd.info"
#define LG_ROLLF_TRC "uvrolf.info"
#define LG_PATH_BUF 512
#define LG_EXEC_WAIT 60 * 2
#define LG_SUSPEND_SLEEP 5
/* log file bits */
#define LG_F_EMPTY 0x1
#define LG_F_NEED_FSYNC 0x2
#define LG_F_HAS_TX 0x4
#define LG_F_ARCHIVE 0x8
#define LG_F_CRASHED 0x10
#define LG_F_INUSE 0x20
/* Keys for RECIO ATTR */
#define LG_CHECKPOINT 0
#define LG_ARCHIVE 1
/* Keys for BASIC RECIO parser */
#define RECIO_FINFO 1
#define RECIO_PATH 2
#define RECIO_STATE 3
#define RECIO_CLEAR 4
#define RECIO_CREATE 5
#define RECIO_ATTR 6
#define RECIO_CHECKPOINT 7
#define RECIO_CONSISTENT 8
#define RECIO_DEVICELIST 9
#define RECIO_DLINFO 10
#define RECIO_RPINFO 11
#define RECIO_RAWPATH 12
#define RECIO_RAWCREATE 13
#define FINFO_AI_STATE 11
#define FINFO_AI_FIRSTSEQ 12
#define FINFO_AI_SEQUENCE 13
#define FINFO_AI_PEOF 14
#define FINFO_AI_EOF 15
#define FINFO_AI_ARCHIVE 16
#define FINFO_AI_CHECKPOINT 17
#define FINFO_AI_LASTSEQ 18
#define FINFO_AI_ARCHIVE_TAPE 19
#define DLINFO_AI_STATE 1
#define RPINFO_LOG_STATE 1
#define RPINFO_REP_STATE 2
#define RMID_UVFS 1
#define RMID_UVAUDIT 2
#define LG_DEBUG_LOGFILE 9
#define LG_WATCHDOG 5
#define WARM_START_LOGGING(fdesc) (LGCONTROL.chkpnt && fdesc->tlfilenum)
#ifdef LG_CHECKPOINTING /* begin of CHECKPOINT definitions */
struct tid_node {
struct tid_node *next;
struct tid_node *parent;
struct tid_node *child;
int txid;
STRING fillst;
unsigned int
currl:1, /* 1: tx was started in curr log file */
prseen:1; /* 1: TXprepare seen for transaction */
};
typedef struct tid_node TID_NODE;
struct log_file {
struct log_file *next;
unsigned int lognum;
STRING tidsleft;
int hastx; /* # of active transactions in this log file */
int filactvn_err; /* if 1, err getting a data file path */
};
typedef struct log_file LOG_FILE;
#endif /* end of CHECKPOINT definitions */
#ifdef LG_ROLLFORWARD /* begin of ROLLFORWARD definitions */
struct tid_node {
struct tid_node *next;
int txid;
int prseen; /* TXprepare seen */
void *ptx; /* pointer to Transaction descriptor */
};
typedef struct tid_node TID_NODE;
struct ftentry {
char *fpath;
char *fname;
DBFILE *fdesc;
int ftype;
};
typedef struct ftentry FTENTRY; /* Files_table entry */
#endif /* end of ROLLFORWARD definitions */
#endif /* LG_R8 */
#endif /* end of clog.h */