home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: writeLogPageHeader.c,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:55:49 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
-
- #include "sysdefs.h"
- #include "ess.h"
- #include "checking.h"
- #include "trace.h"
- #include "error.h"
- #include "list.h"
- #include "pool.h"
- #include "tid.h"
- #include "io.h"
- #include "lock.h"
- #include "object.h"
- #include "msgdefs.h"
- #include "thread.h"
- #include "semaphore.h"
- #include "latch.h"
- #include "link.h"
- #include "lsn.h"
- #include "bf.h"
- #include "volume.h"
- #include "openlog.h"
- #include "trans.h"
- #include "logrecs.h"
- #include "log_intfuncs.h"
- #include "log_extfuncs.h"
- #include "bf_extfuncs.h"
- #include "util_funcs.h"
- #include "thread_globals.h"
-
-
- void
- writeLogPageHeader (
-
- OPENLOG *openLog,
- SHORTPID tailPid
- )
- {
-
- GROUPLINK *tailLink;
- PAGEHASH *tailBuffer;
- LOGPAGEHDR *pageHeader;
- LOGPAGEHDR *endHeader;
- PID pid;
-
-
- TRPRINT(TR_LOG, TR_LEVEL_1, ("tailPid:%d", tailPid));
-
- if(openLog->writeSemaphore.holder != Active) {
- SM_ERROR(TYPE_FATAL, esmINTERNAL);
- }
-
- /* record that the log has a another dirty page to preflush */
- preflushLog();
-
- /* potentially activate a checkpoint */
- activateCheckpoint(FALSE, FALSE, FALSE);
-
- /*
- * create the pid
- */
- pid.volid = openLog->volid;
- pid.page = LOG_PAGE_TO_BLOCK(tailPid, openLog);
-
- /*
- * read the new page
- */
- if ((tailLink = bf_ReadPage(openLog->writeGroup, &pid,
- openLog->page2size, BF_NOREAD)) == NULL) {
-
- SM_ERROR(TYPE_FATAL, Active->errno);
- }
-
- /*
- * Unfix the page. The current page does not have to be fixed as
- * the semaphore on the log protects the currently active page. This
- * is an important assumption that will need to be maintained.
- */
- #ifndef JUNK
- /* REMOVE */
- openLog->tailLink = tailLink;
- #endif
-
- bf_UnfixPage(tailLink, BF_DEFAULT, FALSE);
-
- /*
- * record the pointer
- */
- tailBuffer = tailLink->pageHash;
-
- /*
- * mark that the buffer is a log buffer
- */
- PSET_PAGE_TYPE(tailBuffer, PAGE_LOG);
-
- /*
- * get a pointer to the header and tailer
- */
- pageHeader = (LOGPAGEHDR *) tailBuffer->bufFrame;
- endHeader = (LOGPAGEHDR *) (((char *) pageHeader) + openLog->lastUsableByte);
-
- /*
- * zero out the pge
- */
- bzero(tailBuffer->bufFrame, (int) openLog->pageSize);
-
- /*
- * save the new buffer
- */
- openLog->tailBuffer = tailBuffer;
- openLog->tailLink = tailLink;
-
- /*
- * check to make sure the first mark and the force mark are zero
- */
- SM_ASSERT(LEVEL_3, ((tailBuffer->forceMark == 0) && (tailBuffer->firstMark == 0)));
-
- /*
- * initialize the headers on the page
- */
- pageHeader->magic = LOGPAGE_MAGIC;
- pageHeader->wrapCount = openLog->wrapCount;
- pageHeader->lastRecord = NULL_LAST_RECORD;
- pageHeader->pageNumber = tailPid;
- *endHeader = *pageHeader;
-
- /*
- * dirty the page
- */
- DIRTY_PAGE(tailBuffer);
-
- }
-