diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2009-06-18 17:20:50 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2009-06-18 17:20:50 (GMT) |
commit | b6cfe32b73a7fd3e4c9ace7bcec1e27156db67d3 (patch) | |
tree | 16da916bf11f5972e4383b079fb9788082646c65 /src/H5MF.c | |
parent | 79a41596f50a0c7dee47203af389b8647dfdb963 (diff) | |
download | hdf5-b6cfe32b73a7fd3e4c9ace7bcec1e27156db67d3.zip hdf5-b6cfe32b73a7fd3e4c9ace7bcec1e27156db67d3.tar.gz hdf5-b6cfe32b73a7fd3e4c9ace7bcec1e27156db67d3.tar.bz2 |
[svn-r17083] Description:
Bring r17010,17017,17021-17022,17029-17031,17035 back from trunk:
"temporary" file allocation space changes.
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/H5MF.c')
-rw-r--r-- | src/H5MF.c | 75 |
1 files changed, 73 insertions, 2 deletions
@@ -302,6 +302,8 @@ HDfprintf(stderr, "%s: alloc_type = %u, size = %Hu\n", FUNC, (unsigned)alloc_typ /* check arguments */ HDassert(f); + HDassert(f->shared); + HDassert(f->shared->lf); HDassert(size > 0); /* Get free space type from allocation type */ @@ -374,14 +376,17 @@ HDfprintf(stderr, "%s: Check 2.0\n", FUNC); if(alloc_type != H5FD_MEM_DRAW) { /* Handle metadata differently from "raw" data */ if(HADDR_UNDEF == (ret_value = H5MF_aggr_alloc(f, dxpl_id, &(f->shared->meta_aggr), &(f->shared->sdata_aggr), alloc_type, size))) - HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate metadata") + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate metadata") } /* end if */ else { /* Allocate "raw" data */ if(HADDR_UNDEF == (ret_value = H5MF_aggr_alloc(f, dxpl_id, &(f->shared->sdata_aggr), &(f->shared->meta_aggr), alloc_type, size))) - HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate raw data") + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate raw data") } /* 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_ALLOC_DEBUG HDfprintf(stderr, "%s: Leaving: ret_value = %a, size = %Hu\n", FUNC, ret_value, size); @@ -394,6 +399,66 @@ H5MF_sects_dump(f, dxpl_id, stderr); /*------------------------------------------------------------------------- + * Function: H5MF_alloc_tmp + * + * Purpose: Allocate temporary space in the file + * + * Note: The address returned is non-overlapping with any other address + * in the file and suitable for insertion into the metadata + * cache. + * + * The address is _not_ suitable for actual file I/O and will + * cause an error if it is so used. + * + * The space allocated with this routine should _not_ be freed, + * it should just be abandoned. Calling H5MF_xfree() with space + * from this routine will cause an error. + * + * Return: Success: Temporary file address + * Failure: HADDR_UNDEF + * + * Programmer: Quincey Koziol + * Thursday, June 4, 2009 + * + *------------------------------------------------------------------------- + */ +haddr_t +H5MF_alloc_tmp(H5F_t *f, hsize_t size) +{ + haddr_t eoa; /* End of allocated space in the file */ + haddr_t ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(H5MF_alloc_tmp, HADDR_UNDEF) +#ifdef H5MF_ALLOC_DEBUG +HDfprintf(stderr, "%s: size = %Hu\n", FUNC, size); +#endif /* H5MF_ALLOC_DEBUG */ + + /* check args */ + HDassert(f); + HDassert(f->shared); + HDassert(f->shared->lf); + HDassert(size > 0); + + /* Retrieve the 'eoa' for the file */ + if(HADDR_UNDEF == (eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, HADDR_UNDEF, "driver get_eoa request failed") + + /* Compute value to return */ + ret_value = f->shared->tmp_addr - size; + + /* Check for overlap into the actual allocated space in the file */ + if(H5F_addr_le(ret_value, eoa)) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, HADDR_UNDEF, "driver get_eoa request failed") + + /* Adjust temporary address allocator in the file */ + f->shared->tmp_addr = ret_value; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5MF_alloc_tmp() */ + + +/*------------------------------------------------------------------------- * Function: H5MF_xfree * * Purpose: Frees part of a file, making that part of the file @@ -427,6 +492,10 @@ HDfprintf(stderr, "%s: Entering - alloc_type = %u, addr = %a, size = %Hu\n", FUN HGOTO_DONE(SUCCEED); HDassert(addr != 0); /* Can't deallocate the superblock :-) */ + /* Check for attempting to free space that's a 'temporary' file address */ + if(H5F_addr_le(f->shared->tmp_addr, addr)) + HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, FAIL, "attempting to free temporary file space") + /* Check if the space to free intersects with the file's metadata accumulator */ if(H5F_accum_free(f, dxpl_id, alloc_type, addr, size) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "can't check free space intersection w/metadata accumulator") @@ -701,6 +770,8 @@ HDfprintf(stderr, "%s: Entering - alloc_type = %u, addr = %a, size = %Hu\n", FUN /* check arguments */ HDassert(f); + HDassert(f->shared); + HDassert(f->shared->lf); HDassert(H5F_addr_defined(addr)); HDassert(size > 0); |