summaryrefslogtreecommitdiffstats
path: root/src/H5BT.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2005-03-11 22:18:35 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2005-03-11 22:18:35 (GMT)
commit5420387976499383ec861567e5b781aa32ba8a95 (patch)
treecd12dea0df5bb764ce62a3bd1e6a1cc35c3f78bf /src/H5BT.c
parentcfc77c0d78b4ddecce038fe92be56fbeca34894c (diff)
downloadhdf5-5420387976499383ec861567e5b781aa32ba8a95.zip
hdf5-5420387976499383ec861567e5b781aa32ba8a95.tar.gz
hdf5-5420387976499383ec861567e5b781aa32ba8a95.tar.bz2
[svn-r10203] Purpose:
New feature/tests Description: Add better support & tests for removing blocks being tracked. Platforms tested: FreeBSD 4.11 (sleipnir) Solaris 2.9 (shanti)
Diffstat (limited to 'src/H5BT.c')
-rw-r--r--src/H5BT.c49
1 files changed, 46 insertions, 3 deletions
diff --git a/src/H5BT.c b/src/H5BT.c
index c0a5510..1d23b68 100644
--- a/src/H5BT.c
+++ b/src/H5BT.c
@@ -528,7 +528,7 @@ HGOTO_ERROR(H5E_BLKTRK, H5E_UNSUPPORTED, FAIL, "Couldn't find block to remove")
/* Check for exact fit */
if(found.len == length) {
- /* Delete recode from B-tree */
+ /* Delete record from B-tree */
if(H5B2_remove(f, dxpl_id, H5B2_BLKTRK, bt->bt2_addr, &found)<0)
HGOTO_ERROR(H5E_BLKTRK, H5E_CANTDELETE, FAIL, "can't remove block")
@@ -584,8 +584,51 @@ HGOTO_ERROR(H5E_BLKTRK, H5E_UNSUPPORTED, FAIL, "Couldn't find block to remove")
bt->tot_block_size -= length;
} /* end if */
else if(found.len > length) {
-HDfprintf(stderr,"%s: found={%a/%Hu}\n",FUNC,found.addr,found.len);
-HGOTO_ERROR(H5E_BLKTRK, H5E_UNSUPPORTED, FAIL, "Couldn't find block to remove")
+ H5BT_blk_info_t new_block; /* Updated block info */
+
+ /* Update existing lower block */
+ new_block.addr = found.addr + length;
+ new_block.len = found.len - length;
+ if(H5B2_modify(f, dxpl_id, H5B2_BLKTRK, bt->bt2_addr, &found, H5BT_insert_modify_cb, &new_block) < 0)
+ HGOTO_ERROR(H5E_BLKTRK, H5E_CANTMODIFY, FAIL, "can't change block size")
+
+ /* Update max. block metadata */
+ if(found.len == bt->max_block_size) {
+ /* Decrement maximum block count */
+ bt->max_block_cnt--;
+
+ /* Check if we don't know the maximum size any longer */
+ if(bt->max_block_cnt==0) {
+ bt->max_block_size = new_block.len;
+ bt->max_block_cnt = 1;
+ bt->status &= ~H5BT_STATUS_MAX_VALID;
+ } /* end if */
+ } /* end if */
+ else if(new_block.len > bt->max_block_size) {
+ /* Should only happen if we have partial knowledge */
+ HDassert((bt->status & H5BT_STATUS_MAX_VALID) == 0);
+
+ /* Track the newly discovered max. block size */
+ bt->max_block_size = new_block.len;
+ bt->max_block_cnt = 1;
+ } /* end if */
+ else if(new_block.len == bt->max_block_size) {
+ /* Should only happen if we have partial knowledge */
+ HDassert((bt->status & H5BT_STATUS_MAX_VALID) == 0);
+
+ bt->max_block_cnt++;
+ } /* end if */
+
+ /* Update min. block metadata */
+ if(new_block.len < bt->min_block_size) {
+ bt->min_block_size = new_block.len;
+ bt->min_block_cnt = 1;
+ } /* end if */
+ else if(new_block.len == bt->min_block_size)
+ bt->min_block_cnt++;
+
+ /* Decrement total amount of blocks tracked */
+ bt->tot_block_size -= length;
} /* end if */
else {
/* Check for blocks at higher address, if necessary */