usermode/library/mtm/src/mode/pwb-common/tmlog_tornbit.h

00001 /*
00002     Copyright (C) 2011 Computer Sciences Department, 
00003     University of Wisconsin -- Madison
00004 
00005     ----------------------------------------------------------------------
00006 
00007     This file is part of Mnemosyne: Lightweight Persistent Memory, 
00008     originally developed at the University of Wisconsin -- Madison.
00009 
00010     Mnemosyne was originally developed primarily by Haris Volos
00011     with contributions from Andres Jaan Tack.
00012 
00013     ----------------------------------------------------------------------
00014 
00015     Mnemosyne is free software; you can redistribute it and/or
00016     modify it under the terms of the GNU General Public License
00017     as published by the Free Software Foundation, version 2
00018     of the License.
00019  
00020     Mnemosyne is distributed in the hope that it will be useful,
00021     but WITHOUT ANY WARRANTY; without even the implied warranty of
00022     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023     GNU General Public License for more details.
00024 
00025     You should have received a copy of the GNU General Public License
00026     along with this program; if not, write to the Free Software
00027     Foundation, Inc., 51 Franklin Street, Fifth Floor, 
00028     Boston, MA  02110-1301, USA.
00029 
00030 ### END HEADER ###
00031 */
00032 
00033 #ifndef _TMLOG_TORNBIT_H
00034 #define _TMLOG_TORNBIT_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_TORNBIT = 3
00047 };
00048 
00049 extern m_log_ops_t tmlog_tornbit_ops;
00050 
00051 typedef struct m_tmlog_tornbit_s m_tmlog_tornbit_t;
00052 
00053 typedef void tornbit_flush_set_t;
00054 
00055 /* Must ensure that phlog_tornbit is word aligned. */
00056 struct m_tmlog_tornbit_s {
00057         m_phlog_tornbit_t   phlog_tornbit;
00058         tornbit_flush_set_t *flush_set;
00059 };
00060 
00061 static inline
00062 m_result_t
00063 m_tmlog_tornbit_write(pcm_storeset_t *set, m_tmlog_tornbit_t *tmlog, uintptr_t addr, pcm_word_t val, pcm_word_t mask)
00064 {
00065         m_phlog_tornbit_t *phlog_tornbit = &(tmlog->phlog_tornbit);
00066 
00067 # ifdef SYNC_TRUNCATION
00068         PHLOG_WRITE(tornbit, set, phlog_tornbit, (pcm_word_t) addr);
00069         PHLOG_WRITE(tornbit, set, phlog_tornbit, (pcm_word_t) val);
00070         PHLOG_WRITE(tornbit, set, phlog_tornbit, (pcm_word_t) mask);
00071 # else
00072         PHLOG_WRITE_ASYNCTRUNC(tornbit, set, phlog_tornbit, (pcm_word_t) addr);
00073         PHLOG_WRITE_ASYNCTRUNC(tornbit, set, phlog_tornbit, (pcm_word_t) val);
00074         PHLOG_WRITE_ASYNCTRUNC(tornbit, set, phlog_tornbit, (pcm_word_t) mask);
00075 # endif
00076 
00077         return M_R_SUCCESS;
00078 }
00079 
00080 
00081 static inline
00082 m_result_t
00083 m_tmlog_tornbit_begin(m_tmlog_tornbit_t *tmlog)
00084 {
00085         return M_R_SUCCESS;
00086 }
00087 
00088 
00089 static inline
00090 m_result_t
00091 m_tmlog_tornbit_commit(pcm_storeset_t *set, m_tmlog_tornbit_t *tmlog, uint64_t sqn)
00092 {
00093         m_phlog_tornbit_t *phlog_tornbit = &(tmlog->phlog_tornbit);
00094 
00095 # ifdef SYNC_TRUNCATION
00096         PHLOG_WRITE(tornbit, set, phlog_tornbit, (pcm_word_t) XACT_COMMIT_MARKER);
00097         PHLOG_WRITE(tornbit, set, phlog_tornbit, (pcm_word_t) sqn);
00098         PHLOG_FLUSH(tornbit, set, phlog_tornbit);
00099 # else
00100         PHLOG_WRITE_ASYNCTRUNC(tornbit, set, phlog_tornbit, (pcm_word_t) XACT_COMMIT_MARKER);
00101         PHLOG_WRITE_ASYNCTRUNC(tornbit, set, phlog_tornbit, (pcm_word_t) sqn);
00102         PHLOG_FLUSH_ASYNCTRUNC(tornbit, set, phlog_tornbit);
00103 # endif
00104         return M_R_SUCCESS;
00105 }
00106 
00107 
00108 static inline
00109 m_result_t
00110 m_tmlog_tornbit_abort(pcm_storeset_t *set, m_tmlog_tornbit_t *tmlog, uint64_t sqn)
00111 {
00112         m_phlog_tornbit_t *phlog_tornbit = &(tmlog->phlog_tornbit);
00113 
00114 # ifdef SYNC_TRUNCATION
00115         PHLOG_WRITE(tornbit, set, phlog_tornbit, (pcm_word_t) XACT_ABORT_MARKER);
00116         PHLOG_WRITE(tornbit, set, phlog_tornbit, (pcm_word_t) sqn);
00117         PHLOG_FLUSH(tornbit, set, phlog_tornbit);
00118 # else
00119         PHLOG_WRITE_ASYNCTRUNC(tornbit, set, phlog_tornbit, (pcm_word_t) XACT_ABORT_MARKER);
00120         PHLOG_WRITE_ASYNCTRUNC(tornbit, set, phlog_tornbit, (pcm_word_t) sqn);
00121         PHLOG_FLUSH_ASYNCTRUNC(tornbit, set, phlog_tornbit);
00122 # endif
00123 
00124         return M_R_SUCCESS;
00125 }
00126 
00127 
00128 static inline
00129 m_result_t
00130 m_tmlog_tornbit_truncate_sync(pcm_storeset_t *set, m_tmlog_tornbit_t *tmlog)
00131 {
00132         m_phlog_tornbit_truncate_sync(set, &tmlog->phlog_tornbit);
00133 
00134         return M_R_SUCCESS;
00135 }
00136 
00137 
00138 
00139 m_result_t m_tmlog_tornbit_alloc (m_log_dsc_t *log_dsc);
00140 m_result_t m_tmlog_tornbit_init (pcm_storeset_t *set, m_log_t *log, m_log_dsc_t *log_dsc);
00141 m_result_t m_tmlog_tornbit_truncation_init(pcm_storeset_t *set, m_log_dsc_t *log_dsc);
00142 m_result_t m_tmlog_tornbit_truncation_prepare_next(pcm_storeset_t *set, m_log_dsc_t *log_dsc);
00143 m_result_t m_tmlog_tornbit_truncation_do(pcm_storeset_t *set, m_log_dsc_t *log_dsc);
00144 m_result_t m_tmlog_tornbit_recovery_init(pcm_storeset_t *set, m_log_dsc_t *log_dsc);
00145 m_result_t m_tmlog_tornbit_recovery_prepare_next(pcm_storeset_t *set, m_log_dsc_t *log_dsc);
00146 m_result_t m_tmlog_tornbit_recovery_do(pcm_storeset_t *set, m_log_dsc_t *log_dsc);
00147 m_result_t m_tmlog_tornbit_report_stats(m_log_dsc_t *log_dsc);
00148 
00149 
00150 #endif /* _TMLOG_TORNBIT_H */

Generated on Sat Apr 23 11:43:36 2011 for Mnemosyne by  doxygen 1.4.7