00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef _TMLOG_BASE_H
00034 #define _TMLOG_BASE_H
00035
00036 #include <sys/mman.h>
00037 #include <mnemosyne.h>
00038 #include <log.h>
00039 #include <debug.h>
00040 #include "mtm_i.h"
00041
00042 #define XACT_COMMIT_MARKER 0x0010000000000000
00043 #define XACT_ABORT_MARKER 0x0100000000000000
00044
00045 enum {
00046 LF_TYPE_TM_BASE = 2
00047 };
00048
00049 extern m_log_ops_t tmlog_base_ops;
00050
00051 typedef struct m_tmlog_base_s m_tmlog_base_t;
00052
00053 typedef void set_t;
00054
00055
00056
00057 struct m_tmlog_base_s {
00058 m_phlog_base_t phlog_base;
00059 set_t *flush_set;
00060 };
00061
00062
00063 static inline
00064 m_result_t
00065 m_tmlog_base_write(pcm_storeset_t *set,
00066 m_tmlog_base_t *tmlog,
00067 uintptr_t addr,
00068 pcm_word_t val,
00069 pcm_word_t mask)
00070 {
00071 m_phlog_base_t *phlog_base = &(tmlog->phlog_base);
00072
00073 # ifdef SYNC_TRUNCATION
00074 PHLOG_WRITE(base, set, phlog_base, (pcm_word_t) addr);
00075 PHLOG_WRITE(base, set, phlog_base, (pcm_word_t) val);
00076 PHLOG_WRITE(base, set, phlog_base, (pcm_word_t) mask);
00077 # else
00078 PHLOG_WRITE_ASYNCTRUNC(base, set, phlog_base, (pcm_word_t) addr);
00079 PHLOG_WRITE_ASYNCTRUNC(base, set, phlog_base, (pcm_word_t) val);
00080 PHLOG_WRITE_ASYNCTRUNC(base, set, phlog_base, (pcm_word_t) mask);
00081 # endif
00082 return M_R_SUCCESS;
00083 }
00084
00085
00086 static inline
00087 m_result_t
00088 m_tmlog_base_begin(m_tmlog_base_t *tmlog)
00089 {
00090 return M_R_SUCCESS;
00091 }
00092
00093
00094 static inline
00095 m_result_t
00096 m_tmlog_base_commit(pcm_storeset_t *set, m_tmlog_base_t *tmlog, uint64_t sqn)
00097 {
00098 m_phlog_base_t *phlog_base = &(tmlog->phlog_base);
00099
00100 # ifdef SYNC_TRUNCATION
00101 PHLOG_WRITE(base, set, phlog_base, (pcm_word_t) XACT_COMMIT_MARKER);
00102 PHLOG_WRITE(base, set, phlog_base, (pcm_word_t) sqn);
00103 PHLOG_FLUSH(base, set, phlog_base);
00104 # else
00105 PHLOG_WRITE_ASYNCTRUNC(base, set, phlog_base, (pcm_word_t) XACT_COMMIT_MARKER);
00106 PHLOG_WRITE_ASYNCTRUNC(base, set, phlog_base, (pcm_word_t) sqn);
00107 PHLOG_FLUSH_ASYNCTRUNC(base, set, phlog_base);
00108 # endif
00109 return M_R_SUCCESS;
00110 }
00111
00112
00113 static inline
00114 m_result_t
00115 m_tmlog_base_abort(pcm_storeset_t *set, m_tmlog_base_t *tmlog, uint64_t sqn)
00116 {
00117 m_phlog_base_t *phlog_base = &(tmlog->phlog_base);
00118
00119 # ifdef SYNC_TRUNCATION
00120 PHLOG_WRITE(base, set, phlog_base, (pcm_word_t) XACT_ABORT_MARKER);
00121 PHLOG_WRITE(base, set, phlog_base, (pcm_word_t) sqn);
00122 PHLOG_FLUSH(base, set, phlog_base);
00123 # else
00124 PHLOG_WRITE_ASYNCTRUNC(base, set, phlog_base, (pcm_word_t) XACT_ABORT_MARKER);
00125 PHLOG_WRITE_ASYNCTRUNC(base, set, phlog_base, (pcm_word_t) sqn);
00126 PHLOG_FLUSH_ASYNCTRUNC(base, set, phlog_base);
00127 # endif
00128 return M_R_SUCCESS;
00129 }
00130
00131
00132 static inline
00133 m_result_t
00134 m_tmlog_base_truncate_sync(pcm_storeset_t *set, m_tmlog_base_t *tmlog)
00135 {
00136 m_phlog_base_truncate_sync(set, &tmlog->phlog_base);
00137
00138 return M_R_SUCCESS;
00139 }
00140
00141
00142 m_result_t m_tmlog_base_alloc (m_log_dsc_t *log_dsc);
00143 m_result_t m_tmlog_base_init (pcm_storeset_t *set, m_log_t *log, m_log_dsc_t *log_dsc);
00144 m_result_t m_tmlog_base_truncation_init(pcm_storeset_t *set, m_log_dsc_t *log_dsc);
00145 m_result_t m_tmlog_base_truncation_prepare_next(pcm_storeset_t *set, m_log_dsc_t *log_dsc);
00146 m_result_t m_tmlog_base_truncation_do(pcm_storeset_t *set, m_log_dsc_t *log_dsc);
00147 m_result_t m_tmlog_base_recovery_init(pcm_storeset_t *set, m_log_dsc_t *log_dsc);
00148 m_result_t m_tmlog_base_recovery_prepare_next(pcm_storeset_t *set, m_log_dsc_t *log_dsc);
00149 m_result_t m_tmlog_base_recovery_do(pcm_storeset_t *set, m_log_dsc_t *log_dsc);
00150 m_result_t m_tmlog_base_report_stats(m_log_dsc_t *log_dsc);
00151
00152
00153 #endif