/*------------------------------------------------------------------------- * Function: H5O_chunk_protect * * Purpose: Protect an object header chunk for modifications * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol * [email protected] * Jul 17 2008 * *------------------------------------------------------------------------- */ H5O_chunk_proxy_t * H5O_chunk_protect(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx) { H5O_chunk_proxy_t *chk_proxy = NULL; /* Proxy for protected chunk */ H5O_chunk_proxy_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_TAG(dxpl_id, oh->cache_info.addr, NULL) /* check args */ HDassert(f); HDassert(oh); HDassert(idx < oh->nchunks); /* Check for protecting first chunk */ if(0 == idx) { /* Create new "fake" chunk proxy for first chunk */ /* (since the first chunk is already handled by the H5O_t object) */ if(NULL == (chk_proxy = H5FL_CALLOC(H5O_chunk_proxy_t))) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "memory allocation failed") /* Increment reference count on object header */ if(H5O_inc_rc(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, NULL, "can't increment reference count on object header") /* Set chunk proxy fields */ chk_proxy->oh = oh; chk_proxy->chunkno = idx; } /* end if */ else {
/*------------------------------------------------------------------------- * Function: H5O_chunk_add * * Purpose: Add new chunk for object header to metadata cache * * Return: Success: Non-negative * Failure: Negative * * Programmer: Quincey Koziol * [email protected] * Jul 13 2008 * *------------------------------------------------------------------------- */ herr_t H5O_chunk_add(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx, unsigned cont_chunkno) { H5O_chunk_proxy_t *chk_proxy = NULL; /* Proxy for chunk, to mark it dirty in the cache */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(dxpl_id, oh->cache_info.addr, FAIL) /* check args */ HDassert(f); HDassert(oh); HDassert(idx < oh->nchunks); HDassert(idx > 0); /* Allocate space for the object header data structure */ if(NULL == (chk_proxy = H5FL_CALLOC(H5O_chunk_proxy_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Set the values in the chunk proxy */ chk_proxy->f = f; chk_proxy->oh = oh; chk_proxy->chunkno = idx; chk_proxy->cont_chunkno = cont_chunkno; chk_proxy->fd_parent_addr = HADDR_UNDEF; chk_proxy->fd_parent_ptr = NULL; /* Increment reference count on object header */ if(H5O_inc_rc(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, FAIL, "can't increment reference count on object header") /* Insert the chunk proxy into the cache */ if(H5AC_insert_entry(f, dxpl_id, H5AC_OHDR_CHK, oh->chunk[idx].addr, chk_proxy, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header chunk") chk_proxy = NULL; done: if(ret_value < 0) if(chk_proxy) chk_proxy = H5FL_FREE(H5O_chunk_proxy_t, chk_proxy); FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) } /* end H5O_chunk_add() */