1
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
* Copyright by the Board of Trustees of the University of Illinois. *
3
* All rights reserved. *
5
* This file is part of HDF5. The full HDF5 copyright notice, including *
6
* terms governing use, modification, and redistribution, is contained in *
7
* the files COPYING and Copyright.html. COPYING can be found at the root *
8
* of the source code distribution tree; Copyright.html can be found at the *
9
* root level of an installed copy of the electronic HDF5 document set and *
10
* is linked from the top-level documents page. It can also be found at *
11
* http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
12
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
13
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16
* Programmer: Robb Matzke <matzke@llnl.gov>
17
* Monday, July 26, 1999
23
#include "H5Fpublic.h" /*for H5F_close_degree_t */
25
#define H5_HAVE_VFL 1 /*define a convenient app feature test*/
26
#define H5FD_VFD_DEFAULT 0 /* Default VFL driver value */
29
* Types of allocation requests. The values larger than H5FD_MEM_DEFAULT
30
* should not change other than adding new types to the end. These numbers
31
* might appear in files.
33
typedef enum H5FD_mem_t {
34
H5FD_MEM_NOLIST = -1, /*must be negative*/
35
H5FD_MEM_DEFAULT = 0, /*must be zero*/
43
H5FD_MEM_NTYPES /*must be last*/
47
* A free-list map which maps all types of allocation requests to a single
48
* free list. This is useful for drivers that don't really care about
49
* keeping different requests segregated in the underlying file and which
50
* want to make most efficient reuse of freed memory. The use of the
51
* H5FD_MEM_SUPER free list is arbitrary.
53
#define H5FD_FLMAP_SINGLE { \
54
H5FD_MEM_SUPER, /*default*/ \
55
H5FD_MEM_SUPER, /*super*/ \
56
H5FD_MEM_SUPER, /*btree*/ \
57
H5FD_MEM_SUPER, /*draw*/ \
58
H5FD_MEM_SUPER, /*gheap*/ \
59
H5FD_MEM_SUPER, /*lheap*/ \
60
H5FD_MEM_SUPER /*ohdr*/ \
64
* A free-list map which segregates requests into `raw' or `meta' data
67
#define H5FD_FLMAP_DICHOTOMY { \
68
H5FD_MEM_SUPER, /*default*/ \
69
H5FD_MEM_SUPER, /*super*/ \
70
H5FD_MEM_SUPER, /*btree*/ \
71
H5FD_MEM_DRAW, /*draw*/ \
72
H5FD_MEM_SUPER, /*gheap*/ \
73
H5FD_MEM_SUPER, /*lheap*/ \
74
H5FD_MEM_SUPER /*ohdr*/ \
78
* The default free list map which causes each request type to use it's own
81
#define H5FD_FLMAP_DEFAULT { \
82
H5FD_MEM_DEFAULT, /*default*/ \
83
H5FD_MEM_DEFAULT, /*super*/ \
84
H5FD_MEM_DEFAULT, /*btree*/ \
85
H5FD_MEM_DEFAULT, /*draw*/ \
86
H5FD_MEM_DEFAULT, /*gheap*/ \
87
H5FD_MEM_DEFAULT, /*lheap*/ \
88
H5FD_MEM_DEFAULT /*ohdr*/ \
92
/* Define VFL driver features that can be enabled on a per-driver basis */
93
/* These are returned with the 'query' function pointer in H5FD_class_t */
95
* Defining the H5FD_FEAT_AGGREGATE_METADATA for a VFL driver means that
96
* the library will attempt to allocate a larger block for metadata and
97
* then sub-allocate each metadata request from that larger block.
99
#define H5FD_FEAT_AGGREGATE_METADATA 0x00000001
101
* Defining the H5FD_FEAT_ACCUMULATE_METADATA for a VFL driver means that
102
* the library will attempt to cache metadata as it is written to the file
103
* and build up a larger block of metadata to eventually pass to the VFL
106
* Distinguish between updating the metadata accumulator on writes and
107
* reads. This is particularly (perhaps only, even) important for MPI-I/O
108
* where we guarantee that writes are collective, but reads may not be.
109
* If we were to allow the metadata accumulator to be written during a
110
* read operation, the application would hang.
112
#define H5FD_FEAT_ACCUMULATE_METADATA_WRITE 0x00000002
113
#define H5FD_FEAT_ACCUMULATE_METADATA_READ 0x00000004
114
#define H5FD_FEAT_ACCUMULATE_METADATA (H5FD_FEAT_ACCUMULATE_METADATA_WRITE|H5FD_FEAT_ACCUMULATE_METADATA_READ)
116
* Defining the H5FD_FEAT_DATA_SIEVE for a VFL driver means that
117
* the library will attempt to cache raw data as it is read from/written to
118
* a file in a "data seive" buffer. See Rajeev Thakur's papers:
119
* http://www.mcs.anl.gov/~thakur/papers/romio-coll.ps.gz
120
* http://www.mcs.anl.gov/~thakur/papers/mpio-high-perf.ps.gz
122
#define H5FD_FEAT_DATA_SIEVE 0x00000008
124
* Defining the H5FD_FEAT_AGGREGATE_SMALLDATA for a VFL driver means that
125
* the library will attempt to allocate a larger block for "small" raw data
126
* and then sub-allocate "small" raw data requests from that larger block.
128
#define H5FD_FEAT_AGGREGATE_SMALLDATA 0x00000010
131
/* Forward declaration */
132
typedef struct H5FD_t H5FD_t;
134
/* Class information for each file driver */
135
typedef struct H5FD_class_t {
138
H5F_close_degree_t fc_degree;
139
hsize_t (*sb_size)(H5FD_t *file);
140
herr_t (*sb_encode)(H5FD_t *file, char *name/*out*/,
141
unsigned char *p/*out*/);
142
herr_t (*sb_decode)(H5FD_t *f, const char *name, const unsigned char *p);
144
void * (*fapl_get)(H5FD_t *file);
145
void * (*fapl_copy)(const void *fapl);
146
herr_t (*fapl_free)(void *fapl);
148
void * (*dxpl_copy)(const void *dxpl);
149
herr_t (*dxpl_free)(void *dxpl);
150
H5FD_t *(*open)(const char *name, unsigned flags, hid_t fapl,
152
herr_t (*close)(H5FD_t *file);
153
int (*cmp)(const H5FD_t *f1, const H5FD_t *f2);
154
herr_t (*query)(const H5FD_t *f1, unsigned long *flags);
155
haddr_t (*alloc)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size);
156
herr_t (*free)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id,
157
haddr_t addr, hsize_t size);
158
haddr_t (*get_eoa)(H5FD_t *file);
159
herr_t (*set_eoa)(H5FD_t *file, haddr_t addr);
160
haddr_t (*get_eof)(H5FD_t *file);
161
herr_t (*get_handle)(H5FD_t *file, hid_t fapl, void**file_handle);
162
herr_t (*read)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl,
163
haddr_t addr, size_t size, void *buffer);
164
herr_t (*write)(H5FD_t *file, H5FD_mem_t type, hid_t dxpl,
165
haddr_t addr, size_t size, const void *buffer);
166
herr_t (*flush)(H5FD_t *file, hid_t dxpl_id, unsigned closing);
167
herr_t (*lock)(H5FD_t *file, unsigned char *oid, unsigned lock_type, hbool_t last);
168
herr_t (*unlock)(H5FD_t *file, unsigned char *oid, hbool_t last);
169
H5FD_mem_t fl_map[H5FD_MEM_NTYPES];
172
/* A free list is a singly-linked list of address/size pairs. */
173
typedef struct H5FD_free_t {
176
struct H5FD_free_t *next;
180
* The main datatype for each driver. Public fields common to all drivers
181
* are declared here and the driver appends private fields in memory.
184
hid_t driver_id; /*driver ID for this file */
185
const H5FD_class_t *cls; /*constant class info */
186
unsigned long fileno[2]; /* File serial number */
187
unsigned long feature_flags; /* VFL Driver feature Flags */
188
hsize_t threshold; /* Threshold for alignment */
189
hsize_t alignment; /* Allocation alignment */
190
hsize_t reserved_alloc; /* Space reserved for later alloc calls */
192
/* Metadata aggregation fields */
193
hsize_t def_meta_block_size; /* Metadata allocation
195
* aggregating metadata) */
196
hsize_t cur_meta_block_size; /* Current size of metadata
197
* allocation region left */
198
haddr_t eoma; /* End of metadata
199
* allocated region */
201
/* "Small data" aggregation fields */
202
hsize_t def_sdata_block_size; /* "Small data"
203
* allocation block size
204
* (if aggregating "small
206
hsize_t cur_sdata_block_size; /* Current size of "small
209
haddr_t eosda; /* End of "small data"
210
* allocated region */
212
/* Metadata accumulator fields */
213
unsigned char *meta_accum; /* Buffer to hold the accumulated metadata */
214
haddr_t accum_loc; /* File location (offset) of the
215
* accumulated metadata */
216
size_t accum_size; /* Size of the accumulated
217
* metadata buffer used (in
219
size_t accum_buf_size; /* Size of the accumulated
220
* metadata buffer allocated (in
222
unsigned accum_dirty; /* Flag to indicate that the
223
* accumulated metadata is dirty */
224
haddr_t maxaddr; /* For this file, overrides class */
225
H5FD_free_t *fl[H5FD_MEM_NTYPES]; /* Freelist per allocation type */
226
hsize_t maxsize; /* Largest object on FL, or zero */
233
/* Function prototypes */
234
H5_DLL hid_t H5FDregister(const H5FD_class_t *cls);
235
H5_DLL herr_t H5FDunregister(hid_t driver_id);
236
H5_DLL H5FD_t *H5FDopen(const char *name, unsigned flags, hid_t fapl_id,
238
H5_DLL herr_t H5FDclose(H5FD_t *file);
239
H5_DLL int H5FDcmp(const H5FD_t *f1, const H5FD_t *f2);
240
H5_DLL int H5FDquery(const H5FD_t *f, unsigned long *flags);
241
H5_DLL haddr_t H5FDalloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size);
242
H5_DLL herr_t H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id,
243
haddr_t addr, hsize_t size);
244
H5_DLL haddr_t H5FDrealloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id,
245
haddr_t addr, hsize_t old_size, hsize_t new_size);
246
H5_DLL haddr_t H5FDget_eoa(H5FD_t *file);
247
H5_DLL herr_t H5FDset_eoa(H5FD_t *file, haddr_t eof);
248
H5_DLL haddr_t H5FDget_eof(H5FD_t *file);
249
H5_DLL herr_t H5FDget_vfd_handle(H5FD_t *file, hid_t fapl, void**file_handle);
250
H5_DLL herr_t H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id,
251
haddr_t addr, size_t size, void *buf/*out*/);
252
H5_DLL herr_t H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id,
253
haddr_t addr, size_t size, const void *buf);
254
H5_DLL herr_t H5FDflush(H5FD_t *file, hid_t dxpl_id, unsigned closing);