summaryrefslogtreecommitdiffstats
path: root/src/H5HFcache.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-05-05 13:39:56 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-05-05 13:39:56 (GMT)
commit74c8b68acab0fc2408740e7a38a2ab2bcdf58f57 (patch)
treed0d2da7ac1ea824f0ef78e757ace31a85bc4b6aa /src/H5HFcache.c
parent4c0421ba76a7615cc02f43b8f3778f5d6a1f4d68 (diff)
downloadhdf5-74c8b68acab0fc2408740e7a38a2ab2bcdf58f57.zip
hdf5-74c8b68acab0fc2408740e7a38a2ab2bcdf58f57.tar.gz
hdf5-74c8b68acab0fc2408740e7a38a2ab2bcdf58f57.tar.bz2
[svn-r18702] Description:
Bring r18672 from metadata journaling "merging" branch to trunk: Mostly changes to move to only using one 'user data' parameter for calls to H5AC_protect(), along with some minor reformatting code cleanups. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.6.3 (amazon) in debug mode Mac OS X/32 10.6.3 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'src/H5HFcache.c')
-rw-r--r--src/H5HFcache.c84
1 files changed, 44 insertions, 40 deletions
diff --git a/src/H5HFcache.c b/src/H5HFcache.c
index 2da0375..f02b28c 100644
--- a/src/H5HFcache.c
+++ b/src/H5HFcache.c
@@ -35,6 +35,7 @@
/* Headers */
/***********/
#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
#include "H5Eprivate.h" /* Error handling */
#include "H5HFpkg.h" /* Fractal heaps */
#include "H5MFprivate.h" /* File memory management */
@@ -78,17 +79,17 @@ static herr_t H5HF_dtable_encode(H5F_t *f, uint8_t **pp, const H5HF_dtable_t *dt
static herr_t H5HF_dtable_decode(H5F_t *f, const uint8_t **pp, H5HF_dtable_t *dtable);
/* Metadata cache (H5AC) callbacks */
-static H5HF_hdr_t *H5HF_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata, void *udata2);
+static H5HF_hdr_t *H5HF_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata);
static herr_t H5HF_cache_hdr_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HF_hdr_t *hdr, unsigned UNUSED * flags_ptr);
static herr_t H5HF_cache_hdr_dest(H5F_t *f, H5HF_hdr_t *hdr);
static herr_t H5HF_cache_hdr_clear(H5F_t *f, H5HF_hdr_t *hdr, hbool_t destroy);
static herr_t H5HF_cache_hdr_size(const H5F_t *f, const H5HF_hdr_t *hdr, size_t *size_ptr);
-static H5HF_indirect_t *H5HF_cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata, void *udata2);
+static H5HF_indirect_t *H5HF_cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata);
static herr_t H5HF_cache_iblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HF_indirect_t *iblock, unsigned UNUSED * flags_ptr);
static herr_t H5HF_cache_iblock_dest(H5F_t *f, H5HF_indirect_t *iblock);
static herr_t H5HF_cache_iblock_clear(H5F_t *f, H5HF_indirect_t *iblock, hbool_t destroy);
static herr_t H5HF_cache_iblock_size(const H5F_t *f, const H5HF_indirect_t *iblock, size_t *size_ptr);
-static H5HF_direct_t *H5HF_cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata, void *udata2);
+static H5HF_direct_t *H5HF_cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata);
static herr_t H5HF_cache_dblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HF_direct_t *dblock, unsigned UNUSED * flags_ptr);
static herr_t H5HF_cache_dblock_dest(H5F_t *f, H5HF_direct_t *dblock);
static herr_t H5HF_cache_dblock_clear(H5F_t *f, H5HF_direct_t *dblock, hbool_t destroy);
@@ -262,9 +263,10 @@ H5HF_dtable_encode(H5F_t *f, uint8_t **pp, const H5HF_dtable_t *dtable)
*-------------------------------------------------------------------------
*/
static H5HF_hdr_t *
-H5HF_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1, void UNUSED *udata2)
+H5HF_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
{
H5HF_hdr_t *hdr = NULL; /* Fractal heap info */
+ H5HF_hdr_cache_ud_t *udata = (H5HF_hdr_cache_ud_t *)_udata;
size_t size; /* Header size */
H5WB_t *wb = NULL; /* Wrapped buffer for header data */
uint8_t hdr_buf[H5HF_HDR_BUF_SIZE]; /* Buffer for header */
@@ -280,9 +282,10 @@ H5HF_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *ud
/* Check arguments */
HDassert(f);
HDassert(H5F_addr_defined(addr));
+ HDassert(udata);
/* Allocate space for the fractal heap data structure */
- if(NULL == (hdr = H5HF_hdr_alloc(f)))
+ if(NULL == (hdr = H5HF_hdr_alloc(udata->f)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Set the heap header's address */
@@ -328,22 +331,22 @@ H5HF_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *ud
/* "Huge" object information */
UINT32DECODE(p, hdr->max_man_size); /* Max. size of "managed" objects */
- H5F_DECODE_LENGTH(f, p, hdr->huge_next_id); /* Next ID to use for "huge" object */
- H5F_addr_decode(f, &p, &hdr->huge_bt2_addr); /* Address of "huge" object tracker B-tree */
+ H5F_DECODE_LENGTH(udata->f, p, hdr->huge_next_id); /* Next ID to use for "huge" object */
+ H5F_addr_decode(udata->f, &p, &hdr->huge_bt2_addr); /* Address of "huge" object tracker B-tree */
/* "Managed" object free space information */
- H5F_DECODE_LENGTH(f, p, hdr->total_man_free); /* Internal free space in managed direct blocks */
- H5F_addr_decode(f, &p, &hdr->fs_addr); /* Address of free section header */
+ H5F_DECODE_LENGTH(udata->f, p, hdr->total_man_free); /* Internal free space in managed direct blocks */
+ H5F_addr_decode(udata->f, &p, &hdr->fs_addr); /* Address of free section header */
/* Heap statistics */
- H5F_DECODE_LENGTH(f, p, hdr->man_size);
- H5F_DECODE_LENGTH(f, p, hdr->man_alloc_size);
- H5F_DECODE_LENGTH(f, p, hdr->man_iter_off);
- H5F_DECODE_LENGTH(f, p, hdr->man_nobjs);
- H5F_DECODE_LENGTH(f, p, hdr->huge_size);
- H5F_DECODE_LENGTH(f, p, hdr->huge_nobjs);
- H5F_DECODE_LENGTH(f, p, hdr->tiny_size);
- H5F_DECODE_LENGTH(f, p, hdr->tiny_nobjs);
+ H5F_DECODE_LENGTH(udata->f, p, hdr->man_size);
+ H5F_DECODE_LENGTH(udata->f, p, hdr->man_alloc_size);
+ H5F_DECODE_LENGTH(udata->f, p, hdr->man_iter_off);
+ H5F_DECODE_LENGTH(udata->f, p, hdr->man_nobjs);
+ H5F_DECODE_LENGTH(udata->f, p, hdr->huge_size);
+ H5F_DECODE_LENGTH(udata->f, p, hdr->huge_nobjs);
+ H5F_DECODE_LENGTH(udata->f, p, hdr->tiny_size);
+ H5F_DECODE_LENGTH(udata->f, p, hdr->tiny_nobjs);
/* Managed objects' doubling-table info */
if(H5HF_dtable_decode(hdr->f, &p, &(hdr->man_dtable)) < 0)
@@ -383,13 +386,13 @@ H5HF_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *ud
p = buf + filter_info_off;
/* Decode the size of a filtered root direct block */
- H5F_DECODE_LENGTH(f, p, hdr->pline_root_direct_size);
+ H5F_DECODE_LENGTH(udata->f, p, hdr->pline_root_direct_size);
/* Decode the filter mask for a filtered root direct block */
UINT32DECODE(p, hdr->pline_root_direct_filter_mask);
/* Decode I/O filter information */
- if(NULL == (pline = (H5O_pline_t *)H5O_msg_decode(hdr->f, dxpl_id, NULL, H5O_PLINE_ID, p)))
+ if(NULL == (pline = (H5O_pline_t *)H5O_msg_decode(hdr->f, udata->dxpl_id, NULL, H5O_PLINE_ID, p)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, NULL, "can't decode I/O pipeline filters")
p += hdr->filter_len;
@@ -702,11 +705,10 @@ H5HF_cache_hdr_size(const H5F_t UNUSED *f, const H5HF_hdr_t *hdr, size_t *size_p
*-------------------------------------------------------------------------
*/
static H5HF_indirect_t *
-H5HF_cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrows, void *_par_info)
+H5HF_cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
{
H5HF_hdr_t *hdr; /* Shared fractal heap information */
- const unsigned *nrows = (const unsigned *)_nrows; /* # of rows in indirect block */
- H5HF_parent_t *par_info = (H5HF_parent_t *)_par_info; /* Shared parent information */
+ H5HF_iblock_cache_ud_t *udata = (H5HF_iblock_cache_ud_t *)_udata; /* user data for callback */
H5HF_indirect_t *iblock = NULL; /* Indirect block info */
H5WB_t *wb = NULL; /* Wrapped buffer for indirect block data */
uint8_t iblock_buf[H5HF_IBLOCK_BUF_SIZE]; /* Buffer for indirect block */
@@ -723,17 +725,17 @@ H5HF_cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrows
/* Check arguments */
HDassert(f);
HDassert(H5F_addr_defined(addr));
- HDassert(par_info);
+ HDassert(udata);
/* Allocate space for the fractal heap indirect block */
if(NULL == (iblock = H5FL_CALLOC(H5HF_indirect_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Get the pointer to the shared heap header */
- hdr = par_info->hdr;
+ hdr = udata->par_info->hdr;
/* Set the shared heap header's file context for this operation */
- hdr->f = f;
+ hdr->f = udata->f;
/* Share common heap information */
iblock->hdr = hdr;
@@ -742,7 +744,7 @@ H5HF_cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrows
/* Set block's internal information */
iblock->rc = 0;
- iblock->nrows = *nrows;
+ iblock->nrows = *udata->nrows;
iblock->addr = addr;
iblock->nchildren = 0;
@@ -774,13 +776,13 @@ H5HF_cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrows
HGOTO_ERROR(H5E_HEAP, H5E_VERSION, NULL, "wrong fractal heap direct block version")
/* Address of heap that owns this block */
- H5F_addr_decode(f, &p, &heap_addr);
+ H5F_addr_decode(udata->f, &p, &heap_addr);
if(H5F_addr_ne(heap_addr, hdr->heap_addr))
HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "incorrect heap header address for direct block")
/* Address of parent block */
- iblock->parent = par_info->iblock;
- iblock->par_entry = par_info->entry;
+ iblock->parent = udata->par_info->iblock;
+ iblock->par_entry = udata->par_info->entry;
if(iblock->parent) {
/* Share parent block */
if(H5HF_iblock_incr(iblock->parent) < 0)
@@ -815,7 +817,7 @@ H5HF_cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrows
iblock->filt_ents = NULL;
for(u = 0; u < (iblock->nrows * hdr->man_dtable.cparam.width); u++) {
/* Decode child block address */
- H5F_addr_decode(f, &p, &(iblock->ents[u].addr));
+ H5F_addr_decode(udata->f, &p, &(iblock->ents[u].addr));
/* Check for heap with I/O filters */
if(hdr->filter_len > 0) {
@@ -825,7 +827,7 @@ H5HF_cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrows
/* Decode extra information for direct blocks */
if(u < (hdr->man_dtable.max_direct_rows * hdr->man_dtable.cparam.width)) {
/* Size of filtered direct block */
- H5F_DECODE_LENGTH(f, p, iblock->filt_ents[u].size);
+ H5F_DECODE_LENGTH(udata->f, p, iblock->filt_ents[u].size);
/* Sanity check */
/* (either both the address & size are defined or both are
@@ -1213,11 +1215,11 @@ H5HF_cache_iblock_size(const H5F_t UNUSED *f, const H5HF_indirect_t *iblock, siz
*-------------------------------------------------------------------------
*/
static H5HF_direct_t *
-H5HF_cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_size, void *_par_info)
+H5HF_cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata)
{
- const size_t *size = (const size_t *)_size; /* Size of block */
+ H5HF_dblock_cache_ud_t *udata = (H5HF_dblock_cache_ud_t *)_udata; /* pointer to user data */
H5HF_hdr_t *hdr; /* Shared fractal heap information */
- H5HF_parent_t *par_info = (H5HF_parent_t *)_par_info; /* Pointer to parent information */
+ H5HF_parent_t *par_info; /* Pointer to parent information */
H5HF_direct_t *dblock = NULL; /* Direct block info */
const uint8_t *p; /* Pointer into raw data buffer */
haddr_t heap_addr; /* Address of heap header in the file */
@@ -1228,7 +1230,9 @@ H5HF_cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_size,
/* Check arguments */
HDassert(f);
HDassert(H5F_addr_defined(addr));
- HDassert(par_info);
+ HDassert(udata != NULL);
+ HDassert(udata->f != NULL);
+ HDassert(udata->dblock_size > 0);
/* Allocate space for the fractal heap direct block */
if(NULL == (dblock = H5FL_MALLOC(H5HF_direct_t)))
@@ -1236,10 +1240,11 @@ H5HF_cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_size,
HDmemset(&dblock->cache_info, 0, sizeof(H5AC_info_t));
/* Get the pointer to the shared heap header */
+ par_info = (H5HF_parent_t *)(&(udata->par_info));
hdr = par_info->hdr;
/* Set the shared heap header's file context for this operation */
- hdr->f = f;
+ hdr->f = udata->f;
/* Share common heap information */
dblock->hdr = hdr;
@@ -1247,7 +1252,7 @@ H5HF_cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_size,
HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared heap header")
/* Set block's internal information */
- dblock->size = *size;
+ dblock->size = udata->dblock_size;
dblock->file_size = 0;
/* Allocate block buffer */
@@ -1270,7 +1275,6 @@ H5HF_cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_size,
/* Set up parameters to read filtered direct block */
read_size = hdr->pline_root_direct_size;
- filter_mask = hdr->pline_root_direct_filter_mask;
} /* end if */
else {
/* Sanity check */
@@ -1278,7 +1282,6 @@ H5HF_cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_size,
/* Set up parameters to read filtered direct block */
read_size = par_info->iblock->filt_ents[par_info->entry].size;
- filter_mask = par_info->iblock->filt_ents[par_info->entry].filter_mask;
} /* end else */
/* Allocate buffer to perform I/O filtering on */
@@ -1291,6 +1294,7 @@ H5HF_cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_size,
/* Push direct block data through I/O filter pipeline */
nbytes = read_size;
+ filter_mask = udata->filter_mask;
if(H5Z_pipeline(&(hdr->pline), H5Z_FLAG_REVERSE, &filter_mask, H5Z_ENABLE_EDC, filter_cb, &nbytes, &read_size, &read_buf) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTFILTER, NULL, "output pipeline failed")
@@ -1322,7 +1326,7 @@ H5HF_cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_size,
HGOTO_ERROR(H5E_HEAP, H5E_VERSION, NULL, "wrong fractal heap direct block version")
/* Address of heap that owns this block (just for file integrity checks) */
- H5F_addr_decode(f, &p, &heap_addr);
+ H5F_addr_decode(udata->f, &p, &heap_addr);
if(H5F_addr_ne(heap_addr, hdr->heap_addr))
HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "incorrect heap header address for direct block")