diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2010-05-27 22:57:29 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2010-05-27 22:57:29 (GMT) |
commit | e4246519c9d59a5f837f2b1009471533b729b778 (patch) | |
tree | 0ed23bfb58157edccfa11487a6c9f293b9e97670 /src/H5HL.c | |
parent | fc3de1ec794584b1bdc6e615d8d2afc15f5bb5ec (diff) | |
download | hdf5-e4246519c9d59a5f837f2b1009471533b729b778.zip hdf5-e4246519c9d59a5f837f2b1009471533b729b778.tar.gz hdf5-e4246519c9d59a5f837f2b1009471533b729b778.tar.bz2 |
[svn-r18920] Description:
Bring r18917 from trunk to 1.8 branch:
Bring r18911 (plus some adaptions to match the code on the trunk)
from the metadata journaling "merging" branch to the trunk:
More general changes to align trunk with eventual changes from
metadata journaling branch.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Diffstat (limited to 'src/H5HL.c')
-rw-r--r-- | src/H5HL.c | 24 |
1 files changed, 16 insertions, 8 deletions
@@ -210,6 +210,7 @@ H5HL_dblk_realloc(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t new_heap_size) H5HL_dblk_t *dblk; /* Local heap data block */ haddr_t old_addr; /* Old location of heap data block */ haddr_t new_addr; /* New location of heap data block */ + size_t old_heap_size; /* Old size of heap data block */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5HL_dblk_realloc) @@ -220,8 +221,9 @@ H5HL_dblk_realloc(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t new_heap_size) /* Release old space on disk */ old_addr = heap->dblk_addr; - H5_CHECK_OVERFLOW(heap->dblk_size, size_t, hsize_t); - if(H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, old_addr, (hsize_t)heap->dblk_size) < 0) + old_heap_size = heap->dblk_size; + H5_CHECK_OVERFLOW(old_heap_size, size_t, hsize_t); + if(H5MF_xfree(f, H5FD_MEM_LHEAP, dxpl_id, old_addr, (hsize_t)old_heap_size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "can't release old heap data?") /* Allocate new space on disk */ @@ -229,12 +231,16 @@ H5HL_dblk_realloc(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t new_heap_size) if(HADDR_UNDEF == (new_addr = H5MF_alloc(f, H5FD_MEM_LHEAP, dxpl_id, (hsize_t)new_heap_size))) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "unable to allocate file space for heap") + /* Update heap info*/ + heap->dblk_addr = new_addr; + heap->dblk_size = new_heap_size; + /* Check if heap data block actually moved in the file */ if(H5F_addr_eq(old_addr, new_addr)) { /* Check if heap data block is contiguous w/prefix */ if(heap->single_cache_obj) { /* Sanity check */ - HDassert(H5F_addr_eq(heap->prfx_addr + heap->prfx_size, heap->dblk_addr)); + HDassert(H5F_addr_eq(heap->prfx_addr + heap->prfx_size, old_addr)); HDassert(heap->prfx); /* Resize the heap prefix in the cache */ @@ -243,7 +249,7 @@ H5HL_dblk_realloc(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t new_heap_size) } /* end if */ else { /* Sanity check */ - HDassert(H5F_addr_ne(heap->prfx_addr + heap->prfx_size, heap->dblk_addr)); + HDassert(H5F_addr_ne(heap->prfx_addr + heap->prfx_size, old_addr)); HDassert(heap->dblk); /* Resize the heap data block in the cache */ @@ -285,11 +291,13 @@ H5HL_dblk_realloc(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t new_heap_size) } /* end else */ } /* end else */ - /* Update heap info*/ - heap->dblk_addr = new_addr; - heap->dblk_size = new_heap_size; - done: + if(ret_value < 0) { + /* Restore old heap address & size */ + heap->dblk_addr = old_addr; + heap->dblk_size = old_heap_size; + } /* end if */ + FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL_dblk_realloc() */ |