diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2009-12-20 00:32:48 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2009-12-20 00:32:48 (GMT) |
commit | 2b82a5fff3afb64811aa38ceb8ee8743cabdddc6 (patch) | |
tree | 5213ed97a2b8b0987294f5670ed51696f80f0cd1 /src | |
parent | a7b48fec30b180f5c96cf9601a29ce3f7729f6bb (diff) | |
download | hdf5-2b82a5fff3afb64811aa38ceb8ee8743cabdddc6.zip hdf5-2b82a5fff3afb64811aa38ceb8ee8743cabdddc6.tar.gz hdf5-2b82a5fff3afb64811aa38ceb8ee8743cabdddc6.tar.bz2 |
[svn-r18044] Description:
Slush changes back & forth between trunk, the merging branch and the
metadata journaling branch to level them out to a reasonably common set of code
to work from for the next set of more significant changes.
Tested on:
Mac OS X/32 10.6.2 (amazon) w/debug
(h5committest not required on this branch)
Diffstat (limited to 'src')
-rw-r--r-- | src/H5HGcache.c | 16 | ||||
-rw-r--r-- | src/H5HL.c | 44 | ||||
-rw-r--r-- | src/H5HLcache.c | 20 | ||||
-rw-r--r-- | src/H5HLdbg.c | 5 | ||||
-rw-r--r-- | src/H5HLpkg.h | 1 |
5 files changed, 36 insertions, 50 deletions
diff --git a/src/H5HGcache.c b/src/H5HGcache.c index 64a63b5..0403521 100644 --- a/src/H5HGcache.c +++ b/src/H5HGcache.c @@ -120,7 +120,7 @@ H5HG_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * udata1, uint8_t *p = NULL; size_t nalloc, need; size_t max_idx = 0; /* The maximum index seen */ - H5HG_heap_t *ret_value = NULL; /* Return value */ + H5HG_heap_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5HG_load, NULL) @@ -130,12 +130,12 @@ H5HG_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * udata1, HDassert(!udata1); HDassert(!udata2); - /* Read the initial 4k page */ + /* Allocate space for heap */ if(NULL == (heap = H5FL_CALLOC(H5HG_heap_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed") heap->addr = addr; if(NULL == (heap->chunk = H5FL_BLK_MALLOC(gheap_chunk, (size_t)H5HG_MINSIZE))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed") if(H5F_block_read(f, H5FD_MEM_GHEAP, addr, (size_t)H5HG_MINSIZE, dxpl_id, heap->chunk) < 0) HGOTO_ERROR(H5E_HEAP, H5E_READERROR, NULL, "unable to read global heap collection") @@ -163,7 +163,7 @@ H5HG_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * udata1, haddr_t next_addr = addr + (hsize_t)H5HG_MINSIZE; if(NULL == (heap->chunk = H5FL_BLK_REALLOC(gheap_chunk, heap->chunk, heap->size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed") if(H5F_block_read(f, H5FD_MEM_GHEAP, next_addr, (heap->size - H5HG_MINSIZE), dxpl_id, heap->chunk + H5HG_MINSIZE) < 0) HGOTO_ERROR(H5E_HEAP, H5E_READERROR, NULL, "unable to read global heap collection") } /* end if */ @@ -176,7 +176,7 @@ H5HG_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * udata1, * about the order of the objects, and unused slots must be set to zero. */ if(NULL == (heap->obj = H5FL_SEQ_CALLOC(H5HG_obj_t, nalloc))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed") heap->nalloc = nalloc; while(p < (heap->chunk + heap->size)) { @@ -207,7 +207,7 @@ H5HG_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * udata1, /* Reallocate array of objects */ if(NULL == (new_obj = H5FL_SEQ_REALLOC(H5HG_obj_t, heap->obj, new_alloc))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed") /* Clear newly allocated space */ HDmemset(&new_obj[heap->nalloc], 0, (new_alloc - heap->nalloc) * sizeof(heap->obj[0])); @@ -261,7 +261,7 @@ H5HG_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * udata1, if(!f->shared->cwfs) { f->shared->cwfs = (H5HG_heap_t **)H5MM_malloc(H5HG_NCWFS * sizeof(H5HG_heap_t *)); if(NULL == f->shared->cwfs) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed") f->shared->ncwfs = 1; f->shared->cwfs[0] = heap; } else if(H5HG_NCWFS == f->shared->ncwfs) { @@ -470,7 +470,7 @@ H5HL_remove_free(H5HL_t *heap, H5HL_free_t *fl) * * Return: Success: Offset of new item within heap. * - * Failure: (size_t)(-1) + * Failure: UFAIL * * Programmer: Robb Matzke * matzke@llnl.gov @@ -549,9 +549,9 @@ H5HL_insert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t buf_size, const void * * free chunk. If the heap must expand, we double its size. */ if(found == FALSE) { - size_t need_more; /* How much more space we need */ - size_t new_heap_alloc; /* Final size of space allocated for heap */ - htri_t can_extend; /* Whether the local heap's data segment on disk can be extended */ + size_t need_more; /* How much more space we need */ + size_t new_heap_alloc; /* Final size of space allocated for heap */ + htri_t can_extend; /* Whether the local heap's data segment on disk can be extended */ /* At least double the heap's size, making certain there's enough room * for the new object */ @@ -584,22 +584,13 @@ H5HL_insert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t buf_size, const void * HGOTO_ERROR(H5E_HEAP, H5E_CANTEXTEND, UFAIL, "can't extend heap on disk") } /* end if */ else { /* ...if we can't, allocate a new chunk & release the old */ - haddr_t new_addr; - - /* The new allocation may fail -- to avoid the possiblity of - * file corruption, allocate the new heap first, and then - * deallocate the old. - */ + /* Release old space on disk */ + if(H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, heap->addr, (hsize_t)heap->heap_alloc) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, UFAIL, "unable to free local heap") /* allocate new disk space for the heap */ - if((new_addr = H5MF_alloc(f, H5FD_MEM_LHEAP, dxpl_id, (hsize_t)new_heap_alloc)) == HADDR_UNDEF) + if((heap->addr = H5MF_alloc(f, H5FD_MEM_LHEAP, dxpl_id, (hsize_t)new_heap_alloc)) == HADDR_UNDEF) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, UFAIL, "unable to allocate file space for heap") - - /* Release old space on disk */ - H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, heap->addr, (hsize_t)heap->heap_alloc); - H5E_clear_stack(NULL); /* don't really care if the free failed */ - - heap->addr = new_addr; } /* end else */ /* If the last free list in the heap is at the end of the heap, extend it */ @@ -631,7 +622,7 @@ H5HL_insert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t buf_size, const void * offset = heap->heap_alloc; if(need_more - need_size >= H5HL_SIZEOF_FREE(f)) { if(NULL == (fl = H5FL_MALLOC(H5HL_free_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, (size_t)(-1), "memory allocation failed") + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, UFAIL, "memory allocation failed") fl->offset = heap->heap_alloc + need_size; fl->size = need_more - need_size; HDassert(fl->offset == H5HL_ALIGN(fl->offset)); @@ -660,7 +651,7 @@ H5HL_insert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t buf_size, const void * #endif heap->heap_alloc = new_heap_alloc; if(NULL == (heap->chunk = H5FL_BLK_REALLOC(lheap_chunk, heap->chunk, (sizeof_hdr + heap->heap_alloc)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed") + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, UFAIL, "memory allocation failed") /* Clear new section so junk doesn't appear in the file */ /* (Avoid clearing section which will be overwritten with newly inserted data) */ @@ -852,7 +843,8 @@ done: herr_t H5HL_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr) { - H5HL_t *heap = NULL; + H5HL_t *heap = NULL; /* Local heap to delete */ + unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting heap */ size_t sizeof_hdr; /* Cache H5HL header size for file */ herr_t ret_value = SUCCEED; /* Return value */ @@ -870,7 +862,7 @@ H5HL_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load heap") /* Check if the heap is contiguous on disk */ - assert(!H5F_addr_overflow(addr,sizeof_hdr)); + HDassert(!H5F_addr_overflow(addr,sizeof_hdr)); if(H5F_addr_eq(heap->addr,addr+sizeof_hdr)) { /* Free the contiguous local heap in one call */ H5_CHECK_OVERFLOW(sizeof_hdr+heap->heap_alloc,size_t,hsize_t); @@ -889,15 +881,11 @@ H5HL_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free local heap data") } /* end else */ - /* Release the local heap metadata from the cache */ - if(H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, heap, H5AC__DIRTIED_FLAG | H5C__DELETED_FLAG) < 0) { - heap = NULL; - HGOTO_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release local heap") - } /* end if */ - heap = NULL; + /* Set the cache flags to delete the heap & free its file space */ + cache_flags |= H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG; done: - if(heap && H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, heap, H5AC__NO_FLAGS_SET) < 0) + if(heap && H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, heap, cache_flags) < 0) HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release local heap") FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5HLcache.c b/src/H5HLcache.c index 6d17398..f9ead01 100644 --- a/src/H5HLcache.c +++ b/src/H5HLcache.c @@ -208,19 +208,19 @@ H5HL_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * udata1, /* Check magic number */ if(HDmemcmp(hdr, H5HL_MAGIC, (size_t)H5HL_SIZEOF_MAGIC)) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "bad heap signature") + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, NULL, "bad heap signature") p += H5HL_SIZEOF_MAGIC; /* Version */ if(H5HL_VERSION != *p++) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "wrong version number in global heap") + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, NULL, "wrong version number in global heap") /* Reserved */ p += 3; /* Allocate space in memory for the heap */ if(NULL == (heap = H5FL_CALLOC(H5HL_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed") /* heap data size */ H5F_DECODE_LENGTH(f, p, heap->heap_alloc); @@ -228,22 +228,22 @@ H5HL_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * udata1, /* free list head */ H5F_DECODE_LENGTH(f, p, free_block); if(free_block != H5HL_FREE_NULL && free_block >= heap->heap_alloc) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "bad heap free list") + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, NULL, "bad heap free list") /* data */ H5F_addr_decode(f, &p, &(heap->addr)); if(NULL == (heap->chunk = H5FL_BLK_CALLOC(lheap_chunk, (sizeof_hdr + heap->heap_alloc)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed") if(heap->heap_alloc && H5F_block_read(f, H5FD_MEM_LHEAP, heap->addr, heap->heap_alloc, dxpl_id, heap->chunk + sizeof_hdr) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "unable to read heap data") + HGOTO_ERROR(H5E_HEAP, H5E_READERROR, NULL, "unable to read heap data") /* Build free list */ while(H5HL_FREE_NULL != free_block) { if(free_block >= heap->heap_alloc) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "bad heap free list") + HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, NULL, "bad heap free list") if(NULL == (fl = H5FL_MALLOC(H5HL_free_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed") fl->offset = free_block; fl->prev = tail; fl->next = NULL; @@ -257,11 +257,11 @@ H5HL_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * udata1, H5F_DECODE_LENGTH(f, p, free_block); if(free_block == 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "free block size is zero?") + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, NULL, "free block size is zero?") H5F_DECODE_LENGTH(f, p, fl->size); if(fl->offset + fl->size > heap->heap_alloc) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "bad heap free list") + HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, NULL, "bad heap free list") } /* end while */ /* Set return value */ diff --git a/src/H5HLdbg.c b/src/H5HLdbg.c index 28fe277..6bf35ad 100644 --- a/src/H5HLdbg.c +++ b/src/H5HLdbg.c @@ -22,7 +22,6 @@ #include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ #include "H5Eprivate.h" /* Error handling */ #include "H5HLpkg.h" /* Local heaps */ #include "H5Iprivate.h" /* ID Functions */ @@ -70,7 +69,7 @@ H5HL_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int HDassert(indent >= 0); HDassert(fwidth >= 0); - if(NULL == (h = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_READ))) + if(NULL == (h = (H5HL_t *)H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap") fprintf(stream, "%*sLocal Heap...\n", indent, ""); @@ -92,7 +91,7 @@ H5HL_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int * the heap and that no two free blocks point to the same region of * the heap. */ if(NULL == (marker = (uint8_t *)H5MM_calloc(h->heap_alloc))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed") fprintf(stream, "%*sFree Blocks (offset, size):\n", indent, ""); diff --git a/src/H5HLpkg.h b/src/H5HLpkg.h index 856010c..e2e0c86 100644 --- a/src/H5HLpkg.h +++ b/src/H5HLpkg.h @@ -32,7 +32,6 @@ #include "H5HLprivate.h" /* Other private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata cache */ #include "H5FLprivate.h" /* Free lists */ |