summaryrefslogtreecommitdiffstats
path: root/src/H5Fsuper.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2016-12-02 16:07:04 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2016-12-02 16:07:04 (GMT)
commit64a339183f0e4532597744351548308203e993c8 (patch)
treeddfff2f15c0f3a01782f191a847665c6eceadd42 /src/H5Fsuper.c
parent5d7d029b97b36d1c380cef82d637342921bf3a1d (diff)
downloadhdf5-64a339183f0e4532597744351548308203e993c8.zip
hdf5-64a339183f0e4532597744351548308203e993c8.tar.gz
hdf5-64a339183f0e4532597744351548308203e993c8.tar.bz2
Bring SWMR support in to the main development branch. (Finally!) More tests
and the tool and API wrappers will be coming in over the weekend.
Diffstat (limited to 'src/H5Fsuper.c')
-rw-r--r--src/H5Fsuper.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c
index 489a149..2a82618 100644
--- a/src/H5Fsuper.c
+++ b/src/H5Fsuper.c
@@ -250,6 +250,7 @@ H5F__super_read(H5F_t *f, hid_t dxpl_id, hbool_t initial_read)
haddr_t super_addr; /* Absolute address of superblock */
haddr_t eof; /* End of file address */
unsigned rw_flags; /* Read/write permissions for file */
+ hbool_t skip_eof_check = FALSE; /* Whether to skip checking the EOF value */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE_TAG(dxpl_id, H5AC__SUPERBLOCK_TAG, FAIL)
@@ -317,6 +318,14 @@ H5F__super_read(H5F_t *f, hid_t dxpl_id, hbool_t initial_read)
if(NULL == (sblock = (H5F_super_t *)H5AC_protect(f, dxpl_id, H5AC_SUPERBLOCK, (haddr_t)0, &udata, rw_flags)))
HGOTO_ERROR(H5E_FILE, H5E_CANTPROTECT, FAIL, "unable to load superblock")
+ if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE)
+ if(sblock->super_vers < HDF5_SUPERBLOCK_VERSION_3)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTPROTECT, FAIL, "invalid superblock version for SWMR_WRITE")
+
+ /* Enable all latest version support when file has v3 superblock */
+ if(sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_3)
+ f->shared->latest_flags |= H5F_LATEST_ALL_FLAGS;
+
/* Pin the superblock in the cache */
if(H5AC_pin_protected_entry(sblock) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTPIN, FAIL, "unable to pin superblock")
@@ -410,7 +419,22 @@ H5F__super_read(H5F_t *f, hid_t dxpl_id, hbool_t initial_read)
* Note: the aggregator is changed again after being reset
* earlier before H5AC_flush due to allocation of tmp addresses.
*/
- if(initial_read) {
+ /* The EOF check must be skipped when the file is opened for SWMR read,
+ * as the file can appear truncated if only part of it has been
+ * been flushed to disk by the SWMR writer process.
+ */
+ if(H5F_INTENT(f) & H5F_ACC_SWMR_READ) {
+ /*
+ * When the file is opened for SWMR read access, skip the check if:
+ * --the file is already marked for SWMR writing and
+ * --the file has version 3 superblock for SWMR support
+ */
+ if((sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS) &&
+ (sblock->status_flags & H5F_SUPER_WRITE_ACCESS) &&
+ sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_3)
+ skip_eof_check = TRUE;
+ } /* end if */
+ if(!skip_eof_check && initial_read) {
if(HADDR_UNDEF == (eof = H5FD_get_eof(f->shared->lf, H5FD_MEM_DEFAULT)))
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to determine file size")