summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVailin Choi <vchoi@jam.ad.hdfgroup.org>2019-04-23 15:54:27 (GMT)
committerVailin Choi <vchoi@jam.ad.hdfgroup.org>2019-04-23 15:54:27 (GMT)
commitcee23ba89ac74423f7c8d3e797ecd45cc0fef5c3 (patch)
tree83d5ebdc7d28b6a07ec1d33edfe63b906a325d69 /src
parentffbb870e95329c828b5f5f24fb33d8a9e351e02f (diff)
downloadhdf5-cee23ba89ac74423f7c8d3e797ecd45cc0fef5c3.zip
hdf5-cee23ba89ac74423f7c8d3e797ecd45cc0fef5c3.tar.gz
hdf5-cee23ba89ac74423f7c8d3e797ecd45cc0fef5c3.tar.bz2
Make the corresponding fix for HDFFV-10579 H5Arename fails when creation order of attributes is tracked.
Diffstat (limited to 'src')
-rw-r--r--src/H5Adense.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/H5Adense.c b/src/H5Adense.c
index ab159ff..ac2b9b2 100644
--- a/src/H5Adense.c
+++ b/src/H5Adense.c
@@ -893,6 +893,7 @@ H5A_dense_rename(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, const char *
H5HF_t *fheap = NULL; /* Fractal heap handle */
H5HF_t *shared_fheap = NULL; /* Fractal heap handle for shared header messages */
H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */
+ H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order ndex */
H5A_t *attr_copy = NULL; /* Copy of attribute to rename */
htri_t attr_sharable; /* Flag indicating attributes are sharable */
htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */
@@ -973,6 +974,34 @@ H5A_dense_rename(H5F_t *f, hid_t dxpl_id, const H5O_ainfo_t *ainfo, const char *
if(H5A_set_version(f, attr_copy) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "unable to update attribute version")
+ /* Need to remove the attribute from the creation order index v2 B-tree */
+ if(ainfo->index_corder) {
+ htri_t corder_attr_exists; /* Attribute exists in v2 B-tree */
+
+ /* Open the creation order index v2 B-tree */
+ HDassert(H5F_addr_defined(ainfo->corder_bt2_addr));
+ if(NULL == (bt2_corder = H5B2_open(f, dxpl_id, ainfo->corder_bt2_addr, NULL)))
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation index")
+
+ /* Set up the creation order to search for */
+ udata.corder = attr_copy->shared->crt_idx;
+
+ if((corder_attr_exists = H5B2_find(bt2_corder, dxpl_id, &udata, NULL, NULL)) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "can't search for attribute in name index")
+
+ if(corder_attr_exists) {
+ H5A_bt2_ud_rm_t rm_udata;
+
+ /* Set up the creation order in user data for the v2 B-tree 'record remove' callback */
+ rm_udata.common.corder = attr_copy->shared->crt_idx;
+
+ /* Remove the record from the creation order index v2 B-tree */
+ if(H5B2_remove(bt2_corder, dxpl_id, &rm_udata, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTREMOVE, FAIL, "unable to remove attribute from creation order index v2 B-tree")
+ }
+ }
+
+
/* Insert renamed attribute back into dense storage */
/* (Possibly making it shared) */
if(H5A_dense_insert(f, dxpl_id, ainfo, attr_copy) < 0)
@@ -1020,6 +1049,8 @@ done:
HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close fractal heap")
if(bt2_name && H5B2_close(bt2_name, dxpl_id) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for name index")
+ if(bt2_corder && H5B2_close(bt2_corder, dxpl_id) < 0)
+ HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "can't close v2 B-tree for creation order index")
if(attr_copy)
H5O_msg_free(H5O_ATTR_ID, attr_copy);