diff options
author | Vailin Choi <vchoi@hdfgroup.org> | 2015-06-24 23:47:24 (GMT) |
---|---|---|
committer | Vailin Choi <vchoi@hdfgroup.org> | 2015-06-24 23:47:24 (GMT) |
commit | 39b99473ea6e83aa394779a591eeef55fe141487 (patch) | |
tree | 624455e25b0c7221ee9507bb7bcbbfb2a8c4b0f2 | |
parent | e36e886cf75b836aba005abea24b955057778ebb (diff) | |
download | hdf5-39b99473ea6e83aa394779a591eeef55fe141487.zip hdf5-39b99473ea6e83aa394779a591eeef55fe141487.tar.gz hdf5-39b99473ea6e83aa394779a591eeef55fe141487.tar.bz2 |
[svn-r27281] Bring revision #24478 from revise_chksum_retry branch to revise_chunks. h5committested.
-rw-r--r-- | hl/src/H5HLprivate2.h | 91 | ||||
-rw-r--r-- | src/H5ACprivate.h | 60 | ||||
-rw-r--r-- | src/H5B2cache.c | 39 | ||||
-rw-r--r-- | src/H5EAcache.c | 65 | ||||
-rw-r--r-- | src/H5F.c | 34 | ||||
-rw-r--r-- | src/H5FAcache.c | 41 | ||||
-rw-r--r-- | src/H5FScache.c | 27 | ||||
-rw-r--r-- | src/H5Fint.c | 103 | ||||
-rw-r--r-- | src/H5Fio.c | 61 | ||||
-rw-r--r-- | src/H5Fpkg.h | 8 | ||||
-rw-r--r-- | src/H5Fprivate.h | 23 | ||||
-rw-r--r-- | src/H5Fpublic.h | 12 | ||||
-rw-r--r-- | src/H5Fquery.c | 2 | ||||
-rw-r--r-- | src/H5Fsuper_cache.c | 71 | ||||
-rw-r--r-- | src/H5HFcache.c | 353 | ||||
-rw-r--r-- | src/H5HFpkg.h | 8 | ||||
-rw-r--r-- | src/H5Ocache.c | 61 | ||||
-rw-r--r-- | src/H5Pfapl.c | 28 | ||||
-rw-r--r-- | src/H5Ppublic.h | 2 | ||||
-rw-r--r-- | src/H5SMcache.c | 36 | ||||
-rw-r--r-- | test/dsets.c | 149 | ||||
-rw-r--r-- | test/earray.c | 5 | ||||
-rw-r--r-- | test/links.c | 89 | ||||
-rw-r--r-- | test/swmr_addrem_writer.c | 4 | ||||
-rw-r--r-- | test/swmr_common.c | 23 | ||||
-rw-r--r-- | test/swmr_generator.c | 1 | ||||
-rw-r--r-- | test/swmr_remove_writer.c | 4 | ||||
-rw-r--r-- | test/swmr_sparse_reader.c | 3 | ||||
-rw-r--r-- | test/swmr_sparse_writer.c | 4 | ||||
-rw-r--r-- | test/swmr_writer.c | 4 | ||||
-rw-r--r-- | test/tfile.c | 445 | ||||
-rw-r--r-- | test/use_common.c | 12 |
32 files changed, 968 insertions, 900 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 625d77f..7b55237 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -53,36 +53,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 cde6a82..8e5554a 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 H5_ATTR_UNUSED *f, hid_t dxpl_id, haddr_t addr, void 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 H5_ATTR_UNUSED *f, hid_t dxpl_id, haddr_t addr, void 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 H5_ATTR_UNUSED *f, hid_t dxpl_id, haddr_t addr, void 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 c41ff24..3363701 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 */ size_t u; /* Local index variable */ @@ -599,7 +590,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 */ @@ -654,15 +645,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; @@ -980,8 +966,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 */ @@ -1009,7 +993,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 */ @@ -1058,15 +1042,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; @@ -1374,8 +1353,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 */ @@ -1405,7 +1382,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 */ @@ -1450,15 +1427,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; @@ -1771,8 +1743,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); @@ -1798,7 +1768,7 @@ H5EA__cache_dblk_page_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 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 */ @@ -1819,15 +1789,10 @@ H5EA__cache_dblk_page_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)) /* 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; @@ -61,7 +61,6 @@ /********************/ - /*********************/ /* Package Variables */ /*********************/ @@ -834,7 +833,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) @@ -848,14 +846,6 @@ H5Freopen(hid_t file_id) 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 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); @@ -1428,7 +1418,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. * @@ -1440,7 +1430,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 */ @@ -1459,11 +1449,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) @@ -1497,14 +1486,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; @@ -1515,7 +1507,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() */ /*------------------------------------------------------------------------- diff --git a/src/H5FAcache.c b/src/H5FAcache.c index 0759213..bbfd94e 100644 --- a/src/H5FAcache.c +++ b/src/H5FAcache.c @@ -171,8 +171,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); @@ -197,7 +195,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 */ @@ -254,15 +252,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) @@ -510,8 +503,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 */ @@ -540,8 +531,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 */ @@ -587,15 +578,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; @@ -904,8 +890,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); @@ -931,7 +915,7 @@ H5FA__cache_dblk_page_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 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 */ @@ -952,15 +936,10 @@ H5FA__cache_dblk_page_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)) /* 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 9c1910d..f68bf0f 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 H5_ATTR_UNUSED addr, void 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 H5_ATTR_UNUSED addr, void 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 H5_ATTR_UNUSED addr, void 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/H5Fint.c b/src/H5Fint.c index 3887222..fa20e71 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -78,7 +78,7 @@ typedef struct H5F_olist_t { static int H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key); static herr_t H5F_build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, - const char *name, char ** /*out*/ actual_name);/* Declare a free list to manage the H5F_t struct */ + const char *name, char ** /*out*/ actual_name); /*********************/ @@ -194,7 +194,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); @@ -655,6 +655,12 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t 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; @@ -673,6 +679,10 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t 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) @@ -689,6 +699,37 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t */ 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 @@ -949,7 +990,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) @@ -1065,40 +1105,6 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, shared = file->shared; lf = shared->lf; - 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 with non-SWMR access, the # of read attempts is always H5F_METADATA_READ_ATTEMPTS (set or not set) */ - if(H5F_INTENT(file) & H5F_ACC_SWMR_READ || H5F_INTENT(file)& 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. @@ -1130,6 +1136,9 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to read root group") } /* 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 @@ -2099,8 +2108,8 @@ done: * 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 @@ -2113,31 +2122,31 @@ 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) diff --git a/src/H5Fio.c b/src/H5Fio.c index 296a707..82e957c 100644 --- a/src/H5Fio.c +++ b/src/H5Fio.c @@ -266,6 +266,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 @@ -273,34 +275,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() */ @@ -311,13 +307,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 @@ -327,8 +324,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 */ @@ -339,7 +337,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 */ @@ -352,25 +350,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 c74384d..051cd2b 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -251,6 +251,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 */ }; /* @@ -259,7 +264,6 @@ struct H5F_file_t { * to shared H5F_file_t structs. */ struct H5F_t { - 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 */ @@ -270,8 +274,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 839fa0a..6a47abc 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -283,7 +283,7 @@ #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)) @@ -326,7 +326,7 @@ #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)) @@ -498,17 +498,20 @@ /* 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" @@ -675,10 +678,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 37dcc93..36df854 100644 --- a/src/H5Fpublic.h +++ b/src/H5Fpublic.h @@ -188,12 +188,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" { @@ -232,7 +232,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 69fe193..fb3b490 100644 --- a/src/H5Fquery.c +++ b/src/H5Fquery.c @@ -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 2b5239d..c55abbe 100644 --- a/src/H5Fsuper_cache.c +++ b/src/H5Fsuper_cache.c @@ -135,17 +135,16 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t H5_ATTR_UNUSED addr, void *_uda 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 @@ -183,36 +182,23 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t H5_ATTR_UNUSED addr, void *_uda 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, 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, 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") @@ -240,7 +226,7 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t H5_ATTR_UNUSED addr, void *_uda /* 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") @@ -252,19 +238,17 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t H5_ATTR_UNUSED addr, void *_uda /* 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) { @@ -451,7 +435,7 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t H5_ATTR_UNUSED addr, void *_uda } /* 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++; @@ -473,12 +457,7 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t H5_ATTR_UNUSED addr, void *_uda H5F_addr_decode(f, (const uint8_t **)&p, &stored_eof/*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 diff --git a/src/H5HFcache.c b/src/H5HFcache.c index 70dd569..4b02e06 100644 --- a/src/H5HFcache.c +++ b/src/H5HFcache.c @@ -1,4 +1,4 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +/* / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * @@ -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 H5_ATTR_UNUSED * flags_ptr); @@ -266,138 +270,6 @@ H5HF__dtable_encode(H5F_t *f, uint8_t **pp, const H5HF_dtable_t *dtable) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF__dtable_encode() */ -/**************************************************/ -/* metadata cache callback definitions for header */ -/**************************************************/ - - -/*------------------------------------------------------------------------- - * 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 @@ -418,17 +290,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 @@ -446,59 +319,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) @@ -509,28 +387,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; + + /* 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; - /* 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") + /* "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 */ - /* Metadata checksum */ - UINT32DECODE(p, stored_chksum); + /* "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 */ - /* Sanity check */ - HDassert((size_t)(p - (const uint8_t *)buf) == hdr->heap_size); + /* 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; - /* 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") + /* 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) @@ -854,8 +776,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 */ @@ -898,8 +818,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; @@ -995,15 +915,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) { @@ -1495,14 +1410,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 @@ -1603,10 +1518,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); @@ -1625,11 +1542,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; @@ -1661,7 +1576,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 4863edc..b0eba2f 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 6085222..8653817 100644 --- a/src/H5Ocache.c +++ b/src/H5Ocache.c @@ -317,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 = 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 @@ -350,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 */ @@ -370,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; @@ -429,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); @@ -461,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) @@ -827,13 +815,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 163288c..8125e43 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 /* Definition of core VFD write tracking flag */ #define H5F_ACS_CORE_WRITE_TRACKING_FLAG_SIZE sizeof(hbool_t) #define H5F_ACS_CORE_WRITE_TRACKING_FLAG_DEF FALSE @@ -433,6 +433,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() */ @@ -3122,7 +3123,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 */ @@ -3152,26 +3153,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 7f93dd7..4c29bd8 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -346,7 +346,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); H5_DLL herr_t H5Pset_core_write_tracking(hid_t fapl_id, hbool_t is_enabled, size_t page_size); H5_DLL herr_t H5Pget_core_write_tracking(hid_t fapl_id, hbool_t *is_enabled, size_t *page_size); diff --git a/src/H5SMcache.c b/src/H5SMcache.c index 72f5913..d4052ef 100644 --- a/src/H5SMcache.c +++ b/src/H5SMcache.c @@ -130,13 +130,11 @@ static H5SM_master_table_t * H5SM_table_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void H5_ATTR_UNUSED *udata) { H5SM_master_table_t *table = NULL; - H5WB_t *wb = NULL; /* Wrapped buffer for table data */ + H5WB_t *wb = NULL; /* Wrapped buffer for table data */ 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 u; /* Counter variable for index headers */ + uint8_t *buf; /* Reading buffer */ + const uint8_t *p; /* Pointer into input buffer */ + size_t u; /* Counter variable for index headers */ H5SM_master_table_t *ret_value; FUNC_ENTER_NOAPI_NOINIT @@ -171,7 +169,7 @@ H5SM_table_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void H5_ATTR_UNUSED *udat 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 */ @@ -217,18 +215,12 @@ H5SM_table_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void H5_ATTR_UNUSED *udat H5F_addr_decode(f, &p, &(table->indexes[u].heap_addr)); /* Compute the size of a list index for this SOHM index */ - table->indexes[u].list_size = H5SM_LIST_SIZE(f, table->indexes[u].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; @@ -472,8 +464,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 u; /* Counter variable for messages in list */ size_t chk_size; /* Exact size with checksum at the end */ H5SM_list_t *ret_value; /* Return value */ @@ -505,10 +495,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; @@ -525,15 +514,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(u = udata->header->num_messages; u < udata->header->list_max; u++) diff --git a/test/dsets.c b/test/dsets.c index 6c6bbcd..092a914 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -8005,7 +8005,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 */ @@ -8060,6 +8060,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++) { @@ -9765,7 +9770,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 */ @@ -9783,78 +9788,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: @@ -11006,7 +11019,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) @@ -11093,7 +11106,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 a0a600b..44abdc2 100644 --- a/test/earray.c +++ b/test/earray.c @@ -2499,6 +2499,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(); diff --git a/test/links.c b/test/links.c index ae7aaa2..6420204 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], @@ -4030,10 +4030,46 @@ external_set_elink_acc_flags(hid_t fapl, hbool_t new_format) /* 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 @@ -4041,14 +4077,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 @@ -4056,7 +4092,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 @@ -4064,40 +4100,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 */ @@ -14634,7 +14637,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 0116467..ac32509 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 362e197..0aec265 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 f22586d..11e0a72 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() */ /**************************************************************** ** @@ -5069,7 +5224,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; |