diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Fpkg.h | 3 | ||||
-rw-r--r-- | src/H5Fsuper.c | 63 | ||||
-rw-r--r-- | src/H5MF.c | 3 | ||||
-rw-r--r-- | src/H5Ofsinfo.c | 10 | ||||
-rw-r--r-- | src/H5Oprivate.h | 12 |
5 files changed, 85 insertions, 6 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..f4ff645 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,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() */ @@ -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 */ |