summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5Oattr.c36
-rw-r--r--src/H5Oattribute.c20
-rw-r--r--src/H5Opkg.h2
-rw-r--r--src/H5Osdspace.c14
-rwxr-xr-xsrc/H5SM.c48
-rw-r--r--test/tsohm.c8
6 files changed, 49 insertions, 79 deletions
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index 7ec3217..8c9b22d 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -215,24 +215,9 @@ H5O_attr_decode(H5F_t *f, hid_t dxpl_id, unsigned mesg_flags,
if(NULL == (attr->ds = H5FL_CALLOC(H5S_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- if(flags & H5O_ATTR_FLAG_SPACE_SHARED) {
- H5O_shared_t *shared; /* Shared information */
-
- /* Get the shared information */
- if(NULL == (shared = (H5O_shared_t *)(H5O_MSG_SHARED->decode)(f, dxpl_id, mesg_flags, p)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "unable to decode shared message")
-
- /* Get the actual datatype information */
- if((extent = (H5S_extent_t *)H5O_shared_read(f, dxpl_id, shared, H5O_MSG_SDSPACE, NULL))==NULL)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, NULL, "can't decode attribute dataspace")
-
- /* Free the shared information */
- H5O_msg_free_real(H5O_MSG_SHARED, shared);
- } /* end if */
- else {
- if((extent = (H5S_extent_t *)(H5O_MSG_SDSPACE->decode)(f, dxpl_id, mesg_flags, p)) == NULL)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, NULL, "can't decode attribute dataspace")
- } /* end else */
+ /* Decode attribute's dataspace extent */
+ if((extent = (H5S_extent_t *)(H5O_MSG_SDSPACE->decode)(f, dxpl_id, ((flags & H5O_ATTR_FLAG_SPACE_SHARED) ? H5O_MSG_FLAG_SHARED : 0), p)) == NULL)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, NULL, "can't decode attribute dataspace")
/* Copy the extent information to the dataspace */
HDmemcpy(&(attr->ds->extent), extent, sizeof(H5S_extent_t));
@@ -668,8 +653,7 @@ H5O_attr_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link)
*/
if((tri_ret = H5O_msg_is_shared(H5O_DTYPE_ID, attr->dt)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "can't tell if datatype is shared")
- if(tri_ret > 0)
- {
+ else if(tri_ret > 0) {
/* Check whether datatype is shared */
if(H5T_committed(attr->dt)) {
/* Decrement the reference count on the shared datatype, if requested */
@@ -685,15 +669,9 @@ H5O_attr_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link)
} /* end else */
} /* end if */
- if((tri_ret = H5O_msg_is_shared(H5O_SDSPACE_ID, attr->ds)) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "can't tell if dataspace is shared")
- if(tri_ret > 0)
- {
- if(NULL == H5O_msg_get_share(H5O_SDSPACE_ID, attr->ds, &sh_mesg))
- HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "can't get shared message from dataspace")
- if(H5SM_try_delete(f, dxpl_id, H5O_SDSPACE_ID, &sh_mesg) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_SOHM, FAIL, "can't remove dataspace from shared storage")
- } /* end if */
+ /* Decrement reference count on dataspace in file */
+ if((H5O_MSG_SDSPACE->del)(f, dxpl_id, attr->ds, adj_link) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust dataspace link count")
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c
index defc7ba..62e86e0 100644
--- a/src/H5Oattribute.c
+++ b/src/H5Oattribute.c
@@ -226,9 +226,6 @@ H5O_attr_create(const H5O_loc_t *loc, hid_t dxpl_id, H5A_t *attr)
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5O_attr_create)
-#ifdef QAK
-HDfprintf(stderr, "%s: adding attribute, attr->name = '%s'\n", FUNC, attr->name);
-#endif /* QAK */
/* Check arguments */
HDassert(loc);
@@ -280,19 +277,11 @@ HDfprintf(stderr, "%s: adding attribute, attr->name = '%s'\n", FUNC, attr->name)
if(NULL == (oh = (H5O_t *)H5AC_protect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, NULL, NULL, H5AC_WRITE)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTLOAD, FAIL, "unable to load object header")
-#ifdef QAK
-HDfprintf(stderr, "%s: oh->nattrs = %Hu\n", FUNC, oh->nattrs);
-HDfprintf(stderr, "%s: oh->max_compact = %u\n", FUNC, oh->max_compact);
-HDfprintf(stderr, "%s: oh->min_dense = %u\n", FUNC, oh->min_dense);
-#endif /* QAK */
/* Check for switching to "dense" attribute storage */
if(oh->version > H5O_VERSION_1 && oh->nattrs == oh->max_compact &&
!H5F_addr_defined(oh->attr_fheap_addr)) {
H5O_iter_cvt_t udata; /* User data for callback */
H5O_mesg_operator_t op; /* Wrapper for operator */
-#ifdef QAK
-HDfprintf(stderr, "%s: converting attributes to dense storage\n", FUNC);
-#endif /* QAK */
/* Create dense storage for attributes */
if(H5A_dense_create(loc->file, dxpl_id, oh) < 0)
@@ -324,9 +313,6 @@ HDfprintf(stderr, "%s: converting attributes to dense storage\n", FUNC);
/* Check for storing attribute with dense storage */
if(H5F_addr_defined(oh->attr_fheap_addr)) {
/* Insert attribute into dense storage */
-#ifdef QAK
-HDfprintf(stderr, "%s: inserting attribute to dense storage\n", FUNC);
-#endif /* QAK */
if(H5A_dense_insert(loc->file, dxpl_id, oh, mesg_flags, attr) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to add to dense storage")
} /* end if */
@@ -447,12 +433,6 @@ H5O_attr_open_by_name(const H5O_loc_t *loc, const char *name, hid_t dxpl_id)
if(NULL == (oh = (H5O_t *)H5AC_protect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, NULL, NULL, H5AC_READ)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTLOAD, NULL, "unable to load object header")
-#ifdef QAK
-HDfprintf(stderr, "%s: opening attribute to new-style object header\n", FUNC);
-HDfprintf(stderr, "%s: oh->nattrs = %Hu\n", FUNC, oh->nattrs);
-HDfprintf(stderr, "%s: oh->max_compact = %u\n", FUNC, oh->max_compact);
-HDfprintf(stderr, "%s: oh->min_dense = %u\n", FUNC, oh->min_dense);
-#endif /* QAK */
/* Check for opening attribute with dense storage */
if(H5F_addr_defined(oh->attr_fheap_addr)) {
/* Open attribute in dense storage */
diff --git a/src/H5Opkg.h b/src/H5Opkg.h
index e75f297..1ecf283 100644
--- a/src/H5Opkg.h
+++ b/src/H5Opkg.h
@@ -160,7 +160,7 @@
/* Temporary macro to define which message classes are using the "new"
* shared message "interface" for their methods.
*/
-#define H5O_NEW_SHARED(T) ((T) == H5O_MSG_PLINE || (T) == H5O_MSG_FILL_NEW || (T) == H5O_MSG_FILL)
+#define H5O_NEW_SHARED(T) ((T) == H5O_MSG_PLINE || (T) == H5O_MSG_FILL_NEW || (T) == H5O_MSG_FILL || (T) == H5O_MSG_SDSPACE)
/* The "message class" type */
diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c
index 93a0bf0..57a48e6 100644
--- a/src/H5Osdspace.c
+++ b/src/H5Osdspace.c
@@ -30,7 +30,7 @@ static herr_t H5O_sdspace_encode(H5F_t *f, uint8_t *p, const void *_mesg);
static void *H5O_sdspace_copy(const void *_mesg, void *_dest);
static size_t H5O_sdspace_size(const H5F_t *f, const void *_mesg);
static herr_t H5O_sdspace_reset(void *_mesg);
-static herr_t H5O_sdspace_free (void *_mesg);
+static herr_t H5O_sdspace_free(void *_mesg);
static void *H5O_sdspace_get_share(const void *_mesg, H5O_shared_t *sh);
static herr_t H5O_sdspace_set_share(void *_mesg, const H5O_shared_t *sh);
static htri_t H5O_sdspace_is_shared(const void *_mesg);
@@ -60,20 +60,20 @@ const H5O_msg_class_t H5O_MSG_SDSPACE[1] = {{
H5O_SDSPACE_ID, /* message id number */
"dataspace", /* message name for debugging */
sizeof(H5S_extent_t), /* native message size */
- H5O_sdspace_decode, /* decode message */
- H5O_sdspace_encode, /* encode message */
+ H5O_sdspace_shared_decode, /* decode message */
+ H5O_sdspace_shared_encode, /* encode message */
H5O_sdspace_copy, /* copy the native value */
- H5O_sdspace_size, /* size of symbol table entry */
+ H5O_sdspace_shared_size, /* size of symbol table entry */
H5O_sdspace_reset, /* default reset method */
H5O_sdspace_free, /* free method */
- NULL, /* file delete method */
- NULL, /* link method */
+ H5O_sdspace_shared_delete, /* file delete method */
+ H5O_sdspace_shared_link, /* link method */
H5O_sdspace_get_share, /* get share method */
H5O_sdspace_set_share, /* set share method */
NULL, /*can share method */
H5O_sdspace_is_shared, /* is shared method */
H5O_sdspace_pre_copy_file, /* pre copy native value to file */
- NULL, /* copy native value to file */
+ H5O_sdspace_shared_copy_file,/* copy native value to file */
NULL, /* post copy native value to file */
NULL, /* get creation index */
NULL, /* set creation index */
diff --git a/src/H5SM.c b/src/H5SM.c
index bb0d903..5a656fb 100755
--- a/src/H5SM.c
+++ b/src/H5SM.c
@@ -234,7 +234,9 @@ H5SM_type_to_flag(unsigned type_id, unsigned *type_flag)
case H5O_DTYPE_ID:
*type_flag = H5O_MESG_DTYPE_FLAG;
break;
+#ifdef NOT_YET
case H5O_FILL_ID:
+#endif /* NOT_YET */
case H5O_FILL_NEW_ID:
*type_flag = H5O_MESG_FILL_FLAG;
break;
@@ -753,7 +755,7 @@ done:
HDONE_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "unable to unprotect SOHM index")
FUNC_LEAVE_NOAPI(ret_value)
-}
+} /* end H5SM_convert_btree_to_list() */
/*-------------------------------------------------------------------------
@@ -865,15 +867,17 @@ static herr_t
H5SM_write_mesg(H5F_t *f, hid_t dxpl_id, H5SM_index_header_t *header,
unsigned type_id, void *mesg, unsigned *cache_flags_ptr)
{
+ H5O_shared_t *sh_mesg = (H5O_shared_t *)mesg; /* Pointer to message's shared message info */
+ unsigned old_sh_mesg_flags; /* Message's current shared message flags */
H5SM_list_t *list = NULL; /* List index */
- H5SM_mesg_key_t key; /* Key used to search the index */
+ H5SM_mesg_key_t key; /* Key used to search the index */
H5O_shared_t shared; /* Shared H5O message */
hsize_t list_pos; /* Position in a list index */
hbool_t found = FALSE; /* Was the message in the index? */
- H5HF_t *fheap = NULL; /* Fractal heap handle */
+ H5HF_t *fheap = NULL; /* Fractal heap handle */
size_t buf_size; /* Size of the encoded message */
- void * encoding_buf=NULL; /* Buffer for encoded message */
- size_t empty_pos=UFAIL; /* Empty entry in list */
+ void * encoding_buf = NULL; /* Buffer for encoded message */
+ size_t empty_pos = UFAIL; /* Empty entry in list */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(H5SM_write_mesg, FAIL)
@@ -882,21 +886,25 @@ H5SM_write_mesg(H5F_t *f, hid_t dxpl_id, H5SM_index_header_t *header,
HDassert(header);
HDassert(header->index_type != H5SM_BADTYPE);
- /* Set up a shared message so that we can make this message shared once it's
- * written to the index. This message is always stored to the heap, not to
- * an object header.
+ /* Preserve message's shared message info while getting the
+ * "real" encoded size & buffer (*ick* - QAK)
+ * (XXX: Harmless but ugly for message classes that aren't using shared
+ * message method interface yet - QAK)
*/
- shared.flags = H5O_SHARED_IN_HEAP_FLAG;
+ old_sh_mesg_flags = sh_mesg->flags;
+ sh_mesg->flags = 0;
/* Encode the message to be written */
if((buf_size = H5O_msg_raw_size(f, type_id, mesg)) <= 0)
HGOTO_ERROR(H5E_OHDR, H5E_BADSIZE, FAIL, "can't find message size")
if(NULL == (encoding_buf = H5MM_calloc(buf_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate buffer for encoding")
-
if(H5O_msg_encode(f, type_id, (unsigned char *)encoding_buf, mesg) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "can't encode message to be shared")
+ /* Restore message's shared message info (*ick* - QAK) */
+ sh_mesg->flags = old_sh_mesg_flags;
+
/* Open the fractal heap for this index */
if(NULL == (fheap = H5HF_open(f, dxpl_id, header->heap_addr)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap")
@@ -917,7 +925,7 @@ H5SM_write_mesg(H5F_t *f, hid_t dxpl_id, H5SM_index_header_t *header,
if(header->index_type == H5SM_LIST)
{
/* The index is a list; get it from the cache */
- if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, dxpl_id, H5AC_SOHM_LIST, header->index_addr, NULL, header, H5AC_WRITE)))
+ if(NULL == (list = (H5SM_list_t *)H5AC_protect(f, dxpl_id, H5AC_SOHM_LIST, header->index_addr, NULL, header, H5AC_WRITE)))
HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, FAIL, "unable to load SOHM index")
/* See if the message is already in the index and get its location.
@@ -933,8 +941,8 @@ H5SM_write_mesg(H5F_t *f, hid_t dxpl_id, H5SM_index_header_t *header,
/* Set up the shared location to point to the shared location */
shared.u.heap_id = list->messages[list_pos].fheap_id;
found = TRUE;
- }
- }
+ } /* end if */
+ } /* end if */
else /* Index is a B-tree */
{
HDassert(header->index_type == H5SM_BTREE);
@@ -943,7 +951,13 @@ H5SM_write_mesg(H5F_t *f, hid_t dxpl_id, H5SM_index_header_t *header,
/* If it succeeds, the heap_id in the shared struct will be set */
if(H5B2_modify(f, dxpl_id, H5SM_INDEX, header->index_addr, &key, H5SM_incr_ref, &shared.u.heap_id) >= 0)
found = TRUE;
- }
+ } /* end else */
+
+ /* Set up a shared message so that we can make this message shared once it's
+ * written to the index. This message is always stored to the heap, not to
+ * an object header.
+ */
+ shared.flags = H5O_SHARED_IN_HEAP_FLAG;
/* If the message isn't in the list, add it */
if(!found)
@@ -1239,7 +1253,7 @@ H5SM_delete_from_index(H5F_t *f, hid_t dxpl_id, H5SM_index_header_t *header,
if(header->index_type == H5SM_LIST)
{
/* If the index is stored as a list, get it from the cache */
- if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, dxpl_id, H5AC_SOHM_LIST, header->index_addr, NULL, header, H5AC_WRITE)))
+ if(NULL == (list = (H5SM_list_t *)H5AC_protect(f, dxpl_id, H5AC_SOHM_LIST, header->index_addr, NULL, header, H5AC_WRITE)))
HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM index")
/* Find the message in the list */
@@ -1280,9 +1294,7 @@ H5SM_delete_from_index(H5F_t *f, hid_t dxpl_id, H5SM_index_header_t *header,
/* Remove the message from the index */
if(header->index_type == H5SM_LIST)
- {
list->messages[list_pos].ref_count = 0;
- }
else
{
if(H5B2_remove(f, dxpl_id, H5SM_INDEX, header->index_addr, &key, NULL, NULL) < 0)
@@ -1756,7 +1768,7 @@ H5SM_list_debug(H5F_t *f, hid_t dxpl_id, haddr_t list_addr,
header.index_addr = list_addr;
/* Get the list from the cache */
- if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, dxpl_id, H5AC_SOHM_LIST, list_addr, NULL, &header, H5AC_READ)))
+ if(NULL == (list = (H5SM_list_t *)H5AC_protect(f, dxpl_id, H5AC_SOHM_LIST, list_addr, NULL, &header, H5AC_READ)))
HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, FAIL, "unable to load SOHM index")
HDfprintf(stream, "%*sShared Message List Index...\n", indent, "");
diff --git a/test/tsohm.c b/test/tsohm.c
index e0e4e2b..7361f3e 100644
--- a/test/tsohm.c
+++ b/test/tsohm.c
@@ -2361,11 +2361,11 @@ static void test_sohm_size2(int close_reopen)
btree_index.dsets2 - btree_index.dsets1)
VERIFY(0, 1, "h5_get_file_size");
- if(mult_index_med.interleaved - mult_index_med.dsets2 !=
- list_index_med.interleaved - list_index_med.dsets2)
+ if(mult_index_med.interleaved - mult_index_med.dsets2 >
+ (list_index_med.interleaved - list_index_med.dsets2) * OVERHEAD_ALLOWED)
VERIFY(0, 1, "h5_get_file_size");
- if(mult_index_btree.interleaved - mult_index_btree.dsets2 !=
- btree_index.interleaved - btree_index.dsets2)
+ if(mult_index_btree.interleaved - mult_index_btree.dsets2 >
+ (btree_index.interleaved - btree_index.dsets2) * OVERHEAD_ALLOWED)
VERIFY(0, 1, "h5_get_file_size");
/* When all the attributes are added, only the index holding attributes