Coda Distributed File System
rds.h
Go to the documentation of this file.
1/* BLURB lgpl
2
3 Coda File System
4 Release 7
5
6 Copyright (c) 1987-2019 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 Library General Public Licence Version 2, as
11shown in the file LICENSE. The technical and financial contributors to
12Coda are listed in the file CREDITS.
13
14 Additional copyrights
15 none currently
16
17#*/
18
19/*
20 * Public definitions for the Recoverable Dynamic Storage package.
21 */
22
23#ifndef _RDS_H_
24#define _RDS_H_
25
26#include <stdio.h>
27#include "rvm.h"
28
29/* Error codes */
30
31#define SUCCESS 0
32#define ERVM_FAILED -1
33#define EBAD_LIST -2
34#define EBAD_SEGMENT_HDR -3
35#define EHEAP_VERSION_SKEW -4
36#define EHEAP_INIT -5
37#define EBAD_ARGS -6
38#define ECORRUPT -7
39#define EFREED_TWICE -8
40#define ENO_ROOM -9
41
42/* Function definitions */
43
44int rds_zap_heap(char *DevName, rvm_offset_t DevLength, char *startAddr,
45 rvm_length_t staticLength, rvm_length_t heapLength,
46 unsigned long nlists, unsigned long chunkSize, int *err);
47
48int rds_init_heap(char *base, rvm_length_t length, unsigned long chunkSize,
49 unsigned long nlists, rvm_tid_t *tid, int *err);
50
51int rds_load_heap(char *DevName, rvm_offset_t DevLength, char **staticAddr,
52 int *err);
53
54int rds_unload_heap(int *err);
55
56int rds_start_heap(char *startAddr, int *err);
57
58int rds_stop_heap(int *err);
59
60int rds_prealloc(unsigned long size, unsigned long nblocks, rvm_tid_t *tid,
61 int *err);
62
63char *rds_malloc(unsigned long size, rvm_tid_t *tid, int *err);
64
65int rds_free(char *addr, rvm_tid_t *tid, int *err);
66
67int rds_maxblock(unsigned long size);
68
69/*
70 * Because a transaction may abort we don't actually want to free
71 * objects until the end of the transaction. So fake_free records our intention
72 * to free an object. do_free actually frees the object. It's called as part
73 * of the commit.
74 */
75
76typedef struct intlist {
77 unsigned long size;
78 unsigned long count;
79 char **table;
81
82#define STARTSIZE 128 /* Initial size of list, may grow over time */
83
84int rds_fake_free(char *addr, intentionList_t *list);
85
87
88/* Heap statistics reporting */
89typedef struct {
90 unsigned malloc; /* Allocation requests */
91 unsigned prealloc; /* Preallocation requests */
92 unsigned free; /* Block free requests */
93 unsigned coalesce; /* Heap coalesce count */
94 unsigned hits; /* No need to split */
95 unsigned misses; /* Split required */
96 unsigned large_list; /* Largest list pointer changed */
97 unsigned large_hits; /* Large blocks present in list */
98 unsigned large_misses; /* Large block split required */
99 unsigned merged; /* Objects merged from coalesce */
100 unsigned unmerged; /* Objects not merged in coalesce */
101 unsigned freebytes; /* Number of free bytes in heap */
102 unsigned mallocbytes; /* Bytes allocated */
104
105int rds_print_stats(void);
106int rds_clear_stats(int *err);
108
109extern int rds_tracing;
110extern FILE *rds_tracing_file;
111
112int rds_trace_on(FILE *);
113int rds_trace_off(void);
114int rds_trace_dump_heap(void);
115
116#define RDS_LOG(format, a...) \
117 do { \
118 if (rds_tracing && rds_tracing_file) { \
119 fprintf(rds_tracing_file, format, ##a); \
120 fflush(rds_tracing_file); \
121 } \
122 } while (0);
123
124#endif /* _RDS_H_ */
stats
Definition: gensrvstats.py:225
struct intlist intentionList_t
int rds_trace_off(void)
Definition: rds_stats.c:121
char * rds_malloc(unsigned long size, rvm_tid_t *tid, int *err)
Definition: rds_malloc.c:39
int rds_zap_heap(char *DevName, rvm_offset_t DevLength, char *startAddr, rvm_length_t staticLength, rvm_length_t heapLength, unsigned long nlists, unsigned long chunkSize, int *err)
Definition: rds_zap.c:27
int rds_prealloc(unsigned long size, unsigned long nblocks, rvm_tid_t *tid, int *err)
Definition: rds_prealloc.c:39
int rds_get_stats(rds_stats_t *stats)
Definition: rds_stats.c:101
int rds_print_stats(void)
Definition: rds_stats.c:28
int rds_trace_dump_heap(void)
Definition: rds_stats.c:197
int rds_maxblock(unsigned long size)
Definition: rds_maxblock.c:24
int rds_free(char *addr, rvm_tid_t *tid, int *err)
Definition: rds_free.c:51
int rds_clear_stats(int *err)
Definition: rds_stats.c:57
int rds_init_heap(char *base, rvm_length_t length, unsigned long chunkSize, unsigned long nlists, rvm_tid_t *tid, int *err)
Definition: rds_init.c:30
FILE * rds_tracing_file
Definition: rds_stats.c:23
int rds_start_heap(char *startAddr, int *err)
Definition: rds_start.c:113
int rds_stop_heap(int *err)
Definition: rds_start.c:144
int rds_fake_free(char *addr, intentionList_t *list)
Definition: rds_free.c:145
int rds_do_free(intentionList_t *list, rvm_mode_t mode)
Definition: rds_free.c:188
int rds_tracing
Definition: rds_stats.c:22
int rds_load_heap(char *DevName, rvm_offset_t DevLength, char **staticAddr, int *err)
Definition: rds_start.c:69
int rds_trace_on(FILE *)
Definition: rds_stats.c:110
int rds_unload_heap(int *err)
Definition: rds_start.c:97
command_t list[]
Definition: repair.cc:29
rvm_mode_t
Definition: rvm.h:82
unsigned long rvm_length_t
Definition: rvm.h:140
Definition: rds.h:76
unsigned long size
Definition: rds.h:77
unsigned long count
Definition: rds.h:78
char ** table
Definition: rds.h:79
Definition: rds.h:89
unsigned freebytes
Definition: rds.h:101
unsigned misses
Definition: rds.h:95
unsigned prealloc
Definition: rds.h:91
unsigned merged
Definition: rds.h:99
unsigned coalesce
Definition: rds.h:93
unsigned free
Definition: rds.h:92
unsigned large_misses
Definition: rds.h:98
unsigned large_hits
Definition: rds.h:97
unsigned hits
Definition: rds.h:94
unsigned unmerged
Definition: rds.h:100
unsigned mallocbytes
Definition: rds.h:102
unsigned malloc
Definition: rds.h:90
unsigned large_list
Definition: rds.h:96
Definition: rvm.h:145
Definition: rvm.h:251