summaryrefslogtreecommitdiffstats
path: root/src/H5EAsblock.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2016-12-02 16:07:04 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2016-12-02 16:07:04 (GMT)
commit64a339183f0e4532597744351548308203e993c8 (patch)
treeddfff2f15c0f3a01782f191a847665c6eceadd42 /src/H5EAsblock.c
parent5d7d029b97b36d1c380cef82d637342921bf3a1d (diff)
downloadhdf5-64a339183f0e4532597744351548308203e993c8.zip
hdf5-64a339183f0e4532597744351548308203e993c8.tar.gz
hdf5-64a339183f0e4532597744351548308203e993c8.tar.bz2
Bring SWMR support in to the main development branch. (Finally!) More tests
and the tool and API wrappers will be coming in over the weekend.
Diffstat (limited to 'src/H5EAsblock.c')
-rw-r--r--src/H5EAsblock.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/H5EAsblock.c b/src/H5EAsblock.c
index 4f153cd..2fa87e0 100644
--- a/src/H5EAsblock.c
+++ b/src/H5EAsblock.c
@@ -195,6 +195,7 @@ H5EA__sblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id, H5EA_iblock_t *parent,
H5EA_sblock_t *sblock = NULL; /* Extensible array super block */
haddr_t sblock_addr; /* Extensible array super block address */
haddr_t tmp_addr = HADDR_UNDEF; /* Address value to fill data block addresses with */
+ hbool_t inserted = FALSE; /* Whether the header was inserted into cache */
/* Sanity check */
HDassert(hdr);
@@ -221,6 +222,14 @@ H5EA__sblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id, H5EA_iblock_t *parent,
/* Cache the new extensible array super block */
if(H5AC_insert_entry(hdr->f, dxpl_id, H5AC_EARRAY_SBLOCK, sblock_addr, sblock, H5AC__NO_FLAGS_SET) < 0)
H5E_THROW(H5E_CANTINSERT, "can't add extensible array super block to cache")
+ inserted = TRUE;
+
+ /* Add super block as child of 'top' proxy */
+ if(hdr->top_proxy) {
+ if(H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dxpl_id, sblock) < 0)
+ H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy")
+ sblock->top_proxy = hdr->top_proxy;
+ } /* end if */
/* Update extensible array super block statistics */
hdr->stats.stored.nsuper_blks++;
@@ -235,6 +244,11 @@ H5EA__sblock_create(H5EA_hdr_t *hdr, hid_t dxpl_id, H5EA_iblock_t *parent,
CATCH
if(!H5F_addr_defined(ret_value))
if(sblock) {
+ /* Remove from cache, if inserted */
+ if(inserted)
+ if(H5AC_remove_entry(sblock) < 0)
+ H5E_THROW(H5E_CANTREMOVE, "unable to remove extensible array super block from cache")
+
/* Release super block's disk space */
if(H5F_addr_defined(sblock->addr) && H5MF_xfree(hdr->f, H5FD_MEM_EARRAY_SBLOCK, dxpl_id, sblock->addr, (hsize_t)sblock->size) < 0)
H5E_THROW(H5E_CANTFREE, "unable to release extensible array super block")
@@ -266,6 +280,7 @@ H5EA__sblock_protect(H5EA_hdr_t *hdr, hid_t dxpl_id, H5EA_iblock_t *parent,
haddr_t sblk_addr, unsigned sblk_idx, unsigned flags))
/* Local variables */
+ H5EA_sblock_t *sblock = NULL; /* Pointer to super block */
H5EA_sblock_cache_ud_t udata; /* Information needed for loading super block */
/* Sanity check */
@@ -282,10 +297,27 @@ H5EA__sblock_protect(H5EA_hdr_t *hdr, hid_t dxpl_id, H5EA_iblock_t *parent,
udata.sblk_addr = sblk_addr;
/* Protect the super block */
- if(NULL == (ret_value = (H5EA_sblock_t *)H5AC_protect(hdr->f, dxpl_id, H5AC_EARRAY_SBLOCK, sblk_addr, &udata, flags)))
+ if(NULL == (sblock = (H5EA_sblock_t *)H5AC_protect(hdr->f, dxpl_id, H5AC_EARRAY_SBLOCK, sblk_addr, &udata, flags)))
H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array super block, address = %llu", (unsigned long long)sblk_addr)
+ /* Create top proxy, if it doesn't exist */
+ if(hdr->top_proxy && NULL == sblock->top_proxy) {
+ /* Add super block as child of 'top' proxy */
+ if(H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dxpl_id, sblock) < 0)
+ H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy")
+ sblock->top_proxy = hdr->top_proxy;
+ } /* end if */
+
+ /* Set return value */
+ ret_value = sblock;
+
CATCH
+ /* Clean up on error */
+ if(!ret_value) {
+ /* Release the super block, if it was protected */
+ if(sblock && H5AC_unprotect(hdr->f, dxpl_id, H5AC_EARRAY_SBLOCK, sblock->addr, sblock, H5AC__NO_FLAGS_SET) < 0)
+ H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array super block, address = %llu", (unsigned long long)sblock->addr)
+ } /* end if */
END_FUNC(PKG) /* end H5EA__sblock_protect() */
@@ -409,6 +441,9 @@ H5EA__sblock_dest(H5EA_sblock_t *sblock))
sblock->hdr = NULL;
} /* end if */
+ /* Sanity check */
+ HDassert(NULL == sblock->top_proxy);
+
/* Free the super block itself */
sblock = H5FL_FREE(H5EA_sblock_t, sblock);