libjf API reference guide

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

jf_journal.h File Reference

#include <jf/jf_config.h>
#include <jf/jf_defines.h>
#include <jf/jf_trace.h>
#include <jf/jf_journal_file_tab.h>

Go to the source code of this file.

Data Structures

struct  jf_journal_currec_s
struct  jf_journal_opts_s
struct  jf_journal_t

Defines

#define JF_JOURNAL_2_64_BASE_10_DIGITS   20
#define JF_JOURNAL_DEFAULT_FILE_NUM   ((jf_word_t)3)
#define JF_JOURNAL_DEFAULT_FILE_SIZE   ((jf_offset_t)(4*1024*1024))
#define JF_JOURNAL_DEFAULT_ROTATION_THRESHOLD   ((double)0.8)
#define JF_JOURNAL_FILE_NUM_MIN   ((jf_word_t)1)
#define JF_JOURNAL_FIRST_FILE_ID   0x1
#define JF_JOURNAL_JOURNAL_FILE_ID   0x0
#define JF_JOURNAL_MAGIC_NUMBER   0x41524153
#define JF_JOURNAL_MAX_FILES   ((jf_word_t)(64 * 1024))
#define JF_JOURNAL_NUM_ENV_VAR   "JF_JOURNAL_NUM"
#define JF_JOURNAL_OP_CODE_APPEND   0x2
#define JF_JOURNAL_OP_CODE_COMMIT   (JF_JOURNAL_OP_CODE_SYNC | JF_JOURNAL_OP_DO)
#define JF_JOURNAL_OP_CODE_MASK   (JF_JOURNAL_OP_CODE_APPEND | JF_JOURNAL_OP_CODE_UPDATE | JF_JOURNAL_OP_CODE_SYNC)
#define JF_JOURNAL_OP_CODE_NULL   0x0
#define JF_JOURNAL_OP_CODE_ROLLBACK   JF_JOURNAL_OP_CODE_SYNC
#define JF_JOURNAL_OP_CODE_SYNC   0x6
#define JF_JOURNAL_OP_CODE_UPDATE   0x4
#define JF_JOURNAL_OP_DO   0x1
#define JF_JOURNAL_OP_MASK   (JF_JOURNAL_OP_CODE_MASK | JF_JOURNAL_OP_DO)
#define JF_JOURNAL_PROP_OPEN_O_CREAT   0x00000100
#define JF_JOURNAL_PROP_OPEN_O_EXCL   0x00000200
#define JF_JOURNAL_PROP_SYNC_DEFAULT   JF_JOURNAL_PROP_SYNC_ENV_VAR
#define JF_JOURNAL_PROP_SYNC_ENV_VAR   0x00000040
#define JF_JOURNAL_PROP_SYNC_FAST   0x00000010
#define JF_JOURNAL_PROP_SYNC_SAFE   0x00000020
#define JF_JOURNAL_PROP_SYNC_SUGGESTED   JF_JOURNAL_PROP_SYNC_FAST
#define JF_JOURNAL_PROP_VIRTMEM_DEFAULT   JF_JOURNAL_PROP_VIRTMEM_ENV_VAR
#define JF_JOURNAL_PROP_VIRTMEM_ENV_VAR   0x00000008
#define JF_JOURNAL_PROP_VIRTMEM_HIGH   0x00000004
#define JF_JOURNAL_PROP_VIRTMEM_LOW   0x00000001
#define JF_JOURNAL_PROP_VIRTMEM_MEDIUM   0x00000002
#define JF_JOURNAL_PROP_VIRTMEM_SUGGESTED   JF_JOURNAL_PROP_VIRTMEM_MEDIUM
#define JF_JOURNAL_ROT_THRESH_ENV_VAR   "JF_JOURNAL_ROTATION_THRESHOLD"
#define JF_JOURNAL_SIZE_ENV_VAR   "JF_JOURNAL_SIZE"
#define JF_JOURNAL_SYNC_TYPE_ENV_VAR   "JF_JOURNAL_SYNC_TYPE"
#define JF_JOURNAL_TRACE(j, m)
#define JF_JOURNAL_VERSION   1
#define JF_JOURNAL_VIRTMEM_ENV_VAR   "JF_JOURNAL_VIRTMEM"
#define JF_TRACE_MODULE   JF_TRACE_MOD_LIB_JOURNAL

Functions

int jf_journal_add_byte_data (jf_journal_t *journal, jf_word_t file_id, const byte_t *data, jf_word_t size)
int jf_journal_add_c (jf_journal_t *journal, jf_word_t file_id, int c)
int jf_journal_attach_file (jf_journal_t *journal, jf_journal_file_t *jf, jf_word_t *file_id)
LIBJF_EXPORT int jf_journal_close (jf_journal_t *journal)
int jf_journal_close_detach_file (jf_journal_t *journal, jf_word_t file_id)
int jf_journal_commit (jf_journal_t *journal)
int jf_journal_commit_int (jf_journal_t *journal, jf_word_t file_id)
int jf_journal_create (jf_journal_t *journal, const char *path, jf_word_t max_files, FILE **stream, const struct jf_journal_opts_s *options)
int jf_journal_get_byte_data (jf_journal_t *journal, jf_word_t file_id, byte_t *data, size_t size, size_t *read)
int jf_journal_get_c (jf_journal_t *journal, jf_word_t file_id, int *c)
jf_journal_file_tjf_journal_get_jfile (jf_journal_t *journal, jf_word_t file_id)
uint32_t jf_journal_get_open_opts_flags (const jf_journal_t *journal)
int jf_journal_get_real_path (const char *path, char **real_path)
FILE * jf_journal_get_stream (const jf_journal_t *journal)
int jf_journal_init (jf_journal_t *journal, const struct jf_journal_opts_s *open_opts)
int jf_journal_is_all_sync (const jf_journal_t *journal)
int jf_journal_is_sync (const jf_journal_t *journal, jf_word_t file_id)
int jf_journal_load (jf_journal_t *journal, FILE *stream)
int jf_journal_new_unit_of_work (jf_journal_t *journal, jf_word_t file_id)
LIBJF_EXPORT int jf_journal_open (jf_journal_t *journal, const char *path, jf_word_t max_files, const struct jf_journal_opts_s *options)
int jf_journal_open_attach_file (jf_journal_t *journal, const char *path, const char *mode, jf_word_t *file_id, int join, const struct jf_journal_file_opts_s *options)
void jf_journal_reset (jf_journal_t *journal)
int jf_journal_restore_files (const char *path)
int jf_journal_rollback (jf_journal_t *journal)
int jf_journal_rollback_int (jf_journal_t *journal, jf_word_t file_id)
int jf_journal_rotate (jf_journal_t *journal)
int jf_journal_set_all_sync (jf_journal_t *journal)
int jf_journal_shift_files (const jf_journal_t *journal)
int jf_journal_sync (jf_journal_t *journal)
int jf_journal_trace (const jf_journal_t *journal, const char *method, FILE *out_stream)
int jf_journal_update_file_table (const jf_journal_t *journal, jf_word_t file_id, uint32_t flags)
int jf_journal_write_record (jf_journal_t *journal, jf_word_t file_id, jf_offset_t chunk_id)
int jf_journal_write_records (jf_journal_t *journal, jf_word_t file_id)
void jf_set_default_journal_opts (struct jf_journal_opts_s *options)

Variables

const char * JF_JOURNAL_EXTENSION
const char * JF_JOURNAL_TMP_EXTENSION


Define Documentation

#define JF_JOURNAL_2_64_BASE_10_DIGITS   20
 

"20" is not a magic number, but the number of digits must be used to write 2^64 using base10 notation Definition at line 258 of file jf_journal.h.

