summaryrefslogtreecommitdiffstats
path: root/src/H5Ocopy.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-05-14 20:24:08 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-05-14 20:24:08 (GMT)
commit31ff357f3190a869147378a9a136510be2caafd7 (patch)
tree5220b17a8e4b6c434b799108719a1dc15d6c0326 /src/H5Ocopy.c
parent1726061075e9adc99ac2286fb542438acc79c4ab (diff)
downloadhdf5-31ff357f3190a869147378a9a136510be2caafd7.zip
hdf5-31ff357f3190a869147378a9a136510be2caafd7.tar.gz
hdf5-31ff357f3190a869147378a9a136510be2caafd7.tar.bz2
[svn-r13753] Description:
Check in "unique, but sharable" optimization to ISOHM code, which allows object header messages that are only used in one object to remain in the sole user's header, but migrates messages that are used in more than one header into the ISOHM heap. Tested on: Mac OS X/32 10.4.9 (amazon) FreeBSD/32 6.2 (duty) Linux/32 2.6 (chicago) Linux/64 2.6 (chicago2)
Diffstat (limited to 'src/H5Ocopy.c')
-rw-r--r--src/H5Ocopy.c59
1 files changed, 30 insertions, 29 deletions
diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c
index 71d4c0a..ebb1303 100644
--- a/src/H5Ocopy.c
+++ b/src/H5Ocopy.c
@@ -253,10 +253,8 @@ H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object")
done:
- if(loc_found) {
- if(H5G_loc_free(&src_loc) < 0)
- HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location")
- }
+ if(loc_found && H5G_loc_free(&src_loc) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location")
if(obj_open)
H5O_close(&src_oloc);
@@ -301,12 +299,11 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
const H5O_msg_class_t *copy_type; /* Type of message to use for copying */
const H5O_obj_class_t *obj_class = NULL; /* Type of object we are copying */
void *udata = NULL; /* User data for passing to message callbacks */
- size_t dst_oh_size; /* Total size of the destination OH */
+ uint64_t dst_oh_size; /* Total size of the destination OH */
size_t dst_oh_null; /* Size of the null message to add to destination OH */
unsigned dst_oh_gap; /* Size of the gap in chunk #0 of 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)
@@ -399,7 +396,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
if(copy_type->pre_copy_file) {
/* Decode the message if necessary. */
- H5O_LOAD_NATIVE(oloc_src->file, dxpl_id, mesg_src, FAIL)
+ H5O_LOAD_NATIVE(oloc_src->file, dxpl_id, oh_src, mesg_src, FAIL)
/* Perform "pre copy" operation on message */
if((copy_type->pre_copy_file)(oloc_src->file, mesg_src->native, &(deleted[mesgno]), cpy_info, udata) < 0)
@@ -466,39 +463,43 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
/* copy this message into destination file */
if(copy_type->copy_file) {
- hbool_t recompute_size = FALSE; /* Whether to recompute the destination message's size */
+ htri_t is_shared; /* Whether message is shared */
+ hbool_t recompute_size; /* Whether copy_file callback created a shared message */
/* Decode the message if necessary. */
- H5O_LOAD_NATIVE(oloc_src->file, dxpl_id, mesg_src, FAIL)
+ H5O_LOAD_NATIVE(oloc_src->file, dxpl_id, oh_src, mesg_src, FAIL)
/* Copy the source message */
+ recompute_size = FALSE;
if((mesg_dst->native = H5O_msg_copy_file(copy_type,
- oloc_src->file, mesg_src->native, oloc_dst->file, dxpl_id,
- &shared, cpy_info, udata)) == NULL)
+ oloc_src->file, mesg_src->native, oloc_dst->file,
+ &recompute_size, cpy_info, udata, dxpl_id)) == NULL)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object header message")
+ /* Check if new message is shared */
+ if((is_shared = H5O_msg_is_shared(copy_type->id, mesg_dst->native)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to query message's shared status")
+
/* 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.
+ * being shared, set/unset its sharing flag.
*/
- if(shared == TRUE && !(mesg_dst->flags & H5O_MSG_FLAG_SHARED)) {
- /* Set shared flag */
+ if(is_shared && !(mesg_dst->flags & H5O_MSG_FLAG_SHARED)) {
mesg_dst->flags |= H5O_MSG_FLAG_SHARED;
- /* Recompute shared message size (mesg_dst->native is really
- * shared)
- */
- recompute_size = TRUE;
+ /* Recompute message size (mesg_dst->native is really shared) */
+ recompute_size = TRUE;
} /* end if */
- else if(shared == FALSE && (mesg_dst->flags & H5O_MSG_FLAG_SHARED)) {
- /* Unset shared flag */
+ else if(!is_shared && (mesg_dst->flags & H5O_MSG_FLAG_SHARED)) {
mesg_dst->flags &= ~H5O_MSG_FLAG_SHARED;
- /* Recompute native message size (msg_dest->native is no longer
- * shared)
- */
+ /* Recompute message size (msg_dest->native is no longer shared) */
recompute_size = TRUE;
- } /* end else */
+ } /* end if */
+
+ /* Recompute message's size */
+ /* (its sharing status or one of its components (for attributes)
+ * could have changed)
+ */
if(recompute_size)
mesg_dst->raw_size = H5O_ALIGN_OH(oh_dst,
H5O_msg_raw_size(oloc_dst->file, mesg_dst->type->id, FALSE, mesg_dst->native));
@@ -569,12 +570,12 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
addr_new = oh_dst->chunk[0].addr;
/* Create memory image for the new chunk */
- if(NULL == (oh_dst->chunk[0].image = H5FL_BLK_MALLOC(chunk_image, dst_oh_size)))
+ if(NULL == (oh_dst->chunk[0].image = H5FL_BLK_MALLOC(chunk_image, (size_t)dst_oh_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
/* Set dest. chunk information */
oh_dst->chunk[0].dirty = TRUE;
- oh_dst->chunk[0].size = dst_oh_size;
+ oh_dst->chunk[0].size = (size_t)dst_oh_size;
oh_dst->chunk[0].gap = dst_oh_gap;
/* Set up raw pointers and copy messages that didn't need special
@@ -582,7 +583,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
* allocated.
*/
HDassert(H5O_SIZEOF_MSGHDR_OH(oh_src) == H5O_SIZEOF_MSGHDR_OH(oh_dst));
- msghdr_size = H5O_SIZEOF_MSGHDR_OH(oh_src);
+ msghdr_size = H5O_SIZEOF_MSGHDR_OH(oh_dst);
current_pos = oh_dst->chunk[0].image;
@@ -646,7 +647,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
} /* end if */
/* Make sure we filled the chunk, except for room at the end for a checksum */
- HDassert(current_pos + dst_oh_gap + dst_oh_null + H5O_SIZEOF_CHKSUM_OH(oh_dst) == dst_oh_size + oh_dst->chunk[0].image);
+ HDassert(current_pos + dst_oh_gap + dst_oh_null + H5O_SIZEOF_CHKSUM_OH(oh_dst) == (size_t)dst_oh_size + oh_dst->chunk[0].image);
/* Set the dest. object location to the first chunk address */
HDassert(H5F_addr_defined(addr_new));