diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5A.c | 4 | ||||
-rw-r--r-- | src/H5Adense.c | 2 | ||||
-rw-r--r-- | src/H5Aint.c | 21 | ||||
-rw-r--r-- | src/H5Gpkg.h | 8 | ||||
-rw-r--r-- | src/H5Gstab.c | 2 | ||||
-rw-r--r-- | src/H5Oattribute.c | 2 | ||||
-rw-r--r-- | src/H5Ocopy.c | 30 | ||||
-rw-r--r-- | src/H5Omessage.c | 4 | ||||
-rw-r--r-- | src/H5Opkg.h | 4 | ||||
-rw-r--r-- | src/H5Oprivate.h | 12 | ||||
-rw-r--r-- | src/H5Oshared.c | 67 | ||||
-rw-r--r-- | src/H5Oshared.h | 25 | ||||
-rwxr-xr-x | src/H5SM.c | 67 | ||||
-rwxr-xr-x | src/H5SMprivate.h | 12 |
14 files changed, 152 insertions, 108 deletions
@@ -451,9 +451,9 @@ H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type, /* Check if any of the pieces should be (or are already) shared in the * SOHM table */ - if(H5SM_try_share(attr->oloc.file, dxpl_id, NULL, FALSE, H5O_DTYPE_ID, attr->shared->dt, NULL) < 0) + if(H5SM_try_share(attr->oloc.file, dxpl_id, NULL, 0, H5O_DTYPE_ID, attr->shared->dt, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "trying to share datatype failed") - if(H5SM_try_share(attr->oloc.file, dxpl_id, NULL, FALSE, H5O_SDSPACE_ID, attr->shared->ds, NULL) < 0) + if(H5SM_try_share(attr->oloc.file, dxpl_id, NULL, 0, H5O_SDSPACE_ID, attr->shared->ds, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "trying to share dataspace failed") /* Check whether datatype is committed & increment ref count diff --git a/src/H5Adense.c b/src/H5Adense.c index 6724736..d1421ae 100644 --- a/src/H5Adense.c +++ b/src/H5Adense.c @@ -470,7 +470,7 @@ H5A_dense_insert(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, H5A_t *attr) mesg_flags |= H5O_MSG_FLAG_SHARED; else { /* Should this attribute be written as a SOHM? */ - if(H5SM_try_share(f, dxpl_id, NULL, FALSE, H5O_ATTR_ID, attr, &mesg_flags) < 0) + if(H5SM_try_share(f, dxpl_id, NULL, 0, H5O_ATTR_ID, attr, &mesg_flags) < 0) HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "error determining if message should be shared") /* Attributes can't be "unique be shareable" yet */ diff --git a/src/H5Aint.c b/src/H5Aint.c index e04d080..ec9bf04 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -855,7 +855,8 @@ H5A_attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_si HDassert(attr_dst->shared->name); /* Copy attribute's datatype */ - /* (Start destination datatype as transient, even if source is named) */ + /* If source is named, we will keep dst as named, but we will not actually + * copy the target and update the message until post copy */ if(NULL == (attr_dst->shared->dt = H5T_copy(attr_src->shared->dt, H5T_COPY_ALL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "cannot copy datatype") @@ -883,13 +884,13 @@ H5A_attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_si if(H5O_msg_reset_share(H5O_SDSPACE_ID, attr_dst->shared->ds) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to reset dataspace sharing") - /* Try to share both the datatype and dataset. This does nothing if the - * datatype is committed or sharing is disabled. + /* Simulate trying to share both the datatype and dataset, to determine the + * final size of the messages. This does nothing if the datatype is + * committed or sharing is disabled. */ - /* Use try_share_virtual and move try_share to post copy? -NAF */ - if(H5SM_try_share(file_dst, dxpl_id, NULL, FALSE, H5O_DTYPE_ID, attr_dst->shared->dt, NULL) < 0) + if(H5SM_try_share(file_dst, dxpl_id, NULL, H5SM_DEFER, H5O_DTYPE_ID, attr_dst->shared->dt, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, NULL, "can't share attribute datatype") - if(H5SM_try_share(file_dst, dxpl_id, NULL, FALSE, H5O_SDSPACE_ID, attr_dst->shared->ds, NULL) < 0) + if(H5SM_try_share(file_dst, dxpl_id, NULL, H5SM_DEFER, H5O_SDSPACE_ID, attr_dst->shared->ds, NULL) < 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 @@ -1104,6 +1105,14 @@ H5A_attr_post_copy_file(const H5O_loc_t *src_oloc, const H5A_t *attr_src, H5T_update_shared(attr_dst->shared->dt); } /* end if */ + /* 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, NULL, H5SM_WAS_DEFERRED, H5O_DTYPE_ID, attr_dst->shared->dt, NULL) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "can't share attribute datatype") + if(H5SM_try_share(file_dst, dxpl_id, NULL, H5SM_WAS_DEFERRED, H5O_SDSPACE_ID, attr_dst->shared->ds, NULL) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "can't share attribute dataspace") + /* Only need to fix reference attribute with real data being copied to * another file. */ diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index c966e16..b8f5f42 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -252,7 +252,7 @@ typedef struct H5G_bt_it_cpy_t { const H5O_loc_t *src_oloc; /* Source object location */ haddr_t src_heap_addr; /* Heap address of the source symbol table */ H5F_t *dst_file; /* File of destination group */ - H5O_stab_t *dst_stab; /* Symbol table message for destination group */ + const H5O_stab_t *dst_stab; /* Symbol table message for destination group */ H5O_copy_t *cpy_info; /* Information for copy operation */ } H5G_bt_it_cpy_t; @@ -416,9 +416,9 @@ H5_DLL herr_t H5G_stab_create_components(H5F_t *f, H5O_stab_t *stab, size_t size H5_DLL herr_t H5G_stab_insert(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_lnk, H5O_type_t obj_type, const void *crt_info, hid_t dxpl_id); -H5_DLL herr_t H5G_stab_insert_real(H5F_t *f, H5O_stab_t *stab, const char *name, - H5O_link_t *obj_lnk, H5O_type_t obj_type, const void *crt_info, - hid_t dxpl_id); +H5_DLL herr_t H5G_stab_insert_real(H5F_t *f, const H5O_stab_t *stab, + const char *name, H5O_link_t *obj_lnk, H5O_type_t obj_type, + const void *crt_info, hid_t dxpl_id); H5_DLL herr_t H5G_stab_delete(H5F_t *f, hid_t dxpl_id, const H5O_stab_t *stab); H5_DLL herr_t H5G_stab_iterate(const H5O_loc_t *oloc, hid_t dxpl_id, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, H5G_lib_iterate_t op, void *op_data); diff --git a/src/H5Gstab.c b/src/H5Gstab.c index 6e25857..81c2d6a 100644 --- a/src/H5Gstab.c +++ b/src/H5Gstab.c @@ -259,7 +259,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_stab_insert_real(H5F_t *f, H5O_stab_t *stab, const char *name, +H5G_stab_insert_real(H5F_t *f, const H5O_stab_t *stab, const char *name, H5O_link_t *obj_lnk, H5O_type_t obj_type, const void *crt_info, hid_t dxpl_id) { diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c index a5facbc..e3a3973 100644 --- a/src/H5Oattribute.c +++ b/src/H5Oattribute.c @@ -796,7 +796,7 @@ H5O_attr_update_shared(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5A_t *attr, /* Store new version of message as a SOHM */ /* (should always work, since we're not changing the size of the attribute) */ - if((shared_mesg = H5SM_try_share(f, dxpl_id, oh, FALSE, H5O_ATTR_ID, attr, NULL)) == 0) + if((shared_mesg = H5SM_try_share(f, dxpl_id, oh, 0, H5O_ATTR_ID, attr, NULL)) == 0) HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "attribute changed sharing status") else if(shared_mesg < 0) HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "can't share attribute") diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index 8f81153..184bf74 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -689,13 +689,6 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, if(H5SL_insert(cpy_info->map_list, addr_map, &(addr_map->src_obj_pos)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert object into skip list") - /* Insert destination object header in cache. Insert before post copy loop - * so anything that references this object header can find it. Insert - * pinned so we can continue using oh_dst. */ - if(H5AC_insert_entry(oloc_dst->file, dxpl_id, H5AC_OHDR, oloc_dst->addr, oh_dst, H5AC__PIN_ENTRY_FLAG) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header") - inserted = TRUE; - /* "post copy" loop over messages, to fix up any messages which require a complete * object header for destination object */ @@ -746,10 +739,11 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, oh_dst->nlink += (unsigned)addr_map->inc_ref_count; } /* end if */ - /* Unpin oh_dst */ - if(H5AC_unpin_entry(oh_dst) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "can't unpin object header") + /* Insert destination object header in cache */ + if(H5AC_insert_entry(oloc_dst->file, dxpl_id, H5AC_OHDR, oloc_dst->addr, oh_dst, H5AC__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header") oh_dst = NULL; + inserted = TRUE; /* Set obj_type and udata, if requested */ if(obj_type) { @@ -768,17 +762,11 @@ done: HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") /* Free destination object header on failure */ - if(ret_value < 0 && oh_dst) { - if(inserted) { - if(H5AC_unpin_entry(oh_dst) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "can't unpin object header") - } /* end if */ - else { - if(H5O_free(oh_dst) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data") - if(H5O_loc_reset(oloc_dst) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data") - } /* end else */ + if(ret_value < 0 && oh_dst && !inserted) { + if(H5O_free(oh_dst) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data") + if(H5O_loc_reset(oloc_dst) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Omessage.c b/src/H5Omessage.c index e2d3ac4..467df3d 100644 --- a/src/H5Omessage.c +++ b/src/H5Omessage.c @@ -419,7 +419,7 @@ H5O_msg_write_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *ty * XXX: This doesn't handle freeing extra space in object header from * a message shrinking. */ - if((status = H5SM_try_share(f, dxpl_id, ((mesg_flags & H5O_MSG_FLAG_SHARED) ? NULL : oh), FALSE, idx_msg->type->id, mesg, &mesg_flags)) < 0) + if((status = H5SM_try_share(f, dxpl_id, ((mesg_flags & H5O_MSG_FLAG_SHARED) ? NULL : oh), 0, idx_msg->type->id, mesg, &mesg_flags)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "error while trying to share message") if(status == FALSE && (mesg_flags & H5O_MSG_FLAG_SHARED)) HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "message changed sharing status") @@ -1932,7 +1932,7 @@ H5O_msg_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type, } /* end if */ else { /* Attempt to share message */ - if(H5SM_try_share(f, dxpl_id, oh, FALSE, type->id, native, mesg_flags) < 0) + if(H5SM_try_share(f, dxpl_id, oh, 0, type->id, native, mesg_flags) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "error determining if message should be shared") } /* end else */ diff --git a/src/H5Opkg.h b/src/H5Opkg.h index dd91eb1..7fefde6 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -584,7 +584,9 @@ H5_DLL herr_t H5O_shared_link(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, H5_DLL herr_t H5O_shared_copy_file(H5F_t *file_src, H5F_t *file_dst, const H5O_msg_class_t *mesg_type, const void *_native_src, void *_native_dst, hbool_t *recompute_size, H5O_copy_t *cpy_info, void *udata, hid_t dxpl_id); -H5_DLL herr_t H5O_shared_post_copy_file (H5F_t *f, hid_t dxpl_id, H5O_t *oh, void *mesg); +H5_DLL herr_t H5O_shared_post_copy_file (H5F_t *f, + const H5O_msg_class_t *mesg_type, const H5O_shared_t *shared_src, + H5O_shared_t *shared_dst, hid_t dxpl_id, H5O_copy_t *cpy_info); H5_DLL herr_t H5O_shared_debug(const H5O_shared_t *mesg, FILE *stream, int indent, int fwidth); diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 3f10e81..2640dee 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -110,11 +110,13 @@ typedef struct H5O_t H5O_t; /* Set the fields in a shared message structure */ #define H5O_UPDATE_SHARED(SH_MESG, SH_TYPE, F, MSG_TYPE, CRT_IDX, OH_ADDR) \ - (SH_MESG)->type = (SH_TYPE); \ - (SH_MESG)->file = (F); \ - (SH_MESG)->msg_type_id = (MSG_TYPE); \ - (SH_MESG)->u.loc.index = (CRT_IDX); \ - (SH_MESG)->u.loc.oh_addr = (OH_ADDR); + { \ + (SH_MESG)->type = (SH_TYPE); \ + (SH_MESG)->file = (F); \ + (SH_MESG)->msg_type_id = (MSG_TYPE); \ + (SH_MESG)->u.loc.index = (CRT_IDX); \ + (SH_MESG)->u.loc.oh_addr = (OH_ADDR); \ + } /* end block */ /* Fractal heap ID type for shared message & attribute heap IDs. */ diff --git a/src/H5Oshared.c b/src/H5Oshared.c index 432151c..864c364 100644 --- a/src/H5Oshared.c +++ b/src/H5Oshared.c @@ -285,7 +285,7 @@ H5O_shared_link_adj(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, } /* end if */ /* Check for incrementing reference count on message */ else if(adjust > 0) { - if(H5SM_try_share(f, dxpl_id, open_oh, FALSE, type->id, shared, NULL) < 0) + if(H5SM_try_share(f, dxpl_id, open_oh, 0, type->id, shared, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, FAIL, "error trying to share message") } /* end if */ } /* end else */ @@ -484,7 +484,7 @@ H5O_shared_size(const H5F_t *f, const H5O_shared_t *sh_mesg) if(sh_mesg->type == H5O_SHARE_TYPE_COMMITTED) { ret_value = (size_t)1 + /*version */ (size_t)1 + /*the type field */ - H5F_SIZEOF_ADDR(f); /*sharing by another obj hdr */ + (size_t)H5F_SIZEOF_ADDR(f); /*sharing by another obj hdr */ } /* end if */ else { HDassert(sh_mesg->type == H5O_SHARE_TYPE_SOHM); @@ -616,26 +616,15 @@ H5O_shared_copy_file(H5F_t *file_src, H5F_t *file_dst, * be updated (to allow calculation of the final size) but the message is * not actually shared. */ - if(shared_src->type == H5O_SHARE_TYPE_COMMITTED) { - H5O_loc_t dst_oloc; - H5O_loc_t src_oloc; - - /* Copy the shared object from source to destination */ - dst_oloc.file = file_dst; - src_oloc.file = file_src; - src_oloc.addr = shared_src->u.loc.oh_addr; - if(H5O_copy_header_map(&src_oloc, &dst_oloc, dxpl_id, cpy_info, FALSE, - NULL, NULL) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") - - /* Set up destination message's shared info */ - H5O_UPDATE_SHARED(shared_dst, H5O_SHARE_TYPE_COMMITTED, file_dst, mesg_type->id, 0, dst_oloc.addr) - } /* end if */ - else { + if(shared_src->type != H5O_SHARE_TYPE_COMMITTED) { /* Simulate trying to share new message in the destination file. */ - if(H5SM_try_share(file_dst, dxpl_id, NULL, TRUE, mesg_type->id, _native_dst, NULL) < 0) + if(H5SM_try_share(file_dst, dxpl_id, NULL, H5SM_DEFER, mesg_type->id, _native_dst, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to determine if message should be shared") - } /* end else */ + } /* end if */ + else + /* Mark the message as committed - as it will be committed in post copy + */ + H5O_UPDATE_SHARED(shared_dst, H5O_SHARE_TYPE_COMMITTED, file_dst, mesg_type->id, 0, HADDR_UNDEF) done: FUNC_LEAVE_NOAPI(ret_value) @@ -661,30 +650,40 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_shared_post_copy_file(H5F_t *f, hid_t dxpl_id, H5O_t *oh, void *mesg) +H5O_shared_post_copy_file(H5F_t *f, const H5O_msg_class_t *mesg_type, + const H5O_shared_t *shared_src, H5O_shared_t *shared_dst, hid_t dxpl_id, + H5O_copy_t *cpy_info) { - H5O_shared_t *old_sh_mesg; - htri_t shared_mesg; /* Whether the message should be shared */ - unsigned msg_type_id; /* Message's type ID */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_shared_post_copy_file) /* check args */ HDassert(f); - HDassert(mesg); + HDassert(shared_src); + HDassert(shared_dst); - /* the old shared message */ - old_sh_mesg = (H5O_shared_t *) mesg; + /* Copy the target of committed messages, try to share others */ + if(shared_src->type == H5O_SHARE_TYPE_COMMITTED) { + H5O_loc_t dst_oloc; + H5O_loc_t src_oloc; - /* save the type id for later use */ - msg_type_id = old_sh_mesg->msg_type_id; + /* Copy the shared object from source to destination */ + dst_oloc.file = f; + src_oloc.file = shared_src->file; + src_oloc.addr = shared_src->u.loc.oh_addr; + if(H5O_copy_header_map(&src_oloc, &dst_oloc, dxpl_id, cpy_info, FALSE, + NULL, NULL) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") - /* Add the new message */ - if((shared_mesg = H5SM_try_share(f, dxpl_id, oh, FALSE, msg_type_id, mesg, NULL)) == 0) - HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "message changed sharing status") - else if(shared_mesg < 0) - HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't share message") + /* Set up destination message's shared info */ + H5O_UPDATE_SHARED(shared_dst, H5O_SHARE_TYPE_COMMITTED, f, mesg_type->id, 0, dst_oloc.addr) + } /* end if */ + else + /* Share the message */ + if(H5SM_try_share(f, dxpl_id, NULL, H5SM_WAS_DEFERRED, mesg_type->id, + shared_dst, NULL) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't share message") done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Oshared.h b/src/H5Oshared.h index 569889d..70b54dc 100644 --- a/src/H5Oshared.h +++ b/src/H5Oshared.h @@ -385,8 +385,9 @@ static H5_inline herr_t H5O_SHARED_POST_COPY_FILE(const H5O_loc_t *oloc_src, const void *mesg_src, H5O_loc_t *oloc_dst, void *mesg_dst, hid_t dxpl_id, H5O_copy_t *cpy_info) { - const H5O_shared_t *shared_dst = (const H5O_shared_t *)mesg_dst; /* Alias to shared info in native source */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5O_shared_t *shared_src = (const H5O_shared_t *)mesg_src; /* Alias to shared info in native source */ + H5O_shared_t *shared_dst = (H5O_shared_t *)mesg_dst; /* Alias to shared info in native destination */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_SHARED_POST_COPY_FILE) @@ -394,6 +395,7 @@ H5O_SHARED_POST_COPY_FILE(const H5O_loc_t *oloc_src, const void *mesg_src, HDassert(oloc_dst->file); HDassert(mesg_src); HDassert(mesg_dst); + HDassert(cpy_info); #ifndef H5O_SHARED_TYPE #error "Need to define H5O_SHARED_TYPE macro!" @@ -408,14 +410,17 @@ H5O_SHARED_POST_COPY_FILE(const H5O_loc_t *oloc_src, const void *mesg_src, HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy native message to another file") #endif /* H5O_SHARED_POST_COPY_FILE_REAL */ - /* Update only shared message after the post copy. Do not update committed - * messages as they have already been dealt with in the copy pass. - * (Move copy of target of committed messages to post copy? -NAF) */ - if(shared_dst->type == H5O_SHARE_TYPE_SOHM - || shared_dst->type == H5O_SHARE_TYPE_HERE) { - if(H5O_shared_post_copy_file(oloc_dst->file, dxpl_id, cpy_info->oh_dst, mesg_dst) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to fix shared message in post copy") - } /* end if */ + /* Update shared message after the post copy - will short circuit in + * production if the DEFER pass determined it will not be shared; debug mode + * verifies that it is indeed the case */ + if(H5O_shared_post_copy_file(oloc_dst->file, H5O_SHARED_TYPE, + shared_src, shared_dst, dxpl_id, cpy_info) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to fix shared message in post copy") + + /* Make sure that if the the source or destination is committed, both are + * committed */ + HDassert((shared_src->type == H5O_SHARE_TYPE_COMMITTED) + == (shared_dst->type == H5O_SHARE_TYPE_COMMITTED)); done: FUNC_LEAVE_NOAPI(ret_value) @@ -477,8 +477,8 @@ H5SM_create_index(H5F_t *f, H5SM_index_header_t *header, hid_t dxpl_id) /* Create the v2 B-tree index */ bt2_cparam.cls = H5SM_INDEX; - bt2_cparam.node_size = (size_t)H5SM_B2_NODE_SIZE; - bt2_cparam.rrec_size = (size_t)H5SM_SOHM_ENTRY_SIZE(f); + bt2_cparam.node_size = (uint32_t)H5SM_B2_NODE_SIZE; + bt2_cparam.rrec_size = (uint32_t)H5SM_SOHM_ENTRY_SIZE(f); bt2_cparam.split_percent = H5SM_B2_SPLIT_PERCENT; bt2_cparam.merge_percent = H5SM_B2_MERGE_PERCENT; if(NULL == (bt2 = H5B2_create(f, dxpl_id, &bt2_cparam, f))) @@ -720,8 +720,8 @@ H5SM_convert_list_to_btree(H5F_t *f, H5SM_index_header_t *header, /* Create the new v2 B-tree for tracking the messages */ bt2_cparam.cls = H5SM_INDEX; - bt2_cparam.node_size = (size_t)H5SM_B2_NODE_SIZE; - bt2_cparam.rrec_size = (size_t)H5SM_SOHM_ENTRY_SIZE(f); + bt2_cparam.node_size = (uint32_t)H5SM_B2_NODE_SIZE; + bt2_cparam.rrec_size = (uint32_t)H5SM_SOHM_ENTRY_SIZE(f); bt2_cparam.split_percent = H5SM_B2_SPLIT_PERCENT; bt2_cparam.merge_percent = H5SM_B2_MERGE_PERCENT; if(NULL == (bt2 = H5B2_create(f, dxpl_id, &bt2_cparam, f))) @@ -988,9 +988,11 @@ done: * header it needs (which can cause an error if that OH is * already protected!). * - * The DEFER flag indicates whether the sharing operation - * should actually occur, or whether this is just a set up call - * for a future sharing operation. + * DEFER_FLAGS indicates whether the sharing operation should + * actually occur, or whether this is just a set up call for a + * future sharing operation. In the latter case this argument + * should be H5SM_DEFER. If the message was previously deferred + * this argument should be H5SM_WAS_DEFERRED. * * MESG_FLAGS will have the H5O_MSG_FLAG_SHAREABLE or * H5O_MSG_FLAG_SHARED flag set if one is appropriate. This is @@ -1029,7 +1031,7 @@ done: *------------------------------------------------------------------------- */ htri_t -H5SM_try_share(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, hbool_t defer, +H5SM_try_share(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, unsigned defer_flags, unsigned type_id, void *mesg, unsigned *mesg_flags) { H5SM_master_table_t *table = NULL; @@ -1037,10 +1039,26 @@ H5SM_try_share(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, hbool_t defer, unsigned cache_flags = H5AC__NO_FLAGS_SET; ssize_t index_num; htri_t tri_ret; +#ifndef NDEBUG + unsigned deferred_type = -1u; +#endif htri_t ret_value = TRUE; FUNC_ENTER_NOAPI(H5SM_try_share, FAIL) + /* If we previously deferred this operation, the saved message type should + * be the same as the one we get here. In debug mode, we make sure this + * holds true; otherwise we can leave now if it wasn't shared in the DEFER + * pass. */ + if(defer_flags & H5SM_WAS_DEFERRED) +#ifndef NDEBUG + deferred_type = ((H5O_shared_t *)mesg)->type; +#else /* NDEBUG */ + if((((H5O_shared_t *)mesg)->type != H5O_SHARE_TYPE_HERE) + && (((H5O_shared_t *)mesg)->type != H5O_SHARE_TYPE_SOHM)) + HGOTO_DONE(FALSE); +#endif /* NDEBUG */ + /* "trivial" sharing checks */ if(mesg_flags && (*mesg_flags & H5O_MSG_FLAG_DONTSHARE)) HGOTO_DONE(FALSE) @@ -1075,20 +1093,31 @@ H5SM_try_share(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, hbool_t defer, * message to become shared (if it is unique, it will not be shared). */ if(H5SM_write_mesg(f, dxpl_id, open_oh, &(table->indexes[index_num]), - defer, type_id, mesg, &cache_flags) < 0) + (defer_flags & H5SM_DEFER) != 0, type_id, mesg, &cache_flags) < 0) HGOTO_ERROR(H5E_SOHM, H5E_CANTINSERT, FAIL, "can't write shared message") /* Set flags if this message was "written" without error and wasn't a * 'defer' attempt; it is now either fully shared or "shareable". */ - if(mesg_flags && !defer) { + if(mesg_flags && !(defer_flags & H5SM_DEFER)) { if(((H5O_shared_t *)mesg)->type == H5O_SHARE_TYPE_HERE) *mesg_flags |= H5O_MSG_FLAG_SHAREABLE; - else + else { + HDassert(((H5O_shared_t *)mesg)->type == H5O_SHARE_TYPE_SOHM); *mesg_flags |= H5O_MSG_FLAG_SHARED; + } /* end else */ } /* end if */ done: + HDassert(!ret_value || ((H5O_shared_t *)mesg)->type == H5O_SHARE_TYPE_HERE + || ((H5O_shared_t *)mesg)->type == H5O_SHARE_TYPE_SOHM); +#ifndef NDEBUG + /* If we previously deferred this operation, make sure the saved message + * type is the same as the one we get here. */ + if(defer_flags & H5SM_WAS_DEFERRED) + HDassert(deferred_type == ((H5O_shared_t *)mesg)->type); +#endif /* NDEBUG */ + /* Release the master SOHM table */ if(table && H5AC_unprotect(f, dxpl_id, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, cache_flags) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") @@ -1347,9 +1376,9 @@ H5SM_write_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, * We will insert it in the index but not modify the original * message. * If it can't be shared in an object header location, we will - * insert it in the heap. Note that we assume there will - * be an "open_oh" available when it is time to call - * H5SM_write_mesg with defer flag disabled. + * insert it in the heap. Note that we will only share + * the message in the object header if there is an + * "open_oh" available. * * If 'defer' flag is not set: * Insert it in the index but don't modify the original message. @@ -1357,7 +1386,7 @@ H5SM_write_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, * no object header location available, insert it in the * heap. */ - if(share_in_ohdr && (defer || open_oh)) { + if(share_in_ohdr && open_oh) { /* Set up shared component info */ shared.type = H5O_SHARE_TYPE_HERE; @@ -1589,7 +1618,7 @@ H5SM_find_in_list(const H5SM_list_t *list, const H5SM_mesg_key_t *key, size_t *e * Also record the first empty position we find. */ for(x = 0; x < list->header->list_max; x++) { - if(key && (list->messages[x].location != H5SM_NO_LOC) && + if((list->messages[x].location != H5SM_NO_LOC) && (0 == H5SM_message_compare(key, &(list->messages[x])))) HGOTO_DONE(x) else if(empty_pos && list->messages[x].location == H5SM_NO_LOC) { @@ -1944,14 +1973,14 @@ H5SM_get_info(const H5O_loc_t *ext_loc, H5P_genplist_t *fc_plist, hid_t dxpl_id) HGOTO_ERROR(H5E_SOHM, 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; + sohm_l2b = (unsigned)table->indexes[0].list_max; + sohm_b2l = (unsigned)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; + minsizes[u] = (unsigned)table->indexes[u].min_mesg_size; /* Sanity check */ HDassert(sohm_l2b == table->indexes[u].list_max); diff --git a/src/H5SMprivate.h b/src/H5SMprivate.h index 5fc9915..dddc0a8 100755 --- a/src/H5SMprivate.h +++ b/src/H5SMprivate.h @@ -26,6 +26,16 @@ #include "H5Oprivate.h" /* Object headers */ #include "H5Pprivate.h" /* Property lists */ +/**************************/ +/* Library Private Macros */ +/**************************/ + +/* Flags for the "defer_flags" argument to H5SM_try_share + */ +#define H5SM_DEFER 0x01u /* Don't actually write shared message to index, heap; just update shared info */ +#define H5SM_WAS_DEFERRED 0x02u /* Message was previously updated by a call to H5SM_try_share with H5SM_DEFER */ + + /****************************/ /* Library Private Typedefs */ /****************************/ @@ -44,7 +54,7 @@ H5_DLL herr_t H5SM_init(H5F_t *f, H5P_genplist_t *fc_plist, H5_DLL htri_t H5SM_can_share(H5F_t *f, hid_t dxpl_id, H5SM_master_table_t *table, ssize_t *sohm_index_num, unsigned type_id, const void *mesg); H5_DLL htri_t H5SM_try_share(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, - hbool_t defer, unsigned type_id, void *mesg, unsigned *mesg_flags); + unsigned defer_flags, unsigned type_id, void *mesg, unsigned *mesg_flags); H5_DLL herr_t H5SM_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, H5O_shared_t *sh_mesg); H5_DLL herr_t H5SM_get_info(const H5O_loc_t *ext_loc, H5P_genplist_t *fc_plist, |