summaryrefslogtreecommitdiffstats
path: root/src/H5F.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2002-06-06 13:54:26 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2002-06-06 13:54:26 (GMT)
commit754f4780f236297a6a905c83cfd051361d654f8f (patch)
tree645a11b9ff5a2d7bdbba02f8ab1440dee567fdec /src/H5F.c
parent7292287c89df97b6d8bbe062b95b4f469e7fa9ad (diff)
downloadhdf5-754f4780f236297a6a905c83cfd051361d654f8f.zip
hdf5-754f4780f236297a6a905c83cfd051361d654f8f.tar.gz
hdf5-754f4780f236297a6a905c83cfd051361d654f8f.tar.bz2
[svn-r5542] Purpose:
Code cleanup/bug fix Description: Unused space in the file was being "dropped on the floor" when the metadata or "small data" block was moved to a new location in the file and there was unused space in the old block. Solution: Put the space left in the allocation block into the free list of space for the file. This allows it to be [potentially] reused and sometimes allows the file to be smaller. Platforms tested: Solaris 2.7 (arabica) w/FORTRAN and FreeBSD 4.5 (sleipnir) w/C++
Diffstat (limited to 'src/H5F.c')
-rw-r--r--src/H5F.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/H5F.c b/src/H5F.c
index 961a8e9..fcf0d84 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -2311,6 +2311,10 @@ H5Fflush(hid_t object_id, H5F_scope_t scope)
* Added boot block & driver info block checksumming, to avoid
* writing them out when they haven't changed.
*
+ * Quincey Koziol, 2002-06-06
+ * Return the remainders of the metadata & "small data" blocks to
+ * the free list of blocks for the file.
+ *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -2360,6 +2364,33 @@ H5F_flush(H5F_t *f, H5F_scope_t scope, hbool_t invalidate,
/* Avoid flushing buffers & caches when alloc_only set */
if(!alloc_only) {
+ /* If we are invalidating everything (which only happens just before
+ * the file closes), release the unused portion of the metadata and
+ * "small data" blocks back to the free lists in the file.
+ */
+ if(invalidate) {
+ if(f->shared->lf->feature_flags&H5FD_FEAT_AGGREGATE_METADATA) {
+ /* Return the unused portion of the metadata block to a free list */
+ if(f->shared->lf->eoma!=0)
+ if(H5FD_free(f->shared->lf,H5FD_MEM_DEFAULT,f->shared->lf->eoma,f->shared->lf->cur_meta_block_size)<0)
+ HRETURN_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "can't free metadata block");
+
+ /* Reset metadata block information, just in case */
+ f->shared->lf->eoma=0;
+ f->shared->lf->cur_meta_block_size=0;
+ } /* end if */
+ if(f->shared->lf->feature_flags&H5FD_FEAT_AGGREGATE_SMALLDATA) {
+ /* Return the unused portion of the "small data" block to a free list */
+ if(f->shared->lf->eosda!=0)
+ if(H5FD_free(f->shared->lf,H5FD_MEM_DRAW,f->shared->lf->eosda,f->shared->lf->cur_sdata_block_size)<0)
+ HRETURN_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "can't free 'small data' block");
+
+ /* Reset "small data" block information, just in case */
+ f->shared->lf->eosda=0;
+ f->shared->lf->cur_sdata_block_size=0;
+ } /* end if */
+ } /* end if */
+
/* flush the data sieve buffer, if we have a dirty one */
if(f->shared->sieve_buf && f->shared->sieve_dirty) {
/* Write dirty data sieve buffer to file */