summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2013-11-30 08:12:26 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2013-11-30 08:12:26 (GMT)
commitc42a36b093535d8c3a96cb539918423d220891a2 (patch)
tree7ede61abe27f4bbfbfb3a3aecedfdb97634c208a
parenta9946535de1cbb1158d8cc78d62c8cc8d978e476 (diff)
downloadhdf5-c42a36b093535d8c3a96cb539918423d220891a2.zip
hdf5-c42a36b093535d8c3a96cb539918423d220891a2.tar.gz
hdf5-c42a36b093535d8c3a96cb539918423d220891a2.tar.bz2
[svn-r24478] Description:
Review Vailin's "metadata retry" code and make various cleanups to it. Also, disallow SWMR access for non-latest format and for non-POSIX VFDs. Tested on: Mac OSX/64 10.9.0 (amazon) w/gcc 4.8 and make check-vfd
-rw-r--r--hl/src/H5HLprivate2.h91
-rw-r--r--src/H5ACprivate.h60
-rw-r--r--src/H5B2cache.c39
-rw-r--r--src/H5EAcache.c65
-rw-r--r--src/H5F.c178
-rw-r--r--src/H5FAcache.c41
-rw-r--r--src/H5FScache.c27
-rw-r--r--src/H5Faccum.c4
-rw-r--r--src/H5Fio.c63
-rw-r--r--src/H5Fpkg.h9
-rw-r--r--src/H5Fprivate.h25
-rw-r--r--src/H5Fpublic.h12
-rw-r--r--src/H5Fquery.c4
-rw-r--r--src/H5Fsuper_cache.c73
-rw-r--r--src/H5HFcache.c348
-rw-r--r--src/H5HFpkg.h8
-rw-r--r--src/H5Ocache.c72
-rw-r--r--src/H5Pfapl.c28
-rw-r--r--src/H5Ppublic.h2
-rw-r--r--src/H5SMcache.c27
-rw-r--r--test/dsets.c149
-rw-r--r--test/earray.c312
-rw-r--r--test/links.c95
-rw-r--r--test/swmr_addrem_writer.c4
-rw-r--r--test/swmr_common.c23
-rw-r--r--test/swmr_generator.c1
-rw-r--r--test/swmr_remove_writer.c4
-rw-r--r--test/swmr_sparse_reader.c3
-rw-r--r--test/swmr_sparse_writer.c4
-rw-r--r--test/swmr_writer.c4
-rw-r--r--test/tfile.c445
-rw-r--r--test/use_common.c12
32 files changed, 1165 insertions, 1067 deletions
diff --git a/hl/src/H5HLprivate2.h b/hl/src/H5HLprivate2.h
index 1b67c70..b7a9362 100644
--- a/hl/src/H5HLprivate2.h
+++ b/hl/src/H5HLprivate2.h
@@ -25,5 +25,96 @@
/* HDF5 private functions */
#include "H5private.h"
+/*
+ * Status return values for the `herr_t' type.
+ * Since some unix/c routines use 0 and -1 (or more precisely, non-negative
+ * vs. negative) as their return code, and some assumption had been made in
+ * the code about that, it is important to keep these constants the same
+ * values. When checking the success or failure of an integer-valued
+ * function, remember to compare against zero and not one of these two
+ * values.
+ */
+#define SUCCEED 0
+#define FAIL (-1)
+#define UFAIL (unsigned)(-1)
+
+/* minimum of two, three, or four values */
+#undef MIN
+#define MIN(a,b) (((a)<(b)) ? (a) : (b))
+#define MIN2(a,b) MIN(a,b)
+#define MIN3(a,b,c) MIN(a,MIN(b,c))
+#define MIN4(a,b,c,d) MIN(MIN(a,b),MIN(c,d))
+
+/* maximum of two, three, or four values */
+#undef MAX
+#define MAX(a,b) (((a)>(b)) ? (a) : (b))
+#define MAX2(a,b) MAX(a,b)
+#define MAX3(a,b,c) MAX(a,MAX(b,c))
+#define MAX4(a,b,c,d) MAX(MAX(a,b),MAX(c,d))
+
+/*
+ * HDF Boolean type.
+ */
+#ifndef FALSE
+# define FALSE 0
+#endif
+#ifndef TRUE
+# define TRUE 1
+#endif
+#ifndef HDassert
+ #define HDassert(X) assert(X)
+#endif /* HDassert */
+#ifndef HDcalloc
+ #define HDcalloc(N,Z) calloc(N,Z)
+#endif /* HDcalloc */
+#ifndef HDfflush
+ #define HDfflush(F) fflush(F)
+#endif /* HDfflush */
+H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...);
+#ifndef HDfree
+ #define HDfree(M) free(M)
+#endif /* HDfree */
+#ifndef HDmemcpy
+ #define HDmemcpy(X,Y,Z) memcpy((char*)(X),(const char*)(Y),Z)
+#endif /* HDmemcpy */
+#ifndef HDmemset
+ #define HDmemset(X,C,Z) memset(X,C,Z)
+#endif /* HDmemset */
+#ifndef HDrealloc
+ #define HDrealloc(M,Z) realloc(M,Z)
+#endif /* HDrealloc */
+#ifndef HDsleep
+ #define HDsleep(N) sleep(N)
+#endif /* HDsleep */
+#ifndef HDstrcat
+ #define HDstrcat(X,Y) strcat(X,Y)
+#endif /* HDstrcat */
+#ifndef HDstrcmp
+ #define HDstrcmp(X,Y) strcmp(X,Y)
+#endif /* HDstrcmp */
+#ifndef HDstrlen
+ #define HDstrlen(S) strlen(S)
+#endif /* HDstrlen */
+#ifndef HDstrrchr
+ #define HDstrrchr(S,C) strrchr(S,C)
+#endif /* HDstrrchr */
+#ifndef HDstrtod
+ #define HDstrtod(S,R) strtod(S,R)
+#endif /* HDstrtod */
+#ifndef HDstrtol
+ #define HDstrtol(S,R,N) strtol(S,R,N)
+#endif /* HDstrtol */
+/*
+ * And now for a couple non-Posix functions... Watch out for systems that
+ * define these in terms of macros.
+ */
+#if !defined strdup && !defined H5_HAVE_STRDUP
+extern char *strdup(const char *s);
+#endif
+
+#ifndef HDstrdup
+ #define HDstrdup(S) strdup(S)
+#endif /* HDstrdup */
+
#endif /* _H5HLprivate2_H */
diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h
index c8d3e27..ae4b9fc 100644
--- a/src/H5ACprivate.h
+++ b/src/H5ACprivate.h
@@ -52,36 +52,36 @@
/* Types of metadata objects cached */
typedef enum {
- H5AC_BT_ID = 0, /*B-tree nodes */
- H5AC_SNODE_ID = 1, /*symbol table nodes */
- H5AC_LHEAP_PRFX_ID = 2, /*local heap prefix */
- H5AC_LHEAP_DBLK_ID = 3, /*local heap data block */
- H5AC_GHEAP_ID = 4, /*global heap */
- H5AC_OHDR_ID = 5, /*object header */
- H5AC_OHDR_CHK_ID = 6, /*object header chunk */
- H5AC_OHDR_PROXY_ID = 7, /*object header proxy */
- H5AC_BT2_HDR_ID = 8, /*v2 B-tree header */
- H5AC_BT2_INT_ID = 9, /*v2 B-tree internal node */
- H5AC_BT2_LEAF_ID = 10, /*v2 B-tree leaf node */
- H5AC_FHEAP_HDR_ID = 11, /*fractal heap header */
- H5AC_FHEAP_DBLOCK_ID = 12, /*fractal heap direct block */
- H5AC_FHEAP_IBLOCK_ID = 13, /*fractal heap indirect block */
- H5AC_FSPACE_HDR_ID = 14, /*free space header */
- H5AC_FSPACE_SINFO_ID = 15, /*free space sections */
- H5AC_SOHM_TABLE_ID = 16, /*shared object header message master table */
- H5AC_SOHM_LIST_ID = 17, /*shared message index stored as a list */
- H5AC_EARRAY_HDR_ID = 18, /*extensible array header */
- H5AC_EARRAY_IBLOCK_ID = 19, /*extensible array index block */
- H5AC_EARRAY_SBLOCK_ID = 20, /*extensible array super block */
- H5AC_EARRAY_DBLOCK_ID = 21, /*extensible array data block */
- H5AC_EARRAY_DBLK_PAGE_ID = 22, /*extensible array data block page */
- H5AC_CHUNK_PROXY_ID = 23, /*chunk proxy */
- H5AC_FARRAY_HDR_ID = 24, /*fixed array header */
- H5AC_FARRAY_DBLOCK_ID = 25, /*fixed array data block */
- H5AC_FARRAY_DBLK_PAGE_ID = 26, /*fixed array data block page */
- H5AC_SUPERBLOCK_ID = 27, /*file superblock */
- H5AC_TEST_ID = 28, /*test entry -- not used for actual files */
- H5AC_NTYPES = 29 /*Number of types, must be last */
+ H5AC_BT_ID = 0, /* ( 0) B-tree nodes */
+ H5AC_SNODE_ID, /* ( 1) symbol table nodes */
+ H5AC_LHEAP_PRFX_ID, /* ( 2) local heap prefix */
+ H5AC_LHEAP_DBLK_ID, /* ( 3) local heap data block */
+ H5AC_GHEAP_ID, /* ( 4) global heap */
+ H5AC_OHDR_ID, /* ( 5) object header */
+ H5AC_OHDR_CHK_ID, /* ( 6) object header chunk */
+ H5AC_OHDR_PROXY_ID, /* ( 7) object header proxy */
+ H5AC_BT2_HDR_ID, /* ( 8) v2 B-tree header */
+ H5AC_BT2_INT_ID, /* ( 9) v2 B-tree internal node */
+ H5AC_BT2_LEAF_ID, /* (10) v2 B-tree leaf node */
+ H5AC_FHEAP_HDR_ID, /* (11) fractal heap header */
+ H5AC_FHEAP_DBLOCK_ID, /* (12) fractal heap direct block */
+ H5AC_FHEAP_IBLOCK_ID, /* (13) fractal heap indirect block */
+ H5AC_FSPACE_HDR_ID, /* (14) free space header */
+ H5AC_FSPACE_SINFO_ID, /* (15) free space sections */
+ H5AC_SOHM_TABLE_ID, /* (16) shared object header message master table */
+ H5AC_SOHM_LIST_ID, /* (17) shared message index stored as a list */
+ H5AC_EARRAY_HDR_ID, /* (18) extensible array header */
+ H5AC_EARRAY_IBLOCK_ID, /* (19) extensible array index block */
+ H5AC_EARRAY_SBLOCK_ID, /* (20) extensible array super block */
+ H5AC_EARRAY_DBLOCK_ID, /* (21) extensible array data block */
+ H5AC_EARRAY_DBLK_PAGE_ID, /* (22) extensible array data block page */
+ H5AC_CHUNK_PROXY_ID, /* (23) chunk proxy */
+ H5AC_FARRAY_HDR_ID, /* (24) fixed array header */
+ H5AC_FARRAY_DBLOCK_ID, /* (25) fixed array data block */
+ H5AC_FARRAY_DBLK_PAGE_ID, /* (26) fixed array data block page */
+ H5AC_SUPERBLOCK_ID, /* (27) file superblock */
+ H5AC_TEST_ID, /* (28) test entry -- not used for actual files */
+ H5AC_NTYPES /* Number of types, must be last */
} H5AC_type_t;
/* H5AC_DUMP_STATS_ON_CLOSE should always be FALSE when
diff --git a/src/H5B2cache.c b/src/H5B2cache.c
index 58c0da7..5fe5ff9 100644
--- a/src/H5B2cache.c
+++ b/src/H5B2cache.c
@@ -160,8 +160,6 @@ H5B2__cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
H5B2_create_t cparam; /* B-tree creation parameters */
H5B2_subid_t id; /* ID of B-tree class, as found in file */
uint16_t depth; /* Depth of B-tree */
- uint32_t stored_chksum; /* Stored metadata checksum value */
- uint32_t computed_chksum; /* Computed metadata checksum value */
H5WB_t *wb = NULL; /* Wrapped buffer for header data */
uint8_t hdr_buf[H5B2_HDR_BUF_SIZE]; /* Buffer for header */
uint8_t *buf; /* Pointer to header buffer */
@@ -188,7 +186,7 @@ H5B2__cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, NULL, "can't get actual buffer")
/* Read and validate header from disk */
- if(H5F_read_check_metadata(f, H5FD_MEM_BTREE, H5AC_BT2_HDR_ID, addr, hdr->hdr_size, hdr->hdr_size, dxpl_id, buf, &computed_chksum) < 0)
+ if(H5F_read_check_metadata(f, dxpl_id, H5FD_MEM_BTREE, H5AC_BT2_HDR_ID, addr, hdr->hdr_size, hdr->hdr_size, buf) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "incorrect metadata checksum for v2 B-tree header")
/* Get temporary pointer to serialized header */
@@ -226,15 +224,10 @@ H5B2__cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
UINT16DECODE(p, hdr->root.node_nrec);
H5F_DECODE_LENGTH(udata->f, p, hdr->root.all_nrec);
- /* Metadata checksum */
- UINT32DECODE(p, stored_chksum);
+ /* Already decoded and compared stored checksum earlier, when reading */
/* Sanity check */
- HDassert((size_t)(p - (const uint8_t *)buf) == hdr->hdr_size);
-
- /* Verify checksum with checksum computed via H5F_read_check_metadata() */
- if(stored_chksum != computed_chksum)
- HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "incorrect metadata checksum for v2 B-tree header")
+ HDassert((size_t)(p - (const uint8_t *)buf) == (hdr->hdr_size - H5_SIZEOF_CHKSUM));
/* Initialize B-tree header info */
cparam.cls = H5B2_client_class_g[id];
@@ -572,8 +565,6 @@ H5B2__cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
const uint8_t *p; /* Pointer into raw data buffer */
uint8_t *native; /* Pointer to native record info */
H5B2_node_ptr_t *int_node_ptr; /* Pointer to node pointer info */
- uint32_t stored_chksum; /* Stored metadata checksum value */
- uint32_t computed_chksum; /* Computed metadata checksum value */
unsigned u; /* Local index variable */
size_t chk_size; /* Exact size of the node with checksum at the end */
H5B2_internal_t *ret_value; /* Return value */
@@ -606,7 +597,7 @@ H5B2__cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
/* Internal node prefix header + records + child pointer triplets: size with checksum at the end */
chk_size = H5B2_INT_PREFIX_SIZE + (udata->nrec * udata->hdr->rrec_size) + ((size_t)(udata->nrec + 1) * H5B2_INT_POINTER_SIZE(udata->hdr, udata->depth));
/* Read and validate internal node from disk */
- if(H5F_read_check_metadata(f, H5FD_MEM_BTREE, H5AC_BT2_INT_ID, addr, (size_t)udata->hdr->node_size, chk_size, dxpl_id, udata->hdr->page, &computed_chksum) < 0)
+ if(H5F_read_check_metadata(f, dxpl_id, H5FD_MEM_BTREE, H5AC_BT2_INT_ID, addr, (size_t)udata->hdr->node_size, chk_size, udata->hdr->page) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "incorrect metadata checksum for v2 internal node")
p = udata->hdr->page;
@@ -663,15 +654,10 @@ H5B2__cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
int_node_ptr++;
} /* end for */
- /* Metadata checksum */
- UINT32DECODE(p, stored_chksum);
+ /* Already decoded and compared stored checksum earlier, when reading */
/* Sanity check parsing */
- HDassert((size_t)(p - (const uint8_t *)udata->hdr->page) <= udata->hdr->node_size);
-
- /* Verify checksum */
- if(stored_chksum != computed_chksum)
- HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "incorrect metadata checksum for v2 internal node")
+ HDassert((size_t)(p - (const uint8_t *)udata->hdr->page) <= (udata->hdr->node_size - H5_SIZEOF_CHKSUM));
/* Set return value */
ret_value = internal;
@@ -994,8 +980,6 @@ H5B2__cache_leaf_load(H5F_t UNUSED *f, hid_t dxpl_id, haddr_t addr, void *_udata
H5B2_leaf_t *leaf = NULL; /* Pointer to lead node loaded */
const uint8_t *p; /* Pointer into raw data buffer */
uint8_t *native; /* Pointer to native keys */
- uint32_t stored_chksum; /* Stored metadata checksum value */
- uint32_t computed_chksum; /* Computed metadata checksum value */
unsigned u; /* Local index variable */
size_t chk_size; /* Exact size of the node with checksum at the end */
H5B2_leaf_t *ret_value; /* Return value */
@@ -1029,7 +1013,7 @@ H5B2__cache_leaf_load(H5F_t UNUSED *f, hid_t dxpl_id, haddr_t addr, void *_udata
chk_size = H5B2_LEAF_PREFIX_SIZE + (udata->nrec * udata->hdr->rrec_size);
/* Read and validate leaf node from disk */
- if(H5F_read_check_metadata(f, H5FD_MEM_BTREE, H5AC_BT2_LEAF_ID, addr, (size_t)udata->hdr->node_size, chk_size, dxpl_id, udata->hdr->page, &computed_chksum) < 0)
+ if(H5F_read_check_metadata(f, dxpl_id, H5FD_MEM_BTREE, H5AC_BT2_LEAF_ID, addr, (size_t)udata->hdr->node_size, chk_size, udata->hdr->page) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "incorrect metadata checksum for v2 leaf node")
p = udata->hdr->page;
@@ -1066,15 +1050,10 @@ H5B2__cache_leaf_load(H5F_t UNUSED *f, hid_t dxpl_id, haddr_t addr, void *_udata
native += udata->hdr->cls->nrec_size;
} /* end for */
- /* Metadata checksum */
- UINT32DECODE(p, stored_chksum);
+ /* Already decoded and compared stored checksum earlier, when reading */
/* Sanity check parsing */
- HDassert((size_t)(p - (const uint8_t *)udata->hdr->page) <= udata->hdr->node_size);
-
- /* Verify checksum with checksum computed via H5F_read_check_metadata() */
- if(stored_chksum != computed_chksum)
- HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "incorrect metadata checksum for v2 leaf node")
+ HDassert((size_t)(p - (const uint8_t *)udata->hdr->page) <= (udata->hdr->node_size - H5_SIZEOF_CHKSUM));
/* Set return value */
ret_value = leaf;
diff --git a/src/H5EAcache.c b/src/H5EAcache.c
index 789cdf8..0f96775 100644
--- a/src/H5EAcache.c
+++ b/src/H5EAcache.c
@@ -208,8 +208,6 @@ H5EA__cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata))
uint8_t hdr_buf[H5EA_HDR_BUF_SIZE]; /* Buffer for header */
uint8_t *buf; /* Pointer to header buffer */
const uint8_t *p; /* Pointer into raw data buffer */
- uint32_t stored_chksum; /* Stored metadata checksum value */
- uint32_t computed_chksum; /* Computed metadata checksum value */
/* Check arguments */
HDassert(f);
@@ -234,7 +232,7 @@ H5EA__cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata))
H5E_THROW(H5E_CANTGET, "can't get actual buffer")
/* Read and validate header from disk */
- if(H5F_read_check_metadata(f, H5FD_MEM_EARRAY_HDR, H5AC_EARRAY_HDR_ID, addr, size, size, dxpl_id, buf, &computed_chksum) < 0)
+ if(H5F_read_check_metadata(f, dxpl_id, H5FD_MEM_EARRAY_HDR, H5AC_EARRAY_HDR_ID, addr, size, size, buf) < 0)
H5E_THROW(H5E_BADVALUE, "incorrect metadata checksum for extensible array header")
/* Get temporary pointer to serialized header */
@@ -300,15 +298,10 @@ H5EA__cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata))
/* (allow for checksum not decoded yet) */
HDassert((size_t)(p - buf) == (size - H5EA_SIZEOF_CHKSUM));
- /* Metadata checksum */
- UINT32DECODE(p, stored_chksum);
+ /* Already decoded and compared stored checksum earlier, when reading */
/* Sanity check */
- HDassert((size_t)(p - buf) == size);
-
- /* Verify checksum with checksum computed via H5F_read_check_metadata() */
- if(stored_chksum != computed_chksum)
- H5E_THROW(H5E_BADVALUE, "incorrect metadata checksum for extensible array header")
+ HDassert((size_t)(p - buf) == (size - H5_SIZEOF_CHKSUM));
/* Finish initializing extensible array header */
if(H5EA__hdr_init(hdr, udata) < 0)
@@ -570,8 +563,6 @@ H5EA__cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata))
uint8_t iblock_buf[H5EA_IBLOCK_BUF_SIZE]; /* Buffer for index block */
uint8_t *buf; /* Pointer to index block buffer */
const uint8_t *p; /* Pointer into raw data buffer */
- uint32_t stored_chksum; /* Stored metadata checksum value */
- uint32_t computed_chksum; /* Computed metadata checksum value */
haddr_t arr_addr; /* Address of array header in the file */
/* Sanity check */
@@ -598,7 +589,7 @@ H5EA__cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata))
H5E_THROW(H5E_CANTGET, "can't get actual buffer")
/* Read and validate index block from disk */
- if(H5F_read_check_metadata(f, H5FD_MEM_EARRAY_IBLOCK, H5AC_EARRAY_IBLOCK_ID, addr, size, size, dxpl_id, buf, &computed_chksum) < 0)
+ if(H5F_read_check_metadata(f, dxpl_id, H5FD_MEM_EARRAY_IBLOCK, H5AC_EARRAY_IBLOCK_ID, addr, size, size, buf) < 0)
H5E_THROW(H5E_BADVALUE, "incorrect metadata checksum for extensible array index block")
/* Get temporary pointer to serialized header */
@@ -657,15 +648,10 @@ H5EA__cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata))
/* Save the index block's size */
iblock->size = size;
- /* Metadata checksum */
- UINT32DECODE(p, stored_chksum);
+ /* Already decoded and compared stored checksum earlier, when reading */
/* Sanity check */
- HDassert((size_t)(p - buf) == iblock->size);
-
- /* Verify checksum with checksum computed via H5F_read_check_metadata() */
- if(stored_chksum != computed_chksum)
- H5E_THROW(H5E_BADVALUE, "incorrect metadata checksum for extensible array index block")
+ HDassert((size_t)(p - buf) == (iblock->size - H5_SIZEOF_CHKSUM));
/* Set return value */
ret_value = iblock;
@@ -983,8 +969,6 @@ H5EA__cache_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata))
uint8_t sblock_buf[H5EA_IBLOCK_BUF_SIZE]; /* Buffer for super block */
uint8_t *buf; /* Pointer to super block buffer */
const uint8_t *p; /* Pointer into raw data buffer */
- uint32_t stored_chksum; /* Stored metadata checksum value */
- uint32_t computed_chksum; /* Computed metadata checksum value */
haddr_t arr_addr; /* Address of array header in the file */
size_t u; /* Local index variable */
@@ -1012,7 +996,7 @@ H5EA__cache_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata))
H5E_THROW(H5E_CANTGET, "can't get actual buffer")
/* Read and validate super block from disk */
- if(H5F_read_check_metadata(f, H5FD_MEM_EARRAY_SBLOCK, H5AC_EARRAY_SBLOCK_ID, addr, size, size, dxpl_id, buf, &computed_chksum) < 0)
+ if(H5F_read_check_metadata(f, dxpl_id, H5FD_MEM_EARRAY_SBLOCK, H5AC_EARRAY_SBLOCK_ID, addr, size, size, buf) < 0)
H5E_THROW(H5E_BADVALUE, "incorrect metadata checksum for extensible array super block")
/* Get temporary pointer to serialized header */
@@ -1061,15 +1045,10 @@ H5EA__cache_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata))
/* Save the super block's size */
sblock->size = size;
- /* Metadata checksum */
- UINT32DECODE(p, stored_chksum);
+ /* Already decoded and compared stored checksum earlier, when reading */
/* Sanity check */
- HDassert((size_t)(p - buf) == sblock->size);
-
- /* Verify checksum with checksum computed via H5F_read_check_metadata() */
- if(stored_chksum != computed_chksum)
- H5E_THROW(H5E_BADVALUE, "incorrect metadata checksum for extensible array super block")
+ HDassert((size_t)(p - buf) == (sblock->size - H5_SIZEOF_CHKSUM));
/* Set return value */
ret_value = sblock;
@@ -1377,8 +1356,6 @@ H5EA__cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata))
uint8_t dblock_buf[H5EA_DBLOCK_BUF_SIZE]; /* Buffer for data block */
uint8_t *buf; /* Pointer to data block buffer */
const uint8_t *p; /* Pointer into raw data buffer */
- uint32_t stored_chksum; /* Stored metadata checksum value */
- uint32_t computed_chksum; /* Computed metadata checksum value */
haddr_t arr_addr; /* Address of array header in the file */
/* Sanity check */
@@ -1408,7 +1385,7 @@ H5EA__cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata))
H5E_THROW(H5E_CANTGET, "can't get actual buffer")
/* Read and validate data block from disk */
- if(H5F_read_check_metadata(f, H5FD_MEM_EARRAY_DBLOCK, H5AC_EARRAY_DBLOCK_ID, addr, size, size, dxpl_id, buf, &computed_chksum) < 0)
+ if(H5F_read_check_metadata(f, dxpl_id, H5FD_MEM_EARRAY_DBLOCK, H5AC_EARRAY_DBLOCK_ID, addr, size, size, buf) < 0)
H5E_THROW(H5E_BADVALUE, "incorrect metadata checksum for extensible data block")
/* Get temporary pointer to serialized header */
@@ -1453,15 +1430,10 @@ H5EA__cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata))
/* Set the data block's size */
dblock->size = H5EA_DBLOCK_SIZE(dblock);
- /* Metadata checksum */
- UINT32DECODE(p, stored_chksum);
+ /* Already decoded and compared stored checksum earlier, when reading */
/* Sanity check */
- HDassert((size_t)(p - buf) == size);
-
- /* Verify checksum with checksum computed via H5F_read_check_metadata() */
- if(stored_chksum != computed_chksum)
- H5E_THROW(H5E_BADVALUE, "incorrect metadata checksum for extensible array data block - # pages = %d", dblock->npages)
+ HDassert((size_t)(p - buf) == (size - H5_SIZEOF_CHKSUM));
/* Set return value */
ret_value = dblock;
@@ -1774,8 +1746,6 @@ H5EA__cache_dblk_page_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata))
uint8_t dblk_page_buf[H5EA_DBLK_PAGE_BUF_SIZE]; /* Buffer for data block page */
uint8_t *buf; /* Pointer to data block page buffer */
const uint8_t *p; /* Pointer into raw data buffer */
- uint32_t stored_chksum; /* Stored metadata checksum value */
- uint32_t computed_chksum; /* Computed metadata checksum value */
/* Sanity check */
HDassert(f);
@@ -1804,7 +1774,7 @@ HDfprintf(stderr, "%s: addr = %a\n", FUNC, addr);
H5E_THROW(H5E_CANTGET, "can't get actual buffer")
/* Read and validate data block page from disk */
- if(H5F_read_check_metadata(f, H5FD_MEM_EARRAY_DBLK_PAGE, H5AC_EARRAY_DBLK_PAGE_ID, addr, size, size, dxpl_id, buf, &computed_chksum) < 0)
+ if(H5F_read_check_metadata(f, dxpl_id, H5FD_MEM_EARRAY_DBLK_PAGE, H5AC_EARRAY_DBLK_PAGE_ID, addr, size, size, buf) < 0)
H5E_THROW(H5E_BADVALUE, "incorrect metadata checksum for extensible array data block page")
/* Get temporary pointer to serialized header */
@@ -1825,15 +1795,10 @@ HDfprintf(stderr, "%s: addr = %a\n", FUNC, addr);
/* Set the data block page's size */
dblk_page->size = size;
- /* Metadata checksum */
- UINT32DECODE(p, stored_chksum);
+ /* Already decoded and compared stored checksum earlier, when reading */
/* Sanity check */
- HDassert((size_t)(p - buf) == dblk_page->size);
-
- /* Verify checksum with checksum computed via H5F_read_check_metadata() */
- if(stored_chksum != computed_chksum)
- H5E_THROW(H5E_BADVALUE, "incorrect metadata checksum for extensible array data block page")
+ HDassert((size_t)(p - buf) == (dblk_page->size - H5_SIZEOF_CHKSUM));
/* Set return value */
ret_value = dblk_page;
diff --git a/src/H5F.c b/src/H5F.c
index 9a8d1cc..46442b7 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -77,8 +77,8 @@ typedef struct H5F_olist_t {
/********************/
static herr_t H5F_get_objects(const H5F_t *f, unsigned types, size_t max_index, hid_t *obj_id_list, hbool_t app_ref, size_t *obj_id_count_ptr);
static int H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key);
-static H5F_t *H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id,
- H5FD_t *lf);
+static H5F_t *H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id,
+ hid_t fapl_id, H5FD_t *lf);
static herr_t H5F_build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl,
const char *name, char ** /*out*/ actual_name);
static herr_t H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush);
@@ -337,7 +337,6 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref)
/* Make a copy of the default file access property list */
if(NULL == (old_plist = (H5P_genplist_t *)H5I_object(H5P_LST_FILE_ACCESS_g)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
-
if((ret_value = H5P_copy_plist(old_plist, app_ref)) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "can't copy file access property list")
if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(ret_value)))
@@ -366,7 +365,7 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'small data' cache size")
if(H5P_set(new_plist, H5F_ACS_LATEST_FORMAT_NAME, &(f->shared->latest_format)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'latest format' flag")
- if(H5P_set(new_plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, &(f->read_attempts)) < 0)
+ if(H5P_set(new_plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, &(f->shared->read_attempts)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'latest format' flag")
if(f->shared->efc)
efc_size = H5F_efc_max_nfiles(f->shared->efc);
@@ -887,7 +886,7 @@ done:
*-------------------------------------------------------------------------
*/
static H5F_t *
-H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf)
+H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf)
{
H5F_t *f = NULL, *ret_value;
@@ -910,6 +909,7 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf)
if(NULL == (f->shared = H5FL_CALLOC(H5F_file_t)))
HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate shared file structure")
+ f->shared->flags = flags;
f->shared->sohm_addr = HADDR_UNDEF;
f->shared->sohm_vers = HDF5_SHAREDHEADER_VERSION;
for(u = 0; u < NELMTS(f->shared->fs_addr); u++)
@@ -942,7 +942,6 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf)
/* Get the FAPL values to cache */
if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list")
-
if(H5P_get(plist, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, &(f->shared->mdc_initCacheCfg)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get initial metadata cache resize config")
if(H5P_get(plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, &(f->shared->rdcc_nslots)) < 0)
@@ -961,6 +960,12 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get sieve buffer size")
if(H5P_get(plist, H5F_ACS_LATEST_FORMAT_NAME, &(f->shared->latest_format)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'latest format' flag")
+ /* Require the latest format to use SWMR */
+ /* (Need to revisit this when the 1.10 release is made, and require
+ * 1.10 or later -QAK)
+ */
+ if(!H5F_USE_LATEST_FORMAT(f) && (H5F_INTENT(f) & H5F_ACC_SWMR_WRITE))
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "must use 'latest format' flag with SWMR write access")
if(H5P_get(plist, H5F_ACS_META_BLOCK_SIZE_NAME, &(f->shared->meta_aggr.alloc_size)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get metadata cache size")
f->shared->meta_aggr.feature_flag = H5FD_FEAT_AGGREGATE_METADATA;
@@ -973,13 +978,16 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf)
if(NULL == (f->shared->efc = H5F_efc_create(efc_size)))
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "can't create external file cache")
-
/* Get the VFD values to cache */
f->shared->maxaddr = H5FD_get_maxaddr(lf);
if(!H5F_addr_defined(f->shared->maxaddr))
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad maximum address from VFD")
if(H5FD_get_feature_flags(lf, &f->shared->feature_flags) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get feature flags from VFD")
+ /* Require a POSIX compatible VFD to use SWMR feature */
+ /* (It's reasonable to try to expand this to other VFDs eventually -QAK) */
+ if(!H5F_HAS_FEATURE(f, H5FD_FEAT_POSIX_COMPAT_HANDLE) && (H5F_INTENT(f) & (H5F_ACC_SWMR_WRITE | H5F_ACC_SWMR_READ)))
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "must use POSIX compatible VFD with SWMR write access")
if(H5FD_get_fs_type_map(lf, f->shared->fs_type_map) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get free space type mapping from VFD")
if(H5MF_init_merge_flags(f) < 0)
@@ -996,6 +1004,37 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf)
*/
f->shared->use_tmp_space = !H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI);
+ /* Retrieve the # of read attempts here so that sohm in superblock will get the correct # of attempts */
+ if(H5P_get(plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, &f->shared->read_attempts) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get the # of read attempts")
+
+ /* When opening file with SWMR access, the # of read attempts is H5F_SWMR_METADATA_READ_ATTEMPTS if not set */
+ /* When opening file without SWMR access, the # of read attempts is always H5F_METADATA_READ_ATTEMPTS (set or not set) */
+ if(H5F_INTENT(f) & (H5F_ACC_SWMR_READ | H5F_ACC_SWMR_WRITE)) {
+ /* If no value for read attempts has been set, use the default */
+ if(!f->shared->read_attempts)
+ f->shared->read_attempts = H5F_SWMR_METADATA_READ_ATTEMPTS;
+
+ /* Turn off accumulator with SWMR */
+ f->shared->feature_flags = lf->feature_flags & ~(unsigned)H5FD_FEAT_ACCUMULATE_METADATA;
+ if(H5FD_set_feature_flags(lf, f->shared->feature_flags) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, NULL, "can't set feature_flags in VFD")
+ } /* end if */
+ else
+ f->shared->read_attempts = H5F_METADATA_READ_ATTEMPTS;
+
+ /* Determine the # of bins for metdata read retries */
+ f->shared->retries_nbins = 0;
+ if(f->shared->read_attempts > 1) {
+ double tmp;
+
+ tmp = HDlog10((double)(f->shared->read_attempts - 1));
+ f->shared->retries_nbins = (unsigned)tmp + 1;
+ } /* end if */
+
+ /* Initialize the tracking for metadata read retries */
+ HDmemset(f->shared->retries, 0, sizeof(f->shared->retries));
+
/*
* Create a metadata cache with the specified number of elements.
* The cache might be created with a different number of elements and
@@ -1024,8 +1063,17 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf)
done:
if(!ret_value && f) {
- if(!shared)
+ if(!shared) {
+ /* Attempt to clean up some of the shared file structures */
+ if(f->shared->efc)
+ if(H5F_efc_destroy(f->shared->efc) < 0)
+ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, NULL, "can't destroy external file cache")
+ if(f->shared->fcpl_id > 0)
+ if(H5I_dec_ref(f->shared->fcpl_id) < 0)
+ HDONE_ERROR(H5E_FILE, H5E_CANTDEC, NULL, "can't close property list")
+
f->shared = H5FL_FREE(H5F_file_t, f->shared);
+ } /* end if */
f = H5FL_FREE(H5F_t, f);
} /* end if */
@@ -1248,7 +1296,6 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id,
H5FD_class_t *drvr; /*file driver class info */
H5P_genplist_t *a_plist; /*file access property list */
H5F_close_degree_t fc_degree; /*file close degree */
- unsigned i; /*local index variable */
H5F_t *ret_value; /*actual return value */
FUNC_ENTER_NOAPI(NULL)
@@ -1331,7 +1378,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id,
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "SWMR read access flag not the same for file that is already open")
/* Allocate new "high-level" file struct */
- if((file = H5F_new(shared, fcpl_id, fapl_id, NULL)) == NULL)
+ if((file = H5F_new(shared, flags, fcpl_id, fapl_id, NULL)) == NULL)
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create new file object")
} /* end if */
else {
@@ -1352,57 +1399,18 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id,
} /* end if */
} /* end if */
- if(NULL == (file = H5F_new(NULL, fcpl_id, fapl_id, lf)))
+ if(NULL == (file = H5F_new(NULL, flags, fcpl_id, fapl_id, lf)))
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create new file object")
- file->shared->flags = flags;
} /* end else */
+ /* Retain the name the file was opened with */
+ file->open_name = H5MM_xstrdup(name);
+
/* Short cuts */
shared = file->shared;
lf = shared->lf;
/*
- * The intent at the top level file struct are not necessarily the same as
- * the flags at the bottom. The top level describes how the file can be
- * accessed through the HDF5 library. The bottom level describes how the
- * file can be accessed through the C library.
- */
- file->intent = flags;
- file->open_name = H5MM_xstrdup(name);
-
- /* Get the file access property list, for future queries */
- if(NULL == (a_plist = (H5P_genplist_t *)H5I_object(fapl_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list")
-
- /* Retrieve the # of read attempts here so that sohm in superblock will get the correct # of attempts */
- if(H5P_get(a_plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, &file->read_attempts) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get the # of read attempts")
-
- /* When opening file with SWMR access, the # of read attempts is H5F_SWMR_METADATA_READ_ATTEMPTS if not set */
- /* When opening file without SWMR access, the # of read attempts is always H5F_METADATA_READ_ATTEMPTS (set or not set) */
- if(file->intent & H5F_ACC_SWMR_READ || file->intent & H5F_ACC_SWMR_WRITE) {
- if(!file->read_attempts)
- file->read_attempts = H5F_SWMR_METADATA_READ_ATTEMPTS;
- /* Turn off accumulator */
- shared->feature_flags = lf->feature_flags & ~(unsigned)H5FD_FEAT_ACCUMULATE_METADATA;
- if(H5FD_set_feature_flags(lf, shared->feature_flags) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTSET, NULL, "can't set feature_flags in VFD")
- } else
- file->read_attempts = H5F_METADATA_READ_ATTEMPTS;
-
- /* Determine the # of bins for metdata read retries */
- file->retries_nbins = 0;
- if(file->read_attempts > 1) {
- double tmp;
- tmp = HDlog10((double)(file->read_attempts - 1));
- file->retries_nbins = (unsigned)tmp + 1;
- }
-
- /* Initialize the tracking for metadata read retries */
- for(i = 0; i < H5AC_NTYPES; i++)
- file->retries[i] = NULL;
-
- /*
* Read or write the file superblock, depending on whether the file is
* empty or not.
*/
@@ -1434,6 +1442,10 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id,
} /* end if */
+ /* Get the file access property list, for future queries */
+ if(NULL == (a_plist = (H5P_genplist_t *)H5I_object(fapl_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list")
+
/*
* Decide the file close degree. If it's the first time to open the
* file, set the degree to access property list value; if it's the
@@ -2148,7 +2160,6 @@ H5Freopen(hid_t file_id)
{
H5F_t *old_file = NULL;
H5F_t *new_file = NULL;
- unsigned i;
hid_t ret_value;
FUNC_ENTER_API(FAIL)
@@ -2159,20 +2170,9 @@ H5Freopen(hid_t file_id)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file")
/* Get a new "top level" file struct, sharing the same "low level" file struct */
- if(NULL == (new_file = H5F_new(old_file->shared, H5P_FILE_CREATE_DEFAULT, H5P_FILE_ACCESS_DEFAULT, NULL)))
+ if(NULL == (new_file = H5F_new(old_file->shared, 0, H5P_FILE_CREATE_DEFAULT, H5P_FILE_ACCESS_DEFAULT, NULL)))
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file")
- /* Keep old file's read/write intent in new file */
- new_file->intent = old_file->intent;
-
- /* Keep old file's read attempts in new file */
- new_file->read_attempts = old_file->read_attempts;
-
- new_file->retries_nbins = old_file->retries_nbins;
- for(i = 0; i < H5AC_NTYPES; i++)
- new_file->retries[i] = NULL;
-
-
/* Duplicate old file's names */
new_file->open_name = H5MM_xstrdup(old_file->open_name);
new_file->actual_name = H5MM_xstrdup(old_file->actual_name);
@@ -3186,7 +3186,7 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Fget_metadata_read_retries_info
+ * Function: H5Fget_metadata_read_retry_info
*
* Purpose: To retrieve the collection of read retries for metadata items with checksum.
*
@@ -3198,7 +3198,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5Fget_metadata_read_retries_info(hid_t file_id, H5F_retries_info_t *info)
+H5Fget_metadata_read_retry_info(hid_t file_id, H5F_retry_info_t *info)
{
H5F_t *file; /* File object for file ID */
unsigned i, j; /* Local index variable */
@@ -3217,11 +3217,10 @@ H5Fget_metadata_read_retries_info(hid_t file_id, H5F_retries_info_t *info)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID")
/* Copy the # of bins for "retries" array */
- info->nbins = file->retries_nbins;
+ info->nbins = file->shared->retries_nbins;
/* Initialize the array of "retries" */
- for(i = 0; i < NUM_METADATA_READ_RETRIES; i++)
- info->retries[i] = NULL;
+ HDmemset(info->retries, 0, sizeof(info->retries));
/* Return if there are no bins -- no retries */
if(!info->nbins)
@@ -3255,14 +3254,17 @@ H5Fget_metadata_read_retries_info(hid_t file_id, H5F_retries_info_t *info)
case H5AC_FARRAY_DBLOCK_ID:
case H5AC_FARRAY_DBLK_PAGE_ID:
case H5AC_SUPERBLOCK_ID:
- HDassert(j < NUM_METADATA_READ_RETRIES);
- if(file->retries[i] != NULL) {
+ HDassert(j < H5F_NUM_METADATA_READ_RETRY_TYPES);
+ if(file->shared->retries[i] != NULL) {
/* Allocate memory for retries[i] */
- if((info->retries[j] = (uint32_t *)HDmalloc(tot_size)) == NULL)
+ if(NULL == (info->retries[j] = (uint32_t *)HDmalloc(tot_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+
/* Copy the information */
- HDmemcpy(info->retries[j], file->retries[i], tot_size);
- }
+ HDmemcpy(info->retries[j], file->shared->retries[i], tot_size);
+ } /* end if */
+
+ /* Increment location in info->retries[] array */
j++;
break;
@@ -3273,7 +3275,7 @@ H5Fget_metadata_read_retries_info(hid_t file_id, H5F_retries_info_t *info)
done:
FUNC_LEAVE_API(ret_value)
-} /* end H5Fget_metadata_read_retries_info() */
+} /* end H5Fget_metadata_read_retry_info() */
/*-------------------------------------------------------------------------
@@ -3498,7 +3500,6 @@ H5F_set_store_msg_crt_idx(H5F_t *f, hbool_t flag)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5F_set_store_msg_crt_idx() */
-
/*-------------------------------------------------------------------------
* Function: H5F_track_metadata_read_retries
@@ -3506,8 +3507,8 @@ H5F_set_store_msg_crt_idx(H5F_t *f, hbool_t flag)
* Purpose: To track the # of a "retries" (log10) for a metadata item.
* This routine should be used only when:
* "retries" > 0
- * f->read_attempts > 1 (does not have retry when 1)
- * f->retries_nbins > 0 (calculated based on f->read_attempts)
+ * f->shared->read_attempts > 1 (does not have retry when 1)
+ * f->shared->retries_nbins > 0 (calculated based on f->shared->read_attempts)
*
* Return: Success: SUCCEED
* Failure: FAIL
@@ -3520,32 +3521,33 @@ herr_t
H5F_track_metadata_read_retries(H5F_t *f, unsigned actype, unsigned retries)
{
unsigned log_ind; /* Index to the array of retries based on log10 of retries */
- double tmp;
+ double tmp; /* Temporary value, to keep compiler quiet */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
/* Sanity check */
HDassert(f);
- HDassert(f->read_attempts > 1);
- HDassert(f->retries_nbins > 0);
+ HDassert(f->shared->read_attempts > 1);
+ HDassert(f->shared->retries_nbins > 0);
HDassert(retries > 0);
- HDassert(retries < f->read_attempts);
+ HDassert(retries < f->shared->read_attempts);
HDassert(actype < H5AC_NTYPES);
/* Allocate memory for retries */
- if(f->retries[actype] == NULL)
- if((f->retries[actype] = (uint32_t *)HDcalloc((size_t)f->retries_nbins, sizeof(uint32_t))) == NULL)
+ if(NULL == f->shared->retries[actype])
+ if(NULL == (f->shared->retries[actype] = (uint32_t *)HDcalloc((size_t)f->shared->retries_nbins, sizeof(uint32_t))))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
/* Index to retries based on log10 */
tmp = HDlog10((double)retries);
log_ind = (unsigned)tmp;
- HDassert(log_ind < f->retries_nbins);
+ HDassert(log_ind < f->shared->retries_nbins);
/* Increment the # of the "retries" */
- f->retries[actype][log_ind]++;
+ f->shared->retries[actype][log_ind]++;
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5F_track_metadata_read_retries() */
+
diff --git a/src/H5FAcache.c b/src/H5FAcache.c
index 56ed1e3..23832d1 100644
--- a/src/H5FAcache.c
+++ b/src/H5FAcache.c
@@ -169,8 +169,6 @@ H5FA__cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata))
uint8_t hdr_buf[H5FA_HDR_BUF_SIZE]; /* Buffer for header */
uint8_t *buf; /* Pointer to header buffer */
const uint8_t *p; /* Pointer into raw data buffer */
- uint32_t stored_chksum; /* Stored metadata checksum value */
- uint32_t computed_chksum; /* Computed metadata checksum value */
/* Check arguments */
HDassert(f);
@@ -195,7 +193,7 @@ H5FA__cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata))
H5E_THROW(H5E_CANTGET, "can't get actual buffer")
/* Read and vaildate header from disk */
- if(H5F_read_check_metadata(f, H5FD_MEM_FARRAY_HDR, H5AC_FARRAY_HDR_ID, addr, size, size, dxpl_id, buf, &computed_chksum) < 0)
+ if(H5F_read_check_metadata(f, dxpl_id, H5FD_MEM_FARRAY_HDR, H5AC_FARRAY_HDR_ID, addr, size, size, buf) < 0)
H5E_THROW(H5E_BADVALUE, "incorrect metadata checksum for fixed array header")
/* Get temporary pointer to serialized header */
@@ -252,15 +250,10 @@ H5FA__cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata))
/* (allow for checksum not decoded yet) */
HDassert((size_t)(p - buf) == (size - H5FA_SIZEOF_CHKSUM));
- /* Metadata checksum */
- UINT32DECODE(p, stored_chksum);
+ /* Already decoded and compared stored checksum earlier, when reading */
/* Sanity check */
- HDassert((size_t)(p - buf) == size);
-
- /* Verify checksum with checksum computed via H5F_read_check_metadata() */
- if(stored_chksum != computed_chksum)
- H5E_THROW(H5E_BADVALUE, "incorrect metadata checksum for fixed array header")
+ HDassert((size_t)(p - buf) == (size - H5_SIZEOF_CHKSUM));
/* Finish initializing fixed array header */
if(H5FA__hdr_init(hdr, udata) < 0)
@@ -508,8 +501,6 @@ H5FA__cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata))
uint8_t dblock_buf[H5FA_DBLOCK_BUF_SIZE]; /* Buffer for data block */
uint8_t *buf; /* Pointer to data block buffer */
const uint8_t *p; /* Pointer into raw data buffer */
- uint32_t stored_chksum; /* Stored metadata checksum value */
- uint32_t computed_chksum; /* Computed metadata checksum value */
haddr_t arr_addr; /* Address of array header in the file */
/* Sanity check */
@@ -538,8 +529,8 @@ H5FA__cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata))
if(NULL == (buf = (uint8_t *)H5WB_actual(wb, size)))
H5E_THROW(H5E_CANTGET, "can't get actual buffer")
- /* Read and validate data block from disk */
- if(H5F_read_check_metadata(f, H5FD_MEM_FARRAY_DBLOCK, H5AC_FARRAY_DBLOCK_ID, addr, size, size, dxpl_id, buf, &computed_chksum) < 0)
+ /* Read and validate data block from disk */
+ if(H5F_read_check_metadata(f, dxpl_id, H5FD_MEM_FARRAY_DBLOCK, H5AC_FARRAY_DBLOCK_ID, addr, size, size, buf) < 0)
H5E_THROW(H5E_BADVALUE, "incorrect metadata checksum for fixed array data block")
/* Get temporary pointer to serialized header */
@@ -585,15 +576,10 @@ H5FA__cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata))
/* Set the data block's size */
dblock->size = H5FA_DBLOCK_SIZE(dblock);
- /* Metadata checksum */
- UINT32DECODE(p, stored_chksum);
+ /* Already decoded and compared stored checksum earlier, when reading */
/* Sanity check */
- HDassert((size_t)(p - buf) == size);
-
- /* Verify checksum with checksum computed via H5F_read_check_metadata() */
- if(stored_chksum != computed_chksum)
- H5E_THROW(H5E_BADVALUE, "incorrect metadata checksum for fixed array data block")
+ HDassert((size_t)(p - buf) == (size - H5_SIZEOF_CHKSUM));
/* Set return value */
ret_value = dblock;
@@ -902,8 +888,6 @@ H5FA__cache_dblk_page_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata))
uint8_t dblk_page_buf[H5FA_DBLK_PAGE_BUF_SIZE]; /* Buffer for data block page */
uint8_t *buf; /* Pointer to data block page buffer */
const uint8_t *p; /* Pointer into raw data buffer */
- uint32_t stored_chksum; /* Stored metadata checksum value */
- uint32_t computed_chksum; /* Computed metadata checksum value */
/* Sanity check */
HDassert(f);
@@ -932,7 +916,7 @@ HDfprintf(stderr, "%s: addr = %a\n", FUNC, addr);
H5E_THROW(H5E_CANTGET, "can't get actual buffer")
/* Read and validate data block page from disk */
- if(H5F_read_check_metadata(f, H5FD_MEM_FARRAY_DBLK_PAGE, H5AC_FARRAY_DBLK_PAGE_ID, addr, size, size, dxpl_id, buf, &computed_chksum) < 0)
+ if(H5F_read_check_metadata(f, dxpl_id, H5FD_MEM_FARRAY_DBLK_PAGE, H5AC_FARRAY_DBLK_PAGE_ID, addr, size, size, buf) < 0)
H5E_THROW(H5E_BADVALUE, "incorrect metadata checksum for fixed array data block page")
/* Get temporary pointer to serialized header */
@@ -953,15 +937,10 @@ HDfprintf(stderr, "%s: addr = %a\n", FUNC, addr);
/* Set the data block page's size */
dblk_page->size = size;
- /* Metadata checksum */
- UINT32DECODE(p, stored_chksum);
+ /* Already decoded and compared stored checksum earlier, when reading */
/* Sanity check */
- HDassert((size_t)(p - buf) == dblk_page->size);
-
- /* Verify checksum */
- if(stored_chksum != computed_chksum)
- H5E_THROW(H5E_BADVALUE, "incorrect metadata checksum for fixed array data block page")
+ HDassert((size_t)(p - buf) == (dblk_page->size - H5_SIZEOF_CHKSUM));
/* Set return value */
ret_value = dblk_page;
diff --git a/src/H5FScache.c b/src/H5FScache.c
index c3511ac..ac8d546 100644
--- a/src/H5FScache.c
+++ b/src/H5FScache.c
@@ -156,8 +156,6 @@ H5FS_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
uint8_t hdr_buf[H5FS_HDR_BUF_SIZE]; /* Buffer for header */
uint8_t *hdr; /* Pointer to header buffer */
const uint8_t *p; /* Pointer into raw data buffer */
- uint32_t stored_chksum; /* Stored metadata checksum value */
- uint32_t computed_chksum; /* Computed metadata checksum value */
unsigned nclasses; /* Number of section classes */
H5FS_t *ret_value; /* Return value */
@@ -183,7 +181,7 @@ H5FS_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
HGOTO_ERROR(H5E_FSPACE, H5E_NOSPACE, NULL, "can't get actual buffer")
/* Read and validate header from disk */
- if(H5F_read_check_metadata(f, H5FD_MEM_FSPACE_HDR, H5AC_FSPACE_HDR_ID, addr, fspace->hdr_size, fspace->hdr_size, dxpl_id, hdr, &computed_chksum) < 0)
+ if(H5F_read_check_metadata(f, dxpl_id, H5FD_MEM_FSPACE_HDR, H5AC_FSPACE_HDR_ID, addr, fspace->hdr_size, fspace->hdr_size, hdr) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_BADVALUE, NULL, "incorrect metadata checksum for free space header")
p = hdr;
@@ -241,14 +239,10 @@ H5FS_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
/* Allocated size of serialized free space sections */
H5F_DECODE_LENGTH(udata->f, p, fspace->alloc_sect_size);
- /* Metadata checksum */
- UINT32DECODE(p, stored_chksum);
+ /* Already decoded and compared stored checksum earlier, when reading */
- HDassert((size_t)(p - (const uint8_t *)hdr) == fspace->hdr_size);
-
- /* Verify checksum with checksum computed via H5F_read_check_metadata() */
- if(stored_chksum != computed_chksum)
- HGOTO_ERROR(H5E_FSPACE, H5E_BADVALUE, NULL, "incorrect metadata checksum for free space header")
+ /* Sanity check */
+ HDassert((size_t)(p - (const uint8_t *)hdr) == (fspace->hdr_size - H5_SIZEOF_CHKSUM));
/* Set return value */
ret_value = fspace;
@@ -555,8 +549,6 @@ H5FS_cache_sinfo_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata
size_t old_sect_size; /* Old section size */
uint8_t *buf = NULL; /* Temporary buffer */
const uint8_t *p; /* Pointer into raw data buffer */
- uint32_t stored_chksum; /* Stored metadata checksum value */
- uint32_t computed_chksum; /* Computed metadata checksum value */
H5FS_sinfo_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -575,7 +567,7 @@ H5FS_cache_sinfo_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Read and validate free space sections from disk */
- if(H5F_read_check_metadata(f, H5FD_MEM_FSPACE_SINFO, H5AC_FSPACE_SINFO_ID, udata->fspace->sect_addr, (size_t)udata->fspace->sect_size, (size_t)udata->fspace->sect_size, dxpl_id, buf, &computed_chksum) < 0)
+ if(H5F_read_check_metadata(f, dxpl_id, H5FD_MEM_FSPACE_SINFO, H5AC_FSPACE_SINFO_ID, udata->fspace->sect_addr, (size_t)udata->fspace->sect_size, (size_t)udata->fspace->sect_size, buf) < 0)
HGOTO_ERROR(H5E_FSPACE, H5E_BADVALUE, NULL, "incorrect metadata checksum for free space sections")
/* Deserialize free sections from buffer available */
@@ -668,15 +660,10 @@ H5FS_cache_sinfo_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata
HDassert(old_tot_space == udata->fspace->tot_space);
} /* end if */
- /* Metadata checksum */
- UINT32DECODE(p, stored_chksum);
-
- /* Verify checksum with checksum computed via H5F_read_check_metadata() */
- if(stored_chksum != computed_chksum)
- HGOTO_ERROR(H5E_FSPACE, H5E_BADVALUE, NULL, "incorrect metadata checksum for free space sections")
+ /* Already decoded and compared stored checksum earlier, when reading */
/* Sanity check */
- HDassert((size_t)(p - (const uint8_t *)buf) == old_sect_size);
+ HDassert((size_t)(p - (const uint8_t *)buf) == (old_sect_size - H5_SIZEOF_CHKSUM));
/* Set return value */
ret_value = sinfo;
diff --git a/src/H5Faccum.c b/src/H5Faccum.c
index 529384b..949ebde 100644
--- a/src/H5Faccum.c
+++ b/src/H5Faccum.c
@@ -431,7 +431,7 @@ H5F_accum_write(const H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr,
HDassert(f);
HDassert(f->shared);
- HDassert(f->intent & H5F_ACC_RDWR);
+ HDassert(H5F_INTENT(f) & H5F_ACC_RDWR);
HDassert(buf);
/* Treat global heap as raw data */
@@ -731,7 +731,7 @@ HDmemset(f->shared->accum.buf + size, 0, (f->shared->accum.alloc_size - size));
} /* end else */
} /* end if */
else {
- if((f->intent & H5F_ACC_SWMR_WRITE) > 0) {
+ if((H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) > 0) {
/* Flush if dirty and reset accumulator */
if(H5F_accum_reset(f, dxpl_id, TRUE) < 0)
HGOTO_ERROR(H5E_IO, H5E_CANTRESET, FAIL, "can't reset accumulator")
diff --git a/src/H5Fio.c b/src/H5Fio.c
index 6c2e8c1..5faeaca 100644
--- a/src/H5Fio.c
+++ b/src/H5Fio.c
@@ -145,7 +145,7 @@ HDfprintf(stderr, "%s: write to addr = %a, size = %Zu\n", FUNC, addr, size);
HDassert(f);
HDassert(f->shared);
- HDassert(f->intent & H5F_ACC_RDWR);
+ HDassert(H5F_INTENT(f) & H5F_ACC_RDWR);
HDassert(buf);
HDassert(H5F_addr_defined(addr));
@@ -243,6 +243,8 @@ done:
* Purpose: Decode checksum stored in the buffer
* Calculate checksum for the data in the buffer
*
+ * Note: Assumes that the checksum is the last data in the buffer
+ *
* Return: Non-negative on success/Negative on failure
*
* Programmer: Vailin Choi; Sept 2013
@@ -250,34 +252,28 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5F_get_checksums(uint8_t *buf, size_t chk_size, uint32_t *s_chksum/*out*/, uint32_t *c_chksum/*out*/)
+H5F_get_checksums(const uint8_t *buf, size_t buf_size, uint32_t *s_chksum/*out*/, uint32_t *c_chksum/*out*/)
{
- uint32_t stored_chksum; /* Stored metadata checksum value */
- uint32_t computed_chksum; /* Computed metadata checksum value */
- const uint8_t *chk_p; /* Pointer into raw data buffer */
-
FUNC_ENTER_NOAPI_NOINIT_NOERR
/* Check arguments */
HDassert(buf);
- HDassert(chk_size);
+ HDassert(buf_size);
- /* Compute checksum for the buffer */
- computed_chksum = H5_checksum_metadata(buf, chk_size - H5_SIZEOF_CHKSUM, 0);
+ /* Return the stored checksum */
+ if(s_chksum) {
+ const uint8_t *chk_p; /* Pointer into raw data buffer */
- /* Offset to the checksum in the buffer */
- chk_p = buf + chk_size - H5_SIZEOF_CHKSUM;
+ /* Offset to the checksum in the buffer */
+ chk_p = buf + buf_size - H5_SIZEOF_CHKSUM;
- /* Decode the checksum stored in the buffer */
- UINT32DECODE(chk_p, stored_chksum);
+ /* Decode the checksum stored in the buffer */
+ UINT32DECODE(chk_p, *s_chksum);
+ } /* end if */
- /* Return the stored checksum */
- if(s_chksum)
- *s_chksum = stored_chksum;
-
- /* Return the computed checksum */
+ /* Return the computed checksum for the buffer */
if(c_chksum)
- *c_chksum = computed_chksum;
+ *c_chksum = H5_checksum_metadata(buf, buf_size - H5_SIZEOF_CHKSUM, 0);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5F_get_chksums() */
@@ -288,13 +284,14 @@ H5F_get_checksums(uint8_t *buf, size_t chk_size, uint32_t *s_chksum/*out*/, uint
*
* Purpose: Attempts to read and validate a piece of meatadata that has
* checksum as follows:
- * a) read the piece of metadata
- * b) calculate checksum for the buffer of metadata
- * c) decode the checksum stored in the buffer of metadata
- * d) compare the computed checksum with its stored checksum
+ * a) read the piece of metadata
+ * b) calculate checksum for the buffer of metadata
+ * c) decode the checksum stored in the buffer of metadata
+ * d) compare the computed checksum with its stored checksum
+ *
* The library will perform (a) to (d) above for "f->read_attempts"
* times or until the checksum comparison in (d) passes.
- * This routine also tracks the # of retries via
+ * This routine also records the # of retries via
* H5F_track_metadata_read_retries()
*
* Return: Non-negative on success/Negative on failure
@@ -304,8 +301,9 @@ H5F_get_checksums(uint8_t *buf, size_t chk_size, uint32_t *s_chksum/*out*/, uint
*-------------------------------------------------------------------------
*/
herr_t
-H5F_read_check_metadata(H5F_t *f, H5FD_mem_t type, unsigned actype, haddr_t addr, size_t read_size, size_t chk_size,
- hid_t dxpl_id, uint8_t *buf/*out*/, uint32_t *chksum/*out*/)
+H5F_read_check_metadata(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type,
+ unsigned actype, haddr_t addr, size_t read_size, size_t chk_size,
+ uint8_t *buf/*out*/)
{
unsigned tries, max_tries; /* The # of read attempts */
unsigned retries; /* The # of retries */
@@ -316,7 +314,7 @@ H5F_read_check_metadata(H5F_t *f, H5FD_mem_t type, unsigned actype, haddr_t addr
FUNC_ENTER_NOAPI(FAIL)
/* Get the # of read attempts */
- max_tries = tries = f->read_attempts;
+ max_tries = tries = H5F_GET_READ_ATTEMPTS(f);
do {
/* Read header from disk */
@@ -329,25 +327,20 @@ H5F_read_check_metadata(H5F_t *f, H5FD_mem_t type, unsigned actype, haddr_t addr
/* Verify checksum */
if(stored_chksum == computed_chksum)
break;
-
} while(--tries);
+ /* Check for too many tries */
if(tries == 0)
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "incorrect metadatda checksum after all read attempts (%u) for %u bytes:c_chksum=%u, s_chkum=%u",
max_tries, chk_size, computed_chksum, stored_chksum)
/* Calculate and track the # of retries */
retries = max_tries - tries;
- if(retries) { /* Does not track 0 retry */
- HDfprintf(stderr, "%s: SUCCESS after %u retries; actype=%u\n", FUNC, retries, actype);
+ if(retries) /* Does not track 0 retry */
if(H5F_track_metadata_read_retries(f, actype, retries) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "cannot track read tries = %u ", retries)
- }
-
- /* Return the computed checksum */
- if(chksum)
- *chksum = computed_chksum;
done:
FUNC_LEAVE_NOAPI(ret_value);
} /* end H5F_read_check_metadata */
+
diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h
index 55e2c3a..1cc631c 100644
--- a/src/H5Fpkg.h
+++ b/src/H5Fpkg.h
@@ -255,6 +255,11 @@ struct H5F_file_t {
/* Metadata accumulator information */
H5F_meta_accum_t accum; /* Metadata accumulator info */
+
+ /* Metadata retry info */
+ unsigned read_attempts; /* The # of reads to try when reading metadata with checksum */
+ unsigned retries_nbins; /* # of bins for each retries[] */
+ uint32_t *retries[H5AC_NTYPES]; /* Track # of read retries for metdata items with checksum */
};
/*
@@ -263,8 +268,6 @@ struct H5F_file_t {
* to shared H5F_file_t structs.
*/
struct H5F_t {
- unsigned intent; /* The flags passed to H5F_open()*/
- unsigned read_attempts; /* The # of reads to try when reading metadata with checksum */
char *open_name; /* Name used to open file */
char *actual_name; /* Actual name of the file, after resolving symlinks, etc. */
char *extpath; /* Path for searching target external link file */
@@ -275,8 +278,6 @@ struct H5F_t {
hbool_t closing; /* File is in the process of being closed */
struct H5F_t *parent; /* Parent file that this file is mounted to */
unsigned nmounts; /* Number of children mounted to this file */
- uint32_t *retries[H5AC_NTYPES]; /* Track # of read retries for metdata items with checksum */
- unsigned retries_nbins; /* # of bins for each retries[] */
};
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index cac34b7..8dd6ec3 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -280,7 +280,7 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t;
/* If the module using this macro is allowed access to the private variables, access them directly */
#ifdef H5F_PACKAGE
-#define H5F_INTENT(F) ((F)->intent)
+#define H5F_INTENT(F) ((F)->shared->flags)
#define H5F_OPEN_NAME(F) ((F)->open_name)
#define H5F_ACTUAL_NAME(F) ((F)->actual_name)
#define H5F_EXTPATH(F) ((F)->extpath)
@@ -292,7 +292,7 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t;
#define H5F_FILE_ID(F) ((F)->file_id)
#define H5F_PARENT(F) ((F)->parent)
#define H5F_NMOUNTS(F) ((F)->nmounts)
-#define H5F_GET_READ_ATTEMPTS(F) ((F)->read_attempts)
+#define H5F_GET_READ_ATTEMPTS(F) ((F)->shared->read_attempts)
#define H5F_DRIVER_ID(F) ((F)->shared->lf->driver_id)
#define H5F_GET_FILENO(F,FILENUM) ((FILENUM) = (F)->shared->lf->fileno)
#define H5F_HAS_FEATURE(F,FL) ((F)->shared->lf->feature_flags & (FL))
@@ -335,7 +335,7 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t;
#define H5F_FILE_ID(F) (H5F_get_file_id(F))
#define H5F_PARENT(F) (H5F_get_parent(F))
#define H5F_NMOUNTS(F) (H5F_get_nmounts(F))
-#define H5F_GET_READ_ATTEMPTS(F) (H5F_get_read_attempts(F))
+#define H5F_GET_READ_ATTEMPTS(F) (H5F_get_read_attempts(F))
#define H5F_DRIVER_ID(F) (H5F_get_driver_id(F))
#define H5F_GET_FILENO(F,FILENUM) (H5F_get_fileno((F), &(FILENUM)))
#define H5F_HAS_FEATURE(F,FL) (H5F_has_feature(F,FL))
@@ -499,17 +499,20 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t;
/* Default free space section threshold used by free-space managers */
#define H5F_FREE_SPACE_THRESHOLD_DEF 1
+/* Metadata read attempt values */
+#define H5F_METADATA_READ_ATTEMPTS 1 /* Default # of read attempts for non-SWMR access */
+#define H5F_SWMR_METADATA_READ_ATTEMPTS 100 /* Default # of read attempts for SWMR access */
+
/* Macros to define signatures of all objects in the file */
/* Size of signature information (on disk) */
/* (all on-disk signatures should be this length) */
#define H5_SIZEOF_MAGIC 4
+/* Size of checksum information (on disk) */
+/* (all on-disk checksums should be this length) */
#define H5_SIZEOF_CHKSUM 4
-#define H5F_METADATA_READ_ATTEMPTS 1 /* Default # of read attempts for non-SWMR access */
-#define H5F_SWMR_METADATA_READ_ATTEMPTS 100 /* Default # of read attempts for SWMR access */
-
/* v1 B-tree node signature */
#define H5B_MAGIC "TREE"
@@ -638,10 +641,12 @@ H5_DLL herr_t H5F_block_write(const H5F_t *f, H5FD_mem_t type, haddr_t addr,
H5_DLL herr_t H5F_flush_tagged_metadata(H5F_t * f, haddr_t tag, hid_t dxpl_id);
H5_DLL herr_t H5F_evict_tagged_metadata(H5F_t * f, haddr_t tag, hid_t dxpl_id);
-/* Function that read and verify a piece of metadata with checksum */
-H5_DLL herr_t H5F_read_check_metadata(H5F_t *f, H5FD_mem_t type, unsigned actype, haddr_t addr, size_t read_size, size_t chk_size,
- hid_t dxpl_id, uint8_t *buf/*out*/, uint32_t *chksum/*out*/);
-H5_DLL herr_t H5F_get_checksums(uint8_t *buf, size_t chk_size, uint32_t *s_chksum, uint32_t *c_chksum);
+/* Functions that read & verify a piece of metadata with checksum */
+H5_DLL herr_t H5F_read_check_metadata(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type,
+ unsigned actype, haddr_t addr, size_t read_size, size_t chk_size,
+ uint8_t *buf/*out*/);
+H5_DLL herr_t H5F_get_checksums(const uint8_t *buf, size_t chk_size, uint32_t *s_chksum, uint32_t *c_chksum);
+
/* Routine to track the # of retries */
H5_DLL herr_t H5F_track_metadata_read_retries(H5F_t *f, unsigned actype, unsigned retries);
diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h
index b2c1b6b..c1d96ca 100644
--- a/src/H5Fpublic.h
+++ b/src/H5Fpublic.h
@@ -186,12 +186,12 @@ typedef enum H5F_file_space_type_t {
} H5F_file_space_type_t;
/* Data structure to report the collection of read retries for metadata items with checksum */
-/* Used by public routine H5Fget_metadata_read_retries_info() */
-#define NUM_METADATA_READ_RETRIES 21
-typedef struct H5F_retries_info_t {
+/* Used by public routine H5Fget_metadata_read_retry_info() */
+#define H5F_NUM_METADATA_READ_RETRY_TYPES 21
+typedef struct H5F_retry_info_t {
unsigned nbins;
- uint32_t *retries[NUM_METADATA_READ_RETRIES];
-} H5F_retries_info_t;
+ uint32_t *retries[H5F_NUM_METADATA_READ_RETRY_TYPES];
+} H5F_retry_info_t;
#ifdef __cplusplus
extern "C" {
@@ -230,7 +230,7 @@ H5_DLL herr_t H5Fget_mdc_size(hid_t file_id,
H5_DLL herr_t H5Freset_mdc_hit_rate_stats(hid_t file_id);
H5_DLL ssize_t H5Fget_name(hid_t obj_id, char *name, size_t size);
H5_DLL herr_t H5Fget_info2(hid_t obj_id, H5F_info2_t *finfo);
-H5_DLL herr_t H5Fget_metadata_read_retries_info(hid_t file_id, H5F_retries_info_t *info);
+H5_DLL herr_t H5Fget_metadata_read_retry_info(hid_t file_id, H5F_retry_info_t *info);
H5_DLL ssize_t H5Fget_free_sections(hid_t file_id, H5F_mem_t type,
size_t nsects, H5F_sect_info_t *sect_info/*out*/);
H5_DLL herr_t H5Fclear_elink_file_cache(hid_t file_id);
diff --git a/src/H5Fquery.c b/src/H5Fquery.c
index 02d40d8..fb3b490 100644
--- a/src/H5Fquery.c
+++ b/src/H5Fquery.c
@@ -98,7 +98,7 @@ H5F_get_intent(const H5F_t *f)
HDassert(f);
- FUNC_LEAVE_NOAPI(f->intent)
+ FUNC_LEAVE_NOAPI(f->shared->flags)
} /* end H5F_get_intent() */
@@ -340,7 +340,7 @@ H5F_get_read_attempts(const H5F_t *f)
HDassert(f);
- FUNC_LEAVE_NOAPI(f->read_attempts)
+ FUNC_LEAVE_NOAPI(f->shared->read_attempts)
} /* end H5F_get_read_attempts() */
diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c
index fece50b..74b122b 100644
--- a/src/H5Fsuper_cache.c
+++ b/src/H5Fsuper_cache.c
@@ -123,17 +123,16 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata)
haddr_t eof; /*end of file address */
uint8_t sizeof_addr; /* Size of offsets in the file (in bytes) */
uint8_t sizeof_size; /* Size of lengths in the file (in bytes) */
- const size_t fixed_size = H5F_SUPERBLOCK_FIXED_SIZE; /*fixed sizeof superblock */
+ const size_t fixed_size = H5F_SUPERBLOCK_FIXED_SIZE; /*fixed sizeof superblock */
size_t variable_size; /*variable sizeof superblock */
uint8_t *p; /* Temporary pointer into encoding buffer */
unsigned super_vers; /* Superblock version */
- hbool_t *dirtied = (hbool_t *)_udata; /* Set up dirtied out value */
+ hbool_t *dirtied = (hbool_t *)_udata; /* Set up dirtied out value */
unsigned tries, max_tries; /* The # of read attempts to try */
- unsigned fixed_tries; /* The # of read attempts to try for the fixed-size portion */
unsigned retries; /* The # of retries */
uint32_t computed_chksum; /* Computed checksum */
uint32_t stored_chksum; /* Checksum read from file */
- H5F_super_t *ret_value; /* Return value */
+ H5F_super_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -167,36 +166,23 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata)
H5_CHECK_OVERFLOW(fixed_size, size_t, haddr_t);
/* Get the # of read attempts */
- tries = max_tries = f->read_attempts;
+ tries = max_tries = H5F_GET_READ_ATTEMPTS(f);
+ retries = 0;
do {
- fixed_tries = max_tries;
- do {
- /* Read fixed-size portion of the superblock */
- p = sbuf;
- if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, (haddr_t)fixed_size) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "set end of space allocation request failed")
- if(H5FD_read(lf, dxpl_id, H5FD_MEM_SUPER, (haddr_t)0, fixed_size, p) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_READERROR, NULL, "unable to read superblock")
-
- /* Skip over signature (already checked when locating the superblock) */
- p += H5F_SIGNATURE_LEN;
-
- /* Superblock version */
- super_vers = *p++;
-
- /* A valid version # */
- if(super_vers <= HDF5_SUPERBLOCK_VERSION_LATEST)
- break;
-
- } while (--fixed_tries);
-
- if(fixed_tries == 0)
- /* After all tries (for SWMR access) or after 1 try (for non-SWMR) */
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "bad superblock version number after all tries")
- else if((max_tries - fixed_tries + 1) > 1)
- HDfprintf(stderr, "%s: SUCCESS after %u attempts for fixed data\n", FUNC, max_tries - fixed_tries + 1);
+ /* Read fixed-size portion of the superblock */
+ p = sbuf;
+ if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, (haddr_t)fixed_size) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "set end of space allocation request failed")
+ if(H5FD_read(lf, dxpl_id, H5FD_MEM_SUPER, (haddr_t)0, fixed_size, p) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_READERROR, NULL, "unable to read superblock")
+
+ /* Skip over signature (already checked when locating the superblock) */
+ p += H5F_SIGNATURE_LEN;
- /* Set superblock version in property list */
+ /* Superblock version */
+ super_vers = *p++;
+ if(super_vers > HDF5_SUPERBLOCK_VERSION_LATEST)
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad superblock version number")
if(H5P_set(c_plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set superblock version")
@@ -224,7 +210,7 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata)
/* Decode size of file addresses at this point to get the correct H5F_SIZEOF_ADDR(f) for checksum */
sizeof_addr = *p++;
if(sizeof_addr == 2 || sizeof_addr == 4 ||
- sizeof_addr == 8 || sizeof_addr == 16 || sizeof_addr == 32) {
+ sizeof_addr == 8 || sizeof_addr == 16 || sizeof_addr == 32) {
if(H5P_set(c_plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &sizeof_addr) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set byte number in an address")
@@ -236,19 +222,17 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata)
/* Verify correct checksum */
if(stored_chksum == computed_chksum)
break;
- }
+ } /* end if */
} while (--tries);
if(tries == 0)
/* After all tries (for SWMR access) or after 1 try (for non-SWMR) */
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "bad checksum or bad byte number in superblock")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "bad checksum or bad byte value in superblock")
- retries = max_tries - tries;
- if(retries) { /* Does not track 0 retry */
- HDfprintf(stderr, "%s: SUCCESS after %u retries\n", FUNC, retries);
+ retries += (max_tries - tries);
+ if(retries) /* Does not track 0 retry */
if(H5F_track_metadata_read_retries(f, H5AC_SUPERBLOCK_ID, retries) < 0)
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "cannot track read retries = %u ", retries)
- }
/* Check for older version of superblock format */
if(super_vers < HDF5_SUPERBLOCK_VERSION_2) {
@@ -443,7 +427,7 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata)
} /* end if */
else {
- /* Already decode sizeof_addr when validating checksum up there */
+ /* Already decoded sizeof_addr (and set property) when validating checksum earlier */
/* Size of file sizes */
sizeof_size = *p++;
@@ -465,12 +449,7 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata)
H5F_addr_decode(f, (const uint8_t **)&p, &stored_eoa/*out*/);
H5F_addr_decode(f, (const uint8_t **)&p, &sblock->root_addr/*out*/);
- /* Decode checksum */
- UINT32DECODE(p, stored_chksum);
-
- /* Verify correct checksum with checksum computed via H5F_get_checksums() */
- if(stored_chksum != computed_chksum)
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "bad checksum on superblock")
+ /* Already decoded and compared stored checksum earlier, when reading */
/*
* Check if superblock address is different from base address and
@@ -518,7 +497,7 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata)
* as the file can appear truncated if only part of it has been
* been flushed to disk by the single writer process.)
*/
- if (!(f->intent & H5F_ACC_SWMR_READ)) {
+ if (!(H5F_INTENT(f) & H5F_ACC_SWMR_READ)) {
if(HADDR_UNDEF == (eof = H5FD_get_eof(lf)))
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to determine file size")
diff --git a/src/H5HFcache.c b/src/H5HFcache.c
index b7b4111..4557bab 100644
--- a/src/H5HFcache.c
+++ b/src/H5HFcache.c
@@ -59,6 +59,14 @@
/* Size of stack buffer for serialized indirect blocks */
#define H5HF_IBLOCK_BUF_SIZE 4096
+/* Size of minimum header to decode for determining the full header size */
+#define H5HF_MIN_HEADER_SIZE ( \
+ H5_SIZEOF_MAGIC + /* Signature */ \
+ 1 + /* Version */ \
+ 2 + /* Heap ID len */ \
+ 2 /* I/O filters' encoded len */ \
+ )
+
/******************/
/* Local Typedefs */
@@ -78,10 +86,6 @@
static herr_t H5HF_dtable_encode(H5F_t *f, uint8_t **pp, const H5HF_dtable_t *dtable);
static herr_t H5HF_dtable_decode(H5F_t *f, const uint8_t **pp, H5HF_dtable_t *dtable);
-/* Decode minimum header and full header routines */
-static herr_t H5HF_min_header_decode(const uint8_t **pp, H5HF_hdr_t *hdr);
-static herr_t H5HF_full_header_decode(H5F_t *f, hid_t dxpl_id, const uint8_t **pp, H5HF_hdr_t *hdr);
-
/* Metadata cache (H5AC) callbacks */
static H5HF_hdr_t *H5HF_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata);
static herr_t H5HF_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HF_hdr_t *hdr, unsigned UNUSED * flags_ptr);
@@ -251,135 +255,6 @@ H5HF_dtable_encode(H5F_t *f, uint8_t **pp, const H5HF_dtable_t *dtable)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5HF_dtable_encode() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5HF_min_header_decode
- *
- * Purpose: Decodes enough info in the header to determine full header size
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Vailin Choi; Sept 2013
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5HF_min_header_decode(const uint8_t **pp, H5HF_hdr_t *hdr)
-{
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT
-
- /* Check arguments */
- HDassert(pp && *pp);
- HDassert(hdr);
-
- /* Magic number */
- if(HDmemcmp(*pp, H5HF_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "wrong fractal heap header signature")
- *pp += H5_SIZEOF_MAGIC;
-
- /* Version */
- if(**pp != H5HF_HDR_VERSION)
- HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "wrong fractal heap header version")
- (*pp)++;
-
- /* General heap information */
- UINT16DECODE(*pp, hdr->id_len); /* Heap ID length */
- UINT16DECODE(*pp, hdr->filter_len); /* I/O filters' encoded length */
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5HF_min_header_decode() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5HF_full_header_decode
- *
- * Purpose: Decodes info for the full header (fixed-len + variable-len)
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Vailin Choi; Sept 2013
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5HF_full_header_decode(H5F_t *f, hid_t dxpl_id, const uint8_t **pp, H5HF_hdr_t *hdr)
-{
- uint8_t heap_flags; /* Status flags for heap */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT
-
- /* Check arguments */
- HDassert(pp && *pp);
- HDassert(hdr);
-
- /* Decode the minimum header info */
- if(H5HF_min_header_decode(pp, hdr) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, FAIL, "can't decode minimum header info")
-
- /* Heap status flags */
- /* (bit 0: "huge" object IDs have wrapped) */
- /* (bit 1: checksum direct blocks) */
- heap_flags = **pp;
- (*pp)++;
-
- hdr->huge_ids_wrapped = heap_flags & H5HF_HDR_FLAGS_HUGE_ID_WRAPPED;
- hdr->checksum_dblocks = heap_flags & H5HF_HDR_FLAGS_CHECKSUM_DBLOCKS;
-
- /* "Huge" object information */
- UINT32DECODE(*pp, hdr->max_man_size); /* Max. size of "managed" objects */
- H5F_DECODE_LENGTH(f, *pp, hdr->huge_next_id); /* Next ID to use for "huge" object */
- H5F_addr_decode(f, pp, &hdr->huge_bt2_addr); /* Address of "huge" object tracker B-tree */
-
- /* "Managed" object free space information */
- H5F_DECODE_LENGTH(f, *pp, hdr->total_man_free); /* Internal free space in managed direct blocks */
- H5F_addr_decode(f, pp, &hdr->fs_addr); /* Address of free section header */
-
- /* Heap statistics */
- H5F_DECODE_LENGTH(f, *pp, hdr->man_size);
- H5F_DECODE_LENGTH(f, *pp, hdr->man_alloc_size);
- H5F_DECODE_LENGTH(f, *pp, hdr->man_iter_off);
- H5F_DECODE_LENGTH(f, *pp, hdr->man_nobjs);
- H5F_DECODE_LENGTH(f, *pp, hdr->huge_size);
- H5F_DECODE_LENGTH(f, *pp, hdr->huge_nobjs);
- H5F_DECODE_LENGTH(f, *pp, hdr->tiny_size);
- H5F_DECODE_LENGTH(f, *pp, hdr->tiny_nobjs);
-
- /* Managed objects' doubling-table info */
- if(H5HF_dtable_decode(f, pp, &(hdr->man_dtable)) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTENCODE, FAIL, "unable to encode managed obj. doubling table info")
-
- /* Check for I/O filter information to decode */
- if(hdr->filter_len > 0) {
- H5O_pline_t *pline; /* Pipeline information from the header on disk */
-
- /* Decode the size of a filtered root direct block */
- H5F_DECODE_LENGTH(f, *pp, hdr->pline_root_direct_size);
-
- /* Decode the filter mask for a filtered root direct block */
- UINT32DECODE(*pp, hdr->pline_root_direct_filter_mask);
-
- /* Decode I/O filter information */
- if(NULL == (pline = (H5O_pline_t *)H5O_msg_decode(f, dxpl_id, NULL, H5O_PLINE_ID, *pp)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, FAIL, "can't decode I/O pipeline filters")
- *pp += hdr->filter_len;
-
- /* Copy the information into the header's I/O pipeline structure */
- if(NULL == H5O_msg_copy(H5O_PLINE_ID, pline, &(hdr->pline)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTCOPY, FAIL, "can't copy I/O filter pipeline")
-
- /* Release the space allocated for the I/O pipeline filters */
- H5O_msg_free(H5O_PLINE_ID, pline);
- } /* end if */
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5HF_full_header_decode() */
-
/*-------------------------------------------------------------------------
* Function: H5HF_cache_hdr_load
@@ -400,17 +275,18 @@ H5HF_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
{
H5HF_hdr_t *hdr = NULL; /* Fractal heap info */
H5HF_hdr_cache_ud_t *udata = (H5HF_hdr_cache_ud_t *)_udata;
- size_t size, new_size; /* Header size */
+ size_t min_size; /* Header size */
H5WB_t *wb = NULL; /* Wrapped buffer for header data */
uint8_t hdr_buf[H5HF_HDR_BUF_SIZE]; /* Buffer for header */
uint8_t *buf; /* Pointer to header buffer */
+ size_t buf_size; /* Current size of temporary buffer */
const uint8_t *p; /* Pointer into raw data buffer */
- uint32_t stored_chksum; /* Stored metadata checksum value */
- uint32_t computed_chksum; /* Computed metadata checksum value */
- unsigned tries, max_tries; /* The # of read attempts */
- unsigned fixed_tries; /* The # of read attempts for the minimum portion */
- unsigned retries; /* The # of retries */
- H5HF_hdr_t *ret_value; /* Return value */
+ uint32_t stored_chksum; /* Stored metadata checksum value */
+ uint32_t computed_chksum; /* Computed metadata checksum value */
+ unsigned tries, max_tries; /* The # of read attempts */
+ unsigned retries; /* The # of retries */
+ uint8_t heap_flags; /* Status flags for heap */
+ H5HF_hdr_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -428,59 +304,64 @@ H5HF_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't wrap buffer")
/* Compute the minimum size of the fractal heap header to determine filter info */
- size = (size_t)H5HF_MIN_HEADER_SIZE;
+ min_size = (size_t)H5HF_MIN_HEADER_SIZE;
+
+ /* Get a pointer to a buffer that's large enough for serialized header */
+ if(NULL == (buf = (uint8_t *)H5WB_actual(wb, min_size)))
+ HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, NULL, "can't get actual buffer")
+ buf_size = min_size;
/* Get the # of read attempts */
- tries = max_tries = H5F_GET_READ_ATTEMPTS(f);
+ tries = max_tries = H5F_GET_READ_ATTEMPTS(udata->f);
+ retries = 0;
do {
- /* Get a pointer to a buffer that's large enough for serialized header */
- if(NULL == (buf = (uint8_t *)H5WB_actual(wb, size)))
- HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, NULL, "can't get actual buffer")
+ /* Read minimum header from disk */
+ if(H5F_block_read(udata->f, H5FD_MEM_FHEAP_HDR, addr, min_size, dxpl_id, buf) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_READERROR, NULL, "can't read fractal heap header")
- fixed_tries = max_tries;
- do {
- /* Read minimum header from disk */
- if(H5F_block_read(f, H5FD_MEM_FHEAP_HDR, addr, size, dxpl_id, buf) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_READERROR, NULL, "can't read fractal heap header")
+ /* Get temporary pointer to serialized header */
+ p = buf;
- /* Get temporary pointer to serialized header */
- p = buf;
+ /* Magic number */
+ if(HDmemcmp(p, H5HF_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC))
+ continue; /* Transfer control to while() and count this as a bad read, not an error */
+ p += H5_SIZEOF_MAGIC;
- /* Decode minimum header info */
- if(H5HF_min_header_decode(&p, hdr) >= 0)
- break;
- } while (--fixed_tries);
+ /* Version */
+ if(*p++ != H5HF_HDR_VERSION)
+ continue; /* Transfer control to while() and count this as a bad read, not an error */
- if(fixed_tries == 0)
- /* After all tries (for SWMR access) or after 1 try (for non-SWMR) */
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "bad minimum header info in fractal heap header after all tries")
- else if((max_tries - fixed_tries + 1) > 1)
- HDfprintf(stderr, "%s: SUCCESS after %u attempts for minimum header in fractal heap\n", FUNC, max_tries - fixed_tries + 1);
+ /* General heap information */
+ UINT16DECODE(p, hdr->id_len); /* Heap ID length */
+ UINT16DECODE(p, hdr->filter_len); /* I/O filters' encoded length */
- /* Full header size */
- new_size = (size_t)H5HF_HEADER_SIZE(hdr);
+ /* Fixed-size header length */
+ hdr->heap_size = (size_t)H5HF_HEADER_SIZE(hdr);
/* Check for I/O filter information to decode */
if(hdr->filter_len > 0)
- /* Compute the heap header's size: fixed-len header size + variable-len I/O filter information */
- hdr->heap_size = new_size
- + (size_t)(hdr->sizeof_size /* Size of size for filtered root direct block */
+ /* Add the variable-len I/O filter information */
+ hdr->heap_size += (size_t)(hdr->sizeof_size /* Size of size for filtered root direct block */
+ (unsigned)4 /* Size of filter mask for filtered root direct block */
+ hdr->filter_len); /* Size of encoded I/O filter info */
- else
- /* Set the heap header's size: fixed-len header size */
- hdr->heap_size = new_size;
- /* Re-size current buffer */
- if(NULL == (buf = (uint8_t *)H5WB_actual(wb, hdr->heap_size)))
- HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, NULL, "can't get actual buffer")
+ /* Check if we need to resize the buffer */
+ if(hdr->heap_size > buf_size) {
+ /* Re-size current buffer */
+ if(NULL == (buf = (uint8_t *)H5WB_actual(wb, hdr->heap_size)))
+ HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, NULL, "can't get actual buffer")
+ buf_size = hdr->heap_size;
+ } /* end if */
- /* Read the whole header with possibly filter info */
- if(H5F_block_read(f, H5FD_MEM_FHEAP_HDR, addr, hdr->heap_size, dxpl_id, buf) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_READERROR, NULL, "can't read fractal heap header's I/O pipeline filter info")
+ /* Read the whole header, possibly with filter info */
+ /* (Can't use H5F_read_check_metadata() since the length from the
+ * minimum-sized header info might be incorrect. -QAK)
+ */
+ if(H5F_block_read(udata->f, H5FD_MEM_FHEAP_HDR, addr, hdr->heap_size, dxpl_id, buf) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_READERROR, NULL, "can't read remainder of fractal heap header")
/* Retrieve stored and computed checksums */
- H5F_get_checksums(buf, hdr->heap_size, &stored_chksum, &computed_chksum);
+ H5F_get_checksums(buf, hdr->heap_size, &stored_chksum, &computed_chksum);
/* Verify checksum */
if(stored_chksum == computed_chksum)
@@ -491,28 +372,72 @@ H5HF_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, NULL, "incorrect metadata checksum after all tries (%u) for fractal heap header", max_tries)
/* Calculate and track the # of retry */
- retries = max_tries - tries;
- if(retries) { /* Does not track 0 retry */
- HDfprintf(stderr, "%s: SUCCESS after %u retries\n", FUNC, retries);
- if(H5F_track_metadata_read_retries(f, H5AC_FHEAP_HDR_ID, retries) < 0)
+ retries += (max_tries - tries);
+ if(retries) /* Does not track 0 retry */
+ if(H5F_track_metadata_read_retries(udata->f, H5AC_FHEAP_HDR_ID, retries) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "cannot track read tries = %u ", retries)
- }
- p = buf;
+ /* Reset pointer into [possibly] re-sized buffer */
+ /* (Skip over information decoded earlier) */
+ p = buf + min_size;
- /* Decode full header info */
- if(H5HF_full_header_decode(hdr->f, udata->dxpl_id, &p, hdr) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTENCODE, NULL, "unable to decode full header info")
+ /* Heap status flags */
+ /* (bit 0: "huge" object IDs have wrapped) */
+ /* (bit 1: checksum direct blocks) */
+ heap_flags = *p++;
+ hdr->huge_ids_wrapped = heap_flags & H5HF_HDR_FLAGS_HUGE_ID_WRAPPED;
+ hdr->checksum_dblocks = heap_flags & H5HF_HDR_FLAGS_CHECKSUM_DBLOCKS;
- /* Metadata checksum */
- UINT32DECODE(p, stored_chksum);
+ /* "Huge" object information */
+ UINT32DECODE(p, hdr->max_man_size); /* Max. size of "managed" objects */
+ H5F_DECODE_LENGTH(udata->f, p, hdr->huge_next_id); /* Next ID to use for "huge" object */
+ H5F_addr_decode(udata->f, &p, &hdr->huge_bt2_addr); /* Address of "huge" object tracker B-tree */
- /* Sanity check */
- HDassert((size_t)(p - (const uint8_t *)buf) == hdr->heap_size);
+ /* "Managed" object free space information */
+ H5F_DECODE_LENGTH(udata->f, p, hdr->total_man_free); /* Internal free space in managed direct blocks */
+ H5F_addr_decode(udata->f, &p, &hdr->fs_addr); /* Address of free section header */
- /* Verify checksum with checksum computed via H5F_get_checksums() */
- if(stored_chksum != computed_chksum)
- HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, NULL, "incorrect metadata checksum for fractal heap header")
+ /* Heap statistics */
+ H5F_DECODE_LENGTH(udata->f, p, hdr->man_size);
+ H5F_DECODE_LENGTH(udata->f, p, hdr->man_alloc_size);
+ H5F_DECODE_LENGTH(udata->f, p, hdr->man_iter_off);
+ H5F_DECODE_LENGTH(udata->f, p, hdr->man_nobjs);
+ H5F_DECODE_LENGTH(udata->f, p, hdr->huge_size);
+ H5F_DECODE_LENGTH(udata->f, p, hdr->huge_nobjs);
+ H5F_DECODE_LENGTH(udata->f, p, hdr->tiny_size);
+ H5F_DECODE_LENGTH(udata->f, p, hdr->tiny_nobjs);
+
+ /* Managed objects' doubling-table info */
+ if(H5HF_dtable_decode(udata->f, &p, &(hdr->man_dtable)) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTENCODE, NULL, "unable to encode managed obj. doubling table info")
+
+ /* Check for I/O filter information to decode */
+ if(hdr->filter_len > 0) {
+ H5O_pline_t *pline; /* Pipeline information from the header on disk */
+
+ /* Decode the size of a filtered root direct block */
+ H5F_DECODE_LENGTH(udata->f, p, hdr->pline_root_direct_size);
+
+ /* Decode the filter mask for a filtered root direct block */
+ UINT32DECODE(p, hdr->pline_root_direct_filter_mask);
+
+ /* Decode I/O filter information */
+ if(NULL == (pline = (H5O_pline_t *)H5O_msg_decode(udata->f, udata->dxpl_id, NULL, H5O_PLINE_ID, p)))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, NULL, "can't decode I/O pipeline filters")
+ p += hdr->filter_len;
+
+ /* Copy the information into the header's I/O pipeline structure */
+ if(NULL == H5O_msg_copy(H5O_PLINE_ID, pline, &(hdr->pline)))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTCOPY, NULL, "can't copy I/O filter pipeline")
+
+ /* Release the space allocated for the I/O pipeline filters */
+ H5O_msg_free(H5O_PLINE_ID, pline);
+ } /* end if */
+
+ /* Already decoded and compared stored checksum earlier, when reading */
+
+ /* Sanity check */
+ HDassert((size_t)(p - (const uint8_t *)buf) == (hdr->heap_size - H5_SIZEOF_CHKSUM));
/* Finish initialization of heap header */
if(H5HF_hdr_finish_init(hdr) < 0)
@@ -808,8 +733,6 @@ H5HF_cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
uint8_t *buf; /* Temporary buffer */
const uint8_t *p; /* Pointer into raw data buffer */
haddr_t heap_addr; /* Address of heap header in the file */
- uint32_t stored_chksum; /* Stored metadata checksum value */
- uint32_t computed_chksum; /* Computed metadata checksum value */
unsigned u; /* Local index variable */
H5HF_indirect_t *ret_value; /* Return value */
@@ -852,8 +775,8 @@ H5HF_cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, NULL, "can't get actual buffer")
/* Read and validate indirect block from disk */
- if(H5F_read_check_metadata(f, H5FD_MEM_FHEAP_IBLOCK, H5AC_FHEAP_IBLOCK_ID, addr, iblock->size, iblock->size, dxpl_id, buf, &computed_chksum) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "incorrect metadata checksum for fractal heap indirect block")
+ if(H5F_read_check_metadata(f, dxpl_id, H5FD_MEM_FHEAP_IBLOCK, H5AC_FHEAP_IBLOCK_ID, addr, iblock->size, iblock->size, buf) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, NULL, "incorrect metadata checksum for fractal heap indirect block")
/* Get temporary pointer to serialized indirect block */
p = buf;
@@ -943,15 +866,10 @@ H5HF_cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
/* Sanity check */
HDassert(iblock->nchildren); /* indirect blocks w/no children should have been deleted */
- /* Metadata checksum */
- UINT32DECODE(p, stored_chksum);
+ /* Already decoded and compared stored checksum earlier, when reading */
/* Sanity check */
- HDassert((size_t)(p - (const uint8_t *)buf) == iblock->size);
-
- /* Verify checksum */
- if(stored_chksum != computed_chksum)
- HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, NULL, "incorrect metadata checksum for fractal heap indirect block")
+ HDassert((size_t)(p - (const uint8_t *)buf) == (iblock->size - H5_SIZEOF_CHKSUM));
/* Check if we have any indirect block children */
if(iblock->nrows > hdr->man_dtable.max_direct_rows) {
@@ -1312,14 +1230,14 @@ H5HF_cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
H5HF_direct_t *dblock = NULL; /* Direct block info */
const uint8_t *p; /* Pointer into raw data buffer */
haddr_t heap_addr; /* Address of heap header in the file */
- uint32_t computed_chksum; /* Computed metadata checksum value */
- uint32_t stored_chksum; /* Metadata checksum value */
- unsigned tries, max_tries; /* The # of read attempts */
- unsigned retries; /* The # of retries */
- size_t chk_size; /* The size for validating checksum */
- uint8_t *chk_p; /* Pointer to the area for validating checksum */
- size_t read_size; /* Size of filtered direct block to read */
- H5HF_direct_t *ret_value; /* Return value */
+ uint32_t computed_chksum; /* Computed metadata checksum value */
+ uint32_t stored_chksum; /* Metadata checksum value */
+ unsigned tries, max_tries; /* The # of read attempts */
+ unsigned retries; /* The # of retries */
+ size_t chk_size; /* The size for validating checksum */
+ uint8_t *chk_p; /* Pointer to the area for validating checksum */
+ size_t read_size; /* Size of filtered direct block to read */
+ H5HF_direct_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -1420,10 +1338,12 @@ H5HF_cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
/* Decode checksum on direct block, if requested */
chk_size = (size_t)(H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr) - H5HF_SIZEOF_CHKSUM);
chk_p = dblock->blk + chk_size;
+
/* Metadata checksum */
UINT32DECODE(chk_p, stored_chksum);
chk_p -= H5HF_SIZEOF_CHKSUM;
+
/* Reset checksum field, for computing the checksum */
/* (Casting away const OK - QAK) */
HDmemset(chk_p, 0, (size_t)H5HF_SIZEOF_CHKSUM);
@@ -1442,11 +1362,9 @@ H5HF_cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
/* Calculate and track the # of retries */
retries = max_tries - tries;
- if(retries) { /* Does not track 0 retry */
- HDfprintf(stderr, "%s: SUCCESS after %u retries\n", FUNC, retries);
+ if(retries) /* Does not track 0 retry */
if(H5F_track_metadata_read_retries(f, H5AC_FHEAP_DBLOCK_ID, retries) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, NULL, "cannot track read retries = %u ", retries)
- }
/* Start decoding direct block */
p = dblock->blk;
@@ -1477,7 +1395,7 @@ H5HF_cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
/* Offset of heap within the heap's address space */
UINT64DECODE_VAR(p, dblock->block_off, hdr->heap_off_size);
- /* Decode checksum on direct block, if requested */
+ /* Advance past optional checksum on direct block, it was verified earlier */
if(hdr->checksum_dblocks)
p += H5HF_SIZEOF_CHKSUM;
diff --git a/src/H5HFpkg.h b/src/H5HFpkg.h
index 5979ec2..99571f5 100644
--- a/src/H5HFpkg.h
+++ b/src/H5HFpkg.h
@@ -105,14 +105,6 @@
+ H5HF_DTABLE_INFO_SIZE(h) /* Size of managed obj. doubling-table info */ \
)
-/* Size of minimum header to decode for determining the full header size */
-#define H5HF_MIN_HEADER_SIZE ( \
- H5_SIZEOF_MAGIC + /* Signature */ \
- 1 + /* Version */ \
- 2 + /* Heap ID len */ \
- 2 /* I/O filters' encoded len */ \
- )
-
/* Size of overhead for a direct block */
#define H5HF_MAN_ABS_DIRECT_OVERHEAD(h) ( \
/* General metadata fields */ \
diff --git a/src/H5Ocache.c b/src/H5Ocache.c
index d682253..7c896c1 100644
--- a/src/H5Ocache.c
+++ b/src/H5Ocache.c
@@ -38,6 +38,7 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free lists */
#include "H5MFprivate.h" /* File memory management */
+#include "H5MMprivate.h" /* Memory management */
#include "H5Opkg.h" /* Object headers */
#include "H5WBprivate.h" /* Wrapped Buffers */
@@ -52,6 +53,11 @@
* size to save the extra I/O operations) */
#define H5O_SPEC_READ_SIZE 512
+/* Set the estimated size of the chunk to read */
+/* (Avoids an allocation, if we estimate correctly) */
+#define H5O_EST_CHUNK_SIZE 512
+
+
/******************/
/* Local Typedefs */
@@ -281,7 +287,6 @@ H5O_decode_prefix(H5F_t *f, H5O_t *oh, const uint8_t *buf, void *_udata)
done:
FUNC_LEAVE_NOAPI(ret_value)
-
} /* H5O_decode_prefix() */
@@ -312,18 +317,17 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
{
H5O_t *oh = NULL; /* Object header read in */
H5O_cache_ud_t *udata = (H5O_cache_ud_t *)_udata; /* User data for callback */
- H5WB_t *wb = NULL; /* Wrapped buffer for prefix data */
uint8_t read_buf[H5O_SPEC_READ_SIZE]; /* Buffer for speculative read */
- uint8_t *buf; /* Buffer to decode */
+ uint8_t *buf = NULL; /* Buffer to decode */
size_t spec_read_size; /* Size of buffer to speculatively read in */
size_t buf_size; /* Size of prefix+chunk #0 buffer */
haddr_t eoa; /* Relative end of file address */
unsigned tries, max_tries; /* The # of read attempts */
- unsigned retries; /* The # of retries */
- unsigned fixed_tries; /* The # of read attempts for prefix */
- uint32_t stored_chksum; /* Stored metadata checksum value */
- uint32_t computed_chksum; /* Computed metadata checksum value */
- H5O_t *ret_value; /* Return value */
+ unsigned retries; /* The # of retries */
+ unsigned fixed_tries; /* The # of read attempts for prefix */
+ uint32_t stored_chksum; /* Stored metadata checksum value */
+ uint32_t computed_chksum;/* Computed metadata checksum value */
+ H5O_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -345,17 +349,9 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
if(NULL == (oh = H5FL_CALLOC(H5O_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- /* Wrap the local buffer for serialized header info */
- if(NULL == (wb = H5WB_wrap(read_buf, sizeof(read_buf))))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "can't wrap buffer")
-
/* Get the # of read attempts */
tries = max_tries = H5F_GET_READ_ATTEMPTS(f);
do {
- /* Get a pointer to a buffer that's large enough for serialized header */
- if(NULL == (buf = (uint8_t *)H5WB_actual(wb, spec_read_size)))
- HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "can't get actual buffer")
-
fixed_tries = max_tries;
do {
/* Attempt to speculatively read both object header prefix and first chunk */
@@ -365,45 +361,44 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
/* Decode header prefix */
if(H5O_decode_prefix(f, oh, read_buf, udata) >= 0)
break;
-
} while (--fixed_tries);
if(fixed_tries == 0)
/* After all tries (for SWMR access) or after 1 try (for non-SWMR) */
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "bad object header prefix after all tries")
- else if((max_tries - fixed_tries + 1) > 1)
- HDfprintf(stderr, "%s: SUCCESS after %u attempts for fixed data\n", FUNC, max_tries - fixed_tries + 1);
+ HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "bad object header prefix after all tries")
- /* Compute the size of the buffer used */
+ /* Compute the size of the buffer required */
buf_size = oh->chunk0_size + (size_t)H5O_SIZEOF_HDR(oh);
/* Check if the speculative read was large enough to parse the first chunk */
if(spec_read_size < buf_size) {
-
- /* Get a pointer to a buffer that's large enough for serialized header */
- if(NULL == (buf = (uint8_t *)H5WB_actual(wb, buf_size)))
- HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "can't get actual buffer")
+ /* Allocate space for a buffer that's large enough for serialized header */
+ if(NULL == (buf = (uint8_t *)H5MM_malloc(buf_size)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "can't get actual buffer")
/* SWMR access */
- if(H5F_INTENT(f) & H5F_ACC_SWMR_READ || H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) {
+ if(H5F_INTENT(f) & (H5F_ACC_SWMR_READ | H5F_ACC_SWMR_WRITE)) {
/* Read the chunk that is bigger than the speculative read size */
if(H5F_block_read(f, H5FD_MEM_OHDR, addr, buf_size, dxpl_id, buf) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to read object header")
+
/* See if the data read now is the same as what is read initially */
if(HDmemcmp(buf, read_buf, spec_read_size)) {
- HDmemset(oh, 0, sizeof(oh));
+ HDmemset(oh, 0, sizeof(*oh));
+
/* Decode the prefix again */
if(H5O_decode_prefix(f, oh, buf, udata) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "can't decode object header prefix")
- }
- } else {
+ } /* end if */
+ } /* end if */
+ else {
/* Copy existing raw data into new buffer */
HDmemcpy(buf, read_buf, spec_read_size);
/* Read rest of the raw data */
if(H5F_block_read(f, H5FD_MEM_OHDR, (addr + spec_read_size), (buf_size - spec_read_size), dxpl_id, (buf + spec_read_size)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to read object header data")
- }
+ } /* end else */
} else
buf = read_buf;
@@ -424,11 +419,9 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
/* Calculate and track the # of retries */
retries = max_tries - tries;
- if(retries) { /* Does not track 0 retry */
- HDfprintf(stderr, "%s: SUCCESS after %u retries\n", FUNC, retries);
+ if(retries) /* Does not track 0 retry */
if(H5F_track_metadata_read_retries(f, H5AC_OHDR_ID, retries) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "cannot track read retries = %u ", retries)
- }
/* File-specific, non-stored information */
oh->sizeof_size = H5F_SIZEOF_SIZE(udata->common.f);
@@ -456,8 +449,8 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
done:
/* Release resources */
- if(wb && H5WB_unwrap(wb) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_CLOSEERROR, NULL, "can't close wrapped buffer")
+ if(buf && buf != read_buf)
+ H5MM_free(buf);
/* Release the [possibly partially initialized] object header on errors */
if(!ret_value && oh)
@@ -798,7 +791,7 @@ H5O_cache_chk_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk proxy object */
H5O_chk_cache_ud_t *udata = (H5O_chk_cache_ud_t *)_udata; /* User data for callback */
H5WB_t *wb = NULL; /* Wrapped buffer for prefix data */
- uint8_t chunk_buf[H5O_SPEC_READ_SIZE]; /* Buffer for speculative read */
+ uint8_t chunk_buf[H5O_EST_CHUNK_SIZE]; /* Buffer for estimated chunk size */
uint8_t *buf; /* Buffer to decode */
H5O_chunk_proxy_t *ret_value; /* Return value */
@@ -825,13 +818,14 @@ H5O_cache_chk_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
/* Read rest of the raw data */
if(udata->oh->version == H5O_VERSION_2 && udata->decoding) {
/* Read and validate object header continuation chunk */
- if(H5F_read_check_metadata(f, H5FD_MEM_OHDR, H5AC_OHDR_CHK_ID, addr, udata->size, udata->size, dxpl_id, buf, NULL) < 0)
+ if(H5F_read_check_metadata(f, dxpl_id, H5FD_MEM_OHDR, H5AC_OHDR_CHK_ID, addr, udata->size, udata->size, buf) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "incorrect metadata checksum for object header continuation chunk")
- } else {
+ } /* end if */
+ else {
/* Read the header object continuation chunk */
if(H5F_block_read(f, H5FD_MEM_OHDR, addr, udata->size, dxpl_id, buf) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to read object header continuation chunk")
- }
+ } /* end else */
/* Check if we are still decoding the object header */
/* (as opposed to bringing a piece of it back from the file) */
diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c
index ea29ab3..8a09ed9 100644
--- a/src/H5Pfapl.c
+++ b/src/H5Pfapl.c
@@ -161,10 +161,10 @@
#define H5F_ACS_FILE_IMAGE_INFO_COPY H5P_file_image_info_copy
#define H5F_ACS_FILE_IMAGE_INFO_CLOSE H5P_file_image_info_close
/* Definition for # of metadata read attempts */
-#define H5F_ACS_METADATA_READ_ATTEMPTS_SIZE sizeof(unsigned)
-#define H5F_ACS_METADATA_READ_ATTEMPTS_DEF 0
-#define H5F_ACS_METADATA_READ_ATTEMPTS_ENC H5P__encode_unsigned
-#define H5F_ACS_METADATA_READ_ATTEMPTS_DEC H5P__decode_unsigned
+#define H5F_ACS_METADATA_READ_ATTEMPTS_SIZE sizeof(unsigned)
+#define H5F_ACS_METADATA_READ_ATTEMPTS_DEF 0
+#define H5F_ACS_METADATA_READ_ATTEMPTS_ENC H5P__encode_unsigned
+#define H5F_ACS_METADATA_READ_ATTEMPTS_DEC H5P__decode_unsigned
/******************/
/* Local Typedefs */
@@ -406,6 +406,7 @@ H5P_facc_reg_prop(H5P_genclass_t *pclass)
NULL, NULL, NULL, H5F_ACS_METADATA_READ_ATTEMPTS_ENC, H5F_ACS_METADATA_READ_ATTEMPTS_DEC,
NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P_facc_reg_prop() */
@@ -3017,7 +3018,7 @@ H5Pset_metadata_read_attempts(hid_t plist_id, unsigned attempts)
H5TRACE2("e", "iIu", plist_id, attempts);
/* Cannot set the # of attempts to 0 */
- if(attempts <= 0)
+ if(attempts == 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "number of metadatata read attempts must be greater than 0");
/* Get the plist structure */
@@ -3047,26 +3048,29 @@ done:
herr_t
H5Pget_metadata_read_attempts(hid_t plist_id, unsigned *attempts/*out*/)
{
- H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE2("e", "ix", plist_id, attempts);
- /* Get the plist structure */
- if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
-
/* Get values */
if(attempts) {
+ H5P_genplist_t *plist; /* Property list pointer */
+
+ /* Get the plist structure */
+ if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
+
/* Get the # of read attempts set */
if(H5P_get(plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, attempts) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get the number of metadata read attempts")
+
/* If not set, return the default value */
- if(*attempts == H5F_ACS_METADATA_READ_ATTEMPTS_DEF) /* 0 */
+ if(*attempts == H5F_ACS_METADATA_READ_ATTEMPTS_DEF) /* 0 */
*attempts = H5F_METADATA_READ_ATTEMPTS;
- }
+ } /* end if */
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Pget_metadata_read_attempts() */
+
diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h
index 5caedf6..cbb6f6a 100644
--- a/src/H5Ppublic.h
+++ b/src/H5Ppublic.h
@@ -345,7 +345,7 @@ H5_DLL herr_t H5Pset_file_image_callbacks(hid_t fapl_id,
H5_DLL herr_t H5Pget_file_image_callbacks(hid_t fapl_id,
H5FD_file_image_callbacks_t *callbacks_ptr);
H5_DLL herr_t H5Pset_metadata_read_attempts(hid_t plist_id, unsigned attempts);
-H5_DLL herr_t H5Pget_metadata_read_attempts(hid_t plist_id, unsigned *attempts/*out*/);
+H5_DLL herr_t H5Pget_metadata_read_attempts(hid_t plist_id, unsigned *attempts);
/* Dataset creation property list (DCPL) routines */
H5_DLL herr_t H5Pset_layout(hid_t plist_id, H5D_layout_t layout);
diff --git a/src/H5SMcache.c b/src/H5SMcache.c
index 5a2e928..c150126 100644
--- a/src/H5SMcache.c
+++ b/src/H5SMcache.c
@@ -122,8 +122,6 @@ H5SM_table_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void UNUSED *udata)
uint8_t tbl_buf[H5SM_TBL_BUF_SIZE]; /* Buffer for table */
uint8_t *buf; /* Reading buffer */
const uint8_t *p; /* Pointer into input buffer */
- uint32_t stored_chksum; /* Stored metadata checksum value */
- uint32_t computed_chksum; /* Computed metadata checksum value */
size_t x; /* Counter variable for index headers */
H5SM_master_table_t *ret_value;
@@ -159,7 +157,7 @@ H5SM_table_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void UNUSED *udata)
HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, NULL, "can't get actual buffer")
/* Read and validate shared message table from disk */
- if(H5F_read_check_metadata(f, H5FD_MEM_SOHM_TABLE, H5AC_SOHM_TABLE_ID, addr, table->table_size, table->table_size, dxpl_id, buf, &computed_chksum) < 0)
+ if(H5F_read_check_metadata(f, dxpl_id, H5FD_MEM_SOHM_TABLE, H5AC_SOHM_TABLE_ID, addr, table->table_size, table->table_size, buf) < 0)
HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, NULL, "incorrect metadata checksum for shared message table")
/* Get temporary pointer to serialized table */
@@ -208,15 +206,10 @@ H5SM_table_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void UNUSED *udata)
table->indexes[x].list_size = H5SM_LIST_SIZE(f, table->indexes[x].list_max);
} /* end for */
- /* Read in checksum */
- UINT32DECODE(p, stored_chksum);
+ /* Already decoded and compared stored checksum earlier, when reading */
/* Sanity check */
- HDassert((size_t)(p - (const uint8_t *)buf) == table->table_size);
-
- /* Verify checksum with checksum computed via H5F_read_check_metadata() */
- if(stored_chksum != computed_chksum)
- HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, NULL, "incorrect metadata checksum for shared message table")
+ HDassert((size_t)(p - (const uint8_t *)buf) == (table->table_size - H5_SIZEOF_CHKSUM));
/* Set return value */
ret_value = table;
@@ -460,8 +453,6 @@ H5SM_list_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
uint8_t lst_buf[H5SM_LST_BUF_SIZE]; /* Buffer for list index */
uint8_t *buf; /* Reading buffer */
uint8_t *p; /* Pointer into input buffer */
- uint32_t stored_chksum; /* Stored metadata checksum value */
- uint32_t computed_chksum; /* Computed metadata checksum value */
size_t x; /* Counter variable for messages in list */
size_t chk_size; /* Exact size with checksum at the end */
H5SM_list_t *ret_value; /* Return value */
@@ -494,10 +485,9 @@ H5SM_list_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
chk_size = H5SM_LIST_SIZE(udata->f, udata->header->num_messages);
/* Read and validate shared message list from disk */
- if(H5F_read_check_metadata(f, H5FD_MEM_SOHM_INDEX, H5AC_SOHM_LIST_ID, addr, udata->header->list_size, chk_size, dxpl_id, buf, &computed_chksum) < 0)
+ if(H5F_read_check_metadata(f, dxpl_id, H5FD_MEM_SOHM_INDEX, H5AC_SOHM_LIST_ID, addr, udata->header->list_size, chk_size, buf) < 0)
HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, NULL, "incorrect metadata checksum for shared message list")
-
/* Get temporary pointer to serialized list index */
p = buf;
@@ -514,15 +504,10 @@ H5SM_list_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
p += H5SM_SOHM_ENTRY_SIZE(udata->f);
} /* end for */
- /* Read in checksum */
- UINT32DECODE(p, stored_chksum);
+ /* Already decoded and compared stored checksum earlier, when reading */
/* Sanity check */
- HDassert((size_t)(p - buf) <= udata->header->list_size);
-
- /* Verify checksum with checksum computed via H5F_read_check_metadata() */
- if(stored_chksum != computed_chksum)
- HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, NULL, "incorrect metadata checksum for shared message list")
+ HDassert((size_t)(p - buf) <= (udata->header->list_size - H5_SIZEOF_CHKSUM));
/* Initialize the rest of the array */
for(x = udata->header->num_messages; x < udata->header->list_max; x++)
diff --git a/test/dsets.c b/test/dsets.c
index 245b993..b07e174 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -8271,7 +8271,7 @@ error:
*-------------------------------------------------------------------------
*/
static herr_t
-test_chunk_fast(hid_t fapl)
+test_chunk_fast(const char *env_h5_drvr, hid_t fapl)
{
char filename[FILENAME_BUF_SIZE];
hid_t fid = -1; /* File ID */
@@ -8326,6 +8326,11 @@ test_chunk_fast(hid_t fapl)
/* SWMR is only supported on the latest file format */
if(swmr && H5F_LIBVER_LATEST != low)
continue;
+
+ /* SWMR is not compatible with multi-file VFDs */
+ if(swmr && !(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family")))
+ continue;
+
#ifdef H5_HAVE_FILTER_DEFLATE
/* Loop over compressing chunks */
for(compress = FALSE; compress <= TRUE; compress++) {
@@ -10031,7 +10036,7 @@ error:
*-------------------------------------------------------------------------
*/
static herr_t
-test_swmr_v1_btree_ci_fail(hid_t fapl)
+test_swmr_v1_btree_ci_fail(const char *env_h5_drvr, hid_t fapl)
{
char filename[FILENAME_BUF_SIZE];
hid_t fid = -1; /* File ID */
@@ -10049,78 +10054,86 @@ test_swmr_v1_btree_ci_fail(hid_t fapl)
TESTING("expected SWMR behavior using v-1 B-trees");
- h5_fixname(FILENAME[16], fapl, filename, sizeof filename);
+ /* Can't run this test with multi-file VFDs */
+ if(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family")) {
+ h5_fixname(FILENAME[16], fapl, filename, sizeof filename);
+
+ /* Copy the file access property list */
+ if((v1_fapl = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR
+ if((fh_fapl = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR
+ if(H5Pset_libver_bounds(fh_fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR
+
+ /* Create the test file, then close and reopen.
+ *
+ * We'll create the file with the file access property list that
+ * uses the latest file format so that the group is indexed with a
+ * fractal heap. If we don't do this, there can be issues when
+ * opening the file under SWMR since the root group will use a v1
+ * B-tree for the symbol table.
+ *
+ * The close and re-open is so that new datasets are indexed with
+ * the old v1 B-tree scheme.
+ */
+ if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fh_fapl)) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
+ if((fid = H5Fopen(filename, H5F_ACC_RDWR, v1_fapl)) < 0) FAIL_STACK_ERROR
- /* Copy the file access property list */
- if((v1_fapl = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR
- if((fh_fapl = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR
- if(H5Pset_libver_bounds(fh_fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR
-
- /* Create the test file, then close and reopen.
- *
- * We'll create the file with the file access property list that
- * uses the latest file format so that the group is indexed with a
- * fractal heap. If we don't do this, there can be issues when
- * opening the file under SWMR since the root group will use a v1
- * B-tree for the symbol table.
- *
- * The close and re-open is so that new datasets are indexed with
- * the old v1 B-tree scheme.
- */
- if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fh_fapl)) < 0) FAIL_STACK_ERROR
- if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
- if((fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, v1_fapl)) < 0) FAIL_STACK_ERROR
+ /* Create a dataset that uses v1 B-tree chunk indexing */
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR
+ chunk_dims[0] = 64;
+ if(H5Pset_chunk(dcpl, 1, chunk_dims) < 0) FAIL_STACK_ERROR
+ dims[0] = 1;
+ max_dims[0] = H5S_UNLIMITED;
+ if((sid = H5Screate_simple(1, dims, max_dims)) < 0) FAIL_STACK_ERROR
+ if((did = H5Dcreate2(fid, DSET_DEFAULT_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+
+ /* Explicitly check that the dataset is using a v-1 B-tree index */
+ if(H5D__layout_idx_type_test(did, &idx_type) < 0) FAIL_STACK_ERROR
+ if(idx_type != H5D_CHUNK_IDX_BTREE)
+ FAIL_PUTS_ERROR("created dataset not indexed by version 1 B-tree")
+
+ /* Close the file */
+ if(H5Dclose(did) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
- /* Create a dataset that uses v1 B-tree chunk indexing */
- if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR
- chunk_dims[0] = 64;
- if(H5Pset_chunk(dcpl, 1, chunk_dims) < 0) FAIL_STACK_ERROR
- dims[0] = 1;
- max_dims[0] = H5S_UNLIMITED;
- if((sid = H5Screate_simple(1, dims, max_dims)) < 0) FAIL_STACK_ERROR
- if((did = H5Dcreate2(fid, DSET_DEFAULT_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
-
- /* Explicitly check that the dataset is using a v-1 B-tree index */
- if(H5D__layout_idx_type_test(did, &idx_type) < 0) FAIL_STACK_ERROR
- if(idx_type != H5D_CHUNK_IDX_BTREE)
- FAIL_PUTS_ERROR("created dataset not indexed by version 1 B-tree")
-
- /* Close the file */
- if(H5Dclose(did) < 0) FAIL_STACK_ERROR
- if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
+ /* Reopen the file with SWMR write access */
+ if((fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fh_fapl)) < 0) FAIL_STACK_ERROR
- /* Reopen the file with SWMR write access */
- if((fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, v1_fapl)) < 0) FAIL_STACK_ERROR
+ /* Attempt to write to a dataset that uses v-1 B-tree chunk indexing under
+ * SWMR semantics.
+ */
+ did = -1;
+ err = -1;
+ H5E_BEGIN_TRY {
+ did = H5Dopen(fid, DSET_DEFAULT_NAME, H5P_DEFAULT);
+ if(did >= 0) {
+ err = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &data);
+ }
+ } H5E_END_TRY;
- /* Attempt to write to a dataset that uses v-1 B-tree chunk indexing under
- * SWMR semantics.
- */
- did = -1;
- err = -1;
- H5E_BEGIN_TRY {
- did = H5Dopen(fid, DSET_DEFAULT_NAME, H5P_DEFAULT);
- if(did >= 0) {
- err = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &data);
+ /* Fail on successful write */
+ if(did >= 0 && err >= 0) {
+ H5_FAILED();
+ puts(" library allowed writing to a version 1 B-tree indexed dataset under SWMR semantics");
+ goto error;
}
- } H5E_END_TRY;
- /* Fail on successful write */
- if(did >= 0 && err >= 0) {
- H5_FAILED();
- puts(" library allowed writing to a version 1 B-tree indexed dataset under SWMR semantics");
- goto error;
- }
+ /* Close everything */
+ if(did >= 0)
+ if(H5Dclose(did) < 0) FAIL_STACK_ERROR
+ if(H5Pclose(v1_fapl) < 0) FAIL_STACK_ERROR
+ if(H5Pclose(fh_fapl) < 0) FAIL_STACK_ERROR
+ if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR
+ if(H5Sclose(sid) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
- /* Close everything */
- if(did >= 0)
- if(H5Dclose(did) < 0) FAIL_STACK_ERROR
- if(H5Pclose(v1_fapl) < 0) FAIL_STACK_ERROR
- if(H5Pclose(fh_fapl) < 0) FAIL_STACK_ERROR
- if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR
- if(H5Sclose(sid) < 0) FAIL_STACK_ERROR
- if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
+ PASSED();
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD not compatible with SWMR access");
+ } /* end else */
- PASSED();
return 0;
error:
@@ -11198,7 +11211,7 @@ main(void)
fapl = h5_fileaccess();
/* Test that SWMR access fails with version 1 B-tree access */
- nerrors += (test_swmr_v1_btree_ci_fail(fapl) < 0 ? 1 : 0);
+ nerrors += (test_swmr_v1_btree_ci_fail(envval, fapl) < 0 ? 1 : 0);
/* Turn off the chunk cache, so all the chunks are immediately written to disk */
if(H5Pget_cache(fapl, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0) < 0)
@@ -11285,7 +11298,7 @@ main(void)
nerrors += (test_huge_chunks(my_fapl) < 0 ? 1 : 0);
nerrors += (test_chunk_cache(my_fapl) < 0 ? 1 : 0);
nerrors += (test_big_chunks_bypass_cache(my_fapl) < 0 ? 1 : 0);
- nerrors += (test_chunk_fast(my_fapl) < 0 ? 1 : 0);
+ nerrors += (test_chunk_fast(envval, my_fapl) < 0 ? 1 : 0);
nerrors += (test_reopen_chunk_fast(my_fapl) < 0 ? 1 : 0);
nerrors += (test_chunk_fast_bug1(my_fapl) < 0 ? 1 : 0);
nerrors += (test_chunk_expand(my_fapl) < 0 ? 1 : 0);
diff --git a/test/earray.c b/test/earray.c
index 5474d7e..025828f 100644
--- a/test/earray.c
+++ b/test/earray.c
@@ -1395,9 +1395,10 @@ test_flush_depend_cb(const void *_elmt, size_t nelmts, void *udata)
*-------------------------------------------------------------------------
*/
static unsigned
-test_flush_depend(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t UNUSED *tparam)
+test_flush_depend(const char *env_h5_drvr, hid_t fapl, H5EA_create_t *cparam, earray_test_param_t UNUSED *tparam)
{
hid_t file = -1; /* File ID */
+ hid_t fapl_copy = -1; /* Copy of FAPL */
H5F_t *f = NULL; /* Internal file object pointer */
H5EA_t *ea = NULL; /* Extensible array wrapper */
haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
@@ -1414,188 +1415,205 @@ test_flush_depend(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t UNUSED
uint64_t welmt; /* Element to write */
hsize_t idx; /* Index value of element */
- /* Create file & retrieve pointer to internal file object */
- if(create_file(H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE, fapl, &file, &f) < 0)
- TEST_ERROR
-
/*
* Display testing message
*/
TESTING("flush dependencies on array metadata");
- /* Create array */
- cb.encode = test_flush_depend_cb;
- HDmemset(&fd_info, 0, sizeof(earray_flush_depend_ctx_t));
- cb.udata = &fd_info;
- if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &ea, &ea_addr, &cb) < 0)
- TEST_ERROR
+ /* Can't run this test with multi-file VFDs */
+ if(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family")) {
+ /* Copy FAPL and set latest format on it */
+ if((fapl_copy = H5Pcopy(fapl)) < 0)
+ FAIL_STACK_ERROR
+ if(H5Pset_libver_bounds(fapl_copy, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ FAIL_STACK_ERROR
- /* Verify the creation parameters */
- if(verify_cparam(ea, cparam) < 0)
- TEST_ERROR
+ /* Create file & retrieve pointer to internal file object */
+ if(create_file(H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE, fapl_copy, &file, &f) < 0)
+ TEST_ERROR
- /* Create base entry to insert */
- if(NULL == (base_entry = (earray_test_t *)HDmalloc(sizeof(earray_test_t))))
- TEST_ERROR
- HDmemset(base_entry, 0, sizeof(earray_test_t));
- base_entry->idx = (uint64_t)-1;
- base_entry->fd_info = &fd_info;
+ /* Close copy of FAPL */
+ if(H5Pclose(fapl_copy) < 0)
+ FAIL_STACK_ERROR
- /* Insert test entry into cache */
- base_addr = HADDR_MAX;
- if(H5AC_insert_entry(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, base_addr, base_entry, H5AC__PIN_ENTRY_FLAG) < 0)
- TEST_ERROR
+ /* Create array */
+ cb.encode = test_flush_depend_cb;
+ HDmemset(&fd_info, 0, sizeof(earray_flush_depend_ctx_t));
+ cb.udata = &fd_info;
+ if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &ea, &ea_addr, &cb) < 0)
+ TEST_ERROR
- /* Set the base entry as a flush dependency for the array */
- if(H5EA_depend((H5AC_info_t *)base_entry, ea) < 0)
- TEST_ERROR
+ /* Verify the creation parameters */
+ if(verify_cparam(ea, cparam) < 0)
+ TEST_ERROR
- /* Create entry #1 to insert */
- if(NULL == (entry1 = (earray_test_t *)HDmalloc(sizeof(earray_test_t))))
- TEST_ERROR
- HDmemset(entry1, 0, sizeof(earray_test_t));
- entry1->fd_info = &fd_info;
+ /* Create base entry to insert */
+ if(NULL == (base_entry = (earray_test_t *)HDmalloc(sizeof(earray_test_t))))
+ TEST_ERROR
+ HDmemset(base_entry, 0, sizeof(earray_test_t));
+ base_entry->idx = (uint64_t)-1;
+ base_entry->fd_info = &fd_info;
- /* Insert test entry into cache */
- addr1 = HADDR_MAX - 1;
- if(H5AC_insert_entry(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, addr1, entry1, H5AC__PIN_ENTRY_FLAG) < 0)
- TEST_ERROR
+ /* Insert test entry into cache */
+ base_addr = HADDR_MAX;
+ if(H5AC_insert_entry(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, base_addr, base_entry, H5AC__PIN_ENTRY_FLAG) < 0)
+ TEST_ERROR
- /* Set the test entry as a flush dependency for 0th index in the array */
- if(H5EA_support(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)0, (H5AC_info_t *)entry1) < 0)
- TEST_ERROR
+ /* Set the base entry as a flush dependency for the array */
+ if(H5EA_depend((H5AC_info_t *)base_entry, ea) < 0)
+ TEST_ERROR
- /* Set element of array */
- welmt = (uint64_t)0;
- idx = 0;
- if(H5EA_set(ea, H5P_DATASET_XFER_DEFAULT, idx, &welmt) < 0)
- FAIL_STACK_ERROR
+ /* Create entry #1 to insert */
+ if(NULL == (entry1 = (earray_test_t *)HDmalloc(sizeof(earray_test_t))))
+ TEST_ERROR
+ HDmemset(entry1, 0, sizeof(earray_test_t));
+ entry1->fd_info = &fd_info;
- /* Create entry #2 to insert */
- if(NULL == (entry2 = (earray_test_t *)HDmalloc(sizeof(earray_test_t))))
- TEST_ERROR
- HDmemset(entry2, 0, sizeof(earray_test_t));
- entry2->idx = (uint64_t)1;
- entry2->fd_info = &fd_info;
+ /* Insert test entry into cache */
+ addr1 = HADDR_MAX - 1;
+ if(H5AC_insert_entry(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, addr1, entry1, H5AC__PIN_ENTRY_FLAG) < 0)
+ TEST_ERROR
- /* Insert test entry into cache */
- addr2 = HADDR_MAX - 2;
- if(H5AC_insert_entry(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, addr2, entry2, H5AC__PIN_ENTRY_FLAG) < 0)
- TEST_ERROR
+ /* Set the test entry as a flush dependency for 0th index in the array */
+ if(H5EA_support(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)0, (H5AC_info_t *)entry1) < 0)
+ TEST_ERROR
- /* Set the test entry as a flush dependency for 1st index in the array */
- if(H5EA_support(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)1, (H5AC_info_t *)entry2) < 0)
- TEST_ERROR
+ /* Set element of array */
+ welmt = (uint64_t)0;
+ idx = 0;
+ if(H5EA_set(ea, H5P_DATASET_XFER_DEFAULT, idx, &welmt) < 0)
+ FAIL_STACK_ERROR
- /* Set element of array */
- welmt = (uint64_t)1;
- idx = 1;
- if(H5EA_set(ea, H5P_DATASET_XFER_DEFAULT, idx, &welmt) < 0)
- FAIL_STACK_ERROR
+ /* Create entry #2 to insert */
+ if(NULL == (entry2 = (earray_test_t *)HDmalloc(sizeof(earray_test_t))))
+ TEST_ERROR
+ HDmemset(entry2, 0, sizeof(earray_test_t));
+ entry2->idx = (uint64_t)1;
+ entry2->fd_info = &fd_info;
- /* Create entry #3 to insert */
- if(NULL == (entry3 = (earray_test_t *)HDmalloc(sizeof(earray_test_t))))
- TEST_ERROR
- HDmemset(entry3, 0, sizeof(earray_test_t));
- entry3->idx = (uint64_t)10000;
- entry3->fd_info = &fd_info;
+ /* Insert test entry into cache */
+ addr2 = HADDR_MAX - 2;
+ if(H5AC_insert_entry(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, addr2, entry2, H5AC__PIN_ENTRY_FLAG) < 0)
+ TEST_ERROR
- /* Insert test entry into cache */
- addr3 = HADDR_MAX - 3;
- if(H5AC_insert_entry(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, addr3, entry3, H5AC__PIN_ENTRY_FLAG) < 0)
- TEST_ERROR
+ /* Set the test entry as a flush dependency for 1st index in the array */
+ if(H5EA_support(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)1, (H5AC_info_t *)entry2) < 0)
+ TEST_ERROR
- /* Set the test entry as a flush dependency for 10,000th index in the array */
- if(H5EA_support(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)10000, (H5AC_info_t *)entry3) < 0)
- TEST_ERROR
+ /* Set element of array */
+ welmt = (uint64_t)1;
+ idx = 1;
+ if(H5EA_set(ea, H5P_DATASET_XFER_DEFAULT, idx, &welmt) < 0)
+ FAIL_STACK_ERROR
- /* Set element of array */
- welmt = (uint64_t)10000;
- idx = 10000;
- if(H5EA_set(ea, H5P_DATASET_XFER_DEFAULT, idx, &welmt) < 0)
- FAIL_STACK_ERROR
+ /* Create entry #3 to insert */
+ if(NULL == (entry3 = (earray_test_t *)HDmalloc(sizeof(earray_test_t))))
+ TEST_ERROR
+ HDmemset(entry3, 0, sizeof(earray_test_t));
+ entry3->idx = (uint64_t)10000;
+ entry3->fd_info = &fd_info;
+ /* Insert test entry into cache */
+ addr3 = HADDR_MAX - 3;
+ if(H5AC_insert_entry(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, addr3, entry3, H5AC__PIN_ENTRY_FLAG) < 0)
+ TEST_ERROR
- /* Flush the cache */
- if(H5Fflush(file, H5F_SCOPE_GLOBAL) < 0)
- TEST_ERROR
+ /* Set the test entry as a flush dependency for 10,000th index in the array */
+ if(H5EA_support(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)10000, (H5AC_info_t *)entry3) < 0)
+ TEST_ERROR
- /* Check that all callback flags have been set */
- if(!fd_info.base_obj)
- TEST_ERROR
- if(!fd_info.idx0_obj)
- TEST_ERROR
- if(!fd_info.idx0_elem)
- TEST_ERROR
- if(!fd_info.idx1_obj)
- TEST_ERROR
- if(!fd_info.idx1_elem)
- TEST_ERROR
- if(!fd_info.idx10000_obj)
- TEST_ERROR
- if(!fd_info.idx10000_elem)
- TEST_ERROR
+ /* Set element of array */
+ welmt = (uint64_t)10000;
+ idx = 10000;
+ if(H5EA_set(ea, H5P_DATASET_XFER_DEFAULT, idx, &welmt) < 0)
+ FAIL_STACK_ERROR
- /* Remove the base entry as a flush dependency for the array */
- if(H5EA_undepend((H5AC_info_t *)base_entry, ea) < 0)
- TEST_ERROR
+ /* Flush the cache */
+ if(H5Fflush(file, H5F_SCOPE_GLOBAL) < 0)
+ TEST_ERROR
- /* Protect the base entry */
- if(NULL == (base_entry = (earray_test_t *)H5AC_protect(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, base_addr, NULL, H5AC_WRITE)))
- TEST_ERROR
+ /* Check that all callback flags have been set */
+ if(!fd_info.base_obj)
+ TEST_ERROR
+ if(!fd_info.idx0_obj)
+ TEST_ERROR
+ if(!fd_info.idx0_elem)
+ TEST_ERROR
+ if(!fd_info.idx1_obj)
+ TEST_ERROR
+ if(!fd_info.idx1_elem)
+ TEST_ERROR
+ if(!fd_info.idx10000_obj)
+ TEST_ERROR
+ if(!fd_info.idx10000_elem)
+ TEST_ERROR
- /* Unprotect & unpin the base entry */
- if(H5AC_unprotect(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, base_addr, base_entry, (H5AC__UNPIN_ENTRY_FLAG | H5AC__DELETED_FLAG)) < 0)
- TEST_ERROR
- /* Remove the test entry as a flush dependency for 0th index in the array */
- if(H5EA_unsupport(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)0, (H5AC_info_t *)entry1) < 0)
- TEST_ERROR
+ /* Remove the base entry as a flush dependency for the array */
+ if(H5EA_undepend((H5AC_info_t *)base_entry, ea) < 0)
+ TEST_ERROR
- /* Protect the test entry */
- if(NULL == (entry1 = (earray_test_t *)H5AC_protect(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, addr1, NULL, H5AC_WRITE)))
- TEST_ERROR
+ /* Protect the base entry */
+ if(NULL == (base_entry = (earray_test_t *)H5AC_protect(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, base_addr, NULL, H5AC_WRITE)))
+ TEST_ERROR
- /* Unprotect & unpin the test entry */
- if(H5AC_unprotect(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, addr1, entry1, (H5AC__UNPIN_ENTRY_FLAG | H5AC__DELETED_FLAG)) < 0)
- TEST_ERROR
+ /* Unprotect & unpin the base entry */
+ if(H5AC_unprotect(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, base_addr, base_entry, (H5AC__UNPIN_ENTRY_FLAG | H5AC__DELETED_FLAG)) < 0)
+ TEST_ERROR
- /* Remove the test entry as a flush dependency for 1st index in the array */
- if(H5EA_unsupport(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)1, (H5AC_info_t *)entry2) < 0)
- TEST_ERROR
+ /* Remove the test entry as a flush dependency for 0th index in the array */
+ if(H5EA_unsupport(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)0, (H5AC_info_t *)entry1) < 0)
+ TEST_ERROR
- /* Protect the test entry */
- if(NULL == (entry2 = (earray_test_t *)H5AC_protect(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, addr2, NULL, H5AC_WRITE)))
- TEST_ERROR
+ /* Protect the test entry */
+ if(NULL == (entry1 = (earray_test_t *)H5AC_protect(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, addr1, NULL, H5AC_WRITE)))
+ TEST_ERROR
- /* Unprotect & unpin the test entry */
- if(H5AC_unprotect(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, addr2, entry2, (H5AC__UNPIN_ENTRY_FLAG | H5AC__DELETED_FLAG)) < 0)
- TEST_ERROR
+ /* Unprotect & unpin the test entry */
+ if(H5AC_unprotect(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, addr1, entry1, (H5AC__UNPIN_ENTRY_FLAG | H5AC__DELETED_FLAG)) < 0)
+ TEST_ERROR
- /* Remove the test entry as a flush dependency for 10,000th index in the array */
- if(H5EA_unsupport(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)10000, (H5AC_info_t *)entry3) < 0)
- TEST_ERROR
+ /* Remove the test entry as a flush dependency for 1st index in the array */
+ if(H5EA_unsupport(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)1, (H5AC_info_t *)entry2) < 0)
+ TEST_ERROR
- /* Protect the test entry */
- if(NULL == (entry3 = (earray_test_t *)H5AC_protect(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, addr3, NULL, H5AC_WRITE)))
- TEST_ERROR
+ /* Protect the test entry */
+ if(NULL == (entry2 = (earray_test_t *)H5AC_protect(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, addr2, NULL, H5AC_WRITE)))
+ TEST_ERROR
- /* Unprotect & unpin the test entry */
- if(H5AC_unprotect(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, addr3, entry3, (H5AC__UNPIN_ENTRY_FLAG | H5AC__DELETED_FLAG)) < 0)
- TEST_ERROR
+ /* Unprotect & unpin the test entry */
+ if(H5AC_unprotect(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, addr2, entry2, (H5AC__UNPIN_ENTRY_FLAG | H5AC__DELETED_FLAG)) < 0)
+ TEST_ERROR
- /* Close the extensible array */
- if(H5EA_close(ea, H5P_DATASET_XFER_DEFAULT) < 0)
- FAIL_STACK_ERROR
- ea = NULL;
+ /* Remove the test entry as a flush dependency for 10,000th index in the array */
+ if(H5EA_unsupport(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)10000, (H5AC_info_t *)entry3) < 0)
+ TEST_ERROR
- /* Close the file */
- if(H5Fclose(file) < 0)
- FAIL_STACK_ERROR
+ /* Protect the test entry */
+ if(NULL == (entry3 = (earray_test_t *)H5AC_protect(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, addr3, NULL, H5AC_WRITE)))
+ TEST_ERROR
- /* All tests passed */
- PASSED()
+ /* Unprotect & unpin the test entry */
+ if(H5AC_unprotect(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, addr3, entry3, (H5AC__UNPIN_ENTRY_FLAG | H5AC__DELETED_FLAG)) < 0)
+ TEST_ERROR
+
+ /* Close the extensible array */
+ if(H5EA_close(ea, H5P_DATASET_XFER_DEFAULT) < 0)
+ FAIL_STACK_ERROR
+ ea = NULL;
+
+ /* Close the file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* All tests passed */
+ PASSED()
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD not compatible with SWMR access");
+ } /* end else */
return 0;
@@ -1603,6 +1621,7 @@ error:
H5E_BEGIN_TRY {
if(ea)
H5EA_close(ea, H5P_DATASET_XFER_DEFAULT);
+ H5Pclose(fapl_copy);
H5Fclose(file);
} H5E_END_TRY;
@@ -2790,6 +2809,11 @@ main(void)
unsigned nerrors = 0; /* Cumulative error count */
time_t curr_time; /* Current time, for seeding random number generator */
int ExpressMode; /* Test express value */
+ const char *env_h5_drvr; /* File Driver value from environment */
+
+ env_h5_drvr = HDgetenv("HDF5_DRIVER");
+ if(env_h5_drvr == NULL)
+ env_h5_drvr = "nomatch";
/* Reset library */
h5_reset();
@@ -2855,7 +2879,7 @@ main(void)
nerrors += test_reopen(fapl, &cparam, &tparam);
nerrors += test_open_twice(fapl, &cparam, &tparam);
nerrors += test_delete_open(fapl, &cparam, &tparam);
- nerrors += test_flush_depend(fapl, &cparam, &tparam);
+ nerrors += test_flush_depend(env_h5_drvr, fapl, &cparam, &tparam);
/* Iterate over the type of capacity tests */
for(curr_iter = EARRAY_ITER_FW; curr_iter < EARRAY_ITER_NITERS; curr_iter++) {
diff --git a/test/links.c b/test/links.c
index 0bcfd31..372a785 100644
--- a/test/links.c
+++ b/test/links.c
@@ -3954,7 +3954,7 @@ external_set_elink_fapl3(hbool_t new_format)
*-------------------------------------------------------------------------
*/
static int
-external_set_elink_acc_flags(hid_t fapl, hbool_t new_format)
+external_set_elink_acc_flags(const char *env_h5_drvr, hid_t fapl, hbool_t new_format)
{
hid_t file1 = -1, file2 = -1, group = -1, subgroup = -1, gapl = -1;
char filename1[NAME_BUF_SIZE],
@@ -4001,6 +4001,9 @@ external_set_elink_acc_flags(hid_t fapl, hbool_t new_format)
/* Create a group through the external link using gapl (should succeed) */
if((group = H5Gcreate2(file1, "/ext_link/group", H5P_DEFAULT, H5P_DEFAULT, gapl)) < 0) TEST_ERROR
+ /* Close group */
+ if(H5Gclose(group) < 0) TEST_ERROR
+
/* Unset elink access flags on gapl */
if(H5Pset_elink_acc_flags(gapl, H5F_ACC_DEFAULT) < 0) TEST_ERROR
@@ -4028,14 +4031,49 @@ external_set_elink_acc_flags(hid_t fapl, hbool_t new_format)
} H5E_END_TRY;
if(ret != FAIL) TEST_ERROR
- /* Close file1 and group */
- if(H5Gclose(group) < 0) TEST_ERROR
+ /* Close file1 */
if(H5Fclose(file1) < 0) TEST_ERROR
- /* Reopen file1, with read-write and SWMR-write access */
- /* Only supported under the latest file format */
- if(new_format) {
- if((file1 = H5Fopen(filename1, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) FAIL_STACK_ERROR
+ /* Can't run this test with multi-file VFDs */
+ if(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family")) {
+ /* Reopen file1, with read-write and SWMR-write access */
+ /* Only supported under the latest file format */
+ if(new_format) {
+ if((file1 = H5Fopen(filename1, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0) FAIL_STACK_ERROR
+
+ /* Open a group through the external link using default gapl */
+ if((group = H5Gopen2(file1, "/ext_link/group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+
+ /* Verify that the correct parameters have been set on file2 */
+ if((file2 = H5Iget_file_id(group)) < 0) FAIL_STACK_ERROR
+ if(H5Fget_intent(file2, &flags) < 0) FAIL_STACK_ERROR
+ if(flags != (H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE)) TEST_ERROR
+
+ /* Close file2 and group */
+ if(H5Gclose(group) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(file2) < 0) FAIL_STACK_ERROR
+
+ /* Set elink access flags on gapl to be H5F_ACC_RDWR (dropping SWMR_WRITE) */
+ if(H5Pset_elink_acc_flags(gapl, H5F_ACC_RDWR) < 0) FAIL_STACK_ERROR
+
+ /* Open a group through the external link using gapl */
+ if((group = H5Gopen2(file1, "/ext_link/group", gapl)) < 0) FAIL_STACK_ERROR
+
+ /* Verify that the correct parameters have been set on file2 */
+ if((file2 = H5Iget_file_id(group)) < 0) FAIL_STACK_ERROR
+ if(H5Fget_intent(file2, &flags) < 0) FAIL_STACK_ERROR
+ if(flags != H5F_ACC_RDWR) TEST_ERROR
+
+ /* Close file2 and group */
+ if(H5Gclose(group) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(file2) < 0) FAIL_STACK_ERROR
+
+ /* Close file1 */
+ if(H5Fclose(file1) < 0) TEST_ERROR
+ }
+
+ /* Reopen file1, with read-only and SWMR-read access */
+ if((file1 = H5Fopen(filename1, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) FAIL_STACK_ERROR
/* Open a group through the external link using default gapl */
if((group = H5Gopen2(file1, "/ext_link/group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
@@ -4043,14 +4081,14 @@ external_set_elink_acc_flags(hid_t fapl, hbool_t new_format)
/* Verify that the correct parameters have been set on file2 */
if((file2 = H5Iget_file_id(group)) < 0) FAIL_STACK_ERROR
if(H5Fget_intent(file2, &flags) < 0) FAIL_STACK_ERROR
- if(flags != (H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE)) TEST_ERROR
+ if(flags != (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ)) TEST_ERROR
/* Close file2 and group */
if(H5Gclose(group) < 0) FAIL_STACK_ERROR
if(H5Fclose(file2) < 0) FAIL_STACK_ERROR
/* Set elink access flags on gapl to be H5F_ACC_RDWR (dropping SWMR_WRITE) */
- if(H5Pset_elink_acc_flags(gapl, H5F_ACC_RDWR) < 0) FAIL_STACK_ERROR
+ if(H5Pset_elink_acc_flags(gapl, H5F_ACC_RDONLY) < 0) FAIL_STACK_ERROR
/* Open a group through the external link using gapl */
if((group = H5Gopen2(file1, "/ext_link/group", gapl)) < 0) FAIL_STACK_ERROR
@@ -4058,7 +4096,7 @@ external_set_elink_acc_flags(hid_t fapl, hbool_t new_format)
/* Verify that the correct parameters have been set on file2 */
if((file2 = H5Iget_file_id(group)) < 0) FAIL_STACK_ERROR
if(H5Fget_intent(file2, &flags) < 0) FAIL_STACK_ERROR
- if(flags != H5F_ACC_RDWR) TEST_ERROR
+ if(flags != H5F_ACC_RDONLY) TEST_ERROR
/* Close file2 and group */
if(H5Gclose(group) < 0) FAIL_STACK_ERROR
@@ -4066,40 +4104,7 @@ external_set_elink_acc_flags(hid_t fapl, hbool_t new_format)
/* Close file1 */
if(H5Fclose(file1) < 0) TEST_ERROR
- }
-
- /* Reopen file1, with read-only and SWMR-read access */
- if((file1 = H5Fopen(filename1, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl)) < 0) FAIL_STACK_ERROR
-
- /* Open a group through the external link using default gapl */
- if((group = H5Gopen2(file1, "/ext_link/group", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
-
- /* Verify that the correct parameters have been set on file2 */
- if((file2 = H5Iget_file_id(group)) < 0) FAIL_STACK_ERROR
- if(H5Fget_intent(file2, &flags) < 0) FAIL_STACK_ERROR
- if(flags != (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ)) TEST_ERROR
-
- /* Close file2 and group */
- if(H5Gclose(group) < 0) FAIL_STACK_ERROR
- if(H5Fclose(file2) < 0) FAIL_STACK_ERROR
-
- /* Set elink access flags on gapl to be H5F_ACC_RDWR (dropping SWMR_WRITE) */
- if(H5Pset_elink_acc_flags(gapl, H5F_ACC_RDONLY) < 0) FAIL_STACK_ERROR
-
- /* Open a group through the external link using gapl */
- if((group = H5Gopen2(file1, "/ext_link/group", gapl)) < 0) FAIL_STACK_ERROR
-
- /* Verify that the correct parameters have been set on file2 */
- if((file2 = H5Iget_file_id(group)) < 0) FAIL_STACK_ERROR
- if(H5Fget_intent(file2, &flags) < 0) FAIL_STACK_ERROR
- if(flags != H5F_ACC_RDONLY) TEST_ERROR
-
- /* Close file2 and group */
- if(H5Gclose(group) < 0) FAIL_STACK_ERROR
- if(H5Fclose(file2) < 0) FAIL_STACK_ERROR
-
- /* Close file1 */
- if(H5Fclose(file1) < 0) TEST_ERROR
+ } /* end if */
/* Verify that H5Fcreate and H5Fopen reject H5F_ACC_DEFAULT */
@@ -14631,7 +14636,7 @@ main(void)
/* This test cannot run with the EFC because the EFC cannot currently
* reopen a cached file with a different intent */
- nerrors += external_set_elink_acc_flags(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_set_elink_acc_flags(env_h5_drvr, my_fapl, new_format) < 0 ? 1 : 0;
/* Try external link tests both with and without the external file cache
*/
diff --git a/test/swmr_addrem_writer.c b/test/swmr_addrem_writer.c
index b2cee81..c15854c 100644
--- a/test/swmr_addrem_writer.c
+++ b/test/swmr_addrem_writer.c
@@ -88,6 +88,10 @@ open_skeleton(const char *filename, unsigned verbose)
if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
return -1;
+ /* Set to use the latest library format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ return -1;
+
#ifdef QAK
/* Increase the initial size of the metadata cache */
{
diff --git a/test/swmr_common.c b/test/swmr_common.c
index 651e88e..6cbd5e2 100644
--- a/test/swmr_common.c
+++ b/test/swmr_common.c
@@ -257,17 +257,19 @@ shutdown_symbols(void)
int
print_metadata_retries_info(hid_t fid)
{
- H5F_retries_info_t info;
- unsigned power;
- unsigned i, j;
+ H5F_retry_info_t info;
+ unsigned i;
/* Retrieve the collection of retries */
- if(H5Fget_metadata_read_retries_info(fid, &info) < 0)
+ if(H5Fget_metadata_read_retry_info(fid, &info) < 0)
return (-1);
/* Print information for each non-NULL retries[i] */
- for(i = 0; i < NUM_METADATA_READ_RETRIES; i++) {
- if(info.retries[i] == NULL)
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) {
+ unsigned power;
+ unsigned j;
+
+ if(NULL == info.retries[i])
continue;
fprintf(stderr, "Metadata read retries for item %u:\n", i);
@@ -277,13 +279,14 @@ print_metadata_retries_info(hid_t fid)
fprintf(stderr, "\t# of retries for %u - %u retries: %u\n",
power, (power * 10) - 1, info.retries[i][j]);
power *= 10;
- }
- }
+ } /* end for */
+ } /* end for */
/* Free memory for each non-NULL retries[i] */
- for(i = 0; i < NUM_METADATA_READ_RETRIES; i++) {
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++)
if(info.retries[i] != NULL)
free(info.retries[i]);
- }
+
return 0;
} /* print_metadata_retries_info() */
+
diff --git a/test/swmr_generator.c b/test/swmr_generator.c
index 6946184..f556c3d 100644
--- a/test/swmr_generator.c
+++ b/test/swmr_generator.c
@@ -335,7 +335,6 @@ int main(int argc, const char *argv[])
gettimeofday(&t, NULL);
random_seed = (unsigned)((t.tv_sec * 1000) + t.tv_usec);
} /* end if */
- /* random_seed = 125092666; */
srandom(random_seed);
/* ALWAYS emit the random seed for possible debugging */
fprintf(stderr, "Using generator random seed (used in sparse test only): %u\n", random_seed);
diff --git a/test/swmr_remove_writer.c b/test/swmr_remove_writer.c
index c05cf6f..33d8899 100644
--- a/test/swmr_remove_writer.c
+++ b/test/swmr_remove_writer.c
@@ -88,6 +88,10 @@ open_skeleton(const char *filename, unsigned verbose)
if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
return -1;
+ /* Set to use the latest library format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ return -1;
+
#ifdef QAK
/* Increase the initial size of the metadata cache */
{
diff --git a/test/swmr_sparse_reader.c b/test/swmr_sparse_reader.c
index 9cccef1..1678949 100644
--- a/test/swmr_sparse_reader.c
+++ b/test/swmr_sparse_reader.c
@@ -308,11 +308,10 @@ read_records(const char *filename, unsigned verbose, unsigned long nrecords,
} /* end if */
} /* end while */
-
/* Retrieve and print the collection of metadata read retries */
if(print_metadata_retries_info(fid) < 0)
fprintf(stderr, "Warning: could not obtain metadata retries info\n");
-
+
/* Close file */
if(H5Fclose(fid) < 0)
return -1;
diff --git a/test/swmr_sparse_writer.c b/test/swmr_sparse_writer.c
index dda9c98..d30c86d 100644
--- a/test/swmr_sparse_writer.c
+++ b/test/swmr_sparse_writer.c
@@ -84,6 +84,10 @@ open_skeleton(const char *filename, unsigned verbose)
if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
return -1;
+ /* Set to use the latest library format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ return -1;
+
#ifdef QAK
/* Increase the initial size of the metadata cache */
{
diff --git a/test/swmr_writer.c b/test/swmr_writer.c
index 445932d..29438d3 100644
--- a/test/swmr_writer.c
+++ b/test/swmr_writer.c
@@ -76,6 +76,10 @@ open_skeleton(const char *filename, unsigned verbose)
if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
return -1;
+ /* Set to use the latest library format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ return -1;
+
#ifdef QAK
/* Increase the initial size of the metadata cache */
{
diff --git a/test/tfile.c b/test/tfile.c
index b8b5754..e2c7bf4 100644
--- a/test/tfile.c
+++ b/test/tfile.c
@@ -26,8 +26,8 @@
#include "H5srcdir.h"
#include "H5Bprivate.h"
-#include "H5Pprivate.h"
#include "H5Iprivate.h"
+#include "H5Pprivate.h"
/*
* This file needs to access private information from the H5F package.
@@ -3517,7 +3517,7 @@ test_swmr_write(void)
/* Output message about test being performed */
MESSAGE(5, ("Testing H5F_ACC_SWMR_WRITE access flag\n"));
- /* Create a copy of the file access property list */
+ /* Create a file access property list */
fapl = H5Pcreate(H5P_FILE_ACCESS);
CHECK(fapl, FAIL, "H5Pcreate");
@@ -3545,6 +3545,13 @@ test_swmr_write(void)
CHECK(ret, FAIL, "H5Fclose");
+ /* Attempt to open file, with SWMR_WRITE flag but not latest format */
+ H5E_BEGIN_TRY {
+ fid = H5Fopen(FILE1, (H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE), H5P_DEFAULT);
+ } H5E_END_TRY;
+ VERIFY(fid, FAIL, "H5Fopen");
+
+
/* Create file, with SWMR_WRITE flag */
fid = H5Fcreate(FILE1, (H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE), H5P_DEFAULT, fapl);
CHECK(fid, FAIL, "H5Fcreate");
@@ -3621,6 +3628,25 @@ test_swmr_write(void)
ret = H5Pclose(fapl);
CHECK(ret, FAIL, "H5Pclose");
+
+ /* Create a file access property list */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl, FAIL, "H5Pcreate");
+
+ /* Set a non-POSIX VFD */
+ ret = H5Pset_fapl_stdio(fapl);
+ CHECK(ret, FAIL, "H5Pset_fapl_stdio");
+
+ /* Try to reopen file w/SWMR_WRITE flag & non-POSIX VFD */
+ H5E_BEGIN_TRY {
+ fid = H5Fopen(FILE1, (H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE), fapl);
+ } H5E_END_TRY;
+ VERIFY(fid, FAIL, "H5Fopen");
+
+ /* Close the property list */
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+
} /* end test_swmr_write() */
/****************************************************************
@@ -3634,6 +3660,7 @@ static void
test_swmr_read(void)
{
hid_t fid, fid2; /* File IDs */
+ hid_t fapl; /* File access property list id */
unsigned intent; /* File access flags */
herr_t ret; /* Generic return value */
@@ -3675,7 +3702,13 @@ test_swmr_read(void)
VERIFY(fid, FAIL, "H5Fopen");
- /* Open file, with SWMR_READ flag */
+ /* Attempt to open file, with SWMR_WRITE flag but not latest format */
+ H5E_BEGIN_TRY {
+ fid = H5Fopen(FILE1, (H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE), H5P_DEFAULT);
+ } H5E_END_TRY;
+ VERIFY(fid, FAIL, "H5Fopen");
+
+ /* Open file, with SWMR_READ flag (and non-latest format) */
fid = H5Fopen(FILE1, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), H5P_DEFAULT);
CHECK(fid, FAIL, "H5Fopen");
@@ -3706,6 +3739,26 @@ test_swmr_read(void)
/* Close file */
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
+
+
+ /* Create a file access property list */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl, FAIL, "H5Pcreate");
+
+ /* Set a non-POSIX VFD */
+ ret = H5Pset_fapl_stdio(fapl);
+ CHECK(ret, FAIL, "H5Pset_fapl_stdio");
+
+ /* Try to reopen file w/SWMR_READ flag & non-POSIX VFD */
+ H5E_BEGIN_TRY {
+ fid = H5Fopen(FILE1, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl);
+ } H5E_END_TRY;
+ VERIFY(fid, FAIL, "H5Fopen");
+
+ /* Close the property list */
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+
} /* end test_swmr_read() */
/****************************************************************
@@ -3732,10 +3785,10 @@ test_metadata_read_attempts(void)
/*
* Set A:
* Tests on verifying the # of read attempts when:
- * --setting/getting read attemps from a copy of the
+ * --setting/getting read attempts from a
* file access property list.
*/
- /* Create a copy of file access property list */
+ /* Create a file access property list */
fapl = H5Pcreate(H5P_FILE_ACCESS);
CHECK(fapl, FAIL, "H5Pcreate");
@@ -3808,10 +3861,22 @@ test_metadata_read_attempts(void)
CHECK(ret, FAIL, "H5Pclose");
/* Test 2 */
- /* Open the file with SWMR access and default fapl */
- fid = H5Fopen(FILE1, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), H5P_DEFAULT);
+ /* Create a file access property list */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl, FAIL, "H5Pcreate");
+
+ /* Set to use latest library format */
+ ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
+ CHECK(ret, FAIL, "H5Pset_libver_bounds");
+
+ /* Open the file with SWMR access and default read attempts */
+ fid = H5Fopen(FILE1, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl);
CHECK(fid, FAIL, "H5Fopen");
+ /* Close fapl */
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+
/* Get file's fapl */
file_fapl = H5Fget_access_plist(fid);
CHECK(file_fapl, FAIL, "H5Fget_access_plist");
@@ -3830,10 +3895,14 @@ test_metadata_read_attempts(void)
CHECK(ret, FAIL, "H5Pclose");
/* Test 3 */
- /* Create a copy of file access property list */
+ /* Create a file access property list */
fapl = H5Pcreate(H5P_FILE_ACCESS);
CHECK(fapl, FAIL, "H5Pcreate");
+ /* Set to use latest library format */
+ ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
+ CHECK(ret, FAIL, "H5Pset_libver_bounds");
+
/* Set the # of read attempts */
ret = H5Pset_metadata_read_attempts(fapl, 9);
CHECK(ret, FAIL, "H5Pset_metadata_read_attempts");
@@ -3842,6 +3911,10 @@ test_metadata_read_attempts(void)
fid = H5Fopen(FILE1, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl);
CHECK(fid, FAIL, "H5Fopen");
+ /* Close fapl */
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+
/* Get file's fapl */
file_fapl = H5Fget_access_plist(fid);
CHECK(file_fapl, FAIL, "H5Fget_access_plist");
@@ -3860,10 +3933,14 @@ test_metadata_read_attempts(void)
CHECK(ret, FAIL, "H5Pclose");
/* Test 4 */
- /* Create a copy of file access property list */
+ /* Create a file access property list */
fapl = H5Pcreate(H5P_FILE_ACCESS);
CHECK(fapl, FAIL, "H5Pcreate");
+ /* Set to use latest library format */
+ ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
+ CHECK(ret, FAIL, "H5Pset_libver_bounds");
+
/* Set the # of read attempts */
ret = H5Pset_metadata_read_attempts(fapl, 1);
CHECK(ret, FAIL, "H5Pset_metadata_read_attempts");
@@ -3872,6 +3949,10 @@ test_metadata_read_attempts(void)
fid = H5Fopen(FILE1, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl);
CHECK(fid, FAIL, "H5Fopen");
+ /* Close fapl */
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+
/* Get file's fapl */
file_fapl = H5Fget_access_plist(fid);
CHECK(file_fapl, FAIL, "H5Fget_access_plist");
@@ -3890,14 +3971,22 @@ test_metadata_read_attempts(void)
CHECK(ret, FAIL, "H5Pclose");
/* Test 5 */
- /* Create a copy of file access property list */
+ /* Create a file access property list */
fapl = H5Pcreate(H5P_FILE_ACCESS);
CHECK(fapl, FAIL, "H5Pcreate");
- /* Open the file with SWMR_READ and fapl (non-default but unset) */
+ /* Set to use latest library format */
+ ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
+ CHECK(ret, FAIL, "H5Pset_libver_bounds");
+
+ /* Open the file with SWMR_READ and fapl (non-default read attempts but unset) */
fid = H5Fopen(FILE1, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl);
CHECK(fid, FAIL, "H5Fopen");
+ /* Close fapl */
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+
/* Get file's fapl */
file_fapl = H5Fget_access_plist(fid);
CHECK(file_fapl, FAIL, "H5Fget_access_plist");
@@ -3923,10 +4012,22 @@ test_metadata_read_attempts(void)
* --using default or non-default file access property list
*/
/* Test 1 */
- /* Create a file with non-SWMR access and default fapl */
- fid = H5Fcreate(FILE1, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, H5P_DEFAULT);
+ /* Create a file access property list */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl, FAIL, "H5Pcreate");
+
+ /* Set to use latest library format */
+ ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
+ CHECK(ret, FAIL, "H5Pset_libver_bounds");
+
+ /* Create a file with non-SWMR access and default read attempts */
+ fid = H5Fcreate(FILE1, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl);
CHECK(fid, FAIL, "H5Fcreate");
+ /* Close fapl */
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+
/* Get file's fapl */
file_fapl = H5Fget_access_plist(fid);
CHECK(file_fapl, FAIL, "H5Fget_access_plist");
@@ -3967,7 +4068,7 @@ test_metadata_read_attempts(void)
CHECK(ret, FAIL, "H5Pclose");
/* Test 3 */
- /* Create a copy of file access property list */
+ /* Create a file access property list */
fapl = H5Pcreate(H5P_FILE_ACCESS);
CHECK(fapl, FAIL, "H5Pcreate");
@@ -3975,10 +4076,14 @@ test_metadata_read_attempts(void)
ret = H5Pset_metadata_read_attempts(fapl, 9);
CHECK(ret, FAIL, "H5Pset_metadata_read_attempts");
- /* Open the file with SWMR access and fapl (non-default & set to 9) */
+ /* Open the file with non-SWMR access and fapl (non-default & set to 9) */
fid = H5Fopen(FILE1, H5F_ACC_RDONLY, fapl);
CHECK(fid, FAIL, "H5Fopen");
+ /* Close fapl */
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+
/* Get file's fapl */
file_fapl = H5Fget_access_plist(fid);
CHECK(file_fapl, FAIL, "H5Fget_access_plist");
@@ -3997,7 +4102,7 @@ test_metadata_read_attempts(void)
CHECK(ret, FAIL, "H5Pclose");
/* Test 4 */
- /* Create a copy of file access property list */
+ /* Create a file access property list */
fapl = H5Pcreate(H5P_FILE_ACCESS);
CHECK(fapl, FAIL, "H5Pcreate");
@@ -4005,10 +4110,14 @@ test_metadata_read_attempts(void)
ret = H5Pset_metadata_read_attempts(fapl, 1);
CHECK(ret, FAIL, "H5Pset_metadata_read_attempts");
- /* Open the file with SWMR access and fapl (non-default & set to 1) */
+ /* Open the file with non-SWMR access and fapl (non-default & set to 1) */
fid = H5Fopen(FILE1, H5F_ACC_RDONLY, fapl);
CHECK(fid, FAIL, "H5Fopen");
+ /* Close fapl */
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+
/* Get file's fapl */
file_fapl = H5Fget_access_plist(fid);
CHECK(file_fapl, FAIL, "H5Fget_access_plist");
@@ -4027,14 +4136,18 @@ test_metadata_read_attempts(void)
CHECK(ret, FAIL, "H5Pclose");
/* Test 5 */
- /* Create a copy of file access property list */
+ /* Create a file access property list */
fapl = H5Pcreate(H5P_FILE_ACCESS);
CHECK(fapl, FAIL, "H5Pcreate");
- /* Open the file with SWMR_READ and fapl (non-default but unset) */
+ /* Open the file with non-SWMR_READ and fapl (non-default but unset) */
fid = H5Fopen(FILE1, H5F_ACC_RDONLY, fapl);
CHECK(fid, FAIL, "H5Fopen");
+ /* Close fapl */
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+
/* Get file's fapl */
file_fapl = H5Fget_access_plist(fid);
CHECK(file_fapl, FAIL, "H5Pget_access_plist");
@@ -4053,10 +4166,14 @@ test_metadata_read_attempts(void)
CHECK(ret, FAIL, "H5Pclose");
- /* Create a copy of file access property list */
+ /* Create a file access property list */
fapl = H5Pcreate(H5P_FILE_ACCESS);
CHECK(fapl, FAIL, "H5Pcreate");
+ /* Set to use latest library format */
+ ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
+ CHECK(ret, FAIL, "H5Pset_libver_bounds");
+
/* Set the # of read attempts */
ret = H5Pset_metadata_read_attempts(fapl, 9);
CHECK(ret, FAIL, "H5Pset_metadata_read_attempts");
@@ -4065,11 +4182,15 @@ test_metadata_read_attempts(void)
fid = H5Fcreate(FILE1, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl);
CHECK(fid, FAIL, "H5Fcreate");
+ /* Close fapl */
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+
/* Close the file */
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
- /* Open file again with SWMR access and default fapl */
+ /* Open file again with non-SWMR access and default fapl */
fid = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT);
CHECK(fid, FAIL, "H5Fopen");
@@ -4090,10 +4211,22 @@ test_metadata_read_attempts(void)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
- /* Open file again with SWMR access and default fapl */
- fid = H5Fopen(FILE1, H5F_ACC_SWMR_READ, H5P_DEFAULT);
+ /* Create a file access property list */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl, FAIL, "H5Pcreate");
+
+ /* Set to use latest library format */
+ ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
+ CHECK(ret, FAIL, "H5Pset_libver_bounds");
+
+ /* Open file again with SWMR access and default read attempts */
+ fid = H5Fopen(FILE1, H5F_ACC_SWMR_READ, fapl);
CHECK(fid, FAIL, "H5Fopen");
+ /* Close fapl */
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+
/* Get file's fapl */
file_fapl = H5Fget_access_plist(fid);
CHECK(file_fapl, FAIL, "H5Fget_access_plist");
@@ -4127,14 +4260,18 @@ test_metadata_read_attempts(void)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
- /* Open file again with SWMR access and default fapl */
- fid1 = H5Fopen(FILE1, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, H5P_DEFAULT);
- CHECK(fid1, FAIL, "H5Fopen");
-
- /* Create a copy of file access property list */
+ /* Create a file access property list */
fapl = H5Pcreate(H5P_FILE_ACCESS);
CHECK(fapl, FAIL, "H5Pcreate");
+ /* Set to use latest library format */
+ ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
+ CHECK(ret, FAIL, "H5Pset_libver_bounds");
+
+ /* Open file again with SWMR access and default read attempts */
+ fid1 = H5Fopen(FILE1, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl);
+ CHECK(fid1, FAIL, "H5Fopen");
+
/* Set the # of read attempts */
ret = H5Pset_metadata_read_attempts(fapl, 9);
CHECK(ret, FAIL, "H5Pset_metadata_read_attempts");
@@ -4143,6 +4280,10 @@ test_metadata_read_attempts(void)
fid2 = H5Fopen(FILE1, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl);
CHECK(fid2, FAIL, "H5Fopen");
+ /* Close fapl */
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+
/* Re-open fid1 */
fid = H5Freopen(fid1);
CHECK(fid, FAIL, "H5Freopen");
@@ -4154,7 +4295,7 @@ test_metadata_read_attempts(void)
/* Retrieve the # of read attempts from file fapl -- should be H5F_SWMR_METADATA_READ_ATTEMPTS */
ret = H5Pget_metadata_read_attempts(file_fapl, &attempts);
CHECK(ret, FAIL, "H5Pget_metadata_read_attempts");
- VERIFY(attempts, H5F_SWMR_METADATA_READ_ATTEMPTS, "H5Fget_metadata_read_attempts");
+ VERIFY(attempts, H5F_SWMR_METADATA_READ_ATTEMPTS, "H5Pget_metadata_read_attempts");
/* Close the file's fapl */
ret = H5Pclose(file_fapl);
@@ -4172,10 +4313,10 @@ test_metadata_read_attempts(void)
file_fapl = H5Fget_access_plist(fid);
CHECK(file_fapl, FAIL, "H5Fget_access_plist");
- /* Retrieve the # of read attempts from file fapl -- should be 9 */
+ /* Retrieve the # of read attempts from file fapl -- should be H5F_SWMR_METADATA_READ_ATTEMPTS, not 9 */
ret = H5Pget_metadata_read_attempts(file_fapl, &attempts);
CHECK(ret, FAIL, "H5Pget_metadata_read_attempts");
- VERIFY(attempts, 9, "H5Pget_metadata_read_attempts");
+ VERIFY(attempts, H5F_SWMR_METADATA_READ_ATTEMPTS, "H5Pget_metadata_read_attempts");
/* Close the file's fapl */
ret = H5Pclose(file_fapl);
@@ -4199,10 +4340,22 @@ test_metadata_read_attempts(void)
* --H5reopen the files
*/
+ /* Create a file access property list */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl, FAIL, "H5Pcreate");
+
+ /* Set to use latest library format */
+ ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
+ CHECK(ret, FAIL, "H5Pset_libver_bounds");
+
/* Create a file */
- fid = H5Fcreate(FILE1, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, H5P_DEFAULT);
+ fid = H5Fcreate(FILE1, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl);
CHECK(fid1, FAIL, "H5Fcreate");
+ /* Close fapl */
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+
/* Close the file */
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
@@ -4211,7 +4364,7 @@ test_metadata_read_attempts(void)
fid1 = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT);
CHECK(fid2, FAIL, "H5Fopen");
- /* Create a copy of file access property list */
+ /* Create a file access property list */
fapl = H5Pcreate(H5P_FILE_ACCESS);
CHECK(fapl, FAIL, "H5Pcreate");
@@ -4223,6 +4376,10 @@ test_metadata_read_attempts(void)
fid2 = H5Fopen(FILE1, H5F_ACC_RDONLY, fapl);
CHECK(fid2, FAIL, "H5Fopen");
+ /* Close fapl */
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+
/* Re-open fid1 */
fid = H5Freopen(fid1);
CHECK(fid, FAIL, "H5Freopen");
@@ -4274,17 +4431,17 @@ test_metadata_read_attempts(void)
/****************************************************************
**
-** test_metadata_read_retries_info():
-** This test checks whether the public routine H5Fget_metadata_read_retries_info
+** test_metadata_read_retry_info():
+** This test checks whether the public routine H5Fget_metadata_read_retry_info
** works as specified in the reference manual.
**
*****************************************************************/
static void
-test_metadata_read_retries_info(void)
+test_metadata_read_retry_info(void)
{
hid_t fapl, new_fapl; /* File access property list */
hid_t fid, fid1; /* File IDs */
- H5F_retries_info_t info, info1; /* The collection of metadata retries */
+ H5F_retry_info_t info, info1; /* The collection of metadata retries */
H5F_t *f = NULL, *f1 = NULL; /* Internal file object pointers */
unsigned i, j, n; /* Local index variables */
herr_t ret; /* Generic return value */
@@ -4299,12 +4456,12 @@ test_metadata_read_retries_info(void)
/* Output message about test being performed */
- MESSAGE(5, ("Testing H5Fget_metadata_read_retries_info()\n"));
+ MESSAGE(5, ("Testing H5Fget_metadata_read_retry_info()\n"));
/*
* Set up file for testing
*/
- /* Create a copy of file access property list */
+ /* Create a file access property list */
fapl = H5Pcreate(H5P_FILE_ACCESS);
CHECK(fapl, FAIL, "H5Pcreate");
@@ -4374,15 +4531,15 @@ test_metadata_read_retries_info(void)
CHECK(ret, FAIL, "H5Dopen");
/* Retrieve retries information */
- ret = H5Fget_metadata_read_retries_info(fid, &info);
- CHECK(ret, FAIL, "H5Fget_metadata_read_retries_info");
+ ret = H5Fget_metadata_read_retry_info(fid, &info);
+ CHECK(ret, FAIL, "H5Fget_metadata_read_retry_info");
/* Should be 0 */
- VERIFY(info.nbins, 0, "H5Fget_metadata_read_retries");
+ VERIFY(info.nbins, 0, "H5Fget_metadata_read_retry_info");
/* Should be all NULL */
- for(i = 0; i < NUM_METADATA_READ_RETRIES; i++)
- VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retries");
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++)
+ VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retry_info");
/* Closing */
ret=H5Dclose(did1);
@@ -4402,15 +4559,15 @@ test_metadata_read_retries_info(void)
CHECK(fid, FAIL, "H5Fopen");
/* Retrieve retries information */
- ret = H5Fget_metadata_read_retries_info(fid, &info);
- CHECK(ret, FAIL, "H5Fget_metadata_read_retries_info");
+ ret = H5Fget_metadata_read_retry_info(fid, &info);
+ CHECK(ret, FAIL, "H5Fget_metadata_read_retry_info");
/* Should be 2 */
- VERIFY(info.nbins, 2, "H5Fget_metadata_read_retries");
+ VERIFY(info.nbins, 2, "H5Fget_metadata_read_retry_info");
/* Should be all NULL */
- for(i = 0; i < NUM_METADATA_READ_RETRIES; i++)
- VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retries");
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++)
+ VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retry_info");
/* Closing */
ret=H5Fclose(fid);
@@ -4430,16 +4587,16 @@ test_metadata_read_retries_info(void)
fid = H5Fopen(FILE1, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, new_fapl);
CHECK(fid, FAIL, "H5Fopen");
- /* Retrieve retries information */
- ret = H5Fget_metadata_read_retries_info(fid, &info);
- CHECK(ret, FAIL, "H5Fget_metadata_read_retries_info");
+ /* Retrieve retry information */
+ ret = H5Fget_metadata_read_retry_info(fid, &info);
+ CHECK(ret, FAIL, "H5Fget_metadata_read_retry_info");
/* Should be 1 */
- VERIFY(info.nbins, 1, "H5Fget_metadata_read_retries");
+ VERIFY(info.nbins, 1, "H5Fget_metadata_read_retry_info");
/* Should be all NULL */
- for(i = 0; i < NUM_METADATA_READ_RETRIES; i++)
- VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retries");
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++)
+ VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retry_info");
/* Closing */
ret=H5Pclose(new_fapl);
@@ -4460,16 +4617,16 @@ test_metadata_read_retries_info(void)
fid = H5Fopen(FILE1, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, new_fapl);
CHECK(fid, FAIL, "H5Fopen");
- /* Retrieve retries information */
- ret = H5Fget_metadata_read_retries_info(fid, &info);
- CHECK(ret, FAIL, "H5Fget_metadata_read_retries_info");
+ /* Retrieve retry information */
+ ret = H5Fget_metadata_read_retry_info(fid, &info);
+ CHECK(ret, FAIL, "H5Fget_metadata_read_retry_info");
/* Should be 3 */
- VERIFY(info.nbins, 3, "H5Fget_metadata_read_retries");
+ VERIFY(info.nbins, 3, "H5Fget_metadata_read_retry_info");
/* Should be all NULL */
- for(i = 0; i < NUM_METADATA_READ_RETRIES; i++)
- VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retries");
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++)
+ VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retry_info");
/* Closing */
ret=H5Pclose(new_fapl);
@@ -4492,16 +4649,16 @@ test_metadata_read_retries_info(void)
fid = H5Fopen(FILE1, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, new_fapl);
CHECK(fid, FAIL, "H5Fopen");
- /* Retrieve retries information */
- ret = H5Fget_metadata_read_retries_info(fid, &info);
- CHECK(ret, FAIL, "H5Fget_metadata_read_retries_info");
+ /* Retrieve retry information */
+ ret = H5Fget_metadata_read_retry_info(fid, &info);
+ CHECK(ret, FAIL, "H5Fget_metadata_read_retry_info");
/* Should be 4 */
- VERIFY(info.nbins, 4, "H5Fget_metadata_read_retries");
+ VERIFY(info.nbins, 4, "H5Fget_metadata_read_retry_info");
/* Should be all NULL */
- for(i = 0; i < NUM_METADATA_READ_RETRIES; i++)
- VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retries");
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++)
+ VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retry_info");
/* Closing */
ret=H5Pclose(new_fapl);
@@ -4524,16 +4681,16 @@ test_metadata_read_retries_info(void)
fid = H5Fopen(FILE1, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, new_fapl);
CHECK(fid, FAIL, "H5Fopen");
- /* Retrieve retries information */
- ret = H5Fget_metadata_read_retries_info(fid, &info);
- CHECK(ret, FAIL, "H5Fget_metadata_read_retries_info");
+ /* Retrieve retry information */
+ ret = H5Fget_metadata_read_retry_info(fid, &info);
+ CHECK(ret, FAIL, "H5Fget_metadata_read_retry_info");
/* Should be 0 */
- VERIFY(info.nbins, 0, "H5Fget_metadata_read_retries");
+ VERIFY(info.nbins, 0, "H5Fget_metadata_read_retry_info");
/* Should be all NULL */
- for(i = 0; i < NUM_METADATA_READ_RETRIES; i++)
- VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retries");
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++)
+ VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retry_info");
/* Closing */
ret=H5Pclose(new_fapl);
@@ -4542,7 +4699,6 @@ test_metadata_read_retries_info(void)
CHECK(ret, FAIL, "H5Fclose");
-
/*
* Case 2: tests on retries info
*/
@@ -4567,16 +4723,16 @@ test_metadata_read_retries_info(void)
ret = H5Dread(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chkbuf2);
CHECK(ret, FAIL, "H5Dread");
- /* Retrieve retries information */
- ret = H5Fget_metadata_read_retries_info(fid, &info);
- CHECK(ret, FAIL, "H5Fget_metadata_read_retries_info");
+ /* Retrieve retry information */
+ ret = H5Fget_metadata_read_retry_info(fid, &info);
+ CHECK(ret, FAIL, "H5Fget_metadata_read_retry_info");
/* Should be 2 */
- VERIFY(info.nbins, 2, "H5Fget_metadata_read_retries");
+ VERIFY(info.nbins, 2, "H5Fget_metadata_read_retry_info");
/* Should be all NULL */
- for(i = 0; i < NUM_METADATA_READ_RETRIES; i++)
- VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retries");
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++)
+ VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retry_info");
/* Get a pointer to the internal file object */
f = (H5F_t *)H5I_object(fid);
@@ -4606,23 +4762,23 @@ test_metadata_read_retries_info(void)
CHECK(ret, FAIL, "H5F_track_metadata_read_retries");
/* Retrieve the collection of metadata read retries */
- ret = H5Fget_metadata_read_retries_info(fid, &info);
- CHECK(ret, FAIL, "H5Fget_metadata_read_retries_info");
+ ret = H5Fget_metadata_read_retry_info(fid, &info);
+ CHECK(ret, FAIL, "H5Fget_metadata_read_retry_info");
/* Verify retries for v2 B-tree leaf node */
- VERIFY(info.retries[4][0], 0, "H5Fget_metadata_read_retries");
- VERIFY(info.retries[4][1], 500, "H5Fget_metadata_read_retries");
+ VERIFY(info.retries[4][0], 0, "H5Fget_metadata_read_retry_info");
+ VERIFY(info.retries[4][1], 500, "H5Fget_metadata_read_retry_info");
/* Verify retries for extensive array data block */
- VERIFY(info.retries[15][0], 0, "H5Fget_metadata_read_retries");
- VERIFY(info.retries[15][1], 1000, "H5Fget_metadata_read_retries");
+ VERIFY(info.retries[15][0], 0, "H5Fget_metadata_read_retry_info");
+ VERIFY(info.retries[15][1], 1000, "H5Fget_metadata_read_retry_info");
/* Verify retries for file's superblock */
- VERIFY(info.retries[20][0], 1, "H5Fget_metadata_read_retries");
- VERIFY(info.retries[20][1], 0, "H5Fget_metadata_read_retries");
+ VERIFY(info.retries[20][0], 1, "H5Fget_metadata_read_retry_info");
+ VERIFY(info.retries[20][1], 0, "H5Fget_metadata_read_retry_info");
/* Free memory for info.retries */
- for(i = 0; i < NUM_METADATA_READ_RETRIES; i++) {
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) {
if(info.retries[i] != NULL)
HDfree(info.retries[i]);
}
@@ -4655,50 +4811,49 @@ test_metadata_read_retries_info(void)
CHECK(ret, FAIL, "H5F_track_metadata_read_retries");
/* Retrieve the collection of metadata read retries */
- ret = H5Fget_metadata_read_retries_info(fid, &info);
- CHECK(ret, FAIL, "H5Fget_metadata_read_retries_info");
+ ret = H5Fget_metadata_read_retry_info(fid, &info);
+ CHECK(ret, FAIL, "H5Fget_metadata_read_retry_info");
/*
* Verify info has both previous + current retries information:
*/
- for(i = 0; i < NUM_METADATA_READ_RETRIES; i++) {
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) {
switch(i) {
case 0: /* Object header */
- VERIFY(info.retries[i][0], 5, "H5Fget_metadata_read_retries");
- VERIFY(info.retries[i][1], 0, "H5Fget_metadata_read_retries");
+ VERIFY(info.retries[i][0], 5, "H5Fget_metadata_read_retry_info");
+ VERIFY(info.retries[i][1], 0, "H5Fget_metadata_read_retry_info");
break;
case 4: /* v2 B-tree leaf node */
- VERIFY(info.retries[i][0], 0, "H5Fget_metadata_read_retries");
- VERIFY(info.retries[i][1], 500, "H5Fget_metadata_read_retries");
+ VERIFY(info.retries[i][0], 0, "H5Fget_metadata_read_retry_info");
+ VERIFY(info.retries[i][1], 500, "H5Fget_metadata_read_retry_info");
break;
case 15: /* Extensive array data block */
- VERIFY(info.retries[i][0], 1, "H5Fget_metadata_read_retries");
- VERIFY(info.retries[i][1], 1000, "H5Fget_metadata_read_retries");
+ VERIFY(info.retries[i][0], 1, "H5Fget_metadata_read_retry_info");
+ VERIFY(info.retries[i][1], 1000, "H5Fget_metadata_read_retry_info");
break;
case 17: /* Fixed array header */
- VERIFY(info.retries[i][0], 0, "H5Fget_metadata_read_retries");
- VERIFY(info.retries[i][1], 10000, "H5Fget_metadata_read_retries");
+ VERIFY(info.retries[i][0], 0, "H5Fget_metadata_read_retry_info");
+ VERIFY(info.retries[i][1], 10000, "H5Fget_metadata_read_retry_info");
break;
case 20: /* File's superblock */
- VERIFY(info.retries[i][0], 2, "H5Fget_metadata_read_retries");
- VERIFY(info.retries[i][1], 0, "H5Fget_metadata_read_retries");
+ VERIFY(info.retries[i][0], 2, "H5Fget_metadata_read_retry_info");
+ VERIFY(info.retries[i][1], 0, "H5Fget_metadata_read_retry_info");
break;
default:
- VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retries");
+ VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retry_info");
break;
}
}
/* Free memory for info.retries */
- for(i = 0; i < NUM_METADATA_READ_RETRIES; i++) {
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++)
if(info.retries[i] != NULL)
HDfree(info.retries[i]);
- }
/* Closing */
ret=H5Dclose(did1);
@@ -4726,32 +4881,31 @@ test_metadata_read_retries_info(void)
H5F_track_metadata_read_retries(f, H5AC_SUPERBLOCK_ID, 1);
/* Retrieve the collection of metadata read retries */
- ret = H5Fget_metadata_read_retries_info(fid, &info);
- CHECK(ret, FAIL, "H5Fget_metadata_read_retries_info");
+ ret = H5Fget_metadata_read_retry_info(fid, &info);
+ CHECK(ret, FAIL, "H5Fget_metadata_read_retry_info");
/* Should be 3 */
- VERIFY(info.nbins, 3, "H5Fget_metadata_read_retries");
+ VERIFY(info.nbins, 3, "H5Fget_metadata_read_retry_info");
/* Verify retries info */
- for(i = 0; i < NUM_METADATA_READ_RETRIES; i++) {
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) {
switch(i) {
case 20: /* File's superblock */
- VERIFY(info.retries[i][0], 1, "H5Fget_metadata_read_retries");
- VERIFY(info.retries[i][1], 0, "H5Fget_metadata_read_retries");
- VERIFY(info.retries[i][2], 0, "H5Fget_metadata_read_retries");
+ VERIFY(info.retries[i][0], 1, "H5Fget_metadata_read_retry_info");
+ VERIFY(info.retries[i][1], 0, "H5Fget_metadata_read_retry_info");
+ VERIFY(info.retries[i][2], 0, "H5Fget_metadata_read_retry_info");
break;
default:
- VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retries");
+ VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retry_info");
break;
}
}
/* Free memory */
- for(i = 0; i < NUM_METADATA_READ_RETRIES; i++) {
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++)
if(info.retries[i] != NULL)
HDfree(info.retries[i]);
- }
/* Closing */
ret=H5Pclose(new_fapl);
@@ -4780,21 +4934,21 @@ test_metadata_read_retries_info(void)
CHECK(fid, FAIL, "H5Freopen");
/* Retrieve retries information for fid */
- ret = H5Fget_metadata_read_retries_info(fid, &info);
- CHECK(ret, FAIL, "H5Fget_metadata_read_retries_info");
+ ret = H5Fget_metadata_read_retry_info(fid, &info);
+ CHECK(ret, FAIL, "H5Fget_metadata_read_retry_info");
/* Retrieve retries information for fid1*/
- ret = H5Fget_metadata_read_retries_info(fid1, &info1);
- CHECK(ret, FAIL, "H5Fget_metadata_read_retries_info");
+ ret = H5Fget_metadata_read_retry_info(fid1, &info1);
+ CHECK(ret, FAIL, "H5Fget_metadata_read_retry_info");
/* Should be 0 */
- VERIFY(info.nbins, 0, "H5Fget_metadata_read_retries");
- VERIFY(info1.nbins, 0, "H5Fget_metadata_read_retries");
+ VERIFY(info.nbins, 0, "H5Fget_metadata_read_retry_info");
+ VERIFY(info1.nbins, 0, "H5Fget_metadata_read_retry_info");
/* Should be all NULL */
- for(i = 0; i < NUM_METADATA_READ_RETRIES; i++) {
- VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retries");
- VERIFY(info1.retries[i], NULL, "H5Fget_metadata_read_retries");
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) {
+ VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retry_info");
+ VERIFY(info1.retries[i], NULL, "H5Fget_metadata_read_retry_info");
}
/* Closing */
@@ -4838,40 +4992,42 @@ test_metadata_read_retries_info(void)
}
/* Retrieve the collection of metadata read retries for fid */
- ret = H5Fget_metadata_read_retries_info(fid, &info);
- CHECK(ret, FAIL, "H5Fget_metadata_read_retries_info");
+ ret = H5Fget_metadata_read_retry_info(fid, &info);
+ CHECK(ret, FAIL, "H5Fget_metadata_read_retry_info");
/* Retrieve the collection of metadata read retries for fid1 */
- ret = H5Fget_metadata_read_retries_info(fid1, &info1);
- CHECK(ret, FAIL, "H5Fget_metadata_read_retries_info");
+ ret = H5Fget_metadata_read_retry_info(fid1, &info1);
+ CHECK(ret, FAIL, "H5Fget_metadata_read_retry_info");
/* Verify nbins for fid & fid1: should be 2 */
- VERIFY(info.nbins, 2, "H5Fget_metadata_read_retries");
- VERIFY(info1.nbins, 2, "H5Fget_metadata_read_retries");
+ VERIFY(info.nbins, 2, "H5Fget_metadata_read_retry_info");
+ VERIFY(info1.nbins, 2, "H5Fget_metadata_read_retry_info");
/* Verify retries for fid: fixed array data block page */
- VERIFY(info.retries[19][0], 500, "H5Fget_metadata_read_retries");
- VERIFY(info.retries[19][1], 0, "H5Fget_metadata_read_retries");
+ VERIFY(info.retries[19][0], 500, "H5Fget_metadata_read_retry_info");
+ VERIFY(info.retries[19][1], 0, "H5Fget_metadata_read_retry_info");
- /* Verify retries for fid: free-space sections should be NULL */
- VERIFY(info.retries[9], NULL, "H5Fget_metadata_read_retries");
- VERIFY(info.retries[9], NULL, "H5Fget_metadata_read_retries");
+ /* Verify retries for fid: free-space sections */
+ /* (Since file was re-opened) */
+ VERIFY(info.retries[9][0], 0, "H5Fget_metadata_read_retry_info");
+ VERIFY(info.retries[9][1], 1000, "H5Fget_metadata_read_retry_info");
/* Verify retries for fid1: free-space sections */
- VERIFY(info1.retries[9][0], 0, "H5Fget_metadata_read_retries");
- VERIFY(info1.retries[9][1], 1000, "H5Fget_metadata_read_retries");
+ VERIFY(info1.retries[9][0], 0, "H5Fget_metadata_read_retry_info");
+ VERIFY(info1.retries[9][1], 1000, "H5Fget_metadata_read_retry_info");
- /* Verify retries for fid1: fixed array data block page should be NULL */
- VERIFY(info1.retries[19], NULL, "H5Fget_metadata_read_retries");
- VERIFY(info1.retries[19], NULL, "H5Fget_metadata_read_retries");
+ /* Verify retries for fid1: fixed array data block page */
+ /* (Since file was re-opened) */
+ VERIFY(info1.retries[19][0], 500, "H5Fget_metadata_read_retry_info");
+ VERIFY(info1.retries[19][1], 0, "H5Fget_metadata_read_retry_info");
/* Free memory for info.retries and info1.retries */
- for(i = 0; i < NUM_METADATA_READ_RETRIES; i++) {
+ for(i = 0; i < H5F_NUM_METADATA_READ_RETRY_TYPES; i++) {
if(info.retries[i] != NULL)
HDfree(info.retries[i]);
if(info1.retries[i] != NULL)
HDfree(info1.retries[i]);
- }
+ } /* end for */
/* Closing */
ret=H5Fclose(fid);
@@ -4881,8 +5037,7 @@ test_metadata_read_retries_info(void)
ret=H5Pclose(fapl);
CHECK(ret, FAIL, "H5Pclose");
-
-} /* end test_metadata_read_retries_info() */
+} /* end test_metadata_read_retry_info() */
/****************************************************************
**
@@ -5071,7 +5226,7 @@ test_file(void)
test_swmr_write(); /* Tests for SWMR write access flag */
test_swmr_read(); /* Tests for SWMR read access flag */
test_metadata_read_attempts(); /* Tests for public routines H5Fget/set_metadata_read_attempts() */
- test_metadata_read_retries_info(); /* Tests for public routine H5Fget_metadata_read_retries_info() */
+ test_metadata_read_retry_info(); /* Tests for public routine H5Fget_metadata_read_retry_info() */
#ifndef H5_NO_DEPRECATED_SYMBOLS
test_deprec(); /* Test deprecated routines */
#endif /* H5_NO_DEPRECATED_SYMBOLS */
diff --git a/test/use_common.c b/test/use_common.c
index 36d804c..c25f1f4 100644
--- a/test/use_common.c
+++ b/test/use_common.c
@@ -245,6 +245,7 @@ int write_uc_file(void)
{
hid_t fid; /* File ID for new HDF5 file */
hid_t dsid; /* dataset ID */
+ hid_t fapl; /* File access property list */
hid_t dcpl; /* Dataset creation property list */
char *name;
UC_CTYPE *buffer, *bufptr; /* data buffer */
@@ -261,7 +262,12 @@ int write_uc_file(void)
name = UC_opts.filename;
/* Open the file */
- if((fid = H5Fopen(name, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), H5P_DEFAULT)) < 0){
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ return -1;
+ if(UC_opts.use_swmr)
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ return -1;
+ if((fid = H5Fopen(name, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), fapl)) < 0){
fprintf(stderr, "H5Fopen failed\n");
return -1;
}
@@ -395,6 +401,10 @@ int write_uc_file(void)
fprintf(stderr, "Failed to close file space\n");
return -1;
}
+ if (H5Pclose(fapl) < 0){
+ fprintf(stderr, "Failed to property list\n");
+ return -1;
+ }
if (H5Fclose(fid) < 0){
fprintf(stderr, "Failed to close file id\n");
return -1;