diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2009-05-26 22:42:12 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2009-05-26 22:42:12 (GMT) |
commit | f824891a846ccd95bf059b986b3e7f9b12eab080 (patch) | |
tree | 5a9288740b565438a9b9a3d25dcae04319ff6cac /src | |
parent | f4f4e9862410bccd9d87aa9388a7ff42d70582df (diff) | |
download | hdf5-f824891a846ccd95bf059b986b3e7f9b12eab080.zip hdf5-f824891a846ccd95bf059b986b3e7f9b12eab080.tar.gz hdf5-f824891a846ccd95bf059b986b3e7f9b12eab080.tar.bz2 |
[svn-r16982] Description:
Add library private routines to allow metadata cache entries to be set as
flush dependency children on extensible array entries. This will allow chunk
proxies to be set as child flush dependencies for the extensible array, adding
another necessary layer to the flush dependency chain for SWMR access.
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/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) 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-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.5.6 (amazon) in debug mode
Mac OS X/32 10.5.6 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Cprivate.h | 6 | ||||
-rw-r--r-- | src/H5EA.c | 124 | ||||
-rw-r--r-- | src/H5EApkg.h | 7 | ||||
-rw-r--r-- | src/H5EAprivate.h | 5 | ||||
-rw-r--r-- | src/H5EAtest.c | 17 |
5 files changed, 151 insertions, 8 deletions
diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h index e5a2dba..5524f2b 100644 --- a/src/H5Cprivate.h +++ b/src/H5Cprivate.h @@ -201,10 +201,12 @@ typedef herr_t (*H5C_log_flush_func_t)(H5C_t * cache_ptr, /* Maximum height of flush dependency relationships between entries. This is * currently tuned to the extensible array (H5EA) data structure, which only - * requires 4 levels of dependency (i.e. heights 0-4). + * requires 6 levels of dependency (i.e. heights 0-6) (actually, the extensible + * array needs 4 levels, plus another 2 levels are needed: one for the layer + * under the extensible array and one for the layer above it). */ -#define H5C__NUM_FLUSH_DEP_HEIGHTS 4 +#define H5C__NUM_FLUSH_DEP_HEIGHTS 6 @@ -461,7 +461,7 @@ HDfprintf(stderr, "%s: dblk_idx = %u, iblock->ndblk_addrs = %Zu\n", FUNC, dblk_i *thing_unprot_func = (H5EA__unprotect_func_t)H5EA__dblock_unprotect; } /* end if */ else { - unsigned sblk_off; /* Offset of super block in index block array of super blocks */ + size_t sblk_off; /* Offset of super block in index block array of super blocks */ /* Calculate offset of super block in index block's array */ sblk_off = sblk_idx - iblock->nsblks; @@ -779,6 +779,126 @@ END_FUNC(PRIV) /* end H5EA_get() */ /*------------------------------------------------------------------------- + * Function: H5EA_depend + * + * Purpose: Create a flush dependency on the array metadata that contains + * the element for an array index. + * + * Return: SUCCEED/FAIL + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * May 21 2009 + * + *------------------------------------------------------------------------- + */ +BEGIN_FUNC(PRIV, ERR, +herr_t, SUCCEED, FAIL, +H5EA_depend(const H5EA_t *ea, hid_t dxpl_id, hsize_t idx, H5AC_info_t *child_entry)) + + /* Local variables */ + H5EA_hdr_t *hdr = ea->hdr; /* Header for EA */ + void *thing = NULL; /* Pointer to the array metadata containing the array index we are interested in */ + uint8_t *thing_elmt_buf; /* Pointer to the element buffer for the array metadata */ + hsize_t thing_elmt_idx; /* Index of the element in the element buffer for the array metadata */ + H5EA__unprotect_func_t thing_unprot_func; /* Function pointer for unprotecting the array metadata */ + +#ifdef QAK +HDfprintf(stderr, "%s: Called\n", FUNC); +HDfprintf(stderr, "%s: Index %Hu\n", FUNC, idx); +#endif /* QAK */ + + /* + * Check arguments. + */ + HDassert(ea); + HDassert(hdr); + + /* Set the shared array header's file context for this operation */ + hdr->f = ea->f; + + /* Look up the array metadata containing the element we want to set */ + if(H5EA__lookup_elmt(ea, dxpl_id, idx, H5AC_WRITE, &thing, &thing_elmt_buf, &thing_elmt_idx, &thing_unprot_func) < 0) + H5E_THROW(H5E_CANTPROTECT, "unable to protect array metadata") + + /* Sanity check */ + HDassert(thing); + HDassert(thing_elmt_buf); + HDassert(thing_unprot_func); + + /* Set up flush dependency between child_entry and metadata array 'thing' */ + if(H5EA__create_flush_depend(hdr, (H5AC_info_t *)thing, child_entry) < 0) + H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency on array metadata") + +CATCH + /* Release resources */ + if(thing && (thing_unprot_func)(thing, dxpl_id, H5AC__NO_FLAGS_SET) < 0) + H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array metadata") + +END_FUNC(PRIV) /* end H5EA_depend() */ + + +/*------------------------------------------------------------------------- + * Function: H5EA_undepend + * + * Purpose: Remove a flush dependency on the array metadata that contains + * the element for an array index. + * + * Return: SUCCEED/FAIL + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * May 21 2009 + * + *------------------------------------------------------------------------- + */ +BEGIN_FUNC(PRIV, ERR, +herr_t, SUCCEED, FAIL, +H5EA_undepend(const H5EA_t *ea, hid_t dxpl_id, hsize_t idx, H5AC_info_t *child_entry)) + + /* Local variables */ + H5EA_hdr_t *hdr = ea->hdr; /* Header for EA */ + void *thing = NULL; /* Pointer to the array metadata containing the array index we are interested in */ + uint8_t *thing_elmt_buf; /* Pointer to the element buffer for the array metadata */ + hsize_t thing_elmt_idx; /* Index of the element in the element buffer for the array metadata */ + H5EA__unprotect_func_t thing_unprot_func; /* Function pointer for unprotecting the array metadata */ + +#ifdef QAK +HDfprintf(stderr, "%s: Called\n", FUNC); +HDfprintf(stderr, "%s: Index %Hu\n", FUNC, idx); +#endif /* QAK */ + + /* + * Check arguments. + */ + HDassert(ea); + HDassert(hdr); + + /* Set the shared array header's file context for this operation */ + hdr->f = ea->f; + + /* Look up the array metadata containing the element we want to set */ + if(H5EA__lookup_elmt(ea, dxpl_id, idx, H5AC_READ, &thing, &thing_elmt_buf, &thing_elmt_idx, &thing_unprot_func) < 0) + H5E_THROW(H5E_CANTPROTECT, "unable to protect array metadata") + + /* Sanity check */ + HDassert(thing); + HDassert(thing_elmt_buf); + HDassert(thing_unprot_func); + + /* Remove flush dependency between child_entry and metadata array 'thing' */ + if(H5EA__destroy_flush_depend(hdr, (H5AC_info_t *)thing, child_entry) < 0) + H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency on array metadata") + +CATCH + /* Release resources */ + if(thing && (thing_unprot_func)(thing, dxpl_id, H5AC__NO_FLAGS_SET) < 0) + H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array metadata") + +END_FUNC(PRIV) /* end H5EA_undepend() */ + + +/*------------------------------------------------------------------------- * Function: H5EA_close * * Purpose: Close an extensible array @@ -849,7 +969,7 @@ HDfprintf(stderr, "%s: Called\n", FUNC); } /* end if */ /* Release the extensible array wrapper */ - ea = H5FL_FREE(H5EA_t, ea); + ea = (H5EA_t *)H5FL_FREE(H5EA_t, ea); CATCH diff --git a/src/H5EApkg.h b/src/H5EApkg.h index f64f520..bed47e2 100644 --- a/src/H5EApkg.h +++ b/src/H5EApkg.h @@ -32,7 +32,6 @@ #include "H5EAprivate.h" /* Other private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata cache */ #include "H5FLprivate.h" /* Free Lists */ /************************************************/ @@ -624,6 +623,12 @@ typedef struct H5EA_sblock_load_ud_t { unsigned sblk_idx; /* Index of super block */ } H5EA_sblock_load_ud_t; +#ifdef H5EA_TESTING +typedef struct H5EA__ctx_cb_t { + herr_t (*encode)(const void *elmt, size_t nelmts, void *udata); /* Perform action during encode step */ + void *udata; /* User data for encode action */ +} H5EA__ctx_cb_t; +#endif /* H5EA_TESTING */ /*****************************/ /* Package Private Variables */ diff --git a/src/H5EAprivate.h b/src/H5EAprivate.h index f525a01..adc0b4f 100644 --- a/src/H5EAprivate.h +++ b/src/H5EAprivate.h @@ -34,6 +34,7 @@ #endif /* NOT_YET */ /* Private headers needed by this file */ +#include "H5ACprivate.h" /* Metadata cache */ #include "H5Fprivate.h" /* File access */ @@ -126,6 +127,10 @@ H5_DLL herr_t H5EA_get_nelmts(const H5EA_t *ea, hsize_t *nelmts); H5_DLL herr_t H5EA_get_addr(const H5EA_t *ea, haddr_t *addr); H5_DLL herr_t H5EA_set(const H5EA_t *ea, hid_t dxpl_id, hsize_t idx, const void *elmt); H5_DLL herr_t H5EA_get(const H5EA_t *ea, hid_t dxpl_id, hsize_t idx, void *elmt); +H5_DLL herr_t H5EA_depend(const H5EA_t *ea, hid_t dxpl_id, hsize_t idx, + H5AC_info_t *child_entry); +H5_DLL herr_t H5EA_undepend(const H5EA_t *ea, hid_t dxpl_id, hsize_t idx, + H5AC_info_t *child_entry); H5_DLL herr_t H5EA_close(H5EA_t *ea, hid_t dxpl_id); H5_DLL herr_t H5EA_delete(H5F_t *f, hid_t dxpl_id, haddr_t ea_addr); diff --git a/src/H5EAtest.c b/src/H5EAtest.c index 93cd518..12d14ae 100644 --- a/src/H5EAtest.c +++ b/src/H5EAtest.c @@ -57,6 +57,7 @@ /* Callback context */ typedef struct H5EA__test_ctx_t { uint32_t bogus; /* Placeholder field to verify that context is working */ + H5EA__ctx_cb_t *cb; /* Pointer to context's callback action */ } H5EA__test_ctx_t; /********************/ @@ -126,10 +127,11 @@ H5FL_DEFINE_STATIC(H5EA__test_ctx_t); */ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, -H5EA__test_crt_context(void UNUSED *udata)) +H5EA__test_crt_context(void *_udata)) /* Local variables */ H5EA__test_ctx_t *ctx; /* Context for callbacks */ + H5EA__ctx_cb_t *udata = (H5EA__ctx_cb_t *)_udata; /* User data for context */ /* Sanity checks */ @@ -139,6 +141,7 @@ H5EA__test_crt_context(void UNUSED *udata)) /* Initialize the context */ ctx->bogus = H5EA__TEST_BOGUS_VAL; + ctx->cb = udata; /* Set return value */ ret_value = ctx; @@ -219,8 +222,8 @@ END_FUNC(STATIC) /* end H5EA__test_fill() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, -herr_t, SUCCEED, -, +BEGIN_FUNC(STATIC, ERR, +herr_t, SUCCEED, FAIL, H5EA__test_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx)) /* Local variables */ @@ -233,6 +236,12 @@ H5EA__test_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx)) HDassert(nelmts); HDassert(H5EA__TEST_BOGUS_VAL == ctx->bogus); + /* Check for callback action */ + if(ctx->cb) { + if((*ctx->cb->encode)(elmt, nelmts, ctx->cb->udata) < 0) + H5E_THROW(H5E_BADVALUE, "extensible array testing callback action failed") + } /* end if */ + /* Encode native elements into raw elements */ while(nelmts) { /* Encode element */ @@ -246,6 +255,8 @@ H5EA__test_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx)) nelmts--; } /* end while */ +CATCH + END_FUNC(STATIC) /* end H5EA__test_encode() */ |