summaryrefslogtreecommitdiffstats
path: root/src/H5F.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-08-21 11:33:44 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-08-21 11:33:44 (GMT)
commitd96910fe93972d48a8cfef0a44a57a803b07f031 (patch)
treec6e26ce08bcd26bf71f4fc75edcbabc42d168e02 /src/H5F.c
parent9316a67a8901daf5e85fc2947c666b4e10c04814 (diff)
downloadhdf5-d96910fe93972d48a8cfef0a44a57a803b07f031.zip
hdf5-d96910fe93972d48a8cfef0a44a57a803b07f031.tar.gz
hdf5-d96910fe93972d48a8cfef0a44a57a803b07f031.tar.bz2
[svn-r17404] Description:
Bring r17402 & r17403 from trunk to 1.8 branch: r17402: Switch from using a 'flags' parameter to the flush routine(s), to just using a single 'closing' boolean parameter, since that's all we're doing with the flags anyway and this makes things more obvious. r17403: Eliminate 'closing' flag to dataset flush routine, since all cached dataset information has already been flushed when a file is closed and the datasets themselves will be closed (and the dataset caches destroyed). Skip calling more flush routines when the file is closing, in preparation for eventual separation of the 'flush' concept from the 'shutdown the cache' concept. Tested on: FreeBSD/32 6.3 (duty) in debug mode (h5committest performed on trunk)
Diffstat (limited to 'src/H5F.c')
-rw-r--r--src/H5F.c50
1 files changed, 28 insertions, 22 deletions
diff --git a/src/H5F.c b/src/H5F.c
index 2291a3e..4212d6e 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -72,7 +72,7 @@ static H5F_t *H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id,
H5FD_t *lf);
static herr_t H5F_dest(H5F_t *f, hid_t dxpl_id);
static herr_t H5F_flush(H5F_t *f, hid_t dxpl_id, H5F_scope_t scope);
-static herr_t H5F_flush_real(H5F_t *f, hid_t dxpl_id, unsigned flags);
+static herr_t H5F_flush_real(H5F_t *f, hid_t dxpl_id, hbool_t closing);
static herr_t H5F_close(H5F_t *f);
/* Declare a free list to manage the H5F_t struct */
@@ -1023,7 +1023,7 @@ H5F_dest(H5F_t *f, hid_t dxpl_id)
/* Flush all caches and indicate we are closing the file */
/* (The caches should already be clean and we should just be invalidating objects) */
- if(H5F_flush_real(f, dxpl_id, H5F_FLUSH_CLOSING) < 0)
+ if(H5F_flush_real(f, dxpl_id, TRUE) < 0)
/* Push error, but keep going*/
HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache")
} /* end if */
@@ -1619,9 +1619,8 @@ done:
/*-------------------------------------------------------------------------
* Function: H5F_flush
*
- * Purpose: Flushes (and optionally invalidates) cached data plus the
- * file superblock. If the logical file size field is zero
- * then it is updated to be the length of the superblock.
+ * Purpose: Flushes (and optionally invalidates) cached data, possibly
+ * in all mounted files, depending on the SCOPE.
*
* Return: Non-negative on success/Negative on failure
*
@@ -1661,7 +1660,7 @@ H5F_flush(H5F_t *f, hid_t dxpl_id, H5F_scope_t scope)
} /* end if */
/* Call the "real" flush routine, for this file */
- if(H5F_flush_real(f, dxpl_id, H5F_FLUSH_NONE) < 0)
+ if(H5F_flush_real(f, dxpl_id, FALSE) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information")
/* Check flush errors for children - errors are already on the stack */
@@ -1676,9 +1675,7 @@ done:
/*-------------------------------------------------------------------------
* Function: H5F_flush_real
*
- * Purpose: Flushes (and optionally invalidates) cached data plus the
- * file superblock. If the logical file size field is zero
- * then it is updated to be the length of the superblock.
+ * Purpose: Flushes (and optionally invalidates) cached data.
*
* Return: Non-negative on success/Negative on failure
*
@@ -1689,7 +1686,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_flush_real(H5F_t *f, hid_t dxpl_id, unsigned flags)
+H5F_flush_real(H5F_t *f, hid_t dxpl_id, hbool_t closing)
{
unsigned H5AC_flags = H5AC__NO_FLAGS_SET; /* Flags for H5AC_flush() */
herr_t ret_value = SUCCEED; /* Return value */
@@ -1699,9 +1696,12 @@ H5F_flush_real(H5F_t *f, hid_t dxpl_id, unsigned flags)
/* Sanity check arguments */
HDassert(f);
- /* Flush any cached dataset storage raw data */
- if(H5D_flush(f, dxpl_id, flags) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush dataset cache")
+ /* If we will be closing the file, we don't need to flush the dataset info */
+ if(!closing) {
+ /* Flush any cached dataset storage raw data */
+ if(H5D_flush(f, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush dataset cache")
+ } /* end if */
/* If we will be closing the file, we should release the free space
* information now (needs to happen before truncating the file and
@@ -1709,7 +1709,7 @@ H5F_flush_real(H5F_t *f, hid_t dxpl_id, unsigned flags)
* holding some data structures in memory and also because releasing free
* space can shrink the file's 'eoa' value)
*/
- if(flags & H5F_FLUSH_CLOSING) {
+ if(closing) {
/* Shutdown file free space manager(s) */
if(H5MF_close(f, dxpl_id) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release file free space info")
@@ -1726,7 +1726,7 @@ H5F_flush_real(H5F_t *f, hid_t dxpl_id, unsigned flags)
} /* end else */
/* Flush (and invalidate, if requested) the entire metadata cache */
- if(flags & H5F_FLUSH_CLOSING) {
+ if(closing) {
H5AC_flags |= H5AC__FLUSH_INVALIDATE_FLAG;
/* Unpin the superblock, since we're about to destroy the cache */
@@ -1738,13 +1738,19 @@ H5F_flush_real(H5F_t *f, hid_t dxpl_id, unsigned flags)
if(H5AC_flush(f, dxpl_id, H5AC_flags) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush metadata cache")
- /* Flush out the metadata accumulator */
- if(H5F_accum_flush(f, dxpl_id) < 0)
- HGOTO_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush metadata accumulator")
+ /* If we will be closing the file, we don't need to flush the accumulator info */
+ if(!closing) {
+ /* Flush out the metadata accumulator */
+ if(H5F_accum_flush(f, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush metadata accumulator")
+ } /* end if */
- /* Flush file buffers to disk. */
- if(H5FD_flush(f->shared->lf, dxpl_id, (unsigned)((flags & H5F_FLUSH_CLOSING) > 0)) < 0)
- HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "low level flush failed")
+ /* If we will be closing the file, we don't need to flush file buffers */
+ if(!closing) {
+ /* Flush file buffers to disk. */
+ if(H5FD_flush(f->shared->lf, dxpl_id, closing) < 0)
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "low level flush failed")
+ } /* end if */
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1954,7 +1960,7 @@ H5F_try_close(H5F_t *f)
*/
if(f->intent&H5F_ACC_RDWR) {
/* Flush all caches */
- if(H5F_flush_real(f, H5AC_dxpl_id, H5F_FLUSH_NONE) < 0)
+ if(H5F_flush_real(f, H5AC_dxpl_id, FALSE) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache")
} /* end if */