libjf API reference guide

Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

jf_journal_recovery.h File Reference

#include <jf/jf_config.h>
#include <jf_journal.h>

Go to the source code of this file.

Data Structures

struct  jf_journal_record_s

Defines

#define JF_JOURNAL_ANALYZE_RECOVERY   0x10
#define JF_JOURNAL_ANALYZE_TRACE   0x01
#define JF_JOURNAL_ANALYZE_TRACE_HEX_DATA   0x02
#define JF_JOURNAL_ANALYZE_TRACE_TEXT_DATA   0x04
#define JF_TRACE_MODULE   JF_TRACE_MOD_LIB_JOURNAL_RECOVERY

Enumerations

enum  jf_journal_scan_status_t { JF_SCAN_SEARCH, JF_SCAN_REDO, JF_SCAN_UNDO, JF_SCAN_END }

Functions

LIBJF_EXPORT int jf_journal_analyze (const char *path, uint32_t flags, FILE *out_stream)
int jf_journal_apply_changes (const jf_journal_t *journal, const struct jf_journal_record_s *jr)
const char * jf_journal_describe_code (const jf_word_t ctrl_code)
int jf_journal_fetch_record (const jf_journal_t *journal, struct jf_journal_record_s *jr, int forward)
void jf_journal_record_destroy (struct jf_journal_record_s *jr)
void jf_journal_record_reset (struct jf_journal_record_s *jr)
int jf_journal_remove_changes (const jf_journal_t *journal, const struct jf_journal_record_s *jr)
int jf_journal_reopen_files (jf_journal_t *journal)
int jf_journal_scan (jf_journal_t *journal, jf_word_t file_id, uint32_t flags, int forward, FILE *out_stream)
int jf_journal_scan_redo (jf_journal_t *journal, struct jf_journal_record_s *jr, jf_journal_scan_status_t *status)
int jf_journal_scan_search (jf_journal_t *journal, struct jf_journal_record_s *jr, jf_journal_scan_status_t *status, jf_offset_t last_sync, int forward, uint32_t flags)
int jf_journal_scan_undo (jf_journal_t *journal, jf_word_t file_id, struct jf_journal_record_s *jr, jf_journal_scan_status_t *status)
int jf_journal_trace_record (const jf_journal_t *journal, const struct jf_journal_record_s *jr, jf_offset_t record_offset, FILE *out_stream, uint32_t flags)


Define Documentation

#define JF_JOURNAL_ANALYZE_RECOVERY   0x10
 

Recovery journaled file content Definition at line 68 of file jf_journal_recovery.h.

Referenced by jf_journal_analyze(), jf_journal_rollback_int(), and jf_journal_scan_search().

#define JF_JOURNAL_ANALYZE_TRACE   0x01
 

Trace the content of a journal file on stdout Definition at line 53 of file jf_journal_recovery.h.

Referenced by jf_journal_analyze(), jf_journal_cold_recovery(), jf_journal_cold_recovery_analyze(), jf_journal_cold_recovery_patch(), jf_journal_cold_recovery_patch_record(), jf_journal_cold_recovery_patch_seq(), jf_journal_cold_recovery_prep_pool(), jf_journal_scan(), and main().

#define JF_JOURNAL_ANALYZE_TRACE_HEX_DATA   0x02
 

Dump data using hexadecimal format Definition at line 58 of file jf_journal_recovery.h.

Referenced by jf_journal_cold_recovery(), jf_journal_trace_record(), and main().

#define JF_JOURNAL_ANALYZE_TRACE_TEXT_DATA   0x04
 

Dump data using text format Definition at line 63 of file jf_journal_recovery.h.

Referenced by jf_journal_cold_recovery(), jf_journal_trace_record(), and main().

#define JF_TRACE_MODULE   JF_TRACE_MOD_LIB_JOURNAL_RECOVERY
 

Definition at line 40 of file jf_journal_recovery.h.


Enumeration Type Documentation

enum jf_journal_scan_status_t
 

Available scan automata status: used by jf_journal_scan, jf_journal_scan_search, jf_journal_scan_redo, ...

