summaryrefslogtreecommitdiffstats
path: root/src/H5Fint.c
diff options
context:
space:
mode:
authorMohamad Chaarawi <chaarawi@hdfgroup.org>2015-06-16 13:46:13 (GMT)
committerMohamad Chaarawi <chaarawi@hdfgroup.org>2015-06-16 13:46:13 (GMT)
commit79fe6d27f022b0124782d6e0c6eb345f2e669095 (patch)
tree42851620273b119837bc30534a836192f2904400 /src/H5Fint.c
parentc34e8ef85220b70d3eeed352b4320710f74f4cf9 (diff)
parentafb85e30e5874454fe890bb06c1a8cc67d2dc245 (diff)
downloadhdf5-79fe6d27f022b0124782d6e0c6eb345f2e669095.zip
hdf5-79fe6d27f022b0124782d6e0c6eb345f2e669095.tar.gz
hdf5-79fe6d27f022b0124782d6e0c6eb345f2e669095.tar.bz2
[svn-r27208] merge from trunk.
Diffstat (limited to 'src/H5Fint.c')
-rw-r--r--src/H5Fint.c80
1 files changed, 72 insertions, 8 deletions
diff --git a/src/H5Fint.c b/src/H5Fint.c
index 0979672..fd22977 100644
--- a/src/H5Fint.c
+++ b/src/H5Fint.c
@@ -881,14 +881,6 @@ H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush)
/* Push error, but keep going*/
HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close property list")
- /* Only truncate the file on an orderly close, with write-access */
- if(f->closing && (H5F_ACC_RDWR & H5F_INTENT(f))) {
- /* Truncate the file to the current allocated size */
- if(H5FD_truncate(f->shared->lf, dxpl_id, (unsigned)TRUE) < 0)
- /* Push error, but keep going*/
- HDONE_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "low level truncate failed")
- } /* end if */
-
/* Close the file */
if(H5FD_close(f->shared->lf) < 0)
/* Push error, but keep going*/
@@ -1206,6 +1198,15 @@ H5F_flush(H5F_t *f, hid_t dxpl_id, hbool_t closing)
/* Push error, but keep going*/
HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush metadata cache")
+ /* Truncate the file to the current allocated size */
+ if(H5FD_truncate(f->shared->lf, dxpl_id, closing) < 0)
+ HDONE_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "low level truncate failed")
+
+ /* Flush the entire metadata cache again since the EOA could have changed in the truncate call. */
+ if(H5AC_flush(f, dxpl_id) < 0)
+ /* Push error, but keep going*/
+ HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush metadata cache")
+
/* Set up I/O info for operation */
fio_info.f = f;
if(NULL == (fio_info.dxpl = (H5P_genplist_t *)H5I_object(dxpl_id)))
@@ -2116,3 +2117,66 @@ H5F_get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len)
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5F_get_file_image() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5F__set_base_addr
+ *
+ * Purpose: Quick and dirty routine to set the file's 'base_addr' value
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol <koziol@hdfgroup.org>
+ * July 19, 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5F__set_base_addr(const H5F_t *f, haddr_t addr)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_PACKAGE
+
+ HDassert(f);
+ HDassert(f->shared);
+
+ /* Dispatch to driver */
+ if(H5FD_set_base_addr(f->shared->lf, addr) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set_base_addr request failed")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5F__set_base_addr() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5F__set_eoa
+ *
+ * Purpose: Quick and dirty routine to set the file's 'eoa' value
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol <koziol@hdfgroup.org>
+ * July 19, 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5F__set_eoa(const H5F_t *f, H5F_mem_t type, haddr_t addr)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_PACKAGE
+
+ HDassert(f);
+ HDassert(f->shared);
+
+ /* Dispatch to driver */
+ if(H5FD_set_eoa(f->shared->lf, type, addr) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set_eoa request failed")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5F__set_eoa() */
+