Referenced by jf_journal_shift_files().

#define JF_JOURNAL_DEFAULT_FILE_NUM   ((jf_word_t)3)
 

Default number of old journals should be kept Definition at line 247 of file jf_journal.h.

Referenced by jf_set_default_journal_opts().

#define JF_JOURNAL_DEFAULT_FILE_SIZE   ((jf_offset_t)(4*1024*1024))
 

Default size for a journal file Definition at line 237 of file jf_journal.h.

Referenced by jf_set_default_journal_opts().

#define JF_JOURNAL_DEFAULT_ROTATION_THRESHOLD   ((double)0.8)
 

Default rotation threshold Definition at line 252 of file jf_journal.h.

Referenced by jf_set_default_journal_opts().

#define JF_JOURNAL_FILE_NUM_MIN   ((jf_word_t)1)
 

Min number of old journal can be kept Definition at line 242 of file jf_journal.h.

Referenced by jf_set_default_journal_opts().

#define JF_JOURNAL_FIRST_FILE_ID   0x1
 

Identificator of the first file id Definition at line 225 of file jf_journal.h.

Referenced by jf_journal_close(), jf_journal_cold_recovery(), jf_journal_cold_recovery_update_lists(), jf_journal_commit_int(), jf_journal_file_tab_search(), jf_journal_is_all_sync(), jf_journal_is_sync(), jf_journal_rollback_int(), and jf_journal_set_all_sync().

#define JF_JOURNAL_JOURNAL_FILE_ID   0x0
 

This is the special file id reserved to journal file itself (the first in the journaled file table) Definition at line 220 of file jf_journal.h.

Referenced by jf_file_is_safe(), jf_journal_add_byte_data(), jf_journal_analyze(), jf_journal_apply_changes(), jf_journal_close(), jf_journal_close_detach_file(), jf_journal_cold_recovery(), jf_journal_cold_recovery_analyze(), jf_journal_commit_int(), jf_journal_create(), jf_journal_file_tab_restore(), jf_journal_get_stream(), jf_journal_init(), jf_journal_load(), jf_journal_open(), jf_journal_remove_changes(), jf_journal_rollback_int(), jf_journal_rotate(), jf_journal_shift_files(), jf_journal_sync(), jf_journal_util_leave(), jf_journal_util_rename(), and jf_journal_write_record().

#define JF_JOURNAL_MAGIC_NUMBER   0x41524153
 

A journal file must have this magic number as the first 32 bit word Definition at line 166 of file jf_journal.h.

Referenced by jf_journal_create(), and jf_journal_load().

#define JF_JOURNAL_MAX_FILES   ((jf_word_t)(64 * 1024))
 

Max number of journaled file controlled by a journal file Definition at line 232 of file jf_journal.h.

Referenced by jf_journal_create().

#define JF_JOURNAL_NUM_ENV_VAR   "JF_JOURNAL_NUM"
 

Name of the environment variable can be used to change journal file number if program does NOT specify a custom value when journal file is created: environment var is polled by function jf_set_default_journal_opts Definition at line 78 of file jf_journal.h.

Referenced by jf_set_default_journal_opts().

#define JF_JOURNAL_OP_CODE_APPEND   0x2
 

Append operation code Definition at line 188 of file jf_journal.h.

Referenced by jf_journal_apply_changes(), jf_journal_describe_code(), jf_journal_fetch_ctrl_code(), jf_journal_fetch_record(), jf_journal_remove_changes(), jf_journal_trace_record(), and jf_journal_write_record().

#define JF_JOURNAL_OP_CODE_COMMIT   (JF_JOURNAL_OP_CODE_SYNC | JF_JOURNAL_OP_DO)
 

Commit operation code Definition at line 201 of file jf_journal.h.

Referenced by jf_journal_cold_recovery_update_lists(), jf_journal_commit_int(), jf_journal_scan_redo(), jf_journal_scan_search(), and jf_journal_scan_undo().

#define JF_JOURNAL_OP_CODE_MASK   (JF_JOURNAL_OP_CODE_APPEND | JF_JOURNAL_OP_CODE_UPDATE | JF_JOURNAL_OP_CODE_SYNC)
 

Mask used to isolate operation code: APPEND/UPDATE/SYNC Definition at line 210 of file jf_journal.h.

Referenced by jf_journal_apply_changes(), jf_journal_fetch_ctrl_code(), jf_journal_fetch_record(), jf_journal_remove_changes(), and jf_journal_trace_record().

#define JF_JOURNAL_OP_CODE_NULL   0x0
 

Null operation code: reserved for special tasks Definition at line 184 of file jf_journal.h.

Referenced by jf_journal_fetch_ctrl_code(), jf_journal_fetch_record(), and jf_journal_record_reset().

#define JF_JOURNAL_OP_CODE_ROLLBACK   JF_JOURNAL_OP_CODE_SYNC
 

Rollback operation code Definition at line 205 of file jf_journal.h.

Referenced by jf_journal_cold_recovery(), jf_journal_cold_recovery_prep_pool(), jf_journal_cold_recovery_update_lists(), jf_journal_rollback_int(), jf_journal_scan_redo(), jf_journal_scan_search(), and jf_journal_scan_undo().

#define JF_JOURNAL_OP_CODE_SYNC   0x6
 

Sync (commit/rollback) operation code Definition at line 196 of file jf_journal.h.

Referenced by jf_journal_describe_code(), jf_journal_fetch_ctrl_code(), jf_journal_fetch_record(), and jf_journal_trace_record().

#define JF_JOURNAL_OP_CODE_UPDATE   0x4
 

Update operation code Definition at line 192 of file jf_journal.h.

Referenced by jf_journal_apply_changes(), jf_journal_describe_code(), jf_journal_fetch_ctrl_code(), jf_journal_fetch_record(), jf_journal_remove_changes(), jf_journal_trace_record(), and jf_journal_write_record().

#define JF_JOURNAL_OP_DO   0x1
 

Bit used to specify a DO, instead of UNDO, operation Definition at line 180 of file jf_journal.h.

Referenced by jf_journal_describe_code(), jf_journal_fetch_ctrl_code(), jf_journal_fetch_record(), jf_journal_trace_record(), and jf_journal_write_record().

#define JF_JOURNAL_OP_MASK   (JF_JOURNAL_OP_CODE_MASK | JF_JOURNAL_OP_DO)
 

Journal record operator mask Definition at line 214 of file jf_journal.h.

Referenced by jf_journal_cold_recovery_update_lists(), jf_journal_create(), jf_journal_describe_code(), jf_journal_fetch_ctrl_code(), jf_journal_fetch_record(), jf_journal_scan_redo(), jf_journal_scan_search(), jf_journal_scan_undo(), and jf_journal_trace_record().

#define JF_JOURNAL_PROP_OPEN_O_CREAT   0x00000100
 