Enumeration values:
JF_SCAN_SEARCH 
JF_SCAN_REDO 
JF_SCAN_UNDO 
JF_SCAN_END 
Definition at line 169 of file jf_journal_recovery.h.

Referenced by jf_journal_scan().


Function Documentation

LIBJF_EXPORT int jf_journal_analyze const char *  path,
uint32_t  flags,
FILE *  out_stream
 

Analyze the content of a journal file and does some actions related to flags argument; this is a "static" method because it does NOT need a journal object: this method MUST BE INVOKED ON CLOSED journal files to avoid conflicts

Parameters:
path IN file name of the journal file
flags IN operation must be performed on journaled files
out_stream IN a standard I/O stream can be used for output data (if NULL, stdout is used)
Returns:
a reason code
Definition at line 70 of file jf_journal_recovery.c.

References CATCH, jf_journal_t::file_table, fseeko, JF_JOURNAL_ANALYZE_RECOVERY, JF_JOURNAL_ANALYZE_TRACE, jf_journal_file_get_last_pos(), jf_journal_file_tab_get_jfile(), JF_JOURNAL_GLOBAL_FILE_ID, JF_JOURNAL_JOURNAL_FILE_ID, jf_journal_load(), jf_journal_reset(), jf_journal_scan(), jf_journal_trace(), JF_RC_FCLOSE_ERROR, JF_RC_FOPEN_ERROR, JF_RC_INTERNAL_ERROR, JF_RC_OK, JF_TRACE, THROW, and TRUE.

Referenced by main().

int jf_journal_apply_changes const jf_journal_t journal,
const struct jf_journal_record_s jr
 

Apply changes to journaled file

Parameters:
journal IN/OUT journal object
jr IN journal record containing changes must be applied
Returns:
a reason code
Definition at line 1116 of file jf_journal_recovery.c.

References CATCH, jf_journal_t::file_id_mask, jf_journal_t::file_id_mask_shift, jf_journal_t::file_table, fseeko, jf_journal_file_get_last_uc_size(), jf_journal_file_get_status(), jf_journal_file_get_stream(), jf_journal_file_set_last_uc_size(), JF_JOURNAL_FILE_ST_OPEN, jf_journal_file_tab_get_jfile(), jf_journal_file_tab_get_number_of_files(), JF_JOURNAL_JOURNAL_FILE_ID, JF_JOURNAL_OP_CODE_APPEND, JF_JOURNAL_OP_CODE_MASK, JF_JOURNAL_OP_CODE_UPDATE, jf_offset_t, JF_RC_FSEEK_ERROR, JF_RC_FWRITE_ERROR, JF_RC_INTERNAL_ERROR, JF_RC_INVALID_CTRL_CODE, JF_RC_INVALID_STATUS, JF_RC_OK, JF_TRACE, jf_word_t, jf_journal_record_s::offset, jf_journal_record_s::redo_code, jf_journal_record_s::redo_data, jf_journal_t::size_mask, jf_journal_t::size_mask_shift, and THROW.

Referenced by jf_journal_cold_recovery_patch_record(), and jf_journal_scan_redo().

const char* jf_journal_describe_code const jf_word_t  ctrl_code  ) 
 

Return a string describing a control code

Parameters:
ctrl_code IN control code should be described
Returns:
record description
Definition at line 1294 of file jf_journal_recovery.c.

References JF_JOURNAL_OP_CODE_APPEND, JF_JOURNAL_OP_CODE_SYNC, JF_JOURNAL_OP_CODE_UPDATE, JF_JOURNAL_OP_DO, JF_JOURNAL_OP_MASK, and jf_word_t.

Referenced by jf_journal_fetch_ctrl_code(), and jf_journal_fetch_record().

int jf_journal_fetch_record const jf_journal_t journal,
struct jf_journal_record_s jr,
int  forward
 

Fetch a record from journal file

Parameters:
journal IN journal object
jr OUT fetched journal record
forward IN boolean value: TRUE = forward fetch, FALSE = backward fetch
Returns:
a reason code
Definition at line 807 of file jf_journal_recovery.c.

