summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5D.c15
-rw-r--r--src/H5FD.c12
-rw-r--r--src/H5FDcore.c86
-rw-r--r--src/H5FDcore.h6
-rw-r--r--src/H5FDpublic.h1
-rw-r--r--src/H5Odtype.c9
-rw-r--r--src/H5Oefl.c23
-rw-r--r--src/H5config.h.in9
8 files changed, 132 insertions, 29 deletions
diff --git a/src/H5D.c b/src/H5D.c
index ab3823a..2ed2565 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -865,6 +865,10 @@ done:
* Robb Matzke, 27 Jul 1998
* Added the MTIME message to the dataset object header.
*
+ * Robb Matzke, 1999-10-14
+ * The names for the external file list are entered into the heap hear
+ * instead of when the efl message is encoded, preventing a possible
+ * infinite recursion situation.
*-------------------------------------------------------------------------
*/
H5D_t *
@@ -1066,6 +1070,17 @@ H5D_create(H5G_entry_t *loc, const char *name, const H5T_t *type,
HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
"unable to create external file list name heap");
}
+ for (i=0; i<efl->nused; i++) {
+ size_t offset = H5HL_insert(f, efl->heap_addr,
+ HDstrlen(efl->slot[i].name)+1,
+ efl->slot[i].name);
+ assert(0==efl->slot[i].name_offset);
+ if ((size_t)(-1)==offset) {
+ HGOTO_ERROR(H5E_EFL, H5E_CANTINIT, NULL,
+ "unable to insert URL into name heap");
+ }
+ efl->slot[i].name_offset = offset;
+ }
if (H5O_modify (&(new_dset->ent), H5O_EFL, 0, H5O_FLAG_CONSTANT,
efl)<0) {
HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
diff --git a/src/H5FD.c b/src/H5FD.c
index 64dace3..d4a8d91 100644
--- a/src/H5FD.c
+++ b/src/H5FD.c
@@ -1083,17 +1083,21 @@ H5FD_alloc(H5FD_t *file, H5FD_mem_t type, hsize_t size)
/*
* Try to satisfy the request from the free list. First try to find an
- * exact match, otherwise use the best match.
+ * exact match, otherwise use the best match. Only perform the search if
+ * the free list has the potential of satisfying the request.
*/
- if (mapped_type>=0) {
+ if (mapped_type>=0 &&
+ (0==file->maxsize || size<=file->maxsize)) {
H5FD_free_t *prev=NULL, *best=NULL;
H5FD_free_t *cur = file->fl[mapped_type];
while (cur) {
+ file->maxsize = MAX(file->maxsize, cur->size);
if (cur->size==size) {
ret_value = cur->addr;
if (prev) prev->next = cur->next;
else file->fl[mapped_type] = cur->next;
H5MM_xfree(cur);
+ if (size==file->maxsize) file->maxsize=0; /*unknown*/
HRETURN(ret_value);
} else if (cur->size>size &&
(!best || cur->size<best->size)) {
@@ -1103,6 +1107,7 @@ H5FD_alloc(H5FD_t *file, H5FD_mem_t type, hsize_t size)
cur = cur->next;
}
if (best) {
+ if (best->size==file->maxsize) file->maxsize=0; /*unknown*/
ret_value = best->addr;
best->addr += size;
best->size -= size;
@@ -1232,6 +1237,9 @@ H5FD_free(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size)
cur->size = size;
cur->next = file->fl[mapped_type];
file->fl[mapped_type] = cur;
+ if (file->maxsize && size>file->maxsize) {
+ file->maxsize = size;
+ }
} else if (file->cls->free) {
if ((file->cls->free)(file, type, addr, size)<0) {
HRETURN_ERROR(H5E_VFL, H5E_CANTINIT, FAIL,
diff --git a/src/H5FDcore.c b/src/H5FDcore.c
index 64f93c0..51f57c4 100644
--- a/src/H5FDcore.c
+++ b/src/H5FDcore.c
@@ -35,11 +35,14 @@ typedef struct H5FD_core_t {
haddr_t eoa; /*end of allocated region */
haddr_t eof; /*current allocated size */
size_t increment; /*multiples for mem allocation */
+ int fd; /*backing store file descriptor */
+ hbool_t dirty; /*changes not saved? */
} H5FD_core_t;
/* Driver-specific file access properties */
typedef struct H5FD_core_fapl_t {
size_t increment; /*how much to grow memory */
+ hbool_t backing_store; /*write to file name on flush */
} H5FD_core_fapl_t;
/* Allocate memory in multiples of this size by default */
@@ -71,6 +74,7 @@ typedef struct H5FD_core_fapl_t {
static void *H5FD_core_fapl_get(H5FD_t *_file);
static H5FD_t *H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id,
haddr_t maxaddr);
+static herr_t H5FD_core_flush(H5FD_t *_file);
static herr_t H5FD_core_close(H5FD_t *_file);
static int H5FD_core_cmp(const H5FD_t *_f1, const H5FD_t *_f2);
static haddr_t H5FD_core_get_eoa(H5FD_t *_file);
@@ -104,7 +108,7 @@ static const H5FD_class_t H5FD_core_g = {
H5FD_core_get_eof, /*get_eof */
H5FD_core_read, /*read */
H5FD_core_write, /*write */
- NULL, /*flush */
+ H5FD_core_flush, /*flush */
H5FD_FLMAP_SINGLE, /*fl_map */
};
@@ -149,17 +153,21 @@ H5FD_core_init(void)
* Thursday, February 19, 1998
*
* Modifications:
- *
+ * Robb Matzke, 1999-10-19
+ * Added the BACKING_STORE argument. If set then the entire file
+ * contents are flushed to a file with the same name as this
+ * core file.
*-------------------------------------------------------------------------
*/
herr_t
-H5Pset_fapl_core(hid_t fapl_id, size_t increment)
+H5Pset_fapl_core(hid_t fapl_id, size_t increment, hbool_t backing_store)
{
H5FD_core_fapl_t fa;
/* NO TRACE */
if (H5P_FILE_ACCESS!=H5Pget_class(fapl_id)) return -1;
fa.increment = increment;
+ fa.backing_store = backing_store;
return H5Pset_driver(fapl_id, H5FD_CORE, &fa);
}
@@ -177,11 +185,13 @@ H5Pset_fapl_core(hid_t fapl_id, size_t increment)
* Tuesday, August 10, 1999
*
* Modifications:
- *
+ * Robb Matzke, 1999-10-19
+ * Added the BACKING_STORE argument.
*-------------------------------------------------------------------------
*/
herr_t
-H5Pget_fapl_core(hid_t fapl_id, size_t *increment/*out*/)
+H5Pget_fapl_core(hid_t fapl_id, size_t *increment/*out*/,
+ hbool_t *backing_store/*out*/)
{
H5FD_core_fapl_t *fa;
@@ -189,7 +199,10 @@ H5Pget_fapl_core(hid_t fapl_id, size_t *increment/*out*/)
if (H5P_FILE_ACCESS!=H5Pget_class(fapl_id)) return -1;
if (H5FD_CORE!=H5Pget_driver(fapl_id)) return -1;
if (NULL==(fa=H5Pget_driver_info(fapl_id))) return -1;
+
if (increment) *increment = fa->increment;
+ if (backing_store) *backing_store = fa->backing_store;
+
return 0;
}
@@ -217,6 +230,7 @@ H5FD_core_fapl_get(H5FD_t *_file)
H5FD_core_fapl_t *fa = calloc(1, sizeof(H5FD_core_fapl_t));
fa->increment = file->increment;
+ fa->backing_store = (file->fd>=0);
return fa;
}
@@ -236,7 +250,8 @@ H5FD_core_fapl_get(H5FD_t *_file)
* Thursday, July 29, 1999
*
* Modifications:
- *
+ * Robb Matzke, 1999-10-19
+ * The backing store file is created and opened if specified.
*-------------------------------------------------------------------------
*/
static H5FD_t *
@@ -245,14 +260,22 @@ H5FD_core_open(const char *name, unsigned UNUSED flags, hid_t fapl_id,
{
H5FD_core_t *file=NULL;
H5FD_core_fapl_t *fa=NULL;
+ int fd=-1;
/* Check arguments */
if (0==maxaddr || HADDR_UNDEF==maxaddr) return NULL;
if (ADDR_OVERFLOW(maxaddr)) return NULL;
if (H5P_DEFAULT!=fapl_id) fa = H5Pget_driver_info(fapl_id);
+ /* Open backing store */
+ if (fa && fa->backing_store && name &&
+ (fd=open(name, O_CREAT|O_TRUNC|O_RDWR, 0666))<0) {
+ return NULL;
+ }
+
/* Create the new file struct */
file = calloc(1, sizeof(H5FD_core_t));
+ file->fd = fd;
if (name && *name) {
file->name = malloc(strlen(name)+1);
strcpy(file->name, name);
@@ -271,6 +294,47 @@ H5FD_core_open(const char *name, unsigned UNUSED flags, hid_t fapl_id,
/*-------------------------------------------------------------------------
+ * Function: H5FD_core_flush
+ *
+ * Purpose: Flushes the file to backing store if there is any and if the
+ * dirty flag is set.
+ *
+ * Return: Success: 0
+ *
+ * Failure: -1
+ *
+ * Programmer: Robb Matzke
+ * Friday, October 15, 1999
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5FD_core_flush(H5FD_t *_file)
+{
+ H5FD_core_t *file = (H5FD_core_t*)_file;
+
+ /* Write to backing store */
+ if (file->dirty && file->fd>=0) {
+ haddr_t size = file->eof;
+ unsigned char *ptr = file->mem;
+ if (0!=lseek(file->fd, 0, SEEK_SET)) return -1;
+
+ while (size) {
+ ssize_t n = write(file->fd, ptr, size);
+ if (n<0 && EINTR==errno) continue;
+ if (n<0) return -1;
+ ptr += (size_t)n;
+ size -= (size_t)n;
+ }
+ file->dirty = FALSE;
+ }
+ return 0;
+}
+
+
+/*-------------------------------------------------------------------------
* Function: H5FD_core_close
*
* Purpose: Closes the file.
@@ -283,7 +347,9 @@ H5FD_core_open(const char *name, unsigned UNUSED flags, hid_t fapl_id,
* Thursday, July 29, 1999
*
* Modifications:
- *
+ * Robb Matzke, 1999-10-19
+ * The contents of memory are written to the backing store if
+ * one is open.
*-------------------------------------------------------------------------
*/
static herr_t
@@ -291,6 +357,11 @@ H5FD_core_close(H5FD_t *_file)
{
H5FD_core_t *file = (H5FD_core_t*)_file;
+ /* Flush */
+ if (H5FD_core_flush(_file)<0) return -1;
+
+ /* Release resources */
+ if (file->fd>=0) close(file->fd);
if (file->name) free(file->name);
if (file->mem) free(file->mem);
memset(file, 0, sizeof(H5FD_core_t));
@@ -520,5 +591,6 @@ H5FD_core_write(H5FD_t *_file, hid_t UNUSED dxpl_id, haddr_t addr,
/* Write from BUF to memory */
memcpy(file->mem+addr, buf, size);
+ file->dirty = TRUE;
return 0;
}
diff --git a/src/H5FDcore.h b/src/H5FDcore.h
index 223bb0a..f0d338a 100644
--- a/src/H5FDcore.h
+++ b/src/H5FDcore.h
@@ -15,7 +15,9 @@
#define H5FD_CORE (H5FD_core_init())
__DLL__ hid_t H5FD_core_init(void);
-__DLL__ herr_t H5Pset_fapl_core(hid_t fapl_id, size_t increment);
-__DLL__ herr_t H5Pget_fapl_core(hid_t fapl_id, size_t *increment/*out*/);
+__DLL__ herr_t H5Pset_fapl_core(hid_t fapl_id, size_t increment,
+ hbool_t backing_store);
+__DLL__ herr_t H5Pget_fapl_core(hid_t fapl_id, size_t *increment/*out*/,
+ hbool_t *backing_store/*out*/);
#endif
diff --git a/src/H5FDpublic.h b/src/H5FDpublic.h
index fdd07f5..40e4afc 100644
--- a/src/H5FDpublic.h
+++ b/src/H5FDpublic.h
@@ -125,6 +125,7 @@ struct H5FD_t {
const H5FD_class_t *cls; /*constant class info */
haddr_t maxaddr; /*for this file, overrides class*/
H5FD_free_t *fl[H5FD_MEM_NTYPES];/*freelist per allocation type*/
+ hsize_t maxsize; /*largest object on FL, or zero */
};
#ifdef __cplusplus
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index 039d6c2..4d4322b 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -301,15 +301,18 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
/* Decode base type of VL information */
if (NULL==(dt->parent = H5MM_calloc(sizeof(H5T_t))))
- HRETURN_ERROR (H5E_DATATYPE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ HRETURN_ERROR (H5E_DATATYPE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
dt->parent->ent.header = HADDR_UNDEF;
if (H5O_dtype_decode_helper(f, pp, dt->parent)<0)
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode VL parent type");
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL,
+ "unable to decode VL parent type");
dt->force_conv=TRUE;
/* Mark this type as on disk */
if (H5T_vlen_mark(dt, f, H5T_VLEN_DISK)<0)
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location");
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "invalid VL location");
break;
default:
diff --git a/src/H5Oefl.c b/src/H5Oefl.c
index c14203b..8030005 100644
--- a/src/H5Oefl.c
+++ b/src/H5Oefl.c
@@ -144,6 +144,11 @@ H5O_efl_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh)
* Modifications:
* Robb Matzke, 1998-07-20
* Rearranged the message to add a version number near the beginning.
+ *
+ * Robb Matzke, 1999-10-14
+ * Entering the name into the local heap happens when the dataset is
+ * created. Otherwise we could end up in infinite recursion if the heap
+ * happens to hash to the same cache slot as the object header.
*
*-------------------------------------------------------------------------
*/
@@ -152,8 +157,6 @@ H5O_efl_encode(H5F_t *f, uint8_t *p, const void *_mesg)
{
const H5O_efl_t *mesg = (const H5O_efl_t *)_mesg;
int i;
- size_t offset;
-
FUNC_ENTER(H5O_efl_encode, FAIL);
@@ -183,20 +186,10 @@ H5O_efl_encode(H5F_t *f, uint8_t *p, const void *_mesg)
/* Encode file list */
for (i=0; i<mesg->nused; i++) {
/*
- * If the name has not been added to the heap yet then do so now.
+ * The name should have been added to the heap when the dataset was
+ * created.
*/
- if (0==mesg->slot[i].name_offset) {
- offset = H5HL_insert (f, mesg->heap_addr,
- HDstrlen (mesg->slot[i].name)+1,
- mesg->slot[i].name);
- if ((size_t)(-1)==offset) {
- HRETURN_ERROR (H5E_EFL, H5E_CANTINIT, FAIL,
- "unable to insert URL into name heap");
- }
- mesg->slot[i].name_offset = offset;
- }
-
- /* Encode the file info */
+ assert(mesg->slot[i].name_offset);
H5F_encode_length (f, p, mesg->slot[i].name_offset);
H5F_encode_length (f, p, mesg->slot[i].offset);
H5F_encode_length (f, p, mesg->slot[i].size);
diff --git a/src/H5config.h.in b/src/H5config.h.in
index 0ae9639..d94856a 100644
--- a/src/H5config.h.in
+++ b/src/H5config.h.in
@@ -260,6 +260,9 @@
/* Define if you have the <mfhdf.h> header file. */
#undef HAVE_MFHDF_H
+/* Define if you have the <pdb.h> header file. */
+#undef HAVE_PDB_H
+
/* Define if you have the <setjmp.h> header file. */
#undef HAVE_SETJMP_H
@@ -335,6 +338,12 @@
/* Define if you have the nsl library (-lnsl). */
#undef HAVE_LIBNSL
+/* Define if you have the pdb library (-lpdb). */
+#undef HAVE_LIBPDB
+
+/* Define if you have the silo library (-lsilo). */
+#undef HAVE_LIBSILO
+
/* Define if you have the xnet library (-lxnet). */
#undef HAVE_LIBXNET