If the journal does not exist it will be created (like O_CREAT for open standard function Definition at line 155 of file jf_journal.h.

Referenced by bench_X0_ljf_pre(), jf_file_open(), jf_journal_open(), and main().

#define JF_JOURNAL_PROP_OPEN_O_EXCL   0x00000200
 

When used with JF_JOURNAL_PROP_OPEN_O_CREAT, if the file already exists is an error and the open will fail. In this context, a symbolic link exists, regardless of where its points to Definition at line 161 of file jf_journal.h.

Referenced by bench_X0_ljf_pre(), jf_journal_open(), and main().

#define JF_JOURNAL_PROP_SYNC_DEFAULT   JF_JOURNAL_PROP_SYNC_ENV_VAR
 

Sync type default value Definition at line 143 of file jf_journal.h.

Referenced by jf_set_default_journal_opts().

#define JF_JOURNAL_PROP_SYNC_ENV_VAR   0x00000040
 

Dynamic: type of sync is determined at runtime from environment variable JF_JOURNAL_SYNC_TYPE_ENV_VAR Definition at line 139 of file jf_journal.h.

Referenced by jf_journal_init().

#define JF_JOURNAL_PROP_SYNC_FAST   0x00000010
 

Standard sync journal mode: "fflush" function is used to synchronize journal disk file content; this way is suggested in most cases, but is not 100% safe and should not be used for critical data updated by unstable systems. This mode is application crash safe, but NOT system crash safe Definition at line 126 of file jf_journal.h.

Referenced by jf_journal_init(), and main().

#define JF_JOURNAL_PROP_SYNC_SAFE   0x00000020
 

Safe journal mode: "fclose/fopen" functions are used to synchronize journal disk file content; this mode should be used only for critical data updated by not properly stable systems. The "fclose/fopen" sequence is really heavy and must be deeply valuated This mode is application crash safe, and system crash safe Definition at line 134 of file jf_journal.h.

Referenced by jf_journal_init(), and jf_stream_sync().

#define JF_JOURNAL_PROP_SYNC_SUGGESTED   JF_JOURNAL_PROP_SYNC_FAST
 

Sync type suggested value, used when JF_JOURNAL_PROP_SYNC_ENV_VAR has been specified, but environment var labeled by JF_JOURNAL_SYNC_TYPE_ENV_VAR is not set or is set with an invalid value Definition at line 149 of file jf_journal.h.

Referenced by jf_journal_init().

#define JF_JOURNAL_PROP_VIRTMEM_DEFAULT   JF_JOURNAL_PROP_VIRTMEM_ENV_VAR
 

Default value, used when not specified a specific value Definition at line 112 of file jf_journal.h.

Referenced by jf_set_default_journal_opts().

#define JF_JOURNAL_PROP_VIRTMEM_ENV_VAR   0x00000008
 

Dynamic: virtual memory usage is determined at runtime from environment variable JF_JOURNAL_VIRTMEM_ENV_VAR Definition at line 108 of file jf_journal.h.

Referenced by jf_journal_init().

#define JF_JOURNAL_PROP_VIRTMEM_HIGH   0x00000004
 

Use lot of virtual memory to optimize buffering, reduce CPU cycles, avoid heap fragmentation; suggested for mission critical applications in dedicated environments Definition at line 103 of file jf_journal.h.

Referenced by jf_journal_init().

#define JF_JOURNAL_PROP_VIRTMEM_LOW   0x00000001
 

Use little amount of virtual memory, CPU cycles may be wasted; suggested on system with memory shortages Definition at line 93 of file jf_journal.h.

Referenced by jf_file_vprintf(), and jf_journal_init().

#define JF_JOURNAL_PROP_VIRTMEM_MEDIUM   0x00000002
 

Use virtual memory to optimize buffering and reduce CPU cycles Definition at line 97 of file jf_journal.h.

Referenced by jf_file_vprintf(), and jf_journal_init().

#define JF_JOURNAL_PROP_VIRTMEM_SUGGESTED   JF_JOURNAL_PROP_VIRTMEM_MEDIUM
 

Suggested value, used when JF_JOURNAL_PROP_VIRTMEM_ENV_VAR has been specified, but environment var labeled by JF_JOURNAL_VIRTMEM_ENV_VAR is not set or is set with an invalid value Definition at line 118 of file jf_journal.h.

Referenced by jf_journal_init().

#define JF_JOURNAL_ROT_THRESH_ENV_VAR   "JF_JOURNAL_ROTATION_THRESHOLD"
 

Name of the environment variable can be used to change journal rotation threshold if program does NOT specify a custom value when journal file is created: environment var is polled by function jf_set_default_journal_opts Definition at line 85 of file jf_journal.h.

Referenced by jf_set_default_journal_opts().

#define JF_JOURNAL_SIZE_ENV_VAR   "JF_JOURNAL_SIZE"
 

Name of the environment variable can be used to change journal file size if program does NOT specify a custom value when journal file is created: environment var is polled by function jf_set_default_journal_opts Definition at line 72 of file jf_journal.h.

Referenced by jf_set_default_journal_opts().

#define JF_JOURNAL_SYNC_TYPE_ENV_VAR   "JF_JOURNAL_SYNC_TYPE"
 

Name of the environment variable can be used to change synchronization type if program specifies JF_JOURNAL_PROP_SYNC_DEFAULT. Acceptable values are:

Definition at line 57 of file jf_journal.h.

Referenced by jf_journal_init().

#define JF_JOURNAL_TRACE j,
 ) 
 

Macro wrapper for method jf_journal_trace: active if _DEBUG preprocessor label is set Definition at line 905 of file jf_journal.h.

Referenced by jf_journal_attach_file(), and jf_journal_open().

#define JF_JOURNAL_VERSION   1
 

Journal file library current version Definition at line 173 of file jf_journal.h.

Referenced by jf_journal_create(), and jf_journal_load().

#define JF_JOURNAL_VIRTMEM_ENV_VAR   "JF_JOURNAL_VIRTMEM"
 

Name of the environment variable can be used to change virtual memory usage if program specifies JF_JOURNAL_PROP_VIRTMEM_DEFAULT. Acceptable values are:

Definition at line 66 of file jf_journal.h.

Referenced by jf_journal_init().

#define JF_TRACE_MODULE   JF_TRACE_MOD_LIB_JOURNAL
 

Definition at line 46 of file jf_journal.h.


Function Documentation

int jf_journal_add_byte_data jf_journal_t journal,
jf_word_t  file_id,
const byte_t data,
jf_word_t  size
 

Add data string to journaled file

Parameters:
journal IN/OUT journal object
file_id IN id of the file data are to be sent
data IN data must be appended
size IN number of byte must be appended
Returns:
a reason code
Definition at line 1250 of file jf_journal.c.

References byte_t, CATCH, FALSE, jf_journal_t::file_size, jf_journal_t::file_table, jf_cache_file_get_last_pos(), jf_cache_file_limit_exceeded(), jf_cache_file_resize(), jf_cache_file_set_content(), JF_FILE_OM_APPEND, JF_FILE_OM_MSDOS, jf_journal_file_get_cache_file(), jf_journal_file_get_last_uc_pos(), jf_journal_file_get_last_uc_size(), jf_journal_file_get_open_mode(), jf_journal_file_get_stream(), jf_journal_file_set_all_in_cache(), jf_journal_file_set_last_uc_pos(), jf_journal_file_set_last_uc_size(), jf_journal_file_tab_get_jfile(), JF_JOURNAL_JOURNAL_FILE_ID, jf_journal_write_records(), jf_offset_t, JF_OFFSET_T_FORMAT, JF_RC_INTERNAL_ERROR, JF_RC_JOURNAL_OUT_OF_SPACE, JF_RC_OK, JF_TRACE, jf_translate_NL_CRLF(), jf_word_t, JF_WORD_T_FORMAT, THROW, and TRUE.

Referenced by jf_file_puts(), jf_file_write(), and jf_journal_add_c().

int jf_journal_add_c jf_journal_t journal,
jf_word_t  file_id,
int  c
[inline, static]
 

Add a char to current journal record

Parameters:
journal IN/OUT journal object
file_id IN id of the file data are to be sent
c IN char must be added
Returns:
a reason code
Definition at line 740 of file jf_journal.h.

References byte_t, jf_journal_add_byte_data(), and jf_word_t.

Referenced by jf_file_putc().

int jf_journal_attach_file jf_journal_t journal,
jf_journal_file_t jf,
jf_word_t file_id
 

Attach a file to a journal

