summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5Oattr.c5
-rw-r--r--src/H5Ocopy.c3
-rw-r--r--src/H5Odtype.c2
-rw-r--r--src/H5Ofill.c4
-rw-r--r--src/H5Opkg.h1
-rw-r--r--src/H5Opline.c2
-rw-r--r--src/H5Oprivate.h7
-rw-r--r--src/H5Osdspace.c2
-rw-r--r--src/H5Oshared.c54
-rw-r--r--src/H5Oshared.h55
10 files changed, 131 insertions, 4 deletions
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index 9c6daee..29c4abd 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -61,6 +61,8 @@ static herr_t H5O_attr_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg,
#define H5O_SHARED_LINK_REAL H5O_attr_link
#define H5O_SHARED_COPY_FILE H5O_attr_shared_copy_file
#define H5O_SHARED_COPY_FILE_REAL H5O_attr_copy_file
+#define H5O_SHARED_POST_COPY_FILE H5O_attr_shared_post_copy_file
+#define H5O_SHARED_POST_COPY_FILE_REAL H5O_attr_post_copy_file
#define H5O_SHARED_DEBUG H5O_attr_shared_debug
#define H5O_SHARED_DEBUG_REAL H5O_attr_debug
#include "H5Oshared.h" /* Shared Object Header Message Callbacks */
@@ -83,7 +85,7 @@ const H5O_msg_class_t H5O_MSG_ATTR[1] = {{
NULL, /*can share method */
H5O_attr_pre_copy_file, /* pre copy native value to file */
H5O_attr_shared_copy_file, /* copy native value to file */
- H5O_attr_post_copy_file, /* post copy native value to file */
+ H5O_attr_shared_post_copy_file, /* post copy native value to file */
H5O_attr_get_crt_index, /* get creation index */
H5O_attr_set_crt_index, /* set creation index */
H5O_attr_shared_debug /* debug the message */
@@ -958,6 +960,7 @@ H5O_attr_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src,
HDassert(attr_dst);
HDassert(file_dst);
+
/* Only need to fix reference attribute with real data being copied to
* another file.
*/
diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c
index ebb1303..36d7485 100644
--- a/src/H5Ocopy.c
+++ b/src/H5Ocopy.c
@@ -699,6 +699,9 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
HDassert(mesg_dst->type == mesg_src->type);
HDassert(mesg_dst->native);
+ /* the object header is needed in the post copy for shared message */
+ cpy_info->oh_dst = &oh_dst;
+
/* Perform "post copy" operation on message */
if((copy_type->post_copy_file)(oloc_src, mesg_src->native, oloc_dst,
mesg_dst->native, dxpl_id, cpy_info) < 0)
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index 742d00b..2bfaccf 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -59,6 +59,8 @@ static herr_t H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg,
#undef H5O_SHARED_LINK_REAL
#define H5O_SHARED_COPY_FILE H5O_dtype_shared_copy_file
#define H5O_SHARED_COPY_FILE_REAL H5O_dtype_copy_file
+#define H5O_SHARED_POST_COPY_FILE H5O_dtype_shared_post_copy_file
+#undef H5O_SHARED_POST_COPY_FILE_REAL
#define H5O_SHARED_DEBUG H5O_dtype_shared_debug
#define H5O_SHARED_DEBUG_REAL H5O_dtype_debug
#include "H5Oshared.h" /* Shared Object Header Message Callbacks */
diff --git a/src/H5Ofill.c b/src/H5Ofill.c
index d81b769..93d8ab1 100644
--- a/src/H5Ofill.c
+++ b/src/H5Ofill.c
@@ -57,6 +57,8 @@ static herr_t H5O_fill_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *s
#undef H5O_SHARED_LINK_REAL
#define H5O_SHARED_COPY_FILE H5O_fill_shared_copy_file
#undef H5O_SHARED_COPY_FILE_REAL
+#define H5O_SHARED_POST_COPY_FILE H5O_fill_shared_post_copy_file
+#undef H5O_SHARED_POST_COPY_FILE_REAL
#define H5O_SHARED_DEBUG H5O_fill_shared_debug
#define H5O_SHARED_DEBUG_REAL H5O_fill_debug
#include "H5Oshared.h" /* Shared Object Header Message Callbacks */
@@ -86,6 +88,8 @@ static herr_t H5O_fill_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *s
#undef H5O_SHARED_COPY_FILE
#define H5O_SHARED_COPY_FILE H5O_fill_new_shared_copy_file
#undef H5O_SHARED_COPY_FILE_REAL
+#define H5O_SHARED_POST_COPY_FILE H5O_fill_new_shared_post_copy_file
+#undef H5O_SHARED_POST_COPY_FILE_REAL
#undef H5O_SHARED_DEBUG
#define H5O_SHARED_DEBUG H5O_fill_new_shared_debug
#undef H5O_SHARED_DEBUG_REAL
diff --git a/src/H5Opkg.h b/src/H5Opkg.h
index 83dc647..fb17c0c 100644
--- a/src/H5Opkg.h
+++ b/src/H5Opkg.h
@@ -498,6 +498,7 @@ 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_debug(const H5O_shared_t *mesg, FILE *stream,
int indent, int fwidth);
diff --git a/src/H5Opline.c b/src/H5Opline.c
index 09b52cc..407c1fc 100644
--- a/src/H5Opline.c
+++ b/src/H5Opline.c
@@ -55,6 +55,8 @@ static herr_t H5O_pline_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg,
#undef H5O_SHARED_LINK_REAL
#define H5O_SHARED_COPY_FILE H5O_pline_shared_copy_file
#undef H5O_SHARED_COPY_FILE_REAL
+#define H5O_SHARED_POST_COPY_FILE H5O_pline_shared_post_copy_file
+#undef H5O_SHARED_POST_COPY_FILE_REAL
#define H5O_SHARED_DEBUG H5O_pline_shared_debug
#define H5O_SHARED_DEBUG_REAL H5O_pline_debug
#include "H5Oshared.h" /* Shared Object Header Message Callbacks */
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index c4d2a1f..2376113 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -130,9 +130,10 @@ typedef struct H5O_copy_t {
hbool_t expand_ref; /* Flag to expand object references */
hbool_t copy_without_attr; /* Flag to not copy attributes */
hbool_t preserve_null; /* Flag to not delete NULL messages */
- int curr_depth; /* Current depth in hierarchy copied */
- int max_depth; /* Maximum depth in hierarchy to copy */
- H5SL_t *map_list; /* Skip list to hold address mappings */
+ int curr_depth; /* Current depth in hierarchy copied */
+ int max_depth; /* Maximum depth in hierarchy to copy */
+ H5SL_t *map_list; /* Skip list to hold address mappings */
+ H5O_t *oh_dst; /* The destination object header */
} H5O_copy_t;
/* Header message IDs */
diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c
index 348f894..bb3e349 100644
--- a/src/H5Osdspace.c
+++ b/src/H5Osdspace.c
@@ -51,6 +51,8 @@ static herr_t H5O_sdspace_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg,
#undef H5O_SHARED_LINK_REAL
#define H5O_SHARED_COPY_FILE H5O_sdspace_shared_copy_file
#undef H5O_SHARED_COPY_FILE_REAL
+#define H5O_SHARED_POST_COPY_FILE H5O_sdspace_shared_post_copy_file
+#undef H5O_SHARED_POST_COPY_FILE_REAL
#define H5O_SHARED_DEBUG H5O_sdspace_shared_debug
#define H5O_SHARED_DEBUG_REAL H5O_sdspace_debug
#include "H5Oshared.h" /* Shared Object Header Message Callbacks */
diff --git a/src/H5Oshared.c b/src/H5Oshared.c
index 44b0992..e78a1d3 100644
--- a/src/H5Oshared.c
+++ b/src/H5Oshared.c
@@ -578,6 +578,60 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5O_shared_post_copy_file
+ *
+ * Purpose: Delate a shared message and replace with a new one.
+ * The function is needed at cases such as coping a shared reg_ref attribute.
+ * When a shared reg_ref attribute is copied from one file to
+ * another, the values in file need to be replaced. The only way
+ * to complish that is to delete the old message and write the
+ * new message with the correct values.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Peter Cao
+ * xcao@hdfgroup.org
+ * May 24 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_shared_post_copy_file(H5F_t *f, hid_t dxpl_id, H5O_t *oh, void *mesg)
+{
+ 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);
+
+ /* the old shared message */
+ old_sh_mesg = (H5O_shared_t *) mesg;
+
+ /* save the type id for later use */
+ msg_type_id = old_sh_mesg->msg_type_id;
+
+ /* Remove the old message from the SOHM storage */
+ if(H5SM_delete(f, dxpl_id, oh, old_sh_mesg) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to find attribute information for object")
+
+ /* Add the new message */
+ if((shared_mesg = H5SM_try_share(f, dxpl_id, oh, 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")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_shared_post_copy_file() */
+
+
+
+/*-------------------------------------------------------------------------
* Function: H5O_shared_debug
*
* Purpose: Prints debugging info for the message
diff --git a/src/H5Oshared.h b/src/H5Oshared.h
index 27d2ac3..539577f 100644
--- a/src/H5Oshared.h
+++ b/src/H5Oshared.h
@@ -356,6 +356,61 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5O_SHARED_POST_COPY_FILE
+ *
+ * Purpose: Copies a message from _SRC to _DEST in file
+ *
+ * Note: The actual name of this routine can be different in each source
+ * file that this header file is included in, and must be defined
+ * prior to including this header file.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Peter Cao
+ * May 25, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+static H5_inline herr_t
+H5O_SHARED_POST_COPY_FILE(H5O_loc_t *oloc_src, 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 */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5O_SHARED_POST_COPY_FILE)
+
+ HDassert(oloc_src->file);
+ HDassert(oloc_dst->file);
+ HDassert(mesg_src);
+ HDassert(mesg_dst);
+
+#ifndef H5O_SHARED_TYPE
+#error "Need to define H5O_SHARED_TYPE macro!"
+#endif /* H5O_SHARED_TYPE */
+#ifndef H5O_SHARED_POST_COPY_FILE
+#error "Need to define H5O_SHARED_POST_COPY_FILE macro!"
+#endif /* H5O_SHARED_POST_COPY_FILE */
+
+#ifdef H5O_SHARED_POST_COPY_FILE_REAL
+ /* Call native message's copy file callback to copy the message */
+ if(H5O_SHARED_POST_COPY_FILE_REAL(oloc_src, mesg_src, oloc_dst, mesg_dst, dxpl_id, cpy_info) <0 )
+ 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 */
+ if(H5O_msg_is_shared(shared_dst->msg_type_id, mesg_dst)) {
+ 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")
+ }
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_SHARED_POST_COPY_FILE() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5O_SHARED_DEBUG
*
* Purpose: Prints debugging info for a potentially shared message.