summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5F.c2
-rw-r--r--src/H5FDvfd_swmr.c2
-rw-r--r--src/H5FDvfd_swmr.h4
-rw-r--r--src/H5FDvfd_swmr_private.h2
-rw-r--r--src/H5Fpublic.h2
-rw-r--r--src/H5Fvfd_swmr.c34
-rw-r--r--src/Makefile.am2
7 files changed, 31 insertions, 17 deletions
diff --git a/src/H5F.c b/src/H5F.c
index 144ffbe..70c0278 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -2046,7 +2046,7 @@ H5Fvfd_swmr_end_tick(hid_t file_id)
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must have VFD SWMR configured for this public routine")
/* ??Trigger end of tick processing later */
- H5F_vfd_swmr_writer_end_of_tick(file);
+ H5F_vfd_swmr_writer_end_of_tick(file, true);
done:
FUNC_LEAVE_API(ret_value)
diff --git a/src/H5FDvfd_swmr.c b/src/H5FDvfd_swmr.c
index 9a255a7..b729c1c 100644
--- a/src/H5FDvfd_swmr.c
+++ b/src/H5FDvfd_swmr.c
@@ -391,6 +391,8 @@ H5FD_vfd_swmr_close(H5FD_t *_file)
/* Sanity check */
HDassert(file);
+ vfd_swmr_reader_did_increase_tick_to(0);
+
/* Close the underlying file */
if(file->hdf5_file_lf && H5FD_close(file->hdf5_file_lf) < 0)
/* Push error, but keep going */
diff --git a/src/H5FDvfd_swmr.h b/src/H5FDvfd_swmr.h
index e7f2b8d..86e9d0f 100644
--- a/src/H5FDvfd_swmr.h
+++ b/src/H5FDvfd_swmr.h
@@ -17,6 +17,10 @@
#ifndef H5FDswmr_H
#define H5FDswmr_H
+#include "H5api_adpt.h" /* H5_DLL */
+#include "H5public.h" /* uint64_t *ahem* */
+#include "H5Ipublic.h" /* hid_t */
+
#define H5FD_VFD_SWMR (H5FD_vfd_swmr_init())
#ifdef __cplusplus
diff --git a/src/H5FDvfd_swmr_private.h b/src/H5FDvfd_swmr_private.h
index 1609eeb..94fe662 100644
--- a/src/H5FDvfd_swmr_private.h
+++ b/src/H5FDvfd_swmr_private.h
@@ -81,7 +81,7 @@ H5_DLL herr_t H5F_vfd_swmr_writer__delay_write(struct H5F_shared_t *, uint64_t,
uint64_t *);
H5_DLL herr_t H5F_vfd_swmr_writer__prep_for_flush_or_close(struct H5F_t *f);
herr_t H5F_vfd_swmr_process_eot_queue(bool);
-H5_DLL herr_t H5F_vfd_swmr_writer_end_of_tick(struct H5F_t *f);
+H5_DLL herr_t H5F_vfd_swmr_writer_end_of_tick(struct H5F_t *f, bool);
H5_DLL herr_t H5F_vfd_swmr_writer__dump_index(struct H5F_t * f);
H5_DLL herr_t H5F_vfd_swmr_reader_end_of_tick(struct H5F_t *f, bool);
diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h
index a462dc9..f46f91a 100644
--- a/src/H5Fpublic.h
+++ b/src/H5Fpublic.h
@@ -373,6 +373,8 @@ H5_DLL herr_t H5Fset_dset_no_attrs_hint(hid_t file_id, hbool_t minimize);
/* VFD SWMR */
H5_DLL herr_t H5Fvfd_swmr_end_tick(hid_t file_id);
+H5_DLL bool vfd_swmr_writer_may_increase_tick_to(uint64_t, bool);
+H5_DLL void vfd_swmr_reader_did_increase_tick_to(uint64_t);
#ifdef H5_HAVE_PARALLEL
H5_DLL herr_t H5Fset_mpi_atomicity(hid_t file_id, hbool_t flag);
diff --git a/src/H5Fvfd_swmr.c b/src/H5Fvfd_swmr.c
index 840d64a..231e7b1 100644
--- a/src/H5Fvfd_swmr.c
+++ b/src/H5Fvfd_swmr.c
@@ -711,7 +711,7 @@ H5F_vfd_swmr_writer__prep_for_flush_or_close(H5F_t *f)
* tick so as to avoid attempts to flush entries on the page buffer
* tick list that were modified during the current tick.
*/
- if ( H5F_vfd_swmr_writer_end_of_tick(f) < 0 )
+ if ( H5F_vfd_swmr_writer_end_of_tick(f, true) < 0 )
HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, \
"H5F_vfd_swmr_writer_end_of_tick() failed.")
@@ -833,7 +833,7 @@ clean_shadow_index(H5F_t *f, uint32_t nentries,
*-------------------------------------------------------------------------
*/
herr_t
-H5F_vfd_swmr_writer_end_of_tick(H5F_t *f)
+H5F_vfd_swmr_writer_end_of_tick(H5F_t *f, bool wait_for_reader)
{
uint32_t idx_entries_added = 0;
uint32_t idx_entries_modified = 0;
@@ -841,6 +841,7 @@ H5F_vfd_swmr_writer_end_of_tick(H5F_t *f)
uint32_t idx_ent_not_in_tl = 0;
uint32_t idx_ent_not_in_tl_flushed = 0;
herr_t ret_value = SUCCEED; /* Return value */
+ bool incr_tick = false;
FUNC_ENTER_NOAPI(FAIL)
@@ -849,7 +850,12 @@ H5F_vfd_swmr_writer_end_of_tick(H5F_t *f)
HDassert(f->shared->pb_ptr);
HDassert(f->shared->vfd_swmr_writer);
-
+ if (!vfd_swmr_writer_may_increase_tick_to(f->shared->tick_num + 1,
+ wait_for_reader))
+ goto update_eot;
+
+ incr_tick = true;
+
/* 1) If requested, flush all raw data to the HDF5 file.
*
* (Not for first cut.)
@@ -969,10 +975,12 @@ H5F_vfd_swmr_writer_end_of_tick(H5F_t *f)
HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "can't release delayed writes")
+update_eot:
+
/* 9) Increment the tick, and update the end of tick. */
/* Update end_of_tick */
- if ( H5F__vfd_swmr_update_end_of_tick_and_tick_num(f, TRUE) < 0 )
+ if ( H5F__vfd_swmr_update_end_of_tick_and_tick_num(f, incr_tick) < 0 )
HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, \
"unable to update end of tick")
@@ -985,16 +993,12 @@ H5F_vfd_swmr_writer_end_of_tick(H5F_t *f)
if(H5F_vfd_swmr_insert_entry_eot(f) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to insert entry into the EOT queue")
-#if 0 /* JRM */
- HDfprintf(stderr,
- "*** writer EOT %" PRIu64 " exiting. idx len = %" PRIu32 " ***\n",
- f->shared->tick_num, f->shared->mdf_idx_entries_used);
-#endif /* JRM */
-done:
+ hlog_fast(eot, "%s leave tick %" PRIu64 " idx len %" PRIu32,
+ __func__, f->shared->tick_num, f->shared->mdf_idx_entries_used);
+done:
FUNC_LEAVE_NOAPI(ret_value)
-
-} /* end H5F_vfd_swmr_writer_end_of_tick() */
+}
/*-------------------------------------------------------------------------
@@ -1352,6 +1356,8 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, bool entering_api)
*/
f->shared->tick_num = tmp_tick_num;
+ vfd_swmr_reader_did_increase_tick_to(tmp_tick_num);
+
/* Update end_of_tick */
if (H5F__vfd_swmr_update_end_of_tick_and_tick_num(f, FALSE) < 0) {
HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL,
@@ -2009,7 +2015,7 @@ H5F__vfd_swmr_writer__wait_a_tick(H5F_t *f)
HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "HDnanosleep() failed.")
- if ( H5F_vfd_swmr_writer_end_of_tick(f) < 0 )
+ if ( H5F_vfd_swmr_writer_end_of_tick(f, false) < 0 )
HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, \
"H5F_vfd_swmr_writer_end_of_tick() failed.")
@@ -2041,7 +2047,7 @@ H5F_vfd_swmr_process_eot_queue(bool entering_api)
if(timespeccmp(&now, &head->end_of_tick, <))
break;
if (f->shared->vfd_swmr_writer) {
- if (H5F_vfd_swmr_writer_end_of_tick(f) < 0)
+ if (H5F_vfd_swmr_writer_end_of_tick(f, false) < 0)
HGOTO_ERROR(H5E_FUNC, H5E_CANTSET, FAIL,
"end of tick error for VFD SWMR writer");
} else if (H5F_vfd_swmr_reader_end_of_tick(f, entering_api) < 0) {
diff --git a/src/Makefile.am b/src/Makefile.am
index f26580b..b5d3e04 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -67,7 +67,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \
H5FDhdfs.c \
H5FDint.c \
H5FDlog.c \
- H5FDvfd_swmr.c \
+ H5FDvfd_swmr.c H5FDvfd_swmr_instr.c \
H5FDmulti.c H5FDsec2.c H5FDspace.c H5FDstdio.c H5FDtest.c \
H5FL.c H5FO.c H5FS.c H5FScache.c H5FSdbg.c H5FSint.c H5FSsection.c \
H5FSstat.c H5FStest.c \