summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Laird <jlaird@hdfgroup.org>2007-01-09 22:08:54 (GMT)
committerJames Laird <jlaird@hdfgroup.org>2007-01-09 22:08:54 (GMT)
commita2a3e47d06ce348ce27718b4a3e0e4b156fba6f5 (patch)
tree423182103eab823f0af546780628fd034cd903b9
parent26d2abe9e87a051cd897f77a4a472a432675db8c (diff)
downloadhdf5-a2a3e47d06ce348ce27718b4a3e0e4b156fba6f5.zip
hdf5-a2a3e47d06ce348ce27718b4a3e0e4b156fba6f5.tar.gz
hdf5-a2a3e47d06ce348ce27718b4a3e0e4b156fba6f5.tar.bz2
[svn-r13129] More refactoring. Moved index versions to the index header, so that an
index can be read all at once. This changes the file format! Tested on Windows, kagiso, and smirom.
-rw-r--r--src/H5D.c16
-rw-r--r--src/H5Oalloc.c4
-rw-r--r--src/H5Oprivate.h5
-rw-r--r--src/H5Oshared.c9
-rwxr-xr-xsrc/H5SM.c14
-rw-r--r--src/H5SMcache.c22
-rwxr-xr-xsrc/H5SMpkg.h4
7 files changed, 29 insertions, 45 deletions
diff --git a/src/H5D.c b/src/H5D.c
index ac95d08..090b0c3 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -1195,7 +1195,7 @@ H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset)
/* fill value variables */
H5D_fill_time_t fill_time;
H5O_fill_t *fill_prop; /* Pointer to dataset's fill value information */
- H5O_fill_new_t fill;
+ H5O_fill_new_t fill = {NULL, 0, NULL, H5D_ALLOC_TIME_LATE, H5D_FILL_TIME_ALLOC, TRUE};
H5D_fill_value_t fill_status;
struct H5O_t *oh = NULL; /* Pointer to dataset's object header */
@@ -1218,12 +1218,6 @@ H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset)
/* Get the file's 'use the latest version of the format' flag */
use_latest_format = H5F_USE_LATEST_FORMAT(file);
- /* Initialize the fill value message */
- HDmemset(&fill,0,sizeof(H5O_fill_new_t));
- fill.alloc_time = H5D_ALLOC_TIME_LATE;
- fill.fill_time = H5D_FILL_TIME_ALLOC;
- fill.fill_defined = TRUE;
-
/* Point at dataset's copy, to cache it for later */
fill_prop = &dset->shared->fill;
fill_time = dset->shared->fill_time;
@@ -1864,7 +1858,7 @@ done:
static herr_t
H5D_open_oid(H5D_t *dataset, hid_t dxpl_id)
{
- H5O_fill_new_t fill;
+ H5O_fill_new_t fill = {NULL, 0, NULL, H5D_ALLOC_TIME_LATE, H5D_FILL_TIME_IFSET, TRUE};
unsigned alloc_time_state; /* Allocation time state */
H5O_fill_t *fill_prop; /* Pointer to dataset's fill value area */
H5O_pline_t pline; /* I/O pipeline information */
@@ -1880,12 +1874,6 @@ H5D_open_oid(H5D_t *dataset, hid_t dxpl_id)
if(NULL == (dataset->shared = H5D_new(H5P_DATASET_CREATE_DEFAULT, FALSE, FALSE)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
- /* Initialize the fill value message JAMES: initialize above instead? */
- HDmemset(&fill,0,sizeof(H5O_fill_new_t));
- fill.alloc_time = H5D_ALLOC_TIME_LATE;
- fill.fill_time = H5D_FILL_TIME_IFSET;
- fill.fill_defined = TRUE;
-
/* Open the dataset object */
if(H5O_open(&(dataset->oloc)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open")
diff --git a/src/H5Oalloc.c b/src/H5Oalloc.c
index 1368e84..b1a81aa 100644
--- a/src/H5Oalloc.c
+++ b/src/H5Oalloc.c
@@ -670,11 +670,11 @@ H5O_alloc_new_chunk(H5F_t *f,
(found_attr < 0 ||
oh->mesg[u].raw_size < oh->mesg[found_attr].raw_size))
found_attr = u;
-/* } else if(H5O_LINK_ID == msg_id) {
+ } else if(H5O_LINK_ID == msg_id) {
if(oh->mesg[u].raw_size >= cont_size &&
(found_link < 0 ||
oh->mesg[u].raw_size < oh->mesg[found_link].raw_size))
- found_link = u; JAMES */
+ found_link = u;
} else {
if(oh->mesg[u].raw_size >= cont_size &&
(found_other < 0 ||
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index 392b223..1a42569 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -45,10 +45,9 @@
typedef struct H5O_msg_class_t H5O_msg_class_t;
typedef struct H5O_t H5O_t;
-/* JAMES: should these be in H5SM_private? or renamed? */
/* Fractal heap ID type for shared message heap IDs. The length of a heap ID
- * depends on how the heap is configured; currently they're always stored in
- * 8-byte fields, although only seven bytes are used.
+ * depends on how the heap is configured; currently they're seven bytes long
+ * but are stored in 8-byte fields in memory.
*/
#define H5SM_FHEAP_ID_LEN 7
typedef uint64_t H5SM_fheap_id_t;
diff --git a/src/H5Oshared.c b/src/H5Oshared.c
index 68d3494..fa6a7ef 100644
--- a/src/H5Oshared.c
+++ b/src/H5Oshared.c
@@ -201,6 +201,12 @@ done:
* Purpose: Changes the link count for the object referenced by a shared
* message.
*
+ * This function changes the object header link count and is
+ * only relevant for committed messages. Messages shared in
+ * the heap are re-shared each time they're written, so their
+ * reference count is stored in the file-wide shared message
+ * index and is changed in a different place in the code.
+ *
* Return: Success: New link count
*
* Failure: Negative
@@ -546,7 +552,6 @@ done:
*
*-------------------------------------------------------------------------
*/
-/* JAMES: this is where shared messages increment their links */
static herr_t
H5O_shared_link(H5F_t *f, hid_t dxpl_id, const void *_mesg)
{
@@ -727,8 +732,6 @@ H5O_shared_debug (H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg,
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_shared_debug)
- /* JAMES_HEAP: this oughta change, too, of course. */
-
/* Check args */
HDassert(f);
HDassert(mesg);
diff --git a/src/H5SM.c b/src/H5SM.c
index 4a6e106..e5e28e7 100755
--- a/src/H5SM.c
+++ b/src/H5SM.c
@@ -696,7 +696,6 @@ H5SM_convert_list_to_btree(H5F_t * f, H5SM_index_header_t * header,
if(list->messages[x].ref_count > 0)
{
key.message = list->messages[x];
- /* JAMES: need ref count! And test, if not having refcount doesn't break any tests. */
if(H5B2_insert(f, dxpl_id, H5SM_INDEX, tree_addr, &key) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "couldn't add SOHM to B-tree")
@@ -955,7 +954,6 @@ H5SM_write_mesg(H5F_t *f, hid_t dxpl_id, H5SM_index_header_t *header,
/* JAMES: not very efficient (gets hash value twice, searches list twice). Refactor. */
/* See if the message is already in the index and get its location */
- /* JAMES: should return a pointer to the message */
list_pos = H5SM_find_in_list(list, &key);
if(list_pos != UFAIL)
{
@@ -981,16 +979,11 @@ H5SM_write_mesg(H5F_t *f, hid_t dxpl_id, H5SM_index_header_t *header,
if(!found)
{
hsize_t x; /* Counter variable */
- size_t mesg_size; /* Size of the message on disk */
/* JAMES: wrap this in a function call? */
- /* Encode the message and get its size */ /* JAMES: already have this */
- if((mesg_size = H5O_msg_raw_size(f, type_id, mesg)) == 0)
- HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "unable to get size of message")
-
/* Put the message in the heap and record its new heap ID */
- if(H5HF_insert(fheap, dxpl_id, mesg_size, key.encoding, &shared.u.heap_id) < 0)
+ if(H5HF_insert(fheap, dxpl_id, key.encoding_size, key.encoding, &shared.u.heap_id) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "unable to insert message into fractal heap")
key.message.fheap_id = shared.u.heap_id;
@@ -1044,7 +1037,7 @@ done:
HDONE_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM index")
if(encoding_buf)
- H5MM_free(encoding_buf);
+ encoding_buf = H5MM_xfree(encoding_buf);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5SM_write_mesg() */
@@ -1129,7 +1122,7 @@ done:
/* Free buf */
if(mesg_buf)
- H5MM_xfree(mesg_buf);
+ mesg_buf = H5MM_xfree(mesg_buf);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5SM_try_delete() */
@@ -1368,6 +1361,7 @@ done:
/* Free the serialized message buffer on error */
if(ret_value < 0 && *encoded_mesg)
*encoded_mesg = H5MM_xfree(*encoded_mesg);
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5SM_delete_from_index() */
diff --git a/src/H5SMcache.c b/src/H5SMcache.c
index 7f1c282..c79c7d6 100644
--- a/src/H5SMcache.c
+++ b/src/H5SMcache.c
@@ -138,6 +138,7 @@ H5SM_flush_table(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5SM_ma
/* Encode each index header */
for(x=0; x<table->num_indexes; ++x) {
+ *p++ = H5SM_LIST_VERSION; /* Encode version for this list. */
*p++ = table->indexes[x].index_type; /* Is message index a list or a B-tree? */
UINT16ENCODE(p, table->indexes[x].mesg_types); /* Type of messages in the index */
@@ -248,8 +249,10 @@ H5SM_load_table(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1
/* Read in the index headers */
for(x=0; x<table->num_indexes; ++x) {
- table->indexes[x].index_type= *p++; /* type of the index (list or B-tree) */
+ if (H5SM_LIST_VERSION != *p++)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "bad shared message list version number")
+ table->indexes[x].index_type= *p++; /* type of the index (list or B-tree) */
UINT16DECODE(p, table->indexes[x].mesg_types);
UINT32DECODE(p, table->indexes[x].min_mesg_size);
UINT16DECODE(p, table->indexes[x].list_max);
@@ -410,6 +413,7 @@ H5SM_flush_list(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5SM_lis
size_t size; /* Header size on disk */
uint32_t computed_chksum; /* Computed metadata checksum value */
hsize_t x;
+ hsize_t mesgs_written;
/* JAMES: consider only writing as many messages as necessary, and then adding a
* blank "end of list" message or something?
@@ -423,21 +427,21 @@ H5SM_flush_list(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5SM_lis
HDmemcpy(p, H5SM_LIST_MAGIC, (size_t)H5SM_LIST_SIZEOF_MAGIC);
p += H5SM_LIST_SIZEOF_MAGIC;
- /* Encode version */
- *p++ = H5SM_LIST_VERSION;
-
/* Write messages from the messages array to disk */
- /* JAMES: we have to search the whole array. not the best way to do it; could go until we've written
- * num_messages */
- for(x=0; x<list->header->list_max; x++) {
+ mesgs_written = 0;
+ for(x=0; x<list->header->list_max && mesgs_written < list->header->num_messages; x++) {
if(list->messages[x].ref_count > 0) {
/* JAMES: use H5SM_message_encode here */
UINT32ENCODE(p, list->messages[x].hash); /* Read the hash value for this message */
UINT32ENCODE(p, list->messages[x].ref_count); /* Read the reference count for this message */
UINT64ENCODE(p, list->messages[x].fheap_id); /* Get the heap ID for the message */
+
+ ++mesgs_written;
}
}
+ HDassert(mesgs_written == list->header->num_messages);
+
/* Compute checksum on buffer */
computed_chksum = H5_checksum_metadata(buf, (size - H5SM_SIZEOF_CHECKSUM), 0);
UINT32ENCODE(p, computed_chksum);
@@ -518,10 +522,6 @@ H5SM_load_list(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1,
HGOTO_ERROR(H5E_SOHM, H5E_CANTLOAD, NULL, "bad SOHM list signature");
p += H5SM_LIST_SIZEOF_MAGIC;
- /* Check version JAMES: should be in master table, not list */
- if (H5SM_LIST_VERSION != *p++)
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "wrong shared message list version number")
-
/* Read messages into the list array */
for(x=0; x<header->num_messages; x++)
{
diff --git a/src/H5SMpkg.h b/src/H5SMpkg.h
index 6416a1b..b771893 100755
--- a/src/H5SMpkg.h
+++ b/src/H5SMpkg.h
@@ -41,13 +41,14 @@
#define H5SM_SOHM_ENTRY_SIZE(f) (4 /* Hash value */ \
+ 4 /* reference count*/ \
- + 8) /* JAMES: size of heap ID on disk */
+ + sizeof(H5SM_fheap_id_t)) /* size of heap ID on disk */
#define H5SM_TABLE_SIZE(f) ( H5SM_TABLE_SIZEOF_MAGIC \
+ 1 /* Table version */ \
+ H5SM_SIZEOF_CHECKSUM) /* Checksum */
#define H5SM_INDEX_HEADER_SIZE(f) (1 /* Whether index is a list or B-tree */ \
+ + 1 /* Version of index format */ \
+ 2 /* Type of messages stored in the index */ \
+ 4 /* Minimum size of messages to share */ \
+ (3 * 2) /* B-tree cutoff, list cutoff, # of shared messages */ \
@@ -55,7 +56,6 @@
+ H5F_SIZEOF_ADDR(f)) /* Address of heap */
#define H5SM_LIST_SIZE(f, num_mesg) H5SM_LIST_SIZEOF_MAGIC \
- + 1 /* List version */ \
+ (H5SM_SOHM_ENTRY_SIZE(f) * num_mesg) \
+ H5SM_SIZEOF_CHECKSUM /* Checksum */