summaryrefslogtreecommitdiffstats
path: root/src/H5FDspace.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-08-15 06:26:08 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-08-15 06:26:08 (GMT)
commit173083e1a5c9696be01bd983dd8c9bb87eb5a433 (patch)
treec8c4aa2dd961d18b48d0c734da3e16ea107e6c6f /src/H5FDspace.c
parentec7ca0dea2fba8071ce57e4f61d685c3e4d0d111 (diff)
downloadhdf5-173083e1a5c9696be01bd983dd8c9bb87eb5a433.zip
hdf5-173083e1a5c9696be01bd983dd8c9bb87eb5a433.tar.gz
hdf5-173083e1a5c9696be01bd983dd8c9bb87eb5a433.tar.bz2
[svn-r17365] Description:
Final merge of changes from sblock_mdc branch back to trunk. The superblock is now managed by the metadata cache. 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 (kagiso) 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 production mode Mac OS X/32 10.5.8 (amazon) in debug mode Mac OS X/32 10.5.8 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'src/H5FDspace.c')
-rw-r--r--src/H5FDspace.c142
1 files changed, 115 insertions, 27 deletions
diff --git a/src/H5FDspace.c b/src/H5FDspace.c
index 0fadc1e..5526b03 100644
--- a/src/H5FDspace.c
+++ b/src/H5FDspace.c
@@ -42,7 +42,6 @@
#include "H5Fprivate.h" /* File access */
#include "H5FDpkg.h" /* File Drivers */
#include "H5FDmulti.h" /* Usage-partitioned file family */
-#include "H5MMprivate.h" /* Memory management */
/****************/
@@ -122,10 +121,6 @@ H5FD_space_init_interface(void)
* Programmer: Bill Wendling
* Wednesday, 04. December, 2002
*
- * Modifications:
- * Vailin Choi, 29th July 2008
- * Add 2 more parameters for handling alignment: address and size of the fragment
- *
*-------------------------------------------------------------------------
*/
static haddr_t
@@ -180,9 +175,9 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_alloc
+ * Function: H5FD_alloc_real
*
- * Purpose: Private version of H5FDalloc().
+ * Purpose: Allocate space in the file with the VFD
*
* Return: Success: The format address of the new file memory.
* Failure: The undefined address HADDR_UNDEF
@@ -190,18 +185,14 @@ done:
* Programmer: Robb Matzke
* Wednesday, August 4, 1999
*
- * Modification:
- * Vailin Choi, 29th July 2008
- * Add two more parameters () for handling alignment: address & size of the fragment
- *
*-------------------------------------------------------------------------
*/
haddr_t
-H5FD_alloc(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size)
+H5FD_alloc_real(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size)
{
- haddr_t ret_value = HADDR_UNDEF;
+ haddr_t ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5FD_alloc, HADDR_UNDEF)
+ FUNC_ENTER_NOAPI(H5FD_alloc_real, HADDR_UNDEF)
#ifdef H5FD_ALLOC_DEBUG
HDfprintf(stderr, "%s: type = %u, size = %Hu\n", FUNC, (unsigned)type, size);
#endif /* H5FD_ALLOC_DEBUG */
@@ -230,13 +221,59 @@ done:
HDfprintf(stderr, "%s: ret_value = %a\n", FUNC, ret_value);
#endif /* H5FD_ALLOC_DEBUG */
FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FD_alloc_real() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5FD_alloc
+ *
+ * Purpose: Wrapper for H5FD_alloc, to make certain EOA changes are
+ * reflected in superblock.
+ *
+ * Note: When the metadata cache routines are updated to allow
+ * marking an entry dirty without a H5F_t*, this routine should
+ * be changed to take a H5F_super_t* directly.
+ *
+ * Return: Success: The format address of the new file memory.
+ * Failure: The undefined address HADDR_UNDEF
+ *
+ * Programmer: Quincey Koziol
+ * Friday, August 14, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+haddr_t
+H5FD_alloc(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, H5F_t *f, hsize_t size,
+ haddr_t *frag_addr, hsize_t *frag_size)
+{
+ haddr_t ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5FD_alloc, HADDR_UNDEF)
+
+ /* check args */
+ HDassert(file);
+ HDassert(file->cls);
+ HDassert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES);
+ HDassert(size > 0);
+
+ /* Call the real 'alloc' routine */
+ ret_value = H5FD_alloc_real(file, dxpl_id, type, size, frag_addr, frag_size);
+ if(!H5F_addr_defined(ret_value))
+ HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, HADDR_UNDEF, "real 'alloc' request failed")
+
+ /* Mark superblock dirty in cache, so change to EOA will get encoded */
+ if(H5F_super_dirty(f) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTMARKDIRTY, HADDR_UNDEF, "unable to mark superblock as dirty")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD_alloc() */
/*-------------------------------------------------------------------------
- * Function: H5FD_free
+ * Function: H5FD_free_real
*
- * Purpose: Private version of H5FDfree()
+ * Purpose: Release space back to the VFD
*
* Return: Success: Non-negative
* Failure: Negative
@@ -247,11 +284,11 @@ HDfprintf(stderr, "%s: ret_value = %a\n", FUNC, ret_value);
*-------------------------------------------------------------------------
*/
herr_t
-H5FD_free(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, hsize_t size)
+H5FD_free_real(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, haddr_t addr, hsize_t size)
{
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5FD_free, FAIL)
+ FUNC_ENTER_NOAPI_NOINIT(H5FD_free_real)
/* Check args */
HDassert(file);
@@ -265,14 +302,14 @@ HDfprintf(stderr, "%s: type = %u, addr = %a, size = %Hu\n", FUNC, (unsigned)type
/* Sanity checking */
if(!H5F_addr_defined(addr))
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file offset")
+ HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid file offset")
/* Convert address to absolute file offset */
addr += file->base_addr;
/* More sanity checking */
if(addr > file->maxaddr || H5F_addr_overflow(addr, size) || (addr + size) > file->maxaddr)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file free space region to free")
+ HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid file free space region to free")
/* Check for file driver 'free' callback and call it if available */
if(file->cls->free) {
@@ -309,6 +346,51 @@ HDfprintf(stderr, "%s: LEAKED MEMORY!!! type = %u, addr = %a, size = %Hu\n", FUN
done:
FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FD_free_real() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5FD_free
+ *
+ * Purpose: Wrapper for H5FD_free_real, to make certain EOA changes are
+ * reflected in superblock.
+ *
+ * Note: When the metadata cache routines are updated to allow
+ * marking an entry dirty without a H5F_t*, this routine should
+ * be changed to take a H5F_super_t* directly.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Friday, August 14, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5FD_free(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, H5F_t *f, haddr_t addr,
+ hsize_t size)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5FD_free, FAIL)
+
+ /* Check args */
+ HDassert(file);
+ HDassert(file->cls);
+ HDassert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES);
+ HDassert(size > 0);
+
+ /* Call the real 'free' routine */
+ if(H5FD_free_real(file, dxpl_id, type, addr, size) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "real 'free' request failed")
+
+ /* Mark superblock dirty in cache, so change to EOA will get encoded */
+ if(H5F_super_dirty(f) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD_free() */
@@ -317,6 +399,10 @@ done:
*
* Purpose: Extend a block at the end of the file, if possible.
*
+ * Note: When the metadata cache routines are updated to allow
+ * marking an entry dirty without a H5F_t*, this routine should
+ * be changed to take a H5F_super_t* directly.
+ *
* Return: Success: TRUE(1) - Block was extended
* FALSE(0) - Block could not be extended
* Failure: FAIL
@@ -324,14 +410,11 @@ done:
* Programmer: Quincey Koziol
* Thursday, 17. January, 2008
*
- * Modification:
- * Vailin Choi, 29th July 2008
- * Two more parameters were added to FD_extend() for handling alignment
- *
*-------------------------------------------------------------------------
*/
htri_t
-H5FD_try_extend(H5FD_t *file, H5FD_mem_t type, haddr_t blk_end, hsize_t extra_requested)
+H5FD_try_extend(H5FD_t *file, H5FD_mem_t type, H5F_t *f, haddr_t blk_end,
+ hsize_t extra_requested)
{
haddr_t eoa; /* End of allocated space in file */
htri_t ret_value = FALSE; /* Return value */
@@ -343,10 +426,11 @@ H5FD_try_extend(H5FD_t *file, H5FD_mem_t type, haddr_t blk_end, hsize_t extra_re
HDassert(file->cls);
HDassert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES);
HDassert(extra_requested > 0);
+ HDassert(f);
/* Retrieve the end of the address space */
if(HADDR_UNDEF == (eoa = file->cls->get_eoa(file, type)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed")
+ HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "driver get_eoa request failed")
/* Adjust block end by base address of the file, to create absolute address */
blk_end += file->base_addr;
@@ -355,7 +439,11 @@ H5FD_try_extend(H5FD_t *file, H5FD_mem_t type, haddr_t blk_end, hsize_t extra_re
if(H5F_addr_eq(blk_end, eoa)) {
/* Extend the object by extending the underlying file */
if(HADDR_UNDEF == H5FD_extend(file, type, FALSE, extra_requested, NULL, NULL))
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "driver extend request failed")
+ HGOTO_ERROR(H5E_VFL, H5E_CANTEXTEND, FAIL, "driver extend request failed")
+
+ /* Mark superblock dirty in cache, so change to EOA will get encoded */
+ if(H5F_super_dirty(f) < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty")
/* Indicate success */
HGOTO_DONE(TRUE)