ReadLogRecord function (clfsw32.h)

Initiates a sequence of reads from a specified log sequence number (LSN) in one of three modes, and returns the first of the specified log records and a read context. A client can read subsequent records in the designated mode by passing the read context to ReadNextLogRecord.

Syntax

CLFSUSER_API BOOL ReadLogRecord(
  [in]                PVOID             pvMarshal,
  [in]                PCLFS_LSN         plsnFirst,
  [in]                CLFS_CONTEXT_MODE eContextMode,
  [out]               PVOID             *ppvReadBuffer,
  [out]               PULONG            pcbReadBuffer,
  [out]               PCLFS_RECORD_TYPE peRecordType,
  [out]               PCLFS_LSN         plsnUndoNext,
  [out]               PCLFS_LSN         plsnPrevious,
  [out]               PVOID             *ppvReadContext,
  [in, out, optional] LPOVERLAPPED      pOverlapped
);

Parameters

[in] pvMarshal

A pointer to a marshaling context that is allocated by using the CreateLogMarshallingArea function.

[in] plsnFirst

A pointer to a CLFS_LSN structure that specifies the log sequence number (LSN) of the record where the read operation should start.

This value must be an LSN of a valid record in the active range of the log.

[in] eContextMode

The mode for the read context that is returned in *ppvReadContext.

The following table identifies the three mutually exclusive read modes.

Value Meaning
ClfsContextPrevious
Reads the record linked to by plsnPrevious.
ClfsContextUndoNext
Reads the record chain linked to by plsnUndoNext.
ClfsContextForward
Reads the record with the LSN that immediately follows the current LSN in the read context.

[out] ppvReadBuffer

A pointer to a variable that receives a pointer to the target record in the log I/O block.

[out] pcbReadBuffer

A pointer to a variable that receives the size of the data that is returned in *ppvReadBuffer, in bytes.

[out] peRecordType

A pointer to a variable that receives the type of record read.

This parameter is one of the CLFS_RECORD_TYPE Constants.

[out] plsnUndoNext

A pointer to a CLFS_LSN structure that receives the LSN of the next record in the undo record chain.

[out] plsnPrevious

A pointer to a CLFS_LSN structure that receives the LSN of the next record in the previous record chain.

[out] ppvReadContext

A pointer to a variable that receives a pointer to a system-allocated read context when a read is successful.

If the function defers completion of an operation, it returns a valid read-context pointer and an error status of ERROR_IO_PENDING. On all other errors, the read-context pointer is NULL. For more information about handling deferred completion of the function, see the Remarks section of this topic.

After obtaining all requested log records, the client must pass the read context to TerminateReadLog to free the associated memory. Failure to do so results in memory leakage.

Note  Common Log File System (CLFS) read contexts are not thread-safe. They should not be used by more than one thread at a time, or passed into more than one asynchronous read at a time.
 

[in, out, optional] pOverlapped

A pointer to an OVERLAPPED structure, which is required for asynchronous operation.

This parameter can be NULL if asynchronous operation is not used.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

The following list identifies the possible error codes.

Remarks

The error message ERROR_LOG_BLOCK_INCOMPLETE is returned if the log block size specified by CreateLogMarshallingArea is not large enough to hold a complete log block.

If ReadLogRecord is called with a valid pOverlapped structure and the log handle is created with the overlapped option, then if a call to this function fails with an error code of ERROR_IO_PENDING, a pointer to a valid read context is placed in the variable that is pointed to by the ppvReadContext parameter.

If you attempt to open more read contexts than the number buffers specified in a previous call to CreateLogMarshallingArea, ERROR_LOG_BLOCK_EXHAUSTED is returned.

To complete a log-record copy, the client should first synchronize its execution with deferred completion of the overlapped I/O operation by using GetOverlappedResult or one of the synchronization Wait Functions. For more information, see Synchronization and Overlapped Input and Output.

After ReadLogRecord completes asynchronously, the requested record is read from the disk, but is not resolved to a pointer in *ppvReadBuffer.

To complete the requested read and obtain a valid pointer to the log record, the client must call ReadNextLogRecord, which passes in the read-context pointer that ReadLogRecord returns.

Note  Common Log File System (CLFS) read contexts are not thread-safe. They should not be used by more than one thread at a time.

CLFS read contexts should not be passed into more than one asynchronous read at a time, or the function fails with ERROR_BUSY.

 

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2003 R2 [desktop apps only]
Target Platform Windows
Header clfsw32.h
Library Clfsw32.lib
DLL Clfsw32.dll

See also

CLFS_CONTEXT_MODE

CLFS_LSN

CLFS_RECORD_TYPE

Common Log File System Functions

CreateLogMarshallingArea

OVERLAPPED

ReadNextLogRecord

TerminateReadLog