summaryrefslogtreecommitdiffstats
path: root/src/H5Fvfd_swmr.c
diff options
context:
space:
mode:
authorvchoi <vchoi@jelly.ad.hdfgroup.org>2022-06-03 19:09:32 (GMT)
committervchoi <vchoi@jelly.ad.hdfgroup.org>2022-06-03 19:09:32 (GMT)
commitc766dc8d884a51a9e11af8627ecd3134c566b230 (patch)
treeb77f61f513ec2332059bc8048e6ce1af6af00d1b /src/H5Fvfd_swmr.c
parent54fdbd3af2102353ed3403754f54274839127f25 (diff)
downloadhdf5-c766dc8d884a51a9e11af8627ecd3134c566b230.zip
hdf5-c766dc8d884a51a9e11af8627ecd3134c566b230.tar.gz
hdf5-c766dc8d884a51a9e11af8627ecd3134c566b230.tar.bz2
Merge in VFD SWMR changes by John Mainzer.
Commit log message from John: Returned VFD SWMR to using the VFD SWMR reader VFD only in the reader case. In passing, added a private VFD SWMR reader VFD fapl entry that is pushed and popped off the FAPL during file open, and removed the code that set the VFD SWMR reader VFD as the driver in the FAPL when VFD SWMR is configured. This was necessary, as there is no mechanism to prevent the user from overwriting this entry on the FAPL before file open. While we don't use it now, it also gives us a mechanism for allowing the user to specify an underlying VFD for VFD SWMR. Modified code to compare file opens to compare the terminal VFDs, not the top level VFDs. Failure to do this allowed multiple opens of the same file with the same VFD but with different pass through VFDs to appear to be treated as different files -- with the obvious file corruption issues. To support this, added a new VFD ctl op code to return a pointer to the instance of H5FD_t associated with the terminal VFD. Note that this change does not address the case of the same file being opened twice with different terminal VFDs -- that will have to be addressed another day. Overview of major changes from John: 1) Reworked file open so that the VFD SWMR reader VFD is only used when a file is opened VFD SWMR reader. This required the following changes: a) Removed code to set the driver in H5Pset_vfd_swmr_config() b) Added a private fapl entry for the VFD SWMR reader VFD c) Modified H5F_open to test for VFD SWMR reader opens, and push the vfd swmr reader vfd FAPL entry on the VFD stack if so. In this case the entry is popped off the VFD stack on exit so as to avoid any net modification from the supplied FAPL. 2) Removed dedup code, and augmented H5FD_cmp() to provide the necessary functionality. This required the following changes: a) Added the get terminal VFD op code to the H5FD ctl call. This allows duplicate file opens with the same VFD but different overlying pass through VFDs to be recognized. Updated ctl callback in VFDs as required to support the new op code. b) Modified H5FD_cmp to use the above ctl op code to allow it to recognize duplicate file opens with the same VFD but with different overlying passthoguh VFDs. This is necessary to recognize duplicate VFD SWMR reader and regular opens. Note that this does not allow us to recognize duplicate opens with different terminal VFDs.
Diffstat (limited to 'src/H5Fvfd_swmr.c')
-rw-r--r--src/H5Fvfd_swmr.c75
1 files changed, 71 insertions, 4 deletions
diff --git a/src/H5Fvfd_swmr.c b/src/H5Fvfd_swmr.c
index 9c4360e..0e24804 100644
--- a/src/H5Fvfd_swmr.c
+++ b/src/H5Fvfd_swmr.c
@@ -49,8 +49,9 @@
/* Local Macros */
/****************/
-#define NANOSECS_PER_SECOND 1000000000 /* nanoseconds per second */
-#define NANOSECS_PER_TENTH_SEC 100000000 /* nanoseconds per 0.1 second */
+#define VFD_SWMR_MD_FILE_SUFFIX ".md"
+#define NANOSECS_PER_SECOND 1000000000 /* nanoseconds per second */
+#define NANOSECS_PER_TENTH_SEC 100000000 /* nanoseconds per 0.1 second */
/* Declare an array of string to identify the VFD SMWR Log tags.
* Note this array is used to generate the entry tag by the log reporting macro
@@ -186,8 +187,13 @@ H5F_vfd_swmr_init(H5F_t *f, hbool_t file_create)
shared->vfd_swmr_writer = TRUE;
shared->tick_num = 0;
- /* 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);
+ /* Allocate space for the (possibly constructed) metadata file name */
+ if (NULL == (shared->md_file_path_name = H5MM_calloc((H5FD_MAX_FILENAME_LEN + 1) * sizeof(char))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate memory for mdc log file name")
+
+ if ( H5F_vfd_swmr_build_md_path_name(&(shared->vfd_swmr_config), f->open_name,
+ shared->md_file_path_name) < 0 )
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to build metadata file 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)
@@ -281,6 +287,67 @@ done:
} /* H5F_vfd_swmr_init() */
/*-------------------------------------------------------------------------
+ *
+ * Function: H5F_vfd_swmr_build_md_path_name
+ *
+ * Purpose: To construct the metadata file's full name based on config's
+ * md_file_path and md_file_name. See RFC for details.
+ *
+ *
+ * Return: Success: SUCCEED
+ * Failure: FAIL
+ *
+ * Programmer: Vailin Choi -- 1/13/2022
+ *
+ * Changes: Moved to H5Fvfd_swmr.c from H5FDvfd_swmr.c, and renamed
+ * accordingly. Changed FUNC_ENTER_PACKAGE to
+ * FUNC_ENTER_NOAPI. Converted to a private function so
+ * that it can be called in H5FDvfd_swmr.c
+ *
+ * JRM -- 5/17/22
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5F_vfd_swmr_build_md_path_name(H5F_vfd_swmr_config_t *config, const char *hdf5_filename,
+ char *name /*out*/)
+{
+ size_t tot_len = 0;
+ size_t tmp_len = 0;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ if ((tot_len = HDstrlen(config->md_file_path)) != 0) {
+
+ /* md_file_path + '/' */
+ if (++tot_len > H5F__MAX_VFD_SWMR_FILE_NAME_LEN)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "md_file_path and md_file_name exceeds maximum");
+ HDstrcat(name, config->md_file_path);
+ HDstrcat(name, "/");
+ }
+
+ if ((tmp_len = HDstrlen(config->md_file_name)) != 0) {
+ if ((tot_len += tmp_len) > H5F__MAX_VFD_SWMR_FILE_NAME_LEN)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "md_file_path and md_file_name exceeds maximum");
+ HDstrcat(name, config->md_file_name);
+ }
+ else {
+ /* Automatic generation of metadata file name based on hdf5_filename + '.md' */
+ if ((tot_len += (HDstrlen(hdf5_filename) + 3)) > H5F__MAX_VFD_SWMR_FILE_NAME_LEN)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "md_file_path and md_file_name maximum");
+
+ HDstrcat(name, hdf5_filename);
+ HDstrcat(name, VFD_SWMR_MD_FILE_SUFFIX);
+ }
+
+done:
+
+ FUNC_LEAVE_NOAPI(ret_value)
+
+} /* H5F_vfd_swmr_build_md_path_name() */
+
+/*-------------------------------------------------------------------------
* Function: H5F_vfd_swmr_close_or_flush
*
* Purpose: Used by the VFD SWMR writer when the HDF5 file is closed