References byte_t, CATCH, fseeko, ftello, jf_journal_describe_code(), jf_journal_get_stream(), JF_JOURNAL_OP_CODE_APPEND, JF_JOURNAL_OP_CODE_MASK, JF_JOURNAL_OP_CODE_NULL, JF_JOURNAL_OP_CODE_SYNC, JF_JOURNAL_OP_CODE_UPDATE, JF_JOURNAL_OP_DO, JF_JOURNAL_OP_MASK, jf_offset_t, JF_OFFSET_T_FORMAT, JF_RC_EOF, JF_RC_FREAD_ERROR, JF_RC_FSEEK_ERROR, JF_RC_FTELL_ERROR, JF_RC_INTERNAL_ERROR, JF_RC_INVALID_CTRL_CODE, JF_RC_INVALID_STREAM_POSITION, JF_RC_OK, JF_RC_REALLOC_ERROR, JF_TRACE, jf_word_t, JF_WORD_T_FORMAT, jf_journal_t::journal_recs, jf_journal_record_s::offset, jf_journal_record_s::redo_code, jf_journal_record_s::redo_data, jf_journal_record_s::redo_data_alloc, jf_journal_t::size_mask, jf_journal_t::size_mask_shift, THROW, jf_journal_record_s::undo_code, jf_journal_record_s::undo_data, and jf_journal_record_s::undo_data_alloc.

Referenced by jf_journal_cold_recovery_patch_record(), jf_journal_scan_redo(), jf_journal_scan_search(), and jf_journal_scan_undo().

void jf_journal_record_destroy struct jf_journal_record_s jr  ) 
 

Release dynamic memory allocated for journal record

Parameters:
jr IN/OUT data must be resetted
Definition at line 55 of file jf_journal_recovery.c.

References jf_journal_record_reset(), jf_journal_record_s::redo_data, and jf_journal_record_s::undo_data.

Referenced by jf_journal_cold_recovery_patch_seq(), and jf_journal_scan().

void jf_journal_record_reset struct jf_journal_record_s jr  ) 
 

Reset a journal record

Parameters:
jr OUT data must be resetted
Definition at line 43 of file jf_journal_recovery.c.

References JF_JOURNAL_OP_CODE_NULL, jf_journal_record_s::redo_code, jf_journal_record_s::redo_data, jf_journal_record_s::redo_data_alloc, jf_journal_record_s::undo_code, jf_journal_record_s::undo_data, and jf_journal_record_s::undo_data_alloc.

Referenced by jf_journal_cold_recovery_patch_seq(), jf_journal_record_destroy(), and jf_journal_scan().

int jf_journal_remove_changes const jf_journal_t journal,
const struct jf_journal_record_s jr
 

Remove changes from journaled file

Parameters:
journal IN/OUT journal object
jr IN journal record containing changes must be removed
Returns:
a reason code
Definition at line 1204 of file jf_journal_recovery.c.

References CATCH, jf_journal_t::file_id_mask, jf_journal_t::file_id_mask_shift, jf_journal_t::file_table, fseeko, JF_CRASH_SIMUL, JF_CRASH_SIMUL_F_REMOVE_CHANGES_1, jf_journal_file_get_status(), jf_journal_file_get_stream(), JF_JOURNAL_FILE_ST_OPEN, JF_JOURNAL_FILE_ST_SYNC, jf_journal_file_tab_get_jfile(), jf_journal_file_tab_get_number_of_files(), JF_JOURNAL_JOURNAL_FILE_ID, JF_JOURNAL_OP_CODE_APPEND, JF_JOURNAL_OP_CODE_MASK, JF_JOURNAL_OP_CODE_UPDATE, JF_OFFSET_T_FORMAT, JF_RC_FSEEK_ERROR, JF_RC_FWRITE_ERROR, JF_RC_INTERNAL_ERROR, JF_RC_INVALID_CTRL_CODE, JF_RC_INVALID_STATUS, JF_RC_OK, JF_TRACE, jf_word_t, JF_WORD_T_FORMAT, jf_journal_record_s::offset, jf_journal_t::size_mask, jf_journal_t::size_mask_shift, THROW, jf_journal_record_s::undo_code, and jf_journal_record_s::undo_data.

