summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-05-15 20:10:19 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-05-15 20:10:19 (GMT)
commitc2ea0effd88ecbed05faf69621605d5429bea6e3 (patch)
treef01548df9b749724aae5d63c5d9f46f23f3f1d10 /src
parent7bc768c1a775610090463c0aa5b3dfd672166172 (diff)
downloadhdf5-c2ea0effd88ecbed05faf69621605d5429bea6e3.zip
hdf5-c2ea0effd88ecbed05faf69621605d5429bea6e3.tar.gz
hdf5-c2ea0effd88ecbed05faf69621605d5429bea6e3.tar.bz2
[svn-r18822] Description:
Remove the size parameter from H5[A]C_unprotect() and the H5[A]C__SIZE_CHANGED_FLAG, switching all clients & tests over to using H5[A]C_resize_entry appropriately. Tested on: Mac OS X/32 10.6.3 (amazon) w/debug & prod (h5committest not required on this branch)
Diffstat (limited to 'src')
-rw-r--r--src/H5AC.c59
-rw-r--r--src/H5ACprivate.h1
-rw-r--r--src/H5C.c65
-rw-r--r--src/H5Cprivate.h19
-rw-r--r--src/H5HG.c106
-rw-r--r--src/H5HGpkg.h2
-rw-r--r--src/H5O.c8
-rw-r--r--src/H5Oalloc.c69
-rw-r--r--src/H5Oattribute.c20
-rw-r--r--src/H5Ochunk.c59
-rw-r--r--src/H5Omessage.c8
-rw-r--r--src/H5Opkg.h1
12 files changed, 183 insertions, 234 deletions
diff --git a/src/H5AC.c b/src/H5AC.c
index 35dede5..e1c74d1 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -155,9 +155,7 @@ static herr_t H5AC_log_deleted_entry(H5AC_t * cache_ptr,
unsigned int flags);
static herr_t H5AC_log_dirtied_entry(const H5AC_info_t * entry_ptr,
- haddr_t addr,
- hbool_t size_changed,
- size_t new_size);
+ haddr_t addr);
static herr_t H5AC_log_flushed_entry(H5C_t * cache_ptr,
haddr_t addr,
@@ -1402,7 +1400,7 @@ H5AC_mark_entry_dirty(void *thing)
if((!entry_ptr->is_dirty) && (!entry_ptr->is_protected) &&
(entry_ptr->is_pinned) && (NULL != cache_ptr->aux_ptr)) {
- if(H5AC_log_dirtied_entry(entry_ptr, entry_ptr->addr, FALSE, 0) < 0)
+ if(H5AC_log_dirtied_entry(entry_ptr, entry_ptr->addr) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "can't log dirtied entry")
} /* end if */
}
@@ -1790,6 +1788,9 @@ H5AC_resize_entry(void *thing, size_t new_size)
(int)new_size);
#endif /* H5AC__TRACE_FILE_ENABLED */
+ if(H5C_resize_entry(thing, new_size) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTRESIZE, FAIL, "can't resize entry")
+
#ifdef H5_HAVE_PARALLEL
{
H5AC_info_t * entry_ptr = (H5AC_info_t *)thing;
@@ -1799,19 +1800,12 @@ H5AC_resize_entry(void *thing, size_t new_size)
HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC);
if((!entry_ptr->is_dirty) && (NULL != cache_ptr->aux_ptr)) {
- /* Check for usage errors */
- if(!(entry_ptr->is_pinned || entry_ptr->is_protected))
- HGOTO_ERROR(H5E_CACHE, H5E_CANTRESIZE, FAIL, "Entry isn't pinned or protected??")
-
- if(H5AC_log_dirtied_entry(entry_ptr, entry_ptr->addr, TRUE, new_size) < 0)
+ if(H5AC_log_dirtied_entry(entry_ptr, entry_ptr->addr) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "can't log dirtied entry")
} /* end if */
}
#endif /* H5_HAVE_PARALLEL */
- if(H5C_resize_entry(thing, new_size) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTRESIZE, FAIL, "can't resize entry")
-
done:
#if H5AC__TRACE_FILE_ENABLED
if(trace_file_ptr)
@@ -1966,9 +1960,8 @@ H5AC_unprotect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr,
void *thing, unsigned flags)
{
herr_t result;
- hbool_t size_changed = FALSE;
hbool_t dirtied;
- size_t new_size = 0;
+ hbool_t deleted;
#ifdef H5_HAVE_PARALLEL
H5AC_aux_t * aux_ptr = NULL;
#endif /* H5_HAVE_PARALLEL */
@@ -2014,30 +2007,28 @@ H5AC_unprotect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr,
dirtied = (hbool_t)( ( (flags & H5AC__DIRTIED_FLAG) == H5AC__DIRTIED_FLAG ) ||
( ((H5AC_info_t *)thing)->dirtied ) );
+ deleted = (hbool_t)( (flags & H5C__DELETED_FLAG) == H5C__DELETED_FLAG );
- if ( dirtied ) {
+ /* Check if the size changed out from underneath us, if we're not deleting
+ * the entry.
+ */
+ if ( dirtied && !deleted ) {
+ size_t curr_size = 0;
- if ( (type->size)(f, thing, &new_size) < 0 ) {
+ if ( (type->size)(f, thing, &curr_size) < 0 ) {
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGETSIZE, FAIL, \
"Can't get size of thing")
}
- if ( ((H5AC_info_t *)thing)->size != new_size ) {
-
- size_changed = TRUE;
- flags = flags | H5AC__SIZE_CHANGED_FLAG;
-#if H5AC__TRACE_FILE_ENABLED
- trace_flags = flags;
- trace_new_size = new_size;
-#endif /* H5AC__TRACE_FILE_ENABLED */
- }
+ if(((H5AC_info_t *)thing)->size != curr_size)
+ HGOTO_ERROR(H5E_CACHE, H5E_BADSIZE, FAIL, "size of entry changed")
}
#ifdef H5_HAVE_PARALLEL
if ( ( dirtied ) && ( ((H5AC_info_t *)thing)->is_dirty == FALSE ) &&
( NULL != (aux_ptr = f->shared->cache->aux_ptr) ) ) {
- if(H5AC_log_dirtied_entry((H5AC_info_t *)thing, addr, size_changed, new_size) < 0)
+ if(H5AC_log_dirtied_entry((H5AC_info_t *)thing, addr) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "can't log dirtied entry")
}
@@ -2064,8 +2055,7 @@ H5AC_unprotect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr,
type,
addr,
thing,
- flags,
- new_size);
+ flags);
if ( result < 0 ) {
@@ -3481,9 +3471,7 @@ done:
#ifdef H5_HAVE_PARALLEL
static herr_t
H5AC_log_dirtied_entry(const H5AC_info_t * entry_ptr,
- haddr_t addr,
- hbool_t size_changed,
- size_t new_size)
+ haddr_t addr)
{
size_t entry_size;
H5AC_t * cache_ptr;
@@ -3506,14 +3494,7 @@ H5AC_log_dirtied_entry(const H5AC_info_t * entry_ptr,
HDassert( aux_ptr != NULL );
HDassert( aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC );
- if ( size_changed ) {
-
- entry_size = new_size;
-
- } else {
-
- entry_size = entry_ptr->size;
- }
+ entry_size = entry_ptr->size;
if ( aux_ptr->mpi_rank == 0 ) {
H5AC_slist_entry_t * slist_entry_ptr;
diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h
index c48b805..53b5444 100644
--- a/src/H5ACprivate.h
+++ b/src/H5ACprivate.h
@@ -240,7 +240,6 @@ extern hid_t H5AC_ind_dxpl_id;
#define H5AC__SET_FLUSH_MARKER_FLAG H5C__SET_FLUSH_MARKER_FLAG
#define H5AC__DELETED_FLAG H5C__DELETED_FLAG
#define H5AC__DIRTIED_FLAG H5C__DIRTIED_FLAG
-#define H5AC__SIZE_CHANGED_FLAG H5C__SIZE_CHANGED_FLAG
#define H5AC__PIN_ENTRY_FLAG H5C__PIN_ENTRY_FLAG
#define H5AC__UNPIN_ENTRY_FLAG H5C__UNPIN_ENTRY_FLAG
#define H5AC__FLUSH_INVALIDATE_FLAG H5C__FLUSH_INVALIDATE_FLAG
diff --git a/src/H5C.c b/src/H5C.c
index e540dfb..9623f04 100644
--- a/src/H5C.c
+++ b/src/H5C.c
@@ -4763,14 +4763,12 @@ H5C_unprotect(H5F_t * f,
const H5C_class_t * type,
haddr_t addr,
void * thing,
- unsigned int flags,
- size_t new_size)
+ unsigned int flags)
{
H5C_t * cache_ptr;
hbool_t deleted;
hbool_t dirtied;
hbool_t set_flush_marker;
- hbool_t size_changed;
hbool_t pin_entry;
hbool_t unpin_entry;
#ifdef H5_HAVE_PARALLEL
@@ -4787,16 +4785,9 @@ H5C_unprotect(H5F_t * f,
deleted = ( (flags & H5C__DELETED_FLAG) != 0 );
dirtied = ( (flags & H5C__DIRTIED_FLAG) != 0 );
set_flush_marker = ( (flags & H5C__SET_FLUSH_MARKER_FLAG) != 0 );
- size_changed = ( (flags & H5C__SIZE_CHANGED_FLAG) != 0 );
pin_entry = ( (flags & H5C__PIN_ENTRY_FLAG) != 0 );
unpin_entry = ( (flags & H5C__UNPIN_ENTRY_FLAG) != 0 );
- /* Changing the size of an entry dirties it. Thus, set the
- * dirtied flag if the size_changed flag is set.
- */
-
- dirtied |= size_changed;
-
HDassert( f );
HDassert( f->shared );
@@ -4810,9 +4801,6 @@ H5C_unprotect(H5F_t * f,
HDassert( type->flush );
HDassert( H5F_addr_defined(addr) );
HDassert( thing );
- HDassert( ( size_changed == TRUE ) || ( size_changed == FALSE ) );
- HDassert( ( ! size_changed ) || ( dirtied ) );
- HDassert( ( ! size_changed ) || ( new_size > 0 ) );
HDassert( ! ( pin_entry && unpin_entry ) );
entry_ptr = (H5C_cache_entry_t *)thing;
@@ -4928,57 +4916,6 @@ H5C_unprotect(H5F_t * f,
/* mark the entry as dirty if appropriate */
entry_ptr->is_dirty = ( (entry_ptr->is_dirty) || dirtied );
- /* update for change in entry size if necessary */
- if ( ( size_changed ) && ( entry_ptr->size != new_size ) ) {
-
- /* do a flash cache size increase if appropriate */
- if ( cache_ptr->flash_size_increase_possible ) {
-
- if ( new_size > entry_ptr->size ) {
-
- size_increase = new_size - entry_ptr->size;
-
- if ( size_increase >=
- cache_ptr->flash_size_increase_threshold ) {
-
- result = H5C__flash_increase_cache_size(cache_ptr,
- entry_ptr->size,
- new_size);
-
- if ( result < 0 ) {
-
- HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, \
- "H5C__flash_increase_cache_size failed.")
- }
- }
- }
- }
-
- /* update the protected list */
- H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr->pl_len), \
- (cache_ptr->pl_size), \
- (entry_ptr->size), (new_size));
-
- /* update the hash table */
- H5C__UPDATE_INDEX_FOR_SIZE_CHANGE((cache_ptr), (entry_ptr->size),\
- (new_size));
-
- /* if the entry is in the skip list, update that too */
- if ( entry_ptr->in_slist ) {
-
- H5C__UPDATE_SLIST_FOR_SIZE_CHANGE((cache_ptr), \
- (entry_ptr->size),\
- (new_size));
- }
-
- /* update statistics just before changing the entry size */
- H5C__UPDATE_STATS_FOR_ENTRY_SIZE_CHANGE((cache_ptr), (entry_ptr), \
- (new_size));
-
- /* finally, update the entry size proper */
- entry_ptr->size = new_size;
- }
-
/* Pin or unpin the entry as requested. */
if ( pin_entry ) {
diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h
index d916e9e..f83026a 100644
--- a/src/H5Cprivate.h
+++ b/src/H5Cprivate.h
@@ -922,7 +922,6 @@ typedef struct H5C_auto_size_ctl_t
* H5C__SET_FLUSH_MARKER_FLAG
* H5C__DELETED_FLAG
* H5C__DIRTIED_FLAG
- * H5C__SIZE_CHANGED_FLAG
* H5C__PIN_ENTRY_FLAG
* H5C__UNPIN_ENTRY_FLAG
*
@@ -946,14 +945,13 @@ typedef struct H5C_auto_size_ctl_t
#define H5C__SET_FLUSH_MARKER_FLAG 0x0001
#define H5C__DELETED_FLAG 0x0002
#define H5C__DIRTIED_FLAG 0x0004
-#define H5C__SIZE_CHANGED_FLAG 0x0008
-#define H5C__PIN_ENTRY_FLAG 0x0010
-#define H5C__UNPIN_ENTRY_FLAG 0x0020
-#define H5C__FLUSH_INVALIDATE_FLAG 0x0040
-#define H5C__FLUSH_CLEAR_ONLY_FLAG 0x0080
-#define H5C__FLUSH_MARKED_ENTRIES_FLAG 0x0100
-#define H5C__FLUSH_IGNORE_PROTECTED_FLAG 0x0200
-#define H5C__READ_ONLY_FLAG 0x0400
+#define H5C__PIN_ENTRY_FLAG 0x0008
+#define H5C__UNPIN_ENTRY_FLAG 0x0010
+#define H5C__FLUSH_INVALIDATE_FLAG 0x0020
+#define H5C__FLUSH_CLEAR_ONLY_FLAG 0x0040
+#define H5C__FLUSH_MARKED_ENTRIES_FLAG 0x0080
+#define H5C__FLUSH_IGNORE_PROTECTED_FLAG 0x0100
+#define H5C__READ_ONLY_FLAG 0x0200
H5_DLL H5C_t * H5C_create(size_t max_cache_size,
size_t min_clean_size,
@@ -1086,8 +1084,7 @@ H5_DLL herr_t H5C_unprotect(H5F_t * f,
const H5C_class_t * type,
haddr_t addr,
void * thing,
- unsigned int flags,
- size_t new_size);
+ unsigned int flags);
H5_DLL herr_t H5C_validate_resize_config(H5C_auto_size_ctl_t * config_ptr,
unsigned int tests);
diff --git a/src/H5HG.c b/src/H5HG.c
index 07b1462..32cfed9 100644
--- a/src/H5HG.c
+++ b/src/H5HG.c
@@ -99,7 +99,7 @@ static haddr_t H5HG_create(H5F_t *f, hid_t dxpl_id, size_t size);
/* Package Variables */
/*********************/
-/* Declare a free list to manage the H5HG_t struct */
+/* Declare a free list to manage the H5HG_heap_t struct */
H5FL_DEFINE(H5HG_heap_t);
/* Declare a free list to manage sequences of H5HG_obj_t's */
@@ -158,13 +158,10 @@ H5HG_create (H5F_t *f, hid_t dxpl_id, size_t size)
/* Create it */
H5_CHECK_OVERFLOW(size,size_t,hsize_t);
- if ( HADDR_UNDEF==
- (addr=H5MF_alloc(f, H5FD_MEM_GHEAP, dxpl_id, (hsize_t)size)))
- HGOTO_ERROR (H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, \
- "unable to allocate file space for global heap");
- if (NULL==(heap = H5FL_MALLOC (H5HG_heap_t)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, \
- "memory allocation failed");
+ if(HADDR_UNDEF == (addr = H5MF_alloc(f, H5FD_MEM_GHEAP, dxpl_id, (hsize_t)size)))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, "unable to allocate file space for global heap")
+ if(NULL == (heap = H5FL_MALLOC (H5HG_heap_t)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "memory allocation failed")
heap->addr = addr;
heap->size = size;
heap->shared = f->shared;
@@ -256,7 +253,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-H5HG_t *
+H5HG_heap_t *
H5HG_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, H5AC_protect_t rw)
{
H5HG_heap_t *heap; /* Global heap */
@@ -302,36 +299,36 @@ done:
*-------------------------------------------------------------------------
*/
static size_t
-H5HG_alloc (H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned * heap_flags_ptr)
+H5HG_alloc(H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned *heap_flags_ptr)
{
size_t idx;
- uint8_t *p = NULL;
+ uint8_t *p;
size_t need = H5HG_SIZEOF_OBJHDR(f) + H5HG_ALIGN(size);
- size_t ret_value; /* Return value */
+ size_t ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5HG_alloc);
/* Check args */
- assert (heap);
- assert (heap->obj[0].size>=need);
- assert (heap_flags_ptr);
+ HDassert(heap);
+ HDassert(heap->obj[0].size>=need);
+ HDassert(heap_flags_ptr);
/*
* Find an ID for the new object. ID zero is reserved for the free space
* object.
*/
- if(heap->nused<=H5HG_MAXIDX)
- idx=heap->nused++;
+ if(heap->nused <= H5HG_MAXIDX)
+ idx = heap->nused++;
else {
- for (idx=1; idx<heap->nused; idx++)
- if (NULL==heap->obj[idx].begin)
+ for(idx = 1; idx < heap->nused; idx++)
+ if(NULL == heap->obj[idx].begin)
break;
} /* end else */
HDassert(idx < heap->nused);
/* Check if we need more room to store heap objects */
- if(idx>=heap->nalloc) {
+ if(idx >= heap->nalloc) {
size_t new_alloc; /* New allocation number */
H5HG_obj_t *new_obj; /* New array of object descriptions */
@@ -341,16 +338,16 @@ H5HG_alloc (H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned * heap_flags_ptr)
HDassert(idx < new_alloc);
/* Reallocate array of objects */
- if (NULL==(new_obj = H5FL_SEQ_REALLOC (H5HG_obj_t, heap->obj, new_alloc)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed")
+ if(NULL == (new_obj = H5FL_SEQ_REALLOC(H5HG_obj_t, heap->obj, new_alloc)))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, 0, "memory allocation failed")
/* Clear newly allocated space */
HDmemset(&new_obj[heap->nalloc], 0, (new_alloc - heap->nalloc) * sizeof(heap->obj[0]));
/* Update heap information */
- heap->nalloc=new_alloc;
- heap->obj=new_obj;
- HDassert(heap->nalloc>heap->nused);
+ heap->nalloc = new_alloc;
+ heap->obj = new_obj;
+ HDassert(heap->nalloc > heap->nused);
} /* end if */
/* Initialize the new object */
@@ -364,14 +361,14 @@ H5HG_alloc (H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned * heap_flags_ptr)
H5F_ENCODE_LENGTH (f, p, size);
/* Fix the free space object */
- if (need==heap->obj[0].size) {
+ if(need == heap->obj[0].size) {
/*
* All free space has been exhausted from this collection.
*/
heap->obj[0].size = 0;
heap->obj[0].begin = NULL;
-
- } else if (heap->obj[0].size-need >= H5HG_SIZEOF_OBJHDR (f)) {
+ } /* end if */
+ else if(heap->obj[0].size-need >= H5HG_SIZEOF_OBJHDR (f)) {
/*
* Some free space remains and it's larger than a heap object header,
* so write the new free heap object header to the heap.
@@ -384,8 +381,8 @@ H5HG_alloc (H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned * heap_flags_ptr)
UINT32ENCODE(p, 0); /*reserved*/
H5F_ENCODE_LENGTH (f, p, heap->obj[0].size);
assert(H5HG_ISALIGNED(heap->obj[0].size));
-
- } else {
+ } /* end else-if */
+ else {
/*
* Some free space remains but it's smaller than a heap object header,
* so we don't write the header.
@@ -399,11 +396,11 @@ H5HG_alloc (H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned * heap_flags_ptr)
*heap_flags_ptr |= H5AC__DIRTIED_FLAG;
/* Set the return value */
- ret_value=idx;
+ ret_value = idx;
done:
FUNC_LEAVE_NOAPI(ret_value);
-}
+} /* end H5HG_alloc() */
/*-------------------------------------------------------------------------
@@ -434,12 +431,14 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5HG_extend(H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned *heap_flags_ptr)
+H5HG_extend(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t size)
{
+ H5HG_heap_t *heap = NULL; /* Pointer to heap to extend */
+ unsigned heap_flags = H5AC__NO_FLAGS_SET; /* Flags to unprotecting heap */
size_t need; /* Actual space needed to store object */
size_t old_size; /* Previous size of the heap's chunk */
- uint8_t *new_chunk = NULL; /* Pointer to new chunk information */
- uint8_t *p = NULL; /* Pointer to raw heap info */
+ uint8_t *new_chunk; /* Pointer to new chunk information */
+ uint8_t *p; /* Pointer to raw heap info */
unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
@@ -447,8 +446,11 @@ H5HG_extend(H5F_t *f, H5HG_heap_t *heap, size_t size, unsigned *heap_flags_ptr)
/* Check args */
HDassert(f);
- HDassert(heap);
- HDassert(heap_flags_ptr);
+ HDassert(H5F_addr_defined(addr));
+
+ /* Protect the heap */
+ if(NULL == (heap = H5HG_protect(f, dxpl_id, addr, H5AC_WRITE)))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect global heap")
/* Compute total space need to add to this heap */
need = H5HG_SIZEOF_OBJHDR(f) + H5HG_ALIGN(size);
@@ -498,10 +500,17 @@ HDmemset(new_chunk + heap->size, 0, need);
H5F_ENCODE_LENGTH(f, p, heap->obj[0].size);
assert(H5HG_ISALIGNED(heap->obj[0].size));
+ /* Resize the heap in the cache */
+ if(H5AC_resize_entry(heap, heap->size) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize global heap in cache")
+
/* Mark the heap as dirty */
- *heap_flags_ptr |= H5AC__DIRTIED_FLAG;
+ heap_flags |= H5AC__DIRTIED_FLAG;
done:
+ if(heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, heap->addr, heap, heap_flags) < 0)
+ HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to unprotect heap")
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HG_extend() */
@@ -567,14 +576,6 @@ H5HG_insert(H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out*/
* and protecting and unprotecting all the collections in the global
* heap on a regular basis will skew the replacement policy.
*
- * However, there is a bigger issue -- as best I can tell, we only look
- * for free space in global heap chunks that are in cache. If we can't
- * find any, we allocate a new chunk. This may be a problem in FP mode,
- * as the metadata cache is disabled. Do we allocate a new heap
- * collection for every entry in this case?
- *
- * Note that all this comes from a cursory read of the source. Don't
- * take any of it as gospel.
* JRM - 5/24/04
*/
for(cwfsno = 0; cwfsno < f->shared->ncwfs; cwfsno++)
@@ -597,7 +598,7 @@ H5HG_insert(H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out*/
new_need = MAX(f->shared->cwfs[cwfsno]->size, new_need);
if((f->shared->cwfs[cwfsno]->size + new_need) <= H5HG_MAXSIZE && H5MF_can_extend(f, H5FD_MEM_GHEAP, f->shared->cwfs[cwfsno]->addr, (hsize_t)f->shared->cwfs[cwfsno]->size, (hsize_t)new_need)) {
- if(H5HG_extend(f, f->shared->cwfs[cwfsno], size, &heap_flags) < 0)
+ if(H5HG_extend(f, dxpl_id, f->shared->cwfs[cwfsno]->addr, size) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "unable to extend global heap collection")
addr = f->shared->cwfs[cwfsno]->addr;
found = TRUE;
@@ -633,7 +634,8 @@ H5HG_insert(H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out*/
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect global heap")
/* Split the free space to make room for the new object */
- idx = H5HG_alloc(f, heap, size, &heap_flags);
+ if(0 == (idx = H5HG_alloc(f, heap, size, &heap_flags)))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "unable to allocate global heap object")
/* Copy data into the heap */
if(size > 0) {
@@ -652,7 +654,7 @@ H5HG_insert(H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out*/
done:
if(heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, heap->addr, heap, heap_flags) < 0)
- HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to unprotect heap.")
+ HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to unprotect heap.")
FUNC_LEAVE_NOAPI(ret_value)
} /* H5HG_insert() */
@@ -729,7 +731,7 @@ H5HG_read(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, void *object/*out*/,
done:
if(heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, H5AC__NO_FLAGS_SET) < 0)
- HDONE_ERROR(H5E_HEAP, H5E_PROTECT, NULL, "unable to release object header")
+ HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release object header")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HG_read() */
@@ -795,7 +797,7 @@ H5HG_link (H5F_t *f, hid_t dxpl_id, const H5HG_t *hobj, int adjust)
done:
if(heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, heap_flags) < 0)
- HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release object header")
+ HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
FUNC_LEAVE_NOAPI(ret_value);
}
@@ -902,7 +904,7 @@ H5HG_remove (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj)
done:
if(heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, flags) < 0)
- HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release object header")
+ HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
FUNC_LEAVE_NOAPI(ret_value);
} /* end H5HG_remove() */
diff --git a/src/H5HGpkg.h b/src/H5HGpkg.h
index f747897..6c60656 100644
--- a/src/H5HGpkg.h
+++ b/src/H5HGpkg.h
@@ -150,7 +150,7 @@ struct H5HG_heap_t {
/* Package Private Prototypes */
/******************************/
H5_DLL herr_t H5HG_free(H5HG_heap_t *heap);
-H5_DLL H5HG_t *H5HG_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, H5AC_protect_t rw);
+H5_DLL H5HG_heap_t *H5HG_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, H5AC_protect_t rw);
#endif /* _H5HGpkg_H */
diff --git a/src/H5O.c b/src/H5O.c
index 2c10627..4a207e6 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -1713,7 +1713,7 @@ H5O_protect(const H5O_loc_t *loc, hid_t dxpl_id, H5AC_protect_t prot)
HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to load object header chunk")
/* Unprotect chunk, marking it dirty */
- if(H5O_chunk_unprotect(loc->file, dxpl_id, oh, chk_proxy, H5AC__DIRTIED_FLAG) < 0)
+ if(H5O_chunk_unprotect(loc->file, dxpl_id, oh, chk_proxy, TRUE) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to unprotect object header chunk")
} /* end if */
} /* end for */
@@ -1862,7 +1862,7 @@ herr_t
H5O_touch_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, hbool_t force)
{
H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */
- unsigned chk_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting chunk */
+ hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */
time_t now; /* Current time */
herr_t ret_value = SUCCEED; /* Return value */
@@ -1916,7 +1916,7 @@ H5O_touch_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, hbool_t force)
/* Mark the message as dirty */
oh->mesg[idx].dirty = TRUE;
- chk_flags |= H5AC__DIRTIED_FLAG;
+ chk_dirtied = TRUE;
} /* end if */
else {
/* XXX: For now, update access time & change fields in the object header */
@@ -1931,7 +1931,7 @@ H5O_touch_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, hbool_t force)
done:
/* Release chunk */
- if(chk_proxy && H5O_chunk_unprotect(f, dxpl_id, oh, chk_proxy, chk_flags) < 0)
+ if(chk_proxy && H5O_chunk_unprotect(f, dxpl_id, oh, chk_proxy, chk_dirtied) < 0)
HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk")
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5Oalloc.c b/src/H5Oalloc.c
index 4540d35..afc22bd 100644
--- a/src/H5Oalloc.c
+++ b/src/H5Oalloc.c
@@ -110,7 +110,7 @@ H5O_add_gap(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno, unsigned idx,
uint8_t *new_gap_loc, size_t new_gap_size)
{
H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */
- unsigned chk_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting chunk */
+ hbool_t chk_dirtied = FALSE; /* Flags for unprotecting chunk */
hbool_t merged_with_null; /* Whether the gap was merged with a null message */
unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
@@ -195,12 +195,12 @@ H5O_add_gap(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno, unsigned idx,
oh->chunk[chunkno].gap = new_gap_size;
/* Mark the chunk as modified */
- chk_flags |= H5AC__DIRTIED_FLAG;
+ chk_dirtied = TRUE;
} /* end if */
done:
/* Release chunk */
- if(chk_proxy && H5O_chunk_unprotect(f, dxpl_id, oh, chk_proxy, chk_flags) < 0)
+ if(chk_proxy && H5O_chunk_unprotect(f, dxpl_id, oh, chk_proxy, chk_dirtied) < 0)
HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk")
FUNC_LEAVE_NOAPI(ret_value)
@@ -232,9 +232,9 @@ H5O_eliminate_gap(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_mesg_t *mesg,
uint8_t *gap_loc, size_t gap_size)
{
H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */
- unsigned chk_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting chunk */
+ hbool_t chk_dirtied = FALSE; /* Flags for unprotecting chunk */
uint8_t *move_start, *move_end; /* Pointers to area of messages to move */
- hbool_t null_before_gap; /* Flag whether the null message is before the gap or not */
+ hbool_t null_before_gap; /* Flag whether the null message is before the gap or not */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5O_eliminate_gap)
@@ -314,11 +314,11 @@ H5O_eliminate_gap(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_mesg_t *mesg,
/* Mark null message as dirty */
mesg->dirty = TRUE;
- chk_flags |= H5AC__DIRTIED_FLAG;
+ chk_dirtied = TRUE;
done:
/* Release chunk */
- if(chk_proxy && H5O_chunk_unprotect(f, dxpl_id, oh, chk_proxy, chk_flags) < 0)
+ if(chk_proxy && H5O_chunk_unprotect(f, dxpl_id, oh, chk_proxy, chk_dirtied) < 0)
HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk")
FUNC_LEAVE_NOAPI(ret_value)
@@ -344,7 +344,7 @@ H5O_alloc_null(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned null_idx,
const H5O_msg_class_t *new_type, void *new_native, size_t new_size)
{
H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */
- unsigned chk_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting chunk */
+ hbool_t chk_dirtied = FALSE; /* Flags for unprotecting chunk */
H5O_mesg_t *alloc_msg; /* Pointer to null message to allocate out of */
herr_t ret_value = SUCCEED; /* Return value */
@@ -401,7 +401,7 @@ H5O_alloc_null(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned null_idx,
null_msg->dirty = TRUE;
/* Release chunk, marking it dirty */
- if(H5O_chunk_unprotect(f, dxpl_id, oh, null_chk_proxy, H5AC__DIRTIED_FLAG) < 0)
+ if(H5O_chunk_unprotect(f, dxpl_id, oh, null_chk_proxy, TRUE) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk")
/* Check for gap in new null message's chunk */
@@ -430,11 +430,11 @@ H5O_alloc_null(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned null_idx,
/* Mark the new message as dirty */
alloc_msg->dirty = TRUE;
- chk_flags |= H5AC__DIRTIED_FLAG;
+ chk_dirtied = TRUE;
done:
/* Release chunk */
- if(chk_proxy && H5O_chunk_unprotect(f, dxpl_id, oh, chk_proxy, chk_flags) < 0)
+ if(chk_proxy && H5O_chunk_unprotect(f, dxpl_id, oh, chk_proxy, chk_dirtied) < 0)
HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk")
FUNC_LEAVE_NOAPI(ret_value)
@@ -520,8 +520,8 @@ static htri_t
H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno,
size_t size, unsigned * msg_idx)
{
- H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */
- unsigned chk_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting chunk */
+ H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */
+ hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */
size_t delta; /* Change in chunk's size */
size_t aligned_size = H5O_ALIGN_OH(oh, size);
uint8_t *old_image; /* Old address of chunk's image in memory */
@@ -649,7 +649,7 @@ H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno,
/* Mark the extended message as dirty */
oh->mesg[extend_msg].dirty = TRUE;
- chk_flags |= H5AC__DIRTIED_FLAG;
+ chk_dirtied = TRUE;
/* Allocate more memory space for chunk's image */
old_image = oh->chunk[chunkno].image;
@@ -680,8 +680,8 @@ H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno,
if(chunkno > 0 && (H5O_CONT_ID == oh->mesg[u].type->id) &&
(((H5O_cont_t *)(oh->mesg[u].native))->chunkno == chunkno)) {
H5O_chunk_proxy_t *chk_proxy2 = NULL; /* Chunk that continuation message is in */
- unsigned chk_flags2 = H5AC__NO_FLAGS_SET; /* Flags for unprotecting chunk */
unsigned cont_chunkno = oh->mesg[u].chunkno; /* Chunk # for continuation message */
+ hbool_t chk_dirtied2 = FALSE; /* Flag for unprotecting chunk */
/* Protect chunk containing continuation message */
if(NULL == (chk_proxy2 = H5O_chunk_protect(f, dxpl_id, oh, cont_chunkno)))
@@ -693,23 +693,24 @@ H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno,
/* Flag continuation message as dirty */
oh->mesg[u].dirty = TRUE;
- chk_flags2 |= H5AC__DIRTIED_FLAG;
+ chk_dirtied2 = TRUE;
/* Release chunk containing continuation message */
- if(H5O_chunk_unprotect(f, dxpl_id, oh, chk_proxy2, chk_flags2) < 0)
+ if(H5O_chunk_unprotect(f, dxpl_id, oh, chk_proxy2, chk_dirtied2) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk")
} /* end if */
} /* end for */
- /* Mark the chunk size in the cache as changed */
- chk_flags |= H5AC__SIZE_CHANGED_FLAG;
+ /* Resize the chunk in the cache */
+ if(H5O_chunk_resize(oh, chk_proxy) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTRESIZE, FAIL, "unable to resize object header chunk")
/* Set return value */
*msg_idx = (unsigned)extend_msg;
done:
/* Release chunk */
- if(chk_proxy && H5O_chunk_unprotect(f, dxpl_id, oh, chk_proxy, chk_flags) < 0)
+ if(chk_proxy && H5O_chunk_unprotect(f, dxpl_id, oh, chk_proxy, chk_dirtied) < 0)
HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk")
FUNC_LEAVE_NOAPI(ret_value)
@@ -1004,7 +1005,7 @@ H5O_alloc_new_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t size)
null_msg->dirty = TRUE;
/* Release chunk, marking it dirty */
- if(H5O_chunk_unprotect(f, dxpl_id, oh, null_chk_proxy, H5AC__DIRTIED_FLAG) < 0)
+ if(H5O_chunk_unprotect(f, dxpl_id, oh, null_chk_proxy, TRUE) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, UFAIL, "unable to unprotect object header chunk")
} /* end if */
HDassert(found_null >= 0);
@@ -1149,9 +1150,9 @@ herr_t
H5O_release_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_mesg_t *mesg,
hbool_t adj_link)
{
- H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */
- unsigned chk_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting chunk */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */
+ hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5O_release_mesg, FAIL)
@@ -1184,10 +1185,10 @@ H5O_release_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_mesg_t *mesg,
/* Mark the message as modified */
mesg->dirty = TRUE;
- chk_flags |= H5AC__DIRTIED_FLAG;
+ chk_dirtied = TRUE;
/* Release chunk */
- if(H5O_chunk_unprotect(f, dxpl_id, oh, chk_proxy, chk_flags) < 0)
+ if(H5O_chunk_unprotect(f, dxpl_id, oh, chk_proxy, chk_dirtied) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk")
chk_proxy = NULL;
@@ -1202,7 +1203,7 @@ H5O_release_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_mesg_t *mesg,
done:
/* Release chunk, if not already done */
- if(chk_proxy && H5O_chunk_unprotect(f, dxpl_id, oh, chk_proxy, chk_flags) < 0)
+ if(chk_proxy && H5O_chunk_unprotect(f, dxpl_id, oh, chk_proxy, chk_dirtied) < 0)
HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk")
FUNC_LEAVE_NOAPI(ret_value)
@@ -1288,7 +1289,7 @@ H5O_move_msgs_forward(H5F_t *f, hid_t dxpl_id, H5O_t *oh)
curr_msg->dirty = TRUE;
/* Release chunk, marking it dirty */
- if(H5O_chunk_unprotect(f, dxpl_id, oh, null_chk_proxy, H5AC__DIRTIED_FLAG) < 0)
+ if(H5O_chunk_unprotect(f, dxpl_id, oh, null_chk_proxy, TRUE) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk")
@@ -1348,9 +1349,9 @@ H5O_move_msgs_forward(H5F_t *f, hid_t dxpl_id, H5O_t *oh)
null_msg->dirty = TRUE;
/* Release chunks, marking them dirty */
- if(H5O_chunk_unprotect(f, dxpl_id, oh, null_chk_proxy, H5AC__DIRTIED_FLAG) < 0)
+ if(H5O_chunk_unprotect(f, dxpl_id, oh, null_chk_proxy, TRUE) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk")
- if(H5O_chunk_unprotect(f, dxpl_id, oh, curr_chk_proxy, H5AC__DIRTIED_FLAG) < 0)
+ if(H5O_chunk_unprotect(f, dxpl_id, oh, curr_chk_proxy, TRUE) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk")
/* Check for gap in null message's chunk */
@@ -1376,7 +1377,7 @@ H5O_move_msgs_forward(H5F_t *f, hid_t dxpl_id, H5O_t *oh)
null_msg->dirty = TRUE;
/* Release null message's chunk, marking it dirty */
- if(H5O_chunk_unprotect(f, dxpl_id, oh, null_chk_proxy, H5AC__DIRTIED_FLAG) < 0)
+ if(H5O_chunk_unprotect(f, dxpl_id, oh, null_chk_proxy, TRUE) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk")
/* Add the gap to the chunk */
@@ -1395,7 +1396,7 @@ H5O_move_msgs_forward(H5F_t *f, hid_t dxpl_id, H5O_t *oh)
null_msg->dirty = TRUE;
/* Release null message's chunk, marking it dirty */
- if(H5O_chunk_unprotect(f, dxpl_id, oh, null_chk_proxy, H5AC__DIRTIED_FLAG) < 0)
+ if(H5O_chunk_unprotect(f, dxpl_id, oh, null_chk_proxy, TRUE) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk")
/* Create new null message for previous location of non-null message */
@@ -1422,7 +1423,7 @@ H5O_move_msgs_forward(H5F_t *f, hid_t dxpl_id, H5O_t *oh)
oh->mesg[new_null_msg].dirty = TRUE;
/* Release new null message's chunk, marking it dirty */
- if(H5O_chunk_unprotect(f, dxpl_id, oh, curr_chk_proxy, H5AC__DIRTIED_FLAG) < 0)
+ if(H5O_chunk_unprotect(f, dxpl_id, oh, curr_chk_proxy, TRUE) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk")
/* Check for gap in new null message's chunk */
@@ -1556,7 +1557,7 @@ H5O_merge_null(H5F_t *f, hid_t dxpl_id, H5O_t *oh)
curr_msg->dirty = TRUE;
/* Release new null message's chunk, marking it dirty */
- if(H5O_chunk_unprotect(f, dxpl_id, oh, curr_chk_proxy, H5AC__DIRTIED_FLAG) < 0)
+ if(H5O_chunk_unprotect(f, dxpl_id, oh, curr_chk_proxy, TRUE) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk")
/* Remove second message from list of messages */
diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c
index 0f1cdc6..6ba9d47 100644
--- a/src/H5Oattribute.c
+++ b/src/H5Oattribute.c
@@ -822,8 +822,8 @@ H5O_attr_write_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/,
{
H5O_iter_wrt_t *udata = (H5O_iter_wrt_t *)_udata; /* Operator user data */
H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */
- unsigned chk_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting chunk */
- herr_t ret_value = H5_ITER_CONT; /* Return value */
+ hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */
+ herr_t ret_value = H5_ITER_CONT; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5O_attr_write_cb)
@@ -851,10 +851,10 @@ H5O_attr_write_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/,
/* Mark the message as modified */
mesg->dirty = TRUE;
- chk_flags |= H5AC__DIRTIED_FLAG;
+ chk_dirtied = TRUE;
/* Release chunk */
- if(H5O_chunk_unprotect(udata->f, udata->dxpl_id, oh, chk_proxy, chk_flags) < 0)
+ if(H5O_chunk_unprotect(udata->f, udata->dxpl_id, oh, chk_proxy, chk_dirtied) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to unprotect object header chunk")
chk_proxy = NULL;
@@ -875,7 +875,7 @@ H5O_attr_write_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/,
done:
/* Release chunk, if not already done */
- if(chk_proxy && H5O_chunk_unprotect(udata->f, udata->dxpl_id, oh, chk_proxy, chk_flags) < 0)
+ if(chk_proxy && H5O_chunk_unprotect(udata->f, udata->dxpl_id, oh, chk_proxy, chk_dirtied) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to unprotect object header chunk")
FUNC_LEAVE_NOAPI(ret_value)
@@ -1030,8 +1030,8 @@ H5O_attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/,
{
H5O_iter_ren_t *udata = (H5O_iter_ren_t *)_udata; /* Operator user data */
H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */
- unsigned chk_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting chunk */
- herr_t ret_value = H5_ITER_CONT; /* Return value */
+ hbool_t chk_dirtied = FALSE; /* Flags for unprotecting chunk */
+ herr_t ret_value = H5_ITER_CONT; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5O_attr_rename_mod_cb)
@@ -1058,10 +1058,10 @@ H5O_attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/,
/* Mark the message as modified */
mesg->dirty = TRUE;
- chk_flags |= H5AC__DIRTIED_FLAG;
+ chk_dirtied = TRUE;
/* Release chunk */
- if(H5O_chunk_unprotect(udata->f, udata->dxpl_id, oh, chk_proxy, chk_flags) < 0)
+ if(H5O_chunk_unprotect(udata->f, udata->dxpl_id, oh, chk_proxy, chk_dirtied) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to unprotect object header chunk")
chk_proxy = NULL;
@@ -1125,7 +1125,7 @@ H5O_attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/,
done:
/* Release chunk, if not already done */
- if(chk_proxy && H5O_chunk_unprotect(udata->f, udata->dxpl_id, oh, chk_proxy, chk_flags) < 0)
+ if(chk_proxy && H5O_chunk_unprotect(udata->f, udata->dxpl_id, oh, chk_proxy, chk_dirtied) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to unprotect object header chunk")
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5Ochunk.c b/src/H5Ochunk.c
index a2fa5dc..d683a7b 100644
--- a/src/H5Ochunk.c
+++ b/src/H5Ochunk.c
@@ -208,7 +208,7 @@ done:
*/
herr_t
H5O_chunk_unprotect(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_chunk_proxy_t *chk_proxy,
- unsigned chk_flags)
+ hbool_t dirtied)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -218,33 +218,22 @@ H5O_chunk_unprotect(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_chunk_proxy_t *chk_p
HDassert(f);
HDassert(oh);
HDassert(chk_proxy);
- HDassert(!(chk_flags & (unsigned)~(H5AC__DIRTIED_FLAG | H5AC__SIZE_CHANGED_FLAG)));
/* Check for releasing first chunk */
if(0 == chk_proxy->chunkno) {
- /* Check for resizing the first chunk */
- if(chk_flags & H5AC__SIZE_CHANGED_FLAG) {
- /* Resize object header in cache */
- if(H5AC_resize_entry(oh, oh->chunk[0].size) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTRESIZE, FAIL, "unable to resize chunk in cache")
- } /* end if */
/* Check for dirtying the first chunk */
- else if(chk_flags & H5AC__DIRTIED_FLAG) {
+ if(dirtied) {
/* Mark object header as dirty in cache */
if(H5AC_mark_entry_dirty(oh) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty")
} /* end else/if */
- else {
- /* Sanity check */
- HDassert(0 && "Unknown chunk proxy flag(s)?!?");
- } /* end else */
/* Free fake chunk proxy */
chk_proxy = H5FL_FREE(H5O_chunk_proxy_t, chk_proxy);
} /* end if */
else {
/* Release the chunk proxy from the cache, marking it dirty */
- if(H5AC_unprotect(f, dxpl_id, H5AC_OHDR_CHK, oh->chunk[chk_proxy->chunkno].addr, chk_proxy, chk_flags) < 0)
+ if(H5AC_unprotect(f, dxpl_id, H5AC_OHDR_CHK, oh->chunk[chk_proxy->chunkno].addr, chk_proxy, (dirtied ? H5AC__DIRTIED_FLAG : H5AC__NO_FLAGS_SET)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header chunk")
} /* end else */
@@ -254,6 +243,48 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5O_chunk_resize
+ *
+ * Purpose: Resize an object header chunk
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * May 6 2010
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_chunk_resize(H5O_t *oh, H5O_chunk_proxy_t *chk_proxy)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5O_chunk_resize, FAIL)
+
+ /* check args */
+ HDassert(oh);
+ HDassert(chk_proxy);
+
+ /* Check for resizing first chunk */
+ if(0 == chk_proxy->chunkno) {
+ /* Resize object header in cache */
+ if(H5AC_resize_entry(oh, oh->chunk[0].size) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTRESIZE, FAIL, "unable to resize chunk in cache")
+ } /* end if */
+ else {
+ /* Resize chunk in cache */
+ if(H5AC_resize_entry(chk_proxy, oh->chunk[chk_proxy->chunkno].size) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTRESIZE, FAIL, "unable to resize chunk in cache")
+ } /* end else */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_chunk_resize() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5O_chunk_update_idx
*
* Purpose: Update the chunk index for a chunk proxy
diff --git a/src/H5Omessage.c b/src/H5Omessage.c
index 39a5256..bb02473 100644
--- a/src/H5Omessage.c
+++ b/src/H5Omessage.c
@@ -1996,7 +1996,7 @@ H5O_copy_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx,
{
H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */
H5O_mesg_t *idx_msg = &oh->mesg[idx]; /* Pointer to message to modify */
- unsigned chk_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting chunk */
+ hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5O_copy_mesg)
@@ -2024,10 +2024,10 @@ H5O_copy_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx,
/* Mark the message as modified */
idx_msg->dirty = TRUE;
- chk_flags |= H5AC__DIRTIED_FLAG;
+ chk_dirtied = TRUE;
/* Release chunk */
- if(H5O_chunk_unprotect(f, dxpl_id, oh, chk_proxy, chk_flags) < 0)
+ if(H5O_chunk_unprotect(f, dxpl_id, oh, chk_proxy, chk_dirtied) < 0)
HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk")
chk_proxy = NULL;
@@ -2038,7 +2038,7 @@ H5O_copy_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx,
done:
/* Release chunk, if not already released */
- if(chk_proxy && H5O_chunk_unprotect(f, dxpl_id, oh, chk_proxy, chk_flags) < 0)
+ if(chk_proxy && H5O_chunk_unprotect(f, dxpl_id, oh, chk_proxy, chk_dirtied) < 0)
HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk")
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5Opkg.h b/src/H5Opkg.h
index 61d295a..2298935 100644
--- a/src/H5Opkg.h
+++ b/src/H5Opkg.h
@@ -547,6 +547,7 @@ H5_DLL H5O_chunk_proxy_t *H5O_chunk_protect(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
H5_DLL herr_t H5O_chunk_unprotect(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
H5O_chunk_proxy_t *chk_proxy, unsigned chk_flags);
H5_DLL herr_t H5O_chunk_update_idx(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx);
+H5_DLL herr_t H5O_chunk_resize(H5O_t *oh, H5O_chunk_proxy_t *chk_proxy);
H5_DLL herr_t H5O_chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx);
/* Collect storage info for btree and heap */