mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-03-07 16:37:56 +08:00
[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
This commit is contained in:
parent
da73cc2d02
commit
bcb872eaaa
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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*/);
|
||||
|
167
src/H5Fsuper.c
167
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);
|
||||
|
||||
|
||||
/*********************/
|
||||
@ -212,6 +215,114 @@ done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5F_locate_signature() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* 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
|
||||
@ -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 */
|
||||
|
||||
|
145
src/H5MF.c
145
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)) {
|
||||
@ -806,6 +797,74 @@ HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value);
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5MF_try_shrink() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* 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
|
||||
@ -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
|
||||
|
@ -73,6 +73,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
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user