summaryrefslogtreecommitdiffstats
path: root/src/H5Pfapl.c
diff options
context:
space:
mode:
authorVailin Choi <vchoi@jam.ad.hdfgroup.org>2018-08-14 18:21:00 (GMT)
committerVailin Choi <vchoi@jam.ad.hdfgroup.org>2018-08-14 18:21:00 (GMT)
commit45be06a387c1294fa3c95cc71106afcc023ddb91 (patch)
tree3043133c78a523d02f2671710318046afe29d8b7 /src/H5Pfapl.c
parentce1e8162959b14b97d79b53ebf4bea77e2e871b2 (diff)
downloadhdf5-45be06a387c1294fa3c95cc71106afcc023ddb91.zip
hdf5-45be06a387c1294fa3c95cc71106afcc023ddb91.tar.gz
hdf5-45be06a387c1294fa3c95cc71106afcc023ddb91.tar.bz2
Preliminary checkins for implementation done so far:
1) Public routines: H5Pget/set_vfd_swmr_config 2) Public routine: H5Fvfd_swmr_end_tick 3) Initialization when opening a file with VFD SWMR writer 4) Tests in test/vfd_swmr.c for VFD SWMR 5) Fix a bug in src/H5Fint.c: when error is encountered after the root group is created Note the following: --This is WORK IN PROGRESS and will subject to change as implementation goes. --There is test failure form enc_dec_plist.c: I will fix this when changes to the property list are settled. --The branch is updated with the latest from develop as of 8/14/2018
Diffstat (limited to 'src/H5Pfapl.c')
-rw-r--r--src/H5Pfapl.c213
1 files changed, 213 insertions, 0 deletions
diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c
index 7ba9c11..a0291e6 100644
--- a/src/H5Pfapl.c
+++ b/src/H5Pfapl.c
@@ -259,6 +259,11 @@
#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_ENC H5P__encode_unsigned
#define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEC H5P__decode_unsigned
+/* Definitions for the VFD SWMR configuration */
+#define H5F_ACS_VFD_SWMR_CONFIG_SIZE sizeof(H5F_vfd_swmr_config_t)
+#define H5F_ACS_VFD_SWMR_CONFIG_DEF H5F__DEFAULT_VFD_SWMR_CONFIG
+#define H5F_ACS_VFD_SWMR_CONFIG_ENC H5P__facc_vfd_swmr_config_enc
+#define H5F_ACS_VFD_SWMR_CONFIG_DEC H5P__facc_vfd_swmr_config_dec
/******************/
/* Local Typedefs */
@@ -306,6 +311,8 @@ static herr_t H5P__facc_multi_type_enc(const void *value, void **_pp, size_t *si
static herr_t H5P__facc_multi_type_dec(const void **_pp, void *value);
static herr_t H5P__facc_libver_type_enc(const void *value, void **_pp, size_t *size);
static herr_t H5P__facc_libver_type_dec(const void **_pp, void *value);
+static herr_t H5P__facc_vfd_swmr_config_enc(const void *value, void **_pp, size_t *size);
+static herr_t H5P__facc_vfd_swmr_config_dec(const void **_pp, void *value);
/* Metadata cache log location property callbacks */
static herr_t H5P_facc_mdc_log_location_enc(const void *value, void **_pp, size_t *size);
@@ -398,6 +405,8 @@ static const size_t H5F_def_page_buf_size_g = H5F_ACS_PAGE_BUFFER_SIZE_DEF;
static const unsigned H5F_def_page_buf_min_meta_perc_g = H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEF; /* Default page buffer minimum metadata size */
static const unsigned H5F_def_page_buf_min_raw_perc_g = H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEF; /* Default page buffer mininum raw data size */
+static const H5F_vfd_swmr_config_t *H5F_def_vfd_swmr_config_g = H5F_ACS_VFD_SWMR_CONFIG_DEF; /* Default vfd swmr configuration */
+
/*-------------------------------------------------------------------------
* Function: H5P__facc_reg_prop
@@ -644,6 +653,12 @@ H5P__facc_reg_prop(H5P_genclass_t *pclass)
NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+ /* Register the default VFD SWMR configuration */
+ if(H5P_register_real(pclass, H5F_ACS_VFD_SWMR_CONFIG_NAME, H5F_ACS_VFD_SWMR_CONFIG_SIZE, &H5F_def_vfd_swmr_config_g,
+ NULL, NULL, NULL, H5F_ACS_VFD_SWMR_CONFIG_ENC, H5F_ACS_VFD_SWMR_CONFIG_DEC,
+ NULL, NULL, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P__facc_reg_prop() */
@@ -3643,6 +3658,7 @@ H5P__facc_cache_config_dec(const void **_pp, void *_value)
enc_size = *(*pp)++;
HDassert(enc_size < 256);
UINT64DECODE_VAR(*pp, enc_value, enc_size);
+
config->max_size = (size_t)enc_value;
enc_size = *(*pp)++;
@@ -3927,6 +3943,105 @@ H5P__facc_libver_type_dec(const void **_pp, void *_value)
/*-------------------------------------------------------------------------
+ * Function: H5P__facc_vfd_swmr_config_enc
+ *
+ * Purpose: Callback routine which is called whenever the VFD SWMR config
+ * property in the file access property list is encoded.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Vailin Choi; July 2018
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5P__facc_vfd_swmr_config_enc(const void *value, void **_pp, size_t *size)
+{
+ const H5F_vfd_swmr_config_t *config = (const H5F_vfd_swmr_config_t *)value; /* Create local aliases for values */
+ uint8_t **pp = (uint8_t **)_pp;
+
+ FUNC_ENTER_STATIC_NOERR
+
+ /* Sanity check */
+ HDassert(value);
+ HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t));
+
+ if(NULL != *pp) {
+
+ /* int */
+ INT32ENCODE(*pp, (int32_t)config->version);
+ INT32ENCODE(*pp, (int32_t)config->tick_len);
+ INT32ENCODE(*pp, (int32_t)config->max_lag);
+ H5_ENCODE_UNSIGNED(*pp, config->vfd_swmr_writer);
+ H5_ENCODE_UNSIGNED(*pp, config->flush_raw_data);
+ INT32ENCODE(*pp, (int32_t)config->md_pages_reserved);
+ HDmemcpy(*pp, (const uint8_t *)(config->md_file_path), (size_t)(H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1));
+ *pp += H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1;
+ HDmemcpy(*pp, (const uint8_t *)(config->log_file_path), (size_t)(H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1));
+ *pp += H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1;
+
+ } /* end if */
+
+ /* Compute encoded size */
+ *size += ( (4 * sizeof(int32_t)) + sizeof(unsigned) +
+ (2 * (H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1)) );
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5P__facc_vfd_swmr_config_enc() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5P__facc_vfd_swmr_config_dec
+ *
+ * Purpose: Callback routine which is called whenever the VFD SWMR
+ * config property in the file access property list is decoded.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Vailin Choi; July 2018
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5P__facc_vfd_swmr_config_dec(const void **_pp, void *_value)
+{
+ H5F_vfd_swmr_config_t *config = (H5F_vfd_swmr_config_t *)_value;
+ const uint8_t **pp = (const uint8_t **)_pp;
+
+ FUNC_ENTER_STATIC_NOERR
+
+ /* Sanity checks */
+ HDassert(pp);
+ HDassert(*pp);
+ HDassert(config);
+ HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t));
+
+ /* Set property to default value */
+ HDmemcpy(config, &H5F_def_vfd_swmr_config_g, sizeof(H5F_vfd_swmr_config_t));
+
+ /* int */
+ INT32DECODE(*pp, config->version);
+ INT32DECODE(*pp, config->tick_len);
+ INT32DECODE(*pp, config->max_lag);
+
+ H5_DECODE_UNSIGNED(*pp, config->vfd_swmr_writer);
+ H5_DECODE_UNSIGNED(*pp, config->flush_raw_data);
+
+ /* int */
+ INT32DECODE(*pp, config->md_pages_reserved);
+
+ HDstrcpy(config->md_file_path, (const char *)(*pp));
+ *pp += H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1;
+
+ HDstrcpy(config->log_file_path, (const char *)(*pp));
+ *pp += H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1;
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5P__facc_vfd_swmr_config_dec() */
+
+/*-------------------------------------------------------------------------
* Function: H5Pset_core_write_tracking
*
* Purpose: Enables/disables core VFD write tracking and page
@@ -4939,3 +5054,101 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Pget_page_buffer_size() */
+/*-------------------------------------------------------------------------
+ * Function: H5Pset_vfd_swmr_config
+ *
+ * Purpose: Set VFD SWMR configuration in the target FAPL.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Vailin Choi; July 2018
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Pset_vfd_swmr_config(hid_t plist_id, H5F_vfd_swmr_config_t *config_ptr)
+{
+ H5P_genplist_t *plist; /* Property list pointer */
+ size_t name_len;
+ herr_t ret_value = SUCCEED; /* return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE2("e", "i*x", plist_id, config_ptr);
+
+ /* Get the plist structure */
+ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
+
+ /* Validate the input configuration */
+
+ /* Check args */
+ if(config_ptr == NULL)
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "NULL config_ptr on entry")
+
+ /* This field must always be set to a known version */
+ if(config_ptr->version != H5F__CURR_VFD_SWMR_CONFIG_VERSION)
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "Unknown config version")
+
+ /* This field must be >= 0 */
+ if(config_ptr->tick_len < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "tick_len must be greater than 0")
+
+ /* This field must be at least 3 */
+ if(config_ptr->max_lag < 3 )
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "max_lag must be at least 3")
+
+ /* This field must be >= 1 */
+ if(config_ptr->md_pages_reserved < 1 )
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "md_pages_reserved must be at least 1")
+
+ /* Must provide the path for the metadata file */
+ name_len = HDstrlen(config_ptr->md_file_path);
+ if(name_len == 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "md_file_path is empty")
+ else if(name_len > H5F__MAX_VFD_SWMR_FILE_NAME_LEN)
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "md_file_path is too long")
+
+ /* Set the modified config */
+ if(H5P_set(plist, H5F_ACS_VFD_SWMR_CONFIG_NAME, config_ptr) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set metadata cache initial config")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* H5Pset_vfd_swmr_config() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Pget_vfd_swmr_config
+ *
+ * Purpose: Retrieve the VFD SWMR configuration from the target FAPL.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Vailin Choi; July 2018
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Pget_vfd_swmr_config(hid_t plist_id, H5F_vfd_swmr_config_t *config_ptr)
+{
+ H5P_genplist_t *plist; /* Property list pointer */
+ herr_t ret_value = SUCCEED; /* return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE2("e", "i*x", plist_id, config_ptr);
+
+ /* Get the plist structure */
+ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
+
+ /* Validate the config_ptr */
+ if(config_ptr == NULL)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL config_ptr on entry.")
+
+ /* Get the current VFD SWMR configuration */
+ if(H5P_get(plist, H5F_ACS_VFD_SWMR_CONFIG_NAME, config_ptr) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get VFD SWMR config")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* H5Pget_vfd_swmr_config() */