home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: setLogStartLocation.c,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:55:50 $
- */
- /**********************************************************************
- * 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 "logaction.h"
- #include "threadstate.h"
- #include "util_funcs.h"
- #include "bf_extfuncs.h"
- #include "log_intfuncs.h"
- #include "log_extfuncs.h"
- #include "thread_funcs.h"
- #include "thread_globals.h"
- #include "log_globals.h"
- #include "trans_globals.h"
- #include "distr.h"
- #include "distr_globals.h"
-
-
- /*
- * FUNCTION DESCRIPTION:
- *
- * This function moves the current end of the log to the next page.
- * It takes a checkpoint, whose log record is written to the new page.
- * The log's wrap count is adjusted so that it is >= the parameter wrapCount.
- *
- * WARNING: this function should only be called on storage manager
- * startup. There cannot be any logging activity.
- */
-
- int
- setLogStartLocation (
- int wrapCount
- )
- {
- SHORTPID startpid;
- register OPENLOG *openLog;
- int dirtyPages;
- #ifdef DEBUG
- LSN debugLSN;
- #endif
- TRPRINT(TR_LOG, TR_LEVEL_1, ("start wrap count:%d", wrapCount));
-
- openLog = &OpenLog;
-
- /*
- * make sure there are no dirty pages
- */
- dirtyPages = checkPointDirtyPages();
- SM_ASSERT(LEVEL_3, dirtyPages == 0);
-
- /*
- * check whether there are any prepared transactions
- */
- if ((numActiveServerDistrTrans + numActiveCoordDistrTrans) > 0) {
- /*
- * we cannot boost the wrapCount because we have
- * active transactions left over
- * print user message
- */
- fprintf(sm_ErrorStream,
- "WARNING: Active transactions left over; cannot boost wrap count.\n");
-
- wrapCount = openLog->wrapCount;
-
- } else {
-
- /* wrapcount must be larger than the current one */
- if (wrapCount <= openLog->wrapCount) {
- wrapCount = openLog->wrapCount+1;
- }
- }
-
- /* use the tailLSN left over from recovery */
- startpid = ((LSN_TO_LOG_PAGE(openLog->tailLSN, openLog) + 1)
- % openLog->filePages);
- if(startpid == 0) {
- /* we wrapped */
- wrapCount++;
- }
- openLog->tailLSN = LOG_PAGE_TO_LSN(startpid, openLog);
- openLog->tailPid = startpid;
- openLog->wrapCount = wrapCount;
-
- LastFlushedCheckpoint.wrapCount = openLog->wrapCount;
- LastFlushedCheckpoint.offset = openLog->tailLSN;
- OldestDirtyPageLSN = LastFlushedCheckpoint;
-
- #ifdef DEBUG
- /* make sure we don't overwrite important log records */
- debugLSN.offset = openLog->tailLSN;
- debugLSN.wrapCount = openLog->wrapCount;
- debugLSN.wrapCount--;
- if(compareLSN(&debugLSN, &OldestDirtyPageLSN) >= 0) {
- SM_ERROR(TYPE_FATAL, esmINTERNAL);
- }
- #endif
-
- activateCheckpoint(TRUE, FALSE, TRUE);
-
- return(esmNOERROR);
- }
-