summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-01-10 04:01:31 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-01-10 04:01:31 (GMT)
commit1f3ffdab86a097c9845357c2f87174671234870e (patch)
tree659e43068677e7a54ab786a74c9bea06c9af9220 /src
parenta2a3e47d06ce348ce27718b4a3e0e4b156fba6f5 (diff)
downloadhdf5-1f3ffdab86a097c9845357c2f87174671234870e.zip
hdf5-1f3ffdab86a097c9845357c2f87174671234870e.tar.gz
hdf5-1f3ffdab86a097c9845357c2f87174671234870e.tar.bz2
[svn-r13130] Description:
Further tests & bugfixes for shared/committed components of shared/un- shared attributes using dense/compact storage. Tested on: Mac OS X/32 10.4.8 (amazon) FreeBSD/32 6.1 (duty)
Diffstat (limited to 'src')
-rw-r--r--src/H5Adense.c8
-rw-r--r--src/H5Apkg.h2
-rw-r--r--src/H5Oattr.c36
-rw-r--r--src/H5Oattribute.c14
-rw-r--r--src/H5Oprivate.h2
-rw-r--r--src/H5Oshared.c4
-rwxr-xr-xsrc/H5SM.c24
7 files changed, 50 insertions, 40 deletions
diff --git a/src/H5Adense.c b/src/H5Adense.c
index 972d80e..c492932 100644
--- a/src/H5Adense.c
+++ b/src/H5Adense.c
@@ -51,7 +51,7 @@
#define H5A_FHEAP_MAN_WIDTH 4
#define H5A_FHEAP_MAN_START_BLOCK_SIZE 512
#define H5A_FHEAP_MAN_MAX_DIRECT_SIZE (64 * 1024)
-#define H5A_FHEAP_MAN_MAX_INDEX 32
+#define H5A_FHEAP_MAN_MAX_INDEX 40
#define H5A_FHEAP_MAN_START_ROOT_ROWS 1
#define H5A_FHEAP_CHECKSUM_DBLOCKS TRUE
#define H5A_FHEAP_MAX_MAN_SIZE (4 * 1024)
@@ -824,6 +824,12 @@ H5A_dense_rename(H5F_t *f, hid_t dxpl_id, const H5O_t *oh, const char *old_name,
HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust attribute link count")
} /* end if */
} /* end if */
+ else if(shared_mesg == 0) {
+ /* Increment reference count on attribute components */
+ /* (so that they aren't deleted when the attribute is removed shortly) */
+ if(H5O_attr_link(f, dxpl_id, attr_copy) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust attribute link count")
+ } /* end if */
else if(shared_mesg < 0)
HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "error determining if message should be shared")
diff --git a/src/H5Apkg.h b/src/H5Apkg.h
index 238546f..82471d1 100644
--- a/src/H5Apkg.h
+++ b/src/H5Apkg.h
@@ -51,7 +51,7 @@
/**************************/
/* Standard length of fractal heap ID for attribute */
-#define H5A_DENSE_FHEAP_ID_LEN 7
+#define H5A_DENSE_FHEAP_ID_LEN 8
/****************************/
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index aae4858..1358147 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -665,10 +665,19 @@ H5O_attr_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link)
HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "can't tell if datatype is shared")
if(tri_ret > 0)
{
- if(NULL == H5O_msg_get_share(H5O_DTYPE_ID, attr->dt, &sh_mesg))
- HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "can't get shared message from datatype")
- if(H5SM_try_delete(f, dxpl_id, H5O_DTYPE_ID, &sh_mesg) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "can't remove datatype from heap")
+ /* Check whether datatype is shared */
+ if(H5T_committed(attr->dt)) {
+ /* Decrement the reference count on the shared datatype, if requested */
+ if(adj_link)
+ if(H5T_link(attr->dt, -1, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust shared datatype link count")
+ } /* end if */
+ else {
+ if(NULL == H5O_msg_get_share(H5O_DTYPE_ID, attr->dt, &sh_mesg))
+ HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "can't get shared message from datatype")
+ if(H5SM_try_delete(f, dxpl_id, H5O_DTYPE_ID, &sh_mesg) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "can't remove datatype from heap")
+ } /* end else */
} /* end if */
if((tri_ret = H5O_msg_is_shared(H5O_SDSPACE_ID, attr->ds)) < 0)
@@ -681,14 +690,6 @@ H5O_attr_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link)
HGOTO_ERROR(H5E_ATTR, H5E_SOHM, FAIL, "can't remove dataspace from shared storage")
} /* end if */
- /* Check whether datatype is shared */
- if(H5T_committed(attr->dt)) {
- /* Decrement the reference count on the shared datatype, if requested */
- if(adj_link)
- if(H5T_link(attr->dt, -1, dxpl_id) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust shared datatype link count")
- } /* end if */
-
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_attr_delete() */
@@ -724,17 +725,18 @@ H5O_attr_link(H5F_t *f, hid_t dxpl_id, const void *_mesg)
* Otherwise they may be deleted when the attribute
* message is deleted.
*/
- if(H5SM_try_share(f, dxpl_id, H5O_DTYPE_ID, attr->dt) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "error trying to re-share attribute datatype")
- if(H5SM_try_share(f, dxpl_id, H5O_SDSPACE_ID, attr->ds) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "error trying to re-share attribute dataspace")
-
/* Check whether datatype is shared */
if(H5T_committed(attr->dt)) {
/* Increment the reference count on the shared datatype */
if(H5T_link(attr->dt, 1, dxpl_id) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust shared datatype link count")
} /* end if */
+ else {
+ if(H5SM_try_share(f, dxpl_id, H5O_DTYPE_ID, attr->dt) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "error trying to re-share attribute datatype")
+ } /* end else */
+ if(H5SM_try_share(f, dxpl_id, H5O_SDSPACE_ID, attr->ds) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "error trying to re-share attribute dataspace")
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c
index 57cc4ae..237e352 100644
--- a/src/H5Oattribute.c
+++ b/src/H5Oattribute.c
@@ -957,15 +957,11 @@ H5O_attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/,
oh->nattrs++;
/* Append renamed attribute to object header */
- /* (increments the link count on shared components) */
+ /* (doesn't increment the link count on shared components because
+ * attributes no longer have a 'link' callback) */
if(H5O_msg_append_real(udata->f, udata->dxpl_id, oh, H5O_MSG_ATTR, 0, 0, attr, oh_flags_ptr) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, H5_ITER_ERROR, "unable to relocate renamed attribute in header")
- /* Decrement the link count on shared components */
- /* (to balance all the link count adjustments out) */
- if(H5O_attr_delete(udata->f, udata->dxpl_id, attr, TRUE) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, H5_ITER_ERROR, "unable to delete attribute")
-
/* Release the local copy of the attribute */
H5O_msg_free_real(H5O_MSG_ATTR, attr);
} /* end if */
@@ -1324,6 +1320,12 @@ H5O_attr_remove(const H5O_loc_t *loc, const char *name, hid_t dxpl_id)
if((shared_mesg = H5SM_try_share(loc->file, dxpl_id, H5O_ATTR_ID, &(atable.attrs[u]))) > 0)
/* Mark the message as shared */
mesg_flags |= H5O_MSG_FLAG_SHARED;
+ else if(shared_mesg == 0) {
+ /* Increment reference count on attribute components */
+ /* (so that they aren't deleted when the dense attribute storage is deleted) */
+ if(H5O_attr_link(loc->file, dxpl_id, &(atable.attrs[u])) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust attribute link count")
+ } /* end if */
else if(shared_mesg < 0)
HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "error determining if message should be shared")
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index 1a42569..2d555e8 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -49,7 +49,7 @@ typedef struct H5O_t H5O_t;
* 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
+#define H5SM_FHEAP_ID_LEN 8
typedef uint64_t H5SM_fheap_id_t;
diff --git a/src/H5Oshared.c b/src/H5Oshared.c
index fa6a7ef..eef0bd8 100644
--- a/src/H5Oshared.c
+++ b/src/H5Oshared.c
@@ -318,7 +318,7 @@ H5O_shared_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *buf)
*/
if(mesg->flags & H5O_SHARED_IN_HEAP_FLAG) {
HDassert(version >= H5O_SHARED_VERSION_3 );
- HDmemcpy(&(mesg->u.heap_id), buf, (size_t) H5SM_FHEAP_ID_LEN);
+ HDmemcpy(&(mesg->u.heap_id), buf, sizeof(mesg->u.heap_id));
}
else {
/* The H5O_COMMITTED_FLAG should be set if this message
@@ -395,7 +395,7 @@ H5O_shared_encode(H5F_t *f, uint8_t *buf/*out*/, const void *_mesg)
* object header that holds it.
*/
if(mesg->flags & H5O_SHARED_IN_HEAP_FLAG) {
- HDmemcpy(buf, &(mesg->u.heap_id), (size_t) H5SM_FHEAP_ID_LEN);
+ HDmemcpy(buf, &(mesg->u.heap_id), sizeof(mesg->u.heap_id));
}
else {
H5F_addr_encode(f, &buf, mesg->u.oloc.addr);
diff --git a/src/H5SM.c b/src/H5SM.c
index e5e28e7..40e47c7 100755
--- a/src/H5SM.c
+++ b/src/H5SM.c
@@ -38,7 +38,7 @@
#define H5SM_FHEAP_MAN_WIDTH 4
#define H5SM_FHEAP_MAN_START_BLOCK_SIZE 1024
#define H5SM_FHEAP_MAN_MAX_DIRECT_SIZE (64 * 1024)
-#define H5SM_FHEAP_MAN_MAX_INDEX 32
+#define H5SM_FHEAP_MAN_MAX_INDEX 40
#define H5SM_FHEAP_MAN_START_ROOT_ROWS 1
#define H5SM_FHEAP_CHECKSUM_DBLOCKS TRUE
#define H5SM_FHEAP_MAX_MAN_SIZE (4 * 1024)
@@ -486,6 +486,7 @@ H5SM_create_index(H5F_t *f, H5SM_index_header_t *header, hid_t dxpl_id)
if(H5HF_get_id_len(fheap, &fheap_id_len) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTGETSIZE, FAIL, "can't get fractal heap ID length")
HDassert(fheap_id_len == H5SM_FHEAP_ID_LEN);
+ HDassert(sizeof(H5SM_fheap_id_t) == H5SM_FHEAP_ID_LEN);
#endif /* NDEBUG */
done:
@@ -1145,22 +1146,21 @@ size_t
H5SM_find_in_list(H5SM_list_t *list, const H5SM_mesg_key_t *key)
{
size_t x;
- size_t ret_value = UFAIL;
+ size_t ret_value;
- FUNC_ENTER_NOAPI_NOFUNC(H5SM_find_in_list)
+ FUNC_ENTER_NOAPI(H5SM_find_in_list, UFAIL)
HDassert(list);
HDassert(key);
for(x = 0; x < list->header->list_max; x++)
- {
- if((list->messages[x].ref_count > 0 )&& 0 == H5SM_message_compare(key, &(list->messages[x])))
- {
- ret_value = x;
- break;
- }
- }
+ if((list->messages[x].ref_count > 0) && 0 == H5SM_message_compare(key, &(list->messages[x])))
+ HGOTO_DONE(x)
+
+ /* If we reached this point, we didn't find the message */
+ HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, UFAIL, "message not in list")
+done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5SM_find_in_list */
@@ -1323,7 +1323,7 @@ H5SM_delete_from_index(H5F_t *f, hid_t dxpl_id, H5SM_index_header_t *header,
/* If there are no messages left in the index, delete it */
- if(header->num_messages <=0) {
+ if(header->num_messages == 0) {
/* Unprotect cache and release heap */
if(list && H5AC_unprotect(f, dxpl_id, H5AC_SOHM_LIST, header->index_addr, list, H5AC__DELETED_FLAG) < 0)
@@ -1444,7 +1444,7 @@ H5SM_reconstitute(H5O_shared_t *sh_mesg, const uint8_t *heap_id)
/* Set flag for shared message */
sh_mesg->flags = H5O_SHARED_IN_HEAP_FLAG;
- HDmemcpy(&sh_mesg->u.heap_id, heap_id, (size_t)H5SM_FHEAP_ID_LEN);
+ HDmemcpy(&sh_mesg->u.heap_id, heap_id, sizeof(sh_mesg->u.heap_id));
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5SM_reconstitute() */