From fc2899346417fed3727f28115d30d9fd62d6691d Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 2 Jun 2009 15:14:17 -0500 Subject: [svn-r16997] Description: Change previous "depend/undepend" routine names to be "support/unsupport" and add new "depend/undepend" routines, which make the extensible array a child flush dependency of another piece of metadata in the file. 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.7 (amazon) in debug mode Mac OS X/32 10.5.7 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode --- src/H5EA.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++---- src/H5EAprivate.h | 6 ++-- test/earray.c | 60 ++++++++++++++++++++++++++++---- 3 files changed, 150 insertions(+), 16 deletions(-) diff --git a/src/H5EA.c b/src/H5EA.c index 79b1a6e..ea21b15 100644 --- a/src/H5EA.c +++ b/src/H5EA.c @@ -781,8 +781,94 @@ 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. + * Purpose: Make a child flush dependency between the extensible array's + * header and another piece of metadata in the file. + * + * Return: SUCCEED/FAIL + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * May 27 2009 + * + *------------------------------------------------------------------------- + */ +BEGIN_FUNC(PRIV, ERR, +herr_t, SUCCEED, FAIL, +H5EA_depend(H5AC_info_t *parent_entry, H5EA_t *ea)) + + /* Local variables */ + H5EA_hdr_t *hdr = ea->hdr; /* Header for EA */ + +#ifdef QAK +HDfprintf(stderr, "%s: Called\n", FUNC); +#endif /* QAK */ + + /* + * Check arguments. + */ + HDassert(ea); + HDassert(hdr); + + /* Set the shared array header's file context for this operation */ + hdr->f = ea->f; + + /* Set up flush dependency between child_entry and metadata array 'thing' */ + if(H5EA__create_flush_depend(hdr, parent_entry, (H5AC_info_t *)hdr) < 0) + H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency on file metadata") + +CATCH + +END_FUNC(PRIV) /* end H5EA_depend() */ + + +/*------------------------------------------------------------------------- + * Function: H5EA_undepend + * + * Purpose: Remove a child flush dependency between the extensible array's + * header and another piece of metadata in the file. + * + * Return: SUCCEED/FAIL + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * May 27 2009 + * + *------------------------------------------------------------------------- + */ +BEGIN_FUNC(PRIV, ERR, +herr_t, SUCCEED, FAIL, +H5EA_undepend(H5AC_info_t *parent_entry, H5EA_t *ea)) + + /* Local variables */ + H5EA_hdr_t *hdr = ea->hdr; /* Header for EA */ + +#ifdef QAK +HDfprintf(stderr, "%s: Called\n", FUNC); +#endif /* QAK */ + + /* + * Check arguments. + */ + HDassert(ea); + HDassert(hdr); + + /* Set the shared array header's file context for this operation */ + hdr->f = ea->f; + + /* Remove flush dependency between child_entry and metadata array 'thing' */ + if(H5EA__destroy_flush_depend(hdr, parent_entry, (H5AC_info_t *)hdr) < 0) + H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency on file metadata") + +CATCH + +END_FUNC(PRIV) /* end H5EA_undepend() */ + + +/*------------------------------------------------------------------------- + * Function: H5EA_support + * + * Purpose: Create a child flush dependency on the array metadata that + * contains the element for an array index. * * Return: SUCCEED/FAIL * @@ -794,7 +880,7 @@ END_FUNC(PRIV) /* end H5EA_get() */ */ 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)) +H5EA_support(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 */ @@ -835,11 +921,11 @@ CATCH 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() */ +END_FUNC(PRIV) /* end H5EA_support() */ /*------------------------------------------------------------------------- - * Function: H5EA_undepend + * Function: H5EA_unsupport * * Purpose: Remove a flush dependency on the array metadata that contains * the element for an array index. @@ -854,7 +940,7 @@ END_FUNC(PRIV) /* end H5EA_depend() */ */ 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)) +H5EA_unsupport(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 */ @@ -895,7 +981,7 @@ CATCH 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() */ +END_FUNC(PRIV) /* end H5EA_unsupport() */ /*------------------------------------------------------------------------- diff --git a/src/H5EAprivate.h b/src/H5EAprivate.h index adc0b4f..a132006 100644 --- a/src/H5EAprivate.h +++ b/src/H5EAprivate.h @@ -127,9 +127,11 @@ 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, +H5_DLL herr_t H5EA_depend(H5AC_info_t *parent_entry, H5EA_t *ea); +H5_DLL herr_t H5EA_undepend(H5AC_info_t *parent_entry, H5EA_t *ea); +H5_DLL herr_t H5EA_support(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, +H5_DLL herr_t H5EA_unsupport(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/test/earray.c b/test/earray.c index 1c70851..fe5cb99 100644 --- a/test/earray.c +++ b/test/earray.c @@ -137,6 +137,7 @@ struct earray_test_param_t { /* Flush depend test context */ typedef struct earray_flush_depend_ctx_t { + hbool_t base_obj; /* Flag to indicate that base object has been flushed */ hbool_t idx0_obj; /* Flag to indicate that index 0's object has been flushed */ hbool_t idx0_elem; /* Flag to indicate that index 0's element has been flushed */ hbool_t idx1_obj; /* Flag to indicate that index 1's object has been flushed */ @@ -650,6 +651,10 @@ earray_cache_test_flush(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, hbool_t destroy, HDassert(test); if(test->cache_info.is_dirty) { + /* Check for out of order flush */ + if(test->fd_info->base_obj) + TEST_ERROR + /* Check which index this entry corresponds to */ if((uint64_t)0 == test->idx) { /* Check for out of order flush */ @@ -675,6 +680,10 @@ earray_cache_test_flush(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, hbool_t destroy, /* Set flag for object flush */ test->fd_info->idx10000_obj = TRUE; } /* end if */ + else if((uint64_t)-1 == test->idx) { + /* Set flag for object flush */ + test->fd_info->base_obj = TRUE; + } /* end if */ /* Mark the entry as clean */ test->cache_info.is_dirty = FALSE; @@ -1305,7 +1314,8 @@ error: /*------------------------------------------------------------------------- * Function: test_flush_depend_cb * - * Purpose: Callback for flush dependency 'depend'/'undepend' routines + * Purpose: Callback for flush dependency 'depend'/'undepend' and + * 'support'/'unsupport' routines * * Return: Success: 0 * Failure: 1 @@ -1321,6 +1331,10 @@ test_flush_depend_cb(const void *_elmt, size_t nelmts, void *udata) earray_flush_depend_ctx_t *ctx = (earray_flush_depend_ctx_t *)udata; const uint64_t *elmt = (const uint64_t *)_elmt; /* Convenience pointer to native elements */ + /* Check for out of order flush */ + if(ctx->base_obj) + return(FAIL); + /* Look for magic values */ while(nelmts > 0) { /* Check for elements of interest */ @@ -1380,6 +1394,8 @@ test_flush_depend(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t UNUSED haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */ H5EA__ctx_cb_t cb; /* Extensible array context action info */ earray_flush_depend_ctx_t fd_info; /* Context information for flush depend test */ + haddr_t base_addr; /* Base test entry address */ + earray_test_t *base_entry; /* Pointer to base test entry */ haddr_t addr1; /* Test entry #1 address */ earray_test_t *entry1; /* Pointer to test entry #1 */ haddr_t addr2; /* Test entry #2 address */ @@ -1409,6 +1425,22 @@ test_flush_depend(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t UNUSED if(verify_cparam(ea, cparam) < 0) TEST_ERROR + /* Create base entry to insert */ + if(NULL == (base_entry = (earray_test_t *)HDmalloc(sizeof(earray_test_t)))) + TEST_ERROR + HDmemset(base_entry, 0, sizeof(earray_test_t)); + base_entry->idx = (uint64_t)-1; + base_entry->fd_info = &fd_info; + + /* Insert test entry into cache */ + base_addr = HADDR_MAX; + if(H5AC_set(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, base_addr, base_entry, H5AC__PIN_ENTRY_FLAG) < 0) + TEST_ERROR + + /* Set the base entry as a flush dependency for the array */ + if(H5EA_depend((H5AC_info_t *)base_entry, ea) < 0) + TEST_ERROR + /* Create entry #1 to insert */ if(NULL == (entry1 = (earray_test_t *)HDmalloc(sizeof(earray_test_t)))) TEST_ERROR @@ -1421,7 +1453,7 @@ test_flush_depend(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t UNUSED TEST_ERROR /* Set the test entry as a flush dependency for 0th index in the array */ - if(H5EA_depend(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)0, (H5AC_info_t *)entry1) < 0) + if(H5EA_support(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)0, (H5AC_info_t *)entry1) < 0) TEST_ERROR /* Set element of array */ @@ -1443,7 +1475,7 @@ test_flush_depend(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t UNUSED TEST_ERROR /* Set the test entry as a flush dependency for 1st index in the array */ - if(H5EA_depend(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)1, (H5AC_info_t *)entry2) < 0) + if(H5EA_support(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)1, (H5AC_info_t *)entry2) < 0) TEST_ERROR /* Set element of array */ @@ -1465,7 +1497,7 @@ test_flush_depend(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t UNUSED TEST_ERROR /* Set the test entry as a flush dependency for 10,000th index in the array */ - if(H5EA_depend(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)10000, (H5AC_info_t *)entry3) < 0) + if(H5EA_support(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)10000, (H5AC_info_t *)entry3) < 0) TEST_ERROR /* Set element of array */ @@ -1480,6 +1512,8 @@ test_flush_depend(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t UNUSED TEST_ERROR /* Check that all callback flags have been set */ + if(!fd_info.base_obj) + TEST_ERROR if(!fd_info.idx0_obj) TEST_ERROR if(!fd_info.idx0_elem) @@ -1494,8 +1528,20 @@ test_flush_depend(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t UNUSED TEST_ERROR + /* Remove the base entry as a flush dependency for the array */ + if(H5EA_undepend((H5AC_info_t *)base_entry, ea) < 0) + TEST_ERROR + + /* Protect the base entry */ + if(NULL == (base_entry = (earray_test_t *)H5AC_protect(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, base_addr, NULL, NULL, H5AC_WRITE))) + TEST_ERROR + + /* Unprotect & unpin the base entry */ + if(H5AC_unprotect(f, H5P_DATASET_XFER_DEFAULT, H5AC_EARRAY_TEST, base_addr, base_entry, (H5AC__UNPIN_ENTRY_FLAG | H5AC__DELETED_FLAG)) < 0) + TEST_ERROR + /* Remove the test entry as a flush dependency for 0th index in the array */ - if(H5EA_undepend(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)0, (H5AC_info_t *)entry1) < 0) + if(H5EA_unsupport(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)0, (H5AC_info_t *)entry1) < 0) TEST_ERROR /* Protect the test entry */ @@ -1507,7 +1553,7 @@ test_flush_depend(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t UNUSED TEST_ERROR /* Remove the test entry as a flush dependency for 1st index in the array */ - if(H5EA_undepend(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)1, (H5AC_info_t *)entry2) < 0) + if(H5EA_unsupport(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)1, (H5AC_info_t *)entry2) < 0) TEST_ERROR /* Protect the test entry */ @@ -1519,7 +1565,7 @@ test_flush_depend(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t UNUSED TEST_ERROR /* Remove the test entry as a flush dependency for 10,000th index in the array */ - if(H5EA_undepend(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)10000, (H5AC_info_t *)entry3) < 0) + if(H5EA_unsupport(ea, H5P_DATASET_XFER_DEFAULT, (hsize_t)10000, (H5AC_info_t *)entry3) < 0) TEST_ERROR /* Protect the test entry */ -- cgit v0.12