summaryrefslogtreecommitdiffstats
path: root/src/H5Pfapl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Pfapl.c')
-rw-r--r--src/H5Pfapl.c92
1 files changed, 90 insertions, 2 deletions
diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c
index a416b00..adae24f 100644
--- a/src/H5Pfapl.c
+++ b/src/H5Pfapl.c
@@ -160,7 +160,11 @@
#define H5F_ACS_FILE_IMAGE_INFO_DEL H5P_file_image_info_del
#define H5F_ACS_FILE_IMAGE_INFO_COPY H5P_file_image_info_copy
#define H5F_ACS_FILE_IMAGE_INFO_CLOSE H5P_file_image_info_close
-
+/* Definition for # of read attempts */
+#define H5F_ACS_READ_ATTEMPTS_SIZE sizeof(unsigned)
+#define H5F_ACS_READ_ATTEMPTS_DEF 0
+#define H5F_ACS_READ_ATTEMPTS_ENC H5P__encode_unsigned
+#define H5F_ACS_READ_ATTEMPTS_DEC H5P__decode_unsigned
/******************/
/* Local Typedefs */
@@ -247,7 +251,7 @@ static const hbool_t H5F_def_latest_format_g = H5F_ACS_LATEST_FORMAT_DEF;
static const hbool_t H5F_def_want_posix_fd_g = H5F_ACS_WANT_POSIX_FD_DEF; /* Default setting for retrieving 'handle' from core VFD */
static const unsigned H5F_def_efc_size_g = H5F_ACS_EFC_SIZE_DEF; /* Default external file cache size */
static const H5FD_file_image_info_t H5F_def_file_image_info_g = H5F_ACS_FILE_IMAGE_INFO_DEF; /* Default file image info and callbacks */
-
+static const unsigned H5F_def_read_attempts_g = H5F_ACS_READ_ATTEMPTS_DEF; /* Default setting for the # of read attempts */
/*-------------------------------------------------------------------------
@@ -397,6 +401,11 @@ H5P_facc_reg_prop(H5P_genclass_t *pclass)
H5F_ACS_FILE_IMAGE_INFO_DEL, H5F_ACS_FILE_IMAGE_INFO_COPY, NULL, H5F_ACS_FILE_IMAGE_INFO_CLOSE) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+ /* Register the # of read attempts */
+ if(H5P_register_real(pclass, H5F_ACS_READ_ATTEMPTS_NAME, H5F_ACS_READ_ATTEMPTS_SIZE, &H5F_def_read_attempts_g,
+ NULL, NULL, NULL, H5F_ACS_READ_ATTEMPTS_ENC, H5F_ACS_READ_ATTEMPTS_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() */
@@ -2980,3 +2989,82 @@ H5P__facc_multi_type_dec(const void **_pp, void *_value)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5P__facc_multi_type_dec() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5Pset_read_attempts
+ *
+ * Purpose: Sets the # of read attempts in the file access property list
+ * when reading metadata with checksum.
+ * The # of read attempts set via this routine will apply only
+ * when opening file with SWMR access. When opening file with
+ * non-SWMR access, the # of read attempts will always be 1.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Vailin Choi; Sept 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Pset_read_attempts(hid_t plist_id, unsigned attempts)
+{
+ H5P_genplist_t *plist; /* Property list pointer */
+ herr_t ret_value = SUCCEED; /* return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE2("e", "iIu", plist_id, attempts);
+
+ /* Cannot set the # of attempts to 0 */
+ if(attempts <= 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "number of attempts must be greater than 0");
+
+ /* 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")
+
+ /* Set values */
+ if(H5P_set(plist, H5F_ACS_READ_ATTEMPTS_NAME, &attempts) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set # of read attempts")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* H5Pset_read_attempts() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Pget_read_attempts
+ *
+ * Purpose: Returns the # of read attempts set in the file access property list.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Vailin Choi; Sept 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Pget_read_attempts(hid_t plist_id, unsigned *attempts/*out*/)
+{
+ H5P_genplist_t *plist; /* Property list pointer */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE2("e", "ix", plist_id, attempts);
+
+ /* 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")
+
+ /* Get values */
+ if(attempts) {
+ /* Get the # of read attempts set */
+ if(H5P_get(plist, H5F_ACS_READ_ATTEMPTS_NAME, attempts) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get alignment")
+ /* If not set, return the default value */
+ if(*attempts == H5F_ACS_READ_ATTEMPTS_DEF) /* 0 */
+ *attempts = H5F_READ_ATTEMPTS;
+ }
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Pget_read_attempts() */