2006-02-27 22:52:21 +08:00
|
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2007-02-07 22:56:24 +08:00
|
|
|
|
* Copyright by The HDF Group. *
|
2006-02-27 22:52:21 +08:00
|
|
|
|
* Copyright by the Board of Trustees of the University of Illinois. *
|
|
|
|
|
* All rights reserved. *
|
|
|
|
|
* *
|
|
|
|
|
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
|
|
|
* terms governing use, modification, and redistribution, is contained in *
|
|
|
|
|
* the files COPYING and Copyright.html. COPYING can be found at the root *
|
|
|
|
|
* of the source code distribution tree; Copyright.html can be found at the *
|
|
|
|
|
* root level of an installed copy of the electronic HDF5 document set and *
|
|
|
|
|
* is linked from the top-level documents page. It can also be found at *
|
2007-02-07 22:56:24 +08:00
|
|
|
|
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
|
|
|
|
|
* access to either file, you may request a copy from help@hdfgroup.org. *
|
2006-02-27 22:52:21 +08:00
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
*
|
2006-08-10 11:45:06 +08:00
|
|
|
|
* Created: H5HFman.c
|
2006-02-27 22:52:21 +08:00
|
|
|
|
* Feb 24 2006
|
|
|
|
|
* Quincey Koziol <koziol@ncsa.uiuc.edu>
|
|
|
|
|
*
|
2006-08-17 23:59:14 +08:00
|
|
|
|
* Purpose: "Managed" object routines for fractal heaps.
|
2006-02-27 22:52:21 +08:00
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/****************/
|
|
|
|
|
/* Module Setup */
|
|
|
|
|
/****************/
|
|
|
|
|
|
|
|
|
|
#define H5HF_PACKAGE /*suppress error about including H5HFpkg */
|
|
|
|
|
|
|
|
|
|
/***********/
|
|
|
|
|
/* Headers */
|
|
|
|
|
/***********/
|
|
|
|
|
#include "H5private.h" /* Generic Functions */
|
|
|
|
|
#include "H5Eprivate.h" /* Error handling */
|
2006-03-14 03:47:16 +08:00
|
|
|
|
#include "H5HFpkg.h" /* Fractal heaps */
|
2006-02-27 22:52:21 +08:00
|
|
|
|
#include "H5MFprivate.h" /* File memory management */
|
2006-03-14 03:47:16 +08:00
|
|
|
|
#include "H5MMprivate.h" /* Memory management */
|
2006-03-05 06:56:44 +08:00
|
|
|
|
#include "H5Vprivate.h" /* Vectors and arrays */
|
2006-02-27 22:52:21 +08:00
|
|
|
|
|
|
|
|
|
/****************/
|
|
|
|
|
/* Local Macros */
|
|
|
|
|
/****************/
|
|
|
|
|
|
[svn-r17623] Description:
Bring "compress group's fractal heap" feature from branch back to
trunk.
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/default API=1.8.x,
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.6.1 (amazon) in debug mode
Mac OS X/32 10.6.1 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-10-09 09:31:36 +08:00
|
|
|
|
/* Macro to check if we can apply all filters in the pipeline. Use whenever
|
|
|
|
|
* performing a modification operation */
|
|
|
|
|
#define H5HF_MAN_WRITE_CHECK_PLINE(HDR) \
|
|
|
|
|
{ \
|
|
|
|
|
if(!((HDR)->checked_filters)) { \
|
|
|
|
|
if((HDR)->pline.nused) \
|
|
|
|
|
if(H5Z_can_apply_direct(&((HDR)->pline)) < 0) \
|
|
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "I/O filters can't operate on this heap") \
|
|
|
|
|
\
|
|
|
|
|
(HDR)->checked_filters = TRUE; \
|
|
|
|
|
} /* end if */ \
|
|
|
|
|
}
|
|
|
|
|
|
2006-02-27 22:52:21 +08:00
|
|
|
|
|
|
|
|
|
/******************/
|
|
|
|
|
/* Local Typedefs */
|
|
|
|
|
/******************/
|
|
|
|
|
|
|
|
|
|
|
2006-03-14 03:47:16 +08:00
|
|
|
|
/********************/
|
|
|
|
|
/* Package Typedefs */
|
|
|
|
|
/********************/
|
|
|
|
|
|
|
|
|
|
|
2006-02-27 22:52:21 +08:00
|
|
|
|
/********************/
|
|
|
|
|
/* Local Prototypes */
|
|
|
|
|
/********************/
|
2006-09-12 01:25:26 +08:00
|
|
|
|
static herr_t H5HF_man_op_real(H5HF_hdr_t *hdr, hid_t dxpl_id,
|
2006-12-19 01:52:43 +08:00
|
|
|
|
const uint8_t *id, H5HF_operator_t op, void *op_data, unsigned op_flags);
|
2006-02-27 22:52:21 +08:00
|
|
|
|
|
|
|
|
|
/*********************/
|
|
|
|
|
/* Package Variables */
|
|
|
|
|
/*********************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************/
|
|
|
|
|
/* Library Private Variables */
|
|
|
|
|
/*****************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*******************/
|
|
|
|
|
/* Local Variables */
|
|
|
|
|
/*******************/
|
|
|
|
|
|
|
|
|
|
|
2006-03-05 06:56:44 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2006-04-16 05:11:42 +08:00
|
|
|
|
* Function: H5HF_man_insert
|
2006-03-05 06:56:44 +08:00
|
|
|
|
*
|
2006-04-16 05:11:42 +08:00
|
|
|
|
* Purpose: Insert an object in a managed direct block
|
2006-03-05 06:56:44 +08:00
|
|
|
|
*
|
2006-04-16 05:11:42 +08:00
|
|
|
|
* Return: SUCCEED/FAIL
|
2006-03-05 06:56:44 +08:00
|
|
|
|
*
|
|
|
|
|
* Programmer: Quincey Koziol
|
|
|
|
|
* koziol@ncsa.uiuc.edu
|
2006-04-16 05:11:42 +08:00
|
|
|
|
* Mar 13 2006
|
2006-03-05 06:56:44 +08:00
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
herr_t
|
2006-08-10 11:45:06 +08:00
|
|
|
|
H5HF_man_insert(H5HF_hdr_t *hdr, hid_t dxpl_id, size_t obj_size, const void *obj,
|
|
|
|
|
void *_id)
|
2006-03-05 06:56:44 +08:00
|
|
|
|
{
|
2006-08-10 11:45:06 +08:00
|
|
|
|
H5HF_free_section_t *sec_node; /* Pointer to free space section */
|
2006-04-16 05:11:42 +08:00
|
|
|
|
H5HF_direct_t *dblock = NULL; /* Pointer to direct block to modify */
|
2006-07-31 17:54:09 +08:00
|
|
|
|
haddr_t dblock_addr = HADDR_UNDEF; /* Direct block address */
|
2006-10-29 10:17:07 +08:00
|
|
|
|
size_t dblock_size; /* Direct block size */
|
2006-08-08 05:24:29 +08:00
|
|
|
|
uint8_t *id = (uint8_t *)_id; /* Pointer to ID buffer */
|
2006-08-08 03:51:59 +08:00
|
|
|
|
size_t blk_off; /* Offset of object within block */
|
2006-08-10 11:45:06 +08:00
|
|
|
|
htri_t node_found; /* Whether an existing free list node was found */
|
2006-03-14 03:47:16 +08:00
|
|
|
|
herr_t ret_value = SUCCEED; /* Return value */
|
2006-03-05 06:56:44 +08:00
|
|
|
|
|
2006-04-16 05:11:42 +08:00
|
|
|
|
FUNC_ENTER_NOAPI_NOINIT(H5HF_man_insert)
|
2006-03-05 06:56:44 +08:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Check arguments.
|
|
|
|
|
*/
|
2006-04-16 05:11:42 +08:00
|
|
|
|
HDassert(hdr);
|
|
|
|
|
HDassert(obj_size > 0);
|
|
|
|
|
HDassert(obj);
|
|
|
|
|
HDassert(id);
|
2006-02-27 22:52:21 +08:00
|
|
|
|
|
[svn-r17623] Description:
Bring "compress group's fractal heap" feature from branch back to
trunk.
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/default API=1.8.x,
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.6.1 (amazon) in debug mode
Mac OS X/32 10.6.1 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-10-09 09:31:36 +08:00
|
|
|
|
/* Check pipeline */
|
|
|
|
|
H5HF_MAN_WRITE_CHECK_PLINE(hdr)
|
|
|
|
|
|
2006-08-10 11:45:06 +08:00
|
|
|
|
/* Look for free space */
|
|
|
|
|
if((node_found = H5HF_space_find(hdr, dxpl_id, (hsize_t)obj_size, &sec_node)) < 0)
|
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't locate free space in fractal heap")
|
|
|
|
|
|
|
|
|
|
/* If we didn't find a node, go create a direct block big enough to hold the requested block */
|
|
|
|
|
if(!node_found)
|
|
|
|
|
/* Allocate direct block big enough to hold requested size */
|
|
|
|
|
if(H5HF_man_dblock_new(hdr, dxpl_id, obj_size, &sec_node) < 0)
|
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_CANTCREATE, FAIL, "can't create fractal heap direct block")
|
|
|
|
|
|
2006-07-22 09:55:14 +08:00
|
|
|
|
/* Check for row section */
|
|
|
|
|
if(sec_node->sect_info.type == H5HF_FSPACE_SECT_FIRST_ROW ||
|
|
|
|
|
sec_node->sect_info.type == H5HF_FSPACE_SECT_NORMAL_ROW) {
|
2006-04-16 05:11:42 +08:00
|
|
|
|
|
2006-07-22 09:55:14 +08:00
|
|
|
|
/* Allocate 'single' selection out of 'row' selection */
|
|
|
|
|
if(H5HF_man_iblock_alloc_row(hdr, dxpl_id, &sec_node) < 0)
|
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't break up row section")
|
2006-04-16 05:11:42 +08:00
|
|
|
|
} /* end if */
|
2006-06-19 18:06:10 +08:00
|
|
|
|
HDassert(sec_node->sect_info.type == H5HF_FSPACE_SECT_SINGLE);
|
2006-05-15 12:35:53 +08:00
|
|
|
|
|
2006-08-10 11:45:06 +08:00
|
|
|
|
/* Check for 'single' section being serialized */
|
2006-05-15 12:35:53 +08:00
|
|
|
|
if(sec_node->sect_info.state == H5FS_SECT_SERIALIZED) {
|
2006-05-23 00:43:45 +08:00
|
|
|
|
if(H5HF_sect_single_revive(hdr, dxpl_id, sec_node) < 0)
|
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't revive single free section")
|
2006-05-15 12:35:53 +08:00
|
|
|
|
} /* end if */
|
|
|
|
|
HDassert(sec_node->sect_info.state == H5FS_SECT_LIVE);
|
2006-02-27 22:52:21 +08:00
|
|
|
|
|
2006-10-29 10:17:07 +08:00
|
|
|
|
/* Retrieve direct block address from section */
|
|
|
|
|
if(H5HF_sect_single_dblock_info(hdr, dxpl_id, sec_node, &dblock_addr, &dblock_size) < 0)
|
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't retrieve direct block information")
|
|
|
|
|
|
|
|
|
|
/* Lock direct block */
|
|
|
|
|
if(NULL == (dblock = H5HF_man_dblock_protect(hdr, dxpl_id, dblock_addr, dblock_size, sec_node->u.single.parent, sec_node->u.single.par_entry, H5AC_WRITE)))
|
2006-04-16 05:11:42 +08:00
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load fractal heap direct block")
|
2006-03-05 06:56:44 +08:00
|
|
|
|
|
2006-04-16 05:11:42 +08:00
|
|
|
|
/* Insert object into block */
|
2006-03-05 06:56:44 +08:00
|
|
|
|
|
2006-08-08 03:51:59 +08:00
|
|
|
|
/* Get the offset of the object within the block */
|
2009-01-14 21:09:42 +08:00
|
|
|
|
H5_CHECK_OVERFLOW((sec_node->sect_info.addr - dblock->block_off), hsize_t, size_t);
|
|
|
|
|
blk_off = (size_t)(sec_node->sect_info.addr - dblock->block_off);
|
2006-02-27 22:52:21 +08:00
|
|
|
|
|
2006-08-08 03:51:59 +08:00
|
|
|
|
/* Sanity checks */
|
|
|
|
|
HDassert(sec_node->sect_info.size >= obj_size);
|
2006-02-27 22:52:21 +08:00
|
|
|
|
|
2006-08-08 03:51:59 +08:00
|
|
|
|
/* Reduce (& possibly re-add) single section */
|
|
|
|
|
if(H5HF_sect_single_reduce(hdr, dxpl_id, sec_node, obj_size) < 0)
|
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, "can't reduce single section node")
|
2006-03-16 04:16:04 +08:00
|
|
|
|
|
2006-08-08 03:51:59 +08:00
|
|
|
|
/* Encode the object in the block */
|
|
|
|
|
{
|
|
|
|
|
uint8_t *p; /* Temporary pointer to obj info in block */
|
2006-04-16 05:11:42 +08:00
|
|
|
|
|
|
|
|
|
/* Point to location for object */
|
2006-05-15 12:35:53 +08:00
|
|
|
|
p = dblock->blk + blk_off;
|
2006-03-31 23:43:14 +08:00
|
|
|
|
|
2006-04-16 05:11:42 +08:00
|
|
|
|
/* Copy the object's data into the heap */
|
|
|
|
|
HDmemcpy(p, obj, obj_size);
|
|
|
|
|
p += obj_size;
|
2006-03-31 23:43:14 +08:00
|
|
|
|
|
2006-04-16 05:11:42 +08:00
|
|
|
|
/* Sanity check */
|
2006-05-15 12:35:53 +08:00
|
|
|
|
HDassert((size_t)(p - (dblock->blk + blk_off)) == obj_size);
|
2006-08-08 03:51:59 +08:00
|
|
|
|
} /* end block */
|
2006-03-31 23:43:14 +08:00
|
|
|
|
|
2006-08-08 03:51:59 +08:00
|
|
|
|
/* Set the heap ID for the new object (heap offset & obj length) */
|
|
|
|
|
H5HF_MAN_ID_ENCODE(id, hdr, (dblock->block_off + blk_off), obj_size);
|
2006-03-31 23:43:14 +08:00
|
|
|
|
|
2006-04-16 05:11:42 +08:00
|
|
|
|
/* Update statistics about heap */
|
2006-08-08 05:24:29 +08:00
|
|
|
|
hdr->man_nobjs++;
|
2006-03-31 23:43:14 +08:00
|
|
|
|
|
2006-08-19 10:42:18 +08:00
|
|
|
|
/* Reduce space available in heap (marks header dirty) */
|
|
|
|
|
if(H5HF_hdr_adj_free(hdr, -(ssize_t)obj_size) < 0)
|
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't adjust free space for heap")
|
2006-03-31 23:43:14 +08:00
|
|
|
|
|
|
|
|
|
done:
|
2006-04-16 05:11:42 +08:00
|
|
|
|
/* Release the direct block (marked as dirty) */
|
|
|
|
|
if(dblock && H5AC_unprotect(hdr->f, dxpl_id, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, H5AC__DIRTIED_FLAG) < 0)
|
|
|
|
|
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap direct block")
|
|
|
|
|
|
2006-03-31 23:43:14 +08:00
|
|
|
|
FUNC_LEAVE_NOAPI(ret_value)
|
2006-04-16 05:11:42 +08:00
|
|
|
|
} /* end H5HF_man_insert() */
|
2006-03-31 23:43:14 +08:00
|
|
|
|
|
2006-03-16 04:16:04 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2006-09-12 01:25:26 +08:00
|
|
|
|
* Function: H5HF_man_op_real
|
2006-03-16 04:16:04 +08:00
|
|
|
|
*
|
2006-09-12 01:25:26 +08:00
|
|
|
|
* Purpose: Internal routine to perform an operation on a managed heap
|
|
|
|
|
* object
|
2006-03-16 04:16:04 +08:00
|
|
|
|
*
|
2006-04-16 05:11:42 +08:00
|
|
|
|
* Return: SUCCEED/FAIL
|
2006-03-16 04:16:04 +08:00
|
|
|
|
*
|
|
|
|
|
* Programmer: Quincey Koziol
|
|
|
|
|
* koziol@ncsa.uiuc.edu
|
2006-04-16 05:11:42 +08:00
|
|
|
|
* Mar 17 2006
|
2006-03-16 04:16:04 +08:00
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2006-09-12 01:25:26 +08:00
|
|
|
|
static herr_t
|
2008-09-16 23:52:51 +08:00
|
|
|
|
H5HF_man_op_real(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id,
|
2006-12-19 01:52:43 +08:00
|
|
|
|
H5HF_operator_t op, void *op_data, unsigned op_flags)
|
2006-03-16 04:16:04 +08:00
|
|
|
|
{
|
2006-12-07 06:19:52 +08:00
|
|
|
|
H5HF_direct_t *dblock = NULL; /* Pointer to direct block to query */
|
2006-12-19 01:52:43 +08:00
|
|
|
|
H5AC_protect_t dblock_access; /* Access method for direct block */
|
|
|
|
|
haddr_t dblock_addr; /* Direct block address */
|
|
|
|
|
size_t dblock_size; /* Direct block size */
|
|
|
|
|
unsigned dblock_cache_flags; /* Flags for unprotecting direct block */
|
2006-08-10 11:45:06 +08:00
|
|
|
|
hsize_t obj_off; /* Object's offset in heap */
|
|
|
|
|
size_t obj_len; /* Object's length in heap */
|
2006-04-16 05:11:42 +08:00
|
|
|
|
size_t blk_off; /* Offset of object in block */
|
|
|
|
|
uint8_t *p; /* Temporary pointer to obj info in block */
|
|
|
|
|
herr_t ret_value = SUCCEED; /* Return value */
|
2006-03-16 04:16:04 +08:00
|
|
|
|
|
2006-09-12 01:25:26 +08:00
|
|
|
|
FUNC_ENTER_NOAPI_NOINIT(H5HF_man_op_real)
|
2006-03-16 04:16:04 +08:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Check arguments.
|
|
|
|
|
*/
|
2006-03-28 05:57:50 +08:00
|
|
|
|
HDassert(hdr);
|
2006-08-10 11:45:06 +08:00
|
|
|
|
HDassert(id);
|
2006-09-12 01:25:26 +08:00
|
|
|
|
HDassert(op);
|
2006-08-10 11:45:06 +08:00
|
|
|
|
|
2006-12-19 01:52:43 +08:00
|
|
|
|
/* Set the access mode for the direct block */
|
|
|
|
|
if(op_flags & H5HF_OP_MODIFY) {
|
[svn-r17623] Description:
Bring "compress group's fractal heap" feature from branch back to
trunk.
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/default API=1.8.x,
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.6.1 (amazon) in debug mode
Mac OS X/32 10.6.1 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-10-09 09:31:36 +08:00
|
|
|
|
/* Check pipeline */
|
|
|
|
|
H5HF_MAN_WRITE_CHECK_PLINE(hdr)
|
|
|
|
|
|
2006-12-19 01:52:43 +08:00
|
|
|
|
dblock_access = H5AC_WRITE;
|
|
|
|
|
dblock_cache_flags = H5AC__DIRTIED_FLAG;
|
|
|
|
|
} /* end if */
|
|
|
|
|
else {
|
|
|
|
|
dblock_access = H5AC_READ;
|
|
|
|
|
dblock_cache_flags = H5AC__NO_FLAGS_SET;
|
|
|
|
|
} /* end else */
|
|
|
|
|
|
2006-08-17 23:59:14 +08:00
|
|
|
|
/* Skip over the flag byte */
|
|
|
|
|
id++;
|
|
|
|
|
|
2007-05-14 12:05:28 +08:00
|
|
|
|
/* Decode the object offset within the heap & its length */
|
2006-08-10 11:45:06 +08:00
|
|
|
|
UINT64DECODE_VAR(id, obj_off, hdr->heap_off_size);
|
|
|
|
|
UINT64DECODE_VAR(id, obj_len, hdr->heap_len_size);
|
2006-04-16 05:11:42 +08:00
|
|
|
|
HDassert(obj_off > 0);
|
2006-05-23 00:43:45 +08:00
|
|
|
|
HDassert(obj_len > 0);
|
2006-03-16 04:16:04 +08:00
|
|
|
|
|
2006-08-21 22:56:20 +08:00
|
|
|
|
/* Check for bad offset or length */
|
|
|
|
|
if(obj_off > hdr->man_size)
|
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "fractal heap object offset too large")
|
|
|
|
|
if(obj_len > hdr->man_dtable.cparam.max_direct_size)
|
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "fractal heap object size too large for direct block")
|
|
|
|
|
if(obj_len > hdr->max_man_size)
|
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "fractal heap object should be standalone")
|
|
|
|
|
|
2006-04-16 05:11:42 +08:00
|
|
|
|
/* Check for root direct block */
|
2006-03-28 05:57:50 +08:00
|
|
|
|
if(hdr->man_dtable.curr_root_rows == 0) {
|
2006-04-16 05:11:42 +08:00
|
|
|
|
/* Set direct block info */
|
2006-04-30 21:32:41 +08:00
|
|
|
|
dblock_addr = hdr->man_dtable.table_addr;
|
|
|
|
|
dblock_size = hdr->man_dtable.cparam.start_block_size;
|
2006-03-16 04:16:04 +08:00
|
|
|
|
|
2006-04-16 05:11:42 +08:00
|
|
|
|
/* Lock direct block */
|
2006-12-19 01:52:43 +08:00
|
|
|
|
if(NULL == (dblock = H5HF_man_dblock_protect(hdr, dxpl_id, dblock_addr, dblock_size, NULL, 0, dblock_access)))
|
2006-04-16 05:11:42 +08:00
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap direct block")
|
2006-03-16 04:16:04 +08:00
|
|
|
|
} /* end if */
|
|
|
|
|
else {
|
2006-04-16 05:11:42 +08:00
|
|
|
|
H5HF_indirect_t *iblock; /* Pointer to indirect block */
|
2006-08-19 10:42:18 +08:00
|
|
|
|
hbool_t did_protect; /* Whether we protected the indirect block or not */
|
2006-05-15 12:35:53 +08:00
|
|
|
|
unsigned entry; /* Entry of block */
|
2006-03-31 23:43:14 +08:00
|
|
|
|
|
2006-05-15 12:35:53 +08:00
|
|
|
|
/* Look up indirect block containing direct block */
|
2006-08-19 10:42:18 +08:00
|
|
|
|
if(H5HF_man_dblock_locate(hdr, dxpl_id, obj_off, &iblock, &entry, &did_protect, H5AC_READ) < 0)
|
2006-05-15 12:35:53 +08:00
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPUTE, FAIL, "can't compute row & column of section")
|
2006-03-31 23:43:14 +08:00
|
|
|
|
|
2006-04-16 05:11:42 +08:00
|
|
|
|
/* Set direct block info */
|
|
|
|
|
dblock_addr = iblock->ents[entry].addr;
|
2009-01-14 21:09:42 +08:00
|
|
|
|
H5_CHECK_OVERFLOW((hdr->man_dtable.row_block_size[entry / hdr->man_dtable.cparam.width]), hsize_t, size_t);
|
|
|
|
|
dblock_size = (size_t)hdr->man_dtable.row_block_size[entry / hdr->man_dtable.cparam.width];
|
2006-03-31 23:43:14 +08:00
|
|
|
|
|
2006-08-21 22:56:20 +08:00
|
|
|
|
/* Check for offset of invalid direct block */
|
|
|
|
|
if(!H5F_addr_defined(dblock_addr)) {
|
|
|
|
|
/* Unlock indirect block */
|
|
|
|
|
if(H5HF_man_iblock_unprotect(iblock, dxpl_id, H5AC__NO_FLAGS_SET, did_protect) < 0)
|
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block")
|
|
|
|
|
|
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "fractal heap ID not in allocated direct block")
|
|
|
|
|
} /* end if */
|
|
|
|
|
|
2006-04-16 05:11:42 +08:00
|
|
|
|
/* Lock direct block */
|
2006-12-19 01:52:43 +08:00
|
|
|
|
if(NULL == (dblock = H5HF_man_dblock_protect(hdr, dxpl_id, dblock_addr, dblock_size, iblock, entry, dblock_access))) {
|
2006-08-21 22:56:20 +08:00
|
|
|
|
/* Unlock indirect block */
|
|
|
|
|
if(H5HF_man_iblock_unprotect(iblock, dxpl_id, H5AC__NO_FLAGS_SET, did_protect) < 0)
|
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block")
|
|
|
|
|
|
2006-04-16 05:11:42 +08:00
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap direct block")
|
2006-08-21 22:56:20 +08:00
|
|
|
|
} /* end if */
|
2006-03-31 23:43:14 +08:00
|
|
|
|
|
2006-04-16 05:11:42 +08:00
|
|
|
|
/* Unlock indirect block */
|
2006-08-19 10:42:18 +08:00
|
|
|
|
if(H5HF_man_iblock_unprotect(iblock, dxpl_id, H5AC__NO_FLAGS_SET, did_protect) < 0)
|
2006-05-15 12:35:53 +08:00
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block")
|
2006-04-16 05:11:42 +08:00
|
|
|
|
iblock = NULL;
|
|
|
|
|
} /* end else */
|
2006-03-14 03:47:16 +08:00
|
|
|
|
|
2006-04-16 05:11:42 +08:00
|
|
|
|
/* Compute offset of object within block */
|
|
|
|
|
HDassert((obj_off - dblock->block_off) < (hsize_t)dblock_size);
|
|
|
|
|
blk_off = (size_t)(obj_off - dblock->block_off);
|
2006-03-14 03:47:16 +08:00
|
|
|
|
|
2006-08-21 22:56:20 +08:00
|
|
|
|
/* Check for object's offset in the direct block prefix information */
|
|
|
|
|
if(blk_off < H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr))
|
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "object located in prefix of direct block")
|
|
|
|
|
|
|
|
|
|
/* Check for object's length overrunning the end of the direct block */
|
|
|
|
|
if((blk_off + obj_len) > dblock_size)
|
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "object overruns end of direct block")
|
|
|
|
|
|
2006-04-16 05:11:42 +08:00
|
|
|
|
/* Point to location for object */
|
|
|
|
|
p = dblock->blk + blk_off;
|
2006-03-14 03:47:16 +08:00
|
|
|
|
|
2006-09-12 01:25:26 +08:00
|
|
|
|
/* Call the user's 'op' callback */
|
2006-12-07 06:19:52 +08:00
|
|
|
|
if(op(p, obj_len, op_data) < 0)
|
2006-09-12 01:25:26 +08:00
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "application's callback failed")
|
2006-03-16 04:16:04 +08:00
|
|
|
|
|
2006-12-07 06:19:52 +08:00
|
|
|
|
done:
|
2006-04-16 05:11:42 +08:00
|
|
|
|
/* Unlock direct block */
|
2006-12-19 01:52:43 +08:00
|
|
|
|
if(dblock && H5AC_unprotect(hdr->f, dxpl_id, H5AC_FHEAP_DBLOCK, dblock_addr, dblock, dblock_cache_flags) < 0)
|
2006-12-07 06:19:52 +08:00
|
|
|
|
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap direct block")
|
2006-03-14 03:47:16 +08:00
|
|
|
|
|
2006-09-12 01:25:26 +08:00
|
|
|
|
FUNC_LEAVE_NOAPI(ret_value)
|
|
|
|
|
} /* end H5HF_man_op_real() */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: H5HF_man_read
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Read an object from a managed heap
|
|
|
|
|
*
|
|
|
|
|
* Return: SUCCEED/FAIL
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Quincey Koziol
|
|
|
|
|
* koziol@ncsa.uiuc.edu
|
|
|
|
|
* Mar 17 2006
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
herr_t
|
|
|
|
|
H5HF_man_read(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id, void *obj)
|
|
|
|
|
{
|
|
|
|
|
herr_t ret_value = SUCCEED; /* Return value */
|
|
|
|
|
|
|
|
|
|
FUNC_ENTER_NOAPI_NOINIT(H5HF_man_read)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Check arguments.
|
|
|
|
|
*/
|
|
|
|
|
HDassert(hdr);
|
|
|
|
|
HDassert(id);
|
|
|
|
|
HDassert(obj);
|
|
|
|
|
|
|
|
|
|
/* Call the internal 'op' routine routine */
|
2006-12-19 01:52:43 +08:00
|
|
|
|
if(H5HF_man_op_real(hdr, dxpl_id, id, H5HF_op_read, obj, 0) < 0)
|
2006-09-12 01:25:26 +08:00
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "unable to operate on heap object")
|
|
|
|
|
|
2006-03-14 03:47:16 +08:00
|
|
|
|
done:
|
|
|
|
|
FUNC_LEAVE_NOAPI(ret_value)
|
2006-04-16 05:11:42 +08:00
|
|
|
|
} /* end H5HF_man_read() */
|
2006-02-27 22:52:21 +08:00
|
|
|
|
|
2006-12-19 01:52:43 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: H5HF_man_write
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Write an object to a managed heap
|
|
|
|
|
*
|
|
|
|
|
* Return: SUCCEED/FAIL
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Quincey Koziol
|
|
|
|
|
* koziol@hdfgroup.org
|
|
|
|
|
* Dec 18 2006
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
herr_t
|
|
|
|
|
H5HF_man_write(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id,
|
|
|
|
|
const void *obj)
|
|
|
|
|
{
|
|
|
|
|
herr_t ret_value = SUCCEED; /* Return value */
|
|
|
|
|
|
|
|
|
|
FUNC_ENTER_NOAPI_NOINIT(H5HF_man_write)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Check arguments.
|
|
|
|
|
*/
|
|
|
|
|
HDassert(hdr);
|
|
|
|
|
HDassert(id);
|
|
|
|
|
HDassert(obj);
|
|
|
|
|
|
|
|
|
|
/* Call the internal 'op' routine routine */
|
|
|
|
|
/* (Casting away const OK - QAK) */
|
|
|
|
|
if(H5HF_man_op_real(hdr, dxpl_id, id, H5HF_op_write, (void *)obj, H5HF_OP_MODIFY) < 0)
|
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "unable to operate on heap object")
|
|
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
FUNC_LEAVE_NOAPI(ret_value)
|
|
|
|
|
} /* end H5HF_man_write() */
|
|
|
|
|
|
2006-09-12 01:25:26 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: H5HF_man_op
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Operate directly on an object from a managed heap
|
|
|
|
|
*
|
|
|
|
|
* Return: SUCCEED/FAIL
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Quincey Koziol
|
|
|
|
|
* koziol@ncsa.uiuc.edu
|
|
|
|
|
* Sept 11 2006
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
herr_t
|
|
|
|
|
H5HF_man_op(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id,
|
|
|
|
|
H5HF_operator_t op, void *op_data)
|
|
|
|
|
{
|
|
|
|
|
herr_t ret_value = SUCCEED; /* Return value */
|
|
|
|
|
|
|
|
|
|
FUNC_ENTER_NOAPI_NOINIT(H5HF_man_op)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Check arguments.
|
|
|
|
|
*/
|
|
|
|
|
HDassert(hdr);
|
|
|
|
|
HDassert(id);
|
|
|
|
|
HDassert(op);
|
|
|
|
|
|
|
|
|
|
/* Call the internal 'op' routine routine */
|
2006-12-19 01:52:43 +08:00
|
|
|
|
if(H5HF_man_op_real(hdr, dxpl_id, id, op, op_data, 0) < 0)
|
2006-09-12 01:25:26 +08:00
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "unable to operate on heap object")
|
|
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
FUNC_LEAVE_NOAPI(ret_value)
|
|
|
|
|
} /* end H5HF_man_op() */
|
|
|
|
|
|
2006-05-23 00:43:45 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: H5HF_man_remove
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Remove an object from a managed heap
|
|
|
|
|
*
|
|
|
|
|
* Return: SUCCEED/FAIL
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Quincey Koziol
|
|
|
|
|
* koziol@ncsa.uiuc.edu
|
|
|
|
|
* May 15 2006
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
herr_t
|
2006-08-10 11:45:06 +08:00
|
|
|
|
H5HF_man_remove(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id)
|
2006-05-23 00:43:45 +08:00
|
|
|
|
{
|
|
|
|
|
H5HF_free_section_t *sec_node; /* Pointer to free space section for block */
|
2006-09-13 04:18:00 +08:00
|
|
|
|
H5HF_indirect_t *iblock = NULL; /* Pointer to indirect block */
|
|
|
|
|
hbool_t did_protect; /* Whether we protected the indirect block or not */
|
2006-08-10 11:45:06 +08:00
|
|
|
|
hsize_t obj_off; /* Object's offset in heap */
|
|
|
|
|
size_t obj_len; /* Object's length in heap */
|
2006-05-23 00:43:45 +08:00
|
|
|
|
size_t dblock_size; /* Direct block size */
|
2006-09-13 04:18:00 +08:00
|
|
|
|
hsize_t dblock_block_off; /* Offset of the direct block within the heap's address space */
|
|
|
|
|
unsigned dblock_entry; /* Entry of direct block in parent indirect block */
|
2006-05-23 00:43:45 +08:00
|
|
|
|
size_t blk_off; /* Offset of object in block */
|
|
|
|
|
herr_t ret_value = SUCCEED; /* Return value */
|
|
|
|
|
|
|
|
|
|
FUNC_ENTER_NOAPI_NOINIT(H5HF_man_remove)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Check arguments.
|
|
|
|
|
*/
|
|
|
|
|
HDassert(hdr);
|
2006-08-10 11:45:06 +08:00
|
|
|
|
HDassert(id);
|
|
|
|
|
|
[svn-r17623] Description:
Bring "compress group's fractal heap" feature from branch back to
trunk.
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/default API=1.8.x,
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.6.1 (amazon) in debug mode
Mac OS X/32 10.6.1 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-10-09 09:31:36 +08:00
|
|
|
|
/* Check pipeline */
|
|
|
|
|
H5HF_MAN_WRITE_CHECK_PLINE(hdr)
|
|
|
|
|
|
2006-08-17 23:59:14 +08:00
|
|
|
|
/* Skip over the flag byte */
|
|
|
|
|
id++;
|
|
|
|
|
|
2006-08-10 11:45:06 +08:00
|
|
|
|
/* Decode the object offset within the heap & it's length */
|
|
|
|
|
UINT64DECODE_VAR(id, obj_off, hdr->heap_off_size);
|
|
|
|
|
UINT64DECODE_VAR(id, obj_len, hdr->heap_len_size);
|
2006-05-23 00:43:45 +08:00
|
|
|
|
HDassert(obj_off > 0);
|
|
|
|
|
HDassert(obj_len > 0);
|
|
|
|
|
|
|
|
|
|
/* Check for bad offset or length */
|
2006-06-19 18:06:10 +08:00
|
|
|
|
if(obj_off > hdr->man_size)
|
2006-05-23 00:43:45 +08:00
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "fractal heap object offset too large")
|
2006-06-19 18:06:10 +08:00
|
|
|
|
if(obj_len > hdr->man_dtable.cparam.max_direct_size)
|
2006-05-23 00:43:45 +08:00
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "fractal heap object size too large for direct block")
|
2006-08-08 03:51:59 +08:00
|
|
|
|
if(obj_len > hdr->max_man_size)
|
2006-05-23 00:43:45 +08:00
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "fractal heap object should be standalone")
|
|
|
|
|
|
|
|
|
|
/* Check for root direct block */
|
|
|
|
|
if(hdr->man_dtable.curr_root_rows == 0) {
|
|
|
|
|
/* Set direct block info */
|
|
|
|
|
dblock_size = hdr->man_dtable.cparam.start_block_size;
|
2006-09-13 04:18:00 +08:00
|
|
|
|
dblock_block_off = 0;
|
|
|
|
|
dblock_entry = 0;
|
2006-05-23 00:43:45 +08:00
|
|
|
|
} /* end if */
|
|
|
|
|
else {
|
|
|
|
|
/* Look up indirect block containing direct block */
|
2006-09-13 04:18:00 +08:00
|
|
|
|
if(H5HF_man_dblock_locate(hdr, dxpl_id, obj_off, &iblock, &dblock_entry, &did_protect, H5AC_WRITE) < 0)
|
2006-05-23 00:43:45 +08:00
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPUTE, FAIL, "can't compute row & column of section")
|
|
|
|
|
|
2006-08-13 12:14:38 +08:00
|
|
|
|
/* Check for offset of invalid direct block */
|
2006-10-29 10:17:07 +08:00
|
|
|
|
if(!H5F_addr_defined(iblock->ents[dblock_entry].addr))
|
2006-08-13 12:14:38 +08:00
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "fractal heap ID not in allocated direct block")
|
|
|
|
|
|
2006-10-29 10:17:07 +08:00
|
|
|
|
/* Set direct block info */
|
2009-01-14 21:09:42 +08:00
|
|
|
|
H5_CHECK_OVERFLOW((hdr->man_dtable.row_block_size[dblock_entry / hdr->man_dtable.cparam.width]), hsize_t, size_t);
|
|
|
|
|
dblock_size = (size_t)(hdr->man_dtable.row_block_size[dblock_entry / hdr->man_dtable.cparam.width]);
|
2006-10-29 10:17:07 +08:00
|
|
|
|
|
2006-09-13 04:18:00 +08:00
|
|
|
|
/* Compute the direct block's offset in the heap's address space */
|
|
|
|
|
/* (based on parent indirect block's block offset) */
|
|
|
|
|
dblock_block_off = iblock->block_off;
|
|
|
|
|
dblock_block_off += hdr->man_dtable.row_block_off[dblock_entry / hdr->man_dtable.cparam.width];
|
|
|
|
|
dblock_block_off += hdr->man_dtable.row_block_size[dblock_entry / hdr->man_dtable.cparam.width] * (dblock_entry % hdr->man_dtable.cparam.width);
|
2006-05-23 00:43:45 +08:00
|
|
|
|
} /* end else */
|
|
|
|
|
|
|
|
|
|
/* Compute offset of object within block */
|
2006-09-13 04:18:00 +08:00
|
|
|
|
HDassert((obj_off - dblock_block_off) < (hsize_t)dblock_size);
|
|
|
|
|
blk_off = (size_t)(obj_off - dblock_block_off);
|
2006-05-23 00:43:45 +08:00
|
|
|
|
|
2006-08-13 12:14:38 +08:00
|
|
|
|
/* Check for object's offset in the direct block prefix information */
|
|
|
|
|
if(blk_off < H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr))
|
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "object located in prefix of direct block")
|
|
|
|
|
|
|
|
|
|
/* Check for object's length overrunning the end of the direct block */
|
|
|
|
|
if((blk_off + obj_len) > dblock_size)
|
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "object overruns end of direct block")
|
|
|
|
|
|
2006-05-23 00:43:45 +08:00
|
|
|
|
/* Create free space section node */
|
2006-10-29 10:17:07 +08:00
|
|
|
|
if(NULL == (sec_node = H5HF_sect_single_new(obj_off, obj_len, iblock, dblock_entry)))
|
2006-06-19 18:06:10 +08:00
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't create section for direct block's free space")
|
2006-05-23 00:43:45 +08:00
|
|
|
|
|
2006-09-13 04:18:00 +08:00
|
|
|
|
/* Unlock indirect block */
|
|
|
|
|
if(iblock) {
|
|
|
|
|
if(H5HF_man_iblock_unprotect(iblock, dxpl_id, H5AC__NO_FLAGS_SET, did_protect) < 0)
|
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block")
|
|
|
|
|
iblock = NULL;
|
|
|
|
|
} /* end if */
|
2006-05-23 00:43:45 +08:00
|
|
|
|
|
2006-05-23 09:24:26 +08:00
|
|
|
|
/* Update statistics about heap */
|
2006-08-08 05:24:29 +08:00
|
|
|
|
hdr->man_nobjs--;
|
2006-06-19 18:06:10 +08:00
|
|
|
|
|
2006-08-19 10:42:18 +08:00
|
|
|
|
/* Increase space available in heap (marks header dirty) */
|
2006-06-19 18:06:10 +08:00
|
|
|
|
if(H5HF_hdr_adj_free(hdr, (ssize_t)obj_len) < 0)
|
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't adjust free space for heap")
|
2006-05-23 09:24:26 +08:00
|
|
|
|
|
2006-05-23 00:43:45 +08:00
|
|
|
|
/* Return free space to the heap's list of space */
|
2006-07-22 09:55:14 +08:00
|
|
|
|
if(H5HF_space_add(hdr, dxpl_id, sec_node, H5FS_ADD_RETURNED_SPACE) < 0)
|
2006-05-23 00:43:45 +08:00
|
|
|
|
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't add direct block free space to global list")
|
|
|
|
|
|
|
|
|
|
done:
|
2006-08-13 12:14:38 +08:00
|
|
|
|
if(ret_value < 0) {
|
2006-09-13 04:18:00 +08:00
|
|
|
|
/* Unlock indirect block */
|
|
|
|
|
if(iblock && H5HF_man_iblock_unprotect(iblock, dxpl_id, H5AC__NO_FLAGS_SET, did_protect) < 0)
|
|
|
|
|
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block")
|
2006-08-13 12:14:38 +08:00
|
|
|
|
} /* end if */
|
|
|
|
|
|
2006-05-23 00:43:45 +08:00
|
|
|
|
FUNC_LEAVE_NOAPI(ret_value)
|
|
|
|
|
} /* end H5HF_man_remove() */
|
|
|
|
|
|