summaryrefslogtreecommitdiffstats
path: root/src/H5Fvfd_swmr.c
diff options
context:
space:
mode:
authorvchoi <vchoi@jelly.ad.hdfgroup.org>2022-04-21 18:56:59 (GMT)
committervchoi <vchoi@jelly.ad.hdfgroup.org>2022-04-21 18:56:59 (GMT)
commit3e990fed8edb25df58d79097f7cef9b908ef5a0d (patch)
tree62a45e418e2a5aebfc3004115b00aff63a248c7a /src/H5Fvfd_swmr.c
parentff8f512871b72e80c6d602d1539ae70072e18abb (diff)
downloadhdf5-3e990fed8edb25df58d79097f7cef9b908ef5a0d.zip
hdf5-3e990fed8edb25df58d79097f7cef9b908ef5a0d.tar.gz
hdf5-3e990fed8edb25df58d79097f7cef9b908ef5a0d.tar.bz2
Modifications to:
A) Allow automatic generation of metadata file names for VDS support B) Allow VFD SWMR reader to open an existing HDF5 file either before the VFD SWMR writer has opened it or after it has closed. C) Remove the usage of H5P_FILE_ACCESS_ANY_VFD. D) Add H5FD_FEAT_SUPPORTS_VFD_SWMR feature flag. E) Do not map H5FD_MEM_GHEAP to H5FD_MEM_DRAW when vfd swmr IS enabled; map H5FD_MEM_GHEAP to H5FD_MEM_DRAW when vfd swmr is NOT enabled. For details regarding #A and #B above, see version 9 of the RFC.
Diffstat (limited to 'src/H5Fvfd_swmr.c')
-rw-r--r--src/H5Fvfd_swmr.c59
1 files changed, 50 insertions, 9 deletions
diff --git a/src/H5Fvfd_swmr.c b/src/H5Fvfd_swmr.c
index cd3a345..fce5e88 100644
--- a/src/H5Fvfd_swmr.c
+++ b/src/H5Fvfd_swmr.c
@@ -186,8 +186,10 @@ H5F_vfd_swmr_init(H5F_t *f, hbool_t file_create)
shared->vfd_swmr_writer = TRUE;
shared->tick_num = 0;
- /* Create the metadata file */
- if (((shared->vfd_swmr_md_fd = HDopen(shared->vfd_swmr_config.md_file_path,
+ /* Retrieve the metadata filename built with md_file_path and md_file_name */
+ H5FD_vfd_swmr_get_md_path_name(f->shared->lf, &shared->md_file_path_name);
+
+ if (((shared->vfd_swmr_md_fd = HDopen(shared->md_file_path_name,
O_CREAT | O_RDWR | O_TRUNC, H5_POSIX_CREATE_MODE_RW))) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to create the metadata file")
@@ -215,7 +217,7 @@ H5F_vfd_swmr_init(H5F_t *f, hbool_t file_create)
/* For VFD SWMR testing: invoke callback if set to generate metadata file checksum */
if (shared->generate_md_ck_cb) {
- if (shared->generate_md_ck_cb(shared->vfd_swmr_config.md_file_path, shared->updater_seq_num) < 0)
+ if (shared->generate_md_ck_cb(shared->md_file_path_name, shared->updater_seq_num) < 0)
HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "error from generate_md_ck_cb()")
}
@@ -331,14 +333,16 @@ H5F_vfd_swmr_close_or_flush(H5F_t *f, hbool_t closing)
/* For VFD SWMR testing: invoke callback if set to generate metadata file checksum */
if (shared->generate_md_ck_cb) {
- if (shared->generate_md_ck_cb(shared->vfd_swmr_config.md_file_path, shared->updater_seq_num) < 0)
+ if (shared->generate_md_ck_cb(shared->md_file_path_name, shared->updater_seq_num) < 0)
HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "error from generate_md_ck_cb()")
}
/* Unlink the md file */
- if (HDunlink(shared->vfd_swmr_config.md_file_path) < 0)
+ if (HDunlink(shared->md_file_path_name) < 0)
HSYS_GOTO_ERROR(H5E_FILE, H5E_CANTREMOVE, FAIL, "unable to unlink the metadata file")
+ shared->md_file_path_name = (char *)H5MM_xfree(shared->md_file_path_name);
+
/* Close the free-space manager for the metadata file */
if (H5MV_close(f) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL,
@@ -571,7 +575,7 @@ H5F_update_vfd_swmr_metadata_file(H5F_t *f, uint32_t num_entries, H5FD_vfd_swmr_
/* For VFD SWMR testing: invoke callback if set to generate metadata file checksum */
if (shared->generate_md_ck_cb) {
- if (shared->generate_md_ck_cb(shared->vfd_swmr_config.md_file_path, shared->updater_seq_num) < 0)
+ if (shared->generate_md_ck_cb(shared->md_file_path_name, shared->updater_seq_num) < 0)
HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "error from generate_md_ck_cb()")
}
@@ -1031,6 +1035,14 @@ H5F_vfd_swmr_writer_dump_index(H5F_shared_t *shared)
* 9) Increment the tick, and update the end of tick.
*
* Return: SUCCEED/FAIL
+ *
+ * Programmer: John Mainzer 12/29/18
+ *
+ * Changes:
+ * VDS changes: Check make_believe whether to continue the same or
+ * get out of make_believe and load header/index.
+ * For details, see RFC for VDS changes.
+ *
*-------------------------------------------------------------------------
*/
herr_t
@@ -1053,6 +1065,7 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, hbool_t entering_api)
herr_t ret_value = SUCCEED;
uint32_t i, j, nchanges;
H5FD_t * file = shared->lf;
+ htri_t ret;
FUNC_ENTER_NOAPI(FAIL)
@@ -1071,9 +1084,34 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, hbool_t entering_api)
* so as to detect the need to allocate more space for the
* index.
*/
- if (H5FD_vfd_swmr_get_tick_and_idx(file, TRUE, &tmp_tick_num, &vfd_entries, NULL) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "error in retrieving tick_num from driver")
+ /* Check if make_believe is set */
+ if(H5FD_vfd_swmr_get_make_believe(file)) {
+
+ /* Return value is TRUE: metadata file is not found, continue with make_believe
+ and skip eot processing */
+ if((ret = H5FD_vfd_swmr_assess_make_believe(file)) == TRUE) {
+ /* Skip most of the EOT processing */
+ goto reader_update_eot;
+ } else if (ret == FAIL)
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "error in assessing make_believe from driver")
+
+ /* Return value is FALSE i.e. found the metadata file */
+ HDassert(!ret);
+
+ /* Try to load the metadata file header and index */
+ if (H5FD_vfd_swmr_get_tick_and_idx(file, TRUE, &tmp_tick_num, &vfd_entries, NULL) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "error in retrieving tick_num from driver")
+
+ /* Set make_believe to FALSE;
+ get out from make_believe state, continue normal processing */
+ H5FD_vfd_swmr_set_make_believe(file, FALSE);
+
+ } else {
+ /* make_believe is not set, continue normal processing */
+ if (H5FD_vfd_swmr_get_tick_and_idx(file, TRUE, &tmp_tick_num, &vfd_entries, NULL) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "error in retrieving tick_num from driver")
+ }
/* This is ok if we're entering the API, but it should
* not happen if we're exiting the API.
@@ -1288,6 +1326,8 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, hbool_t entering_api)
}
}
+reader_update_eot:
+
/* Remove the entry from the EOT queue */
if (H5F_vfd_swmr_remove_entry_eot(f) < 0)
HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to remove entry from EOT queue")
@@ -2305,7 +2345,8 @@ H5F__generate_updater_file(H5F_t *f, uint32_t num_entries, uint16_t flags, uint8
if (sz > H5F__MAX_VFD_SWMR_FILE_NAME_LEN)
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "string passed to snprintf would be truncated")
newname[H5F__MAX_VFD_SWMR_FILE_NAME_LEN - 1] = '\0';
- HDrename(namebuf, newname);
+ if (HDrename(namebuf, newname) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "error from renaming the updater file")
++shared->updater_seq_num;