Parameters:
journal IN/OUT journal object
jf IN journaled file must be attached to journal
file_id OUT journaled file id: used to retrieve properties from journal
Returns:
a reason code
Definition at line 811 of file jf_journal.c.

References CATCH, jf_journal_t::file_table, jf_journal_file_get_cache_file(), jf_journal_file_get_open_mode(), jf_journal_file_get_stream(), jf_journal_file_set_cache_file(), jf_journal_file_set_open_mode(), jf_journal_file_set_stream(), jf_journal_file_tab_add(), jf_journal_file_tab_get_jfile(), JF_JOURNAL_FILE_TAB_PATH, jf_journal_file_tab_search(), JF_JOURNAL_FILE_TAB_SIZE, JF_JOURNAL_TRACE, jf_journal_update_file_table(), JF_RC_INTERNAL_ERROR, JF_RC_NULL_OBJECT, JF_RC_OBJ_NOT_FOUND, JF_RC_OK, JF_TRACE, jf_word_t, JF_WORD_T_FORMAT, and THROW.

Referenced by jf_journal_open_attach_file().

LIBJF_EXPORT int jf_journal_close jf_journal_t journal  ) 
 

PUBLIC METHOD
Close a journal object

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

References CATCH, jf_journal_t::file_table, ftello, jf_journal_close_detach_file(), jf_journal_file_get_stream(), jf_journal_file_set_last_pos(), jf_journal_file_tab_destroy(), jf_journal_file_tab_get_jfile(), jf_journal_file_tab_get_number_of_files(), JF_JOURNAL_FIRST_FILE_ID, JF_JOURNAL_GLOBAL_FILE_ID, JF_JOURNAL_JOURNAL_FILE_ID, jf_journal_rollback_int(), jf_journal_rotate(), jf_journal_sync(), jf_offset_t, JF_RC_FTELL_ERROR, JF_RC_INTERNAL_ERROR, JF_RC_OK, JF_TRACE, jf_word_t, and THROW.

Referenced by bench_X0_ljf_post(), jf_file_close(), jf_journal_util_join(), jf_journal_util_leave(), jf_journal_util_rename(), and main().

int jf_journal_close_detach_file jf_journal_t journal,
jf_word_t  file_id
 

Detach a journaled file from a journal, close associated stream as well

Parameters:
journal IN/OUT journal object
file_id IN identificator of the file in journal
Returns:
a reason code
Definition at line 1156 of file jf_journal.c.

References CATCH, jf_journal_t::file_table, jf_journal_opts_s::flags, jf_journal_file_get_status(), jf_journal_file_get_stream(), jf_journal_file_set_status(), jf_journal_file_set_stream(), JF_JOURNAL_FILE_ST_OPEN, JF_JOURNAL_FILE_TAB_CTRL, jf_journal_file_tab_get_jfile(), JF_JOURNAL_JOURNAL_FILE_ID, jf_journal_update_file_table(), JF_RC_FCLOSE_ERROR, JF_RC_INTERNAL_ERROR, JF_RC_OK, jf_stream_sync(), JF_TRACE, jf_word_t, jf_journal_t::open_opts, and THROW.

Referenced by jf_file_close(), jf_journal_close(), and jf_journal_cold_recovery().

int jf_journal_commit jf_journal_t journal  )  [inline, static]
 

PUBLIC METHOD
Commit all the journaled file controlled by a journal. NOTE: if you desire to commit the changes of only ONE journaled file you should use jf_file_commit instead of this method

Parameters:
journal IN journal object used to coordinate journaled files
Returns:
a reason code
Definition at line 540 of file jf_journal.h.

References jf_journal_commit_int(), and JF_JOURNAL_GLOBAL_FILE_ID.

Referenced by bench_00_ljf_run(), bench_01_ljf_run(), bench_02_ljf_pre(), bench_02_ljf_run(), bench_03_ljf_run(), and bench_X1_ljf_pre().

int jf_journal_commit_int jf_journal_t journal,
jf_word_t  file_id
 

Commit updates of ONE or ALL the journaled files handle by a journal this method is for internal use only: take a look to jf_journal_commit and jf_file_commit for public methods

Parameters:
journal IN/OUT journal object
file_id IN id of the file must be committed, use JF_JOURNAL_GLOBAL_FILE_ID if the sync is a GLOBAL SYNC POINT (all the journaled filed handled by this journal are committed)
Returns:
a reason code
Definition at line 1602 of file jf_journal.c.

References CATCH, jf_journal_t::file_id_mask, jf_journal_t::file_id_mask_shift, jf_journal_t::file_num, jf_journal_t::file_size, jf_journal_t::file_table, JF_CRASH_SIMUL, JF_CRASH_SIMUL_F_COMMIT_1, JF_CRASH_SIMUL_F_COMMIT_2, JF_CRASH_SIMUL_F_COMMIT_3, JF_CRASH_SIMUL_F_COMMIT_4, JF_CRASH_SIMUL_F_COMMIT_5, JF_CRASH_SIMUL_F_COMMIT_6, jf_journal_file_get_last_uc_pos(), jf_journal_file_get_last_uc_size(), jf_journal_file_get_status(), jf_journal_file_set_all_in_cache(), jf_journal_file_set_last_pos(), jf_journal_file_set_last_size(), jf_journal_file_set_last_uc_size(), jf_journal_file_set_status(), JF_JOURNAL_FILE_ST_SYNC, JF_JOURNAL_FILE_TAB_CTRL, jf_journal_file_tab_get_jfile(), jf_journal_file_tab_get_number_of_files(), JF_JOURNAL_FIRST_FILE_ID, jf_journal_get_stream(), JF_JOURNAL_GLOBAL_FILE_ID, jf_journal_is_all_sync(), JF_JOURNAL_JOURNAL_FILE_ID, JF_JOURNAL_OP_CODE_COMMIT, jf_journal_rotate(), jf_journal_set_all_sync(), jf_journal_sync(), jf_journal_update_file_table(), jf_journal_write_records(), jf_offset_t, JF_RC_FWRITE_ERROR, JF_RC_INTERNAL_ERROR, JF_RC_OK, JF_TRACE, jf_word_t, JF_WORD_T_FORMAT, jf_journal_t::open_opts, jf_journal_opts_s::rotation_threshold, THROW, and TRUE.

Referenced by jf_file_commit(), and jf_journal_commit().

int jf_journal_create jf_journal_t journal,
const char *  path,
jf_word_t  max_files,
FILE **  stream,
const struct jf_journal_opts_s options
 

Create a new journal file and set-up journal object

Parameters:
journal OUT journal object
path IN journal file path
max_files IN max number of files this journal will deal with
stream OUT the (opened) stream associated to the created journal
options IN special option may be used for creating and managing files
Returns:
a reason code
Definition at line 468 of file jf_journal.c.

