summaryrefslogtreecommitdiffstats
path: root/src/H5Fint.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2018-04-01 17:47:58 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2018-04-01 17:47:58 (GMT)
commitd834e9158c8dd55c30a7fe13a142cfa124c02513 (patch)
tree9700f98803c6c1fd003131de4efb1aa1469e203b /src/H5Fint.c
parent84ed0b1d57453f4e2041f08dceacc8ade2ce160e (diff)
parent066b342af1ca455661034f72c141cef99f1bedb0 (diff)
downloadhdf5-d834e9158c8dd55c30a7fe13a142cfa124c02513.zip
hdf5-d834e9158c8dd55c30a7fe13a142cfa124c02513.tar.gz
hdf5-d834e9158c8dd55c30a7fe13a142cfa124c02513.tar.bz2
Merge remote-tracking branch 'origin/develop' into merge_func_enter_vol
Diffstat (limited to 'src/H5Fint.c')
-rw-r--r--src/H5Fint.c181
1 files changed, 160 insertions, 21 deletions
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++) {