Referenced by jf_journal_cold_recovery_patch_record(), and jf_journal_scan_undo().

int jf_journal_reopen_files jf_journal_t journal  ) 
 

Re-open all journaled file opened at last journal sync time

Parameters:
journal IN/OUT journal object
Returns:
a reason code
Definition at line 756 of file jf_journal_recovery.c.

References CATCH, jf_journal_t::file_table, jf_file_open(), jf_journal_file_get_path(), jf_journal_file_get_status(), jf_journal_file_get_stream(), JF_JOURNAL_FILE_ST_OPEN, jf_journal_file_tab_get_jfile(), jf_journal_file_tab_get_number_of_files(), JF_RC_INTERNAL_ERROR, JF_RC_OK, JF_TRACE, jf_word_t, and THROW.

Referenced by jf_journal_scan().

int jf_journal_scan jf_journal_t journal,
jf_word_t  file_id,
uint32_t  flags,
int  forward,
FILE *  out_stream
 

Scan the content of a journal NOTE: this is a "private" method

Parameters:
journal IN journal object
file_id IN identificator of the file(s) is in commit/rollback phase
flags IN operation must be performed on journaled files
forward IN if TRUE, scan is performed forward, if FALSE, scan is performed backward
out_stream IN a standard I/O stream can be used for output data
Returns:
a reason code
Definition at line 161 of file jf_journal_recovery.c.

References CATCH, fseeko, ftello, JF_JOURNAL_ANALYZE_TRACE, jf_journal_get_stream(), jf_journal_record_destroy(), jf_journal_record_reset(), jf_journal_reopen_files(), jf_journal_scan_redo(), jf_journal_scan_search(), jf_journal_scan_status_t, jf_journal_scan_undo(), jf_journal_trace_record(), jf_offset_t, JF_RC_EOF, JF_RC_FSEEK_ERROR, JF_RC_FTELL_ERROR, JF_RC_INTERNAL_ERROR, JF_RC_OK, JF_SCAN_END, JF_SCAN_REDO, JF_SCAN_SEARCH, JF_SCAN_UNDO, JF_TRACE, jf_word_t, JF_WORD_T_FORMAT, THROW, and TRUE.

Referenced by jf_journal_analyze(), and jf_journal_rollback_int().

int jf_journal_scan_redo jf_journal_t journal,
struct jf_journal_record_s jr,
jf_journal_scan_status_t status
 

Scan the journal content and "redo" changes (commit phase)

Parameters:
journal IN journal object
jr OUT last journal fetched record
status IN/OUT old/new automata status
Returns:
a reason code
Definition at line 403 of file jf_journal_recovery.c.

References CATCH, jf_journal_apply_changes(), jf_journal_fetch_record(), JF_JOURNAL_OP_CODE_COMMIT, JF_JOURNAL_OP_CODE_ROLLBACK, JF_JOURNAL_OP_MASK, JF_RC_EOF, JF_RC_INTERNAL_ERROR, JF_RC_OK, JF_TRACE, jf_word_t, jf_journal_record_s::redo_code, THROW, and TRUE.

Referenced by jf_journal_scan().

int jf_journal_scan_search jf_journal_t journal,
struct jf_journal_record_s jr,
jf_journal_scan_status_t status,
jf_offset_t  last_sync,
int  forward,
uint32_t  flags
 

Scan the journal content searching next commit point

Parameters:
journal IN journal object
jr IN/OUT journal file fetched record
status IN/OUT automata status
last_sync IN last synchronization point
forward IN if TRUE, scan is performed forward, if FALSE, scan is performed backward
flags IN operation must be performed on journaled files
Returns:
a reason code
Definition at line 307 of file jf_journal_recovery.c.

