diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2009-06-18 18:37:49 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2009-06-18 18:37:49 (GMT) |
commit | ed7658df795092d7bd50705cae4319adb5985289 (patch) | |
tree | 78f3a1eb1e2fc5da697be2655b2f824710e5a6e1 /src/H5MFaggr.c | |
parent | 879d58b86bacd743e75d78bed2c54f549aeb0a9d (diff) | |
download | hdf5-ed7658df795092d7bd50705cae4319adb5985289.zip hdf5-ed7658df795092d7bd50705cae4319adb5985289.tar.gz hdf5-ed7658df795092d7bd50705cae4319adb5985289.tar.bz2 |
[svn-r17085] Description:
Bring r17002:17084 from trunk to revise_chunks 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/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.5.7 (amazon) in debug mode
Mac OS X/32 10.5.7 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
Diffstat (limited to 'src/H5MFaggr.c')
-rw-r--r-- | src/H5MFaggr.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/H5MFaggr.c b/src/H5MFaggr.c index f383e23..0f8a374 100644 --- a/src/H5MFaggr.c +++ b/src/H5MFaggr.c @@ -119,6 +119,9 @@ HDfprintf(stderr, "%s: type = %u, size = %Hu\n", FUNC, (unsigned)type, size); HDassert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES); HDassert(size > 0); + if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, type))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, HADDR_UNDEF, "Unable to get eoa") + /* * If the aggregation feature is enabled for this file, allocate "generic" * space and sub-allocate out of that, if possible. Otherwise just allocate @@ -138,9 +141,6 @@ HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_siz frag_size = alignment - mis_align; } - if (HADDR_UNDEF == (eoa = H5F_get_eoa(f, type))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "Unable to get eoa") - alloc_type = aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA ? H5FD_MEM_DEFAULT : H5FD_MEM_DRAW; other_alloc_type = other_aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA ? H5FD_MEM_DEFAULT : H5FD_MEM_DRAW; @@ -149,9 +149,12 @@ HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_siz /* Check if the block asked for is too large for 'normal' aggregator block */ if(size >= aggr->alloc_size) { - hsize_t ext_size = size + frag_size; + /* Check for overlapping into file's temporary allocation space */ + if(H5F_addr_gt((aggr->addr + aggr->size + ext_size), f->shared->tmp_addr)) + HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space") + if ((aggr->addr > 0) && (extended=H5FD_try_extend(f->shared->lf, alloc_type, aggr->addr + aggr->size, ext_size)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't extending space") else if (extended) { @@ -160,6 +163,10 @@ HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_siz aggr->addr += ext_size; aggr->tot_size += ext_size; } else { + /* Check for overlapping into file's temporary allocation space */ + if(H5F_addr_gt((eoa + size), f->shared->tmp_addr)) + HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space") + if ((other_aggr->size > 0) && (H5F_addr_eq((other_aggr->addr + other_aggr->size), eoa)) && ((other_aggr->tot_size - other_aggr->size) >= other_aggr->alloc_size)) { @@ -189,6 +196,10 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC); if (frag_size > (ext_size - size)) ext_size += (frag_size - (ext_size - size)); + /* Check for overlapping into file's temporary allocation space */ + if(H5F_addr_gt((aggr->addr + aggr->size + ext_size), f->shared->tmp_addr)) + HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space") + if ((aggr->addr > 0) && (extended = H5FD_try_extend(f->shared->lf, alloc_type, aggr->addr + aggr->size, ext_size)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't extending space") else if (extended) { @@ -196,6 +207,10 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC); aggr->size += (ext_size - frag_size); aggr->tot_size += ext_size; } else { + /* Check for overlapping into file's temporary allocation space */ + if(H5F_addr_gt((eoa + aggr->alloc_size), f->shared->tmp_addr)) + HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space") + if ((other_aggr->size > 0) && (H5F_addr_eq((other_aggr->addr + other_aggr->size), eoa)) && ((other_aggr->tot_size - other_aggr->size) >= other_aggr->alloc_size)) { @@ -250,6 +265,10 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC); } } /* end if */ else { + /* Check for overlapping into file's temporary allocation space */ + if(H5F_addr_gt((eoa + size), f->shared->tmp_addr)) + HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space") + /* Allocate data from the file */ if(HADDR_UNDEF == (ret_value = H5FD_alloc(f->shared->lf, dxpl_id, type, size, &eoa_frag_addr, &eoa_frag_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space") @@ -258,6 +277,9 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC); HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, HADDR_UNDEF, "can't free eoa fragment") } /* end else */ + /* Sanity check for overlapping into file's temporary allocation space */ + HDassert(H5F_addr_le((ret_value + size), f->shared->tmp_addr)); + done: #ifdef H5MF_AGGR_DEBUG HDfprintf(stderr, "%s: ret_value = %a\n", FUNC, ret_value); |