summaryrefslogtreecommitdiffstats
path: root/src/H5FAdblock.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/H5FAdblock.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/H5FAdblock.c')
-rw-r--r--src/H5FAdblock.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/H5FAdblock.c b/src/H5FAdblock.c
index f597c8e..440447d 100644
--- a/src/H5FAdblock.c
+++ b/src/H5FAdblock.c
@@ -191,6 +191,7 @@ H5FA__dblock_create(H5FA_hdr_t *hdr, hid_t dxpl_id, hbool_t *hdr_dirty))
/* Local variables */
H5FA_dblock_t *dblock = NULL; /* Fixed array data block */
haddr_t dblock_addr; /* Fixed array data block address */
+ hbool_t inserted = FALSE; /* Whether the header was inserted into cache */
/* Sanity check */
HDassert(hdr);
@@ -217,6 +218,14 @@ H5FA__dblock_create(H5FA_hdr_t *hdr, hid_t dxpl_id, hbool_t *hdr_dirty))
/* Cache the new fixed array data block */
if(H5AC_insert_entry(hdr->f, dxpl_id, H5AC_FARRAY_DBLOCK, dblock_addr, dblock, H5AC__NO_FLAGS_SET) < 0)
H5E_THROW(H5E_CANTINSERT, "can't add fixed array data block to cache")
+ inserted = TRUE;
+
+ /* Add data block as child of 'top' proxy */
+ if(hdr->top_proxy) {
+ if(H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dxpl_id, dblock) < 0)
+ H5E_THROW(H5E_CANTSET, "unable to add fixed array entry as child of array proxy")
+ dblock->top_proxy = hdr->top_proxy;
+ } /* end if */
/* Mark the header dirty (for updating statistics) */
*hdr_dirty = TRUE;
@@ -228,6 +237,11 @@ CATCH
if(!H5F_addr_defined(ret_value))
if(dblock) {
+ /* Remove from cache, if inserted */
+ if(inserted)
+ if(H5AC_remove_entry(dblock) < 0)
+ H5E_THROW(H5E_CANTREMOVE, "unable to remove fixed array data block from cache")
+
/* Release data block's disk space */
if(H5F_addr_defined(dblock->addr) && H5MF_xfree(hdr->f, H5FD_MEM_FARRAY_DBLOCK, dxpl_id, dblock->addr, (hsize_t)dblock->size) < 0)
H5E_THROW(H5E_CANTFREE, "unable to release fixed array data block")
@@ -258,6 +272,7 @@ H5FA__dblock_protect(H5FA_hdr_t *hdr, hid_t dxpl_id, haddr_t dblk_addr,
unsigned flags))
/* Local variables */
+ H5FA_dblock_t *dblock; /* Fixed array data block */
H5FA_dblock_cache_ud_t udata; /* Information needed for loading data block */
/* Sanity check */
@@ -272,11 +287,28 @@ H5FA__dblock_protect(H5FA_hdr_t *hdr, hid_t dxpl_id, haddr_t dblk_addr,
udata.dblk_addr = dblk_addr;
/* Protect the data block */
- if(NULL == (ret_value = (H5FA_dblock_t *)H5AC_protect(hdr->f, dxpl_id, H5AC_FARRAY_DBLOCK, dblk_addr, &udata, flags)))
+ if(NULL == (dblock = (H5FA_dblock_t *)H5AC_protect(hdr->f, dxpl_id, H5AC_FARRAY_DBLOCK, dblk_addr, &udata, flags)))
H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", (unsigned long long)dblk_addr)
+ /* Create top proxy, if it doesn't exist */
+ if(hdr->top_proxy && NULL == dblock->top_proxy) {
+ /* Add data block as child of 'top' proxy */
+ if(H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dxpl_id, dblock) < 0)
+ H5E_THROW(H5E_CANTSET, "unable to add fixed array entry as child of array proxy")
+ dblock->top_proxy = hdr->top_proxy;
+ } /* end if */
+
+ /* Set return value */
+ ret_value = dblock;
+
CATCH
+ /* Clean up on error */
+ if(!ret_value)
+ /* Release the data block, if it was protected */
+ if(dblock && H5AC_unprotect(hdr->f, dxpl_id, H5AC_FARRAY_DBLOCK, dblock->addr, dblock, H5AC__NO_FLAGS_SET) < 0)
+ H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect fixed array data block, address = %llu", (unsigned long long)dblock->addr)
+
END_FUNC(PKG) /* end H5FA__dblock_protect() */
@@ -408,6 +440,9 @@ H5FA__dblock_dest(H5FA_dblock_t *dblock))
dblock->hdr = NULL;
} /* end if */
+ /* Sanity check */
+ HDassert(NULL == dblock->top_proxy);
+
/* Free the data block itself */
dblock = H5FL_FREE(H5FA_dblock_t, dblock);