From 1bc858b1b889ae2d0eeca463646592d195db8c94 Mon Sep 17 00:00:00 2001 From: Vailin Choi Date: Fri, 18 Oct 2013 13:10:03 -0500 Subject: [svn-r24331] Changes to track metadata read retries for metadata items with checksum. Implement new public routine H5Fget_metadata_read_retries_info(). h5committested. --- src/H5B2cache.c | 6 +- src/H5EAcache.c | 10 +- src/H5F.c | 172 +++++++- src/H5FAcache.c | 6 +- src/H5FD.c | 26 ++ src/H5FDprivate.h | 1 + src/H5FScache.c | 4 +- src/H5Fio.c | 21 +- src/H5Fpkg.h | 2 + src/H5Fprivate.h | 10 +- src/H5Fpublic.h | 8 + src/H5Fsuper_cache.c | 14 +- src/H5HFcache.c | 26 +- src/H5Ocache.c | 13 +- src/H5Pfapl.c | 52 +-- src/H5Ppublic.h | 4 +- src/H5SMcache.c | 4 +- test/swmr_common.c | 47 +++ test/swmr_common.h | 1 + test/swmr_sparse_reader.c | 13 + test/testfiles/plist_files/fapl_be | Bin 1421 -> 1430 bytes test/testfiles/plist_files/fapl_le | Bin 1421 -> 1430 bytes test/testfiles/plist_files/lapl_be | Bin 1521 -> 1530 bytes test/testfiles/plist_files/lapl_le | Bin 1521 -> 1530 bytes test/tfile.c | 833 ++++++++++++++++++++++++++++++++----- 25 files changed, 1092 insertions(+), 181 deletions(-) diff --git a/src/H5B2cache.c b/src/H5B2cache.c index e9030d8..1d97c63 100644 --- a/src/H5B2cache.c +++ b/src/H5B2cache.c @@ -188,7 +188,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, addr, hdr->hdr_size, hdr->hdr_size, dxpl_id, buf, &computed_chksum) < 0) + 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) HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "incorrect metadata checksum for v2 B-tree header") /* Get temporary pointer to serialized header */ @@ -607,7 +607,7 @@ H5B2__cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) chk_size = H5B2_INT_PREFIX_SIZE + (udata->nrec * udata->hdr->rrec_size) + ((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, addr, udata->hdr->node_size, chk_size, dxpl_id, udata->hdr->page, &computed_chksum) < 0) + if(H5F_read_check_metadata(f, H5FD_MEM_BTREE, H5AC_BT2_INT_ID, addr, udata->hdr->node_size, chk_size, dxpl_id, udata->hdr->page, &computed_chksum) < 0) HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "incorrect metadata checksum for v2 internal node") p = udata->hdr->page; @@ -1030,7 +1030,7 @@ H5B2__cache_leaf_load(H5F_t UNUSED *f, hid_t dxpl_id, haddr_t addr, void *_udata chk_size = H5B2_LEAF_PREFIX_SIZE + (udata->nrec * udata->hdr->rrec_size); /* Read and validate leaf node from disk */ - if(H5F_read_check_metadata(f, H5FD_MEM_BTREE, addr, udata->hdr->node_size, chk_size, dxpl_id, udata->hdr->page, &computed_chksum) < 0) + if(H5F_read_check_metadata(f, H5FD_MEM_BTREE, H5AC_BT2_LEAF_ID, addr, udata->hdr->node_size, chk_size, dxpl_id, udata->hdr->page, &computed_chksum) < 0) HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "incorrect metadata checksum for v2 leaf node") p = udata->hdr->page; diff --git a/src/H5EAcache.c b/src/H5EAcache.c index 381b364..789cdf8 100644 --- a/src/H5EAcache.c +++ b/src/H5EAcache.c @@ -234,7 +234,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, addr, size, size, dxpl_id, buf, &computed_chksum) < 0) + if(H5F_read_check_metadata(f, H5FD_MEM_EARRAY_HDR, H5AC_EARRAY_HDR_ID, addr, size, size, dxpl_id, buf, &computed_chksum) < 0) H5E_THROW(H5E_BADVALUE, "incorrect metadata checksum for extensible array header") /* Get temporary pointer to serialized header */ @@ -598,7 +598,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, addr, size, size, dxpl_id, buf, &computed_chksum) < 0) + if(H5F_read_check_metadata(f, H5FD_MEM_EARRAY_IBLOCK, H5AC_EARRAY_IBLOCK_ID, addr, size, size, dxpl_id, buf, &computed_chksum) < 0) H5E_THROW(H5E_BADVALUE, "incorrect metadata checksum for extensible array index block") /* Get temporary pointer to serialized header */ @@ -1012,7 +1012,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, addr, size, size, dxpl_id, buf, &computed_chksum) < 0) + if(H5F_read_check_metadata(f, H5FD_MEM_EARRAY_SBLOCK, H5AC_EARRAY_SBLOCK_ID, addr, size, size, dxpl_id, buf, &computed_chksum) < 0) H5E_THROW(H5E_BADVALUE, "incorrect metadata checksum for extensible array super block") /* Get temporary pointer to serialized header */ @@ -1408,7 +1408,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, addr, size, size, dxpl_id, buf, &computed_chksum) < 0) + if(H5F_read_check_metadata(f, H5FD_MEM_EARRAY_DBLOCK, H5AC_EARRAY_DBLOCK_ID, addr, size, size, dxpl_id, buf, &computed_chksum) < 0) H5E_THROW(H5E_BADVALUE, "incorrect metadata checksum for extensible data block") /* Get temporary pointer to serialized header */ @@ -1804,7 +1804,7 @@ HDfprintf(stderr, "%s: addr = %a\n", FUNC, addr); H5E_THROW(H5E_CANTGET, "can't get actual buffer") /* Read and validate data block page from disk */ - if(H5F_read_check_metadata(f, H5FD_MEM_EARRAY_DBLK_PAGE, addr, size, size, dxpl_id, buf, &computed_chksum) < 0) + 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) H5E_THROW(H5E_BADVALUE, "incorrect metadata checksum for extensible array data block page") /* Get temporary pointer to serialized header */ diff --git a/src/H5F.c b/src/H5F.c index a6361ff..d5a0131 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -367,7 +367,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_READ_ATTEMPTS_NAME, &(f->read_attempts)) < 0) + if(H5P_set(new_plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, &(f->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); @@ -1239,6 +1239,7 @@ 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) @@ -1365,16 +1366,29 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t 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_READ_ATTEMPTS_NAME, &file->read_attempts) < 0) + 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 H5_SWMR_READ_ATTEMPTS if not set */ - /* When opening file with non-SWMR access, the # of read attempts is always H5F_READ_ATTEMPTS (set or not set) */ + /* When opening file with SWMR access, the # of read attempts is H5F_SWMR_METADATA_READ_ATTEMPTS if not set */ + /* When opening file without SWMR access, the # of read attempts is always H5F_METADATA_READ_ATTEMPTS (set or not set) */ if(file->intent & H5F_ACC_SWMR_READ || file->intent & H5F_ACC_SWMR_WRITE) { if(!file->read_attempts) - file->read_attempts = H5F_SWMR_READ_ATTEMPTS; + file->read_attempts = H5F_SWMR_METADATA_READ_ATTEMPTS; + /* Turn off accumulator */ + shared->feature_flags = lf->feature_flags & ~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_READ_ATTEMPTS; + file->read_attempts = H5F_METADATA_READ_ATTEMPTS; + + /* Determine the # of bins for metdata read retries */ + file->retries_nbins = 0; + if(file->read_attempts > 1) + file->retries_nbins = HDlog10((double)(file->read_attempts - 1)) + 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 @@ -2122,6 +2136,7 @@ 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) @@ -2141,6 +2156,11 @@ H5Freopen(hid_t file_id) /* 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); @@ -3154,6 +3174,97 @@ done: /*------------------------------------------------------------------------- + * Function: H5Fget_metadata_read_retries_info + * + * Purpose: To retrieve the collection of read retries for metadata items with checksum. + * + * Return: Success: non-negative on success + * Failure: Negative + * + * Programmer: Vailin Choi; October 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Fget_metadata_read_retries_info(hid_t file_id, H5F_retries_info_t *info) +{ + H5F_t *file; /* File object for file ID */ + unsigned i, j; /* Local index variable */ + size_t tot_size; /* Size of each retries[i] */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "i*x", file_id, info); + + /* Check args */ + if(!info) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") + + /* Get the file pointer */ + if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") + + /* Copy the # of bins for "retries" array */ + info->nbins = file->retries_nbins; + + /* Initialize the array of "retries" */ + for(i = 0; i < NUM_METADATA_READ_RETRIES; i++) + info->retries[i] = NULL; + + /* Return if there are no bins -- no retries */ + if(!info->nbins) + HGOTO_DONE(SUCCEED); + + /* Calculate size for each retries[i] */ + tot_size = info->nbins * sizeof(uint32_t); + + /* Map and copy information to info's retries for metadata items with tracking for read retries */ + j = 0; + for(i = 0; i < H5AC_NTYPES; i++) { + switch(i) { + case H5AC_OHDR_ID: + case H5AC_OHDR_CHK_ID: + case H5AC_BT2_HDR_ID: + case H5AC_BT2_INT_ID: + case H5AC_BT2_LEAF_ID: + case H5AC_FHEAP_HDR_ID: + case H5AC_FHEAP_DBLOCK_ID: + case H5AC_FHEAP_IBLOCK_ID: + case H5AC_FSPACE_HDR_ID: + case H5AC_FSPACE_SINFO_ID: + case H5AC_SOHM_TABLE_ID: + case H5AC_SOHM_LIST_ID: + case H5AC_EARRAY_HDR_ID: + case H5AC_EARRAY_IBLOCK_ID: + case H5AC_EARRAY_SBLOCK_ID: + case H5AC_EARRAY_DBLOCK_ID: + case H5AC_EARRAY_DBLK_PAGE_ID: + case H5AC_FARRAY_HDR_ID: + 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) { + /* Allocate memory for retries[i] */ + if((info->retries[j] = (uint32_t *)HDmalloc(tot_size)) == NULL) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + /* Copy the information */ + HDmemcpy(info->retries[j], file->retries[i], tot_size); + } + j++; + break; + + default: + break; + } /* end switch */ + } /* end for */ + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Fget_metadata_read_retries_info() */ + + +/*------------------------------------------------------------------------- * Function: H5Fget_free_sections * * Purpose: To get free-space section information for free-space manager with @@ -3375,3 +3486,52 @@ H5F_set_store_msg_crt_idx(H5F_t *f, hbool_t flag) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5F_set_store_msg_crt_idx() */ + + +/*------------------------------------------------------------------------- + * Function: H5F_track_metadata_read_retries + * + * 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) + * + * Return: Success: SUCCEED + * Failure: FAIL + * + * Programmer: Vailin Choi; October 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5F_track_metadata_read_retries(H5F_t *f, H5AC_type_t actype, unsigned retries) +{ + unsigned log_ind; /* Index to the array of retries based on log10 of retries */ + 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(retries > 0); + HDassert(retries < f->read_attempts); + HDassert(actype < H5AC_NTYPES); + + /* Allocate memory for retries */ + if(f->retries[actype] == NULL) + if((f->retries[actype] = (uint32_t *)HDcalloc(f->retries_nbins, sizeof(uint32_t))) == NULL) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + + /* Index to retries based on log10 */ + log_ind = HDlog10((double)retries); + HDassert(log_ind < f->retries_nbins); + + /* Increment the # of the "retries" */ + f->retries[actype][log_ind]++; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5F_track_metadata_read_retries() */ diff --git a/src/H5FAcache.c b/src/H5FAcache.c index 9b2d32c..56ed1e3 100644 --- a/src/H5FAcache.c +++ b/src/H5FAcache.c @@ -195,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, addr, size, size, dxpl_id, buf, &computed_chksum) < 0) + if(H5F_read_check_metadata(f, H5FD_MEM_FARRAY_HDR, H5AC_FARRAY_HDR_ID, addr, size, size, dxpl_id, buf, &computed_chksum) < 0) H5E_THROW(H5E_BADVALUE, "incorrect metadata checksum for fixed array header") /* Get temporary pointer to serialized header */ @@ -539,7 +539,7 @@ H5FA__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_FARRAY_DBLOCK, addr, size, size, dxpl_id, buf, &computed_chksum) < 0) + if(H5F_read_check_metadata(f, H5FD_MEM_FARRAY_DBLOCK, H5AC_FARRAY_DBLOCK_ID, addr, size, size, dxpl_id, buf, &computed_chksum) < 0) H5E_THROW(H5E_BADVALUE, "incorrect metadata checksum for fixed array data block") /* Get temporary pointer to serialized header */ @@ -932,7 +932,7 @@ HDfprintf(stderr, "%s: addr = %a\n", FUNC, addr); H5E_THROW(H5E_CANTGET, "can't get actual buffer") /* Read and validate data block page from disk */ - if(H5F_read_check_metadata(f, H5FD_MEM_FARRAY_DBLK_PAGE, addr, size, size, dxpl_id, buf, &computed_chksum) < 0) + 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) H5E_THROW(H5E_BADVALUE, "incorrect metadata checksum for fixed array data block page") /* Get temporary pointer to serialized header */ diff --git a/src/H5FD.c b/src/H5FD.c index b38b904..49844c5 100644 --- a/src/H5FD.c +++ b/src/H5FD.c @@ -1598,6 +1598,32 @@ H5FD_get_feature_flags(const H5FD_t *file, unsigned long *feature_flags) /*------------------------------------------------------------------------- + * Function: H5FD_set_feature_flags + * + * Purpose: Set the feature flags for the VFD + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Vailin Choi; Oct 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5FD_set_feature_flags(H5FD_t *file, unsigned long feature_flags) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(file); + + /* Set the file's feature flags */ + file->feature_flags = feature_flags; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FD_set_feature_flags() */ + + +/*------------------------------------------------------------------------- * Function: H5FD_get_fs_type_map * * Purpose: Retrieve the free space type mapping for the VFD diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h index 600cae1..b21ecca 100644 --- a/src/H5FDprivate.h +++ b/src/H5FDprivate.h @@ -134,6 +134,7 @@ H5_DLL herr_t H5FD_set_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t addr); H5_DLL haddr_t H5FD_get_eof(const H5FD_t *file); H5_DLL haddr_t H5FD_get_maxaddr(const H5FD_t *file); H5_DLL herr_t H5FD_get_feature_flags(const H5FD_t *file, unsigned long *feature_flags); +H5_DLL herr_t H5FD_set_feature_flags(H5FD_t *file, unsigned long feature_flags); H5_DLL herr_t H5FD_get_fs_type_map(const H5FD_t *file, H5FD_mem_t *type_map); H5_DLL herr_t H5FD_read(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/); diff --git a/src/H5FScache.c b/src/H5FScache.c index 9e93fdf..c3511ac 100644 --- a/src/H5FScache.c +++ b/src/H5FScache.c @@ -183,7 +183,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, addr, fspace->hdr_size, fspace->hdr_size, dxpl_id, hdr, &computed_chksum) < 0) + 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) HGOTO_ERROR(H5E_FSPACE, H5E_BADVALUE, NULL, "incorrect metadata checksum for free space header") p = hdr; @@ -575,7 +575,7 @@ H5FS_cache_sinfo_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Read and validate free space sections from disk */ - if(H5F_read_check_metadata(f, H5FD_MEM_FSPACE_SINFO, 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, 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) HGOTO_ERROR(H5E_FSPACE, H5E_BADVALUE, NULL, "incorrect metadata checksum for free space sections") /* Deserialize free sections from buffer available */ diff --git a/src/H5Fio.c b/src/H5Fio.c index bd8c39a..6c87284 100644 --- a/src/H5Fio.c +++ b/src/H5Fio.c @@ -291,9 +291,11 @@ H5F_get_checksums(uint8_t *buf, size_t chk_size, uint32_t *s_chksum/*out*/, uint * 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 + * 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 + * H5F_track_metadata_read_retries() * * Return: Non-negative on success/Negative on failure * @@ -302,13 +304,14 @@ H5F_get_checksums(uint8_t *buf, size_t chk_size, uint32_t *s_chksum/*out*/, uint *------------------------------------------------------------------------- */ herr_t -H5F_read_check_metadata(const H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t read_size, size_t chk_size, +H5F_read_check_metadata(H5F_t *f, H5FD_mem_t type, H5AC_type_t actype, haddr_t addr, size_t read_size, size_t chk_size, hid_t dxpl_id, uint8_t *buf/*out*/, uint32_t *chksum/*out*/) { - size_t tries, max_tries; + size_t tries, max_tries; /* The # of read attempts */ + size_t retries; /* The # of retries */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -332,8 +335,14 @@ H5F_read_check_metadata(const H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t re 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) - else if((max_tries - tries + 1) > 1) - HDfprintf(stderr, "%s: SUCCESS after %u attempts; type=%u\n", FUNC, max_tries - tries + 1, type); + + /* 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(H5F_track_metadata_read_retries(f, actype, retries) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "cannot track read tries = %u ", retries) + } /* Return the computed checksum */ if(chksum) diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index b8d623a..c4f7c02 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -275,6 +275,8 @@ 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 5f81cb7..cac34b7 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -462,7 +462,7 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; #define H5F_ACS_MULTI_TYPE_NAME "multi_type" /* Data type in multi file driver */ #define H5F_ACS_LATEST_FORMAT_NAME "latest_format" /* 'Use latest format version' flag */ #define H5F_ACS_WANT_POSIX_FD_NAME "want_posix_fd" /* Internal: query the file descriptor from the core VFD, instead of the memory address */ -#define H5F_ACS_READ_ATTEMPTS_NAME "read_attempts" /* # of read attempts */ +#define H5F_ACS_METADATA_READ_ATTEMPTS_NAME "metadata_read_attempts" /* # of metadata read attempts */ #define H5F_ACS_EFC_SIZE_NAME "efc_size" /* Size of external file cache */ #define H5F_ACS_FILE_IMAGE_INFO_NAME "file_image_info" /* struct containing initial file image and callback info */ @@ -507,8 +507,8 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; #define H5_SIZEOF_CHKSUM 4 -#define H5F_READ_ATTEMPTS 1 /* Default # of read attempts for non-swmr access */ -#define H5F_SWMR_READ_ATTEMPTS 100 /* Default # of read attempts for swmr access */ +#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" @@ -639,9 +639,11 @@ 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(const H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t read_size, size_t chk_size, +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); +/* Routine to track the # of retries */ +H5_DLL herr_t H5F_track_metadata_read_retries(H5F_t *f, unsigned actype, unsigned retries); /* Address-related functions */ H5_DLL void H5F_addr_encode(const H5F_t *f, uint8_t **pp, haddr_t addr); diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h index b0907e0..b2c1b6b 100644 --- a/src/H5Fpublic.h +++ b/src/H5Fpublic.h @@ -185,6 +185,13 @@ typedef enum H5F_file_space_type_t { H5F_FILE_SPACE_NTYPES /* must be last */ } 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 { + unsigned nbins; + uint32_t *retries[NUM_METADATA_READ_RETRIES]; +} H5F_retries_info_t; #ifdef __cplusplus extern "C" { @@ -223,6 +230,7 @@ H5_DLL herr_t H5Fget_mdc_size(hid_t file_id, H5_DLL herr_t H5Freset_mdc_hit_rate_stats(hid_t file_id); H5_DLL ssize_t H5Fget_name(hid_t obj_id, char *name, size_t size); H5_DLL herr_t H5Fget_info2(hid_t obj_id, H5F_info2_t *finfo); +H5_DLL herr_t H5Fget_metadata_read_retries_info(hid_t file_id, H5F_retries_info_t *info); H5_DLL 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/H5Fsuper_cache.c b/src/H5Fsuper_cache.c index 3d906c7..4216bbe 100644 --- a/src/H5Fsuper_cache.c +++ b/src/H5Fsuper_cache.c @@ -127,9 +127,10 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata) 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 */ size_t tries, max_tries; /* The # of read attempts to try */ - size_t fixed_tries; /* The # of read attempts to try */ + size_t fixed_tries; /* The # of read attempts to try for the fixed-size portion */ + size_t 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 */ @@ -240,8 +241,13 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata) 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") - else if((max_tries - tries + 1) > 1) - HDfprintf(stderr, "%s: SUCCESS after %u attempts\n", FUNC, max_tries - tries + 1); + + 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_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) { diff --git a/src/H5HFcache.c b/src/H5HFcache.c index 2b098be..c91ef1b 100644 --- a/src/H5HFcache.c +++ b/src/H5HFcache.c @@ -408,7 +408,8 @@ H5HF_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ size_t tries, max_tries; /* The # of read attempts */ - size_t fixed_tries; + size_t fixed_tries; /* The # of read attempts for the minimum portion */ + size_t retries; /* The # of retries */ H5HF_hdr_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -488,8 +489,14 @@ H5HF_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) if(tries == 0) HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, NULL, "incorrect metadata checksum after all tries (%u) for fractal heap header", max_tries) - else if((max_tries - tries + 1) > 1) - HDfprintf(stderr, "%s: SUCCESS after %u attempts\n", FUNC, max_tries - tries + 1); + + /* 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) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "cannot track read tries = %u ", retries) + } p = buf; @@ -845,7 +852,7 @@ 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, addr, iblock->size, iblock->size, dxpl_id, buf, &computed_chksum) < 0) + 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") /* Get temporary pointer to serialized indirect block */ @@ -1308,6 +1315,7 @@ H5HF_cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) uint32_t computed_chksum; /* Computed metadata checksum value */ uint32_t stored_chksum; /* Metadata checksum value */ size_t tries, max_tries; /* The # of read attempts */ + size_t 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 */ @@ -1431,8 +1439,14 @@ H5HF_cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) if(tries == 0) HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, NULL, "incorrect metadata checksum after all tries (%u) for fractal heap direct block", max_tries) - else if((max_tries - tries + 1) > 1) - HDfprintf(stderr, "%s: SUCCESS after %u attempts\n", FUNC, max_tries - tries + 1); + + /* 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(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; diff --git a/src/H5Ocache.c b/src/H5Ocache.c index 3a087e5..35d7f44 100644 --- a/src/H5Ocache.c +++ b/src/H5Ocache.c @@ -319,6 +319,7 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) size_t buf_size; /* Size of prefix+chunk #0 buffer */ haddr_t eoa; /* Relative end of file address */ size_t tries, max_tries; /* The # of read attempts */ + size_t retries; /* The # of retries */ size_t fixed_tries; /* The # of read attempts for prefix */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ @@ -420,8 +421,14 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) if(tries == 0) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "incorrect metadata checksum for object header chunk after all read tries (%u) for %u bytes", max_tries, buf_size) - else if((max_tries - tries + 1) > 1) - HDfprintf(stderr, "%s: SUCCESS after %u attempts\n", FUNC, max_tries - tries + 1); + + /* 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(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); @@ -818,7 +825,7 @@ 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, addr, udata->size, udata->size, dxpl_id, buf, NULL) < 0) + if(H5F_read_check_metadata(f, H5FD_MEM_OHDR, H5AC_OHDR_CHK_ID, addr, udata->size, udata->size, dxpl_id, buf, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "incorrect metadata checksum for object header continuation chunk") } else { /* Read the header object continuation chunk */ diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index adae24f..269f064 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -160,11 +160,11 @@ #define H5F_ACS_FILE_IMAGE_INFO_DEL H5P_file_image_info_del #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 read attempts */ -#define H5F_ACS_READ_ATTEMPTS_SIZE sizeof(unsigned) -#define H5F_ACS_READ_ATTEMPTS_DEF 0 -#define H5F_ACS_READ_ATTEMPTS_ENC H5P__encode_unsigned -#define H5F_ACS_READ_ATTEMPTS_DEC H5P__decode_unsigned +/* 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 /******************/ /* Local Typedefs */ @@ -251,7 +251,7 @@ static const hbool_t H5F_def_latest_format_g = H5F_ACS_LATEST_FORMAT_DEF; static const hbool_t H5F_def_want_posix_fd_g = H5F_ACS_WANT_POSIX_FD_DEF; /* Default setting for retrieving 'handle' from core VFD */ static const unsigned H5F_def_efc_size_g = H5F_ACS_EFC_SIZE_DEF; /* Default external file cache size */ static const H5FD_file_image_info_t H5F_def_file_image_info_g = H5F_ACS_FILE_IMAGE_INFO_DEF; /* Default file image info and callbacks */ -static const unsigned H5F_def_read_attempts_g = H5F_ACS_READ_ATTEMPTS_DEF; /* Default setting for the # of read attempts */ +static const unsigned H5F_def_metadata_read_attempts_g = H5F_ACS_METADATA_READ_ATTEMPTS_DEF; /* Default setting for the # of metadata read attempts */ /*------------------------------------------------------------------------- @@ -402,8 +402,8 @@ H5P_facc_reg_prop(H5P_genclass_t *pclass) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the # of read attempts */ - if(H5P_register_real(pclass, H5F_ACS_READ_ATTEMPTS_NAME, H5F_ACS_READ_ATTEMPTS_SIZE, &H5F_def_read_attempts_g, - NULL, NULL, NULL, H5F_ACS_READ_ATTEMPTS_ENC, H5F_ACS_READ_ATTEMPTS_DEC, + if(H5P_register_real(pclass, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, H5F_ACS_METADATA_READ_ATTEMPTS_SIZE, &H5F_def_metadata_read_attempts_g, + 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: @@ -2991,13 +2991,15 @@ H5P__facc_multi_type_dec(const void **_pp, void *_value) /*------------------------------------------------------------------------- - * Function: H5Pset_read_attempts + * Function: H5Pset_metadata_read_attempts * * Purpose: Sets the # of read attempts in the file access property list * when reading metadata with checksum. - * The # of read attempts set via this routine will apply only - * when opening file with SWMR access. When opening file with - * non-SWMR access, the # of read attempts will always be 1. + * The # of read attempts set via this routine will only apply + * when opening a file with SWMR access. + * The # of read attempts set via this routine does not have + * any effect when opening a file with non-SWMR access; for this + * case, the # of read attempts will be always be 1. * * Return: Non-negative on success/Negative on failure * @@ -3006,7 +3008,7 @@ H5P__facc_multi_type_dec(const void **_pp, void *_value) *------------------------------------------------------------------------- */ herr_t -H5Pset_read_attempts(hid_t plist_id, unsigned attempts) +H5Pset_metadata_read_attempts(hid_t plist_id, unsigned attempts) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value = SUCCEED; /* return value */ @@ -3016,25 +3018,25 @@ H5Pset_read_attempts(hid_t plist_id, unsigned attempts) /* Cannot set the # of attempts to 0 */ if(attempts <= 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "number of attempts must be greater than 0"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "number of metadatata read attempts must be greater than 0"); /* 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") /* Set values */ - if(H5P_set(plist, H5F_ACS_READ_ATTEMPTS_NAME, &attempts) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set # of read attempts") + if(H5P_set(plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, &attempts) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set # of metadata read attempts") done: FUNC_LEAVE_API(ret_value) -} /* H5Pset_read_attempts() */ +} /* H5Pset_metadata_read_attempts() */ /*------------------------------------------------------------------------- - * Function: H5Pget_read_attempts + * Function: H5Pget_metadata_read_attempts * - * Purpose: Returns the # of read attempts set in the file access property list. + * Purpose: Returns the # of metadata read attempts set in the file access property list. * * Return: Non-negative on success/Negative on failure * @@ -3043,7 +3045,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_read_attempts(hid_t plist_id, unsigned *attempts/*out*/) +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 */ @@ -3058,13 +3060,13 @@ H5Pget_read_attempts(hid_t plist_id, unsigned *attempts/*out*/) /* Get values */ if(attempts) { /* Get the # of read attempts set */ - if(H5P_get(plist, H5F_ACS_READ_ATTEMPTS_NAME, attempts) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get alignment") + 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_READ_ATTEMPTS_DEF) /* 0 */ - *attempts = H5F_READ_ATTEMPTS; + if(*attempts == H5F_ACS_METADATA_READ_ATTEMPTS_DEF) /* 0 */ + *attempts = H5F_METADATA_READ_ATTEMPTS; } done: FUNC_LEAVE_API(ret_value) -} /* end H5Pget_read_attempts() */ +} /* end H5Pget_metadata_read_attempts() */ diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index f2b9e8f..5caedf6 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -344,8 +344,8 @@ H5_DLL herr_t H5Pset_file_image_callbacks(hid_t fapl_id, H5FD_file_image_callbacks_t *callbacks_ptr); H5_DLL herr_t H5Pget_file_image_callbacks(hid_t fapl_id, H5FD_file_image_callbacks_t *callbacks_ptr); -H5_DLL herr_t H5Pset_read_attempts(hid_t plist_id, unsigned attempts); -H5_DLL herr_t H5Pget_read_attempts(hid_t plist_id, unsigned *attempts/*out*/); +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*/); /* Dataset creation property list (DCPL) routines */ H5_DLL herr_t H5Pset_layout(hid_t plist_id, H5D_layout_t layout); diff --git a/src/H5SMcache.c b/src/H5SMcache.c index c5b333f..b01fcdc 100644 --- a/src/H5SMcache.c +++ b/src/H5SMcache.c @@ -159,7 +159,7 @@ H5SM_table_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void UNUSED *udata) HGOTO_ERROR(H5E_SOHM, H5E_NOSPACE, NULL, "can't get actual buffer") /* Read and validate shared message table from disk */ - if(H5F_read_check_metadata(f, H5FD_MEM_SOHM_TABLE, addr, table->table_size, table->table_size, dxpl_id, buf, &computed_chksum) < 0) + 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) HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, NULL, "incorrect metadata checksum for shared message table") /* Get temporary pointer to serialized table */ @@ -494,7 +494,7 @@ 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, addr, udata->header->list_size, chk_size, dxpl_id, buf, &computed_chksum) < 0) + 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) HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, NULL, "incorrect metadata checksum for shared message list") diff --git a/test/swmr_common.c b/test/swmr_common.c index cdac4c9..651e88e 100644 --- a/test/swmr_common.c +++ b/test/swmr_common.c @@ -240,3 +240,50 @@ shutdown_symbols(void) return 0; } /* end shutdown_symbols() */ + + +/*------------------------------------------------------------------------- + * Function: print_metadata_retries_info + * + * Purpose: To retrieve and print the collection of metadata retries for the file. + * + * Parameters: fid: the currently opened file identifier + * + * Return: Success: 0 + * Failure: negative + * + *------------------------------------------------------------------------- + */ +int +print_metadata_retries_info(hid_t fid) +{ + H5F_retries_info_t info; + unsigned power; + unsigned i, j; + + /* Retrieve the collection of retries */ + if(H5Fget_metadata_read_retries_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) + continue; + + fprintf(stderr, "Metadata read retries for item %u:\n", i); + power = 1; + for(j = 0; j < info.nbins; j++) { + if(info.retries[i][j]) + fprintf(stderr, "\t# of retries for %u - %u retries: %u\n", + power, (power * 10) - 1, info.retries[i][j]); + power *= 10; + } + } + + /* Free memory for each non-NULL retries[i] */ + for(i = 0; i < NUM_METADATA_READ_RETRIES; i++) { + if(info.retries[i] != NULL) + free(info.retries[i]); + } + return 0; +} /* print_metadata_retries_info() */ diff --git a/test/swmr_common.h b/test/swmr_common.h index 83491ee..b80ad12 100644 --- a/test/swmr_common.h +++ b/test/swmr_common.h @@ -75,5 +75,6 @@ hid_t create_symbol_datatype(void); int generate_name(char *name_buf, unsigned level, unsigned count); int generate_symbols(void); int shutdown_symbols(void); +int print_metadata_retries_info(hid_t fid); #endif /* _SWMR_COMMON_H */ diff --git a/test/swmr_sparse_reader.c b/test/swmr_sparse_reader.c index ab34d97..9cccef1 100644 --- a/test/swmr_sparse_reader.c +++ b/test/swmr_sparse_reader.c @@ -267,6 +267,10 @@ read_records(const char *filename, unsigned verbose, unsigned long nrecords, /* Pause */ sleep(poll_time); + /* 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"); + /* Reopen the file */ if(H5Fclose(fid) < 0) return -1; @@ -291,6 +295,10 @@ read_records(const char *filename, unsigned verbose, unsigned long nrecords, if(verbose) fprintf(stderr, "Reopening file: %s\n", filename); + /* 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"); + /* Reopen the file */ if(H5Fclose(fid) < 0) return -1; @@ -300,6 +308,11 @@ 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/testfiles/plist_files/fapl_be b/test/testfiles/plist_files/fapl_be index 24e944c..060dfc4 100644 Binary files a/test/testfiles/plist_files/fapl_be and b/test/testfiles/plist_files/fapl_be differ diff --git a/test/testfiles/plist_files/fapl_le b/test/testfiles/plist_files/fapl_le index 24e944c..060dfc4 100644 Binary files a/test/testfiles/plist_files/fapl_le and b/test/testfiles/plist_files/fapl_le differ diff --git a/test/testfiles/plist_files/lapl_be b/test/testfiles/plist_files/lapl_be index 2ab61ed..ff487fb 100644 Binary files a/test/testfiles/plist_files/lapl_be and b/test/testfiles/plist_files/lapl_be differ diff --git a/test/testfiles/plist_files/lapl_le b/test/testfiles/plist_files/lapl_le index 2ab61ed..ff487fb 100644 Binary files a/test/testfiles/plist_files/lapl_le and b/test/testfiles/plist_files/lapl_le differ diff --git a/test/tfile.c b/test/tfile.c index 200279c..65ae0bc 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -27,6 +27,7 @@ #include "H5Bprivate.h" #include "H5Pprivate.h" +#include "H5Iprivate.h" /* * This file needs to access private information from the H5F package. @@ -3566,13 +3567,15 @@ test_swmr_read(void) /**************************************************************** ** -** test_read_attempts(): -** This test checks whether the public routines H5Pset_read_attempts() -** and H5Pget_read_attempts() work properly. +** test_metadata_read_attempts(): +** This test checks whether the following two public routines work as +** specified in the reference manuals: +** H5Pset_metadata_read_attempts() +** H5Pget_metadata_read_attempts() ** *****************************************************************/ static void -test_read_attempts(void) +test_metadata_read_attempts(void) { hid_t fapl; /* File access property list */ hid_t file_fapl; /* The file's access property list */ @@ -3581,7 +3584,7 @@ test_read_attempts(void) herr_t ret; /* Generic return value */ /* Output message about test being performed */ - MESSAGE(5, ("Testing H5Fget/set_read_attempts()\n")); + MESSAGE(5, ("Testing H5Pget/set_metadata_read_attempts()\n")); /* * Set A: @@ -3594,40 +3597,40 @@ test_read_attempts(void) CHECK(fapl, FAIL, "H5Pcreate"); /* Get # of read attempts -- should be the default: 1 */ - ret = H5Pget_read_attempts(fapl, &attempts); - CHECK(ret, FAIL, "H5Pget_read_attempts"); - VERIFY(attempts, 1, "H5Pget_read_attempts"); + ret = H5Pget_metadata_read_attempts(fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_metadata_read_attempts"); + VERIFY(attempts, 1, "H5Pget_metadata_read_attempts"); /* Set the # of read attempts to 0--should fail */ - ret = H5Pset_read_attempts(fapl, 0); - VERIFY(ret, FAIL, "H5Pset_read_attempts"); + ret = H5Pset_metadata_read_attempts(fapl, 0); + VERIFY(ret, FAIL, "H5Pset_metadata_read_attempts"); /* Set the # of read attempts to a # > 0--should succeed */ - ret = H5Pset_read_attempts(fapl, 9); - VERIFY(ret, 0, "H5Pset_read_attempts"); + ret = H5Pset_metadata_read_attempts(fapl, 9); + VERIFY(ret, 0, "H5Pset_metadata_read_attempts"); - /* Retrieve the # of read attempts -- should succeed and equal to 9 */ - ret = H5Pget_read_attempts(fapl, &attempts); - CHECK(ret, FAIL, "H5Pget_read_attempts"); - VERIFY(attempts, 9, "H5Pget_read_attempts"); + /* Retrieve the # of read attempts -- should be 9 */ + ret = H5Pget_metadata_read_attempts(fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_metadata_read_attempts"); + VERIFY(attempts, 9, "H5Pget_metadata_read_attempts"); - /* Set the # of read attempts to the non-SWMR access default: H5F_READ_ATTEMPTS --should succeed */ - ret = H5Pset_read_attempts(fapl, H5F_READ_ATTEMPTS); - CHECK(ret, FAIL, "H5Pget_read_attempts"); + /* Set the # of read attempts to the default for non-SWMR access: H5F_METADATA_READ_ATTEMPTS --should succeed */ + ret = H5Pset_metadata_read_attempts(fapl, H5F_METADATA_READ_ATTEMPTS); + CHECK(ret, FAIL, "H5Pget_metadata_read_attempts"); - /* Retrieve the # of read attempts -- should succeed and equal to H5F_READ_ATTEMPTS */ - ret = H5Pget_read_attempts(fapl, &attempts); - CHECK(ret, FAIL, "H5Pget_read_attempts"); - VERIFY(attempts, H5F_READ_ATTEMPTS, "H5Pget_read_attempts"); + /* Retrieve the # of read attempts -- should be H5F_METADATA_READ_ATTEMPTS */ + ret = H5Pget_metadata_read_attempts(fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_metadata_read_attempts"); + VERIFY(attempts, H5F_METADATA_READ_ATTEMPTS, "H5Pget_metadata_read_attempts"); - /* Set the # of read attempts to the SWMR access default: H5F_SWMR_READ_ATEMPTS --should succeed */ - ret = H5Pset_read_attempts(fapl, H5F_SWMR_READ_ATTEMPTS); - VERIFY(ret, 0, "H5Pset_read_attempts"); + /* Set the # of read attempts to the default for SWMR access: H5F_SWMR_METADATA_READ_ATEMPTS --should succeed */ + ret = H5Pset_metadata_read_attempts(fapl, H5F_SWMR_METADATA_READ_ATTEMPTS); + VERIFY(ret, 0, "H5Pset_metadata_read_attempts"); - /* Retrieve the # of read attempts -- should succeed and equal to H5F_SWMR_READ_ATTEMPTS */ - ret = H5Pget_read_attempts(fapl, &attempts); - CHECK(ret, FAIL, "H5Pget_read_attempts"); - VERIFY(attempts, H5F_SWMR_READ_ATTEMPTS, "H5Pget_read_attempts"); + /* Retrieve the # of read attempts -- should be H5F_SWMR_METADATA_READ_ATTEMPTS */ + ret = H5Pget_metadata_read_attempts(fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_metadata_read_attempts"); + VERIFY(attempts, H5F_SWMR_METADATA_READ_ATTEMPTS, "H5Pget_metadata_read_attempts"); ret = H5Pclose(fapl); CHECK(ret, FAIL, "H5Pclose"); @@ -3648,10 +3651,10 @@ test_read_attempts(void) file_fapl = H5Fget_access_plist(fid); CHECK(file_fapl, FAIL, "H5Fget_access_plist"); - /* Retrieve the # of read attempts from file's fapl -- should be H5F_READ_ATTEMPTS */ - ret = H5Pget_read_attempts(file_fapl, &attempts); - CHECK(ret, FAIL, "H5Pget_read_attempts"); - VERIFY(attempts, H5F_READ_ATTEMPTS, "H5Pget_read_attempts"); + /* Retrieve the # of read attempts from file's fapl -- should be H5F_METADATA_READ_ATTEMPTS */ + ret = H5Pget_metadata_read_attempts(file_fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_metadata_read_attempts"); + VERIFY(attempts, H5F_METADATA_READ_ATTEMPTS, "H5Pget_metadata_read_attempts"); /* Close the file */ ret=H5Fclose(fid); @@ -3670,10 +3673,10 @@ test_read_attempts(void) file_fapl = H5Fget_access_plist(fid); CHECK(file_fapl, FAIL, "H5Fget_access_plist"); - /* Retrieve the # of read attempts from file's fapl -- should be H5F_SWMR_READ_ATTEMPTS */ - ret = H5Pget_read_attempts(file_fapl, &attempts); - CHECK(ret, FAIL, "H5Pget_read_attempts"); - VERIFY(attempts, H5F_SWMR_READ_ATTEMPTS, "H5Fget_read_attempts"); + /* Retrieve the # of read attempts from file's 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"); /* Close the file */ ret=H5Fclose(fid); @@ -3689,8 +3692,8 @@ test_read_attempts(void) CHECK(fapl, FAIL, "H5Pcreate"); /* Set the # of read attempts */ - ret = H5Pset_read_attempts(fapl, 9); - CHECK(ret, FAIL, "H5Pset_read_attempts"); + 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) */ fid = H5Fopen(FILE1, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl); @@ -3701,9 +3704,9 @@ test_read_attempts(void) CHECK(file_fapl, FAIL, "H5Fget_access_plist"); /* Retrieve the # of read attempts from file's fapl -- should be 9 */ - ret = H5Pget_read_attempts(file_fapl, &attempts); - CHECK(ret, FAIL, "H5Pget_read_attempts"); - VERIFY(attempts, 9, "H5Pget_read_attempts"); + ret = H5Pget_metadata_read_attempts(file_fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_metadata_read_attempts"); + VERIFY(attempts, 9, "H5Pget_metadata_read_attempts"); /* Close the file */ ret=H5Fclose(fid); @@ -3719,8 +3722,8 @@ test_read_attempts(void) CHECK(fapl, FAIL, "H5Pcreate"); /* Set the # of read attempts */ - ret = H5Pset_read_attempts(fapl, 1); - CHECK(ret, FAIL, "H5Pset_read_attempts"); + 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) */ fid = H5Fopen(FILE1, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl); @@ -3730,10 +3733,10 @@ test_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 succeed and equal to 1 */ - ret = H5Pget_read_attempts(file_fapl, &attempts); - CHECK(ret, FAIL, "H5Pget_read_attempts"); - VERIFY(attempts, 1, "H5Pget_read_attempts"); + /* Retrieve the # of read attempts from file fapl -- should be 1 */ + ret = H5Pget_metadata_read_attempts(file_fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_metadata_read_attempts"); + VERIFY(attempts, 1, "H5Pget_metadata_read_attempts"); /* Close the file */ ret=H5Fclose(fid); @@ -3756,10 +3759,10 @@ test_read_attempts(void) file_fapl = H5Fget_access_plist(fid); CHECK(file_fapl, FAIL, "H5Fget_access_plist"); - /* Retrieve the # of read attempts from file's fapl -- should be H5F_SWMR_READ_ATTEMPTS */ - ret = H5Pget_read_attempts(file_fapl, &attempts); - CHECK(ret, FAIL, "H5Pget_read_attempts"); - VERIFY(attempts, H5F_SWMR_READ_ATTEMPTS, "H5Pget_read_attempts"); + /* Retrieve the # of read attempts from file's 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, "H5Pget_metadata_read_attempts"); /* Close the file */ ret=H5Fclose(fid); @@ -3785,10 +3788,10 @@ test_read_attempts(void) file_fapl = H5Fget_access_plist(fid); CHECK(file_fapl, FAIL, "H5Fget_access_plist"); - /* Retrieve the # of read attempts from file's fapl -- should be H5F_SWMR_READ_ATTEMPTS */ - ret = H5Pget_read_attempts(file_fapl, &attempts); - CHECK(ret, FAIL, "H5Pget_read_attempts"); - VERIFY(attempts, H5F_SWMR_READ_ATTEMPTS, "H5Pget_read_attempts"); + /* Retrieve the # of read attempts from file's 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, "H5Pget_metadata_read_attempts"); /* Close the file */ ret=H5Fclose(fid); @@ -3807,10 +3810,10 @@ test_read_attempts(void) file_fapl = H5Fget_access_plist(fid); CHECK(file_fapl, FAIL, "H5Fget_access_plist"); - /* Retrieve the # of read attempts from file's fapl -- should be H5F_READ_ATTEMPTS */ - ret = H5Pget_read_attempts(file_fapl, &attempts); - CHECK(ret, FAIL, "H5Pget_read_attempts"); - VERIFY(attempts, H5F_READ_ATTEMPTS, "H5Pget_read_attempts"); + /* Retrieve the # of read attempts from file's fapl -- should be H5F_METADATA_READ_ATTEMPTS */ + ret = H5Pget_metadata_read_attempts(file_fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_metadata_read_attempts"); + VERIFY(attempts, H5F_METADATA_READ_ATTEMPTS, "H5Pget_metadata_read_attempts"); /* Close the file */ ret=H5Fclose(fid); @@ -3826,8 +3829,8 @@ test_read_attempts(void) CHECK(fapl, FAIL, "H5Pcreate"); /* Set the # of read attempts */ - ret = H5Pset_read_attempts(fapl, 9); - CHECK(ret, FAIL, "H5Pset_read_attempts"); + 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) */ fid = H5Fopen(FILE1, H5F_ACC_RDONLY, fapl); @@ -3837,10 +3840,10 @@ test_read_attempts(void) file_fapl = H5Fget_access_plist(fid); CHECK(file_fapl, FAIL, "H5Fget_access_plist"); - /* Retrieve the # of read attempts from file's fapl -- should be H5F_READ_ATTEMPTS */ - ret = H5Pget_read_attempts(file_fapl, &attempts); - CHECK(ret, FAIL, "H5Pget_read_attempts"); - VERIFY(attempts, H5F_READ_ATTEMPTS, "H5Pget_read_attempts"); + /* Retrieve the # of read attempts from file's fapl -- should be H5F_METADATA_READ_ATTEMPTS */ + ret = H5Pget_metadata_read_attempts(file_fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_metadata_read_attempts"); + VERIFY(attempts, H5F_METADATA_READ_ATTEMPTS, "H5Pget_metadata_read_attempts"); /* Close the file */ ret=H5Fclose(fid); @@ -3856,8 +3859,8 @@ test_read_attempts(void) CHECK(fapl, FAIL, "H5Pcreate"); /* Set the # of read attempts */ - ret = H5Pset_read_attempts(fapl, 1); - CHECK(ret, FAIL, "H5Pset_read_attempts"); + 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) */ fid = H5Fopen(FILE1, H5F_ACC_RDONLY, fapl); @@ -3867,10 +3870,10 @@ test_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 succeed and equal to 1 */ - ret = H5Pget_read_attempts(file_fapl, &attempts); - CHECK(ret, FAIL, "H5Pget_read_attempts"); - VERIFY(attempts, 1, "H5Fget_read_attempts"); + /* Retrieve the # of read attempts from file fapl -- should be 1 */ + ret = H5Pget_metadata_read_attempts(file_fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_metadata_read_attempts"); + VERIFY(attempts, 1, "H5Fget_metadata_read_attempts"); /* Close the file */ ret=H5Fclose(fid); @@ -3893,10 +3896,10 @@ test_read_attempts(void) file_fapl = H5Fget_access_plist(fid); CHECK(file_fapl, FAIL, "H5Pget_access_plist"); - /* Retrieve the # of read attempts from file's fapl -- should be H5F_READ_ATTEMPTS */ - ret = H5Pget_read_attempts(file_fapl, &attempts); - CHECK(ret, FAIL, "H5Pget_read_attempts"); - VERIFY(attempts, H5F_READ_ATTEMPTS, "H5Fget_read_attempts"); + /* Retrieve the # of read attempts from file's fapl -- should be H5F_METADATA_READ_ATTEMPTS */ + ret = H5Pget_metadata_read_attempts(file_fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_metadata_read_attempts"); + VERIFY(attempts, H5F_METADATA_READ_ATTEMPTS, "H5Fget_metadata_read_attempts"); /* Close the file */ ret=H5Fclose(fid); @@ -3907,15 +3910,13 @@ test_read_attempts(void) CHECK(ret, FAIL, "H5Pclose"); - - /* Create a copy of file access property list */ fapl = H5Pcreate(H5P_FILE_ACCESS); CHECK(fapl, FAIL, "H5Pcreate"); /* Set the # of read attempts */ - ret = H5Pset_read_attempts(fapl, 9); - CHECK(ret, FAIL, "H5Pset_read_attempts"); + ret = H5Pset_metadata_read_attempts(fapl, 9); + CHECK(ret, FAIL, "H5Pset_metadata_read_attempts"); /* Create a file */ fid = H5Fcreate(FILE1, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl); @@ -3933,10 +3934,10 @@ test_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 H5F_READ_ATTEMPTS */ - ret = H5Pget_read_attempts(file_fapl, &attempts); - CHECK(ret, FAIL, "H5Pget_read_attempts"); - VERIFY(attempts, H5F_READ_ATTEMPTS, "H5Pget_read_attempts"); + /* Retrieve the # of read attempts from file fapl -- should be H5F_METADATA_READ_ATTEMPTS */ + ret = H5Pget_metadata_read_attempts(file_fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_metadata_read_attempts"); + VERIFY(attempts, H5F_METADATA_READ_ATTEMPTS, "H5Pget_metadata_read_attempts"); /* Close the file's fapl */ ret = H5Pclose(file_fapl); @@ -3954,10 +3955,10 @@ test_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 H5F_SWMR_READ_ATTEMPTS */ - ret = H5Pget_read_attempts(file_fapl, &attempts); - CHECK(ret, FAIL, "H5Pget_read_attempts"); - VERIFY(attempts, H5F_SWMR_READ_ATTEMPTS, "H5Pget_read_attempts"); + /* 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, "H5Pget_metadata_read_attempts"); /* Close the file's fapl */ ret = H5Pclose(file_fapl); @@ -3992,8 +3993,8 @@ test_read_attempts(void) CHECK(fapl, FAIL, "H5Pcreate"); /* Set the # of read attempts */ - ret = H5Pset_read_attempts(fapl, 9); - CHECK(ret, FAIL, "H5Pset_read_attempts"); + ret = H5Pset_metadata_read_attempts(fapl, 9); + CHECK(ret, FAIL, "H5Pset_metadata_read_attempts"); /* Open file again with SWMR access and fapl (non-default & set to 9) */ fid2 = H5Fopen(FILE1, (H5F_ACC_RDONLY | H5F_ACC_SWMR_READ), fapl); @@ -4007,10 +4008,10 @@ test_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 H5F_SWMR_READ_ATTEMPTS */ - ret = H5Pget_read_attempts(file_fapl, &attempts); - CHECK(ret, FAIL, "H5Pget_read_attempts"); - VERIFY(attempts, H5F_SWMR_READ_ATTEMPTS, "H5Fget_read_attempts"); + /* 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"); /* Close the file's fapl */ ret = H5Pclose(file_fapl); @@ -4029,9 +4030,9 @@ test_read_attempts(void) CHECK(file_fapl, FAIL, "H5Fget_access_plist"); /* Retrieve the # of read attempts from file fapl -- should be 9 */ - ret = H5Pget_read_attempts(file_fapl, &attempts); - CHECK(ret, FAIL, "H5Pget_read_attempts"); - VERIFY(attempts, 9, "H5Pget_read_attempts"); + ret = H5Pget_metadata_read_attempts(file_fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_metadata_read_attempts"); + VERIFY(attempts, 9, "H5Pget_metadata_read_attempts"); /* Close the file's fapl */ ret = H5Pclose(file_fapl); @@ -4072,8 +4073,8 @@ test_read_attempts(void) CHECK(fapl, FAIL, "H5Pcreate"); /* Set the # of read attempts */ - ret = H5Pset_read_attempts(fapl, 9); - CHECK(ret, FAIL, "H5Pset_read_attempts"); + ret = H5Pset_metadata_read_attempts(fapl, 9); + CHECK(ret, FAIL, "H5Pset_metadata_read_attempts"); /* Open file again with non-SWMR access and fapl (non-default & set to 9) */ fid2 = H5Fopen(FILE1, H5F_ACC_RDONLY, fapl); @@ -4086,10 +4087,10 @@ test_read_attempts(void) /* Get file's fapl */ file_fapl = H5Fget_access_plist(fid); CHECK(file_fapl, FAIL, "H5Fget_access_plist"); - /* Retrieve the # of read attempts from file fapl -- should be H5F_READ_ATTEMPTS */ - ret = H5Pget_read_attempts(file_fapl, &attempts); - CHECK(ret, FAIL, "H5Pget_read_attempts"); - VERIFY(attempts, H5F_READ_ATTEMPTS, "H5Fget_read_attempts"); + /* Retrieve the # of read attempts from file fapl -- should be H5F_METADATA_READ_ATTEMPTS */ + ret = H5Pget_metadata_read_attempts(file_fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_metadata_read_attempts"); + VERIFY(attempts, H5F_METADATA_READ_ATTEMPTS, "H5Fget_metadata_read_attempts"); /* Close the file's fapl */ ret = H5Pclose(file_fapl); @@ -4107,10 +4108,10 @@ test_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 H5F_READ_ATTEMPTS */ - ret = H5Pget_read_attempts(file_fapl, &attempts); - CHECK(ret, FAIL, "H5Pget_read_attempts"); - VERIFY(attempts, H5F_READ_ATTEMPTS, "H5Pget_read_attempts"); + /* Retrieve the # of read attempts from file fapl -- should be H5F_METADATA_READ_ATTEMPTS */ + ret = H5Pget_metadata_read_attempts(file_fapl, &attempts); + CHECK(ret, FAIL, "H5Pget_metadata_read_attempts"); + VERIFY(attempts, H5F_METADATA_READ_ATTEMPTS, "H5Pget_metadata_read_attempts"); /* Close the file's fapl */ ret = H5Pclose(file_fapl); @@ -4126,8 +4127,619 @@ test_read_attempts(void) ret=H5Fclose(fid2); CHECK(ret, FAIL, "H5Fclose"); +} /* end test_metadata_read_attempts() */ + +/**************************************************************** +** +** test_metadata_read_retries_info(): +** This test checks whether the public routine H5Fget_metadata_read_retries_info +** works as specified in the reference manual. +** +*****************************************************************/ +static void +test_metadata_read_retries_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_t *f = NULL, *f1 = NULL; /* Internal file object pointers */ + unsigned i, j, n; /* Local index variables */ + herr_t ret; /* Generic return value */ + hid_t did1, did2; /* Dataset IDs */ + hid_t sid; /* Dataspace ID */ + hid_t dcpl; /* Dataset creation property list */ + hsize_t dims[2] = {6, 10}; /* Dataset dimensions */ + int buf[6][10], chkbuf1[6][10], chkbuf2[6][10]; /* Buffers for data */ + hsize_t max_dims_1un[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Dataset maximum dimensions */ + hsize_t max_dims_2un[2] = {500, H5S_UNLIMITED}; /* Dataset maximum dimensions */ + hsize_t chunk_dims[2] = {2, 2}; /* Chunk dimensions */ + + + /* Output message about test being performed */ + MESSAGE(5, ("Testing H5Fget_metadata_read_retries_info()\n")); + + /* + * Set up file for testing + */ + /* Create a copy of 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 without SWMR access */ + fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); + CHECK(fid, FAIL, "H5Fcreate"); + + /* Create a chunked dataset with 1 unlimited dimension: extensible array indexing will be used */ + sid = H5Screate_simple(2, dims, max_dims_1un); + dcpl = H5Pcreate(H5P_DATASET_CREATE); + ret = H5Pset_chunk(dcpl, 2, chunk_dims); + did1 = H5Dcreate2(fid, "DSET_1UNLIM", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); + + /* Create a chunked dataset with 2 unlimited dimension: v2 Btree indexing will be used */ + sid = H5Screate_simple(2, dims, max_dims_2un); + dcpl = H5Pcreate(H5P_DATASET_CREATE); + ret = H5Pset_chunk(dcpl, 2, chunk_dims); + did2 = H5Dcreate2(fid, "DSET_2UNLIM", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); + + /* Initialize buffer data */ + for(i = n = 0; i < 6; i++) + for(j = 0; j < 10; j++) + buf[i][j] = n++; + + /* Write to the 2 datasets */ + ret = H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + ret = H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); + + /* Closing */ + ret = H5Dclose(did1); + CHECK(ret, FAIL, "H5Dclose"); + ret = H5Dclose(did2); + CHECK(ret, FAIL, "H5Dclose"); + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + ret = H5Pclose(dcpl); + CHECK(ret, FAIL, "H5Pclose"); + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* + * Case 1: tests on nbins + */ + /* + * Open a file without SWMR access, default # of read attempts-- + * info.nbins should be 0 + * info.retries should all be NULL + */ + /* Open the file without SWMR access */ + fid = H5Fopen(FILE1, H5F_ACC_RDONLY, fapl); + CHECK(fid, FAIL, "H5Fopen"); + + /* Open the dataset */ + did1 = H5Dopen2(fid, "DSET_1UNLIM", H5P_DEFAULT); + CHECK(did1, FAIL, "H5Dopen"); + ret = H5Dread(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chkbuf1); + CHECK(ret, FAIL, "H5Dopen"); + + /* Open the dataset */ + did2 = H5Dopen2(fid, "DSET_2UNLIM", H5P_DEFAULT); + CHECK(did2, FAIL, "H5Dopen"); + ret = H5Dread(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chkbuf2); + CHECK(ret, FAIL, "H5Dopen"); + + /* Retrieve retries information */ + ret = H5Fget_metadata_read_retries_info(fid, &info); + CHECK(ret, FAIL, "H5Fget_metadata_read_retries_info"); + + /* Should be 0 */ + VERIFY(info.nbins, 0, "H5Fget_metadata_read_retries"); + + /* Should be all NULL */ + for(i = 0; i < NUM_METADATA_READ_RETRIES; i++) + VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retries"); + + /* Closing */ + ret=H5Dclose(did1); + CHECK(ret, FAIL, "H5Dclose"); + ret=H5Dclose(did2); + CHECK(ret, FAIL, "H5Dclose"); + ret=H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* + * Open a file with SWMR access, default # of read attempts-- + * info.nbins should be 2 + * info.retries should all be NULL + */ + /* Open the file with SWMR access */ + fid = H5Fopen(FILE1, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl); + CHECK(fid, FAIL, "H5Fopen"); + + /* Retrieve retries information */ + ret = H5Fget_metadata_read_retries_info(fid, &info); + CHECK(ret, FAIL, "H5Fget_metadata_read_retries_info"); + + /* Should be 2 */ + VERIFY(info.nbins, 2, "H5Fget_metadata_read_retries"); + + /* Should be all NULL */ + for(i = 0; i < NUM_METADATA_READ_RETRIES; i++) + VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retries"); + + /* Closing */ + ret=H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + + /* + * Open a file with SWMR access, # of read_attempts is 10: + * info.nbins should be 1 + * info.retries should all be NULL + */ + new_fapl = H5Pcopy(fapl); + ret = H5Pset_metadata_read_attempts(new_fapl, 10); + CHECK(ret, FAIL, "H5Pset_metadatda_read_attempts"); + + /* Open the file with SWMR access */ + 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"); + + /* Should be 1 */ + VERIFY(info.nbins, 1, "H5Fget_metadata_read_retries"); + + /* Should be all NULL */ + for(i = 0; i < NUM_METADATA_READ_RETRIES; i++) + VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retries"); + + /* Closing */ + ret=H5Pclose(new_fapl); + CHECK(ret, FAIL, "H5Pclose"); + ret=H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* + * Open a file with SWMR access, # of read attempts is 101: + * info.nbins should be 3 + * info.retries should all be NULL + */ + new_fapl = H5Pcopy(fapl); + ret = H5Pset_metadata_read_attempts(new_fapl, 101); + CHECK(ret, FAIL, "H5Pset_metadata_read_attempts"); + + /* Open the file with SWMR access */ + 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"); + + /* Should be 3 */ + VERIFY(info.nbins, 3, "H5Fget_metadata_read_retries"); + + /* Should be all NULL */ + for(i = 0; i < NUM_METADATA_READ_RETRIES; i++) + VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retries"); + + /* Closing */ + ret=H5Pclose(new_fapl); + CHECK(ret, FAIL, "H5Pclose"); + ret=H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* + * Open a file with SWMR access, # of read_attempts is 10000: + * info.nbins should be 4 + * info.retries should all be NULL + */ + new_fapl = H5Pcopy(fapl); + CHECK(new_fapl, FAIL, "H5Pcopy"); + + ret = H5Pset_metadata_read_attempts(new_fapl, 10000); + CHECK(ret, FAIL, "H5Pset_metadata_read_attempts"); + + /* Open the file with SWMR access */ + 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"); + + /* Should be 4 */ + VERIFY(info.nbins, 4, "H5Fget_metadata_read_retries"); + + /* Should be all NULL */ + for(i = 0; i < NUM_METADATA_READ_RETRIES; i++) + VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retries"); + + /* Closing */ + ret=H5Pclose(new_fapl); + CHECK(ret, FAIL, "H5Pclose"); + ret=H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* + * Open a file with SWMR access, # of read_attempts is 1: + * info.nbins should be 0 + * info.retries should all be NULL + */ + new_fapl = H5Pcopy(fapl); + CHECK(new_fapl, FAIL, "H5Pcopy"); + + ret = H5Pset_metadata_read_attempts(new_fapl, 1); + CHECK(ret, FAIL, "H5Pset_metadata_read_attempts"); + + /* Open the file with SWMR access */ + 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"); + + /* Should be 0 */ + VERIFY(info.nbins, 0, "H5Fget_metadata_read_retries"); + + /* Should be all NULL */ + for(i = 0; i < NUM_METADATA_READ_RETRIES; i++) + VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retries"); + + /* Closing */ + ret=H5Pclose(new_fapl); + CHECK(ret, FAIL, "H5Pclose"); + ret=H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + + + /* + * Case 2: tests on retries info + */ + + /* Open the file with SWMR access */ + fid = H5Fopen(FILE1, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl); + CHECK(fid, FAIL, "H5Fopen"); + + /* Open the dataset */ + did1 = H5Dopen2(fid, "DSET_1UNLIM", H5P_DEFAULT); + CHECK(did1, FAIL, "H5Dopen"); + + /* Read data from the dataset */ + ret = H5Dread(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, chkbuf1); + CHECK(ret, FAIL, "H5Dread"); + + /* Open the dataset */ + did2 = H5Dopen2(fid, "DSET_2UNLIM", H5P_DEFAULT); + CHECK(did2, FAIL, "H5Dopen"); + + /* Read data from the dataset */ + 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"); + + /* Should be 2 */ + VERIFY(info.nbins, 2, "H5Fget_metadata_read_retries"); + + /* Should be all NULL */ + for(i = 0; i < NUM_METADATA_READ_RETRIES; i++) + VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retries"); + + /* Get a pointer to the internal file object */ + f = (H5F_t *)H5I_object(fid); + CHECK(f, NULL, "H5I_object"); + + /* + * Increment 1st set of retries for metadata items: + * a) v2 B-tree leaf node--retries[4][1] + * b) Extensive array data block--retries[15][1] + * c) File's superblock--retries[20][0] + */ + + /* v2 B-tree leaf node: log retry 99 for 500 times */ + for(i = 0; i < 500; i++) { + ret = H5F_track_metadata_read_retries(f, H5AC_BT2_LEAF_ID, 99); + CHECK(ret, FAIL, "H5F_track_metadata_read_retries"); + } + + /* Extensive array data block: log retry 10 for 1000 times */ + for(i = 0; i < 1000; i++) { + ret = H5F_track_metadata_read_retries(f, H5AC_EARRAY_DBLOCK_ID, 10); + CHECK(ret, FAIL, "H5F_track_metadata_read_retries"); + } + + /* File's superblock: log retry 1 for 1 time */ + ret = H5F_track_metadata_read_retries(f, H5AC_SUPERBLOCK_ID, 1); + 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"); + + /* 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 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 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"); + + /* Free memory for info.retries */ + for(i = 0; i < NUM_METADATA_READ_RETRIES; i++) { + if(info.retries[i] != NULL) + HDfree(info.retries[i]); + } + + /* + * Increment 2nd set of retries for metadata items: + * a) Object header--retries[0][0] + * b) Extensive array datablock--retries[15][0] + * c) Fixed array header--retries[17][1] + * d) File's superblock--retries[20][0] + */ + + /* Object header: log retry 5 for 5 times */ + for(i = 0; i < 5; i++) { + ret = H5F_track_metadata_read_retries(f, H5AC_OHDR_ID, 5); + CHECK(ret, FAIL, "H5F_track_metadata_read_retries"); + } + + /* Extensive array data block: log retry 4 for 1 time */ + ret = H5F_track_metadata_read_retries(f, H5AC_EARRAY_DBLOCK_ID, 4); + + /* Fixed array header : log retry 50 for 10000 times */ + for(i = 0; i < 10000; i++) { + ret = H5F_track_metadata_read_retries(f, H5AC_FARRAY_HDR_ID, 50); + CHECK(ret, FAIL, "H5F_track_metadata_read_retries"); + } + + /* File's superblock: log retry 1 for 1 more time */ + ret = H5F_track_metadata_read_retries(f, H5AC_SUPERBLOCK_ID, 1); + 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"); + + /* + * Verify info has both previous + current retries information: + */ + for(i = 0; i < NUM_METADATA_READ_RETRIES; 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"); + 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"); + 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"); + 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"); + 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"); + break; + + default: + VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retries"); + break; + } + } + + /* Free memory for info.retries */ + for(i = 0; i < NUM_METADATA_READ_RETRIES; i++) { + if(info.retries[i] != NULL) + HDfree(info.retries[i]); + } + + /* Closing */ + ret=H5Dclose(did1); + CHECK(ret, FAIL, "H5Dclose"); + ret=H5Dclose(did2); + CHECK(ret, FAIL, "H5Dclose"); + ret=H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* Get a copy of the file access property list */ + new_fapl = H5Pcopy(fapl); + + /* Set the number of metadata read attempts to 101 */ + ret = H5Pset_metadata_read_attempts(new_fapl, 101); + + /* Open the file with SWMR access */ + fid = H5Fopen(FILE1, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, new_fapl); + CHECK(fid, FAIL, "H5Fopen"); + + /* Get a pointer to the internal file object */ + f = (H5F_t *)H5I_object(fid); + CHECK(f, NULL, "H5I_object"); + + /* File's superblock: log retry 1 for 1 time */ + 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"); + + /* Should be 3 */ + VERIFY(info.nbins, 3, "H5Fget_metadata_read_retries"); + + /* Verify retries info */ + for(i = 0; i < NUM_METADATA_READ_RETRIES; 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"); + break; + + default: + VERIFY(info.retries[i], NULL, "H5Fget_metadata_read_retries"); + break; + } + } + + /* Free memory */ + for(i = 0; i < NUM_METADATA_READ_RETRIES; i++) { + if(info.retries[i] != NULL) + HDfree(info.retries[i]); + } + + /* Closing */ + ret=H5Pclose(new_fapl); + CHECK(ret, FAIL, "H5Pclose"); + ret=H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + /* + * Case 3: Tests on retrieving the collection of retries + * when H5Fopen and H5Freopen the same file. + */ + + /* + * Open a file without SWMR access, default # of read attempts-- + * H5Freopen the same file-- + * Both files should: + * nbins should be 0 + * retries should all be NULL + */ + /* Open the file without SWMR access */ + fid = H5Fopen(FILE1, H5F_ACC_RDONLY, fapl); + CHECK(fid, FAIL, "H5Fopen"); + + /* Re-open fid */ + fid1 = H5Freopen(fid); + 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"); + + /* Retrieve retries information for fid1*/ + ret = H5Fget_metadata_read_retries_info(fid1, &info1); + CHECK(ret, FAIL, "H5Fget_metadata_read_retries_info"); + + /* Should be 0 */ + VERIFY(info.nbins, 0, "H5Fget_metadata_read_retries"); + VERIFY(info1.nbins, 0, "H5Fget_metadata_read_retries"); + + /* 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"); + } + + /* Closing */ + ret=H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + ret=H5Fclose(fid1); + CHECK(ret, FAIL, "H5Fclose"); + + /* + * Open a file with SWMR access, default # of read attempts: + * --increment retries for metadata item: fixed array data block page (retries[19][0]) + * H5Freopen the same file: + * --increment retries for metadata item: free-space sections (retries[9][1])-- + */ + /* Open the file with SWMR access */ + fid = H5Fopen(FILE1, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl); + CHECK(fid, FAIL, "H5Fopen"); + + /* Get a pointer to the internal file object for fid */ + f = (H5F_t *)H5I_object(fid); + CHECK(f, NULL, "H5I_object"); + + /* Re-open fid */ + fid1 = H5Freopen(fid); + CHECK(fid, FAIL, "H5Freopen"); + + /* Get a pointer to the internal file object for fid1 */ + f1 = (H5F_t *)H5I_object(fid1); + CHECK(f, NULL, "H5I_object"); + + /* For fid: fixed array data block page--log retry 9 for 500 times */ + for(i = 0; i < 500; i++) { + ret = H5F_track_metadata_read_retries(f, H5AC_FARRAY_DBLK_PAGE_ID, 9); + CHECK(ret, FAIL, "H5F_track_metadata_read_retries"); + } + + /* For fid1: free-space sections--log retry 99 for 1000 times */ + for(i = 0; i < 1000; i++) { + ret = H5F_track_metadata_read_retries(f1, H5AC_FSPACE_SINFO_ID, 99); + CHECK(ret, FAIL, "H5F_track_metadata_read_retries"); + } + + /* 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"); + + /* 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"); + + /* 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 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 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 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 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"); + + /* Free memory for info.retries and info1.retries */ + for(i = 0; i < NUM_METADATA_READ_RETRIES; i++) { + if(info.retries[i] != NULL) + HDfree(info.retries[i]); + if(info1.retries[i] != NULL) + HDfree(info1.retries[i]); + } + + /* Closing */ + ret=H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + ret=H5Fclose(fid1); + CHECK(ret, FAIL, "H5Fclose"); + + ret=H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); -} /* end test_read_attempts() */ +} /* end test_metadata_read_retries_info() */ /**************************************************************** ** @@ -4314,7 +4926,8 @@ test_file(void) test_libver_macros2(); /* Test the macros for library version comparison */ test_swmr_write(); /* Tests for SWMR write access flag */ test_swmr_read(); /* Tests for SWMR read access flag */ - test_read_attempts(); /* Tests for public routine H5Fget/set_read_attempts() */ + 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() */ #ifndef H5_NO_DEPRECATED_SYMBOLS test_deprec(); /* Test deprecated routines */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ -- cgit v0.12