diff options
Diffstat (limited to 'src/H5EAcache.c')
-rw-r--r-- | src/H5EAcache.c | 225 |
1 files changed, 209 insertions, 16 deletions
diff --git a/src/H5EAcache.c b/src/H5EAcache.c index 565127f..8947960 100644 --- a/src/H5EAcache.c +++ b/src/H5EAcache.c @@ -88,22 +88,26 @@ static herr_t H5EA__cache_hdr_dest(H5F_t *f, H5EA_hdr_t *hdr); static H5EA_iblock_t *H5EA__cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata, void *udata2); static herr_t H5EA__cache_iblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5EA_iblock_t *iblock, unsigned * flags_ptr); static herr_t H5EA__cache_iblock_clear(H5F_t *f, H5EA_iblock_t *iblock, hbool_t destroy); +static herr_t H5EA__cache_iblock_notify(H5AC_notify_action_t action, H5EA_iblock_t *iblock); static herr_t H5EA__cache_iblock_size(const H5F_t *f, const H5EA_iblock_t *iblock, size_t *size_ptr); static herr_t H5EA__cache_iblock_dest(H5F_t *f, H5EA_iblock_t *iblock); static H5EA_sblock_t *H5EA__cache_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata, void *udata2); static herr_t H5EA__cache_sblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5EA_sblock_t *sblock, unsigned * flags_ptr); static herr_t H5EA__cache_sblock_clear(H5F_t *f, H5EA_sblock_t *sblock, hbool_t destroy); static herr_t H5EA__cache_sblock_size(const H5F_t *f, const H5EA_sblock_t *sblock, size_t *size_ptr); +static herr_t H5EA__cache_sblock_notify(H5AC_notify_action_t action, H5EA_sblock_t *sblock); static herr_t H5EA__cache_sblock_dest(H5F_t *f, H5EA_sblock_t *sblock); static H5EA_dblock_t *H5EA__cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata, void *udata2); static herr_t H5EA__cache_dblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5EA_dblock_t *dblock, unsigned * flags_ptr); static herr_t H5EA__cache_dblock_clear(H5F_t *f, H5EA_dblock_t *dblock, hbool_t destroy); static herr_t H5EA__cache_dblock_size(const H5F_t *f, const H5EA_dblock_t *dblock, size_t *size_ptr); +static herr_t H5EA__cache_dblock_notify(H5AC_notify_action_t action, H5EA_dblock_t *dblock); static herr_t H5EA__cache_dblock_dest(H5F_t *f, H5EA_dblock_t *dblock); static H5EA_dblk_page_t *H5EA__cache_dblk_page_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *udata, void *udata2); static herr_t H5EA__cache_dblk_page_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5EA_dblk_page_t *dblk_page, unsigned * flags_ptr); static herr_t H5EA__cache_dblk_page_clear(H5F_t *f, H5EA_dblk_page_t *dblk_page, hbool_t destroy); static herr_t H5EA__cache_dblk_page_size(const H5F_t *f, const H5EA_dblk_page_t *dblk_page, size_t *size_ptr); +static herr_t H5EA__cache_dblk_page_notify(H5AC_notify_action_t action, H5EA_dblk_page_t *dblk_page); static herr_t H5EA__cache_dblk_page_dest(H5F_t *f, H5EA_dblk_page_t *dblk_page); @@ -129,7 +133,7 @@ const H5AC_class_t H5AC_EARRAY_IBLOCK[1] = {{ (H5AC_flush_func_t)H5EA__cache_iblock_flush, (H5AC_dest_func_t)H5EA__cache_iblock_dest, (H5AC_clear_func_t)H5EA__cache_iblock_clear, - (H5AC_notify_func_t)NULL, + (H5AC_notify_func_t)H5EA__cache_iblock_notify, (H5AC_size_func_t)H5EA__cache_iblock_size, }}; @@ -140,7 +144,7 @@ const H5AC_class_t H5AC_EARRAY_SBLOCK[1] = {{ (H5AC_flush_func_t)H5EA__cache_sblock_flush, (H5AC_dest_func_t)H5EA__cache_sblock_dest, (H5AC_clear_func_t)H5EA__cache_sblock_clear, - (H5AC_notify_func_t)NULL, + (H5AC_notify_func_t)H5EA__cache_sblock_notify, (H5AC_size_func_t)H5EA__cache_sblock_size, }}; @@ -151,7 +155,7 @@ const H5AC_class_t H5AC_EARRAY_DBLOCK[1] = {{ (H5AC_flush_func_t)H5EA__cache_dblock_flush, (H5AC_dest_func_t)H5EA__cache_dblock_dest, (H5AC_clear_func_t)H5EA__cache_dblock_clear, - (H5AC_notify_func_t)NULL, + (H5AC_notify_func_t)H5EA__cache_dblock_notify, (H5AC_size_func_t)H5EA__cache_dblock_size, }}; @@ -162,7 +166,7 @@ const H5AC_class_t H5AC_EARRAY_DBLK_PAGE[1] = {{ (H5AC_flush_func_t)H5EA__cache_dblk_page_flush, (H5AC_dest_func_t)H5EA__cache_dblk_page_dest, (H5AC_clear_func_t)H5EA__cache_dblk_page_clear, - (H5AC_notify_func_t)NULL, + (H5AC_notify_func_t)H5EA__cache_dblk_page_notify, (H5AC_size_func_t)H5EA__cache_dblk_page_size, }}; @@ -834,6 +838,53 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_clear() */ /*------------------------------------------------------------------------- + * Function: H5EA__cache_iblock_notify + * + * Purpose: Handle cache action notifications + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Mar 31 2009 + * + *------------------------------------------------------------------------- + */ +BEGIN_FUNC(STATIC, ERR, +herr_t, SUCCEED, FAIL, +H5EA__cache_iblock_notify(H5AC_notify_action_t action, H5EA_iblock_t *iblock)) + + /* Sanity check */ + HDassert(iblock); + + /* Determine which action to take */ + switch(action) { + case H5AC_NOTIFY_ACTION_AFTER_INSERT: + /* Create flush dependency on extensible array header */ + if(H5EA__create_flush_depend(iblock->hdr, (H5AC_info_t *)iblock->hdr, (H5AC_info_t *)iblock) < 0) + H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency between index block and header, address = %llu", (unsigned long long)iblock->addr) + break; + + case H5AC_NOTIFY_ACTION_BEFORE_EVICT: + /* Destroy flush dependency on extensible array header */ + if(H5EA__destroy_flush_depend(iblock->hdr, (H5AC_info_t *)iblock->hdr, (H5AC_info_t *)iblock) < 0) + H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between index block and header, address = %llu", (unsigned long long)iblock->addr) + break; + + default: +#ifdef NDEBUG + H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") +#else /* NDEBUG */ + HDassert(0 && "Unknown action?!?"); +#endif /* NDEBUG */ + } /* end switch */ + +CATCH + +END_FUNC(STATIC) /* end H5EA__cache_iblock_notify() */ + + +/*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_size * * Purpose: Compute the size in bytes of a extensible array index block @@ -929,11 +980,11 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_dest() */ BEGIN_FUNC(STATIC, ERR, H5EA_sblock_t *, NULL, NULL, H5EA__cache_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, - const void *_sblk_idx, void *_hdr)) + const void *_udata1, void *_hdr)) /* Local variables */ H5EA_hdr_t *hdr = (H5EA_hdr_t *)_hdr; /* Shared extensible array information */ - const unsigned *sblk_idx = (const unsigned *)_sblk_idx; /* Index of this super block */ + const H5EA_sblock_load_ud_t *ud_load = (const H5EA_sblock_load_ud_t *)_udata1; /* User data for loading super block */ H5EA_sblock_t *sblock = NULL; /* Super block info */ size_t size; /* Super block size */ H5WB_t *wb = NULL; /* Wrapped buffer for super block data */ @@ -948,11 +999,11 @@ H5EA__cache_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, /* Sanity check */ HDassert(f); HDassert(H5F_addr_defined(addr)); - HDassert(sblk_idx && *sblk_idx > 0); + HDassert(ud_load && ud_load->parent && ud_load->sblk_idx > 0); HDassert(hdr); /* Allocate the extensible array super block */ - if(NULL == (sblock = H5EA__sblock_alloc(hdr, *sblk_idx))) + if(NULL == (sblock = H5EA__sblock_alloc(hdr, ud_load->parent, ud_load->sblk_idx))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array super block") /* Set the extensible array super block's address */ @@ -1218,6 +1269,53 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_size() */ /*------------------------------------------------------------------------- + * Function: H5EA__cache_sblock_notify + * + * Purpose: Handle cache action notifications + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Mar 31 2009 + * + *------------------------------------------------------------------------- + */ +BEGIN_FUNC(STATIC, ERR, +herr_t, SUCCEED, FAIL, +H5EA__cache_sblock_notify(H5AC_notify_action_t action, H5EA_sblock_t *sblock)) + + /* Sanity check */ + HDassert(sblock); + + /* Determine which action to take */ + switch(action) { + case H5AC_NOTIFY_ACTION_AFTER_INSERT: + /* Create flush dependency on index block */ + if(H5EA__create_flush_depend(sblock->hdr, (H5AC_info_t *)sblock->parent, (H5AC_info_t *)sblock) < 0) + H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency between super block and index block, address = %llu", (unsigned long long)sblock->addr) + break; + + case H5AC_NOTIFY_ACTION_BEFORE_EVICT: + /* Destroy flush dependency on index block */ + if(H5EA__destroy_flush_depend(sblock->hdr, (H5AC_info_t *)sblock->parent, (H5AC_info_t *)sblock) < 0) + H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between super block and index block, address = %llu", (unsigned long long)sblock->addr) + break; + + default: +#ifdef NDEBUG + H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") +#else /* NDEBUG */ + HDassert(0 && "Unknown action?!?"); +#endif /* NDEBUG */ + } /* end switch */ + +CATCH + +END_FUNC(STATIC) /* end H5EA__cache_sblock_notify() */ + + +/*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_dest * * Purpose: Destroys an extensible array super block in memory. @@ -1281,11 +1379,11 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_dest() */ BEGIN_FUNC(STATIC, ERR, H5EA_dblock_t *, NULL, NULL, H5EA__cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, - const void *_nelmts, void *_hdr)) + const void *_udata1, void *_hdr)) /* Local variables */ H5EA_hdr_t *hdr = (H5EA_hdr_t *)_hdr; /* Shared extensible array information */ - const size_t *nelmts = (const size_t *)_nelmts; /* Number of elements in data block */ + const H5EA_dblock_load_ud_t *ud_load = (const H5EA_dblock_load_ud_t *)_udata1; /* User data for loading data block */ H5EA_dblock_t *dblock = NULL; /* Data block info */ size_t size; /* Data block size */ H5WB_t *wb = NULL; /* Wrapped buffer for data block data */ @@ -1299,11 +1397,11 @@ H5EA__cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, /* Sanity check */ HDassert(f); HDassert(H5F_addr_defined(addr)); - HDassert(nelmts && *nelmts > 0); + HDassert(ud_load && ud_load->parent && ud_load->nelmts > 0); HDassert(hdr); /* Allocate the extensible array data block */ - if(NULL == (dblock = H5EA__dblock_alloc(hdr, *nelmts))) + if(NULL == (dblock = H5EA__dblock_alloc(hdr, ud_load->parent, ud_load->nelmts))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block") /* Set the extensible array data block's information */ @@ -1357,9 +1455,9 @@ H5EA__cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, if(!dblock->npages) { /* Decode elements in data block */ /* Convert from raw elements on disk into native elements in memory */ - if((hdr->cparam.cls->decode)(p, dblock->elmts, *nelmts, hdr->cb_ctx) < 0) + if((hdr->cparam.cls->decode)(p, dblock->elmts, ud_load->nelmts, hdr->cb_ctx) < 0) H5E_THROW(H5E_CANTDECODE, "can't decode extensible array data elements") - p += (*nelmts * hdr->cparam.raw_elmt_size); + p += (ud_load->nelmts * hdr->cparam.raw_elmt_size); } /* end if */ /* Sanity check */ @@ -1536,6 +1634,53 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_clear() */ /*------------------------------------------------------------------------- + * Function: H5EA__cache_dblock_notify + * + * Purpose: Handle cache action notifications + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Mar 31 2009 + * + *------------------------------------------------------------------------- + */ +BEGIN_FUNC(STATIC, ERR, +herr_t, SUCCEED, FAIL, +H5EA__cache_dblock_notify(H5AC_notify_action_t action, H5EA_dblock_t *dblock)) + + /* Sanity check */ + HDassert(dblock); + + /* Determine which action to take */ + switch(action) { + case H5AC_NOTIFY_ACTION_AFTER_INSERT: + /* Create flush dependency on parent */ + if(H5EA__create_flush_depend(dblock->hdr, (H5AC_info_t *)dblock->parent, (H5AC_info_t *)dblock) < 0) + H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency between data block and parent, address = %llu", (unsigned long long)dblock->addr) + break; + + case H5AC_NOTIFY_ACTION_BEFORE_EVICT: + /* Destroy flush dependency on parent */ + if(H5EA__destroy_flush_depend(dblock->hdr, (H5AC_info_t *)dblock->parent, (H5AC_info_t *)dblock) < 0) + H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between data block and parent, address = %llu", (unsigned long long)dblock->addr) + break; + + default: +#ifdef NDEBUG + H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") +#else /* NDEBUG */ + HDassert(0 && "Unknown action?!?"); +#endif /* NDEBUG */ + } /* end switch */ + +CATCH + +END_FUNC(STATIC) /* end H5EA__cache_dblock_notify() */ + + +/*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_size * * Purpose: Compute the size in bytes of a extensible array data block @@ -1636,10 +1781,11 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_dest() */ BEGIN_FUNC(STATIC, ERR, H5EA_dblk_page_t *, NULL, NULL, H5EA__cache_dblk_page_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, - const void UNUSED *udata1, void *_hdr)) + const void *_ud_load, void *_hdr)) /* Local variables */ H5EA_hdr_t *hdr = (H5EA_hdr_t *)_hdr; /* Shared extensible array information */ + const H5EA_dblk_page_load_ud_t *ud_load = (const H5EA_dblk_page_load_ud_t *)_ud_load; /* User data for loading data block page */ H5EA_dblk_page_t *dblk_page = NULL; /* Data block page info */ size_t size; /* Data block page size */ H5WB_t *wb = NULL; /* Wrapped buffer for data block page data */ @@ -1658,7 +1804,7 @@ HDfprintf(stderr, "%s: addr = %a\n", FUNC, addr); #endif /* QAK */ /* Allocate the extensible array data block page */ - if(NULL == (dblk_page = H5EA__dblk_page_alloc(hdr))) + if(NULL == (dblk_page = H5EA__dblk_page_alloc(hdr, ud_load->parent))) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block page") /* Set the extensible array data block's information */ @@ -1842,6 +1988,53 @@ END_FUNC(STATIC) /* end H5EA__cache_dblk_page_clear() */ /*------------------------------------------------------------------------- + * Function: H5EA__cache_dblk_page_notify + * + * Purpose: Handle cache action notifications + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Mar 31 2009 + * + *------------------------------------------------------------------------- + */ +BEGIN_FUNC(STATIC, ERR, +herr_t, SUCCEED, FAIL, +H5EA__cache_dblk_page_notify(H5AC_notify_action_t action, H5EA_dblk_page_t *dblk_page)) + + /* Sanity check */ + HDassert(dblk_page); + + /* Determine which action to take */ + switch(action) { + case H5AC_NOTIFY_ACTION_AFTER_INSERT: + /* Create flush dependency on parent */ + if(H5EA__create_flush_depend(dblk_page->hdr, (H5AC_info_t *)dblk_page->parent, (H5AC_info_t *)dblk_page) < 0) + H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency between data block page and parent, address = %llu", (unsigned long long)dblk_page->addr) + break; + + case H5AC_NOTIFY_ACTION_BEFORE_EVICT: + /* Destroy flush dependency on parent */ + if(H5EA__destroy_flush_depend(dblk_page->hdr, (H5AC_info_t *)dblk_page->parent, (H5AC_info_t *)dblk_page) < 0) + H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between data block page and parent, address = %llu", (unsigned long long)dblk_page->addr) + break; + + default: +#ifdef NDEBUG + H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") +#else /* NDEBUG */ + HDassert(0 && "Unknown action?!?"); +#endif /* NDEBUG */ + } /* end switch */ + +CATCH + +END_FUNC(STATIC) /* end H5EA__cache_dblk_page_notify() */ + + +/*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_size * * Purpose: Compute the size in bytes of a extensible array data block page |