References CATCH, jf_journal_t::ctrl_recs, jf_journal_t::file_id_mask, jf_journal_t::file_id_mask_shift, jf_journal_opts_s::file_num, jf_journal_t::file_num, jf_journal_opts_s::file_size, jf_journal_t::file_size, jf_journal_t::file_table, ftello, jf_journal_file_create(), jf_journal_file_init(), jf_journal_file_set_last_pos(), jf_journal_file_set_last_uc_size(), jf_journal_file_tab_add(), jf_journal_file_tab_create(), JF_JOURNAL_FILE_TAB_CTRL, jf_journal_file_tab_destroy(), jf_journal_file_tab_dump(), jf_journal_file_tab_get_jfile(), jf_journal_file_tab_init(), JF_JOURNAL_FILE_TAB_PATH, JF_JOURNAL_FILE_TAB_SIZE, JF_JOURNAL_GLOBAL_FILE_ID, JF_JOURNAL_JOURNAL_FILE_ID, JF_JOURNAL_MAGIC_NUMBER, JF_JOURNAL_MAX_FILES, JF_JOURNAL_OP_MASK, jf_journal_update_file_table(), JF_JOURNAL_VERSION, JF_RC_FFLUSH_ERROR, JF_RC_FOPEN_ERROR, JF_RC_FTELL_ERROR, JF_RC_FWRITE_ERROR, JF_RC_INTERNAL_ERROR, JF_RC_INVALID_OPTION, JF_RC_OK, JF_RC_OUT_OF_RANGE, JF_TRACE, jf_word_t, jf_journal_opts_s::journal_file_opts, jf_journal_t::journal_recs, jf_journal_t::magic_number, jf_journal_t::size_mask, jf_journal_t::size_mask_shift, THROW, and jf_journal_t::version.

Referenced by jf_journal_open().

int jf_journal_get_byte_data jf_journal_t journal,
jf_word_t  file_id,
byte_t data,
size_t  size,
size_t *  read
 

Get data string from journaled file

Parameters:
journal IN/OUT journal object
file_id IN id of the file data are to be sent
data OUT room for data must be read
size IN max number of bytes can be read
read OUT real number of bytes stored in "data"
Returns:
a reason code
Definition at line 1384 of file jf_journal.c.

References byte_t, CATCH, FALSE, jf_journal_t::file_table, fseeko, jf_cache_file_chunk_get_content(), jf_cache_file_chunk_get_range(), jf_cache_file_search(), JF_FILE_OM_MSDOS, jf_journal_file_get_cache_file(), jf_journal_file_get_last_uc_pos(), jf_journal_file_get_last_uc_size(), jf_journal_file_get_open_mode(), jf_journal_file_get_stream(), jf_journal_file_set_last_uc_pos(), jf_journal_file_tab_get_jfile(), jf_offset_t, JF_RC_EOF, JF_RC_FREAD_ERROR, JF_RC_FSEEK_ERROR, JF_RC_INTERNAL_ERROR, JF_RC_MALLOC_ERROR, JF_RC_OBJ_NOT_FOUND, JF_RC_OK, JF_TRACE, jf_translate_CRLF_NL(), jf_word_t, THROW, and TRUE.

Referenced by jf_file_read(), and jf_journal_get_c().

int jf_journal_get_c jf_journal_t journal,
jf_word_t  file_id,
int *  c
[inline, static]
 

Get a char from journaled file

Parameters:
journal IN/OUT journal object
file_id IN id of the file data are to be retrieved
c OUT room for read char; NOTE: the higher level bits are not resetted (use & 0xff)
Returns:
a reason code
Definition at line 757 of file jf_journal.h.

References byte_t, jf_journal_get_byte_data(), and jf_word_t.

Referenced by jf_file_getc(), and jf_file_gets().

jf_journal_file_t* jf_journal_get_jfile jf_journal_t journal,
jf_word_t  file_id
[inline, static]
 

Retrieve a reference to a journaled file object handled by a journal

Parameters:
journal IN journal object
file_id IN id of the desired journaled file
Returns:
a pointer to journaled file or NULL
Definition at line 672 of file jf_journal.h.

References jf_journal_t::file_table, jf_journal_file_tab_get_jfile(), and jf_word_t.

Referenced by jf_file_eof(), jf_file_get_cache_limit(), jf_file_getc(), jf_file_gets(), jf_file_seek(), jf_file_size(), and jf_journal_open_attach_file().

uint32_t jf_journal_get_open_opts_flags const jf_journal_t journal  )  [inline, static]
 

Retrieve the flags passed at open time; value can be JF_JOURNAL_PROP_VIRTMEM_LOW / JF_JOURNAL_PROP_VIRTMEM_MEDIUM / JF_JOURNAL_PROP_VIRTMEM_HIGH OR-ed with JF_JOURNAL_PROP_SYNC_FAST / JF_JOURNAL_PROP_SYNC_SAFE

Parameters:
journal IN journal object
Returns:
flags
Definition at line 876 of file jf_journal.h.

References jf_journal_opts_s::flags, and jf_journal_t::open_opts.

Referenced by jf_file_vprintf().

int jf_journal_get_real_path const char *  path,
char **  real_path
 

Real journal path may be different than expected one if a crash happened
Note: output parameter must be freed if not NULL

Parameters:
path IN expected journal file path
real_path OUT real path name if different than expected path NULL if path is the real path
Returns:
a reason code
Definition at line 2321 of file jf_journal.c.

References CATCH, JF_JOURNAL_TMP_EXTENSION, JF_RC_FCLOSE_ERROR, JF_RC_INTERNAL_ERROR, JF_RC_MALLOC_ERROR, JF_RC_OBJ_NOT_FOUND, JF_RC_OK, JF_TRACE, and THROW.

Referenced by jf_journal_cold_recovery_analyze(), and jf_journal_restore_files().

FILE* jf_journal_get_stream const jf_journal_t journal  )  [inline, static]
 

Retrieve the stream associated to journal file

Parameters:
journal IN journal file object
Returns:
the current standard I/O stream
Definition at line 454 of file jf_journal.h.

References jf_journal_t::file_table, jf_journal_file_get_stream(), jf_journal_file_tab_get_jfile(), and JF_JOURNAL_JOURNAL_FILE_ID.

Referenced by jf_journal_cold_recovery(), jf_journal_cold_recovery_patch_record(), jf_journal_cold_recovery_prep_pool(), jf_journal_commit_int(), jf_journal_fetch_ctrl_code(), jf_journal_fetch_record(), jf_journal_rollback_int(), jf_journal_scan(), jf_journal_scan_search(), jf_journal_scan_undo(), and jf_journal_update_file_table().

int jf_journal_init jf_journal_t journal,
const struct jf_journal_opts_s open_opts
 

Initialize a new journal object

Parameters:
journal OUT journal file object
open_opts IN journal open options: it can NOT be a NULL pointer
Returns:
a reason code
Definition at line 60 of file jf_journal.c.

References CATCH, FALSE, jf_journal_opts_s::flags, JF_JOURNAL_JOURNAL_FILE_ID, JF_JOURNAL_PROP_SYNC_ENV_VAR, JF_JOURNAL_PROP_SYNC_FAST, JF_JOURNAL_PROP_SYNC_SAFE, JF_JOURNAL_PROP_SYNC_SUGGESTED, JF_JOURNAL_PROP_VIRTMEM_ENV_VAR, JF_JOURNAL_PROP_VIRTMEM_HIGH, JF_JOURNAL_PROP_VIRTMEM_LOW, JF_JOURNAL_PROP_VIRTMEM_MEDIUM, JF_JOURNAL_PROP_VIRTMEM_SUGGESTED, JF_JOURNAL_SYNC_TYPE_ENV_VAR, JF_JOURNAL_VIRTMEM_ENV_VAR, JF_RC_INTERNAL_ERROR, JF_RC_INVALID_OPTION, JF_RC_NULL_OBJECT, JF_RC_OK, JF_TRACE, jf_journal_currec_s::last_id, jf_journal_t::open_opts, jf_journal_t::r, THROW, and TRUE.

Referenced by jf_journal_cold_recovery_analyze(), and jf_journal_open().

int jf_journal_is_all_sync const jf_journal_t journal  ) 
 

Check if the status of all, but journal, journaled files is "synchronized"

Parameters:
journal IN journal object
Returns:
a boolean value
Definition at line 2526 of file jf_journal.c.

