Coda Distributed File System
rvmlib.h
Go to the documentation of this file.
1/* BLURB gpl
2
3 Coda File System
4 Release 8
5
6 Copyright (c) 1987-2021 Carnegie Mellon University
7 Additional copyrights listed below
8
9This code is distributed "AS IS" without warranty of any kind under
10the terms of the GNU General Public Licence Version 2, as shown in the
11file LICENSE. The technical and financial contributors to Coda are
12listed in the file CREDITS.
13
14 Additional copyrights
15 none currently
16
17#*/
18
19#ifndef _RVMLIB_H_
20#define _RVMLIB_H_ 1
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#ifdef HAVE_CONFIG_H
27#include <config.h>
28#endif
29
30#include "coda_string.h"
31#include <rvm/rvm.h>
32#include <unistd.h>
33#include <stdlib.h>
34#include <setjmp.h>
35
36#include <lwp/lwp.h>
37#include <rvm/rvm.h>
38#include <rvm/rds.h>
39
40#include <rvm/rds.h>
41#include <util.h>
42
43#ifdef __cplusplus
44}
45#endif
46
47#include <coda_tsa.h>
48
49/* ***** Types ***** */
50
51typedef enum
52{
53 UNSET = 0, /* uninitialized */
54 RAWIO = 1, /* raw disk partition */
55 UFS = 2, /* Unix file system */
56 VM = 3 /* virtual memory */
58
59typedef struct {
62 /* jmp_buf abort; */
64
65 /* where was the transaction started */
66 const char *file;
67 int line;
69
70/* ***** Variables ***** */
71
72extern rvm_type_t RvmType; /* your program must supply this! */
73extern long rvm_no_yield; /* exported by rvm */
74
75/* ***** Functions ***** */
76
77#ifdef __cplusplus
78extern "C" {
79#endif
80
81int rvmlib_in_transaction(void);
83
84void rvmlib_set_range(void *base, unsigned long size) REQUIRES_TRANSACTION;
85void rvmlib_modify_bytes(void *dest, const void *newval,
86 int len) REQUIRES_TRANSACTION;
87char *rvmlib_strdup(const char *src, const char *file,
89
90void *rvmlib_malloc(unsigned long size, const char *file,
92void rvmlib_free(void *p, const char *file, int line) REQUIRES_TRANSACTION;
93
95extern void rvmlib_set_thread_data(void *);
97
98#define rvmlib_begin_transaction(restore_mode) \
99 _rvmlib_begin_transaction(restore_mode, __FILE__, __LINE__);
100void _rvmlib_begin_transaction(int restore_mode, const char file[],
101 int line) BEGINS_TRANSACTION;
102void rvmlib_end_transaction(int flush_mode,
104
105#ifdef __cplusplus
106}
107#endif
108
109#define CODA_STACK_LENGTH 0x20000 /* 128 K */
110#define LOGTHRESHOLD 50
111
112/* pointer to rvm_perthread_t must be under this rock! */
113extern int optimizationson;
114
115#define RVMLIB_ASSERT(errmsg) \
116 do { \
117 fprintf(stderr, "RVMLIB_ASSERT: %s\n", errmsg); \
118 fflush(stderr); \
119 coda_assert("0", __FILE__, __LINE__); \
120 } while (0)
121
122#define rvmlib_rec_malloc(size) rvmlib_malloc(size, __FILE__, __LINE__)
123#define rvmlib_rec_free(addr) rvmlib_free(addr, __FILE__, __LINE__)
124#define rvmlib_rec_strdup(size) rvmlib_strdup(size, __FILE__, __LINE__)
125
126#define RVMLIB_REC_OBJECT(object) rvmlib_set_range(&(object), sizeof(object))
127
128void rvmlib_check_trans(char *where, char *file);
129#define rvmlib_intrans() rvmlib_check_trans(__FUNCTION__, __FILE__)
130
131/* macros */
132
133#define RVMLIB_MODIFY(object, newValue) \
134 do { \
135 rvm_perthread_t *_rvm_data = rvmlib_thread_data(); \
136 if (RvmType == VM) \
137 (object) = (newValue); \
138 else if (RvmType == RAWIO || \
139 RvmType == UFS) { /* is object a pointer? */ \
140 rvm_return_t ret = rvm_set_range(_rvm_data->tid, (char *)&object, \
141 sizeof(object)); \
142 if (ret != RVM_SUCCESS) \
143 printf("Modify Bytes error %s\n", rvm_return(ret)); \
144 CODA_ASSERT(ret == RVM_SUCCESS); \
145 (object) = (newValue); \
146 } else { \
147 CODA_ASSERT(0); \
148 } \
149 } while (0)
150
151#endif /* _RVMLIB_H_ */
#define REQUIRES_TRANSACTION
Definition: coda_tsa.h:107
#define ENDS_TRANSACTION
Definition: coda_tsa.h:106
#define BEGINS_TRANSACTION
Definition: coda_tsa.h:105
FILE * file
Definition: dirtest.c:723
int line
Definition: advice_parser.c:54
int rvm_return_t
Definition: rvm.h:94
void rvmlib_abort(int) ENDS_TRANSACTION
Definition: rvmlib.c:159
void rvmlib_set_thread_data(void *)
Definition: rvmlib.c:58
void rvmlib_modify_bytes(void *dest, const void *newval, int len) REQUIRES_TRANSACTION
Definition: rvmlib.c:200
void rvmlib_set_range(void *base, unsigned long size) REQUIRES_TRANSACTION
Definition: rvmlib.c:184
char * rvmlib_strdup(const char *src, const char *file, int line) REQUIRES_TRANSACTION
Definition: rvmlib.c:206
long rvm_no_yield
Definition: rvm_logrecovr.c:46
void _rvmlib_begin_transaction(int restore_mode, const char file[], int line) BEGINS_TRANSACTION
Definition: rvmlib.c:65
void * rvmlib_malloc(unsigned long size, const char *file, int line) REQUIRES_TRANSACTION
Definition: rvmlib.c:217
int rvmlib_in_transaction(void)
Definition: rvmlib.c:282
rvm_type_t
Definition: rvmlib.h:52
@ UFS
Definition: rvmlib.h:55
@ RAWIO
Definition: rvmlib.h:54
@ VM
Definition: rvmlib.h:56
@ UNSET
Definition: rvmlib.h:53
void rvmlib_free(void *p, const char *file, int line) REQUIRES_TRANSACTION
Definition: rvmlib.c:248
void rvmlib_check_trans(char *where, char *file)
Definition: rvmlib.c:272
void rvmlib_init_threaddata(rvm_perthread_t *rvmptt)
Definition: rvmlib.c:36
rvm_perthread_t * rvmlib_thread_data(void)
Definition: rvmlib.c:48
int optimizationson
Definition: srv.cc:135
rvm_type_t RvmType
Definition: rvmlib.c:34
void rvmlib_end_transaction(int flush_mode, rvm_return_t *statusp) ENDS_TRANSACTION
Definition: rvmlib.c:109
Definition: rds.h:76
Definition: rvmlib.h:59
rvm_tid_t * tid
Definition: rvmlib.h:60
intentionList_t list
Definition: rvmlib.h:63
int line
Definition: rvmlib.h:67
rvm_tid_t tids
Definition: rvmlib.h:61
const char * file
Definition: rvmlib.h:66
Definition: rvm.h:251