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 /src/H5HFcache.c | |
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.
Diffstat (limited to 'src/H5HFcache.c')
-rw-r--r-- | src/H5HFcache.c | 353 |
1 files changed, 134 insertions, 219 deletions
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; |