summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5A.c6
-rw-r--r--src/H5Adense.c2
-rw-r--r--src/H5Apkg.h2
-rw-r--r--src/H5Oattr.c134
-rw-r--r--src/H5Oattribute.c2
-rw-r--r--src/H5Ocopy.c28
-rw-r--r--src/H5Odtype.c36
-rw-r--r--src/H5Ofill.c12
-rw-r--r--src/H5Omessage.c93
-rw-r--r--src/H5Opkg.h5
-rw-r--r--src/H5Opline.c12
-rw-r--r--src/H5Oprivate.h2
-rw-r--r--src/H5Osdspace.c12
-rw-r--r--src/H5Oshared.c48
-rwxr-xr-xsrc/H5SM.c15
-rw-r--r--src/H5SMcache.c16
16 files changed, 276 insertions, 149 deletions
diff --git a/src/H5A.c b/src/H5A.c
index ca75372..e678d58 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -28,11 +28,11 @@
/***********/
#include "H5private.h" /* Generic Functions */
#include "H5Apkg.h" /* Attributes */
+#include "H5Opkg.h" /* Object headers */
#include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free Lists */
#include "H5Iprivate.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */
-#include "H5Opkg.h" /* Object headers */
#include "H5Sprivate.h" /* Dataspace functions */
#include "H5SMprivate.h" /* Shared Object Header Messages */
@@ -384,7 +384,7 @@ H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type,
else if(tri_ret > 0)
{
/* Message is shared. Use size of shared message */
- if(H5O_msg_get_share(H5O_DTYPE_ID, attr->dt, &sh_mesg) < 0)
+ if(NULL == H5O_msg_get_share(H5O_DTYPE_ID, attr->dt, &sh_mesg))
HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "couldn't get size of shared message")
attr->dt_size = H5O_msg_raw_size(attr->oloc.file, H5O_SHARED_ID, &sh_mesg);
@@ -402,7 +402,7 @@ H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type,
else if(tri_ret > 0)
{
/* Message is shared. Use size of shared message */
- if(H5O_msg_get_share(H5O_SDSPACE_ID, attr->ds, &sh_mesg) < 0)
+ if(NULL == H5O_msg_get_share(H5O_SDSPACE_ID, attr->ds, &sh_mesg))
HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "couldn't get size of shared message")
attr->ds_size = H5O_msg_raw_size(attr->oloc.file, H5O_SHARED_ID, &sh_mesg);
diff --git a/src/H5Adense.c b/src/H5Adense.c
index 3258019..d235512 100644
--- a/src/H5Adense.c
+++ b/src/H5Adense.c
@@ -662,7 +662,7 @@ H5A_dense_insert(H5F_t *f, hid_t dxpl_id, const H5O_t *oh, unsigned mesg_flags,
/* Get the shared information for the attribute */
HDmemset(&sh_mesg, 0, sizeof(sh_mesg));
- if(H5O_attr_get_share(attr, &sh_mesg) < 0)
+ if(NULL == H5O_attr_get_share(attr, &sh_mesg))
HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "can't get shared message")
/* Use heap ID for shared message heap */
diff --git a/src/H5Apkg.h b/src/H5Apkg.h
index a3b0e70..5f8d477 100644
--- a/src/H5Apkg.h
+++ b/src/H5Apkg.h
@@ -184,7 +184,7 @@ H5_DLL herr_t H5A_attr_release_table(H5A_attr_table_t *atable);
/* Attribute object header routines */
H5_DLL herr_t H5O_attr_reset(void *_mesg);
H5_DLL herr_t H5O_attr_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link);
-H5_DLL herr_t H5O_attr_get_share(const void *_mesg, H5O_shared_t *sh);
+H5_DLL void *H5O_attr_get_share(const void *_mesg, H5O_shared_t *sh);
#endif /* _H5Apkg_H */
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index bc2b81f..8b8edc5 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -392,7 +392,7 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg)
HDmemset(&sh_mesg, 0, sizeof(H5O_shared_t));
/* Get shared message information from datatype */
- if((H5O_MSG_DTYPE->get_share)(attr->dt, &sh_mesg/*out*/) < 0)
+ if(NULL == (H5O_MSG_DTYPE->get_share)(attr->dt, &sh_mesg/*out*/))
HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode shared attribute datatype")
/* Encode shared message information for datatype */
@@ -418,7 +418,7 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg)
HDmemset(&sh_mesg, 0, sizeof(H5O_shared_t));
/* Get shared message information from dataspace */
- if((H5O_MSG_SDSPACE->get_share)(attr->ds, &sh_mesg/*out*/) < 0)
+ if(NULL == (H5O_MSG_SDSPACE->get_share)(attr->ds, &sh_mesg/*out*/))
HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode shared attribute dataspace")
/* Encode shared message information for dataspace */
@@ -650,6 +650,8 @@ herr_t
H5O_attr_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link)
{
const H5A_t *attr = (const H5A_t *) _mesg;
+ htri_t tri_ret;
+ H5O_shared_t sh_mesg;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5O_attr_delete)
@@ -658,37 +660,33 @@ H5O_attr_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link)
HDassert(f);
HDassert(attr);
- /* Check if we are adjusting link count on components in the file */
- if(adj_link) {
- htri_t tri_ret;
- H5O_shared_t sh_mesg;
-
- /* Remove both the datatype and dataspace from the SOHM heap if they're
- * shared there.
- */
- if((tri_ret = H5O_msg_is_shared(H5O_DTYPE_ID, attr->dt)) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't tell if datatype is shared")
- if(tri_ret > 0)
- {
- if(H5O_msg_get_share(H5O_DTYPE_ID, attr->dt, &sh_mesg) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't get shared message from datatype")
- if(H5SM_try_delete(f, H5AC_dxpl_id, H5O_DTYPE_ID, &sh_mesg) < 0)
- HGOTO_ERROR(H5E_SOHM, H5E_CANTREMOVE, FAIL, "can't remove datatype from SOHM heap")
- } /* end if */
-
- if((tri_ret = H5O_msg_is_shared(H5O_SDSPACE_ID, attr->ds)) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't tell if dataspace is shared")
- if(tri_ret > 0)
- {
- if(H5O_msg_get_share(H5O_SDSPACE_ID, attr->ds, &sh_mesg) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't get shared message from dataspace")
- if(H5SM_try_delete(f, H5AC_dxpl_id, H5O_SDSPACE_ID, &sh_mesg) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_SOHM, FAIL, "can't remove dataspace from SOHM heap")
- } /* end if */
-
- /* Check whether datatype is shared */
- if(H5T_committed(attr->dt))
- /* Decrement the reference count on the shared datatype */
+ /* Remove both the datatype and dataspace from the SOHM heap if they're
+ * shared there.
+ */
+ if((tri_ret = H5O_msg_is_shared(H5O_DTYPE_ID, attr->dt)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't tell if datatype is shared")
+ if(tri_ret > 0)
+ {
+ if(NULL == H5O_msg_get_share(H5O_DTYPE_ID, attr->dt, &sh_mesg))
+ HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't get shared message from datatype")
+ if(H5SM_try_delete(f, H5AC_dxpl_id, H5O_DTYPE_ID, &sh_mesg) < 0)
+ HGOTO_ERROR(H5E_SOHM, H5E_CANTREMOVE, FAIL, "can't remove datatype from SOHM heap")
+ } /* end if */
+
+ if((tri_ret = H5O_msg_is_shared(H5O_SDSPACE_ID, attr->ds)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't tell if dataspace is shared")
+ if(tri_ret > 0)
+ {
+ if(NULL == H5O_msg_get_share(H5O_SDSPACE_ID, attr->ds, &sh_mesg))
+ HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't get shared message from dataspace")
+ if(H5SM_try_delete(f, H5AC_dxpl_id, H5O_SDSPACE_ID, &sh_mesg) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_SOHM, FAIL, "can't remove dataspace from SOHM heap")
+ } /* end if */
+
+ /* Check whether datatype is shared */
+ if(H5T_committed(attr->dt)) {
+ /* Decrement the reference count on the shared datatype, if requested */
+ if(adj_link)
if(H5T_link(attr->dt, -1, dxpl_id) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared datatype link count")
} /* end if */
@@ -808,6 +806,9 @@ H5O_attr_copy_file(H5F_t *file_src, const H5O_msg_class_t UNUSED *mesg_type,
void *reclaim_buf = NULL; /* Buffer for reclaiming data */
hid_t buf_sid = -1; /* ID for buffer dataspace */
+ H5O_shared_t sh_mesg; /* Shared message information */
+ htri_t tri_ret; /* htri_t return value */
+
void *ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5O_attr_copy_file)
@@ -847,7 +848,6 @@ H5O_attr_copy_file(H5F_t *file_src, const H5O_msg_class_t UNUSED *mesg_type,
if(H5T_committed(attr_src->dt)) {
H5O_loc_t *src_oloc; /* Pointer to source datatype's object location */
H5O_loc_t *dst_oloc; /* Pointer to dest. datatype's object location */
- H5O_shared_t sh_mesg;
/* Get group entries for source & destination */
src_oloc = H5T_oloc(attr_src->dt);
@@ -862,12 +862,32 @@ H5O_attr_copy_file(H5F_t *file_src, const H5O_msg_class_t UNUSED *mesg_type,
/* Copy the shared object from source to destination */
if(H5O_copy_header_map(src_oloc, dst_oloc, dxpl_id, cpy_info, FALSE) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy object")
+ } /* end if */
+
+ /* Copy the dataspace for the attribute */
+ /* JAMES: does this need to be copy_file? */
+ attr_dst->ds = H5S_copy(attr_src->ds, FALSE);
+ HDassert(attr_dst->ds);
+ /* Try to share both the datatype and dataset. This does nothing if the
+ * datatype is committed or sharing is disabled.
+ */
+ if(H5SM_try_share(file_dst, dxpl_id, H5O_DTYPE_ID, attr_dst->dt) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, NULL, "can't share attribute datatype")
+ if(H5SM_try_share(file_dst, dxpl_id, H5O_SDSPACE_ID, attr_dst->ds) <0)
+ HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, NULL, "can't share attribute dataspace")
+
+ /* Compute the sizes of the datatype and dataspace. This is their raw
+ * size unless they're shared.
+ */
+ if((tri_ret = H5O_msg_is_shared(H5O_DTYPE_ID, attr_dst->dt)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, NULL, "unable to determine if datatype is shared")
+ if(tri_ret == TRUE) {
/* Reset shared message information */
HDmemset(&sh_mesg, 0, sizeof(H5O_shared_t));
/* Get shared message information for datatype */
- if(H5O_msg_get_share(H5O_DTYPE_ID, attr_src->dt, &sh_mesg/*out*/) < 0)
+ if(NULL == H5O_msg_get_share(H5O_DTYPE_ID, attr_dst->dt, &sh_mesg/*out*/))
HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to get shared message")
/* Compute shared message size for datatype */
@@ -876,12 +896,24 @@ H5O_attr_copy_file(H5F_t *file_src, const H5O_msg_class_t UNUSED *mesg_type,
else
attr_dst->dt_size = H5O_msg_raw_size(file_dst, H5O_DTYPE_ID, attr_src->dt);
HDassert(attr_dst->dt_size > 0);
- attr_dst->ds_size = H5S_raw_size(file_dst, attr_src->ds);
- HDassert(attr_dst->ds_size > 0);
- /* Copy the dataspace for the attribute */
- attr_dst->ds = H5S_copy(attr_src->ds, FALSE);
- HDassert(attr_dst->ds);
+ if((tri_ret = H5O_msg_is_shared(H5O_SDSPACE_ID, attr_dst->ds)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, NULL, "unable to determine if dataspace is shared")
+ if(tri_ret == TRUE) {
+ /* Reset shared message information */
+ HDmemset(&sh_mesg, 0, sizeof(H5O_shared_t));
+
+ /* Get shared message information for dataspace */
+ if(NULL == H5O_msg_get_share(H5O_SDSPACE_ID, attr_dst->ds, &sh_mesg/*out*/))
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to get shared message")
+
+ /* Compute shared message size for dataspace */
+ attr_dst->ds_size = H5O_msg_raw_size(file_dst, H5O_SHARED_ID, &sh_mesg);
+ }
+ else {
+ attr_dst->ds_size = H5O_msg_raw_size(file_dst, H5O_SDSPACE_ID, attr_src->ds);
+ }
+ HDassert(attr_dst->ds_size > 0);
/* Compute the size of the data */
H5_ASSIGN_OVERFLOW(attr_dst->data_size, H5S_GET_EXTENT_NPOINTS(attr_dst->ds) * H5T_get_size(attr_dst->dt), hsize_t, size_t);
@@ -1045,26 +1077,24 @@ done:
*
* Purpose: Gets sharing information from the message
*
- * Return: Non-negative on success/Negative on failure
+ * Return: Shared message on success/NULL on failure
*
* Programmer: James Laird
* Tuesday, October 17, 2006
*
*-------------------------------------------------------------------------
*/
-herr_t
+void *
H5O_attr_get_share(const void *_mesg, H5O_shared_t *sh /*out*/)
{
const H5A_t *mesg = (const H5A_t *)_mesg;
- herr_t ret_value = SUCCEED;
+ void *ret_value = NULL;
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_attr_get_share)
HDassert (mesg);
- HDassert (sh);
- if(NULL == H5O_msg_copy(H5O_SHARED_ID, &(mesg->sh_loc), sh))
- ret_value = FAIL;
+ ret_value = H5O_msg_copy(H5O_SHARED_ID, &(mesg->sh_loc), sh);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_attr_get_share() */
@@ -1119,6 +1149,7 @@ static htri_t
H5O_attr_is_shared(const void *_mesg)
{
const H5A_t *mesg = (const H5A_t *)_mesg;
+ htri_t ret_value;
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_attr_is_shared)
@@ -1128,8 +1159,13 @@ H5O_attr_is_shared(const void *_mesg)
* library read a "committed attribute" if we ever create one in
* the future.
*/
- FUNC_LEAVE_NOAPI(H5O_IS_SHARED(mesg->sh_loc.flags))
-} /* end H5O_attr_is_shared() */
+ if(mesg->sh_loc.flags & (H5O_COMMITTED_FLAG | H5O_SHARED_IN_HEAP_FLAG))
+ ret_value = TRUE;
+ else
+ ret_value = FALSE;
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_attr_is_shared */
/*--------------------------------------------------------------------------
@@ -1194,7 +1230,7 @@ H5O_attr_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream, int in
HDmemset(&sh_mesg, 0, sizeof(H5O_shared_t));
/* Get shared message information from datatype */
- if((H5O_MSG_DTYPE->get_share)(mesg->dt, &sh_mesg/*out*/) < 0)
+ if(NULL == (H5O_MSG_DTYPE->get_share)(mesg->dt, &sh_mesg/*out*/))
HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't retrieve shared message information")
debug = H5O_MSG_SHARED->debug;
diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c
index 17d6dcd..aaf91f6 100644
--- a/src/H5Oattribute.c
+++ b/src/H5Oattribute.c
@@ -501,7 +501,7 @@ H5O_attr_write_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/,
HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, H5_ITER_ERROR, "unable to delete shared attribute in shared storage")
/* Extract shared message info from current attribute */
- if(H5O_attr_get_share(udata->attr, mesg->native) < 0)
+ if(NULL == H5O_attr_get_share(udata->attr, mesg->native))
HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, H5_ITER_ERROR, "can't get shared info")
/* Indicate that we found the correct attribute */
diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c
index e48f29c..cce2d6d 100644
--- a/src/H5Ocopy.c
+++ b/src/H5Ocopy.c
@@ -302,6 +302,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
size_t dst_oh_size; /* Total size of the destination OH */
uint8_t *current_pos; /* Current position in destination image */
size_t msghdr_size;
+ hbool_t shared; /* Whether copy_file callback created a shared message */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI_NOINIT(H5O_copy_header_real)
@@ -506,9 +507,32 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
/* Copy the source message */
if((mesg_dst->native = H5O_msg_copy_file(copy_type, mesg_dst->type,
oloc_src->file, mesg_src->native, oloc_dst->file, dxpl_id,
- cpy_info, udata)) == NULL)
+ &shared, cpy_info, udata)) == NULL)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object header message")
+ /* In being copied, the message may have become shared or stopped
+ * being shared. If its sharing status has changed, recalculate
+ * its size and set/unset its sharing flag.
+ */
+ if(shared == TRUE && !(mesg_dst->flags & H5O_MSG_FLAG_SHARED)) {
+ /* Set shared flag */
+ mesg_dst->flags |= H5O_MSG_FLAG_SHARED;
+
+ /* Recompute shared message size (mesg_dst->native is really
+ * an H5O_shared_t)
+ */
+ mesg_dst->raw_size = H5O_ALIGN_OH(oh_dst,
+ H5O_msg_raw_size(oloc_dst->file, H5O_SHARED_ID, mesg_dst->native));
+ }
+ else if(shared == FALSE && (mesg_dst->flags & H5O_MSG_FLAG_SHARED)) {
+ /* Unset shared flag */
+ mesg_dst->flags &= ~H5O_MSG_FLAG_SHARED;
+
+ /* Recompute native message size */
+ mesg_dst->raw_size = H5O_ALIGN_OH(oh_dst,
+ H5O_msg_raw_size(oloc_dst->file, mesg_dst->type->id, mesg_dst->native));
+ }
+
/* Mark the message in the destination as dirty, so it'll get encoded when the object header is flushed */
mesg_dst->dirty = TRUE;
} /* end if (mesg_src->type->copy_file) */
@@ -528,7 +552,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
/* Add space for messages. */
for(mesgno = 0; mesgno < oh_dst->nmesgs; mesgno++) {
dst_oh_size += H5O_SIZEOF_MSGHDR_OH(oh_dst);
- dst_oh_size += H5O_ALIGN_OH(oh_dst, oh_dst->mesg[mesgno].raw_size);
+ dst_oh_size += oh_dst->mesg[mesgno].raw_size;
} /* end for */
/* Allocate space for chunk in destination file */
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index 73f8686..429db74 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -33,7 +33,7 @@ static void *H5O_dtype_copy(const void *_mesg, void *_dest);
static size_t H5O_dtype_size(const H5F_t *f, const void *_mesg);
static herr_t H5O_dtype_reset(void *_mesg);
static herr_t H5O_dtype_free(void *_mesg);
-static herr_t H5O_dtype_get_share(const void *_mesg, H5O_shared_t *sh);
+static void *H5O_dtype_get_share(const void *_mesg, H5O_shared_t *sh);
static herr_t H5O_dtype_set_share(void *_mesg, const H5O_shared_t *sh);
static herr_t H5O_dtype_is_shared(const void *_mesg);
static herr_t H5O_dtype_pre_copy_file(H5F_t *file_src, const H5O_msg_class_t *type,
@@ -1264,39 +1264,39 @@ H5O_dtype_free(void *mesg)
* Purpose: Returns information about where the shared message is located
* by filling in the SH shared message struct.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: Shared message on success/NULL on failure
*
* Programmer: Robb Matzke
* Monday, June 1, 1998
*
*-------------------------------------------------------------------------
*/
-static herr_t
+static void *
H5O_dtype_get_share(const void *_mesg, H5O_shared_t *sh/*out*/)
{
const H5T_t *dt = (const H5T_t *)_mesg;
- herr_t ret_value = SUCCEED; /* Return value */
+ void *ret_value = NULL; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5O_dtype_get_share)
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_dtype_get_share)
HDassert(dt);
- HDassert(sh);
- /* Make sure the datatype is shared */
- HDassert(dt->sh_loc.flags & (H5O_SHARED_IN_HEAP_FLAG | H5O_COMMITTED_FLAG));
+ /* Make sure the shared struct is initialized to some reasonable value */
+ HDassert((dt->sh_loc.flags & (H5O_SHARED_IN_HEAP_FLAG | H5O_COMMITTED_FLAG)) || dt->sh_loc.flags == H5O_NOT_SHARED);
+#ifndef NDEBUG
/* Make sure datatype state is correct: committed datatypes must have
- * state NAMED or OPEN and datatypes in the heap cannot be NAMED or OPEN. */
- if(dt->sh_loc.flags & H5O_SHARED_IN_HEAP_FLAG)
- HDassert(! (H5T_STATE_NAMED == dt->shared->state || H5T_STATE_OPEN == dt->shared->state));
- else
+ * state NAMED or OPEN and neither unshared datatypes nor datatypes
+ * shared in the heap can be NAMED or OPEN. */
+ if(dt->sh_loc.flags & H5O_COMMITTED_FLAG)
HDassert(H5T_STATE_NAMED == dt->shared->state || H5T_STATE_OPEN == dt->shared->state);
+ else
+ HDassert(! (H5T_STATE_NAMED == dt->shared->state || H5T_STATE_OPEN == dt->shared->state));
+#endif /* NDEBUG */
/* Do actual copy of shared information */
- if(NULL == H5O_msg_copy(H5O_SHARED_ID, &(dt->sh_loc), sh))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to get shared information")
+ ret_value = H5O_msg_copy(H5O_SHARED_ID, &(dt->sh_loc), sh);
-done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_dtype_get_share() */
@@ -1324,8 +1324,10 @@ H5O_dtype_set_share(void *_mesg/*in,out*/, const H5O_shared_t *sh)
HDassert(dt);
HDassert(sh);
- /* Make sure the shared message location is initialized*/
- HDassert(sh->flags & (H5O_SHARED_IN_HEAP_FLAG | H5O_COMMITTED_FLAG));
+ /* Make sure the shared message location is initialized, so that it
+ * either has valid sharing information or is set to 0.
+ */
+ HDassert(sh->flags & (H5O_SHARED_IN_HEAP_FLAG | H5O_COMMITTED_FLAG) || sh->flags == H5O_NOT_SHARED);
/* Make sure we're not sharing a committed type in the heap */
HDassert(sh->flags & H5O_COMMITTED_FLAG ||
diff --git a/src/H5Ofill.c b/src/H5Ofill.c
index 2c6158b..78b5c77 100644
--- a/src/H5Ofill.c
+++ b/src/H5Ofill.c
@@ -45,7 +45,7 @@ static void *H5O_fill_copy(const void *_mesg, void *_dest);
static size_t H5O_fill_size(const H5F_t *f, const void *_mesg);
static herr_t H5O_fill_reset(void *_mesg);
static herr_t H5O_fill_free(void *_mesg);
-static herr_t H5O_fill_new_get_share(const void *_mesg, H5O_shared_t *sh);
+static void *H5O_fill_new_get_share(const void *_mesg, H5O_shared_t *sh);
static herr_t H5O_fill_new_set_share(void *_mesg, const H5O_shared_t *sh);
static htri_t H5O_fill_new_is_shared(const void *_mesg);
static herr_t H5O_fill_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream,
@@ -673,26 +673,24 @@ H5O_fill_free (void *mesg)
*
* Purpose: Gets sharing information from the message
*
- * Return: Non-negative on success/Negative on failure
+ * Return: Shared message on success/NULL on failure
*
* Programmer: James Laird
* Tuesday, October 10, 2006
*
*-------------------------------------------------------------------------
*/
-static herr_t
+static void *
H5O_fill_new_get_share(const void *_mesg, H5O_shared_t *sh /*out*/)
{
const H5O_fill_new_t *mesg = (const H5O_fill_new_t *)_mesg;
- herr_t ret_value = SUCCEED;
+ void *ret_value = NULL;
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_fill_new_get_share)
HDassert (mesg);
- HDassert (sh);
- if(NULL == H5O_msg_copy(H5O_SHARED_ID, &(mesg->sh_loc), sh))
- ret_value = FAIL;
+ ret_value = H5O_msg_copy(H5O_SHARED_ID, &(mesg->sh_loc), sh);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_fill_new_get_share() */
diff --git a/src/H5Omessage.c b/src/H5Omessage.c
index cb827f4..0fafac7 100644
--- a/src/H5Omessage.c
+++ b/src/H5Omessage.c
@@ -446,7 +446,7 @@ H5O_msg_write_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type,
* replacement messages that aren't shared, too. */
/* Extract shared message info from current message */
- if(H5O_msg_get_share(type->id, mesg, &sh_mesg) < 0)
+ if(NULL == H5O_msg_get_share(type->id, mesg, &sh_mesg))
HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't get shared message")
/* Instead of writing the original message, write a shared message */
@@ -1509,12 +1509,17 @@ done:
* Function: H5O_msg_get_share
*
* Purpose: Call the 'get_share' method for a
- * particular class of object header.
+ * particular class of object header. Fills SHARE
+ * with the shared object, or allocated an H5O_shared_t
+ * message and returns it.
*
- * Return: Success: Non-negative, and SHARE describes the shared
- * object.
+ * If SHARE is NULL, the return value must be freed
+ * with H5O_msg_free.
*
- * Failure: Negative
+ * Return: Success: H5O_shared_t describing the shared information
+ * for the message.
+ *
+ * Failure: NULL
*
* Programmer: Quincey Koziol
* koziol@ncsa.uiuc.edu
@@ -1522,13 +1527,13 @@ done:
*
*-------------------------------------------------------------------------
*/
-herr_t
+void *
H5O_msg_get_share(unsigned type_id, const void *mesg, H5O_shared_t *share)
{
const H5O_msg_class_t *type; /* Actual H5O class type for the ID */
- herr_t ret_value; /* Return value */
+ void *ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5O_msg_get_share, FAIL)
+ FUNC_ENTER_NOAPI(H5O_msg_get_share, NULL)
/* Check args */
HDassert(type_id < NELMTS(H5O_msg_class_g));
@@ -1536,11 +1541,10 @@ H5O_msg_get_share(unsigned type_id, const void *mesg, H5O_shared_t *share)
HDassert(type);
HDassert(type->get_share);
HDassert(mesg);
- HDassert(share);
/* Get shared data for the mesg */
- if((ret_value = (type->get_share)(mesg, share)) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve shared message information")
+ if((ret_value = (type->get_share)(mesg, share)) == NULL)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to retrieve shared message information")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1761,6 +1765,9 @@ done:
* Purpose: Copies a message to file. If MESG is is the null pointer then a null
* pointer is returned with no error.
*
+ * Attempts to share the message in the destination and sets
+ * SHARED to TRUE or FALSE depending on whether this succeeds.
+ *
* Return: Success: Ptr to the new message
*
* Failure: NULL
@@ -1772,8 +1779,12 @@ done:
*/
void *
H5O_msg_copy_file(const H5O_msg_class_t *copy_type, const H5O_msg_class_t *mesg_type, H5F_t *file_src, void *native_src,
- H5F_t *file_dst, hid_t dxpl_id, H5O_copy_t *cpy_info, void *udata)
+ H5F_t *file_dst, hid_t dxpl_id, hbool_t *shared, H5O_copy_t *cpy_info, void *udata)
{
+ void *native_mesg=NULL;
+ void *shared_mesg=NULL;
+ hbool_t committed; /* TRUE if message is a committed message */
+ htri_t try_share_ret; /* Value returned from H5SM_try_share */
void *ret_value;
FUNC_ENTER_NOAPI_NOINIT(H5O_msg_copy_file)
@@ -1787,10 +1798,64 @@ H5O_msg_copy_file(const H5O_msg_class_t *copy_type, const H5O_msg_class_t *mesg_
HDassert(file_dst);
HDassert(cpy_info);
- if(NULL == (ret_value = (copy_type->copy_file)(file_src, mesg_type, native_src, file_dst, dxpl_id, cpy_info, udata)))
+ /* Check if this message is committed. We'll need to know this later. */
+ committed = FALSE;
+ if(copy_type->id == H5O_SHARED_ID) {
+ H5O_shared_t *shared_mesg = (H5O_shared_t *) native_src;
+
+ if( shared_mesg->flags & H5O_COMMITTED_FLAG) {
+ HDassert(!(shared_mesg->flags & H5O_SHARED_IN_HEAP_FLAG));
+ committed = TRUE;
+ }
+ }
+
+ /* The copy_file callback will return an H5O_shared_t only if the message
+ * to be copied is a committed datatype.
+ */
+ if(NULL == (native_mesg = (copy_type->copy_file)(file_src, mesg_type, native_src, file_dst, dxpl_id, cpy_info, udata)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy object header message to file")
+ /* Committed messages are always committed in the destination. Messages in
+ * the heap are not shared by default--they need to be "re-shared" in the
+ * destination.
+ */
+ if(committed == TRUE)
+ *shared = TRUE;
+ else
+ *shared = FALSE;
+
+ /* If message isn't committed but can be shared, handle with implicit sharing. */
+ if(committed == FALSE && (mesg_type->set_share)) {
+ /* Try to share it in the destination file. */
+ if((try_share_ret = H5SM_try_share(file_dst, dxpl_id, mesg_type->id, native_mesg)) < 0)
+ HGOTO_ERROR(H5E_SOHM, H5E_WRITEERROR, NULL, "unable to determine if message should be shared")
+
+ /* If it isn't shared, reset its sharing information. If it is
+ * shared, its sharing information will have been overwritten by
+ * H5SM_try_share.
+ */
+ if(try_share_ret == FALSE) {
+ if(H5O_msg_reset_share(mesg_type->id, native_mesg) < 0)
+ HGOTO_ERROR(H5E_SOHM, H5E_WRITEERROR, NULL, "unable to reset sharing information in message")
+ }
+ else {
+ /* Get shared message from native message */
+ if(NULL == (shared_mesg = H5O_msg_get_share(mesg_type->id, native_mesg, NULL)))
+ HGOTO_ERROR(H5E_SOHM, H5E_READERROR, NULL, "unable to get shared location from message")
+
+ /* Free native message; the shared message is all we need to return */
+ H5O_msg_free(mesg_type->id, native_mesg);
+
+ native_mesg = shared_mesg;
+ *shared = TRUE;
+ }
+ }
+
+ ret_value = native_mesg;
done:
+ if(NULL == ret_value) {
+ H5O_msg_free(mesg_type->id, native_mesg);
+ }
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_msg_copy_file() */
@@ -1846,7 +1911,7 @@ H5O_new_mesg(H5F_t *f, H5O_t *oh, unsigned *mesg_flags, const H5O_msg_class_t *o
/* Message is shared. Get shared message, change message type,
* and use shared information */
HDmemset(sh_mesg, 0, sizeof(H5O_shared_t));
- if((orig_type->get_share)(orig_mesg, sh_mesg/*out*/) < 0)
+ if(NULL == (orig_type->get_share)(orig_mesg, sh_mesg/*out*/))
HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, UFAIL, "can't get shared message")
*new_type = H5O_MSG_SHARED;
diff --git a/src/H5Opkg.h b/src/H5Opkg.h
index a87c3ba..8b52c2e 100644
--- a/src/H5Opkg.h
+++ b/src/H5Opkg.h
@@ -165,7 +165,7 @@ struct H5O_msg_class_t {
herr_t (*free)(void *); /*free main data struct */
herr_t (*del)(H5F_t *, hid_t, const void *, hbool_t); /* Delete space in file referenced by this message */
herr_t (*link)(H5F_t *, hid_t, const void *); /* Increment any links in file reference by this message */
- herr_t (*get_share)(const void*, struct H5O_shared_t*); /* Get shared information */
+ void *(*get_share)(const void*, struct H5O_shared_t*); /* Get shared information */
herr_t (*set_share)(void*, const struct H5O_shared_t*); /* Set shared information */
htri_t (*is_shared)(const void*); /* Is message shared? */
herr_t (*pre_copy_file)(H5F_t *, const H5O_msg_class_t *, const void *, hbool_t *, const H5O_copy_t *, void *); /*"pre copy" action when copying native value to file */
@@ -403,7 +403,7 @@ H5_DLL herr_t H5O_msg_free_mesg(H5O_mesg_t *mesg);
H5_DLL htri_t H5O_msg_exists_oh(struct H5O_t *oh, unsigned type_id, int sequence);
H5_DLL void * H5O_msg_copy_file(const H5O_msg_class_t *copy_type,
const H5O_msg_class_t *mesg_type, H5F_t *file_src, void *mesg_src,
- H5F_t *file_dst, hid_t dxpl_id, H5O_copy_t *cpy_info, void *udata);
+ H5F_t *file_dst, hid_t dxpl_id, hbool_t *shared, H5O_copy_t *cpy_info, void *udata);
H5_DLL herr_t H5O_msg_iterate_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type,
hbool_t internal, H5O_mesg_operator_t op, void *op_data, hid_t dxpl_id,
unsigned *oh_flags_ptr);
@@ -453,3 +453,4 @@ H5_DLL herr_t H5O_debug_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, haddr_t addr, F
#endif /* _H5Opkg_H */
+
diff --git a/src/H5Opline.c b/src/H5Opline.c
index ccbddd0..abd7471 100644
--- a/src/H5Opline.c
+++ b/src/H5Opline.c
@@ -35,7 +35,7 @@ static void *H5O_pline_copy(const void *_mesg, void *_dest);
static size_t H5O_pline_size(const H5F_t *f, const void *_mesg);
static herr_t H5O_pline_reset(void *_mesg);
static herr_t H5O_pline_free(void *_mesg);
-static herr_t H5O_pline_get_share(const void *_mesg, H5O_shared_t *sh);
+static void *H5O_pline_get_share(const void *_mesg, H5O_shared_t *sh);
static herr_t H5O_pline_set_share(void *_mesg, const H5O_shared_t *sh);
static htri_t H5O_pline_is_shared(const void *_mesg);
static herr_t H5O_pline_pre_copy_file(H5F_t *file_src, const H5O_msg_class_t *type,
@@ -599,26 +599,24 @@ done:
*
* Purpose: Gets sharing information from the message
*
- * Return: Non-negative on success/Negative on failure
+ * Return: Shared message on success/NULL on failure
*
* Programmer: James Laird
* Tuesday, October 10, 2006
*
*-------------------------------------------------------------------------
*/
-static herr_t
+static void *
H5O_pline_get_share(const void *_mesg, H5O_shared_t *sh /*out*/)
{
const H5O_pline_t *mesg = (const H5O_pline_t *)_mesg;
- herr_t ret_value = SUCCEED;
+ void *ret_value = NULL;
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_pline_get_share)
HDassert (mesg);
- HDassert (sh);
- if(NULL == H5O_msg_copy(H5O_SHARED_ID, &(mesg->sh_loc), sh))
- ret_value = FAIL;
+ ret_value = H5O_msg_copy(H5O_SHARED_ID, &(mesg->sh_loc), sh);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_pline_get_share() */
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index cd68ae5..27e2bdf 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -425,7 +425,7 @@ H5_DLL herr_t H5O_msg_iterate(const H5O_loc_t *loc, unsigned type_id, H5O_operat
H5_DLL size_t H5O_msg_raw_size(const H5F_t *f, unsigned type_id, const void *mesg);
H5_DLL size_t H5O_msg_mesg_size(const H5F_t *f, unsigned type_id, const void *mesg,
size_t extra_raw);
-H5_DLL herr_t H5O_msg_get_share(unsigned type_id, const void *mesg, H5O_shared_t *share);
+H5_DLL void *H5O_msg_get_share(unsigned type_id, const void *mesg, H5O_shared_t *share);
H5_DLL htri_t H5O_msg_is_shared(unsigned type_id, const void *mesg);
H5_DLL herr_t H5O_msg_set_share(unsigned type_id, H5O_shared_t *share, void *mesg);
H5_DLL herr_t H5O_msg_reset_share(unsigned type_id, void *mesg);
diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c
index 9b4c473..e5af3a6 100644
--- a/src/H5Osdspace.c
+++ b/src/H5Osdspace.c
@@ -31,7 +31,7 @@ static void *H5O_sdspace_copy(const void *_mesg, void *_dest);
static size_t H5O_sdspace_size(const H5F_t *f, const void *_mesg);
static herr_t H5O_sdspace_reset(void *_mesg);
static herr_t H5O_sdspace_free (void *_mesg);
-static herr_t H5O_sdspace_get_share(const void *_mesg, H5O_shared_t *sh);
+static void *H5O_sdspace_get_share(const void *_mesg, H5O_shared_t *sh);
static herr_t H5O_sdspace_set_share(void *_mesg, const H5O_shared_t *sh);
static htri_t H5O_sdspace_is_shared(const void *_mesg);
static herr_t H5O_sdspace_pre_copy_file(H5F_t *file_src, const H5O_msg_class_t *type,
@@ -452,26 +452,24 @@ H5O_sdspace_free (void *mesg)
*
* Purpose: Gets sharing information from the message
*
- * Return: Non-negative on success/Negative on failure
+ * Return: Shared message on success/NULL on failure
*
* Programmer: James Laird
* Tuesday, October 10, 2006
*
*-------------------------------------------------------------------------
*/
-static herr_t
+static void *
H5O_sdspace_get_share(const void *_mesg, H5O_shared_t *sh /*out*/)
{
const H5S_extent_t *mesg = (const H5S_extent_t *)_mesg;
- herr_t ret_value = SUCCEED;
+ void *ret_value = NULL;
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_get_share)
HDassert (mesg);
- HDassert (sh);
- if(NULL == H5O_msg_copy(H5O_SHARED_ID, &(mesg->sh_loc), sh))
- ret_value = FAIL;
+ ret_value = H5O_msg_copy(H5O_SHARED_ID, &(mesg->sh_loc), sh);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_sdspace_get_share() */
diff --git a/src/H5Oshared.c b/src/H5Oshared.c
index 963e8f4..d1f6577 100644
--- a/src/H5Oshared.c
+++ b/src/H5Oshared.c
@@ -293,10 +293,10 @@ H5O_shared_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *buf)
/* Get the shared information flags
* Flags are unused before version 3.
*/
- if(version >= H5O_SHARED_VERSION_2)
+ if(version >= H5O_SHARED_VERSION_2) {
mesg->flags = *buf++;
- else
- {
+ }
+ else {
mesg->flags = H5O_COMMITTED_FLAG;
buf++;
} /* end else */
@@ -306,20 +306,18 @@ H5O_shared_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *buf)
buf += 6;
/* Body */
- if(version == H5O_SHARED_VERSION_1)
+ if(version == H5O_SHARED_VERSION_1) {
H5G_obj_ent_decode(f, &buf, &(mesg->u.oloc));
- else if (version >= H5O_SHARED_VERSION_2)
- {
+ }
+ else if (version >= H5O_SHARED_VERSION_2) {
/* If this message is in the heap, copy a heap ID.
* Otherwise, it is a named datatype, so copy an H5O_loc_t.
*/
- if(mesg->flags & H5O_SHARED_IN_HEAP_FLAG)
- {
+ if(mesg->flags & H5O_SHARED_IN_HEAP_FLAG) {
HDassert(version >= H5O_SHARED_VERSION_3 );
HDmemcpy(&(mesg->u.heap_id), buf, (size_t) H5SM_FHEAP_ID_LEN);
}
- else
- {
+ else {
/* The H5O_COMMITTED_FLAG should be set if this message
* is from an older version before the flag existed.
*/
@@ -337,9 +335,10 @@ H5O_shared_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *buf)
ret_value = mesg;
done:
- if(ret_value == NULL)
+ if(ret_value == NULL) {
if(mesg != NULL)
H5MM_xfree(mesg);
+ } /* end if */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_shared_decode() */
@@ -377,9 +376,10 @@ H5O_shared_encode(H5F_t *f, uint8_t *buf/*out*/, const void *_mesg)
/* If this message is shared in the heap, we need to use version 3 of the
* encoding and encode the SHARED_IN_HEAP flag.
*/
- /* JAMES: also use "use latest version" flag here? */
- if(mesg->flags & H5O_SHARED_IN_HEAP_FLAG)
+ /* JAMES: also use "use latest version" flag here */
+ if(mesg->flags & H5O_SHARED_IN_HEAP_FLAG) {
version = H5O_SHARED_VERSION;
+ }
else {
HDassert(mesg->flags & H5O_COMMITTED_FLAG);
version = H5O_SHARED_VERSION_2; /* version 1 is no longer used */
@@ -391,10 +391,12 @@ H5O_shared_encode(H5F_t *f, uint8_t *buf/*out*/, const void *_mesg)
/* Encode either the heap ID of the message or the address of the
* object header that holds it.
*/
- if(mesg->flags & H5O_SHARED_IN_HEAP_FLAG)
- HDmemcpy(buf, &(mesg->u.heap_id), (size_t)H5SM_FHEAP_ID_LEN);
- else
+ if(mesg->flags & H5O_SHARED_IN_HEAP_FLAG) {
+ HDmemcpy(buf, &(mesg->u.heap_id), (size_t) H5SM_FHEAP_ID_LEN);
+ }
+ else {
H5F_addr_encode(f, &buf, mesg->u.oloc.addr);
+ }
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5O_shared_encode() */
@@ -484,8 +486,8 @@ H5O_shared_size(const H5F_t *f, const void *_mesg)
H5SM_FHEAP_ID_LEN; /* Shared in the heap */
}
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_shared_size() */
+ FUNC_LEAVE_NOAPI(ret_value);
+}
/*-------------------------------------------------------------------------
@@ -692,9 +694,9 @@ H5O_shared_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type,
HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, NULL, "unable to read shared message")
if(mesg_type->copy_file) {
- /* Copy the original, un-shared message and return it */
- ret_value = H5O_msg_copy_file(mesg_type, mesg_type, file_src, dst_mesg, file_dst, dxpl_id, cpy_info, udata);
- H5MM_xfree(dst_mesg);
+ /* Copy the original, un-shared message and return it */
+ ret_value = (mesg_type->copy_file)(file_src, mesg_type, dst_mesg, file_dst, dxpl_id, cpy_info, udata);
+ H5O_msg_free(mesg_type->id, dst_mesg);
}
else {
ret_value = dst_mesg;
@@ -705,9 +707,9 @@ done:
if(!ret_value)
{
if(shared_dst)
- H5MM_xfree(shared_dst);
+ H5O_msg_free(H5O_SHARED_ID, shared_dst);
if(dst_mesg)
- H5MM_xfree(dst_mesg);
+ H5O_msg_free(mesg_type->id, dst_mesg);
}
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5SM.c b/src/H5SM.c
index 0e7ba0e..de9bddb 100755
--- a/src/H5SM.c
+++ b/src/H5SM.c
@@ -720,6 +720,7 @@ H5SM_write_mesg(H5F_t *f, hid_t dxpl_id, H5SM_index_header_t *header,
HGOTO_ERROR(H5E_OHDR, H5E_BADSIZE, FAIL, "can't find message size")
if(NULL == (encoding_buf = H5MM_calloc(buf_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate buffer for encoding")
+
if(H5O_msg_encode(f, type_id, encoding_buf, mesg) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "can't encode message to be shared")
@@ -1153,23 +1154,15 @@ H5SM_get_info(H5F_t *f, unsigned *index_flags, unsigned *minsizes,
FUNC_ENTER_NOAPI(H5SM_get_info, FAIL)
- HDassert(f);
+ HDassert(f && f->shared);
+ HDassert(f->shared->sohm_addr != HADDR_UNDEF);
/* Convenience variables */
table_addr = f->shared->sohm_addr;
- HDassert(table_addr != HADDR_UNDEF);
- HDassert(f->shared->sohm_nindexes > 0);
-
- /* Allocate and initialize the master table structure */
- if(NULL == (table = H5MM_calloc(sizeof(H5SM_master_table_t))))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
-
- table->version = f->shared->sohm_vers;
- table->num_indexes = f->shared->sohm_nindexes;
/* Read the rest of the SOHM table information from the cache */
- if (NULL == (table = H5AC_protect(f, dxpl_id, H5AC_SOHM_TABLE, table_addr, NULL, table, H5AC_READ)))
+ if (NULL == (table = 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 */
diff --git a/src/H5SMcache.c b/src/H5SMcache.c
index 6c9118e..155a3ab 100644
--- a/src/H5SMcache.c
+++ b/src/H5SMcache.c
@@ -57,7 +57,7 @@
/* Local Prototypes */
/********************/
static herr_t H5SM_flush_table(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5SM_master_table_t *table);
-static H5SM_master_table_t *H5SM_load_table(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata1, H5SM_master_table_t *table);
+static H5SM_master_table_t *H5SM_load_table(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata1, void *table);
static herr_t H5SM_clear_table(H5F_t *f, H5SM_master_table_t *table, hbool_t destroy);
static herr_t H5SM_dest_table(H5F_t *f, H5SM_master_table_t* table);
static herr_t H5SM_table_size(const H5F_t *f, const H5SM_master_table_t *table, size_t *size_ptr);
@@ -191,8 +191,9 @@ done:
*-------------------------------------------------------------------------
*/
static H5SM_master_table_t *
-H5SM_load_table(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1, H5SM_master_table_t *table)
+H5SM_load_table(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1, void UNUSED *udata2)
{
+ H5SM_master_table_t *table = NULL;
size_t table_size; /* Size of SOHM master table on disk */
uint8_t *buf=NULL; /* Reading buffer */
const uint8_t *p; /* Pointer into input buffer */
@@ -203,7 +204,16 @@ H5SM_load_table(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1
FUNC_ENTER_NOAPI(H5SM_load_table, NULL)
- HDassert(table);
+ /* Allocate space for the master table in memory */
+ if(NULL == (table = H5MM_calloc(sizeof(H5SM_master_table_t))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+
+ /* Read number of indexes and version from file superblock */
+ table->num_indexes = f->shared->sohm_nindexes;
+ table->version = f->shared->sohm_vers;
+
+ HDassert(addr == f->shared->sohm_addr);
+ HDassert(addr != HADDR_UNDEF);
HDassert(table->num_indexes > 0);
/* Compute the size of the SOHM table header on disk. This is the "table" itself