summaryrefslogtreecommitdiffstats
path: root/src/H5Fsuper_cache.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Fsuper_cache.c')
-rw-r--r--src/H5Fsuper_cache.c501
1 files changed, 205 insertions, 296 deletions
diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c
index 6cfd9c7..76866db 100644
--- a/src/H5Fsuper_cache.c
+++ b/src/H5Fsuper_cache.c
@@ -5,12 +5,10 @@
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
- * the files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*-------------------------------------------------------------------------
@@ -74,9 +72,6 @@ static htri_t H5F__cache_superblock_verify_chksum(const void *image_ptr, size_t
static void *H5F__cache_superblock_deserialize(const void *image, size_t len,
void *udata, hbool_t *dirty);
static herr_t H5F__cache_superblock_image_len(const void *thing, size_t *image_len);
-static herr_t H5F__cache_superblock_pre_serialize(const H5F_t *f,
- hid_t dxpl_id, void *thing, haddr_t addr, size_t len,
- haddr_t *new_addr, size_t *new_len, unsigned *flags);
static herr_t H5F__cache_superblock_serialize(const H5F_t *f, void *image, size_t len,
void *thing);
static herr_t H5F__cache_superblock_free_icr(void *thing);
@@ -91,6 +86,14 @@ static herr_t H5F__cache_drvrinfo_serialize(const H5F_t *f, void *image, size_t
void *thing);
static herr_t H5F__cache_drvrinfo_free_icr(void *thing);
+/* Local encode/decode routines */
+static herr_t H5F__superblock_prefix_decode(H5F_super_t *sblock,
+ const uint8_t **image_ref, const H5F_superblock_cache_ud_t *udata,
+ hbool_t extend_eoa);
+static herr_t H5F__drvrinfo_prefix_decode(H5O_drvinfo_t *drvinfo, char *drv_name,
+ const uint8_t **image_ref, H5F_drvrinfo_cache_ud_t *udata,
+ hbool_t extend_eoa);
+
/*********************/
/* Package Variables */
@@ -107,7 +110,7 @@ const H5AC_class_t H5AC_SUPERBLOCK[1] = {{
H5F__cache_superblock_verify_chksum, /* 'verify_chksum' callback */
H5F__cache_superblock_deserialize, /* 'deserialize' callback */
H5F__cache_superblock_image_len, /* 'image_len' callback */
- H5F__cache_superblock_pre_serialize,/* 'pre_serialize' callback */
+ NULL, /* 'pre_serialize' callback */
H5F__cache_superblock_serialize, /* 'serialize' callback */
NULL, /* 'notify' callback */
H5F__cache_superblock_free_icr, /* 'free_icr' callback */
@@ -148,6 +151,158 @@ H5FL_EXTERN(H5F_super_t);
/*-------------------------------------------------------------------------
+ * Function: H5F__superblock_prefix_decode
+ *
+ * Purpose: Decode a superblock prefix
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * December 15, 2016
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5F__superblock_prefix_decode(H5F_super_t *sblock, const uint8_t **image_ref,
+ const H5F_superblock_cache_ud_t *udata, hbool_t extend_eoa)
+{
+ const uint8_t *image = (const uint8_t *)*image_ref; /* Pointer into raw data buffer */
+ htri_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ /* Check arguments */
+ HDassert(sblock);
+ HDassert(image_ref);
+ HDassert(image);
+ HDassert(udata);
+ HDassert(udata->f);
+
+ /* Skip over signature (already checked when locating the superblock) */
+ image += H5F_SIGNATURE_LEN;
+
+ /* Superblock version */
+ sblock->super_vers = *image++;
+ if(sblock->super_vers > HDF5_SUPERBLOCK_VERSION_LATEST)
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad superblock version number")
+
+ /* Sanity check */
+ HDassert(((size_t)(image - (const uint8_t *)*image_ref)) == H5F_SUPERBLOCK_FIXED_SIZE);
+
+ /* Determine the size of addresses & size of offsets, for computing the
+ * variable-sized portion of the superblock.
+ */
+ if(sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) {
+ sblock->sizeof_addr = image[4];
+ sblock->sizeof_size = image[5];
+ } /* end if */
+ else {
+ sblock->sizeof_addr = image[0];
+ sblock->sizeof_size = image[1];
+ } /* end else */
+ if(sblock->sizeof_addr != 2 && sblock->sizeof_addr != 4 &&
+ sblock->sizeof_addr != 8 && sblock->sizeof_addr != 16 && sblock->sizeof_addr != 32)
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad byte number in an address")
+ if(sblock->sizeof_size != 2 && sblock->sizeof_size != 4 &&
+ sblock->sizeof_size != 8 && sblock->sizeof_size != 16 && sblock->sizeof_size != 32)
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad byte number for object size")
+
+ /* Check for extending the EOA for the file */
+ if(extend_eoa) {
+ size_t variable_size; /* Variable size of superblock */
+
+ /* Determine the size of the variable-length part of the superblock */
+ variable_size = (size_t)H5F_SUPERBLOCK_VARLEN_SIZE(sblock->super_vers, sblock->sizeof_addr, sblock->sizeof_size);
+ HDassert(variable_size > 0);
+
+ /* Make certain we can read the variable-sized portion of the superblock */
+ if(H5F__set_eoa(udata->f, H5FD_MEM_SUPER, (haddr_t)(H5F_SUPERBLOCK_FIXED_SIZE + variable_size)) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "set end of space allocation request failed")
+ } /* end if */
+
+ /* Update the image buffer pointer */
+ *image_ref = image;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5F__superblock_prefix_decode() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5F__drvrinfo_prefix_decode
+ *
+ * Purpose: Decode a driver info prefix
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * December 15, 2016
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5F__drvrinfo_prefix_decode(H5O_drvinfo_t *drvrinfo, char *drv_name,
+ const uint8_t **image_ref, H5F_drvrinfo_cache_ud_t *udata,
+ hbool_t extend_eoa)
+{
+ const uint8_t *image = (const uint8_t *)*image_ref; /* Pointer into raw data buffer */
+ unsigned drv_vers; /* Version of driver info block */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ /* Sanity check */
+ HDassert(drvrinfo);
+ HDassert(image_ref);
+ HDassert(image);
+ HDassert(udata);
+ HDassert(udata->f);
+
+ /* Version number */
+ drv_vers = *image++;
+ if(drv_vers != HDF5_DRIVERINFO_VERSION_0)
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad driver information block version number")
+
+ image += 3; /* reserved bytes */
+
+ /* Driver info size */
+ UINT32DECODE(image, drvrinfo->len);
+
+ /* Driver name and/or version */
+ if(drv_name) {
+ HDmemcpy(drv_name, (const char *)image, (size_t)8);
+ drv_name[8] = '\0';
+ image += 8; /* advance past name/version */
+ } /* end if */
+
+ /* Extend the EOA if required so that we can read the complete driver info block */
+ if(extend_eoa) {
+ haddr_t eoa; /* Current EOA for the file */
+ haddr_t min_eoa; /* Minimum EOA needed for reading the driver info */
+
+ /* Get current EOA... */
+ eoa = H5FD_get_eoa(udata->f->shared->lf, H5FD_MEM_SUPER);
+ if(!H5F_addr_defined(eoa))
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "driver get_eoa request failed")
+
+ /* ... if it is too small, extend it. */
+ min_eoa = udata->driver_addr + H5F_DRVINFOBLOCK_HDR_SIZE + drvrinfo->len;
+
+ /* If it grew, set it */
+ if(H5F_addr_gt(min_eoa, eoa))
+ if(H5FD_set_eoa(udata->f->shared->lf, H5FD_MEM_SUPER, min_eoa) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "set end of space allocation request failed")
+ } /* end if */
+
+ /* Update the image buffer pointer */
+ *image_ref = image;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5F__drvrinfo_prefix_decode() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5F__cache_superblock_get_initial_load_size
*
* Purpose: Compute the size of the data structure on disk.
@@ -195,10 +350,7 @@ H5F__cache_superblock_get_final_load_size(const void *_image, size_t image_len,
{
const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */
H5F_superblock_cache_ud_t *udata = (H5F_superblock_cache_ud_t *)_udata; /* User data */
- unsigned super_vers; /* Superblock version */
- uint8_t sizeof_addr; /* Size of offsets in the file (in bytes) */
- uint8_t sizeof_size; /* Size of lengths in the file (in bytes) */
- size_t variable_size; /* Variable size of superblock */
+ H5F_super_t sblock; /* Temporary file superblock */
htri_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -206,56 +358,20 @@ H5F__cache_superblock_get_final_load_size(const void *_image, size_t image_len,
/* Check arguments */
HDassert(image);
HDassert(udata);
- HDassert(udata->f);
HDassert(actual_len);
HDassert(*actual_len == image_len);
-
- /* Skip over file signature */
- image += H5F_SIGNATURE_LEN;
-
- /* Superblock version */
- super_vers = *image++;
- if(super_vers > HDF5_SUPERBLOCK_VERSION_LATEST)
- HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad superblock version number")
-
- /* Save the version to be used in verify_chksum callback */
- udata->super_vers = super_vers;
-
- /* Sanity check */
- HDassert(((size_t)(image - (const uint8_t *)_image)) == H5F_SUPERBLOCK_FIXED_SIZE);
HDassert(image_len >= H5F_SUPERBLOCK_FIXED_SIZE + 6);
- /* Determine the size of addresses & size of offsets, for computing the
- * variable-sized portion of the superblock.
- */
- if(super_vers < HDF5_SUPERBLOCK_VERSION_2) {
- sizeof_addr = image[4];
- sizeof_size = image[5];
- } /* end if */
- else {
- sizeof_addr = image[0];
- sizeof_size = image[1];
- } /* end else */
- if(sizeof_addr != 2 && sizeof_addr != 4 &&
- sizeof_addr != 8 && sizeof_addr != 16 && sizeof_addr != 32)
- HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad byte number in an address")
- if(sizeof_size != 2 && sizeof_size != 4 &&
- sizeof_size != 8 && sizeof_size != 16 && sizeof_size != 32)
- HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad byte number for object size")
-
- /* Determine the size of the variable-length part of the superblock */
- variable_size = (size_t)H5F_SUPERBLOCK_VARLEN_SIZE(super_vers, sizeof_addr, sizeof_size);
- HDassert(variable_size > 0);
+ /* Deserialize the file superblock's prefix */
+ if(H5F__superblock_prefix_decode(&sblock, &image, udata, TRUE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, FAIL, "can't decode file superblock prefix")
- /* Sanity check */
- HDassert(image_len == (H5F_SUPERBLOCK_FIXED_SIZE + H5F_SUPERBLOCK_MINIMAL_VARLEN_SIZE));
-
- /* Make certain we can read the variable-sized portion of the superblock */
- if(H5F__set_eoa(udata->f, H5FD_MEM_SUPER, (haddr_t)(H5F_SUPERBLOCK_FIXED_SIZE + variable_size)) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "set end of space allocation request failed")
+ /* Save the version to be used in verify_chksum callback */
+ udata->super_vers = sblock.super_vers;
/* Set the final size for the cache image */
- *actual_len = H5F_SUPERBLOCK_FIXED_SIZE + variable_size;
+ *actual_len = H5F_SUPERBLOCK_FIXED_SIZE +
+ (size_t)H5F_SUPERBLOCK_VARLEN_SIZE(sblock.super_vers, sblock.sizeof_addr, sblock.sizeof_size);
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -325,10 +441,6 @@ H5F__cache_superblock_deserialize(const void *_image, size_t len, void *_udata,
H5F_super_t *sblock = NULL; /* File's superblock */
H5F_superblock_cache_ud_t *udata = (H5F_superblock_cache_ud_t *)_udata; /* User data */
const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */
- size_t variable_size; /* Variable size of superblock */
- unsigned super_vers; /* Superblock version */
- uint8_t sizeof_addr; /* Size of offsets in the file (in bytes) */
- uint8_t sizeof_size; /* Size of lengths in the file (in bytes) */
H5F_super_t *ret_value = NULL; /* Return value */
FUNC_ENTER_STATIC
@@ -337,54 +449,18 @@ H5F__cache_superblock_deserialize(const void *_image, size_t len, void *_udata,
HDassert(image);
HDassert(udata);
HDassert(udata->f);
+ HDassert(len >= H5F_SUPERBLOCK_FIXED_SIZE + 6);
/* Allocate space for the superblock */
if(NULL == (sblock = H5FL_CALLOC(H5F_super_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- /* Skip over signature (already checked when locating the superblock) */
- image += H5F_SIGNATURE_LEN;
-
- /* Superblock version */
- super_vers = *image++;
- if(super_vers > HDF5_SUPERBLOCK_VERSION_LATEST)
- HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad superblock version number")
-
- /* Record the superblock version */
- sblock->super_vers = super_vers;
-
- /* Sanity check */
- HDassert(((size_t)(image - (const uint8_t *)_image)) == H5F_SUPERBLOCK_FIXED_SIZE);
- HDassert(len >= H5F_SUPERBLOCK_FIXED_SIZE + 6);
-
- /* Determine the size of addresses & size of offsets, for computing the
- * variable-sized portion of the superblock.
- */
- if(super_vers < HDF5_SUPERBLOCK_VERSION_2) {
- sizeof_addr = image[4];
- sizeof_size = image[5];
- } /* end if */
- else {
- sizeof_addr = image[0];
- sizeof_size = image[1];
- } /* end else */
- if(sizeof_addr != 2 && sizeof_addr != 4 &&
- sizeof_addr != 8 && sizeof_addr != 16 && sizeof_addr != 32)
- HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad byte number in an address")
- if(sizeof_size != 2 && sizeof_size != 4 &&
- sizeof_size != 8 && sizeof_size != 16 && sizeof_size != 32)
- HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad byte number for object size")
- sblock->sizeof_addr = sizeof_addr;
- sblock->sizeof_size = sizeof_size;
-
- /* Determine the size of the variable-length part of the superblock */
- variable_size = (size_t)H5F_SUPERBLOCK_VARLEN_SIZE(super_vers, sizeof_addr, sizeof_size);
- HDassert(variable_size > 0);
-
- HDassert(len == (H5F_SUPERBLOCK_FIXED_SIZE + variable_size));
+ /* Deserialize the file superblock's prefix */
+ if(H5F__superblock_prefix_decode(sblock, &image, udata, FALSE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, NULL, "can't decode file superblock prefix")
/* Check for older version of superblock format */
- if(super_vers < HDF5_SUPERBLOCK_VERSION_2) {
+ if(sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) {
uint32_t status_flags; /* File status flags */
unsigned sym_leaf_k; /* Symbol table leaf node's 'K' value */
unsigned snode_btree_k; /* B-tree symbol table internal node 'K' value */
@@ -405,21 +481,13 @@ H5F__cache_superblock_deserialize(const void *_image, size_t len, void *_udata,
if(HDF5_SHAREDHEADER_VERSION != *image++)
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad shared-header format version number")
- /* Size of file addresses */
- sizeof_addr = *image++;
- if(sizeof_addr != 2 && sizeof_addr != 4 &&
- sizeof_addr != 8 && sizeof_addr != 16 && sizeof_addr != 32)
- HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad byte number in an address")
- sblock->sizeof_addr = sizeof_addr;
- udata->f->shared->sizeof_addr = sizeof_addr; /* Keep a local copy also */
-
- /* Size of file sizes */
- sizeof_size = *image++;
- if(sizeof_size != 2 && sizeof_size != 4 &&
- sizeof_size != 8 && sizeof_size != 16 && sizeof_size != 32)
- HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad byte number for object size")
- sblock->sizeof_size = sizeof_size;
- udata->f->shared->sizeof_size = sizeof_size; /* Keep a local copy also */
+ /* Skip over size of file addresses (already decoded) */
+ image++;
+ udata->f->shared->sizeof_addr = sblock->sizeof_addr; /* Keep a local copy also */
+
+ /* Skip over size of file sizes (already decoded) */
+ image++;
+ udata->f->shared->sizeof_size = sblock->sizeof_size; /* Keep a local copy also */
/* Skip over reserved byte */
image++;
@@ -452,11 +520,11 @@ H5F__cache_superblock_deserialize(const void *_image, size_t len, void *_udata,
* If the superblock version # is greater than 0, read in the indexed
* storage B-tree internal 'K' value
*/
- if(super_vers > HDF5_SUPERBLOCK_VERSION_DEF) {
+ if(sblock->super_vers > HDF5_SUPERBLOCK_VERSION_DEF) {
UINT16DECODE(image, chunk_btree_k);
/* Reserved bytes are present only in version 1 */
- if(super_vers == HDF5_SUPERBLOCK_VERSION_1)
+ if(sblock->super_vers == HDF5_SUPERBLOCK_VERSION_1)
image += 2; /* reserved */
} /* end if */
else
@@ -498,21 +566,13 @@ H5F__cache_superblock_deserialize(const void *_image, size_t len, void *_udata,
else {
uint32_t read_chksum; /* Checksum read from file */
- /* Size of file addresses */
- sizeof_addr = *image++;
- if(sizeof_addr != 2 && sizeof_addr != 4 &&
- sizeof_addr != 8 && sizeof_addr != 16 && sizeof_addr != 32)
- HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad byte number in an address")
- sblock->sizeof_addr = sizeof_addr;
- udata->f->shared->sizeof_addr = sizeof_addr; /* Keep a local copy also */
-
- /* Size of file sizes */
- sizeof_size = *image++;
- if(sizeof_size != 2 && sizeof_size != 4 &&
- sizeof_size != 8 && sizeof_size != 16 && sizeof_size != 32)
- HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad byte number for object size")
- sblock->sizeof_size = sizeof_size;
- udata->f->shared->sizeof_size = sizeof_size; /* Keep a local copy also */
+ /* Skip over size of file addresses (already decoded) */
+ image++;
+ udata->f->shared->sizeof_addr = sblock->sizeof_addr; /* Keep a local copy also */
+
+ /* Skip over size of file sizes (already decoded) */
+ image++;
+ udata->f->shared->sizeof_size = sblock->sizeof_size; /* Keep a local copy also */
/* File status flags (not really used yet) */
sblock->status_flags = *image++;
@@ -588,120 +648,6 @@ H5F__cache_superblock_image_len(const void *_thing, size_t *image_len)
/*-------------------------------------------------------------------------
- * Function: H5FS__cache_hdf_pre_serialize
- *
- * Purpose: The current use of this function is a cludge to repair an
- * oversight in the conversion of the superblock code to use the
- * version 3 cache.
- *
- * In the V2 metadata cache callbacks, the superblock dirver info
- * message was updated in the flush routine. Note that this
- * operation only applies to version 2 or later superblocks.
- *
- * Somehow, this functionality was lost in the conversion to use
- * the V3 cache, causing failures with the multi file driver
- * (and possibly the family file driver as well).
- *
- * Performing this operation is impossible in the current
- * serialize routine, as the dxpl_id is not available. While
- * I am pretty sure that this is not the correct place for this
- * functionality, as I can see it causing problems with both
- * journaling and possibly parallel HDF5 as well, I am placing
- * code for the necessary update in the pre_serialize call for
- * now for testing purposes. We will almost certainly want to
- * change this.
- *
- * Return: Success: SUCCEED
- * Failure: FAIL
- *
- * Programmer: John Mainzer
- * 10/82/14
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5F__cache_superblock_pre_serialize(const H5F_t *f, hid_t dxpl_id,
- void *_thing, haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED len,
- haddr_t H5_ATTR_UNUSED *new_addr, size_t H5_ATTR_UNUSED *new_len,
- unsigned H5_ATTR_UNUSED *flags)
-{
- H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */
- H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */
- H5F_super_t *sblock = (H5F_super_t *)_thing; /* Pointer to the super block */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT
-
- /* Sanity check */
- HDassert(f);
- HDassert(sblock);
- HDassert(sblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC);
- HDassert(sblock->cache_info.type == H5AC_SUPERBLOCK);
- HDassert(flags);
-
- if(sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2) {
- /* WARNING: This code almost certainly doesn't belong here. Must
- * discuss with Quincey where to put it. Note issues
- * for journaling and possibly parallel.
- *
- * -- JRM
- */
- /* Update the driver information message in the superblock extension
- * if appropriate.
- */
- if(H5F_addr_defined(sblock->ext_addr)) {
- size_t driver_size; /* Size of driver info block (bytes)*/
- H5O_loc_t ext_loc; /* "Object location" for superblock extension */
-
- HDassert(sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2);
-
- /* Open the superblock extension's object header */
- if(H5F_super_ext_open((H5F_t *)f, sblock->ext_addr, &ext_loc) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, FAIL, "unable to open file's superblock extension")
-
- /* Check for ignoring the driver info for this file */
- if(!H5F_HAS_FEATURE(f, H5FD_FEAT_IGNORE_DRVRINFO)) {
- /* Check for driver info message */
- H5_CHECKED_ASSIGN(driver_size, size_t, H5FD_sb_size(f->shared->lf), hsize_t);
- if(driver_size > 0) {
- H5O_drvinfo_t drvinfo; /* Driver info */
- uint8_t dbuf[H5F_MAX_DRVINFOBLOCK_SIZE]; /* Driver info block encoding buffer */
-
- /* Sanity check */
- HDassert(driver_size <= H5F_MAX_DRVINFOBLOCK_SIZE);
-
- /* Encode driver-specific data */
- if(H5FD_sb_encode(f->shared->lf, drvinfo.name, dbuf) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to encode driver information")
-
- /* Set the ring type in the DXPL */
- if(H5AC_set_ring(dxpl_id, H5AC_RING_SBE, &dxpl, &orig_ring) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set ring value")
-
- /* Write driver info information to the superblock extension */
- drvinfo.len = driver_size;
- drvinfo.buf = dbuf;
- if(H5O_msg_write(&ext_loc, H5O_DRVINFO_ID, H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, &drvinfo, dxpl_id) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "unable to update driver info header message")
- } /* end if */
- } /* end if */
-
- /* Close the superblock extension object header */
- if(H5F_super_ext_close((H5F_t *)f, &ext_loc, dxpl_id, FALSE) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to close file's superblock extension")
- } /* end if */
- } /* end if */
-
-done:
- /* Reset the ring in the DXPL */
- if(H5AC_reset_ring(dxpl, orig_ring) < 0)
- HDONE_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set property value")
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5FS_cache_superblock_pre_serialize() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5F__cache_superblock_serialize
*
* Purpose: Flushes a dirty object to disk.
@@ -927,50 +873,24 @@ H5F__cache_drvrinfo_get_final_load_size(const void *_image, size_t image_len,
{
const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */
H5F_drvrinfo_cache_ud_t *udata = (H5F_drvrinfo_cache_ud_t *)_udata; /* User data */
- unsigned drv_vers; /* Version of driver info block */
- size_t drvinfo_len; /* Length of encoded buffer */
- haddr_t eoa; /* Current EOA for the file */
- haddr_t min_eoa; /* Minimum EOA needed for reading the driver info */
- htri_t ret_value = SUCCEED; /* Return value */
+ H5O_drvinfo_t drvrinfo; /* Driver info */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
/* Check arguments */
HDassert(image);
HDassert(udata);
- HDassert(udata->f);
HDassert(actual_len);
HDassert(*actual_len == image_len);
-
- /* Version number */
- drv_vers = *image++;
- if(drv_vers != HDF5_DRIVERINFO_VERSION_0)
- HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad driver information block version number")
-
- image += 3; /* reserved bytes */
-
- /* Driver info size */
- UINT32DECODE(image, drvinfo_len);
-
- /* Sanity check */
HDassert(image_len == H5F_DRVINFOBLOCK_HDR_SIZE);
- /* Extend the EOA if required so that we can read the complete driver info block */
-
- /* Get current EOA... */
- if((eoa = H5FD_get_eoa(udata->f->shared->lf, H5FD_MEM_SUPER)) == HADDR_UNDEF)
- HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "driver get_eoa request failed")
-
- /* ... if it is too small, extend it. */
- min_eoa = udata->driver_addr + H5F_DRVINFOBLOCK_HDR_SIZE + drvinfo_len;
-
- /* If it grew, set it */
- if(H5F_addr_gt(min_eoa, eoa))
- if(H5FD_set_eoa(udata->f->shared->lf, H5FD_MEM_SUPER, min_eoa) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "set end of space allocation request failed")
+ /* Deserialize the file driver info's prefix */
+ if(H5F__drvrinfo_prefix_decode(&drvrinfo, NULL, &image, udata, TRUE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, FAIL, "can't decode file driver info prefix")
/* Set the final size for the cache image */
- *actual_len = H5F_DRVINFOBLOCK_HDR_SIZE + drvinfo_len;
+ *actual_len = H5F_DRVINFOBLOCK_HDR_SIZE + drvrinfo.len;
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -982,7 +902,7 @@ done:
*
* Purpose: Loads an object from the disk.
*
- * Return: Success: Pointer to a new B-tree.
+ * Return: Success: Pointer to a new driver info struct
* Failure: NULL
*
* Programmer: Quincey Koziol
@@ -999,7 +919,6 @@ H5F__cache_drvrinfo_deserialize(const void *_image, size_t len, void *_udata,
H5F_drvrinfo_cache_ud_t *udata = (H5F_drvrinfo_cache_ud_t *)_udata; /* User data */
const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */
char drv_name[9]; /* Name of driver */
- unsigned drv_vers; /* Version of driver info block */
H5O_drvinfo_t *ret_value = NULL; /* Return value */
FUNC_ENTER_STATIC
@@ -1014,21 +933,11 @@ H5F__cache_drvrinfo_deserialize(const void *_image, size_t len, void *_udata,
if(NULL == (drvinfo = (H5O_drvinfo_t *)H5MM_calloc(sizeof(H5O_drvinfo_t))))
HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, NULL, "memory allocation failed for driver info message")
- /* Version number */
- drv_vers = *image++;
- if(drv_vers != HDF5_DRIVERINFO_VERSION_0)
- HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad driver information block version number")
-
- image += 3; /* reserved bytes */
-
- /* Driver info size */
- UINT32DECODE(image, drvinfo->len);
-
- /* Driver name and/or version */
- HDstrncpy(drv_name, (const char *)image, (size_t)8);
- drv_name[8] = '\0';
- image += 8; /* advance past name/version */
+ /* Deserialize the file driver info's prefix */
+ if(H5F__drvrinfo_prefix_decode(drvinfo, drv_name, &image, udata, FALSE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, NULL, "can't decode file driver info prefix")
+ /* Sanity check */
HDassert(len == (H5F_DRVINFOBLOCK_HDR_SIZE + drvinfo->len));
/* Validate and decode driver information */