summaryrefslogtreecommitdiffstats
path: root/src/H5Dint.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Dint.c')
-rw-r--r--src/H5Dint.c187
1 files changed, 187 insertions, 0 deletions
diff --git a/src/H5Dint.c b/src/H5Dint.c
index a324873..6f088af 100644
--- a/src/H5Dint.c
+++ b/src/H5Dint.c
@@ -1955,6 +1955,139 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5D_mult_refresh_close
+ *
+ * Purpose: Closing down the needed information when the dataset has
+ * multiple opens. (From H5O_refresh_metadata_close())
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Vailin Choi
+ * 12/24/15
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5D_mult_refresh_close(hid_t dset_id, hid_t dxpl_id)
+{
+ H5D_t *dataset; /* Dataset to refresh */
+ herr_t ret_value = SUCCEED; /* return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ if(NULL == (dataset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
+
+ /* check args */
+ HDassert(dataset && dataset->oloc.file && dataset->shared);
+ HDassert(dataset->shared->fo_count > 0);
+
+ if(dataset->shared->fo_count > 1) {
+ /* Free cached information for each kind of dataset */
+ switch(dataset->shared->layout.type) {
+ case H5D_CONTIGUOUS:
+ /* Free the data sieve buffer, if it's been allocated */
+ if(dataset->shared->cache.contig.sieve_buf)
+ dataset->shared->cache.contig.sieve_buf = (unsigned char *)H5FL_BLK_FREE(sieve_buf,dataset->shared->cache.contig.sieve_buf);
+ break;
+
+ case H5D_CHUNKED:
+ /* Check for skip list for iterating over chunks during I/O to close */
+ if(dataset->shared->cache.chunk.sel_chunks) {
+ HDassert(H5SL_count(dataset->shared->cache.chunk.sel_chunks) == 0);
+ H5SL_close(dataset->shared->cache.chunk.sel_chunks);
+ dataset->shared->cache.chunk.sel_chunks = NULL;
+ } /* end if */
+
+ /* Check for cached single chunk dataspace */
+ if(dataset->shared->cache.chunk.single_space) {
+ (void)H5S_close(dataset->shared->cache.chunk.single_space);
+ dataset->shared->cache.chunk.single_space = NULL;
+ } /* end if */
+
+ /* Check for cached single element chunk info */
+ if(dataset->shared->cache.chunk.single_chunk_info) {
+ dataset->shared->cache.chunk.single_chunk_info = H5FL_FREE(H5D_chunk_info_t, dataset->shared->cache.chunk.single_chunk_info);
+ dataset->shared->cache.chunk.single_chunk_info = NULL;
+ } /* end if */
+ break;
+
+ case H5D_COMPACT:
+ case H5D_VIRTUAL:
+ /* Nothing special to do (info freed in the layout destroy) */
+ break;
+
+ case H5D_LAYOUT_ERROR:
+ case H5D_NLAYOUTS:
+ default:
+ HDassert("not implemented yet" && 0);
+#ifdef NDEBUG
+ HGOTO_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, "unsupported storage layout")
+#endif /* NDEBUG */
+ } /* end switch */ /*lint !e788 All appropriate cases are covered */
+
+ /* Destroy any cached layout information for the dataset */
+ if(dataset->shared->layout.ops->dest && (dataset->shared->layout.ops->dest)(dataset, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info")
+ } /* end if */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5D_mult_refresh_close() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5D_mult_refresh_reopen
+ *
+ * Purpose: Re-initialize the needed info when the dataset has multiple
+ * opens. (From H5O_refresh_metadata_reopen())
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Vailin Choi
+ * 12/24/15
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5D_mult_refresh_reopen(H5D_t *dataset, hid_t dxpl_id)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* check args */
+ HDassert(dataset && dataset->oloc.file && dataset->shared);
+ HDassert(dataset->shared->fo_count > 0);
+
+ if(dataset->shared->fo_count > 1) {
+ /* Release dataspace info */
+ if(H5S_close(dataset->shared->space) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release dataspace")
+
+ /* Re-load dataspace info */
+ if(NULL == (dataset->shared->space = H5S_read(&(dataset->oloc), dxpl_id)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to load dataspace info from dataset header")
+
+ /* Cache the dataset's dataspace info */
+ if(H5D__cache_dataspace_info(dataset) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't cache dataspace info")
+
+ /* Release layout info */
+ if(H5O_msg_reset(H5O_LAYOUT_ID, &dataset->shared->layout) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset layout info")
+
+ /* Re-load layout message info */
+ if(NULL == H5O_msg_read(&(dataset->oloc), H5O_LAYOUT_ID, &(dataset->shared->layout), dxpl_id))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read data layout message")
+ } /* end if */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5D_mult_refresh_reopen() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5D_oloc
*
* Purpose: Returns a pointer to the object location for a dataset.
@@ -3475,3 +3608,57 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_get_type() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5D__refresh
+ *
+ * Purpose: Refreshes all buffers associated with a dataset.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Dana Robinson
+ * November 2015
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5D__refresh(hid_t dset_id, H5D_t *dset, hid_t dxpl_id)
+{
+ H5D_virtual_held_file_t *head = NULL; /* Pointer to list of files held open */
+ hbool_t virt_dsets_held = FALSE; /* Whether virtual datasets' files are held open */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ HDassert(dset);
+
+ /* If the layout is virtual... */
+ if(dset->shared->layout.type == H5D_VIRTUAL) {
+ /* Hold open the source datasets' files */
+ if(H5D__virtual_hold_source_dset_files(dset, &head) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINC, FAIL, "unable to hold VDS source files open")
+ virt_dsets_held = TRUE;
+
+ /* Refresh source datasets for virtual dataset */
+ if(H5D__virtual_refresh_source_dsets(dset, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to refresh VDS source datasets")
+ } /* end if */
+
+ /* Refresh dataset object */
+ if((H5O_refresh_metadata(dset_id, dset->oloc, dxpl_id)) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to refresh dataset")
+
+done:
+ /* Release hold on virtual datasets' files */
+ if(virt_dsets_held) {
+ /* Sanity check */
+ HDassert(dset->shared->layout.type == H5D_VIRTUAL);
+
+ /* Release the hold on source datasets' files */
+ if(H5D__virtual_release_source_dset_files(head) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't release VDS source files held open")
+ } /* end if */
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5D__refresh() */
+