References FALSE, jf_journal_t::file_table, jf_journal_file_get_status(), JF_JOURNAL_FILE_ST_SYNC, jf_journal_file_tab_get_jfile(), jf_journal_file_tab_get_number_of_files(), JF_JOURNAL_FIRST_FILE_ID, jf_word_t, and TRUE.

Referenced by jf_journal_commit_int(), and jf_journal_rollback_int().

int jf_journal_is_sync const jf_journal_t journal,
jf_word_t  file_id
 

Check the status of one/all (but journal) journaled files: if one/all files is/are synchronized it returns TRUE, else FALSE

Parameters:
journal IN journal object
file_id IN journaled file to check (use JF_JOURNAL_GLOBAL_FILE_ID to check all journaled files: global sync)
Returns:
a boolean value
Definition at line 2439 of file jf_journal.c.

References FALSE, jf_journal_t::file_table, jf_journal_file_get_status(), JF_JOURNAL_FILE_ST_SYNC, jf_journal_file_tab_get_jfile(), jf_journal_file_tab_get_number_of_files(), JF_JOURNAL_FIRST_FILE_ID, JF_JOURNAL_GLOBAL_FILE_ID, JF_TRACE, jf_word_t, JF_WORD_T_FORMAT, and TRUE.

Referenced by jf_journal_scan_undo().

int jf_journal_load jf_journal_t journal,
FILE *  stream
 

Load from disk the journal content

Parameters:
journal OUT journal object
stream IN journal file stream
Returns:
a reason code
Definition at line 667 of file jf_journal.c.

References CATCH, jf_journal_t::ctrl_recs, jf_journal_t::file_id_mask, jf_journal_t::file_id_mask_shift, jf_journal_t::file_num, jf_journal_t::file_size, jf_journal_t::file_table, ftello, jf_journal_file_set_last_uc_size(), jf_journal_file_tab_create(), jf_journal_file_tab_destroy(), jf_journal_file_tab_get_jfile(), jf_journal_file_tab_restore(), JF_JOURNAL_JOURNAL_FILE_ID, JF_JOURNAL_MAGIC_NUMBER, JF_JOURNAL_VERSION, jf_offset_t, JF_OFFSET_T_FORMAT, JF_RC_FREAD_ERROR, JF_RC_FTELL_ERROR, JF_RC_INTERNAL_ERROR, JF_RC_MAGIC_NUMBER_ERROR, JF_RC_NULL_OBJECT, JF_RC_OK, JF_RC_VERSION_ERROR, jf_stream_size(), JF_TRACE, jf_journal_t::journal_recs, jf_journal_t::magic_number, jf_journal_t::size_mask, jf_journal_t::size_mask_shift, THROW, and jf_journal_t::version.

Referenced by jf_journal_analyze(), jf_journal_cold_recovery_analyze(), and jf_journal_open().

int jf_journal_new_unit_of_work jf_journal_t journal,
jf_word_t  file_id
 

Open a new unit of work (recovery) for journaled file; this private method can be used before every journaled file update: it checks current status and dump control information if first write is in progress

Parameters:
journal IN/OUT journal object
file_id IN id of the journaled file will be written
Returns:
a reason code
Definition at line 2003 of file jf_journal.c.

References CATCH, jf_journal_t::file_table, jf_journal_file_get_status(), jf_journal_file_set_status(), JF_JOURNAL_FILE_ST_OPEN, JF_JOURNAL_FILE_ST_SYNC, JF_JOURNAL_FILE_TAB_CTRL, jf_journal_file_tab_get_jfile(), jf_journal_update_file_table(), JF_RC_INTERNAL_ERROR, JF_RC_OK, JF_TRACE, jf_word_t, JF_WORD_T_FORMAT, and THROW.

Referenced by jf_journal_write_records().

LIBJF_EXPORT int jf_journal_open jf_journal_t journal,
const char *  path,
jf_word_t  max_files,
const struct jf_journal_opts_s options
 

PUBLIC METHOD
Open a journal object retrieving data from journal file or creating a new one

Parameters:
journal OUT journal object
path IN journal file path
max_files IN max number of files this journal will deal with (meaningless if the journal already exists)
options IN stuff may be passed to tune specific values; it can be a NULL pointer: default options are used (see jf_set_default_journal_opts)
Returns:
a reason code
Definition at line 236 of file jf_journal.c.

References CATCH, FALSE, jf_journal_t::file_table, jf_journal_opts_s::flags, fseeko, jf_journal_cold_recovery(), jf_journal_create(), jf_journal_file_get_last_pos(), jf_journal_file_get_stream(), jf_journal_file_tab_get_jfile(), jf_journal_init(), JF_JOURNAL_JOURNAL_FILE_ID, jf_journal_load(), JF_JOURNAL_PROP_OPEN_O_CREAT, JF_JOURNAL_PROP_OPEN_O_EXCL, jf_journal_restore_files(), JF_JOURNAL_TRACE, JF_RC_FILE_ALREADY_EXISTS, JF_RC_FSEEK_ERROR, JF_RC_INTERNAL_ERROR, JF_RC_INVALID_PATH_NAME, JF_RC_OK, JF_RC_OUT_OF_RANGE, jf_set_default_journal_opts(), JF_TRACE, jf_word_t, and THROW.

Referenced by bench_X0_ljf_pre(), jf_file_open(), jf_journal_util_join(), jf_journal_util_leave(), jf_journal_util_rename(), and main().

int jf_journal_open_attach_file jf_journal_t journal,
const char *  path,
const char *  mode,
jf_word_t file_id,
int  join,
const struct jf_journal_file_opts_s options
 

Open a standard stream, create related journaled file object and attach to a journal

Parameters:
journal IN/OUT journal object
path IN journaled file name
mode IN journaled file open mode
file_id OUT identificator of the file in journal
join IN use TRUE if you want to join the journal, FALSE if file must be attached only if already journaled
options IN special option may be used for managing the journaled file will be attached; it's an optional parameter: pass a NULL pointer to use default values
Returns:
a reason code
Definition at line 908 of file jf_journal.c.

References CATCH, FALSE, jf_journal_t::file_table, jf_cache_file_resize(), jf_file_build_open_mode(), jf_file_check_mode(), JF_FILE_OPEN_MODE_SIZE, jf_journal_attach_file(), jf_journal_file_create(), jf_journal_file_get_cache_file(), jf_journal_file_get_last_pos(), jf_journal_file_get_last_size(), jf_journal_file_get_stream(), jf_journal_file_init(), jf_journal_file_set_all_in_cache(), jf_journal_file_set_last_pos(), jf_journal_file_set_last_size(), jf_journal_file_set_last_uc_pos(), jf_journal_file_set_last_uc_size(), jf_journal_file_tab_get_jfile(), jf_journal_file_tab_search(), jf_journal_get_jfile(), jf_offset_t, JF_RC_FILE_NOT_ABOVE_JOURNAL, JF_RC_FOPEN_ERROR, JF_RC_INTERNAL_ERROR, JF_RC_OBJ_NOT_FOUND, JF_RC_OK, JF_TRACE, jf_word_t, THROW, and TRUE.

Referenced by jf_file_open().

void jf_journal_reset jf_journal_t journal  )  [inline, static]
 

Reset an object journal

Parameters:
journal OUT journal object to reset
Definition at line 468 of file jf_journal.h.

References jf_set_default_journal_opts(), and jf_journal_t::open_opts.

Referenced by jf_journal_analyze().

int jf_journal_restore_files const char *  path  ) 
 

Used to assure the journal file is at this place (it may have a different name due to a crash in jf_journal_rotate phase

Parameters:
path IN expected path name for journal
Returns:
a reason code
Definition at line 2391 of file jf_journal.c.

References CATCH, jf_journal_get_real_path(), JF_RC_INTERNAL_ERROR, JF_RC_OBJ_NOT_FOUND, JF_RC_OK, JF_RC_RENAME_ERROR, JF_TRACE, and THROW.

Referenced by jf_journal_open().

int jf_journal_rollback jf_journal_t journal  )  [inline, static]
 

