summaryrefslogtreecommitdiffstats
path: root/src/H5Fsuper.c
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2019-06-26 15:47:31 (GMT)
committerVailin Choi <vchoi@jam.ad.hdfgroup.org>2019-07-22 19:52:43 (GMT)
commit00a546ec57edd319d95baea088ab0f9fb7b722b5 (patch)
treec181579c0be6fa120f81671e5955b479e1a3aa7d /src/H5Fsuper.c
parentf4e2304bad527b57d6edcb7136e69ac7ba70cebf (diff)
downloadhdf5-00a546ec57edd319d95baea088ab0f9fb7b722b5.zip
hdf5-00a546ec57edd319d95baea088ab0f9fb7b722b5.tar.gz
hdf5-00a546ec57edd319d95baea088ab0f9fb7b722b5.tar.bz2
Bring pull request #1772 from develop to 1.10.
Fails file creation when non-default free-space info is set in fcpl and the library version high bound is less than v110 because free-space info message is introduced in library release v110. Merge pull request #1772 in HDFFV/hdf5 from ~VCHOI/my_third_fork:bugfix/HDFFV-10808-h5pset_file_space_strategy-succeeds to develop * commit '3768566139df18928aa29ece0eff3010b224633b': Add release notes. Correct hid_t error value to H5I_INVALID_HID in tests related to libver_bounds. Fix for HDFFV-10808 H5Pset_file_space_strategy succeeds when using H5Pset_libver_bounds v18,v18. Fails file creation when non-default free-space info is set in fcpl and the library version high bound is less than v110 because free-space info message is introduced in library release v110. Conflicts: test/tfile.c
Diffstat (limited to 'src/H5Fsuper.c')
-rw-r--r--src/H5Fsuper.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c
index 9339b3d..8d165ec 100644
--- a/src/H5Fsuper.c
+++ b/src/H5Fsuper.c
@@ -79,6 +79,15 @@ static const unsigned HDF5_superblock_ver_bounds[] = {
HDF5_SUPERBLOCK_VERSION_LATEST /* H5F_LIBVER_LATEST */
};
+/* Format version bounds for fsinfo message */
+/* This message exists starting library release v1.10 */
+static const unsigned H5O_fsinfo_ver_bounds[] = {
+ H5O_INVALID_VERSION, /* H5F_LIBVER_EARLIEST */
+ H5O_INVALID_VERSION, /* H5F_LIBVER_V18 */
+ H5O_FSINFO_VERSION_1, /* H5F_LIBVER_V110 */
+ H5O_FSINFO_VERSION_LATEST /* H5F_LIBVER_LATEST */
+};
+
/*-------------------------------------------------------------------------
* Function: H5F__super_ext_create
@@ -784,6 +793,14 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get free-space manager info message")
/* Update changed values */
+
+ /* Version bounds check */
+ if(H5O_fsinfo_ver_bounds[H5F_HIGH_BOUND(f)] == H5O_INVALID_VERSION ||
+ fsinfo.version > H5O_fsinfo_ver_bounds[H5F_HIGH_BOUND(f)])
+ HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, FAIL, "File space info message's version out of bounds")
+ if(f->shared->fs_version != fsinfo.version)
+ f->shared->fs_version = fsinfo.version;
+
if(f->shared->fs_strategy != fsinfo.strategy) {
f->shared->fs_strategy = fsinfo.strategy;
@@ -1376,6 +1393,11 @@ H5F__super_init(H5F_t *f)
fsinfo.eoa_pre_fsm_fsalloc = HADDR_UNDEF;
fsinfo.mapped = FALSE;
+ /* Set the version for the fsinfo message */
+ if(H5O__fsinfo_set_version(f, &fsinfo) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set version of fsinfo")
+ f->shared->fs_version = fsinfo.version;
+
for(ptype = H5F_MEM_PAGE_SUPER; ptype < H5F_MEM_PAGE_NTYPES; H5_INC_ENUM(H5F_mem_page_t, ptype))
fsinfo.fs_addr[ptype - 1] = HADDR_UNDEF;
@@ -1800,3 +1822,44 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5F__super_ext_remove_msg() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5O__fsinfo_set_version
+ *
+ * Purpose: Set the version to encode the fsinfo message with.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Vailin Choi; June 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O__fsinfo_set_version(H5F_t *f, H5O_fsinfo_t *fsinfo)
+{
+ unsigned version; /* Message version */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Sanity check */
+ HDassert(f);
+ HDassert(fsinfo);
+
+ version = H5O_FSINFO_VERSION_1;
+
+ /* Upgrade to the version indicated by the file's low bound if higher */
+ if(H5O_fsinfo_ver_bounds[H5F_LOW_BOUND(f)] != H5O_INVALID_VERSION)
+ version = MAX(version, H5O_fsinfo_ver_bounds[H5F_LOW_BOUND(f)]);
+
+ /* Version bounds check */
+ if(H5O_fsinfo_ver_bounds[H5F_HIGH_BOUND(f)] == H5O_INVALID_VERSION ||
+ version > H5O_fsinfo_ver_bounds[H5F_HIGH_BOUND(f)])
+ HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "File space info message's version out of bounds")
+
+ /* Set the message version */
+ fsinfo->version = version;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O__fsinfo_set_version() */