From d9653606d8b38689c7f4d0c757753b8acc378a04 Mon Sep 17 00:00:00 2001 From: Vailin Choi Date: Mon, 24 Jun 2019 18:00:02 -0500 Subject: 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. --- src/H5Fpkg.h | 3 + src/H5Fsuper.c | 64 +++++++++++++ src/H5MF.c | 3 + src/H5Ofsinfo.c | 10 +- src/H5Oprivate.h | 12 +++ test/tfile.c | 286 +++++++++++++++++++++++++++++++------------------------ 6 files changed, 249 insertions(+), 129 deletions(-) diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 335d0a7..6c1156f 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -318,6 +318,9 @@ struct H5F_file_t { H5F_fspace_strategy_t fs_strategy; /* File space handling strategy */ hsize_t fs_threshold; /* Free space section threshold */ hbool_t fs_persist; /* Free-space persist or not */ + unsigned fs_version; /* Free-space version: */ + /* It is used to update fsinfo message in the superblock + extension when closing down the free-space managers */ hbool_t use_tmp_space; /* Whether temp. file space allocation is allowed */ haddr_t tmp_addr; /* Next address to use for temp. space in the file */ hbool_t point_of_no_return; /* Flag to indicate that we can't go back and delete a freespace header when it's used up */ diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index ef52844..7d90df1 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -80,6 +80,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 @@ -782,6 +791,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; @@ -1375,6 +1392,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; @@ -1801,3 +1823,45 @@ 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() */ diff --git a/src/H5MF.c b/src/H5MF.c index 0d368d4..8d7ab96 100644 --- a/src/H5MF.c +++ b/src/H5MF.c @@ -1835,6 +1835,7 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); fsinfo.page_size = f->shared->fs_page_size; fsinfo.pgend_meta_thres = f->shared->pgend_meta_thres; fsinfo.eoa_pre_fsm_fsalloc = f->shared->eoa_pre_fsm_fsalloc; + fsinfo.version = f->shared->fs_version; /* Write the free space manager message -- message must already exist */ if(H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, FALSE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) @@ -1973,6 +1974,8 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); fsinfo.page_size = f->shared->fs_page_size; fsinfo.pgend_meta_thres = f->shared->pgend_meta_thres; fsinfo.eoa_pre_fsm_fsalloc = HADDR_UNDEF; + fsinfo.version = f->shared->fs_version; + for(ptype = H5F_MEM_PAGE_META; ptype < H5F_MEM_PAGE_NTYPES; H5_INC_ENUM(H5F_mem_page_t, ptype)) fsinfo.fs_addr[ptype - 1] = HADDR_UNDEF; diff --git a/src/H5Ofsinfo.c b/src/H5Ofsinfo.c index bb15f62..ec2328c 100644 --- a/src/H5Ofsinfo.c +++ b/src/H5Ofsinfo.c @@ -65,10 +65,6 @@ const H5O_msg_class_t H5O_MSG_FSINFO[1] = {{ H5O__fsinfo_debug /* debug the message */ }}; -/* Current version of free-space manager info information */ -#define H5O_FSINFO_VERSION_0 0 -#define H5O_FSINFO_VERSION_1 1 - /* Declare a free list to manage the H5O_fsinfo_t struct */ H5FL_DEFINE_STATIC(H5O_fsinfo_t); @@ -157,11 +153,13 @@ H5O_fsinfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file space strategy") } /* end switch */ + fsinfo->version = H5O_FSINFO_VERSION_1; fsinfo->mapped = TRUE; } else { - HDassert(vers == H5O_FSINFO_VERSION_1); + HDassert(vers >= H5O_FSINFO_VERSION_1); + fsinfo->version = vers; fsinfo->strategy = (H5F_fspace_strategy_t)*p++; /* File space strategy */ fsinfo->persist = *p++; /* Free-space persist or not */ H5F_DECODE_LENGTH(f, p, fsinfo->threshold); /* Free-space section threshold */ @@ -214,7 +212,7 @@ H5O_fsinfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, c HDassert(p); HDassert(fsinfo); - *p++ = H5O_FSINFO_VERSION_1; /* message version */ + *p++ = (uint8_t)fsinfo->version; /* message version */ *p++ = fsinfo->strategy; /* File space strategy */ *p++ = (unsigned char)fsinfo->persist; /* Free-space persist or not */ H5F_ENCODE_LENGTH(f, p, fsinfo->threshold); /* Free-space section size threshold */ diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 5987ecf..d143f31 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -804,6 +804,17 @@ typedef uint32_t H5O_refcount_t; /* Contains # of links to object, if >1 */ typedef unsigned H5O_unknown_t; /* Original message type ID */ +/* To indicate an invalid version for a message that does not exist yet for the release */ +/* Message version is 1 byte so the value can be 0 to 255 */ +#define H5O_INVALID_VERSION 256 + +/* The initial version of the fsinfo message: deprecated */ +/* This version is mapped to version 1 from release 1.10.1 onwards */ +#define H5O_FSINFO_VERSION_0 0 + +/* The latest version for fsinfo message */ +#define H5O_FSINFO_VERSION_1 1 +#define H5O_FSINFO_VERSION_LATEST H5O_FSINFO_VERSION_1 /* * File space info Message. * Contains file space management info and @@ -811,6 +822,7 @@ typedef unsigned H5O_unknown_t; /* Original message type ID */ * (Data structure in memory) */ typedef struct H5O_fsinfo_t { + unsigned version; /* Version number */ H5F_fspace_strategy_t strategy; /* File space strategy */ hbool_t persist; /* Persisting free-space or not */ hsize_t threshold; /* Free-space section threshold */ diff --git a/test/tfile.c b/test/tfile.c index c15064a..0dd0700 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -181,8 +181,8 @@ const char *FILESPACE_NAME[] = { /* Local test function declarations for version bounds */ static void test_libver_bounds_low_high(void); static void test_libver_bounds_super(hid_t fapl); -static void test_libver_bounds_super_create(hid_t fapl, hid_t fcpl, htri_t is_swmr); -static void test_libver_bounds_super_open(hid_t fapl, hid_t fcpl, htri_t is_swmr); +static void test_libver_bounds_super_create(hid_t fapl, hid_t fcpl, htri_t is_swmr, htri_t non_def_fsm); +static void test_libver_bounds_super_open(hid_t fapl, hid_t fcpl, htri_t is_swmr, htri_t non_def_fsm); static void test_libver_bounds_obj(hid_t fapl); static void test_libver_bounds_dataset(hid_t fapl); static void test_libver_bounds_dataspace(hid_t fapl); @@ -4819,7 +4819,7 @@ test_filespace_1_10_0_compatible(void) for(j = 0; j < NELMTS(OLD_1_10_0_FILENAME); j++) { /* Make a copy of the test file */ status = h5_make_local_copy(OLD_1_10_0_FILENAME[j], FILE5); - CHECK(status, FAIL, "h5_make_local_copy"); + CHECK(status, FAIL, "h5_make_local_copy"); /* Open the temporary test file */ fid = H5Fopen(FILE5, H5F_ACC_RDWR, H5P_DEFAULT); @@ -5583,13 +5583,13 @@ test_libver_bounds_super(hid_t fapl) /* Verify superblock version when creating a file with input fapl, fcpl #A and with/without SWMR access */ - test_libver_bounds_super_create(fapl, fcpl, TRUE); - test_libver_bounds_super_create(fapl, fcpl, FALSE); + test_libver_bounds_super_create(fapl, fcpl, TRUE, FALSE); + test_libver_bounds_super_create(fapl, fcpl, FALSE, FALSE); /* Verify superblock version when opening a file which is created with input fapl, fcpl #A and with/without SWMR access */ - test_libver_bounds_super_open(fapl, fcpl, TRUE); - test_libver_bounds_super_open(fapl, fcpl, FALSE); + test_libver_bounds_super_open(fapl, fcpl, TRUE, FALSE); + test_libver_bounds_super_open(fapl, fcpl, FALSE, FALSE); /* Close the fcpl */ ret = H5Pclose(fcpl); @@ -5604,13 +5604,13 @@ test_libver_bounds_super(hid_t fapl) /* Verify superblock version when creating a file with input fapl, fcpl #B and with/without SWMR access */ - test_libver_bounds_super_create(fapl, fcpl, TRUE); - test_libver_bounds_super_create(fapl, fcpl, FALSE); + test_libver_bounds_super_create(fapl, fcpl, TRUE, FALSE); + test_libver_bounds_super_create(fapl, fcpl, FALSE, FALSE); /* Verify superblock version when opening a file which is created with input fapl, fcpl #B and with/without SWMR access */ - test_libver_bounds_super_open(fapl, fcpl, TRUE); - test_libver_bounds_super_open(fapl, fcpl, FALSE); + test_libver_bounds_super_open(fapl, fcpl, TRUE, FALSE); + test_libver_bounds_super_open(fapl, fcpl, FALSE, FALSE); /* Close the fcpl */ ret = H5Pclose(fcpl); @@ -5627,13 +5627,13 @@ test_libver_bounds_super(hid_t fapl) /* Verify superblock version when creating a file with input fapl, fcpl #C and with/without SWMR access */ - test_libver_bounds_super_create(fapl, fcpl, TRUE); - test_libver_bounds_super_create(fapl, fcpl, FALSE); + test_libver_bounds_super_create(fapl, fcpl, TRUE, FALSE); + test_libver_bounds_super_create(fapl, fcpl, FALSE, FALSE); /* Verify superblock version when opening a file which is created with input fapl, fcpl #C and with/without SWMR access */ - test_libver_bounds_super_open(fapl, fcpl, TRUE); - test_libver_bounds_super_open(fapl, fcpl, FALSE); + test_libver_bounds_super_open(fapl, fcpl, TRUE, FALSE); + test_libver_bounds_super_open(fapl, fcpl, FALSE, FALSE); /* Close the fcpl */ ret = H5Pclose(fcpl); @@ -5648,13 +5648,13 @@ test_libver_bounds_super(hid_t fapl) /* Verify superblock version when creating a file with input fapl, fcpl #D and with/without SWMR access */ - test_libver_bounds_super_create(fapl, fcpl, TRUE); - test_libver_bounds_super_create(fapl, fcpl, FALSE); + test_libver_bounds_super_create(fapl, fcpl, TRUE, TRUE); + test_libver_bounds_super_create(fapl, fcpl, FALSE, TRUE); /* Verify superblock version when opening a file which is created with input fapl, fcpl #D and with/without SWMR access */ - test_libver_bounds_super_open(fapl, fcpl, TRUE); - test_libver_bounds_super_open(fapl, fcpl, FALSE); + test_libver_bounds_super_open(fapl, fcpl, TRUE, TRUE); + test_libver_bounds_super_open(fapl, fcpl, FALSE, TRUE); /* Close the fcpl */ ret = H5Pclose(fcpl); @@ -5666,8 +5666,8 @@ test_libver_bounds_super(hid_t fapl) /************************************************************************************************** ** ** test_libver_bounds_super_create(): -** Verify the following when the file is created with the input fapl, fcpl, and -** with/without SWMR access: +** Verify the following when the file is created with the input fapl, fcpl, +** and with/without SWMR access: ** (a) the superblock version # ** (b) the file's low bound setting ** (c) fail or succeed in creating the file @@ -5679,7 +5679,10 @@ test_libver_bounds_super(hid_t fapl) ** in the input fapl. The next three rows list the expected results for #a to #c. ** "-->" indicates "upgrade to" ** -** Creating a file with write access +** The last table lists the expected results in creating the file when non-default +** free-space info (fsinfo) is enabled in fcpl. +** +** Creating a file with write access ** -------------------------------------------------------------------------------- ** | (earliest, v18) | (earliest, v110) | (v18, v18) | (v18, v110) | (v110, v110) | ** |______________________________________________________________________________| @@ -5690,7 +5693,7 @@ test_libver_bounds_super(hid_t fapl) ** File creation | succeed | ** |______________________________________________________________________________| ** -** Creating a file with SWMR-write access +** Creating a file with SWMR-write access ** -------------------------------------------------------------------------------- ** | (earliest, v18) | (earliest, v110) | (v18, v18) | (v18, v110) | (v110, v110) | ** |______________________________________________________________________________| @@ -5698,12 +5701,19 @@ test_libver_bounds_super(hid_t fapl) ** |------------------------------------------------------------------------------| ** File's low bound | -- | ->v110 | -- | ->v110 | no change | ** |------------------------------------------------------------------------------| -** File creation | fail | succeed | fail | succeed | succed | +** File creation | fail | succeed | fail | succeed | succeed | +** |______________________________________________________________________________| +** +** Creating a file with write/SWMR-write access + non-default fsinfo +** -------------------------------------------------------------------------------- +** | (earliest, v18) | (earliest, v110) | (v18, v18) | (v18, v110) | (v110, v110) | +** |______________________________________________________________________________| +** File creation | fail | succeed | fail | succeed | succeed | ** |______________________________________________________________________________| ** ******************************************************************************************************/ static void -test_libver_bounds_super_create(hid_t fapl, hid_t fcpl, htri_t is_swmr) +test_libver_bounds_super_create(hid_t fapl, hid_t fcpl, htri_t is_swmr, htri_t non_def_fsm) { hid_t fid = -1; /* File ID */ H5F_t *f = NULL; /* Internal file pointer */ @@ -5726,8 +5736,10 @@ test_libver_bounds_super_create(hid_t fapl, hid_t fcpl, htri_t is_swmr) ret = H5Pget_libver_bounds(fapl, &low, &high); CHECK(ret, FAIL, "H5Pget_libver_bounds"); - if(is_swmr) { /* SWMR is enabled */ + if(non_def_fsm && high < H5F_LIBVER_V110) + VERIFY(fid, FAIL, "H5Fcreate"); + else if(is_swmr) { /* SWMR is enabled */ if(high >= H5F_LIBVER_V110) { /* Should succeed */ VERIFY(fid >= 0, TRUE, "H5Fcreate"); VERIFY(HDF5_SUPERBLOCK_VERSION_3, f->shared->sblock->super_vers, "HDF5_superblock_ver_bounds"); @@ -5736,37 +5748,37 @@ test_libver_bounds_super_create(hid_t fapl, hid_t fcpl, htri_t is_swmr) } else /* Should fail */ VERIFY(fid >= 0, FALSE, "H5Fcreate"); - } - else { /* Should succeed */ + } else { /* Should succeed */ VERIFY(fid >= 0, TRUE, "H5Fcreate"); VERIFY(low, f->shared->low_bound, "HDF5_superblock_ver_bounds"); switch(low) { case H5F_LIBVER_EARLIEST: - ok = (f->shared->sblock->super_vers == HDF5_SUPERBLOCK_VERSION_DEF || - f->shared->sblock->super_vers == HDF5_SUPERBLOCK_VERSION_1 || - f->shared->sblock->super_vers == HDF5_SUPERBLOCK_VERSION_2); - VERIFY(ok, TRUE, "HDF5_superblock_ver_bounds"); - break; + ok = (f->shared->sblock->super_vers == HDF5_SUPERBLOCK_VERSION_DEF || + f->shared->sblock->super_vers == HDF5_SUPERBLOCK_VERSION_1 || + f->shared->sblock->super_vers == HDF5_SUPERBLOCK_VERSION_2); + VERIFY(ok, TRUE, "HDF5_superblock_ver_bounds"); + break; case H5F_LIBVER_V18: - ok = (f->shared->sblock->super_vers == HDF5_SUPERBLOCK_VERSION_2); - VERIFY(ok, TRUE, "HDF5_superblock_ver_bounds"); - break; + ok = (f->shared->sblock->super_vers == HDF5_SUPERBLOCK_VERSION_2); + VERIFY(ok, TRUE, "HDF5_superblock_ver_bounds"); + break; case H5F_LIBVER_V110: case H5F_LIBVER_V112: - ok = (f->shared->sblock->super_vers == HDF5_SUPERBLOCK_VERSION_3); - VERIFY(ok, TRUE, "HDF5_superblock_ver_bounds"); - break; + ok = (f->shared->sblock->super_vers == HDF5_SUPERBLOCK_VERSION_3); + VERIFY(ok, TRUE, "HDF5_superblock_ver_bounds"); + break; case H5F_LIBVER_ERROR: case H5F_LIBVER_NBOUNDS: default: - ERROR("H5Pget_libver_bounds"); + ERROR("H5Pget_libver_bounds"); } /* end switch */ - } + + } /* end else */ if(fid >= 0) { /* Close the file */ ret = H5Fclose(fid); @@ -5793,11 +5805,14 @@ test_libver_bounds_super_create(hid_t fapl, hid_t fcpl, htri_t is_swmr) ** For file open, the file's superblock version, the low/high bounds setting in fapl, ** and with/without SWMR file access will determine the results for #a and #b. ** -** The first row for the following tables is the 5 pairs of low/high bounds setting +** The first row for the following tables (#A - #B) is the 5 pairs of low/high bounds setting ** in the input fapl. The next two rows list the expected results for #a and #b. ** "-->" indicates "upgrade to" ** -** Opening a file with write access +** The last table (#C) lists the expected results in opening the file when non-default +** free-space info (fsinfo) is enabled in fcpl. +** +** (A) Opening a file with write access ** ** Superblock version 0, 1 ** -------------------------------------------------------------------------------- @@ -5829,7 +5844,7 @@ test_libver_bounds_super_create(hid_t fapl, hid_t fcpl, htri_t is_swmr) ** ** ** -** Opening a file with SWMR-write access +** (B) Opening a file with SWMR-write access ** ** Superblock version 0, 1, 2 ** ------------------------------------------------------------------------------- @@ -5851,9 +5866,17 @@ test_libver_bounds_super_create(hid_t fapl, hid_t fcpl, htri_t is_swmr) ** |_____________________________________________________________________________| ** ** +** (C) Opening a file with write/SWMR-write access + non-default fsinfo +** ------------------------------------------------------------------------------- +** | (earliest, v18) | (earliest, v10) | (v18, v18) | (v18, v110) | (v110, v110) | +** |_____________________________________________________________________________| +** File open | fail | succeed | fail | succeed | succeed | +** |_____________________________________________________________________________| +** +** ******************************************************************************************************/ static void -test_libver_bounds_super_open(hid_t fapl, hid_t fcpl, htri_t is_swmr) +test_libver_bounds_super_open(hid_t fapl, hid_t fcpl, htri_t is_swmr, htri_t non_def_fsm) { hid_t fid = -1; /* File ID */ H5F_t *f = NULL; /* Internal file pointer */ @@ -5863,96 +5886,113 @@ test_libver_bounds_super_open(hid_t fapl, hid_t fcpl, htri_t is_swmr) herr_t ret; /* Return value */ /* Create the file with the input fcpl and fapl */ - fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, fcpl, fapl); - CHECK(fid, FAIL, "H5Fcreate"); + H5E_BEGIN_TRY { + fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, fcpl, fapl); + } H5E_END_TRY; - /* Get the internal file pointer */ - f = (H5F_t *)H5VL_object(fid); - CHECK(f, NULL, "H5VL_object"); + /* Retrieve the low/high bounds */ + ret = H5Pget_libver_bounds(fapl, &low, &high); + CHECK(ret, FAIL, "H5Pget_libver_bounds"); - /* The file's superblock version */ - super_vers = f->shared->sblock->super_vers; + if(non_def_fsm && high < H5F_LIBVER_V110) { + VERIFY(fid, FAIL, "H5Fcreate"); - /* Close the file */ - ret = H5Fclose(fid); - CHECK(ret, FAIL, "H5Fclose"); + } else { + VERIFY(fid >= 0, TRUE, "H5Fcreate"); - /* Create a default file access property list */ - new_fapl = H5Pcreate(H5P_FILE_ACCESS); - CHECK(new_fapl, FAIL, "H5Pcreate"); + /* Get the internal file pointer */ + f = (H5F_t *)H5VL_object(fid); + CHECK(f, NULL, "H5VL_object"); - /* Loop through all the combinations of low/high bounds in new_fapl */ - for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; H5_INC_ENUM(H5F_libver_t, low)) { - for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; H5_INC_ENUM(H5F_libver_t, high)) { - H5E_BEGIN_TRY { - ret = H5Pset_libver_bounds(new_fapl, low, high); - } H5E_END_TRY; + /* The file's superblock version */ + super_vers = f->shared->sblock->super_vers; - /* Invalid combinations */ - if (ret < 0) - continue; + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); - /* Open the file with or without SWMR access */ - H5E_BEGIN_TRY { - fid = H5Fopen(FILE8, H5F_ACC_RDWR | (is_swmr ? H5F_ACC_SWMR_WRITE : 0), new_fapl); - } H5E_END_TRY; + /* Create a default file access property list */ + new_fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(new_fapl, FAIL, "H5Pcreate"); - /* Get the internal file pointer if the open succeeds */ - if(fid >= 0) { - f = (H5F_t *)H5VL_object(fid); - CHECK(f, NULL, "H5VL_object"); - } + /* Loop through all the combinations of low/high bounds in new_fapl */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; H5_INC_ENUM(H5F_libver_t, low)) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; H5_INC_ENUM(H5F_libver_t, high)) { + H5E_BEGIN_TRY { + ret = H5Pset_libver_bounds(new_fapl, low, high); + } H5E_END_TRY; - /* Verify the file open succeeds or fails */ - switch(super_vers) { - case 3: - if(high >= H5F_LIBVER_V110) { - /* Should succeed */ - VERIFY(fid >= 0, TRUE, "H5Fopen"); - VERIFY(f->shared->low_bound >= H5F_LIBVER_V110, TRUE, "HDF5_superblock_ver_bounds"); - - /* Close the file */ - ret = H5Fclose(fid); - CHECK(ret, FAIL, "H5Fclose"); - } else /* Should fail */ - VERIFY(fid >= 0, FALSE, "H5Fopen"); - break; - - case 2: - if(is_swmr) /* Should fail */ - VERIFY(fid >= 0, FALSE, "H5Fopen"); - else { /* Should succeed */ - VERIFY(fid >= 0, TRUE, "H5Fopen"); - VERIFY(f->shared->low_bound >= H5F_LIBVER_V18, TRUE, "HDF5_superblock_ver_bounds"); - - /* Close the file */ - ret = H5Fclose(fid); - CHECK(ret, FAIL, "H5Fclose"); - } - break; - - case 1: - case 0: - if(is_swmr) /* Should fail */ - VERIFY(fid >= 0, FALSE, "H5Fopen"); - else { /* Should succeed */ - VERIFY(fid >= 0, TRUE, "H5Fopen"); - VERIFY(f->shared->low_bound, low, "HDF5_superblock_ver_bounds"); - - ret = H5Fclose(fid); - CHECK(ret, FAIL, "H5Fclose"); - } - break; + /* Invalid combinations */ + if (ret < 0) + continue; + + /* Open the file with or without SWMR access */ + H5E_BEGIN_TRY { + fid = H5Fopen(FILE8, H5F_ACC_RDWR | (is_swmr ? H5F_ACC_SWMR_WRITE : 0), new_fapl); + } H5E_END_TRY; + + if(non_def_fsm && high < H5F_LIBVER_V110) { + VERIFY(fid, FAIL, "H5Fopen"); + continue; + } + + /* Get the internal file pointer if the open succeeds */ + if(fid >= 0) { + f = (H5F_t *)H5VL_object(fid); + CHECK(f, NULL, "H5VL_object"); + } - default: - break; - } /* end switch */ + /* Verify the file open succeeds or fails */ + switch(super_vers) { + case 3: + if(high >= H5F_LIBVER_V110) { + /* Should succeed */ + VERIFY(fid >= 0, TRUE, "H5Fopen"); + VERIFY(f->shared->low_bound >= H5F_LIBVER_V110, TRUE, "HDF5_superblock_ver_bounds"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + } else /* Should fail */ + VERIFY(fid >= 0, FALSE, "H5Fopen"); + break; + + case 2: + if(is_swmr) /* Should fail */ + VERIFY(fid >= 0, FALSE, "H5Fopen"); + else { /* Should succeed */ + VERIFY(fid >= 0, TRUE, "H5Fopen"); + VERIFY(f->shared->low_bound >= H5F_LIBVER_V18, TRUE, "HDF5_superblock_ver_bounds"); + + /* Close the file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + } + break; + + case 1: + case 0: + if(is_swmr) /* Should fail */ + VERIFY(fid >= 0, FALSE, "H5Fopen"); + else { /* Should succeed */ + VERIFY(fid >= 0, TRUE, "H5Fopen"); + VERIFY(f->shared->low_bound, low, "HDF5_superblock_ver_bounds"); + + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + } + break; + + default: + break; + } /* end switch */ + } /* end for */ } /* end for */ - } /* end for */ - /* Close the file access property list */ - ret = H5Pclose(new_fapl); - CHECK(ret, FAIL, "H5Pclose"); + /* Close the file access property list */ + ret = H5Pclose(new_fapl); + CHECK(ret, FAIL, "H5Pclose"); + } /* end else */ } /* end test_libver_bounds_super_open() */ -- cgit v0.12 From 71de5b808818a2619fe179eac4f6c6ec892a4420 Mon Sep 17 00:00:00 2001 From: Vailin Choi Date: Tue, 25 Jun 2019 11:47:33 -0500 Subject: Correct hid_t error value to H5I_INVALID_HID in tests related to libver_bounds. --- test/tfile.c | 224 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 112 insertions(+), 112 deletions(-) diff --git a/test/tfile.c b/test/tfile.c index 0dd0700..9e17c34 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -5501,16 +5501,16 @@ test_libver_bounds(void) static void test_libver_bounds_low_high(void) { - hid_t fapl = -1; /* File access property list */ - H5F_libver_t low, high; /* Low and high bounds */ - herr_t ret; /* The return value */ + hid_t fapl = H5I_INVALID_HID; /* File access property list */ + H5F_libver_t low, high; /* Low and high bounds */ + herr_t ret; /* The return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing setting (low, high) format version bounds\n")); /* Create a file access property list */ fapl = H5Pcreate(H5P_FILE_ACCESS); - CHECK(fapl, FAIL, "H5Pcreate"); + CHECK(fapl, H5I_INVALID_HID, "H5Pcreate"); /* Loop through all the combinations of low/high version bounds */ for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; H5_INC_ENUM(H5F_libver_t, low)) @@ -5573,13 +5573,13 @@ test_libver_bounds_low_high(void) static void test_libver_bounds_super(hid_t fapl) { - hid_t fcpl = -1; /* File creation property list */ - herr_t ret; /* The return value */ + hid_t fcpl = H5I_INVALID_HID; /* File creation property list */ + herr_t ret; /* The return value */ /* Create a default fcpl: #A */ /* This will result in superblock version 0 */ fcpl = H5Pcreate(H5P_FILE_CREATE); - CHECK(fcpl, FAIL, "H5Pcreate"); + CHECK(fcpl, H5I_INVALID_HID, "H5Pcreate"); /* Verify superblock version when creating a file with input fapl, fcpl #A and with/without SWMR access */ @@ -5598,7 +5598,7 @@ test_libver_bounds_super(hid_t fapl) /* Create a fcpl with v1-btree K value enabled: #B */ /* This will result in superblock version 1 */ fcpl = H5Pcreate(H5P_FILE_CREATE); - CHECK(fcpl, FAIL, "H5Pcreate"); + CHECK(fcpl, H5I_INVALID_HID, "H5Pcreate"); ret = H5Pset_istore_k(fcpl, 64); CHECK(ret, FAIL, "H5Pset_istore_k"); @@ -5619,7 +5619,7 @@ test_libver_bounds_super(hid_t fapl) /* Create a fcpl with shared messages enabled: #C */ /* This will result in superblock version 2 */ fcpl = H5Pcreate(H5P_FILE_CREATE); - CHECK(fcpl, FAIL, "H5Pcreate"); + CHECK(fcpl, H5I_INVALID_HID, "H5Pcreate"); ret = H5Pset_shared_mesg_nindexes(fcpl, 1); CHECK(ret, FAIL, "H5Pset_shared_mesg_nindexes"); ret = H5Pset_shared_mesg_index(fcpl, 0, H5O_SHMESG_ATTR_FLAG, 2); @@ -5642,7 +5642,7 @@ test_libver_bounds_super(hid_t fapl) /* Create a fcpl with persistent free-space manager enabled: #D */ /* This will result in superblock version 2 */ fcpl = H5Pcreate(H5P_FILE_CREATE); - CHECK(fcpl, FAIL, "H5Pcreate"); + CHECK(fcpl, H5I_INVALID_HID, "H5Pcreate"); ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, 1, (hsize_t)1); CHECK(ret, FAIL, "H5Pset_file_space"); @@ -5715,11 +5715,11 @@ test_libver_bounds_super(hid_t fapl) static void test_libver_bounds_super_create(hid_t fapl, hid_t fcpl, htri_t is_swmr, htri_t non_def_fsm) { - hid_t fid = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file pointer */ - H5F_libver_t low, high; /* Low and high bounds */ - hbool_t ok; /* The result is ok or not */ - herr_t ret; /* The return value */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + H5F_t *f = NULL; /* Internal file pointer */ + H5F_libver_t low, high; /* Low and high bounds */ + hbool_t ok; /* The result is ok or not */ + herr_t ret; /* The return value */ /* Try to create the file */ H5E_BEGIN_TRY { @@ -5737,7 +5737,7 @@ test_libver_bounds_super_create(hid_t fapl, hid_t fcpl, htri_t is_swmr, htri_t n CHECK(ret, FAIL, "H5Pget_libver_bounds"); if(non_def_fsm && high < H5F_LIBVER_V110) - VERIFY(fid, FAIL, "H5Fcreate"); + VERIFY(fid, H5I_INVALID_HID, "H5Fcreate"); else if(is_swmr) { /* SWMR is enabled */ if(high >= H5F_LIBVER_V110) { /* Should succeed */ @@ -5878,9 +5878,9 @@ test_libver_bounds_super_create(hid_t fapl, hid_t fcpl, htri_t is_swmr, htri_t n static void test_libver_bounds_super_open(hid_t fapl, hid_t fcpl, htri_t is_swmr, htri_t non_def_fsm) { - hid_t fid = -1; /* File ID */ - H5F_t *f = NULL; /* Internal file pointer */ - hid_t new_fapl = -1; /* File access property list */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + H5F_t *f = NULL; /* Internal file pointer */ + hid_t new_fapl = H5I_INVALID_HID; /* File access property list */ unsigned super_vers; /* Superblock version */ H5F_libver_t low, high; /* Low and high bounds */ herr_t ret; /* Return value */ @@ -5895,7 +5895,7 @@ test_libver_bounds_super_open(hid_t fapl, hid_t fcpl, htri_t is_swmr, htri_t non CHECK(ret, FAIL, "H5Pget_libver_bounds"); if(non_def_fsm && high < H5F_LIBVER_V110) { - VERIFY(fid, FAIL, "H5Fcreate"); + VERIFY(fid, H5I_INVALID_HID, "H5Fcreate"); } else { VERIFY(fid >= 0, TRUE, "H5Fcreate"); @@ -5932,7 +5932,7 @@ test_libver_bounds_super_open(hid_t fapl, hid_t fcpl, htri_t is_swmr, htri_t non } H5E_END_TRY; if(non_def_fsm && high < H5F_LIBVER_V110) { - VERIFY(fid, FAIL, "H5Fopen"); + VERIFY(fid, H5I_INVALID_HID, "H5Fopen"); continue; } @@ -6025,10 +6025,10 @@ test_libver_bounds_super_open(hid_t fapl, hid_t fcpl, htri_t is_swmr, htri_t non static void test_libver_bounds_obj(hid_t fapl) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group ID */ - hid_t fcpl = -1; /* File creation property list */ - hid_t new_fapl = -1; /* File access property list */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t gid = H5I_INVALID_HID; /* Group ID */ + hid_t fcpl = H5I_INVALID_HID; /* File creation property list */ + hid_t new_fapl = H5I_INVALID_HID; /* File access property list */ H5F_t *f = NULL; /* Internal file pointer */ H5F_libver_t low, high; /* Low and high bounds */ H5O_info_t oinfo; /* Object info */ @@ -6041,7 +6041,7 @@ test_libver_bounds_obj(hid_t fapl) /* Create a default file creation property list */ fcpl = H5Pcreate(H5P_FILE_CREATE); - CHECK(fcpl, FAIL, "H5Pcreate"); + CHECK(fcpl, H5I_INVALID_HID, "H5Pcreate"); /* Enable shared message in the fcpl */ /* This will result in a version 2 object header */ @@ -6052,7 +6052,7 @@ test_libver_bounds_obj(hid_t fapl) /* Create the file with the fcpl and the input fapl */ fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, fcpl, fapl); - CHECK(fid, FAIL, "H5Fcreate"); + CHECK(fid, H5I_INVALID_HID, "H5Fcreate"); /* Get root group's object info */ ret = H5Oget_info_by_name2(fid, "/", &oinfo, H5O_INFO_HDR, H5P_DEFAULT); @@ -6071,7 +6071,7 @@ test_libver_bounds_obj(hid_t fapl) /* Create a file with the default fcpl and input fapl */ fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - CHECK(fid, FAIL, "H5Fcreate"); + CHECK(fid, H5I_INVALID_HID, "H5Fcreate"); /* Get root group's object info */ ret = H5Oget_info_by_name2(fid, "/", &oinfo, H5O_INFO_HDR, H5P_DEFAULT); @@ -6087,7 +6087,7 @@ test_libver_bounds_obj(hid_t fapl) /* Create a new default file access property list which is used to open the file in the "for" loop */ new_fapl = H5Pcreate(H5P_FILE_ACCESS); - CHECK(new_fapl, FAIL, "H5Pcreate"); + CHECK(new_fapl, H5I_INVALID_HID, "H5Pcreate"); /* Loop through all the combinations of low/high bounds in new_fapl */ /* Open the file with the fapl; create a group and verify the @@ -6185,11 +6185,11 @@ test_libver_bounds_obj(hid_t fapl) static void test_libver_bounds_dataset(hid_t fapl) { - hid_t fid = -1; /* File ID */ - hid_t new_fapl = -1; /* File access property list */ - hid_t did = -1; /* Dataset ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t dcpl = -1; /* Dataset creation property list */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t new_fapl = H5I_INVALID_HID; /* File access property list */ + hid_t did = H5I_INVALID_HID; /* Dataset ID */ + hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ + hid_t dcpl = H5I_INVALID_HID; /* Dataset creation property list */ H5D_t *dset = NULL; /* Internal dataset pointer */ H5F_t *f = NULL; /* Internal file pointer */ H5F_libver_t low, high; /* Low and high bounds */ @@ -6206,15 +6206,15 @@ test_libver_bounds_dataset(hid_t fapl) /* Create the file with the input fapl */ fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - CHECK(fid, FAIL, "H5Fcreate"); + CHECK(fid, H5I_INVALID_HID, "H5Fcreate"); /* Create the dataspace */ sid = H5Screate(H5S_SCALAR); - CHECK(sid, FAIL, "H5Screate"); + CHECK(sid, H5I_INVALID_HID, "H5Screate"); /* Create a contiguous dataset */ did = H5Dcreate2(fid, DSETA, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(did, FAIL, "H5Dcreate"); + CHECK(did, H5I_INVALID_HID, "H5Dcreate"); /* Get the internal dataset pointer */ dset = (H5D_t *)H5VL_object(did); @@ -6246,9 +6246,9 @@ test_libver_bounds_dataset(hid_t fapl) with "no filter edge chunks" enabled. This will result in a version 4 layout message */ sid = H5Screate_simple(2, fix_dims2, NULL); - CHECK(sid, FAIL, "H5Screate_simple"); + CHECK(sid, H5I_INVALID_HID, "H5Screate_simple"); dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + CHECK(dcpl, H5I_INVALID_HID, "H5Pcreate"); ret = H5Pset_chunk(dcpl, 2, fix_chunks2); CHECK(ret, FAIL, "H5Pset_chunk"); ret = H5Pset_chunk_opts(dcpl, H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS); @@ -6289,14 +6289,14 @@ test_libver_bounds_dataset(hid_t fapl) /* Create a default file access property list which is used to open the file in the 'for' loop */ new_fapl = H5Pcreate(H5P_FILE_ACCESS); - CHECK(new_fapl, FAIL, "H5Pcreate"); + CHECK(new_fapl, H5I_INVALID_HID, "H5Pcreate"); /* Set up dataspace and dcpl for creating a chunked dataset with 2 unlimited dimensions in the 'for' loop */ sid = H5Screate_simple(2, dims2, max_dims2); - CHECK(sid, FAIL, "H5Screate_simple"); + CHECK(sid, H5I_INVALID_HID, "H5Screate_simple"); dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + CHECK(dcpl, H5I_INVALID_HID, "H5Pcreate"); ret = H5Pset_chunk(dcpl, 2, chunks2); CHECK(ret, FAIL, "H5Pset_chunk"); @@ -6325,7 +6325,7 @@ test_libver_bounds_dataset(hid_t fapl) /* Create the chunked dataset */ did = H5Dcreate2(fid, DSETC, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); - CHECK(did, FAIL, "H5Dcreate2"); + CHECK(did, H5I_INVALID_HID, "H5Dcreate2"); /* Get the internal file pointer */ dset = (H5D_t *)H5VL_object(did); @@ -6409,14 +6409,14 @@ test_libver_bounds_dataset(hid_t fapl) static void test_libver_bounds_dataspace(hid_t fapl) { - hid_t fid = -1; /* File ID */ - hid_t new_fapl = -1; /* File access property list */ - hid_t did = -1, did_null = -1; /* Dataset IDs */ - hid_t did_compact = -1, did_contig = -1; /* Dataset IDs */ - hid_t sid = -1, sid_null = -1; /* Dataspace IDs */ - hid_t sid_compact = -1, sid_contig = -1; /* Dataspace IDs */ - hid_t dcpl = -1; /* Dataset creation property list */ - hid_t dcpl_compact = -1, dcpl_contig = -1; /* Dataset creation property lists */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t new_fapl = H5I_INVALID_HID; /* File access property list */ + hid_t did = H5I_INVALID_HID, did_null = H5I_INVALID_HID; /* Dataset IDs */ + hid_t did_compact = H5I_INVALID_HID, did_contig = H5I_INVALID_HID; /* Dataset IDs */ + hid_t sid = H5I_INVALID_HID, sid_null = H5I_INVALID_HID; /* Dataspace IDs */ + hid_t sid_compact = H5I_INVALID_HID, sid_contig = H5I_INVALID_HID; /* Dataspace IDs */ + hid_t dcpl = H5I_INVALID_HID; /* Dataset creation property list */ + hid_t dcpl_compact = H5I_INVALID_HID, dcpl_contig = H5I_INVALID_HID; /* Dataset creation property lists */ H5S_t *space = NULL, *space_null = NULL; /* Internal dataspace pointers */ H5F_t *f = NULL; /* Internal file pointer */ H5F_libver_t low, high; /* Low and high bounds */ @@ -6432,19 +6432,19 @@ test_libver_bounds_dataspace(hid_t fapl) /* Create the file with the input fapl */ fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - CHECK(fid, FAIL, "H5Fcreate"); + CHECK(fid, H5I_INVALID_HID, "H5Fcreate"); /* Create scalar dataspace */ sid = H5Screate(H5S_SCALAR); - CHECK(sid, FAIL, "H5Screate"); + CHECK(sid, H5I_INVALID_HID, "H5Screate"); /* Create a dataset with the scalar dataspace */ did = H5Dcreate2(fid, DSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(did, FAIL, "H5Dcreate"); + CHECK(did, H5I_INVALID_HID, "H5Dcreate"); /* Get the internal dataspace pointer */ sid = H5Dget_space(did); - CHECK(sid, FAIL, "H5Dget_space"); + CHECK(sid, H5I_INVALID_HID, "H5Dget_space"); space = (H5S_t *)H5I_object(sid); CHECK(space, NULL, "H5I_object"); @@ -6453,15 +6453,15 @@ test_libver_bounds_dataspace(hid_t fapl) /* Create null dataspace */ sid_null = H5Screate(H5S_NULL); - CHECK(sid_null, FAIL, "H5Screate"); + CHECK(sid_null, H5I_INVALID_HID, "H5Screate"); /* Create a dataset with the null dataspace */ did_null = H5Dcreate2(fid, DSET_NULL, H5T_NATIVE_INT, sid_null, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(did_null, FAIL, "H5Dcreate"); + CHECK(did_null, H5I_INVALID_HID, "H5Dcreate"); /* Get the internal dataspace pointer */ sid_null = H5Dget_space(did_null); - CHECK(sid_null, FAIL, "H5Dget_space"); + CHECK(sid_null, H5I_INVALID_HID, "H5Dget_space"); space_null = (H5S_t *)H5I_object(sid_null); CHECK(space_null, NULL, "H5I_object"); @@ -6487,29 +6487,29 @@ test_libver_bounds_dataspace(hid_t fapl) /* Create a default file access property list which is used to open the file in the 'for' loop */ new_fapl = H5Pcreate(H5P_FILE_ACCESS); - CHECK(new_fapl, FAIL, "H5Pcreate"); + CHECK(new_fapl, H5I_INVALID_HID, "H5Pcreate"); /* Set up dataspace and dcpl for creating a chunked dataset */ sid = H5Screate_simple(1, dims, max_dims); - CHECK(sid, FAIL, "H5Screate_simple"); + CHECK(sid, H5I_INVALID_HID, "H5Screate_simple"); dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + CHECK(dcpl, H5I_INVALID_HID, "H5Pcreate"); ret = H5Pset_chunk(dcpl, 1, chunks); CHECK(ret, FAIL, "H5Pset_chunk"); /* Set up dataspace and dcpl for creating a compact dataset */ sid_compact = H5Screate_simple(1, dims, NULL); - CHECK(sid_compact, FAIL, "H5Screate_simple"); + CHECK(sid_compact, H5I_INVALID_HID, "H5Screate_simple"); dcpl_compact = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl_compact, FAIL, "H5Pcreate"); + CHECK(dcpl_compact, H5I_INVALID_HID, "H5Pcreate"); ret = H5Pset_layout(dcpl_compact, H5D_COMPACT); CHECK(ret, FAIL, "H5Pset_layout"); /* Set up dataspace and dcpl for creating a contiguous dataset */ sid_contig = H5Screate_simple(2, dims2, NULL); - CHECK(sid_contig, FAIL, "H5Screate_simple"); + CHECK(sid_contig, H5I_INVALID_HID, "H5Screate_simple"); dcpl_contig = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl_contig, FAIL, "H5Pcreate"); + CHECK(dcpl_contig, H5I_INVALID_HID, "H5Pcreate"); ret = H5Pset_layout(dcpl_contig, H5D_CONTIGUOUS); CHECK(ret, FAIL, "H5Pset_layout"); @@ -6541,31 +6541,31 @@ test_libver_bounds_dataspace(hid_t fapl) /* Create the chunked dataset */ did = H5Dcreate2(fid, DSETA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); - CHECK(did, FAIL, "H5Dcreate2"); + CHECK(did, H5I_INVALID_HID, "H5Dcreate2"); /* Get the internal dataspace pointer for the chunked dataset */ tmp_sid = H5Dget_space(did); - CHECK(tmp_sid, FAIL, "H5Dget_space"); + CHECK(tmp_sid, H5I_INVALID_HID, "H5Dget_space"); tmp_space = (H5S_t *)H5I_object(tmp_sid); CHECK(tmp_space, NULL, "H5I_object"); /* Create the compact dataset */ did_compact = H5Dcreate2(fid, DSETB, H5T_NATIVE_INT, sid_compact, H5P_DEFAULT, dcpl_compact, H5P_DEFAULT); - CHECK(did_compact, FAIL, "H5Dcreate2"); + CHECK(did_compact, H5I_INVALID_HID, "H5Dcreate2"); /* Get the internal dataspace pointer for the compact dataset */ tmp_sid_compact = H5Dget_space(did_compact); - CHECK(tmp_sid_compact, FAIL, "H5Dget_space"); + CHECK(tmp_sid_compact, H5I_INVALID_HID, "H5Dget_space"); tmp_space_compact = (H5S_t *)H5I_object(tmp_sid_compact); CHECK(tmp_space_compact, NULL, "H5I_object"); /* Create the contiguous dataset */ did_contig = H5Dcreate2(fid, DSETC, H5T_NATIVE_INT, sid_contig, H5P_DEFAULT, dcpl_contig, H5P_DEFAULT); - CHECK(did_contig, FAIL, "H5Dcreate2"); + CHECK(did_contig, H5I_INVALID_HID, "H5Dcreate2"); /* Get the internal dataspace pointer for the contiguous dataset */ tmp_sid_contig = H5Dget_space(did_contig); - CHECK(tmp_sid_contig, FAIL, "H5Dget_space"); + CHECK(tmp_sid_contig, H5I_INVALID_HID, "H5Dget_space"); tmp_space_contig = (H5S_t *)H5I_object(tmp_sid_contig); CHECK(tmp_space_contig, NULL, "H5I_object"); @@ -6647,8 +6647,8 @@ test_libver_bounds_dataspace(hid_t fapl) static void test_libver_bounds_datatype(hid_t fapl) { - hid_t tid = -1, tid_enum = -1, tid_array = -1; /* Datatype IDs */ - hid_t tid_compound = -1, tid_vlen = -1; /* Datatype IDs */ + hid_t tid = H5I_INVALID_HID, tid_enum = H5I_INVALID_HID, tid_array = H5I_INVALID_HID; /* Datatype IDs */ + hid_t tid_compound = H5I_INVALID_HID, tid_vlen = H5I_INVALID_HID; /* Datatype IDs */ int enum_value; /* Value for enum datatype */ typedef struct s1 { /* Data structure for compound datatype */ char c; @@ -6739,13 +6739,13 @@ test_libver_bounds_datatype(hid_t fapl) static void test_libver_bounds_datatype_check(hid_t fapl, hid_t tid) { - hid_t fid = -1; /* File ID */ - hid_t new_fapl = -1; /* File acess property list */ - hid_t dcpl = -1; /* Dataset creation property list */ - hid_t dtid = -1; /* Datatype ID for the dataset */ - hid_t str_tid = -1; /* String datatype ID */ - hid_t did = -1; /* Dataset ID */ - hid_t sid = -1; /* Dataspace ID */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t new_fapl = H5I_INVALID_HID; /* File acess property list */ + hid_t dcpl = H5I_INVALID_HID; /* Dataset creation property list */ + hid_t dtid = H5I_INVALID_HID; /* Datatype ID for the dataset */ + hid_t str_tid = H5I_INVALID_HID; /* String datatype ID */ + hid_t did = H5I_INVALID_HID; /* Dataset ID */ + hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ hsize_t dims[1] = {1}; /* Dimension sizes */ hsize_t dims2[2] = {5, 4}; /* Dimension sizes */ hsize_t max_dims2[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */ @@ -6762,12 +6762,12 @@ test_libver_bounds_datatype_check(hid_t fapl, hid_t tid) /* Create the file with the input fapl */ fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - CHECK(fid, FAIL, "H5Fcreate"); + CHECK(fid, H5I_INVALID_HID, "H5Fcreate"); /* Create a committed datatype of string which will be used later inside the 'for' loop */ str_tid = H5Tcopy(H5T_C_S1); - CHECK(str_tid, FAIL, "H5Tcopy"); + CHECK(str_tid, H5I_INVALID_HID, "H5Tcopy"); ret = H5Tset_size(str_tid, (size_t)10); CHECK(ret, FAIL, "H5Tset_size"); ret = H5Tcommit2(fid, "datatype", str_tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -6777,15 +6777,15 @@ test_libver_bounds_datatype_check(hid_t fapl, hid_t tid) /* Create dataspace */ sid = H5Screate_simple(1, dims, NULL); - CHECK(sid, FAIL, "H5Screate_simple"); + CHECK(sid, H5I_INVALID_HID, "H5Screate_simple"); /* Create a dataset with the input tid */ did = H5Dcreate2(fid, DSET1, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(did, FAIL, "H5Dcreate2"); + CHECK(did, H5I_INVALID_HID, "H5Dcreate2"); /* Get the dataset's datatype */ dtid = H5Dget_type(did); - CHECK(dtid, FAIL, "H5Dget_type"); + CHECK(dtid, H5I_INVALID_HID, "H5Dget_type"); /* Get the internal datatype pointer */ dtype = (H5T_t *)H5I_object(dtid); @@ -6827,13 +6827,13 @@ test_libver_bounds_datatype_check(hid_t fapl, hid_t tid) /* Create a default file access property list */ new_fapl = H5Pcreate(H5P_FILE_ACCESS); - CHECK(new_fapl, FAIL, "H5Pcreate"); + CHECK(new_fapl, H5I_INVALID_HID, "H5Pcreate"); /* Set up dataspace and dcpl for creating a chunked dataset */ sid = H5Screate_simple(2, dims2, max_dims2); - CHECK(sid, FAIL, "H5Screate_simple"); + CHECK(sid, H5I_INVALID_HID, "H5Screate_simple"); dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + CHECK(dcpl, H5I_INVALID_HID, "H5Pcreate"); ret = H5Pset_chunk(dcpl, 2, chunks); CHECK(ret, FAIL, "H5Pset_chunk"); @@ -6877,11 +6877,11 @@ test_libver_bounds_datatype_check(hid_t fapl, hid_t tid) /* Create the chunked dataset */ did = H5Dcreate2(fid, DSETNAME, tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); - CHECK(did, FAIL, "H5Dcreate2"); + CHECK(did, H5I_INVALID_HID, "H5Dcreate2"); /* Get the dataset's datatype */ dtid = H5Dget_type(did); - CHECK(dtid, FAIL, "H5Dget_type"); + CHECK(dtid, H5I_INVALID_HID, "H5Dget_type"); /* Get the internal datatype pointer */ dtype = (H5T_t *)H5I_object(dtid); @@ -6974,14 +6974,14 @@ test_libver_bounds_datatype_check(hid_t fapl, hid_t tid) static void test_libver_bounds_attributes(hid_t fapl) { - hid_t fid = -1; /* File ID */ - hid_t fcpl = -1; /* File creation property list */ - hid_t new_fapl = -1; /* File access property list */ - hid_t tid = -1; /* Datatype ID */ - hid_t gid = -1; /* Group ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t aid = -1; /* Attribute ID */ - hid_t attr_cpl = -1; /* Attribute creation property list */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t fcpl = H5I_INVALID_HID; /* File creation property list */ + hid_t new_fapl = H5I_INVALID_HID; /* File access property list */ + hid_t tid = H5I_INVALID_HID; /* Datatype ID */ + hid_t gid = H5I_INVALID_HID; /* Group ID */ + hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ + hid_t aid = H5I_INVALID_HID; /* Attribute ID */ + hid_t attr_cpl = H5I_INVALID_HID; /* Attribute creation property list */ H5A_t *attr = NULL; /* Internal attribute pointer */ H5F_t *f = NULL; /* Internal file pointer */ H5F_libver_t low, high; /* Low and high bounds */ @@ -6993,11 +6993,11 @@ test_libver_bounds_attributes(hid_t fapl) /* Create the file */ fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - CHECK(fid, FAIL, "H5Fcreate"); + CHECK(fid, H5I_INVALID_HID, "H5Fcreate"); /* Integer datatpye */ tid = H5Tcopy(H5T_NATIVE_INT); - CHECK(tid, FAIL, "H5Tcopy"); + CHECK(tid, H5I_INVALID_HID, "H5Tcopy"); /* Create a committed datatype */ ret = H5Tcommit2(fid, "datatype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -7005,15 +7005,15 @@ test_libver_bounds_attributes(hid_t fapl) /* Create dataspace */ sid = H5Screate(H5S_SCALAR); - CHECK(sid, FAIL, "H5Screate"); + CHECK(sid, H5I_INVALID_HID, "H5Screate"); /* Create a group */ gid = H5Gcreate2(fid, GRP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(gid, FAIL, "H5Gcreate2"); + CHECK(gid, H5I_INVALID_HID, "H5Gcreate2"); /* Attach an attribute to the group with the committed datatype */ aid = H5Acreate2(gid, "attr1", tid, sid, H5P_DEFAULT, H5P_DEFAULT); - CHECK(aid, FAIL, "H5Acreate2"); + CHECK(aid, H5I_INVALID_HID, "H5Acreate2"); /* Get the internal attribute pointer */ attr = (H5A_t *)H5VL_object(aid); @@ -7047,13 +7047,13 @@ test_libver_bounds_attributes(hid_t fapl) /* Enable character encoding in attribute creation property list */ attr_cpl = H5Pcreate(H5P_ATTRIBUTE_CREATE); - CHECK(attr_cpl, FAIL, "H5Pcreate"); + CHECK(attr_cpl, H5I_INVALID_HID, "H5Pcreate"); ret = H5Pset_char_encoding(attr_cpl, H5T_CSET_UTF8); CHECK(ret, FAIL, "H5Pset_char_encoding"); /* Attach an attribute to the group with character encoding set */ aid = H5Acreate2(gid, "attr3", H5T_NATIVE_INT, sid, attr_cpl, H5P_DEFAULT); - CHECK(aid, FAIL, "H5Acreate2"); + CHECK(aid, H5I_INVALID_HID, "H5Acreate2"); /* Get internal attribute pointer */ attr = (H5A_t *)H5VL_object(aid); @@ -7092,7 +7092,7 @@ test_libver_bounds_attributes(hid_t fapl) /* Create a copy of the file creation property list */ fcpl = H5Pcreate(H5P_FILE_CREATE); - CHECK(fcpl, FAIL, "H5Pcreate"); + CHECK(fcpl, H5I_INVALID_HID, "H5Pcreate"); /* Enable shared datatype message */ ret = H5Pset_shared_mesg_nindexes(fcpl, 1); @@ -7102,23 +7102,23 @@ test_libver_bounds_attributes(hid_t fapl) /* Create the file with shared datatype message enabled */ fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, fcpl, fapl); - CHECK(fid, FAIL, "H5Fcreate"); + CHECK(fid, H5I_INVALID_HID, "H5Fcreate"); /* Create an integer datatye */ tid = H5Tcopy(H5T_NATIVE_INT); - CHECK(tid, FAIL, "H5Tcopy"); + CHECK(tid, H5I_INVALID_HID, "H5Tcopy"); /* Create dataspace */ sid = H5Screate(H5S_SCALAR); - CHECK(sid, FAIL, "H5Screate"); + CHECK(sid, H5I_INVALID_HID, "H5Screate"); /* Create a group */ gid = H5Gcreate2(fid, GRP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(gid, FAIL, "H5Gcreate2"); + CHECK(gid, H5I_INVALID_HID, "H5Gcreate2"); /* Attach an attribute to the group with shared integer datatype */ aid = H5Acreate2(gid, ATTR_NAME, tid, sid, H5P_DEFAULT, H5P_DEFAULT); - CHECK(aid, FAIL, "H5Acreate2"); + CHECK(aid, H5I_INVALID_HID, "H5Acreate2"); /* Get the internal attribute pointer */ attr = (H5A_t *)H5VL_object(aid); @@ -7157,7 +7157,7 @@ test_libver_bounds_attributes(hid_t fapl) /* Create a scalar dataspace to be used later for the attribute */ sid = H5Screate(H5S_SCALAR); - CHECK(sid, FAIL, "H5Screate"); + CHECK(sid, H5I_INVALID_HID, "H5Screate"); /* Loop through all the combinations of low/high bounds */ /* Open the file and group and attach an attribute to the group */ -- cgit v0.12 From 3768566139df18928aa29ece0eff3010b224633b Mon Sep 17 00:00:00 2001 From: Vailin Choi Date: Tue, 25 Jun 2019 14:47:53 -0500 Subject: Add release notes. --- release_docs/RELEASE.txt | 16 ++++++++++++++++ src/H5Fsuper.c | 3 +-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index c8061f5..7c9bbfa 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -282,6 +282,22 @@ Bug Fixes since HDF5-1.10.3 release Library ------- + - Fixed an issue where creating a file with non-default file space info + together with library high bound setting to H5F_LIBVER_V18. + + When setting non-default file space info in fcpl via + H5Pset_file_space_strategy() and then creating a file with + both high and low library bounds set to + H5F_LIBVER_V18 in fapl, the library succeeds in creating the file. + File creation should fail because the feature of setting non-default + file space info does not exist in library release 1.8 or earlier. + + This was fixed by setting and checking the proper version in the + file space info message based on the library low and high bounds + when creating and opening the HDF5 file. + + (VC - 2019/6/25, HDFFV-10808) + - Fixed an issue where copying a version 1.8 dataset between files using H5Ocopy fails due to an incompatible fill version diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index 7d90df1..f4ff645 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -1850,9 +1850,8 @@ H5O__fsinfo_set_version(H5F_t *f, H5O_fsinfo_t *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) { + 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 || -- cgit v0.12