YggOpenDocLog.mesa
Copyright Ó 1985, 1988 by Xerox Corporation. All rights reserved.
Last edited by:
MBrown on January 30, 1984 5:24:32 pm PST
Taft on April 6, 1983 5:14 pm
Hauser, March 7, 1985 2:56:14 pm PST
Carl Hauser, October 20, 1987 2:49:15 pm PDT
Bob Hagmann May 5, 1988 11:54:01 am PDT
This interface captures all interactions between the AlpineFile implementation and the Log.
DIRECTORY
ConstArith,
YggEnvironment,
YggInternal,
YggOpenDoc,
YggDIDMap,
YggTransactionMap;
YggOpenDocLog: DEFINITIONS =
BEGIN
LockSubID: TYPE = YggInternal.LockSubID;
LogRecordID: TYPE = YggInternal.LogRecordID;
OwnerName: TYPE = YggEnvironment.OwnerName;
PageCount: TYPE = YggEnvironment.PageCount;
PageRun: TYPE = YggEnvironment.PageRun;
ReferencePattern: TYPE = YggEnvironment.ReferencePattern;
TransState: TYPE = YggInternal.TransState;
VolumeID: TYPE = YggEnvironment.VolumeID;
TransID: TYPE = YggEnvironment.TransID;
RecordID: TYPE = YggInternal.LogRecordID;
logDocID: TYPE = CARD; -- unique ID for the document only used in the log
Exported from YggOpenDocLogImpl, for writing and reading log records during normal operation
LogCreate: PROCEDURE [openDoc: YggOpenDoc.OpenDoc, initialSize: PageCount, owner: OwnerName];
! Log.WriteFailed;
Logs the creation of a file (as an undo action). Note: this operation forces the log to stable storage.
LogDelete: PROCEDURE [openDoc: YggOpenDoc.OpenDoc];
! Log.WriteFailed;
Logs the deletion of a file (as a deferred action).
LogSetSize: PROCEDURE [openDoc: YggOpenDoc.OpenDoc, old, new: PageCount];
! Log.WriteFailed;
Logs a change in the size of a file. old should be the committed size of the file. This is a deferred action if new<old, an undo action if new>old.
LogWritePages: PROCEDURE [openDoc: YggOpenDoc.OpenDoc, where: LONG POINTER, pageRun: PageRun, referencePattern: ReferencePattern] RETURNS [recordID: LogRecordID];
! Log.WriteFailed;
Writes a writePages log record from memory.
LogReadPages: PROCEDURE [openDoc: YggOpenDoc.OpenDoc, where: LONG POINTER, pageRun: PageRun, recordID: LogRecordID] RETURNS [referencePattern: ReferencePattern];
Reads the specified pageRun interval of the file designated by openDoc into memory starting at where. recordID identifies a writePages record which the caller asserts includes the requested interval. Returns the ReferencePattern which was passed to LogWritePages. A fatal error occurs if pageRun is not a subinterval of the pageRun actually contained in the log record or if the log record describes a write to the wrong file.
LogFileLock: PROCEDURE [openDoc: YggOpenDoc.OpenDoc];
! Log.WriteFailed;
Logs the setting of a file write lock (only write locks are logged).
Imported by FileLogImpl, for processing log records during recovery. Each takes as arguments the information that was passed to the corresponding WriteXXX procedure which wrote the log record, plus the transaction outcome which is {committed, aborted, ready}. Note that the calls are made only for files which still exist at recovery time. Exported by FileActionsImpl.
RecoverCreate: PROCEDURE [openDoc: YggOpenDoc.OpenDoc, initialSize: PageCount, outcome: TransState];
Note: type and owner are not passed, as they are not actually needed for recovery, and constructing an owner string from the log record is a messy job.
RecoverDelete: PROCEDURE [openDoc: YggOpenDoc.OpenDoc, outcome: TransState];
RecoverSetSize: PROCEDURE [openDoc: YggOpenDoc.OpenDoc, old, new: PageCount, recordID: LogRecordID, outcome: TransState];
RecoverWritePages: PROCEDURE [openDoc: YggOpenDoc.OpenDoc, recordID: LogRecordID, pageRun: PageRun, outcome: TransState];
RecoverLock: PROCEDURE [openDoc: YggOpenDoc.OpenDoc, lockSubID: LockSubID, outcome: TransState];
AnalyzeSetSizes: PROCEDURE;
Called after the log analysis pass to figure out what the size history of each file must be during recovery. All this is necessary because of direct writing to files above the high water mark, which makes changing their size during recovery incorrect until you know the ultimate committed length.
DoSetSizes: PROCEDURE;
Called after the log update pass to establish each file at the correct length.
Log record representation
DefinedFileRecord: TYPE = YggInternal.FileRecord[writePages..lock];
fixedFLRSize: INT = WORDS[logDocID];
FileLogRecord: PRIVATE TYPE = MACHINE DEPENDENT RECORD [
fileID (0): logDocID,
specifics (fixedFLRSize): SELECT COMPUTED DefinedFileRecord FROM
writePages => [
pageRun (fixedFLRSize): PageRun, referencePattern (fixedFLRSize+WORDS[PageRun]): ReferencePattern, data (fixedFLRSize+WORDS[PageRun]+WORDS[ReferencePattern]): DataRep],
setSize => [old (fixedFLRSize), new (fixedFLRSize+WORDS[PageCount]): PageCount],
old is needed for undo actions, which arise only if new>old.
create => [initialSize (fixedFLRSize): PageCount, owner (fixedFLRSize+WORDS[PageCount]): StringRep],
delete => [],
lock => [lockSubID (fixedFLRSize): LockSubID],
ENDCASE];
DataRep: PRIVATE TYPE = MACHINE DEPENDENT RECORD [
ARRAY [0..0) OF WORD];
StringRep: PRIVATE TYPE = MACHINE DEPENDENT RECORD [
length (0): CARDINAL,
text (1): PACKED ARRAY [0..0) OF CHARACTER];
SetSizeList: TYPE = LIST OF SetSizeItem;
SetSizeItem: TYPE = RECORD [
old, new: PageCount,
trans: TransID,
record: RecordID,
file: YggDIDMap.Document
];
END.
Hauser, March 7, 1985 2:55:53 pm PST
Added copyright.
Carl Hauser, October 16, 1987 10:46:27 am PDT
Add AnalyzeSetSizes, DoSetSizes. Add SizeList stuff.