summaryrefslogtreecommitdiffstats
path: root/src/H5Ocache.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2005-12-04 02:27:37 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2005-12-04 02:27:37 (GMT)
commit8d344f96bcd012742c55e668d6a6b3d81d1c39ee (patch)
tree918447ffaa4d7a81b921dac1a9a0d9a4f380760d /src/H5Ocache.c
parent4620776d72dc398dd134f4b266a38350d6cb7f60 (diff)
downloadhdf5-8d344f96bcd012742c55e668d6a6b3d81d1c39ee.zip
hdf5-8d344f96bcd012742c55e668d6a6b3d81d1c39ee.tar.gz
hdf5-8d344f96bcd012742c55e668d6a6b3d81d1c39ee.tar.bz2
[svn-r11758] Purpose:
New feature Description: Add in a combination of Peter's & my code to support copying variable-length data from one file to another, although currently only supported with contiguous data storage. Platforms tested: FreeBSD 4.11 (sleipnir) h5committest
Diffstat (limited to 'src/H5Ocache.c')
-rw-r--r--src/H5Ocache.c146
1 files changed, 78 insertions, 68 deletions
diff --git a/src/H5Ocache.c b/src/H5Ocache.c
index e5e20e4..4cd5760 100644
--- a/src/H5Ocache.c
+++ b/src/H5Ocache.c
@@ -25,9 +25,6 @@
#define H5O_PACKAGE /*suppress error about including H5Opkg */
-/* Interface initialization */
-#define H5_INTERFACE_INIT_FUNC H5O_cache_init_interface
-
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
@@ -57,25 +54,87 @@ const H5AC_class_t H5AC_OHDR[1] = {{
/*-------------------------------------------------------------------------
- * Function: H5O_cache_init_interface
+ * Function: H5O_flush_msgs
*
- * Purpose: Initialize the H5O interface. (Just calls
- * H5O_init_iterface currently).
+ * Purpose: Flushes messages for object header.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Quincey Koziol
- * Wednesday, September 28, 2005
+ * koziol@ncsa.uiuc.edu
+ * Nov 21 2005
*
*-------------------------------------------------------------------------
*/
-static herr_t
-H5O_cache_init_interface(void)
+herr_t
+H5O_flush_msgs(H5F_t *f, H5O_t *oh)
{
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_cache_init_interface)
+ uint8_t *p; /* Temporary pointer to encode with */
+ int id; /* ID of message to encode */
+ H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */
+ herr_t (*encode)(H5F_t*, uint8_t*, const void*) = NULL;
+ unsigned u; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5O_flush_msgs, FAIL)
+
+ /* check args */
+ HDassert(f);
+ HDassert(oh);
+
+ /* Encode any dirty messages */
+ for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) {
+ if(curr_msg->dirty) {
+ p = curr_msg->raw - H5O_SIZEOF_MSGHDR(f);
+
+ id = curr_msg->type->id;
+ UINT16ENCODE(p, id);
+ HDassert(curr_msg->raw_size < H5O_MAX_SIZE);
+ UINT16ENCODE(p, curr_msg->raw_size);
+ *p++ = curr_msg->flags;
+ *p++ = 0; /*reserved*/
+ *p++ = 0; /*reserved*/
+ *p++ = 0; /*reserved*/
+
+ if(curr_msg->native) {
+ HDassert(curr_msg->type->encode);
+
+ /* allocate file space for chunks that have none yet */
+ if(H5O_CONT_ID == id && !H5F_addr_defined(((H5O_cont_t *)(curr_msg->native))->addr))
+ /* We now allocate disk space on insertion, instead
+ * of on flush from the cache, so this case is now an
+ * error. -- JRM
+ */
+ HGOTO_ERROR(H5E_OHDR, H5E_SYSTEM, FAIL, "File space for message not allocated!?!")
+
+ /*
+ * Encode the message. If the message is shared then we
+ * encode a Shared Object message instead of the object
+ * which is being shared.
+ */
+ HDassert(curr_msg->raw >= oh->chunk[curr_msg->chunkno].image);
+ HDassert(curr_msg->raw_size == H5O_ALIGN (curr_msg->raw_size));
+ HDassert(curr_msg->raw + curr_msg->raw_size <=
+ oh->chunk[curr_msg->chunkno].image + oh->chunk[curr_msg->chunkno].size);
+ if(curr_msg->flags & H5O_FLAG_SHARED)
+ encode = H5O_MSG_SHARED->encode;
+ else
+ encode = curr_msg->type->encode;
+ if((encode)(f, curr_msg->raw, curr_msg->native) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode object header message")
+ } /* end if */
+ curr_msg->dirty = FALSE;
+ oh->chunk[curr_msg->chunkno].dirty = TRUE;
+ } /* end if */
+ } /* end for */
- FUNC_LEAVE_NOAPI(H5O_init())
-} /* end H5O_cache_init_interface() */
+ /* Sanity check for the correct # of messages in object header */
+ if(oh->nmesgs != u)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "corrupt object header - too few messages")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_flush_msgs() */
/*-------------------------------------------------------------------------
@@ -191,7 +250,7 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
/* Skip header messages we don't know about */
/* (Usually from future versions of the library */
- if(id >= NELMTS(message_type_g) || NULL == message_type_g[id]) {
+ if(id >= NELMTS(H5O_msg_class_g) || NULL == H5O_msg_class_g[id]) {
skipped_msgs++;
continue;
} /* end if */
@@ -208,7 +267,7 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
if (oh->nmesgs >= nmesgs)
HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "corrupt object header - too many messages");
mesgno = oh->nmesgs++;
- oh->mesg[mesgno].type = message_type_g[id];
+ oh->mesg[mesgno].type = H5O_msg_class_g[id];
oh->mesg[mesgno].dirty = FALSE;
oh->mesg[mesgno].flags = flags;
oh->mesg[mesgno].native = NULL;
@@ -225,7 +284,7 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
if(H5O_CONT_ID == oh->mesg[curmesg].type->id) {
H5O_cont_t *cont;
- cont = (H5O_CONT->decode) (f, dxpl_id, oh->mesg[curmesg].raw);
+ cont = (H5O_MSG_CONT->decode) (f, dxpl_id, oh->mesg[curmesg].raw);
oh->mesg[curmesg].native = cont;
chunk_addr = cont->addr;
chunk_size = cont->size;
@@ -268,10 +327,7 @@ static herr_t
H5O_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5O_t *oh)
{
uint8_t buf[16], *p;
- int id;
- H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */
- herr_t (*encode)(H5F_t*, uint8_t*, const void*) = NULL;
- unsigned combine = 0; /* Whether to combine the object header prefix & the first chunk */
+ hbool_t combine = FALSE; /* Whether to combine the object header prefix & the first chunk */
unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
@@ -285,54 +341,8 @@ H5O_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5O_t *oh)
/* flush */
if(oh->cache_info.is_dirty) {
/* Encode any dirty messages */
- for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) {
- if(curr_msg->dirty) {
- p = curr_msg->raw - H5O_SIZEOF_MSGHDR(f);
-
- id = curr_msg->type->id;
- UINT16ENCODE(p, id);
- HDassert(curr_msg->raw_size < H5O_MAX_SIZE);
- UINT16ENCODE(p, curr_msg->raw_size);
- *p++ = curr_msg->flags;
- *p++ = 0; /*reserved*/
- *p++ = 0; /*reserved*/
- *p++ = 0; /*reserved*/
-
- if(curr_msg->native) {
- HDassert(curr_msg->type->encode);
-
- /* allocate file space for chunks that have none yet */
- if(H5O_CONT_ID == curr_msg->type->id && !H5F_addr_defined(((H5O_cont_t *)(curr_msg->native))->addr))
- /* We now allocate disk space on insertion, instead
- * of on flush from the cache, so this case is now an
- * error. -- JRM
- */
- HGOTO_ERROR(H5E_OHDR, H5E_SYSTEM, FAIL, "File space for message not allocated!?!")
-
- /*
- * Encode the message. If the message is shared then we
- * encode a Shared Object message instead of the object
- * which is being shared.
- */
- HDassert(curr_msg->raw >= oh->chunk[curr_msg->chunkno].image);
- HDassert(curr_msg->raw_size == H5O_ALIGN (curr_msg->raw_size));
- HDassert(curr_msg->raw + curr_msg->raw_size <=
- oh->chunk[curr_msg->chunkno].image + oh->chunk[curr_msg->chunkno].size);
- if(curr_msg->flags & H5O_FLAG_SHARED)
- encode = H5O_SHARED->encode;
- else
- encode = curr_msg->type->encode;
- if((encode)(f, curr_msg->raw, curr_msg->native) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode object header message")
- } /* end if */
- curr_msg->dirty = FALSE;
- oh->chunk[curr_msg->chunkno].dirty = TRUE;
- } /* end if */
- } /* end for */
-
- /* Sanity check for the correct # of messages in object header */
- if(oh->nmesgs != u)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "corrupt object header - too few messages")
+ if(H5O_flush_msgs(f, oh) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object header messages")
/* Encode header prefix */
p = buf;
@@ -359,7 +369,7 @@ H5O_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5O_t *oh)
/* Check if we can combine the object header prefix & the first chunk into one I/O operation */
if(oh->chunk[0].dirty && (addr + H5O_SIZEOF_HDR(f)) == oh->chunk[0].addr) {
- combine = 1;
+ combine = TRUE;
} /* end if */
else {
if(H5F_block_write(f, H5FD_MEM_OHDR, addr, (size_t)H5O_SIZEOF_HDR(f), dxpl_id, buf) < 0)