PUBLIC METHOD
Rollback all the journaled file controlled by a journal. NOTE: if you desire to rollback the changes of only ONE journaled file you should use jf_file_rollback instead of this method

Parameters:
journal IN journal object used to coordinate journaled files
Returns:
a reason code
Definition at line 570 of file jf_journal.h.

References JF_JOURNAL_GLOBAL_FILE_ID, and jf_journal_rollback_int().

int jf_journal_rollback_int jf_journal_t journal,
jf_word_t  file_id
 

Rollback updates of ONE or ALL the journaled files handle by a journal; this method is for internal use only: take a look to jf_journal_rollback and jf_file_rollback for public methods

Parameters:
journal IN/OUT journal object
file_id IN id of the file must be backed-out, use JF_JOURNAL_GLOBAL_FILE_ID if the sync is a GLOBAL ROLLBACK (all the journaled filed handled by this journal are backed-out)
Returns:
a reason code
Definition at line 1786 of file jf_journal.c.

References CATCH, FALSE, jf_journal_t::file_id_mask, jf_journal_t::file_id_mask_shift, jf_journal_t::file_num, jf_journal_t::file_size, jf_journal_t::file_table, jf_cache_file_clear(), jf_cache_file_get_last_pos(), jf_cache_file_set_last_pos(), JF_CRASH_SIMUL, JF_CRASH_SIMUL_F_ROLLBACK_1, JF_CRASH_SIMUL_F_ROLLBACK_2, JF_CRASH_SIMUL_F_ROLLBACK_3, JF_CRASH_SIMUL_F_ROLLBACK_4, JF_JOURNAL_ANALYZE_RECOVERY, jf_journal_file_get_all_in_cache(), jf_journal_file_get_cache_file(), jf_journal_file_get_last_pos(), jf_journal_file_get_last_size(), jf_journal_file_get_last_uc_size(), jf_journal_file_get_status(), jf_journal_file_get_stream(), jf_journal_file_set_all_in_cache(), jf_journal_file_set_last_uc_pos(), jf_journal_file_set_last_uc_size(), jf_journal_file_tab_get_jfile(), jf_journal_file_tab_get_number_of_files(), JF_JOURNAL_FIRST_FILE_ID, jf_journal_get_stream(), JF_JOURNAL_GLOBAL_FILE_ID, jf_journal_is_all_sync(), JF_JOURNAL_JOURNAL_FILE_ID, JF_JOURNAL_OP_CODE_ROLLBACK, jf_journal_rotate(), jf_journal_scan(), jf_offset_t, JF_OFFSET_T_FORMAT, JF_RC_FWRITE_ERROR, JF_RC_INTERNAL_ERROR, JF_RC_OK, jf_stream_truncate(), JF_TRACE, jf_word_t, JF_WORD_T_FORMAT, jf_journal_t::open_opts, jf_journal_opts_s::rotation_threshold, THROW, and TRUE.

Referenced by jf_file_rollback(), jf_journal_close(), and jf_journal_rollback().

int jf_journal_rotate jf_journal_t journal  ) 
 

Rotate the stream associated to journal: current journal is stored and a fresh one is produced (if size was exceeded)

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

References CATCH, jf_journal_t::file_table, jf_journal_opts_s::flags, JF_CRASH_SIMUL, JF_CRASH_SIMUL_F_ROTATE_1, JF_CRASH_SIMUL_F_ROTATE_2, JF_CRASH_SIMUL_F_ROTATE_3, JF_CRASH_SIMUL_F_ROTATE_4, JF_CRASH_SIMUL_F_ROTATE_5, JF_CRASH_SIMUL_F_ROTATE_6, jf_journal_file_get_path(), jf_journal_file_get_stream(), jf_journal_file_set_last_pos(), jf_journal_file_set_last_uc_size(), jf_journal_file_set_stream(), JF_JOURNAL_FILE_TAB_CTRL, jf_journal_file_tab_get_jfile(), jf_journal_file_tab_get_number_of_files(), JF_JOURNAL_JOURNAL_FILE_ID, jf_journal_shift_files(), JF_JOURNAL_TMP_EXTENSION, jf_journal_update_file_table(), JF_RC_FCLOSE_ERROR, JF_RC_FOPEN_ERROR, JF_RC_FREAD_ERROR, JF_RC_FWRITE_ERROR, JF_RC_INTERNAL_ERROR, JF_RC_MALLOC_ERROR, JF_RC_OK, JF_RC_RENAME_ERROR, jf_stream_sync(), JF_TRACE, jf_word_t, jf_journal_t::journal_recs, jf_journal_t::open_opts, and THROW.

Referenced by jf_journal_close(), jf_journal_commit_int(), jf_journal_rollback_int(), jf_journal_util_leave(), and jf_journal_util_rename().

int jf_journal_set_all_sync jf_journal_t journal  ) 
 

Set the status of all, but journal, journaled files to "synchronized"

Parameters:
journal IN journal object
Returns:
a reason code
Definition at line 2476 of file jf_journal.c.

References CATCH, jf_journal_t::file_table, jf_journal_file_get_status(), jf_journal_file_set_status(), JF_JOURNAL_FILE_ST_SYNC, jf_journal_file_tab_get_jfile(), jf_journal_file_tab_get_number_of_files(), JF_JOURNAL_FIRST_FILE_ID, JF_RC_INTERNAL_ERROR, JF_RC_OK, JF_TRACE, jf_word_t, JF_WORD_T_FORMAT, and THROW.

Referenced by jf_journal_commit_int(), and jf_journal_scan_undo().

int jf_journal_shift_files const jf_journal_t journal  ) 
 

Shift old journal files: jf.n-1 -> jf.n, jf.n-2 -> jf.n-1, ... jf.1 -> jf.2 This is a convenience internal method

Parameters:
journal IN journal object
Returns:
a reason code
Definition at line 2228 of file jf_journal.c.

References CATCH, jf_journal_t::file_num, jf_journal_t::file_table, JF_CRASH_SIMUL, JF_CRASH_SIMUL_F_SHIFT_FILES_1, JF_JOURNAL_2_64_BASE_10_DIGITS, jf_journal_file_get_path(), jf_journal_file_tab_get_jfile(), JF_JOURNAL_JOURNAL_FILE_ID, JF_RC_FCLOSE_ERROR, JF_RC_INTERNAL_ERROR, JF_RC_MALLOC_ERROR, JF_RC_OK, JF_RC_RENAME_ERROR, JF_TRACE, jf_word_t, JF_WORD_T_FORMAT, and THROW.

Referenced by jf_journal_rotate().

int jf_journal_sync jf_journal_t journal  ) 
 

Synchronize journal disk file content

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

References CATCH, jf_journal_t::file_table, jf_journal_opts_s::flags, jf_journal_file_get_stream(), jf_journal_file_tab_get_jfile(), JF_JOURNAL_JOURNAL_FILE_ID, JF_RC_INTERNAL_ERROR, JF_RC_OK, jf_stream_sync(), JF_TRACE, jf_journal_t::open_opts, and THROW.

Referenced by jf_journal_close(), jf_journal_cold_recovery(), jf_journal_commit_int(), and jf_journal_write_records().

int jf_journal_trace const jf_journal_t journal,
const char *  method,
FILE *  out_stream
 

Trace journal file content to stream

Parameters:
journal IN journal object
method IN method name
out_stream IN output stream (i.e. stderr)
Definition at line 2917 of file jf_journal.c.