References CATCH, jf_journal_t::file_id_mask, jf_journal_t::file_id_mask_shift, fseeko, JF_JOURNAL_ANALYZE_RECOVERY, jf_journal_fetch_record(), jf_journal_get_stream(), JF_JOURNAL_OP_CODE_COMMIT, JF_JOURNAL_OP_CODE_ROLLBACK, JF_JOURNAL_OP_MASK, jf_offset_t, JF_RC_EOF, JF_RC_FSEEK_ERROR, JF_RC_INTERNAL_ERROR, JF_RC_OK, JF_SCAN_REDO, JF_SCAN_UNDO, JF_TRACE, jf_word_t, jf_journal_record_s::redo_code, THROW, and jf_journal_record_s::undo_code.

Referenced by jf_journal_scan().

int jf_journal_scan_undo jf_journal_t journal,
jf_word_t  file_id,
struct jf_journal_record_s jr,
jf_journal_scan_status_t status
 

Scan the journal content and "undo" changes (rollback phase)

Parameters:
journal IN journal object
file_id IN identificator of the file(s) is in commit/rollback phase
jr OUT last journal fetched record
status IN/OUT old/new automata status
Returns:
a reason code
Definition at line 464 of file jf_journal_recovery.c.

References CATCH, FALSE, jf_journal_t::file_id_mask, jf_journal_t::file_id_mask_shift, jf_journal_t::file_table, fseeko, jf_journal_fetch_record(), jf_journal_file_get_status(), jf_journal_file_set_status(), JF_JOURNAL_FILE_ST_SYNC, jf_journal_file_tab_get_jfile(), jf_journal_get_stream(), JF_JOURNAL_GLOBAL_FILE_ID, jf_journal_is_sync(), JF_JOURNAL_OP_CODE_COMMIT, JF_JOURNAL_OP_CODE_ROLLBACK, JF_JOURNAL_OP_MASK, jf_journal_remove_changes(), jf_journal_set_all_sync(), jf_offset_t, JF_RC_EOF, JF_RC_FSEEK_ERROR, JF_RC_INTERNAL_ERROR, JF_RC_OK, JF_TRACE, jf_word_t, JF_WORD_T_FORMAT, THROW, and jf_journal_record_s::undo_code.

Referenced by jf_journal_scan().

int jf_journal_trace_record const jf_journal_t journal,
const struct jf_journal_record_s jr,
jf_offset_t  record_offset,
FILE *  out_stream,
uint32_t  flags
 

Trace the content of a journal record

Parameters:
journal IN journal object
jr IN journal record must be traced; NOTE: the journal record MUST be a well-formed record retrieved for example by jf_journal_fetch_record without errors
record_offset IN offset of the record in journal stream
out_stream IN a standard I/O stream can be used for output data
flags IN specify which type of data must be traced (see JF_JOURNAL_ANALYZE_TRACE_HEX_DATA, JF_JOURNAL_ANALYZE_TRACE_TEXT_DATA)
Returns:
a reason code
Definition at line 1316 of file jf_journal_recovery.c.

References CATCH, jf_journal_t::file_id_mask, jf_journal_t::file_id_mask_shift, JF_JOURNAL_ANALYZE_TRACE_HEX_DATA, JF_JOURNAL_ANALYZE_TRACE_TEXT_DATA, JF_JOURNAL_OP_CODE_APPEND, JF_JOURNAL_OP_CODE_MASK, JF_JOURNAL_OP_CODE_SYNC, JF_JOURNAL_OP_CODE_UPDATE, JF_JOURNAL_OP_DO, JF_JOURNAL_OP_MASK, jf_offset_t, JF_OFFSET_T_FORMAT, JF_RC_INTERNAL_ERROR, JF_RC_INVALID_CTRL_CODE, JF_RC_OK, JF_TRACE, jf_trace_hex_data(), jf_trace_text_data(), jf_word_t, JF_WORD_T_FORMAT, jf_journal_record_s::offset, jf_journal_record_s::redo_code, jf_journal_record_s::redo_data, jf_journal_t::size_mask, jf_journal_t::size_mask_shift, THROW, and jf_journal_record_s::undo_data.

Referenced by jf_journal_cold_recovery_patch_record(), and jf_journal_scan().


Copyright 2005 © Tiian