summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5F.c121
-rw-r--r--src/H5Fint.c181
-rw-r--r--src/H5Fpkg.h1
-rw-r--r--src/H5Fprivate.h1
4 files changed, 171 insertions, 133 deletions
diff --git a/src/H5F.c b/src/H5F.c
index 4f7d597..8023a04 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -1221,82 +1221,23 @@ done:
herr_t
H5Fget_metadata_read_retry_info(hid_t file_id, H5F_retry_info_t *info)
{
- H5F_t *file; /* File object for file ID */
- unsigned i, j; /* Local index variable */
- size_t tot_size; /* Size of each retries[i] */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5F_t *file; /* File object for file ID */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE2("e", "i*x", file_id, info);
/* Check args */
- if(!info)
+ 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->shared->retries_nbins;
-
- /* Initialize the array of "retries" */
- HDmemset(info->retries, 0, sizeof(info->retries));
-
- /* 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 < H5F_NUM_METADATA_READ_RETRY_TYPES);
- if(file->shared->retries[i] != NULL) {
- /* Allocate memory for retries[i]
- *
- * This memory should be released by the user with
- * the H5free_memory() call.
- */
- if(NULL == (info->retries[j] = (uint32_t *)H5MM_malloc(tot_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
-
- /* Copy the information */
- HDmemcpy(info->retries[j], file->shared->retries[i], tot_size);
- } /* end if */
-
- /* Increment location in info->retries[] array */
- j++;
- break;
-
- default:
- break;
- } /* end switch */
- } /* end for */
+ /* Get the retry info */
+ if(H5F__get_metadata_read_retry_info(file, info) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't get metadata read retry info")
done:
FUNC_LEAVE_API(ret_value)
@@ -1379,39 +1320,16 @@ done:
* Function: H5Fstart_swmr_write
*
* Purpose: To enable SWMR writing mode for the file
- * 1) Refresh opened objects: part 1
- * 2) Flush & reset accumulator
- * 3) Mark the file in SWMR writing mode
- * 4) Set metadata read attempts and retries info
- * 5) Disable accumulator
- * 6) Evict all cache entries except the superblock
- * 7) Refresh opened objects (part 2)
- * 8) Unlock the file
- *
- * Pre-conditions:
- * 1) The file being opened has v3 superblock
- * 2) The file is opened with H5F_ACC_RDWR
- * 3) The file is not already marked for SWMR writing
- * 4) Current implementaion for opened objects:
- * --only allow datasets and groups without attributes
- * --disallow named datatype with/without attributes
- * --disallow opened attributes attached to objects
- * NOTE: Currently, only opened groups and datasets are allowed
- * when enabling SWMR via H5Fstart_swmr_write().
- * Will later implement a different approach--
- * set up flush dependency/proxy even for file opened without
- * SWMR to resolve issues with opened objects.
*
* Return: Non-negative on success/negative on failure
+ *
*-------------------------------------------------------------------------
*/
herr_t
H5Fstart_swmr_write(hid_t file_id)
{
- H5F_t *file; /* File info */
- hbool_t ci_load = FALSE; /* whether MDC ci load requested */
- hbool_t ci_write = FALSE; /* whether MDC CI write requested */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5F_t *file = NULL; /* File info */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("e", "i", file_id);
@@ -1420,27 +1338,6 @@ H5Fstart_swmr_write(hid_t file_id)
if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file")
- /* Should have write permission */
- if((H5F_INTENT(file) & H5F_ACC_RDWR) == 0)
- HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "no write intent on file")
-
- if(file->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_3)
- HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "file superblock version should be at least 3")
-
- HDassert((file->shared->low_bound == H5F_LIBVER_V110) && (file->shared->high_bound == H5F_LIBVER_V110));
-
- /* Should not be marked for SWMR writing mode already */
- if(file->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS)
- HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "file already in SWMR writing mode")
-
- HDassert(file->shared->sblock->status_flags & H5F_SUPER_WRITE_ACCESS);
-
- /* Check to see if cache image is enabled. Fail if so */
- if(H5C_cache_image_status(file, &ci_load, &ci_write) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get MDC cache image status")
- if(ci_load || ci_write )
- HGOTO_ERROR(H5E_FILE, H5E_UNSUPPORTED, FAIL, "can't have both SWMR and MDC cache image")
-
/* Set up collective metadata if appropriate */
if(H5CX_set_loc(file_id) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info")
diff --git a/src/H5Fint.c b/src/H5Fint.c
index 5a5bad6..c5d281d 100644
--- a/src/H5Fint.c
+++ b/src/H5Fint.c
@@ -3287,10 +3287,125 @@ H5F_set_coll_md_read(H5F_t *f, H5P_coll_md_read_flag_t cmr)
/*-------------------------------------------------------------------------
+ * Function: H5F__get_metadata_read_retry_info
+ *
+ * Purpose: Private function to retrieve the collection of read retries
+ * for metadata items with checksum.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5F__get_metadata_read_retry_info(H5F_t *file, H5F_retry_info_t *info)
+{
+ unsigned i, j; /* Local index variable */
+ size_t tot_size; /* Size of each retries[i] */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_PACKAGE
+
+ /* Check args */
+ HDassert(file);
+ HDassert(info);
+
+ /* Copy the # of bins for "retries" array */
+ info->nbins = file->shared->retries_nbins;
+
+ /* Initialize the array of "retries" */
+ HDmemset(info->retries, 0, sizeof(info->retries));
+
+ /* 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 < H5F_NUM_METADATA_READ_RETRY_TYPES);
+ if (file->shared->retries[i] != NULL) {
+ /* Allocate memory for retries[i]
+ *
+ * This memory should be released by the user with
+ * the H5free_memory() call.
+ */
+ if (NULL == (info->retries[j] = (uint32_t *)H5MM_malloc(tot_size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+
+ /* Copy the information */
+ HDmemcpy(info->retries[j], file->shared->retries[i], tot_size);
+ }
+
+ /* Increment location in info->retries[] array */
+ j++;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5F__get_metadata_read_retry_info() */
+
+
+
+/*-------------------------------------------------------------------------
* Function: H5F__start_swmr_write
*
* Purpose: Private version of H5Fstart_swmr_write
*
+ * 1) Refresh opened objects: part 1
+ * 2) Flush & reset accumulator
+ * 3) Mark the file in SWMR writing mode
+ * 4) Set metadata read attempts and retries info
+ * 5) Disable accumulator
+ * 6) Evict all cache entries except the superblock
+ * 7) Refresh opened objects (part 2)
+ * 8) Unlock the file
+ *
+ * Pre-conditions:
+ *
+ * 1) The file being opened has v3 superblock
+ * 2) The file is opened with H5F_ACC_RDWR
+ * 3) The file is not already marked for SWMR writing
+ * 4) Current implementaion for opened objects:
+ * --only allow datasets and groups without attributes
+ * --disallow named datatype with/without attributes
+ * --disallow opened attributes attached to objects
+ *
+ * Note: Currently, only opened groups and datasets are allowed
+ * when enabling SWMR via H5Fstart_swmr_write().
+ * Will later implement a different approach--
+ * set up flush dependency/proxy even for file opened without
+ * SWMR to resolve issues with opened objects.
+ *
* Note: This routine is needed so that there's a non-API routine
* that can set up VOL / SWMR info (which need a DXPL).
*
@@ -3301,15 +3416,17 @@ H5F_set_coll_md_read(H5F_t *f, H5P_coll_md_read_flag_t cmr)
herr_t
H5F__start_swmr_write(H5F_t *f)
{
- size_t grp_dset_count = 0; /* # of open objects: groups & datasets */
- size_t nt_attr_count = 0; /* # of opened named datatypes + opened attributes */
- hid_t *obj_ids = NULL; /* List of ids */
- H5G_loc_t *obj_glocs = NULL;/* Group location of the object */
- H5O_loc_t *obj_olocs = NULL;/* Object location */
- H5G_name_t *obj_paths = NULL; /* Group hierarchy path */
- size_t u; /* Local index variable */
- hbool_t setup = FALSE; /* Boolean flag to indicate whether SWMR setting is enabled */
- herr_t ret_value = SUCCEED; /* Return value */
+ hbool_t ci_load = FALSE; /* whether MDC ci load requested */
+ hbool_t ci_write = FALSE; /* whether MDC CI write requested */
+ size_t grp_dset_count = 0; /* # of open objects: groups & datasets */
+ size_t nt_attr_count = 0; /* # of opened named datatypes + opened attributes */
+ hid_t *obj_ids = NULL; /* List of ids */
+ H5G_loc_t *obj_glocs = NULL; /* Group location of the object */
+ H5O_loc_t *obj_olocs = NULL; /* Object location */
+ H5G_name_t *obj_paths = NULL; /* Group hierarchy path */
+ size_t u; /* Local index variable */
+ hbool_t setup = FALSE; /* Boolean flag to indicate whether SWMR setting is enabled */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE_VOL
@@ -3317,6 +3434,28 @@ H5F__start_swmr_write(H5F_t *f)
HDassert(f);
HDassert(f->shared);
+ /* Should have write permission */
+ if((H5F_INTENT(f) & H5F_ACC_RDWR) == 0)
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "no write intent on file")
+
+ /* Check superblock version */
+ if(f->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_3)
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "file superblock version - should be at least 3")
+
+ /* Check for correct file format version */
+ if((f->shared->low_bound != H5F_LIBVER_V110) || (f->shared->high_bound != H5F_LIBVER_V110))
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "file format version does not support SWMR - needs to be 1.10 or greater")
+
+ /* Should not be marked for SWMR writing mode already */
+ if(f->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS)
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "file already in SWMR writing mode")
+
+ /* Check to see if cache image is enabled. Fail if so */
+ if(H5C_cache_image_status(f, &ci_load, &ci_write) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get MDC cache image status")
+ if(ci_load || ci_write )
+ HGOTO_ERROR(H5E_FILE, H5E_UNSUPPORTED, FAIL, "can't have both SWMR and MDC cache image")
+
/* Flush the superblock extension */
if(H5F_flush_tagged_metadata(f, f->shared->sblock->ext_addr) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush superblock extension")
@@ -3337,18 +3476,18 @@ H5F__start_swmr_write(H5F_t *f)
if(grp_dset_count) {
/* Allocate space for group and object locations */
- if((obj_ids = (hid_t *) H5MM_malloc(grp_dset_count * sizeof(hid_t))) == NULL)
- HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for hid_t")
- if((obj_glocs = (H5G_loc_t *) H5MM_malloc(grp_dset_count * sizeof(H5G_loc_t))) == NULL)
- HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for H5G_loc_t")
- if((obj_olocs = (H5O_loc_t *) H5MM_malloc(grp_dset_count * sizeof(H5O_loc_t))) == NULL)
- HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for H5O_loc_t")
- if((obj_paths = (H5G_name_t *) H5MM_malloc(grp_dset_count * sizeof(H5G_name_t))) == NULL)
- HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for H5G_name_t")
-
- /* Get the list of opened object ids (groups & datasets) */
- if(H5F_get_obj_ids(f, H5F_OBJ_GROUP|H5F_OBJ_DATASET, grp_dset_count, obj_ids, FALSE, &grp_dset_count) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "H5F_get_obj_ids failed")
+ if((obj_ids = (hid_t *) H5MM_malloc(grp_dset_count * sizeof(hid_t))) == NULL)
+ HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for hid_t")
+ if((obj_glocs = (H5G_loc_t *) H5MM_malloc(grp_dset_count * sizeof(H5G_loc_t))) == NULL)
+ HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for H5G_loc_t")
+ if((obj_olocs = (H5O_loc_t *) H5MM_malloc(grp_dset_count * sizeof(H5O_loc_t))) == NULL)
+ HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for H5O_loc_t")
+ if((obj_paths = (H5G_name_t *) H5MM_malloc(grp_dset_count * sizeof(H5G_name_t))) == NULL)
+ HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for H5G_name_t")
+
+ /* Get the list of opened object ids (groups & datasets) */
+ if(H5F_get_obj_ids(f, H5F_OBJ_GROUP|H5F_OBJ_DATASET, grp_dset_count, obj_ids, FALSE, &grp_dset_count) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "H5F_get_obj_ids failed")
/* Refresh opened objects (groups, datasets) in the file */
for(u = 0; u < grp_dset_count; u++) {
diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h
index 376f5d8..050e426 100644
--- a/src/H5Fpkg.h
+++ b/src/H5Fpkg.h
@@ -410,6 +410,7 @@ H5_DLL ssize_t H5F__get_file_image(H5F_t *f, void *buf_ptr, size_t buf_len);
H5_DLL herr_t H5F__get_info(H5F_t *f, H5F_info2_t *finfo);
H5_DLL ssize_t H5F__get_free_sections(H5F_t *f, H5FD_mem_t type,
size_t nsects, H5F_sect_info_t *sect_info);
+H5_DLL herr_t H5F__get_metadata_read_retry_info(H5F_t *file, H5F_retry_info_t *info);
H5_DLL herr_t H5F__format_convert(H5F_t *f);
H5_DLL herr_t H5F__start_swmr_write(H5F_t *f);
H5_DLL herr_t H5F__close(hid_t file_id);
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index 4843b5d..3e77700 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -716,6 +716,7 @@ typedef enum H5F_prefix_open_t {
H5_DLL H5F_t *H5F_open(const char *name, unsigned flags, hid_t fcpl_id,
hid_t fapl_id);
H5_DLL herr_t H5F_try_close(H5F_t *f, hbool_t *was_closed/*out*/);
+H5_DLL herr_t H5F_start_swmr_write(H5F_t *file);
/* Functions that retrieve values from the file struct */
H5_DLL H5F_libver_t H5F_get_low_bound(const H5F_t *f);