summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5F.c121
-rw-r--r--src/H5Fpkg.h1
-rw-r--r--src/H5Fprivate.h20
-rw-r--r--src/H5Fsuper.c341
-rw-r--r--src/H5Oshmesg.c4
-rw-r--r--src/H5Pfcpl.c34
-rwxr-xr-xsrc/H5SM.c103
-rw-r--r--src/H5SMcache.c3
-rwxr-xr-xsrc/H5SMprivate.h4
-rw-r--r--src/H5private.h21
10 files changed, 310 insertions, 342 deletions
diff --git a/src/H5F.c b/src/H5F.c
index 36e1053..603c438 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -737,74 +737,6 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5F_locate_signature
- *
- * Purpose: Finds the HDF5 super block signature in a file. The signature
- * can appear at address 0, or any power of two beginning with
- * 512.
- *
- * Return: Success: The absolute format address of the signature.
- *
- * Failure: HADDR_UNDEF
- *
- * Programmer: Robb Matzke
- * Friday, November 7, 1997
- *
- * Modifications:
- * Robb Matzke, 1999-08-02
- * Rewritten to use the virtual file layer.
- *-------------------------------------------------------------------------
- */
-haddr_t
-H5F_locate_signature(H5FD_t *file, hid_t dxpl_id)
-{
- haddr_t addr, eoa;
- uint8_t buf[H5F_SIGNATURE_LEN];
- unsigned n, maxpow;
- haddr_t ret_value; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT(H5F_locate_signature)
-
- /* Find the least N such that 2^N is larger than the file size */
- if (HADDR_UNDEF==(addr=H5FD_get_eof(file)) ||
- HADDR_UNDEF==(eoa=H5FD_get_eoa(file, H5FD_MEM_SUPER)))
- HGOTO_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF, "unable to obtain EOF/EOA value")
- for (maxpow=0; addr; maxpow++)
- addr>>=1;
- maxpow = MAX(maxpow, 9);
-
- /*
- * Search for the file signature at format address zero followed by
- * powers of two larger than 9.
- */
- for (n=8; n<maxpow; n++) {
- addr = (8==n) ? 0 : (haddr_t)1 << n;
- if (H5FD_set_eoa(file, H5FD_MEM_SUPER, addr+H5F_SIGNATURE_LEN) < 0)
- HGOTO_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF, "unable to set EOA value for file signature")
- if (H5FD_read(file, H5FD_MEM_SUPER, dxpl_id, addr, (size_t)H5F_SIGNATURE_LEN, buf) < 0)
- HGOTO_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF, "unable to read file signature")
- if (!HDmemcmp(buf, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN))
- break;
- }
-
- /*
- * If the signature was not found then reset the EOA value and return
- * failure.
- */
- if (n>=maxpow) {
- (void)H5FD_set_eoa(file, H5FD_MEM_SUPER, eoa); /* Ignore return value */
- HGOTO_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF, "unable to find a valid file signature")
- }
-
- /* Set return value */
- ret_value=addr;
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-}
-
-
-/*-------------------------------------------------------------------------
* Function: H5Fis_hdf5
*
* Purpose: Check the file signature to detect an HDF5 file.
@@ -896,9 +828,6 @@ static H5F_t *
H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf)
{
H5F_t *f = NULL, *ret_value;
- unsigned sohm_indexes;
- unsigned super_vers = HDF5_SUPERBLOCK_VERSION_DEF;
- H5P_genplist_t *plist; /* Property list */
FUNC_ENTER_NOAPI_NOINIT(H5F_new)
@@ -911,6 +840,9 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf)
f->shared = shared;
} /* end if */
else {
+ unsigned super_vers = HDF5_SUPERBLOCK_VERSION_DEF; /* Superblock version for file */
+ H5P_genplist_t *plist; /* Property list */
+
HDassert(lf != NULL);
if(NULL == (f->shared = H5FL_CALLOC(H5F_file_t)))
HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate shared file structure")
@@ -941,38 +873,21 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get byte number for object size")
if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, &f->shared->btree_k[0]) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "unable to get rank for btree internal nodes")
-
- /* Check for non-default indexed storage B-tree internal 'K' value
- * and set the version # of the superblock to 1 if it is a non-default
- * value.
- */
- if(f->shared->btree_k[H5B_ISTORE_ID] != HDF5_BTREE_ISTORE_IK_DEF)
- super_vers = HDF5_SUPERBLOCK_VERSION_1; /* Super block version 1 */
-
- /* The shared object header message table gets created later, but if
- * it is present we should use version 2 of the superblock.
- */
- if(H5P_get(plist, H5F_CRT_SHMSG_NINDEXES_NAME, &sohm_indexes)<0)
+ if(H5P_get(plist, H5F_CRT_SHMSG_NINDEXES_NAME, &f->shared->sohm_nindexes)<0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get number of SOHM indexes")
- HDassert(sohm_indexes < 255);
- f->shared->sohm_nindexes = sohm_indexes;
-
- /* Bump superblock version to hold SOHM info */
- if(sohm_indexes > 0)
- super_vers = HDF5_SUPERBLOCK_VERSION_2; /* Super block version 2 */
+ HDassert(f->shared->sohm_nindexes < 255);
+ /* Get the FAPL values to cache */
if(NULL == (plist = H5I_object(fapl_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list")
if(H5P_get(plist, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, &(f->shared->mdc_initCacheCfg)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get initial meta data cache resize config")
-
if(H5P_get(plist, H5F_ACS_DATA_CACHE_ELMT_SIZE_NAME, &(f->shared->rdcc_nelmts)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get data cache element size")
if(H5P_get(plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, &(f->shared->rdcc_nbytes)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get data cache cache size")
if(H5P_get(plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, &(f->shared->rdcc_w0)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get preempt read chunk")
-
if(H5P_get(plist, H5F_ACS_ALIGN_THRHD_NAME, &(f->shared->threshold)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get alignment threshold")
if(H5P_get(plist, H5F_ACS_ALIGN_NAME, &(f->shared->alignment)) < 0)
@@ -984,16 +899,28 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf)
if(H5P_get(plist, H5F_ACS_LATEST_FORMAT_NAME, &(f->shared->latest_format)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'latest format' flag")
- /* If a newer super block version is required, set it here */
- if(super_vers != HDF5_SUPERBLOCK_VERSION_DEF)
- {
+ /* Bump superblock version if we are to use the latest version of the format */
+ if(f->shared->latest_format)
+ super_vers = HDF5_SUPERBLOCK_VERSION_LATEST;
+ /* Bump superblock version to create superblock extension for SOHM info */
+ else if(f->shared->sohm_nindexes > 0)
+ super_vers = HDF5_SUPERBLOCK_VERSION_2;
+ /* Check for non-default indexed storage B-tree internal 'K' value
+ * and set the version # of the superblock to 1 if it is a non-default
+ * value.
+ */
+ else if(f->shared->btree_k[H5B_ISTORE_ID] != HDF5_BTREE_ISTORE_IK_DEF)
+ super_vers = HDF5_SUPERBLOCK_VERSION_1;
+
+ /* If a newer superblock version is required, set it here */
+ if(super_vers != HDF5_SUPERBLOCK_VERSION_DEF) {
H5P_genplist_t *c_plist; /* Property list */
if(NULL == (c_plist = H5I_object(f->shared->fcpl_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not property list")
if(H5P_set(c_plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set superblock version")
- }
+ } /* end if */
/*
* Create a meta data cache with the specified number of elements.
@@ -1766,8 +1693,8 @@ done:
* Function: H5F_flush
*
* Purpose: Flushes (and optionally invalidates) cached data plus the
- * file super block. If the logical file size field is zero
- * then it is updated to be the length of the super block.
+ * file superblock. If the logical file size field is zero
+ * then it is updated to be the length of the superblock.
*
* Return: Non-negative on success/Negative on failure
*
diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h
index c699485..9a76472 100644
--- a/src/H5Fpkg.h
+++ b/src/H5Fpkg.h
@@ -80,7 +80,6 @@ typedef struct H5F_file_t {
haddr_t super_addr; /* Absolute address of super block */
haddr_t base_addr; /* Absolute base address for rel.addrs. */
haddr_t extension_addr; /* Relative address of superblock extension */
- H5O_shmesg_table_t sohm_table; /* Shared message table information */
haddr_t sohm_addr; /* Relative address of shared object header message table */
unsigned sohm_vers; /* Version of shared message table on disk */
unsigned sohm_nindexes; /* Number of shared messages indexes in the table */
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index fc7df5b..ee81c6d 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -381,6 +381,26 @@ typedef struct H5F_t H5F_t;
#define H5_PAR_META_WRITE 0
#endif /* H5_HAVE_PARALLEL */
+/* Version #'s of the major components of the file format */
+#define HDF5_SUPERBLOCK_VERSION_DEF 0 /* The default super block format */
+#define HDF5_SUPERBLOCK_VERSION_1 1 /* Version with non-default B-tree 'K' value */
+#define HDF5_SUPERBLOCK_VERSION_2 2 /* Version with superblock extension and checksum */
+#define HDF5_SUPERBLOCK_VERSION_LATEST HDF5_SUPERBLOCK_VERSION_2 /* The maximum super block format */
+#define HDF5_FREESPACE_VERSION 0 /* of the Free-Space Info */
+#define HDF5_OBJECTDIR_VERSION 0 /* of the Object Directory format */
+#define HDF5_SHAREDHEADER_VERSION 0 /* of the Shared-Header Info */
+#define HDF5_DRIVERINFO_VERSION_0 0 /* of the Driver Information Block*/
+#define HDF5_DRIVERINFO_VERSION_LATEST HDF5_DRIVERINFO_VERSION_0 /* Maximum driver info block format */
+
+/* B-tree internal 'K' values */
+#define HDF5_BTREE_SNODE_IK_DEF 16
+#define HDF5_BTREE_ISTORE_IK_DEF 32 /* Note! this value is assumed
+ to be 32 for version 0
+ of the superblock and
+ if it is changed, the code
+ must compensate. -QAK
+ */
+
/* Forward declarations for prototype arguments */
struct H5B_class_t;
struct H5RC_t;
diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c
index ffb101f..295adca 100644
--- a/src/H5Fsuper.c
+++ b/src/H5Fsuper.c
@@ -54,7 +54,7 @@
/* Macros for computing variable-size superblock size */
#define H5F_SUPERBLOCK_VARLEN_SIZE_V0(f) \
( H5F_SIZEOF_ADDR(f) /* base address */ \
- + H5F_SIZEOF_ADDR(f) /* free space address */ \
+ + H5F_SIZEOF_ADDR(f) /* <unused> */ \
+ H5F_SIZEOF_ADDR(f) /* EOF address */ \
+ H5F_SIZEOF_ADDR(f) /* driver block address */ \
+ H5G_SIZEOF_ENTRY(f)) /* root group ptr */
@@ -62,18 +62,18 @@
( 2 /* indexed B-tree internal k */ \
+ 2 /* reserved */ \
+ H5F_SIZEOF_ADDR(f) /* base address */ \
- + H5F_SIZEOF_ADDR(f) /* free space address */ \
+ + H5F_SIZEOF_ADDR(f) /* <unused> */ \
+ H5F_SIZEOF_ADDR(f) /* EOF address */ \
+ H5F_SIZEOF_ADDR(f) /* driver block address */ \
+ H5G_SIZEOF_ENTRY(f)) /* root group ptr */
#define H5F_SUPERBLOCK_VARLEN_SIZE_V2(f) \
( 2 /* indexed B-tree internal k */ \
+ H5F_SIZEOF_ADDR(f) /* base address */ \
- + H5F_SIZEOF_ADDR(f) /* free space address */ \
+ + H5F_SIZEOF_ADDR(f) /* superblock extension address */ \
+ H5F_SIZEOF_ADDR(f) /* EOF address */ \
+ H5F_SIZEOF_ADDR(f) /* driver block address */ \
+ H5G_SIZEOF_ENTRY(f) /* root group ptr */ \
- + H5F_SIZEOF_CHKSUM)
+ + H5F_SIZEOF_CHKSUM) /* superblock + driver info block checksum (keep this last) */
#define H5F_SUPERBLOCK_VARLEN_SIZE(v, f) ( \
(v == 0 ? H5F_SUPERBLOCK_VARLEN_SIZE_V0(f) : 0) \
+ (v == 1 ? H5F_SUPERBLOCK_VARLEN_SIZE_V1(f) : 0) \
@@ -85,7 +85,6 @@
/* Driver info block macros */
#define H5F_DRVINFOBLOCK_HDR_SIZE 16
-#define H5F_DRVINFO_CHKSUM(v) (v == 0 ? 0 : H5F_SIZEOF_CHKSUM)
/* Maximum size of super-block buffers */
#define H5F_MAX_SUPERBLOCK_SIZE 134
@@ -145,6 +144,70 @@ H5F_init_super_interface(void)
/*-------------------------------------------------------------------------
+ * Function: H5F_locate_signature
+ *
+ * Purpose: Finds the HDF5 superblock signature in a file. The signature
+ * can appear at address 0, or any power of two beginning with
+ * 512.
+ *
+ * Return: Success: The absolute format address of the signature.
+ *
+ * Failure: HADDR_UNDEF
+ *
+ * Programmer: Robb Matzke
+ * Friday, November 7, 1997
+ *
+ *-------------------------------------------------------------------------
+ */
+haddr_t
+H5F_locate_signature(H5FD_t *file, hid_t dxpl_id)
+{
+ haddr_t addr, eoa;
+ uint8_t buf[H5F_SIGNATURE_LEN];
+ unsigned n, maxpow;
+ haddr_t ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5F_locate_signature)
+
+ /* Find the least N such that 2^N is larger than the file size */
+ if(HADDR_UNDEF == (addr = H5FD_get_eof(file)) || HADDR_UNDEF == (eoa = H5FD_get_eoa(file, H5FD_MEM_SUPER)))
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF, "unable to obtain EOF/EOA value")
+ for(maxpow = 0; addr; maxpow++)
+ addr >>= 1;
+ maxpow = MAX(maxpow, 9);
+
+ /*
+ * Search for the file signature at format address zero followed by
+ * powers of two larger than 9.
+ */
+ for(n = 8; n < maxpow; n++) {
+ addr = (8 == n) ? 0 : (haddr_t)1 << n;
+ if(H5FD_set_eoa(file, H5FD_MEM_SUPER, addr+H5F_SIGNATURE_LEN) < 0)
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF, "unable to set EOA value for file signature")
+ if(H5FD_read(file, H5FD_MEM_SUPER, dxpl_id, addr, (size_t)H5F_SIGNATURE_LEN, buf) < 0)
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF, "unable to read file signature")
+ if(!HDmemcmp(buf, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN))
+ break;
+ } /* end for */
+
+ /*
+ * If the signature was not found then reset the EOA value and return
+ * failure.
+ */
+ if(n >= maxpow) {
+ (void)H5FD_set_eoa(file, H5FD_MEM_SUPER, eoa); /* Ignore return value */
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF, "unable to find a valid file signature")
+ } /* end if */
+
+ /* Set return value */
+ ret_value = addr;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5F_locate_signature() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5F_read_superblock
*
* Purpose: Reads the superblock from the file or from the BUF. If
@@ -166,8 +229,8 @@ H5F_read_superblock(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc)
{
haddr_t stored_eoa; /*relative end-of-addr in file */
haddr_t eof; /*end of file address */
- size_t sizeof_addr = 0;
- size_t sizeof_size = 0;
+ size_t sizeof_addr; /* Size of offsets in the file (in bytes) */
+ size_t sizeof_size; /* Size of lengths in the file (in bytes) */
const size_t fixed_size = H5F_SUPERBLOCK_FIXED_SIZE; /*fixed sizeof superblock */
unsigned sym_leaf_k = 0;
size_t variable_size; /*variable sizeof superblock */
@@ -175,17 +238,11 @@ H5F_read_superblock(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc)
H5F_file_t *shared = NULL; /* shared part of `file' */
H5FD_t *lf = NULL; /* file driver part of `shared' */
uint8_t *p; /* Temporary pointer into encoding buffers */
- uint32_t read_chksum; /* Checksum read from file */
- uint32_t computed_chksum; /* Computed checksum */
- size_t driver_size; /* Size of driver info block, in bytes */
- char driver_name[9]; /* Name of driver, for driver info block */
unsigned super_vers; /* Superblock version */
unsigned freespace_vers; /* Freespace info version */
unsigned obj_dir_vers; /* Object header info version */
unsigned share_head_vers; /* Shared header info version */
- uint8_t sbuf[H5F_MAX_SUPERBLOCK_SIZE]; /* Local buffer */
- size_t buf_size = sizeof(sbuf); /* Size of superblock buffer */
- unsigned nindexes; /* Number of shared message indexes */
+ uint8_t buf[H5F_MAX_SUPERBLOCK_SIZE + H5F_MAX_DRVINFOBLOCK_SIZE]; /* Buffer for superblock & driver info block */
H5P_genplist_t *c_plist; /* File creation property list */
herr_t ret_value = SUCCEED;
@@ -196,26 +253,26 @@ H5F_read_superblock(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc)
lf = shared->lf;
/* Get the shared file creation property list */
- if (NULL == (c_plist = H5I_object(shared->fcpl_id)))
+ if(NULL == (c_plist = H5I_object(shared->fcpl_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list")
- /* Read the superblock */
+ /* Find the superblock */
if(HADDR_UNDEF == (shared->super_addr = H5F_locate_signature(lf, dxpl_id)))
HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to find file signature")
/* Read fixed-size portion of the superblock */
- p = sbuf;
+ p = buf;
if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, shared->super_addr + fixed_size) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "set end of space allocation request failed")
if(H5FD_read(lf, H5FD_MEM_SUPER, dxpl_id, shared->super_addr, fixed_size, p) < 0)
HGOTO_ERROR(H5E_FILE, H5E_READERROR, FAIL, "unable to read superblock")
- /* Signature, already checked */
+ /* Signature, already checked (when locating the superblock) */
p += H5F_SIGNATURE_LEN;
/* Superblock version */
super_vers = *p++;
- if(super_vers > HDF5_SUPERBLOCK_VERSION_MAX)
+ if(super_vers > HDF5_SUPERBLOCK_VERSION_LATEST)
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad superblock version number")
if(H5P_set(c_plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set superblock version")
@@ -286,12 +343,12 @@ H5F_read_superblock(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc)
/* File consistency flags. Not really used yet */
UINT32DECODE(p, shared->consist_flags);
- HDassert(((size_t)(p - sbuf)) == fixed_size);
+ HDassert(((size_t)(p - buf)) == fixed_size);
/* Determine the size of the variable-length part of the superblock */
variable_size = H5F_SUPERBLOCK_VARLEN_SIZE(super_vers, f);
HDassert(variable_size > 0);
- HDassert(fixed_size + variable_size <= buf_size);
+ HDassert(fixed_size + variable_size <= sizeof(buf));
/* Read in variable-sized portion of superblock */
if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, shared->super_addr + fixed_size + variable_size) < 0)
@@ -317,6 +374,7 @@ H5F_read_superblock(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set rank for btree internal nodes")
HDmemcpy(shared->btree_k, btree_k, sizeof(unsigned) * (size_t)H5B_NUM_BTREE_ID); /* Keep a local copy also */
+ /* Remainder of "variable-sized" portion of superblock */
H5F_addr_decode(f, (const uint8_t **)&p, &shared->base_addr/*out*/);
H5F_addr_decode(f, (const uint8_t **)&p, &shared->extension_addr/*out*/);
H5F_addr_decode(f, (const uint8_t **)&p, &stored_eoa/*out*/);
@@ -324,18 +382,6 @@ H5F_read_superblock(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc)
if(H5G_obj_ent_decode(f, (const uint8_t **)&p, root_loc->oloc/*out*/) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to read root symbol entry")
- /* Compute superblock checksum for versions greater than 1 */
- if(super_vers >= HDF5_SUPERBLOCK_VERSION_2) {
- computed_chksum = H5_checksum_metadata(sbuf, (unsigned) (p - sbuf), 0);
- /* Read stored superblock checksum */
- UINT32DECODE(p, read_chksum);
-
- if(read_chksum != computed_chksum)
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "bad checksum on superblock")
- }
-
- HDassert((unsigned) (p - sbuf) == H5F_SUPERBLOCK_SIZE(super_vers, f));
-
/*
* Check if superblock address is different from base address and
* adjust base address and "end of address" address if so.
@@ -352,78 +398,94 @@ H5F_read_superblock(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc)
} /* end if */
- /* This step is for h5repart tool only. If user wants to change file driver from
- * family to sec2 while using h5repart, set the driver address to undefined to let
- * the library ignore the family driver information saved in the superblock.
+ /* This step is for h5repart tool only. If user wants to change file driver
+ * from family to sec2 while using h5repart, set the driver address to
+ * undefined to let the library ignore the family driver information saved
+ * in the superblock.
*/
if(shared->fam_to_sec2)
shared->driver_addr = HADDR_UNDEF;
/* Decode the optional driver information block */
if(H5F_addr_defined(shared->driver_addr)) {
- unsigned drv_vers;
+ char drv_name[9]; /* Name of driver */
+ unsigned drv_vers; /* Version of driver info block */
haddr_t drv_addr = shared->base_addr + shared->driver_addr;
- uint8_t dbuf[H5F_MAX_DRVINFOBLOCK_SIZE]; /* Local buffer */
- size_t dbuf_size = sizeof(dbuf); /* Size available for driver info */
+ size_t drv_fixed_size; /* Amount of fixed size driver info to read */
+ size_t drv_variable_size; /* Size of variable-length portion of driver info block, in bytes */
+
+ /* Account for extra data read in for superblock version > 1 */
+ /* (extra room is for the trailing checksum on the superblock + driver info block) */
+ if(super_vers >= HDF5_SUPERBLOCK_VERSION_2)
+ drv_fixed_size = (size_t)H5F_DRVINFOBLOCK_HDR_SIZE - H5F_SIZEOF_CHKSUM;
+ else
+ drv_fixed_size = (size_t)H5F_DRVINFOBLOCK_HDR_SIZE;
/* Read in fixed-sized portion of driver info block */
- p = dbuf;
if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, drv_addr + H5F_DRVINFOBLOCK_HDR_SIZE) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "set end of space allocation request failed")
- if(H5FD_read(lf, H5FD_MEM_SUPER, dxpl_id, drv_addr, (size_t)H5F_DRVINFOBLOCK_HDR_SIZE, p) < 0)
+ if(H5FD_read(lf, H5FD_MEM_SUPER, dxpl_id, drv_addr, drv_fixed_size, p) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to read driver information block")
/* Version number */
drv_vers = *p++;
- if(drv_vers > HDF5_DRIVERINFO_VERSION_MAX)
+ if(drv_vers > HDF5_DRIVERINFO_VERSION_LATEST)
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "bad driver information block version number")
p += 3; /* reserved bytes */
/* Driver info size */
- UINT32DECODE(p, driver_size);
+ UINT32DECODE(p, drv_variable_size);
- /* Driver name and/or version */
- HDstrncpy(driver_name, (const char *)p, (size_t)8);
- driver_name[8] = '\0';
- p += 8; /* advance past name/version */
+ /* Account for extra data to read for superblock version > 1 */
+ /* (extra room is for the trailing checksum on the superblock + driver info block) */
+ if(super_vers >= HDF5_SUPERBLOCK_VERSION_2)
+ drv_variable_size += H5F_SIZEOF_CHKSUM;
- HDassert(p - dbuf == H5F_DRVINFOBLOCK_HDR_SIZE);
+ /* Sanity check */
+ HDassert(fixed_size + variable_size + drv_fixed_size + drv_variable_size <= sizeof(buf));
- /* Read driver information */
- HDassert((driver_size + H5F_DRVINFOBLOCK_HDR_SIZE + H5F_DRVINFO_CHKSUM(drv_vers)) <= dbuf_size);
+ /* Driver name and/or version */
+ HDstrncpy(drv_name, (const char *)p, (size_t)8);
+ drv_name[8] = '\0';
+ p += 8; /* advance past name/version */
/* Read in variable-sized portion of driver info block */
- if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, drv_addr + H5F_DRVINFOBLOCK_HDR_SIZE + driver_size + H5F_DRVINFO_CHKSUM(drv_vers)) < 0)
+ if(H5FD_set_eoa(lf, H5FD_MEM_SUPER, drv_addr + H5F_DRVINFOBLOCK_HDR_SIZE + drv_variable_size) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "set end of space allocation request failed")
- if(H5FD_read(lf, H5FD_MEM_SUPER, dxpl_id, drv_addr + H5F_DRVINFOBLOCK_HDR_SIZE, driver_size, p) < 0)
+ if(H5FD_read(lf, H5FD_MEM_SUPER, dxpl_id, drv_addr + H5F_DRVINFOBLOCK_HDR_SIZE, drv_variable_size, p) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to read file driver information")
/* Decode driver information */
/* Check if driver matches driver information saved. Unfortunately, we can't push this
- * function to each specific driver because we're checking if the driver is correct.*/
- if(!HDstrncmp(driver_name, "NCSAfami", (size_t)8) && HDstrcmp(lf->cls->name, "family"))
+ * function to each specific driver because we're checking if the driver is correct.
+ */
+ if(!HDstrncmp(drv_name, "NCSAfami", (size_t)8) && HDstrcmp(lf->cls->name, "family"))
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "family driver should be used")
- if(!HDstrncmp(driver_name, "NCSAmult", (size_t)8) && HDstrcmp(lf->cls->name, "multi"))
+ if(!HDstrncmp(drv_name, "NCSAmult", (size_t)8) && HDstrcmp(lf->cls->name, "multi"))
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "multi driver should be used")
/* Decode the driver-specific driver info block information */
- if(H5FD_sb_decode(lf, driver_name, p) < 0)
+ if(H5FD_sb_decode(lf, drv_name, p) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to decode driver information")
- p += driver_size;
+ /* Advance past variable length portion of driver info block */
+ p += drv_variable_size;
+ } /* end if */
- /* Compute checksum for versions > 0 */
- if(drv_vers >= HDF5_DRIVERINFO_VERSION_1) {
- computed_chksum = H5_checksum_metadata(dbuf, (H5F_DRVINFOBLOCK_HDR_SIZE + driver_size), 0);
- /* Read checksum */
- UINT32DECODE(p, read_chksum);
+ /* Compute checksum for superblock versions > 1 */
+ if(super_vers >= HDF5_SUPERBLOCK_VERSION_2) {
+ uint32_t computed_chksum; /* Computed checksum */
+ uint32_t read_chksum; /* Checksum read from file */
- if(read_chksum != computed_chksum)
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "bad checksum on driver information block")
- } /* end if */
-
- HDassert((unsigned) (p - dbuf) == driver_size + H5F_DRVINFOBLOCK_HDR_SIZE + H5F_DRVINFO_CHKSUM(drv_vers));
+ /* Compute checksum on superblock + driver info block */
+ computed_chksum = H5_checksum_metadata(buf, (size_t)(p - buf), 0);
+
+ /* Decode checksum */
+ UINT32DECODE(p, read_chksum);
+
+ if(read_chksum != computed_chksum)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "bad checksum on driver information block")
} /* end if */
/*
@@ -451,9 +513,15 @@ H5F_read_superblock(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc)
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to set end-of-address marker for file")
/* Read the file's superblock extension, if there is one. */
- if(shared->extension_addr != HADDR_UNDEF && super_vers >= HDF5_SUPERBLOCK_VERSION_2) {
- H5O_loc_t ext_loc;
+ if(H5F_addr_defined(shared->extension_addr)) {
+ H5O_loc_t ext_loc; /* "Object location" for superblock extension */
+
+ /* Sanity check - superblock extension should only be defined for
+ * superblock version >= 2.
+ */
+ HDassert(super_vers >= HDF5_SUPERBLOCK_VERSION_2);
+ /* Set up "fake" object location for superblock extension */
H5O_loc_reset(&ext_loc);
ext_loc.file = f;
ext_loc.addr = shared->extension_addr;
@@ -462,17 +530,9 @@ H5F_read_superblock(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc)
if(H5O_open(&ext_loc) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENFILE, FAIL, "unable to open superblock extension")
- /* Read in shared message information, if it exists */
- if(NULL == H5O_msg_read(&ext_loc, H5O_SHMESG_ID, &shared->sohm_table, dxpl_id)) {
- H5E_clear_stack(NULL);
- shared->sohm_addr = HADDR_UNDEF;
- shared->sohm_nindexes = 0;
- shared->sohm_vers = 0;
- } else {
- shared->sohm_addr = shared->sohm_table.addr;
- shared->sohm_vers = shared->sohm_table.version;
- shared->sohm_nindexes = shared->sohm_table.nindexes;
- }
+ /* Read in the shared OH message information if there is any */
+ if(H5SM_get_info(&ext_loc, c_plist, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to read SOHM table information")
/* Close the extension. Bump the version number to avoid closing the
* file (since this will be the only open object).
@@ -483,38 +543,6 @@ H5F_read_superblock(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc)
f->nopen_objs--;
} /* end if */
- /* Decode shared object header message information and store it in the FCPL */
- if(shared->sohm_addr != HADDR_UNDEF) {
- unsigned index_flags[H5O_SHMESG_MAX_NINDEXES] = {0};
- unsigned minsizes[H5O_SHMESG_MAX_NINDEXES] = {0};
- unsigned sohm_l2b; /* SOHM list-to-btree cutoff */
- unsigned sohm_b2l; /* SOHM btree-to-list cutoff */
-
- HDassert(shared->sohm_nindexes > 0 && shared->sohm_nindexes <= H5O_SHMESG_MAX_NINDEXES);
-
- /* Read in the shared OH message information if there is any */
- if(H5SM_get_info(f, index_flags, minsizes, &sohm_l2b, &sohm_b2l, dxpl_id) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to read SOHM table information")
-
- /* Set values in the property list */
- if(H5P_set(c_plist, H5F_CRT_SHMSG_NINDEXES_NAME, &(shared->sohm_nindexes)) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set number of SOHM indexes");
- if(H5P_set(c_plist, H5F_CRT_SHMSG_INDEX_TYPES_NAME, index_flags) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set type flags for indexes");
- if(H5P_set(c_plist, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, minsizes) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set type flags for indexes");
- if(H5P_set(c_plist, H5F_CRT_SHMSG_LIST_MAX_NAME, &sohm_l2b) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set SOHM cutoff in property list");
- if(H5P_set(c_plist, H5F_CRT_SHMSG_BTREE_MIN_NAME, &sohm_b2l) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set SOHM cutoff in property list");
- } /* end if */
- else {
- /* Shared object header messages are disabled */
- nindexes = 0;
- if(H5P_set(c_plist, H5F_CRT_SHMSG_NINDEXES_NAME, &nindexes) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set number of SOHM indexes");
- } /* end else */
-
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F_read_superblock() */
@@ -572,20 +600,14 @@ H5F_init_superblock(H5F_t *f, H5O_loc_t *ext_loc, hid_t dxpl_id)
/* Compute the size of the superblock */
superblock_size = H5F_SUPERBLOCK_SIZE(super_vers, f);
- /* Compute the size of the driver information block. Use driver block
- * version 1 if the superblock is at least version 2
- */
+ /* Compute the size of the driver information block */
H5_ASSIGN_OVERFLOW(driver_size, H5FD_sb_size(f->shared->lf), hsize_t, size_t);
if(driver_size > 0) {
driver_size += H5F_DRVINFOBLOCK_HDR_SIZE;
- if(super_vers > HDF5_SUPERBLOCK_VERSION_1)
- driver_size += H5F_DRVINFO_CHKSUM(1);
- else
- driver_size += H5F_DRVINFO_CHKSUM(0);
/*
* The file driver information block begins immediately after the
- * superblock.
+ * superblock. (relative to base address in file)
*/
f->shared->driver_addr = superblock_size;
} /* end if */
@@ -653,13 +675,11 @@ done:
herr_t
H5F_write_superblock(H5F_t *f, hid_t dxpl_id)
{
- uint8_t sbuf[H5F_MAX_SUPERBLOCK_SIZE]; /* Superblock encoding buffer */
- uint8_t dbuf[H5F_MAX_DRVINFOBLOCK_SIZE];/* Driver info block encoding buffer*/
+ uint8_t buf[H5F_MAX_SUPERBLOCK_SIZE + H5F_MAX_DRVINFOBLOCK_SIZE]; /* Superblock & driver info blockencoding buffer */
uint8_t *p = NULL; /* Ptr into encoding buffers */
- uint32_t chksum; /* Checksum temporary variable */
+ uint32_t chksum = 0; /* Checksum temporary variable */
size_t superblock_size; /* Size of superblock, in bytes */
size_t driver_size; /* Size of driver info block (bytes)*/
- char driver_name[9]; /* Name of driver, for driver info block */
unsigned super_vers; /* Superblock version */
unsigned freespace_vers; /* Freespace info version */
unsigned obj_dir_vers; /* Object header info version */
@@ -684,7 +704,7 @@ H5F_write_superblock(H5F_t *f, hid_t dxpl_id)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get shared-header format version")
/* Encode the file superblock */
- p = sbuf;
+ p = buf;
HDmemcpy(p, H5F_SIGNATURE, (size_t)H5F_SIGNATURE_LEN);
p += H5F_SIGNATURE_LEN;
*p++ = (uint8_t)super_vers;
@@ -719,71 +739,58 @@ H5F_write_superblock(H5F_t *f, hid_t dxpl_id)
H5F_addr_encode(f, &p, f->shared->extension_addr);
H5F_addr_encode(f, &p, H5FD_get_eoa(f->shared->lf, H5FD_MEM_SUPER));
H5F_addr_encode(f, &p, f->shared->driver_addr);
- if(H5G_obj_ent_encode(f, &p, H5G_oloc(f->shared->root_grp))<0)
+ if(H5G_obj_ent_encode(f, &p, H5G_oloc(f->shared->root_grp)) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to encode root group information")
/* Compute superblock checksum */
- if(super_vers >= HDF5_SUPERBLOCK_VERSION_2) {
- chksum = H5_checksum_metadata(sbuf, H5F_SUPERBLOCK_SIZE(super_vers, f) - H5F_SIZEOF_CHKSUM, 0);
- UINT32ENCODE(p, chksum);
- } /* end if */
-
- /* Double check we didn't overrun the block (unlikely) */
- H5_ASSIGN_OVERFLOW(superblock_size, p - sbuf, int, size_t);
- HDassert(superblock_size <= sizeof(sbuf));
-
- /* Double check that the superblock is the right size */
- HDassert(superblock_size == (H5F_SUPERBLOCK_SIZE(super_vers, f)));
-
- /* Write superblock */
- if(H5FD_write(f->shared->lf, H5FD_MEM_SUPER, dxpl_id, f->shared->super_addr, superblock_size, sbuf) < 0)
- HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write superblock")
+ if(super_vers >= HDF5_SUPERBLOCK_VERSION_2)
+ chksum = H5_checksum_metadata(buf, (H5F_SUPERBLOCK_SIZE(super_vers, f) - H5F_SIZEOF_CHKSUM), 0);
/* Encode the driver information block. */
H5_ASSIGN_OVERFLOW(driver_size, H5FD_sb_size(f->shared->lf), hsize_t, size_t);
if(driver_size > 0) {
- unsigned driver_vers;
+ char driver_name[9]; /* Name of driver, for driver info block */
+ uint8_t *dbuf = p; /* Pointer to beginning of driver info */
- /* Use driver info block version 1 on superblock version >= 2 */
- if(super_vers > HDF5_SUPERBLOCK_VERSION_1)
- driver_vers = HDF5_DRIVERINFO_VERSION_1;
- else
- driver_vers = HDF5_DRIVERINFO_VERSION_0;
-
- driver_size += H5F_DRVINFOBLOCK_HDR_SIZE + H5F_DRVINFO_CHKSUM(driver_vers);
-
- /* Double check we didn't overrun the block (unlikely) */
- HDassert(driver_size <= sizeof(dbuf));
+ /* Add in the size of the header */
+ driver_size += H5F_DRVINFOBLOCK_HDR_SIZE;
/* Encode the driver information block */
- p = dbuf;
-
- *p++ = driver_vers; /* Version */
+ *p++ = HDF5_DRIVERINFO_VERSION_0; /* Version */
*p++ = 0; /* reserved */
*p++ = 0; /* reserved */
*p++ = 0; /* reserved */
- /* Driver info size, excluding header and checksum */
- UINT32ENCODE(p, driver_size - H5F_DRVINFOBLOCK_HDR_SIZE - H5F_DRVINFO_CHKSUM(driver_vers));
+ /* Driver info size, excluding header */
+ UINT32ENCODE(p, driver_size - H5F_DRVINFOBLOCK_HDR_SIZE);
/* Encode driver-specific data */
if(H5FD_sb_encode(f->shared->lf, driver_name, dbuf + H5F_DRVINFOBLOCK_HDR_SIZE) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to encode driver information")
- /* Driver name */
+ /* Store driver name (set in 'H5FD_sb_encode' call above) */
HDmemcpy(dbuf + 8, driver_name, (size_t)8);
- /* Compute driver info block checksum on versions > 0 */
- if(driver_vers > HDF5_DRIVERINFO_VERSION_0) {
- chksum = H5_checksum_metadata(dbuf, (driver_size - H5F_SIZEOF_CHKSUM), 0);
- UINT32ENCODE(p, chksum);
- } /* end if */
-
- /* Write driver information block */
- if(H5FD_write(f->shared->lf, H5FD_MEM_SUPER, dxpl_id, f->shared->base_addr + f->shared->driver_addr, driver_size, dbuf) < 0)
- HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write driver information block")
+ /* Update superblock checksum with driver info block checksum */
+ /* (on superblock versions > 1) */
+ if(super_vers >= HDF5_SUPERBLOCK_VERSION_2)
+ chksum = H5_checksum_metadata(dbuf, driver_size, chksum);
} /* end if */
+ /* Encode the checksum on the superblock (for versions > 1) */
+ if(super_vers >= HDF5_SUPERBLOCK_VERSION_2)
+ UINT32ENCODE(p, chksum);
+
+ /* Retrieve the total size of the superblock info */
+ H5_ASSIGN_OVERFLOW(superblock_size, (p - buf), int, size_t);
+
+ /* Double check we didn't overrun the block (unlikely) */
+ HDassert(superblock_size <= sizeof(buf));
+
+ /* Write superblock */
+ if(H5FD_write(f->shared->lf, H5FD_MEM_SUPER, dxpl_id, f->shared->super_addr, superblock_size, buf) < 0)
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write superblock")
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F_write_superblock() */
diff --git a/src/H5Oshmesg.c b/src/H5Oshmesg.c
index 8f511a8..05898a3 100644
--- a/src/H5Oshmesg.c
+++ b/src/H5Oshmesg.c
@@ -89,7 +89,7 @@ H5O_shmesg_decode(H5F_t *f, hid_t UNUSED dxpl_id, unsigned UNUSED mesg_flags,
if(NULL == (mesg = H5MM_calloc(sizeof(H5O_shmesg_table_t))))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for shared message table message")
- /* Read version, table address, and number of indexes */
+ /* Retrieve version, table address, and number of indexes */
mesg->version = *p++;
H5F_addr_decode(f, &p, &(mesg->addr));
mesg->nindexes = *p++;
@@ -126,7 +126,7 @@ H5O_shmesg_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const voi
HDassert(p);
HDassert(mesg);
- /* Read version, table address, and number of indexes */
+ /* Store version, table address, and number of indexes */
*p++ = mesg->version;
H5F_addr_encode(f, &p, mesg->addr);
*p++ = mesg->nindexes;
diff --git a/src/H5Pfcpl.c b/src/H5Pfcpl.c
index 9ab78f8..e093f19 100644
--- a/src/H5Pfcpl.c
+++ b/src/H5Pfcpl.c
@@ -228,7 +228,6 @@ done:
* Purpose: Retrieves version information for various parts of a file.
*
* SUPER: The file super block.
- * HEAP: The global heap.
* FREELIST: The global free list.
* STAB: The root symbol table entry.
* SHHDR: Shared object headers.
@@ -244,44 +243,39 @@ done:
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
- * Modifications:
- *
- * Raymond Lu, Oct 14, 2001
- * Change to the new generic property list.
- *
*-------------------------------------------------------------------------
*/
herr_t
H5Pget_version(hid_t plist_id, unsigned *super/*out*/, unsigned *freelist/*out*/,
- unsigned *stab/*out*/, unsigned *shhdr/*out*/)
+ unsigned *stab/*out*/, unsigned *shhdr/*out*/)
{
H5P_genplist_t *plist; /* Property list pointer */
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_API(H5Pget_version, FAIL);
+ FUNC_ENTER_API(H5Pget_version, FAIL)
H5TRACE5("e", "ixxxx", plist_id, super, freelist, stab, shhdr);
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
/* Get values */
- if (super)
+ if(super)
if(H5P_get(plist, H5F_CRT_SUPER_VERS_NAME, super) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get superblock version");
- if (freelist)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get superblock version")
+ if(freelist)
if(H5P_get(plist, H5F_CRT_FREESPACE_VERS_NAME, freelist) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get free-space version");
- if (stab)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get free-space version")
+ if(stab)
if(H5P_get(plist, H5F_CRT_OBJ_DIR_VERS_NAME, stab) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object directory version");
- if (shhdr)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object directory version")
+ if(shhdr)
if(H5P_get(plist, H5F_CRT_SHARE_HEAD_VERS_NAME, shhdr) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get shared-header version");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get shared-header version")
done:
- FUNC_LEAVE_API(ret_value);
-}
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Pget_version() */
/*-------------------------------------------------------------------------
diff --git a/src/H5SM.c b/src/H5SM.c
index c2e2534..8192c21 100755
--- a/src/H5SM.c
+++ b/src/H5SM.c
@@ -705,7 +705,7 @@ H5SM_convert_list_to_btree(H5F_t * f, H5SM_index_header_t * header,
*/
HDmemcpy(&temp_header, header, sizeof(H5SM_index_header_t));
if(H5SM_delete_index(f, &temp_header, dxpl_id, FALSE) < 0)
- HGOTO_ERROR(H5E_SOHM, H5E_CANTDELETE, FAIL, "can't free list index");
+ HGOTO_ERROR(H5E_SOHM, H5E_CANTDELETE, FAIL, "can't free list index")
header->index_addr = tree_addr;
header->index_type = H5SM_BTREE;
@@ -1465,8 +1465,7 @@ done:
/*-------------------------------------------------------------------------
* Function: H5SM_get_info
*
- * Purpose: Get the list-to-btree and btree-to-list cutoff numbers for
- * an index within the master table.
+ * Purpose: Get the shared message info for a file, if there is any.
*
* Return: Non-negative on success/Negative on failure
*
@@ -1476,40 +1475,84 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5SM_get_info(H5F_t *f, unsigned *index_flags, unsigned *minsizes,
- unsigned *list_max, unsigned *btree_min, hid_t dxpl_id)
+H5SM_get_info(const H5O_loc_t *ext_loc, H5P_genplist_t *fc_plist, hid_t dxpl_id)
{
- H5SM_master_table_t *table = NULL;
- haddr_t table_addr;
- uint8_t i;
- herr_t ret_value = SUCCEED;
+ H5F_t *f = ext_loc->file; /* File pointer (convenience variable) */
+ H5F_file_t *shared = f->shared; /* Shared file info (convenience variable) */
+ H5O_shmesg_table_t sohm_table; /* SOHM message from superblock extension */
+ H5SM_master_table_t *table = NULL; /* SOHM master table */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5SM_get_info, FAIL)
- HDassert(f && f->shared);
- HDassert(f->shared->sohm_addr != HADDR_UNDEF);
-
- /* Convenience variables */
- table_addr = f->shared->sohm_addr;
-
-
- /* Read the rest of the SOHM table information from the cache */
- if(NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, dxpl_id, H5AC_SOHM_TABLE, table_addr, NULL, NULL, H5AC_READ)))
- HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table")
-
- /* Return info */
- *list_max = table->indexes[0].list_max;
- *btree_min = table->indexes[0].btree_min;
-
- /* Get information about the individual SOHM indexes */
- for(i=0; i<table->num_indexes; ++i) {
- index_flags[i] = table->indexes[i].mesg_types;
- minsizes[i] = table->indexes[i].min_mesg_size;
- }
+ /* Sanity check */
+ HDassert(ext_loc);
+ HDassert(f && shared);
+ HDassert(fc_plist);
+
+ /* Read in shared message information, if it exists */
+ if(NULL == H5O_msg_read(ext_loc, H5O_SHMESG_ID, &sohm_table, dxpl_id)) {
+ /* Reset error from "failed" message read */
+ H5E_clear_stack(NULL);
+
+ /* No SOHM info in file */
+ shared->sohm_addr = HADDR_UNDEF;
+ shared->sohm_nindexes = 0;
+ shared->sohm_vers = 0;
+
+ /* Shared object header messages are disabled */
+ if(H5P_set(fc_plist, H5F_CRT_SHMSG_NINDEXES_NAME, &shared->sohm_nindexes) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set number of SOHM indexes")
+ } /* end if */
+ else {
+ unsigned index_flags[H5O_SHMESG_MAX_NINDEXES]; /* Message flags for each index */
+ unsigned minsizes[H5O_SHMESG_MAX_NINDEXES]; /* Minimum message size for each index */
+ unsigned sohm_l2b; /* SOHM list-to-btree cutoff */
+ unsigned sohm_b2l; /* SOHM btree-to-list cutoff */
+ unsigned u; /* Local index variable */
+
+ /* Set SOHM info from file */
+ shared->sohm_addr = sohm_table.addr;
+ shared->sohm_vers = sohm_table.version;
+ shared->sohm_nindexes = sohm_table.nindexes;
+ HDassert(H5F_addr_defined(shared->sohm_addr));
+ HDassert(shared->sohm_nindexes > 0 && shared->sohm_nindexes <= H5O_SHMESG_MAX_NINDEXES);
+
+ /* Read the rest of the SOHM table information from the cache */
+ if(NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, dxpl_id, H5AC_SOHM_TABLE, shared->sohm_addr, NULL, NULL, H5AC_READ)))
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table")
+
+ /* Get index conversion limits */
+ sohm_l2b = table->indexes[0].list_max;
+ sohm_b2l = table->indexes[0].btree_min;
+
+ /* Iterate through all indices */
+ for(u = 0; u < table->num_indexes; ++u) {
+ /* Pack information about the individual SOHM index */
+ index_flags[u] = table->indexes[u].mesg_types;
+ minsizes[u] = table->indexes[u].min_mesg_size;
+
+ /* Sanity check */
+ HDassert(sohm_l2b == table->indexes[u].list_max);
+ HDassert(sohm_b2l == table->indexes[u].btree_min);
+ } /* end for */
+
+ /* Set values in the property list */
+ if(H5P_set(fc_plist, H5F_CRT_SHMSG_NINDEXES_NAME, &shared->sohm_nindexes) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set number of SOHM indexes")
+ if(H5P_set(fc_plist, H5F_CRT_SHMSG_INDEX_TYPES_NAME, index_flags) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set type flags for indexes")
+ if(H5P_set(fc_plist, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, minsizes) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set type flags for indexes")
+ if(H5P_set(fc_plist, H5F_CRT_SHMSG_LIST_MAX_NAME, &sohm_l2b) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set SOHM cutoff in property list")
+ if(H5P_set(fc_plist, H5F_CRT_SHMSG_BTREE_MIN_NAME, &sohm_b2l) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set SOHM cutoff in property list")
+ } /* end else */
done:
/* Release the master SOHM table if we took it out of the cache */
- if(table && H5AC_unprotect(f, dxpl_id, H5AC_SOHM_TABLE, table_addr, table, H5AC__NO_FLAGS_SET) < 0)
+ if(table && H5AC_unprotect(f, dxpl_id, H5AC_SOHM_TABLE, shared->sohm_addr, table, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_CACHE, H5E_CANTRELEASE, FAIL, "unable to close SOHM master table")
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5SMcache.c b/src/H5SMcache.c
index 91115ae..168b4e4 100644
--- a/src/H5SMcache.c
+++ b/src/H5SMcache.c
@@ -24,10 +24,9 @@
/* Headers */
/***********/
#include "H5Eprivate.h" /* Error handling */
+#include "H5Fpkg.h" /* File access */
#include "H5FLprivate.h" /* Free Lists */
#include "H5MMprivate.h" /* Memory management */
-
-#include "H5Fpkg.h" /* File access */
#include "H5SMpkg.h" /* Shared object header messages */
/****************/
diff --git a/src/H5SMprivate.h b/src/H5SMprivate.h
index 5c56602..88249b9 100755
--- a/src/H5SMprivate.h
+++ b/src/H5SMprivate.h
@@ -46,8 +46,8 @@ H5_DLL htri_t H5SM_can_share(H5F_t *f, hid_t dxpl_id, H5SM_master_table_t *table
H5_DLL htri_t H5SM_try_share(H5F_t *f, hid_t dxpl_id, unsigned type_id,
void *mesg);
H5_DLL herr_t H5SM_try_delete(H5F_t *f, hid_t dxpl_id, unsigned type_id, const H5O_shared_t *mesg);
-H5_DLL herr_t H5SM_get_info(H5F_t *f, unsigned *index_flags, unsigned *minsizes,
- unsigned *list_max, unsigned *btree_min, hid_t dxpl_id);
+H5_DLL herr_t H5SM_get_info(const H5O_loc_t *ext_loc, H5P_genplist_t *fc_plist,
+ hid_t dxpl_id);
H5_DLL htri_t H5SM_type_shared(H5F_t *f, unsigned type_id, hid_t dxpl_id);
H5_DLL herr_t H5SM_get_fheap_addr(H5F_t *f, hid_t dxpl_id, unsigned type_id,
haddr_t *fheap_addr);
diff --git a/src/H5private.h b/src/H5private.h
index 026c96e..31213c3 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -264,27 +264,6 @@
# define __FUNCTION__ "NoFunctionName"
#endif
-/* Version #'s of the major components of the file format */
-#define HDF5_SUPERBLOCK_VERSION_DEF 0 /* The default super block format */
-#define HDF5_SUPERBLOCK_VERSION_1 1 /* Version with non-default B-tree 'K' value */
-#define HDF5_SUPERBLOCK_VERSION_2 2 /* Version with implicit shared OH messages and checksum */
-#define HDF5_SUPERBLOCK_VERSION_MAX HDF5_SUPERBLOCK_VERSION_2 /* The maximum super block format */
-#define HDF5_FREESPACE_VERSION 0 /* of the Free-Space Info */
-#define HDF5_OBJECTDIR_VERSION 0 /* of the Object Directory format */
-#define HDF5_SHAREDHEADER_VERSION 0 /* of the Shared-Header Info */
-#define HDF5_DRIVERINFO_VERSION_0 0 /* of the Driver Information Block*/
-#define HDF5_DRIVERINFO_VERSION_1 1 /* Driver Information Block with checksum */
-#define HDF5_DRIVERINFO_VERSION_MAX HDF5_DRIVERINFO_VERSION_1 /* Maximum driver info block format */
-
-/* B-tree internal 'K' values */
-#define HDF5_BTREE_SNODE_IK_DEF 16
-#define HDF5_BTREE_ISTORE_IK_DEF 32 /* Note! this value is assumed
- to be 32 for older versions
- of the superblock (<1) and
- if it is changed, the code
- must compensate. -QAK
- */
-
/*
* Status return values for the `herr_t' type.
* Since some unix/c routines use 0 and -1 (or more precisely, non-negative