References jf_journal_t::ctrl_recs, jf_journal_t::file_id_mask, jf_journal_t::file_id_mask_shift, jf_journal_t::file_num, jf_journal_t::file_size, jf_journal_t::file_table, jf_journal_file_tab_trace(), JF_OFFSET_T_FORMAT, jf_journal_t::journal_recs, jf_journal_t::magic_number, jf_journal_t::open_opts, jf_journal_opts_s::rotation_threshold, jf_journal_t::size_mask, jf_journal_t::size_mask_shift, and jf_journal_t::version.

Referenced by jf_journal_analyze().

int jf_journal_update_file_table const jf_journal_t journal,
jf_word_t  file_id,
uint32_t  flags
 

Update the content of the journal file physical copy: the table file has been changed at pos "pos"

Parameters:
journal IN journal object
file_id IN changed file id
flags IN which data of file table must be updated ( JF_JOURNAL_FILE_TAB_SIZE, JF_JOURNAL_FILE_TAB_PATH, JF_JOURNAL_FILE_TAB_CTRL )
Returns:
a reason code
Definition at line 1098 of file jf_journal.c.

References CATCH, jf_journal_t::ctrl_recs, jf_journal_t::file_table, fseeko, ftello, jf_journal_file_tab_dump(), jf_journal_get_stream(), jf_offset_t, JF_RC_FSEEK_ERROR, JF_RC_FTELL_ERROR, JF_RC_INTERNAL_ERROR, JF_RC_OK, JF_TRACE, jf_word_t, and THROW.

Referenced by jf_journal_attach_file(), jf_journal_close_detach_file(), jf_journal_cold_recovery(), jf_journal_commit_int(), jf_journal_create(), jf_journal_new_unit_of_work(), jf_journal_rotate(), jf_journal_util_leave(), and jf_journal_util_rename().

int jf_journal_write_record jf_journal_t journal,
jf_word_t  file_id,
jf_offset_t  chunk_id
 

Write a record to journal file: every used range in the cache file is dumped as a journal record. This is a private method generally invoked by jf_journal_write_records

Parameters:
journal IN/OUT journal object
file_id IN id of the journaled file the range is a piece of
chunk_id IN id of the chunk must be saved to journal
Returns:
a reason code
Definition at line 2676 of file jf_journal.c.

References byte_t, CATCH, jf_journal_t::file_id_mask, jf_journal_t::file_id_mask_shift, jf_journal_t::file_table, fseeko, jf_cache_file_chunk_get_content(), jf_cache_file_chunk_get_range(), jf_cache_file_is_empty(), JF_CRASH_SIMUL, JF_CRASH_SIMUL_F_WRITE_RECORD_1, JF_CRASH_SIMUL_F_WRITE_RECORD_2, JF_CRASH_SIMUL_F_WRITE_RECORD_3, JF_CRASH_SIMUL_F_WRITE_RECORD_4, JF_CRASH_SIMUL_F_WRITE_RECORD_5, JF_CRASH_SIMUL_F_WRITE_RECORD_6, JF_CRASH_SIMUL_F_WRITE_RECORD_7, JF_CRASH_SIMUL_F_WRITE_RECORD_8, JF_CRASH_SIMUL_F_WRITE_RECORD_9, jf_journal_file_get_cache_file(), jf_journal_file_get_last_size(), jf_journal_file_get_last_uc_size(), jf_journal_file_get_stream(), jf_journal_file_set_last_uc_size(), jf_journal_file_tab_get_jfile(), JF_JOURNAL_JOURNAL_FILE_ID, JF_JOURNAL_OP_CODE_APPEND, JF_JOURNAL_OP_CODE_UPDATE, JF_JOURNAL_OP_DO, jf_offset_t, JF_RC_FREAD_ERROR, JF_RC_FSEEK_ERROR, JF_RC_FWRITE_ERROR, JF_RC_INTERNAL_ERROR, JF_RC_MALLOC_ERROR, JF_RC_OK, JF_RC_OUT_OF_RANGE, JF_TRACE, JF_TRACE_HEX_DATA, jf_word_t, jf_journal_t::size_mask, jf_journal_t::size_mask_shift, and THROW.

Referenced by jf_journal_write_records().

int jf_journal_write_records jf_journal_t journal,
jf_word_t  file_id
 

Write records related to a journaled file: redo data and undo data are saved to assure file recovery

Parameters:
journal IN/OUT journal object
file_id IN id of the journaled file must be "saved"
Returns:
a reason code
Definition at line 2545 of file jf_journal.c.

References byte_t, CATCH, jf_journal_t::file_table, fseeko, ftello, jf_cache_file_chunk_get_content(), jf_cache_file_chunk_get_range(), jf_cache_file_chunk_is_used(), jf_cache_file_clear(), jf_cache_file_get_size(), JF_CRASH_SIMUL, JF_CRASH_SIMUL_F_WRITE_RECORDS_1, JF_CRASH_SIMUL_F_WRITE_RECORDS_2, JF_CRASH_SIMUL_F_WRITE_RECORDS_3, JF_CRASH_SIMUL_F_WRITE_RECORDS_4, jf_journal_file_get_cache_file(), 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_tab_get_jfile(), jf_journal_new_unit_of_work(), jf_journal_sync(), jf_journal_write_record(), jf_offset_t, JF_RC_FSEEK_ERROR, JF_RC_FTELL_ERROR, JF_RC_FWRITE_ERROR, JF_RC_INTERNAL_ERROR, JF_RC_OK, JF_TRACE, JF_TRACE_HEX_DATA, jf_word_t, JF_WORD_T_FORMAT, and THROW.

Referenced by jf_journal_add_byte_data(), and jf_journal_commit_int().

void jf_set_default_journal_opts struct jf_journal_opts_s options  ) 
 

PUBLIC METHOD
Set default value for journal options

Parameters:
options IN/OUT pointer to struct must be set
Definition at line 202 of file jf_journal.c.

References FALSE, jf_journal_opts_s::file_num, jf_journal_opts_s::file_size, jf_journal_opts_s::flags, JF_JOURNAL_DEFAULT_FILE_NUM, JF_JOURNAL_DEFAULT_FILE_SIZE, JF_JOURNAL_DEFAULT_ROTATION_THRESHOLD, JF_JOURNAL_FILE_NUM_MIN, JF_JOURNAL_NUM_ENV_VAR, JF_JOURNAL_PROP_SYNC_DEFAULT, JF_JOURNAL_PROP_VIRTMEM_DEFAULT, JF_JOURNAL_ROT_THRESH_ENV_VAR, JF_JOURNAL_SIZE_ENV_VAR, jf_set_default_journal_file_opts(), jf_journal_opts_s::journal_file_opts, jf_journal_opts_s::recovery_analyze_flags, jf_journal_opts_s::recovery_damaged_journal, jf_journal_opts_s::recovery_enabled, and jf_journal_opts_s::rotation_threshold.

Referenced by bench_X0_ljf_pre(), jf_journal_cold_recovery_analyze(), jf_journal_open(), jf_journal_reset(), jf_journal_util_join(), jf_journal_util_leave(), jf_journal_util_rename(), jf_set_default_file_open_opts(), and main().


Variable Documentation

const char* JF_JOURNAL_EXTENSION
 

This is the default extension for private journal files Definition at line 46 of file jf_journal.c.

Referenced by jf_file_open().

const char* JF_JOURNAL_TMP_EXTENSION
 

This is the default extension for temporary journal files created by jf_journal_rotate Definition at line 48 of file jf_journal.c.

Referenced by jf_journal_get_real_path(), and jf_journal_rotate().


Copyright 2005 © Tiian