summaryrefslogtreecommitdiffstats
path: root/src/H5F.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5F.c')
-rw-r--r--src/H5F.c132
1 files changed, 103 insertions, 29 deletions
diff --git a/src/H5F.c b/src/H5F.c
index 414bb19..877d504 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -866,8 +866,6 @@ herr_t
H5Fget_filesize(hid_t file_id, hsize_t *size)
{
H5F_t *file; /* File object for file ID */
- haddr_t eof; /* End of file address */
- haddr_t eoa; /* End of allocation address */
haddr_t max_eof_eoa; /* Maximum of the EOA & EOF */
haddr_t base_addr; /* Base address for the file */
herr_t ret_value = SUCCEED; /* Return value */
@@ -880,11 +878,9 @@ H5Fget_filesize(hid_t file_id, hsize_t *size)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID")
/* Go get the actual file size */
- eof = H5FD_get_eof(file->shared->lf, H5FD_MEM_DEFAULT);
- eoa = H5FD_get_eoa(file->shared->lf, H5FD_MEM_DEFAULT);
- max_eof_eoa = MAX(eof, eoa);
- if(HADDR_UNDEF == max_eof_eoa)
- HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file get eof/eoa requests failed")
+ if(H5F__get_max_eof_eoa(file, &max_eof_eoa) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ")
+
base_addr = H5FD_get_base_addr(file->shared->lf);
if(size)
@@ -1508,7 +1504,8 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
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->latest_flags | H5F_LATEST_LAYOUT_MSG) > 0);
+
+ 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)
@@ -1638,54 +1635,47 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Fset_latest_format
+ * Function: H5Fset_libver_bounds
*
- * Purpose: Enable switching the "latest format" flag while a file is open.
+ * Purpose: Set to a different low and high bounds while a file is open.
+ * This public routine is introduced in place of
+ * H5Fset_latest_format() starting release 1.10.2.
+ * See explanation for H5Fset_latest_format() in H5Fdeprec.c.
*
* Return: Non-negative on success/Negative on failure
*-------------------------------------------------------------------------
*/
herr_t
-H5Fset_latest_format(hid_t file_id, hbool_t latest_format)
+H5Fset_libver_bounds(hid_t file_id, H5F_libver_t low, H5F_libver_t high)
{
H5F_t *f; /* File */
- unsigned latest_flags; /* Latest format flags for file */
hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
- H5TRACE2("e", "ib", file_id, latest_format);
+ H5TRACE3("e", "iFvFv", file_id, low, high);
/* Check args */
if(NULL == (f = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "not a file ID")
- /* Check if the value is changing */
- latest_flags = H5F_USE_LATEST_FLAGS(f, H5F_LATEST_ALL_FLAGS);
- if(latest_format != (H5F_LATEST_ALL_FLAGS == latest_flags)) {
- hid_t fapl_id = H5P_DEFAULT; /* FAPL to use */
-
/* Set API context */
if(H5CX_push() < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set API context")
api_ctx_pushed = TRUE;
-/* Verify access property list and set up collective metadata if appropriate */
-if(H5CX_set_apl(&fapl_id, H5P_CLS_FACC, file_id, TRUE) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set access property list info")
-
- /* Call the flush routine, for this file */
- if(H5F__flush_real(f, FALSE) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information")
+/* Set up collective metadata if appropriate */
+if(H5CX_set_loc(file_id, TRUE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info")
- /* Toggle the 'latest format' flag */
- H5F_SET_LATEST_FLAGS(f, latest_format ? H5F_LATEST_ALL_FLAGS : 0);
- } /* end if */
+ /* Call internal set_libver_bounds function */
+ if(H5F__set_libver_bounds(f, low, high) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set low/high bounds")
done:
if(api_ctx_pushed && H5CX_pop() < 0)
HDONE_ERROR(H5E_FILE, H5E_CANTRESET, FAIL, "can't reset API context")
FUNC_LEAVE_API(ret_value)
-} /* end H5Fset_latest_format() */
+} /* end H5Fset_libver_bounds() */
/*-------------------------------------------------------------------------
@@ -1840,3 +1830,87 @@ done:
FUNC_LEAVE_API(ret_value)
} /* H5Fget_mdc_image_info() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5Fget_eoa
+ *
+ * Purpose: Returns the address of the first byte after the last
+ * allocated memory in the file.
+ * (See H5FDget_eoa() in H5FD.c)
+ *
+ * Return: Success: First byte after allocated memory.
+ * Failure: HADDR_UNDEF
+ *
+ * Return: Non-negative on success/Negative on errors
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Fget_eoa(hid_t file_id, haddr_t *eoa)
+{
+ H5F_t *file; /* File object for file ID */
+ haddr_t rel_eoa; /* Relative address of EOA */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE2("e", "i*a", file_id, eoa);
+
+ /* Check args */
+ if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID")
+
+ /* This public routine will work only for drivers with this feature enabled.*/
+ /* We might introduce a new feature flag in the future */
+ if(!H5F_HAS_FEATURE(file, H5FD_FEAT_SUPPORTS_SWMR_IO))
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must use a SWMR-compatible VFD for this public routine")
+
+ /* The real work */
+ if(HADDR_UNDEF == (rel_eoa = H5FD_get_eoa(file->shared->lf, H5FD_MEM_DEFAULT)))
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "get_eoa request failed")
+
+ /* (Note compensating for base address subtraction in internal routine) */
+ if(eoa)
+ *eoa = rel_eoa + H5FD_get_base_addr(file->shared->lf);
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* H5Fget_eoa() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Fincrement_filesize
+ *
+ * Purpose: Set the EOA for the file to the maximum of (EOA, EOF) + increment
+ *
+ * Return: Non-negative on success/Negative on errors
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Fincrement_filesize(hid_t file_id, hsize_t increment)
+{
+ H5F_t *file; /* File object for file ID */
+ haddr_t max_eof_eoa; /* Maximum of the relative EOA & EOF */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE2("e", "ih", file_id, increment);
+
+ /* Check args */
+ if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID")
+
+ /* This public routine will work only for drivers with this feature enabled.*/
+ /* We might introduce a new feature flag in the future */
+ if(!H5F_HAS_FEATURE(file, H5FD_FEAT_SUPPORTS_SWMR_IO))
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must use a SWMR-compatible VFD for this public routine")
+
+ /* Get the maximum of EOA and EOF */
+ if(H5F__get_max_eof_eoa(file, &max_eof_eoa) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ")
+
+ /* Set EOA to the maximum value + increment */
+ /* H5FD_set_eoa() will add base_addr to max_eof_eoa */
+ if(H5FD_set_eoa(file->shared->lf, H5FD_MEM_DEFAULT, max_eof_eoa + increment) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set_eoa request failed")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* H5Fincrement_filesize() */