summaryrefslogtreecommitdiffstats
path: root/src/H5O.c
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2009-02-12 18:47:04 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2009-02-12 18:47:04 (GMT)
commitfb81174e767b62bcccd45b68611255982e96d449 (patch)
tree55735c9f26b3e1720a061856cd14f497b356e16b /src/H5O.c
parente52b18bf2c3ad7c2a58176617001d05e50cc3f51 (diff)
downloadhdf5-fb81174e767b62bcccd45b68611255982e96d449.zip
hdf5-fb81174e767b62bcccd45b68611255982e96d449.tar.gz
hdf5-fb81174e767b62bcccd45b68611255982e96d449.tar.bz2
[svn-r16473] Purpose: fix problems related to 'self-referential' attributes
Description: When an attribute was created with a datatype or dataspace that was shared in the same object header that the attribute was in, the attribute could not be deleted. Changes made to ensure that the attribute can be deleted both when the attribute is in the object header and when it is shared in the heap. Object header message decode routines now take an "open_oh" parameter to enable them to avoid opening the same object header twice. Tested: jam, smirom (h5committest)
Diffstat (limited to 'src/H5O.c')
-rw-r--r--src/H5O.c89
1 files changed, 61 insertions, 28 deletions
diff --git a/src/H5O.c b/src/H5O.c
index 73c8e73..8c8ace0 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -1393,9 +1393,9 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5O_link
+ * Function: H5O_link_oh
*
- * Purpose: Adjust the link count for an object header by adding
+ * Purpose: Adjust the link count for an open object header by adding
* ADJUST to the link count.
*
* Return: Success: New link count
@@ -1409,24 +1409,12 @@ done:
*-------------------------------------------------------------------------
*/
int
-H5O_link(const H5O_loc_t *loc, int adjust, hid_t dxpl_id)
+H5O_link_oh(H5F_t *f, int adjust, hid_t dxpl_id, H5O_t *oh, unsigned *oh_flags)
{
- H5O_t *oh = NULL;
- H5AC_protect_t oh_acc; /* Access mode for protecting object header */
- unsigned oh_flags = H5AC__NO_FLAGS_SET; /* Whether the object was deleted */
+ haddr_t addr = H5O_OH_GET_ADDR(oh); /* Object header address */
int ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5O_link, FAIL)
-
- /* check args */
- HDassert(loc);
- HDassert(loc->file);
- HDassert(H5F_addr_defined(loc->addr));
-
- /* get header */
- oh_acc = adjust ? H5AC_WRITE : H5AC_READ;
- if(NULL == (oh = (H5O_t *)H5AC_protect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, NULL, NULL, oh_acc)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header")
+ FUNC_ENTER_NOAPI(H5O_link_oh, FAIL)
/* Check for adjusting link count */
if(adjust) {
@@ -1435,38 +1423,38 @@ H5O_link(const H5O_loc_t *loc, int adjust, hid_t dxpl_id)
if((unsigned)(-adjust) > oh->nlink)
HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "link count would be negative")
oh->nlink += adjust;
- oh_flags |= H5AC__DIRTIED_FLAG;
+ *oh_flags |= H5AC__DIRTIED_FLAG;
/* Check if the object should be deleted */
if(oh->nlink == 0) {
/* Check if the object is still open by the user */
- if(H5FO_opened(loc->file, loc->addr) != NULL) {
+ if(H5FO_opened(f, addr) != NULL) {
/* Flag the object to be deleted when it's closed */
- if(H5FO_mark(loc->file, loc->addr, TRUE) < 0)
+ if(H5FO_mark(f, addr, TRUE) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't mark object for deletion")
} /* end if */
else {
/* Delete object right now */
- if(H5O_delete_oh(loc->file, dxpl_id, oh) < 0)
+ if(H5O_delete_oh(f, dxpl_id, oh) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't delete object from file")
/* Mark the object header as deleted */
- oh_flags = H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG;
+ *oh_flags = H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG;
} /* end else */
} /* end if */
} else {
/* A new object, or one that will be deleted */
if(oh->nlink == 0) {
/* Check if the object is current open, but marked for deletion */
- if(H5FO_marked(loc->file, loc->addr) > 0) {
+ if(H5FO_marked(f, addr) > 0) {
/* Remove "delete me" flag on the object */
- if(H5FO_mark(loc->file, loc->addr, FALSE) < 0)
+ if(H5FO_mark(f, addr, FALSE) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't mark object for deletion")
} /* end if */
} /* end if */
oh->nlink += adjust;
- oh_flags |= H5AC__DIRTIED_FLAG;
+ *oh_flags |= H5AC__DIRTIED_FLAG;
} /* end if */
/* Check for operations on refcount message */
@@ -1475,7 +1463,7 @@ H5O_link(const H5O_loc_t *loc, int adjust, hid_t dxpl_id)
if(oh->has_refcount_msg) {
/* Check for removing refcount message */
if(oh->nlink <= 1) {
- if(H5O_msg_remove_real(loc->file, oh, H5O_MSG_REFCOUNT, H5O_ALL, NULL, NULL, TRUE, dxpl_id) < 0)
+ if(H5O_msg_remove_real(f, oh, H5O_MSG_REFCOUNT, H5O_ALL, NULL, NULL, TRUE, dxpl_id) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete refcount message")
oh->has_refcount_msg = FALSE;
} /* end if */
@@ -1483,7 +1471,7 @@ H5O_link(const H5O_loc_t *loc, int adjust, hid_t dxpl_id)
else {
H5O_refcount_t refcount = oh->nlink;
- if(H5O_msg_write_real(loc->file, dxpl_id, oh, H5O_MSG_REFCOUNT, H5O_MSG_FLAG_DONTSHARE, 0, &refcount) < 0)
+ if(H5O_msg_write_real(f, dxpl_id, oh, H5O_MSG_REFCOUNT, H5O_MSG_FLAG_DONTSHARE, 0, &refcount) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTUPDATE, FAIL, "unable to update refcount message")
} /* end else */
} /* end if */
@@ -1492,7 +1480,7 @@ H5O_link(const H5O_loc_t *loc, int adjust, hid_t dxpl_id)
if(oh->nlink > 1) {
H5O_refcount_t refcount = oh->nlink;
- if(H5O_msg_append_real(loc->file, dxpl_id, oh, H5O_MSG_REFCOUNT, H5O_MSG_FLAG_DONTSHARE, 0, &refcount) < 0)
+ if(H5O_msg_append_real(f, dxpl_id, oh, H5O_MSG_REFCOUNT, H5O_MSG_FLAG_DONTSHARE, 0, &refcount) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to create new refcount message")
oh->has_refcount_msg = TRUE;
} /* end if */
@@ -1504,6 +1492,51 @@ H5O_link(const H5O_loc_t *loc, int adjust, hid_t dxpl_id)
ret_value = oh->nlink;
done:
+ FUNC_LEAVE_NOAPI(ret_value);
+} /* end H5O_link_oh() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_link
+ *
+ * Purpose: Adjust the link count for an object header by adding
+ * ADJUST to the link count.
+ *
+ * Return: Success: New link count
+ *
+ * Failure: Negative
+ *
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 5 1997
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+H5O_link(const H5O_loc_t *loc, int adjust, hid_t dxpl_id)
+{
+ H5O_t *oh = NULL;
+ H5AC_protect_t oh_acc; /* Access mode for protecting object header */
+ unsigned oh_flags = H5AC__NO_FLAGS_SET; /* Whether the object was deleted */
+ int ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5O_link, FAIL)
+
+ /* check args */
+ HDassert(loc);
+ HDassert(loc->file);
+ HDassert(H5F_addr_defined(loc->addr));
+
+ /* get header */
+ oh_acc = adjust ? H5AC_WRITE : H5AC_READ;
+ if(NULL == (oh = (H5O_t *)H5AC_protect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, NULL, NULL, oh_acc)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header")
+
+ /* Call the "real" link routine */
+ if((ret_value = H5O_link_oh(loc->file, adjust, dxpl_id, oh, &oh_flags)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust object link count")
+
+done:
if(oh && H5AC_unprotect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, oh, oh_flags) < 0)
HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header")