summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-08-11 12:47:43 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-08-11 12:47:43 (GMT)
commitbcb872eaaa7da3a726ff6f71921d3ba82577d597 (patch)
tree4d3a566d701c3a6e42d99447eb6de506e68d8fa8
parentda73cc2d02248c73cfa545a765d2d017cb0b1bff (diff)
downloadhdf5-bcb872eaaa7da3a726ff6f71921d3ba82577d597.zip
hdf5-bcb872eaaa7da3a726ff6f71921d3ba82577d597.tar.gz
hdf5-bcb872eaaa7da3a726ff6f71921d3ba82577d597.tar.bz2
[svn-r17319] Description:
Bring more superblock manipulation & aggregator changes from file free space 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 (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 Linux/64-amd64 2.6 (abe) 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
-rw-r--r--src/H5FS.c6
-rw-r--r--src/H5FSdbg.c2
-rw-r--r--src/H5FSprivate.h1
-rw-r--r--src/H5Fsuper.c167
-rw-r--r--src/H5MF.c145
-rw-r--r--src/H5MFaggr.c60
-rw-r--r--src/H5MFprivate.h1
7 files changed, 273 insertions, 109 deletions
diff --git a/src/H5FS.c b/src/H5FS.c
index 4282200..deb9378 100644
--- a/src/H5FS.c
+++ b/src/H5FS.c
@@ -386,9 +386,9 @@ HDfprintf(stderr, "%s: Real sections to store in file\n", FUNC);
HGOTO_ERROR(H5E_FSPACE, H5E_CANTMARKDIRTY, FAIL, "unable to mark free space header as dirty")
} /* end if */
} /* end if */
- else
- /* Sanity check that section info has address */
- HDassert(H5F_addr_defined(fspace->sect_addr));
+ else
+ /* Sanity check that section info has address */
+ HDassert(H5F_addr_defined(fspace->sect_addr));
/* Cache the free space section info */
if(H5AC_set(f, dxpl_id, H5AC_FSPACE_SINFO, fspace->sect_addr, fspace->sinfo, H5AC__NO_FLAGS_SET) < 0)
diff --git a/src/H5FSdbg.c b/src/H5FSdbg.c
index cf165ca..1e36c77 100644
--- a/src/H5FSdbg.c
+++ b/src/H5FSdbg.c
@@ -131,7 +131,7 @@ H5FS_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int
HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
"Free space client:",
(fspace->client == H5FS_CLIENT_FHEAP_ID ? "Fractal heap" :
- (fspace->client == H5FS_CLIENT_FILE_ID ? "File Memory Management" : "Unknown")));
+ (fspace->client == H5FS_CLIENT_FILE_ID ? "File" : "Unknown")));
HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth,
"Total free space tracked:",
fspace->tot_space);
diff --git a/src/H5FSprivate.h b/src/H5FSprivate.h
index 6f73b93..353f85f 100644
--- a/src/H5FSprivate.h
+++ b/src/H5FSprivate.h
@@ -149,7 +149,6 @@ typedef struct H5FS_stat_t {
hsize_t ghost_sect_count; /* # of un-serializable sections tracked */
} H5FS_stat_t;
-
/* Typedef for iteration operations */
typedef herr_t (*H5FS_operator_t)(const H5FS_section_info_t *sect,
void *operator_data/*in,out*/);
diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c
index 32541ae..6a72b57 100644
--- a/src/H5Fsuper.c
+++ b/src/H5Fsuper.c
@@ -110,6 +110,9 @@
/********************/
/* Local Prototypes */
/********************/
+static herr_t H5F_super_ext_create(H5F_t *f, hid_t dxpl_id, H5O_loc_t *ext_ptr);
+static herr_t H5F_super_ext_open(H5F_t *f, H5O_loc_t *ext_ptr);
+static herr_t H5F_super_ext_close(H5F_t *f, H5O_loc_t *ext_ptr);
/*********************/
@@ -214,6 +217,114 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5F_super_ext_create
+ *
+ * Purpose: Create the superblock extension
+ *
+ * Return: Success: non-negative on success
+ * Failure: Negative
+ *
+ * Programmer: Vailin Choi; Feb 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5F_super_ext_create(H5F_t *f, hid_t dxpl_id, H5O_loc_t *ext_ptr)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5F_super_ext_create)
+
+ /* Sanity check */
+ HDassert(f);
+ HDassert(ext_ptr);
+ HDassert(!H5F_addr_defined(f->shared->extension_addr));
+
+ H5O_loc_reset(ext_ptr);
+ if(H5O_create(f, dxpl_id, 0, H5P_GROUP_CREATE_DEFAULT, ext_ptr) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "unable to create superblock extension")
+
+ /* Record the address of the superblock extension */
+ f->shared->extension_addr = ext_ptr->addr;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5F_super_ext_create() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5F_super_ext_open
+ *
+ * Purpose: Open an existing superblock extension
+ *
+ * Return: Success: non-negative on success
+ * Failure: Negative
+ *
+ * Programmer: Vailin Choi; Feb 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5F_super_ext_open(H5F_t *f, H5O_loc_t *ext_ptr)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5F_super_ext_open)
+
+ /* Sanity check */
+ HDassert(f);
+ HDassert(ext_ptr);
+ HDassert(H5F_addr_defined(f->shared->extension_addr));
+
+ /* Set up "fake" object location for superblock extension */
+ H5O_loc_reset(ext_ptr);
+ ext_ptr->file = f;
+ ext_ptr->addr = f->shared->extension_addr;
+
+ /* Open the superblock extension object header */
+ if(H5O_open(ext_ptr) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENFILE, FAIL, "unable to open superblock extension")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5F_super_ext_open() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5F_super_ext_close
+ *
+ * Purpose: Close superblock extension
+ *
+ * Return: Success: non-negative on success
+ * Failure: Negative
+ *
+ * Programmer: Vailin Choi; Feb 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5F_super_ext_close(H5F_t *f, H5O_loc_t *ext_ptr)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5F_super_ext_close)
+
+ /* Sanity check */
+ HDassert(f);
+ HDassert(ext_ptr);
+
+ /* Twiddle the number of open objects to avoid closing the file. */
+ f->nopen_objs++;
+ if(H5O_close(ext_ptr) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close superblock extension")
+ f->nopen_objs--;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5F_super_ext_close() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5F_super_read
*
* Purpose: Reads the superblock from the file or from the BUF. If
@@ -584,14 +695,9 @@ H5F_super_read(H5F_t *f, hid_t dxpl_id)
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to set end-of-address marker for file")
} /* end if */
- /* Set up "fake" object location for superblock extension */
- H5O_loc_reset(&ext_loc);
- ext_loc.file = f;
- ext_loc.addr = shared->extension_addr;
-
/* Open the superblock extension */
- if(H5O_open(&ext_loc) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to open superblock extension")
+ if(H5F_super_ext_open(f, &ext_loc) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, FAIL, "unable to start file's superblock extension")
/* Check for the extension having a 'driver info' message */
if((status = H5O_msg_exists(&ext_loc, H5O_DRVINFO_ID, dxpl_id)) < 0)
@@ -647,13 +753,9 @@ H5F_super_read(H5F_t *f, hid_t dxpl_id)
shared->sym_leaf_k = H5F_CRT_SYM_LEAF_DEF;
} /* end if */
- /* Close the extension. Twiddle the number of open objects to avoid
- * closing the file (since this will be the only open object).
- */
- f->nopen_objs++;
- if(H5O_close(&ext_loc) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENFILE, FAIL, "unable to close superblock extension")
- f->nopen_objs--;
+ /* Close superblock extension */
+ if(H5F_super_ext_close(f, &ext_loc) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to close file's superblock extension")
} /* end if */
done:
@@ -789,12 +891,8 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id)
* be tuned if more information is added to the superblock
* extension.
*/
- H5O_loc_reset(&ext_loc);
- if(H5O_create(f, dxpl_id, 0, H5P_GROUP_CREATE_DEFAULT, &ext_loc) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "unable to create superblock extension")
-
- /* Record the address of the superblock extension */
- f->shared->extension_addr = ext_loc.addr;
+ if(H5F_super_ext_create(f, dxpl_id, &ext_loc) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to start file's superblock extension")
/* Create the Shared Object Header Message table and register it with
* the metadata cache, if this file supports shared messages.
@@ -838,13 +936,9 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id)
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update driver info header message")
} /* end if */
- /* Twiddle the number of open objects to avoid closing the file
- * (since this will be the only open object currently).
- */
- f->nopen_objs++;
- if(H5O_close(&ext_loc) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close superblock extension")
- f->nopen_objs--;
+ /* Close superblock extension */
+ if(H5F_super_ext_close(f, &ext_loc) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to close file's superblock extension")
} /* end if */
done:
@@ -1026,14 +1120,9 @@ H5F_super_write(H5F_t *f, hid_t dxpl_id)
if(H5FD_sb_encode(f->shared->lf, drvinfo.name, dbuf) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to encode driver information")
- /* Set up "fake" object location for superblock extension */
- H5O_loc_reset(&ext_loc);
- ext_loc.file = f;
- ext_loc.addr = f->shared->extension_addr;
-
/* Open the superblock extension */
- if(H5O_open(&ext_loc) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENFILE, FAIL, "unable to open superblock extension")
+ if(H5F_super_ext_open(f, &ext_loc) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, FAIL, "unable to start file's superblock extension")
/* Write driver info information to the superblock extension */
drvinfo.len = driver_size;
@@ -1041,13 +1130,9 @@ H5F_super_write(H5F_t *f, hid_t dxpl_id)
if(H5O_msg_write(&ext_loc, H5O_DRVINFO_ID, H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, &drvinfo, dxpl_id) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to update driver info header message")
- /* Close the extension. Twiddle the number of open objects to avoid
- * closing the file (since this will be the only open object).
- */
- f->nopen_objs++;
- if(H5O_close(&ext_loc) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENFILE, FAIL, "unable to close superblock extension")
- f->nopen_objs--;
+ /* Close superblock extension */
+ if(H5F_super_ext_close(f, &ext_loc) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to close file's superblock extension")
} /* end if */
} /* end if */
diff --git a/src/H5MF.c b/src/H5MF.c
index 637151e..7e4b6f9 100644
--- a/src/H5MF.c
+++ b/src/H5MF.c
@@ -372,20 +372,9 @@ HDfprintf(stderr, "%s: Check 1.7, re-adding node, node->sect_info.size = %Hu\n",
HDfprintf(stderr, "%s: Check 2.0\n", FUNC);
#endif /* H5MF_ALLOC_DEBUG_MORE */
- /* Couldn't find anything from the free space manager, go allocate some */
- 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_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_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));
+ /* Allocate from the metadata aggregator (or the VFD) */
+ if(HADDR_UNDEF == (ret_value = H5MF_aggr_vfd_alloc(f, alloc_type, dxpl_id, size)))
+ HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, HADDR_UNDEF, "allocation failed from aggr/vfd")
done:
#ifdef H5MF_ALLOC_DEBUG
@@ -569,14 +558,14 @@ HDfprintf(stderr, "%s: Before H5FS_sect_add()\n", FUNC);
#endif /* H5MF_ALLOC_DEBUG_MORE */
if(H5FS_sect_add(f, dxpl_id, f->shared->fs_man[fs_type], (H5FS_section_info_t *)node, H5FS_ADD_RETURNED_SPACE, &udata) < 0)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINSERT, FAIL, "can't add section to file free space")
+ node = NULL;
#ifdef H5MF_ALLOC_DEBUG_MORE
HDfprintf(stderr, "%s: After H5FS_sect_add()\n", FUNC);
#endif /* H5MF_ALLOC_DEBUG_MORE */
- node = NULL;
done:
- if(ret_value < 0 && node)
- /* On error, free section node allocated */
+ /* Release section node, if allocated and not added to section list or merged */
+ if(node)
if(H5MF_sect_simple_free((H5FS_section_info_t *)node) < 0)
HDONE_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't free simple section node")
@@ -695,10 +684,12 @@ H5MF_get_freespace(H5F_t *f, hid_t dxpl_id)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed")
/* Retrieve metadata aggregator info, if available */
- H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
+ if(H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size) < 0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query metadata aggregator stats")
/* Retrieve 'small data' aggregator info, if available */
- H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sda_addr, &sda_size);
+ if(H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sda_addr, &sda_size) < 0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query metadata aggregator stats")
/* Iterate over all the free space types that have managers and get each free list's space */
for(type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) {
@@ -808,6 +799,74 @@ HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value);
/*-------------------------------------------------------------------------
+ * Function: H5MF_free_aggrs
+ *
+ * Purpose: Reset a block aggregator, returning any space back to file
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Vailin Choi
+ * July 1st, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5MF_free_aggrs(H5F_t *f, hid_t dxpl_id)
+{
+ H5F_blk_aggr_t *first_aggr; /* First aggregator to reset */
+ H5F_blk_aggr_t *second_aggr; /* Second aggregator to reset */
+ haddr_t ma_addr = HADDR_UNDEF; /* Base "metadata aggregator" address */
+ hsize_t ma_size = 0; /* Size of "metadata aggregator" */
+ haddr_t sda_addr = HADDR_UNDEF; /* Base "small data aggregator" address */
+ hsize_t sda_size = 0; /* Size of "small data aggregator" */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5MF_free_aggrs, FAIL)
+
+ /* Check args */
+ HDassert(f);
+ HDassert(f->shared);
+ HDassert(f->shared->lf);
+
+ /* Retrieve metadata aggregator info, if available */
+ if(H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size) < 0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query metadata aggregator stats")
+
+ /* Retrieve 'small data' aggregator info, if available */
+ if(H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sda_addr, &sda_size) < 0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't query small data aggregator stats")
+
+ /* Make certain we release the aggregator that's later in the file first */
+ /* (so the file shrinks properly) */
+ if(H5F_addr_defined(ma_addr) && H5F_addr_defined(sda_addr)) {
+ if(H5F_addr_lt(ma_addr, sda_addr)) {
+ first_aggr = &(f->shared->sdata_aggr);
+ second_aggr = &(f->shared->meta_aggr);
+ } /* end if */
+ else {
+ first_aggr = &(f->shared->meta_aggr);
+ second_aggr = &(f->shared->sdata_aggr);
+ } /* end else */
+ } /* end if */
+ else {
+ first_aggr = &(f->shared->meta_aggr);
+ second_aggr = &(f->shared->sdata_aggr);
+ } /* end else */
+
+ /* Release the unused portion of the metadata and "small data" blocks back
+ * to the free lists in the file.
+ */
+ if(H5MF_aggr_reset(f, dxpl_id, first_aggr) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't reset metadata block")
+ if(H5MF_aggr_reset(f, dxpl_id, second_aggr) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't reset 'small data' block")
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5MF_free_aggrs() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5MF_close
*
* Purpose: Close the free space tracker(s) for a file
@@ -823,12 +882,6 @@ herr_t
H5MF_close(H5F_t *f, hid_t dxpl_id)
{
H5FD_mem_t type; /* Memory type for iteration */
- H5F_blk_aggr_t *first_aggr; /* First aggregator to reset */
- H5F_blk_aggr_t *second_aggr; /* Second aggregator to reset */
- haddr_t ma_addr = HADDR_UNDEF; /* Base "metadata aggregator" address */
- hsize_t ma_size = 0; /* Size of "metadata aggregator" */
- haddr_t sda_addr = HADDR_UNDEF; /* Base "small data aggregator" address */
- hsize_t sda_size = 0; /* Size of "small data aggregator" */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5MF_close, FAIL)
@@ -879,8 +932,8 @@ HDfprintf(stderr, "%s: Check 2.0 - f->shared->fs_man[%u] = %p, f->shared->fs_add
HDfprintf(stderr, "%s: Before deleting free space manager\n", FUNC);
#endif /* H5MF_ALLOC_DEBUG_MORE */
/* Delete free space manager for this type */
- if(H5FS_delete(f, dxpl_id, tmp_fs_addr) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "can't delete free space manager")
+ if(H5FS_delete(f, dxpl_id, tmp_fs_addr) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTFREE, FAIL, "can't delete free space manager")
/* Shift [back] to closed state */
HDassert(f->shared->fs_state[type] == H5F_FS_STATE_DELETING);
@@ -891,42 +944,8 @@ HDfprintf(stderr, "%s: Before deleting free space manager\n", FUNC);
} /* end if */
} /* end for */
- /* Retrieve metadata aggregator info, if available */
- H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size);
-#ifdef H5MF_ALLOC_DEBUG_MORE
-HDfprintf(stderr, "%s: ma_addr = %a, ma_size = %Hu, end of ma = %a\n", FUNC, ma_addr, ma_size, (haddr_t)((ma_addr + ma_size) - 1));
-#endif /* H5MF_ALLOC_DEBUG_MORE */
-
- /* Retrieve 'small data' aggregator info, if available */
- H5MF_aggr_query(f, &(f->shared->sdata_aggr), &sda_addr, &sda_size);
-#ifdef H5MF_ALLOC_DEBUG_MORE
-HDfprintf(stderr, "%s: sda_addr = %a, sda_size = %Hu, end of sda = %a\n", FUNC, sda_addr, sda_size, (haddr_t)((sda_addr + sda_size) - 1));
-#endif /* H5MF_ALLOC_DEBUG_MORE */
-
- /* Make certain we release the aggregator that's later in the file first */
- /* (so the file shrinks properly) */
- if(H5F_addr_defined(ma_addr) && H5F_addr_defined(sda_addr)) {
- if(H5F_addr_lt(ma_addr, sda_addr)) {
- first_aggr = &(f->shared->sdata_aggr);
- second_aggr = &(f->shared->meta_aggr);
- } /* end if */
- else {
- first_aggr = &(f->shared->meta_aggr);
- second_aggr = &(f->shared->sdata_aggr);
- } /* end else */
- } /* end if */
- else {
- first_aggr = &(f->shared->meta_aggr);
- second_aggr = &(f->shared->sdata_aggr);
- } /* end else */
-
- /* Release the unused portion of the metadata and "small data" blocks back
- * to the free lists in the file.
- */
- if(H5MF_aggr_reset(f, dxpl_id, first_aggr) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't reset metadata block")
- if(H5MF_aggr_reset(f, dxpl_id, second_aggr) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't reset 'small data' block")
+ if(H5MF_free_aggrs(f, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't free aggregators")
done:
#ifdef H5MF_ALLOC_DEBUG
diff --git a/src/H5MFaggr.c b/src/H5MFaggr.c
index fa5014bc..0526ef2 100644
--- a/src/H5MFaggr.c
+++ b/src/H5MFaggr.c
@@ -75,6 +75,66 @@
/*-------------------------------------------------------------------------
+ * Function: H5MF_aggr_vfd_alloc
+ *
+ * Purpose: Allocate SIZE bytes of file memory via H5MF_aggr_alloc()
+ * and return the relative address where that contiguous chunk
+ * of file memory exists.
+ * The TYPE argument describes the purpose for which the storage
+ * is being requested.
+ *
+ * Return: Success: The file address of new chunk.
+ * Failure: HADDR_UNDEF
+ *
+ * Programmer: Vailin Choi; July 1st, 2009
+ * (The coding is from H5MF_alloc().)
+ *
+ *-------------------------------------------------------------------------
+ */
+haddr_t
+H5MF_aggr_vfd_alloc(H5F_t *f, H5FD_mem_t alloc_type, hid_t dxpl_id, hsize_t size)
+{
+ haddr_t ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5MF_aggr_vfd_alloc, HADDR_UNDEF)
+#ifdef H5MF_ALLOC_DEBUG
+HDfprintf(stderr, "%s: alloc_type = %u, size = %Hu\n", FUNC, (unsigned)alloc_type, size);
+#endif /* H5MF_ALLOC_DEBUG */
+
+ /* check arguments */
+ HDassert(f);
+ HDassert(f->shared);
+ HDassert(f->shared->lf);
+ HDassert(size > 0);
+
+ /* Couldn't find anything from the free space manager, go allocate some */
+ 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_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_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);
+#endif /* H5MF_ALLOC_DEBUG */
+#ifdef H5MF_ALLOC_DEBUG_DUMP
+H5MF_sects_dump(f, dxpl_id, stderr);
+#endif /* H5MF_ALLOC_DEBUG_DUMP */
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5MF_aggr_vfd_alloc() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5MF_aggr_alloc
*
* Purpose: Try to allocate SIZE bytes of memory from an aggregator
diff --git a/src/H5MFprivate.h b/src/H5MFprivate.h
index 4508199..e08381f 100644
--- a/src/H5MFprivate.h
+++ b/src/H5MFprivate.h
@@ -65,6 +65,7 @@ H5_DLL herr_t H5MF_close(H5F_t *f, hid_t dxpl_id);
/* File space allocation routines */
H5_DLL haddr_t H5MF_alloc(H5F_t *f, H5FD_mem_t type, hid_t dxpl_id, hsize_t size);
+H5_DLL haddr_t H5MF_aggr_vfd_alloc(H5F_t *f, H5FD_mem_t type, hid_t dxpl_id, hsize_t size);
H5_DLL herr_t H5MF_xfree(H5F_t *f, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr,
hsize_t size);
H5_DLL herr_t H5MF_try_extend(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type,