diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2016-11-18 01:48:21 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2016-11-18 01:48:21 (GMT) |
commit | eba0ff43c968ef9a0b09edf19c1e337cfcae0816 (patch) | |
tree | 53142d64c8e678f0862533b17790bb4ea72fa87c /src/H5Ocache.c | |
parent | 248a93cde8d87dd3a8162831103b5358a166fed8 (diff) | |
download | hdf5-eba0ff43c968ef9a0b09edf19c1e337cfcae0816.zip hdf5-eba0ff43c968ef9a0b09edf19c1e337cfcae0816.tar.gz hdf5-eba0ff43c968ef9a0b09edf19c1e337cfcae0816.tar.bz2 |
Remove 'clear' callback from metadata cache client interface, using the
new 'entry cleaned' notify action innstead.
Diffstat (limited to 'src/H5Ocache.c')
-rw-r--r-- | src/H5Ocache.c | 279 |
1 files changed, 132 insertions, 147 deletions
diff --git a/src/H5Ocache.c b/src/H5Ocache.c index badeb69..edabc52 100644 --- a/src/H5Ocache.c +++ b/src/H5Ocache.c @@ -74,8 +74,8 @@ static void *H5O__cache_deserialize(const void *image, size_t len, static herr_t H5O__cache_image_len(const void *thing, size_t *image_len); static herr_t H5O__cache_serialize(const H5F_t *f, void *image, size_t len, void *thing); +static herr_t H5O__cache_notify(H5AC_notify_action_t action, void *_thing); static herr_t H5O__cache_free_icr(void *thing); -static herr_t H5O__cache_clear(const H5F_t *f, void *thing, hbool_t about_to_destroy); static herr_t H5O__cache_chk_get_load_size(const void *udata, size_t *image_len); static void *H5O__cache_chk_deserialize(const void *image, size_t len, @@ -83,8 +83,8 @@ static void *H5O__cache_chk_deserialize(const void *image, size_t len, static herr_t H5O__cache_chk_image_len(const void *thing, size_t *image_len); static herr_t H5O__cache_chk_serialize(const H5F_t *f, void *image, size_t len, void *thing); +static herr_t H5O__cache_chk_notify(H5AC_notify_action_t action, void *_thing); static herr_t H5O__cache_chk_free_icr(void *thing); -static herr_t H5O__cache_chk_clear(const H5F_t *f, void *thing, hbool_t about_to_destroy); /* Chunk routines */ static herr_t H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, @@ -112,9 +112,8 @@ const H5AC_class_t H5AC_OHDR[1] = {{ H5O__cache_image_len, /* 'image_len' callback */ NULL, /* 'pre_serialize' callback */ H5O__cache_serialize, /* 'serialize' callback */ - NULL, /* 'notify' callback */ + H5O__cache_notify, /* 'notify' callback */ H5O__cache_free_icr, /* 'free_icr' callback */ - H5O__cache_clear, /* 'clear' callback */ NULL, /* 'fsf_size' callback */ }}; @@ -129,9 +128,8 @@ const H5AC_class_t H5AC_OHDR_CHK[1] = {{ H5O__cache_chk_image_len, /* 'image_len' callback */ NULL, /* 'pre_serialize' callback */ H5O__cache_chk_serialize, /* 'serialize' callback */ - NULL, /* 'notify' callback */ + H5O__cache_chk_notify, /* 'notify' callback */ H5O__cache_chk_free_icr, /* 'free_icr' callback */ - H5O__cache_chk_clear, /* 'clear' callback */ NULL, /* 'fsf_size' callback */ }}; @@ -592,123 +590,111 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cache_serialize() */ -/**********************************/ -/* no H5O_cache_notify() function */ -/**********************************/ - /*------------------------------------------------------------------------- - * Function: H5O__cache_free_icr + * Function: H5O__cache_notify * - * Purpose: Free the in core representation of the supplied object header. + * Purpose: Handle cache action notifications * - * Note: The metadata cache sets the object's cache_info.magic to - * H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC before calling a free_icr - * callback (checked in assert). + * Return: Non-negative on success/Negative on failure * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: John Mainzer - * 7/28/14 + * Programmer: Quincey Koziol + * Jul 23 2016 * *------------------------------------------------------------------------- */ static herr_t -H5O__cache_free_icr(void *_thing) -{ - H5O_t *oh = (H5O_t *)_thing; /* Object header to destroy */ - herr_t ret_value = SUCCEED; /* Return value */ +H5O__cache_notify(H5AC_notify_action_t action, void *_thing) +{ + H5O_t *oh = (H5O_t *)_thing; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - /* Check arguments */ + /* + * Check arguments. + */ HDassert(oh); - HDassert(oh->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC); - HDassert(oh->cache_info.type == H5AC_OHDR); - /* Destroy object header */ - if(H5O__free(oh) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't destroy object header") + switch(action) { + case H5AC_NOTIFY_ACTION_AFTER_INSERT: + case H5AC_NOTIFY_ACTION_AFTER_LOAD: + case H5AC_NOTIFY_ACTION_AFTER_FLUSH: + case H5AC_NOTIFY_ACTION_ENTRY_DIRTIED: + /* do nothing */ + break; + + case H5AC_NOTIFY_ACTION_ENTRY_CLEANED: + { + unsigned u; /* Local index variable */ + + /* Mark messages stored with the object header (i.e. messages in chunk 0) as clean */ + for(u = 0; u < oh->nmesgs; u++) + if(oh->mesg[u].chunkno == 0) + oh->mesg[u].dirty = FALSE; +#ifndef NDEBUG + /* Reset the number of messages dirtied by decoding */ + oh->ndecode_dirtied = 0; +#endif /* NDEBUG */ + } + break; + + case H5AC_NOTIFY_ACTION_CHILD_DIRTIED: + case H5AC_NOTIFY_ACTION_CHILD_CLEANED: + case H5AC_NOTIFY_ACTION_BEFORE_EVICT: + /* do nothing */ + break; + + default: +#ifdef NDEBUG + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unknown action from metadata cache") +#else /* NDEBUG */ + HDassert(0 && "Unknown action?!?"); +#endif /* NDEBUG */ + } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O__cache_free_icr() */ +} /* end H5O__cache_notify() */ /*------------------------------------------------------------------------- - * Function: H5O__cache_clear - * - * Purpose: Clear all dirty bits associated with this cache entry. + * Function: H5O__cache_free_icr * - * This is ncessary as the object header cache client maintains - * its own dirty bits on individual messages. These dirty bits - * used to be cleared by the old V2 metadata cache flush callback, - * but now the metadata cache must clear them explicitly, as - * the serialize callback does not imply that the data has been - * written to disk. + * Purpose: Free the in core representation of the supplied object header. * - * This callback is also necessary for the parallel case. + * Note: The metadata cache sets the object's cache_info.magic to + * H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC before calling a free_icr + * callback (checked in assert). * * Return: Success: SUCCEED * Failure: FAIL * * Programmer: John Mainzer - * 9/22/14 + * 7/28/14 * *------------------------------------------------------------------------- */ static herr_t -#ifdef H5_HAVE_PARALLEL -H5O__cache_clear(const H5F_t *f, void *_thing, hbool_t H5_ATTR_UNUSED about_to_destroy) -#else -H5O__cache_clear(const H5F_t H5_ATTR_UNUSED *f, void *_thing, hbool_t H5_ATTR_UNUSED about_to_destroy) -#endif /* H5_HAVE_PARALLEL */ +H5O__cache_free_icr(void *_thing) { - H5O_t *oh = (H5O_t *)_thing; /* Object header to reset */ - unsigned u; /* Local index variable */ + H5O_t *oh = (H5O_t *)_thing; /* Object header to destroy */ herr_t ret_value = SUCCEED; /* Return value */ -#ifdef H5_HAVE_PARALLEL FUNC_ENTER_STATIC -#else - FUNC_ENTER_STATIC_NOERR -#endif /* H5_HAVE_PARALLEL */ /* Check arguments */ HDassert(oh); - HDassert(oh->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(oh->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC); HDassert(oh->cache_info.type == H5AC_OHDR); -#ifdef H5_HAVE_PARALLEL - if((oh->nchunks > 0) && (!about_to_destroy)) { - /* Scan through chunk 0 (the chunk stored contiguously with this - * object header) and cause it to update its image of all entries - * currently marked dirty. Must do this in the parallel case, as - * it is possible that this processor may clear this object header - * several times before flushing it -- thus causing undefined - * sections of the image to be written to disk overwriting valid data. - */ - if(H5O__chunk_serialize(f, oh, 0) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, FAIL, "unable to serialize object header chunk") - } /* end if */ -#endif /* H5_HAVE_PARALLEL */ - - /* Mark messages stored with the object header (i.e. messages in chunk 0) as clean */ - for(u = 0; u < oh->nmesgs; u++) - if(oh->mesg[u].chunkno == 0) - oh->mesg[u].dirty = FALSE; - -#ifndef NDEBUG - /* Reset the number of messages dirtied by decoding */ - oh->ndecode_dirtied = 0; -#endif /* NDEBUG */ + /* Destroy object header */ + if(H5O__free(oh) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't destroy object header") -#ifdef H5_HAVE_PARALLEL done: -#endif /* H5_HAVE_PARALLEL */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O__cache_clear() */ +} /* end H5O__cache_free_icr() */ /*------------------------------------------------------------------------- @@ -905,116 +891,115 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__cache_chk_serialize() */ -/**************************************/ -/* no H5O_cache_chk_notify() function */ -/**************************************/ - /*------------------------------------------------------------------------- - * Function: H5O__cache_chk_free_icr + * Function: H5O__cache_chk_notify * - * Purpose: Free the in core memory associated with the supplied object - * header continuation chunk. + * Purpose: Handle cache action notifications * - * Note: The metadata cache sets the object's cache_info.magic to - * H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC before calling a free_icr - * callback (checked in assert). + * Return: Non-negative on success/Negative on failure * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: John Mainzer - * 7/28/14 + * Programmer: Neil Fortner + * Mar 20 2012 * *------------------------------------------------------------------------- */ static herr_t -H5O__cache_chk_free_icr(void *_thing) +H5O__cache_chk_notify(H5AC_notify_action_t action, void *_thing) { - H5O_chunk_proxy_t * chk_proxy = (H5O_chunk_proxy_t *)_thing; /* Object header chunk proxy to release */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_chunk_proxy_t *chk_proxy = (H5O_chunk_proxy_t *)_thing; + void *parent = NULL; /* Chunk containing continuation message that points to this chunk */ + H5O_chunk_proxy_t *cont_chk_proxy = NULL; /* Proxy for chunk containing continuation message that points to this chunk, if not chunk 0 */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - /* Check arguments */ + /* + * Check arguments. + */ HDassert(chk_proxy); - HDassert(chk_proxy->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC); - HDassert(chk_proxy->cache_info.type == H5AC_OHDR_CHK); + HDassert(chk_proxy->oh); - /* Destroy object header chunk proxy */ - if(H5O__chunk_dest(chk_proxy) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to destroy object header chunk proxy") + switch(action) { + case H5AC_NOTIFY_ACTION_AFTER_INSERT: + case H5AC_NOTIFY_ACTION_AFTER_LOAD: + case H5AC_NOTIFY_ACTION_AFTER_FLUSH: + case H5AC_NOTIFY_ACTION_ENTRY_DIRTIED: + /* do nothing */ + break; + + case H5AC_NOTIFY_ACTION_ENTRY_CLEANED: + { + unsigned u; /* Local index variable */ + + /* Mark messages in chunk as clean */ + for(u = 0; u < chk_proxy->oh->nmesgs; u++) + if(chk_proxy->oh->mesg[u].chunkno == chk_proxy->chunkno) + chk_proxy->oh->mesg[u].dirty = FALSE; + } + break; + + case H5AC_NOTIFY_ACTION_CHILD_DIRTIED: + case H5AC_NOTIFY_ACTION_CHILD_CLEANED: + case H5AC_NOTIFY_ACTION_BEFORE_EVICT: + /* do nothing */ + break; + + default: +#ifdef NDEBUG + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unknown action from metadata cache") +#else /* NDEBUG */ + HDassert(0 && "Unknown action?!?"); +#endif /* NDEBUG */ + } /* end switch */ done: + if(cont_chk_proxy) + if(H5O_chunk_unprotect(chk_proxy->f, H5AC_ind_read_dxpl_id, cont_chk_proxy, FALSE) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") + FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O__cache_chk_free_icr() */ +} /* end H5O__cache_chk_notify() */ /*------------------------------------------------------------------------- - * Function: H5O__cache_chk_clear - * - * Purpose: Clear all dirty bits associated with this cache entry. + * Function: H5O__cache_chk_free_icr * - * This is ncessary as the object header cache client maintains - * its own dirty bits on individual messages. These dirty bits - * used to be cleared by the old V2 metadata cache flush callback, - * but now the metadata cache must clear them explicitly, as - * the serialize callback does not imply that the data has been - * written to disk. + * Purpose: Free the in core memory associated with the supplied object + * header continuation chunk. * - * This callback is also necessary for the parallel case. + * Note: The metadata cache sets the object's cache_info.magic to + * H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC before calling a free_icr + * callback (checked in assert). * * Return: Success: SUCCEED * Failure: FAIL * * Programmer: John Mainzer - * 9/22/14 + * 7/28/14 * *------------------------------------------------------------------------- */ static herr_t -#ifdef H5_HAVE_PARALLEL -H5O__cache_chk_clear(const H5F_t *f, void *_thing, hbool_t about_to_destroy) -#else -H5O__cache_chk_clear(const H5F_t H5_ATTR_UNUSED *f, void *_thing, hbool_t H5_ATTR_UNUSED about_to_destroy) -#endif /* H5_HAVE_PARALLEL */ -{ - H5O_chunk_proxy_t *chk_proxy = (H5O_chunk_proxy_t *)_thing; /* Object header chunk to reset */ - H5O_t *oh; /* Object header for chunk */ - unsigned u; /* Local index variable */ +H5O__cache_chk_free_icr(void *_thing) +{ + H5O_chunk_proxy_t * chk_proxy = (H5O_chunk_proxy_t *)_thing; /* Object header chunk proxy to release */ herr_t ret_value = SUCCEED; /* Return value */ -#ifdef H5_HAVE_PARALLEL FUNC_ENTER_STATIC -#else - FUNC_ENTER_STATIC_NOERR -#endif /* H5_HAVE_PARALLEL */ /* Check arguments */ HDassert(chk_proxy); - HDassert(chk_proxy->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert(chk_proxy->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC); HDassert(chk_proxy->cache_info.type == H5AC_OHDR_CHK); - oh = chk_proxy->oh; - HDassert(oh); - HDassert(oh->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert(oh->cache_info.type == H5AC_OHDR); - -#ifdef H5_HAVE_PARALLEL - if((chk_proxy->oh->cache_info.is_dirty) && (!about_to_destroy)) - if(H5O__chunk_serialize(f, chk_proxy->oh, chk_proxy->chunkno) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, FAIL, "unable to serialize object header chunk") -#endif /* H5_HAVE_PARALLEL */ - /* Mark messages in chunk as clean */ - for(u = 0; u < chk_proxy->oh->nmesgs; u++) - if(chk_proxy->oh->mesg[u].chunkno == chk_proxy->chunkno) - chk_proxy->oh->mesg[u].dirty = FALSE; + /* Destroy object header chunk proxy */ + if(H5O__chunk_dest(chk_proxy) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to destroy object header chunk proxy") -#ifdef H5_HAVE_PARALLEL done: -#endif /* H5_HAVE_PARALLEL */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O__cache_chk_clear() */ +} /* end H5O__cache_chk_free_icr() */ /*------------------------------------------------------------------------- |