summaryrefslogtreecommitdiffstats
path: root/src/H5F.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-11-16 20:45:05 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-11-16 20:45:05 (GMT)
commitd2b87ec47ebdb096c331c7b62a195b9cea2f33ae (patch)
treea066f01361afaf5df457cef612bb0bb9fd80fe18 /src/H5F.c
parentee5a1e07350f0dcf3ef07d9443aa2f4c073392f4 (diff)
downloadhdf5-d2b87ec47ebdb096c331c7b62a195b9cea2f33ae.zip
hdf5-d2b87ec47ebdb096c331c7b62a195b9cea2f33ae.tar.gz
hdf5-d2b87ec47ebdb096c331c7b62a195b9cea2f33ae.tar.bz2
[svn-r17896] Description:
Bring r17546:17895 from trunk to revise_chunks branch. Changes to fixed and extensible array dataset chunk indexing code to accommodate changes to private APIs in those interfaces. Also, other adjustments to source code and expected output in response to changes on the 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.2 (amazon) in debug mode Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'src/H5F.c')
-rw-r--r--src/H5F.c93
1 files changed, 75 insertions, 18 deletions
diff --git a/src/H5F.c b/src/H5F.c
index 6d16e73..064988e 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -891,6 +891,10 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf)
if(H5P_get(plist, H5F_CRT_SHMSG_NINDEXES_NAME, &f->shared->sohm_nindexes) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get number of SOHM indexes")
HDassert(f->shared->sohm_nindexes < 255);
+ if(H5P_get(plist, H5F_CRT_FILE_SPACE_STRATEGY_NAME, &f->shared->fs_strategy) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get file space strategy")
+ if(H5P_get(plist, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, &f->shared->fs_threshold) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get free-space section threshold")
/* Get the FAPL values to cache */
if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
@@ -1025,9 +1029,11 @@ H5F_dest(H5F_t *f, hid_t dxpl_id)
* and also because releasing free space can shrink the file's
* 'eoa' value)
*/
- if(H5MF_close(f, dxpl_id) < 0)
- /* Push error, but keep going*/
- HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release file free space info")
+ if(H5F_ACC_RDWR & H5F_INTENT(f)) {
+ if(H5MF_close(f, dxpl_id) < 0)
+ /* Push error, but keep going*/
+ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release file free space info")
+ } /* end if */
/* Unpin the superblock, since we're about to destroy the cache */
if(H5AC_unpin_entry(f, f->shared->sblock) < 0)
@@ -1084,7 +1090,7 @@ H5F_dest(H5F_t *f, hid_t dxpl_id)
HDONE_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't close property list")
/* Only truncate the file on an orderly close, with write-access */
- if(f->closing && (H5F_ACC_RDWR & f->shared->flags)) {
+ if(f->closing && (H5F_ACC_RDWR & H5F_INTENT(f))) {
/* Truncate the file to the current allocated size */
if(H5FD_truncate(f->shared->lf, dxpl_id, (unsigned)TRUE) < 0)
/* Push error, but keep going*/
@@ -1629,7 +1635,7 @@ H5Fflush(hid_t object_id, H5F_scope_t scope)
* calling H5Fflush() with the read-only handle, still causes data
* to be flushed.
*/
- if(H5F_ACC_RDWR & f->shared->flags) {
+ if(H5F_ACC_RDWR & H5F_INTENT(f)) {
/* Flush other files, depending on scope */
if(H5F_SCOPE_GLOBAL == scope) {
/* Call the flush routine for mounted file hierarchies */
@@ -1907,7 +1913,7 @@ H5F_try_close(H5F_t *f)
* copy of the cache needs to be clean.
* Only try to flush the file if it was opened with write access.
*/
- if(f->intent&H5F_ACC_RDWR) {
+ if(f->intent & H5F_ACC_RDWR) {
/* Flush all caches */
if(H5F_flush(f, H5AC_dxpl_id) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache")
@@ -2798,11 +2804,13 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Fget_info
- * 1. Get storage size for superblock extension if there is one
+ * Function: H5Fget_info2
+ *
+ * Purpose: Gets general information about the file, including:
+ * 1. Get storage size for superblock extension if there is one.
* 2. Get the amount of btree and heap storage for entries
* in the SOHM table if there is one.
- * Consider success when there is no superblock extension and/or SOHM table
+ * 3. The amount of free space tracked in the file.
*
* Return: Success: non-negative on success
* Failure: Negative
@@ -2813,12 +2821,12 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5Fget_info(hid_t obj_id, H5F_info_t *finfo)
+H5Fget_info2(hid_t obj_id, H5F_info2_t *finfo)
{
H5F_t *f; /* Top file in mount hierarchy */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_API(H5Fget_info, FAIL)
+ FUNC_ENTER_API(H5Fget_info2, FAIL)
H5TRACE2("e", "i*x", obj_id, finfo);
/* Check args */
@@ -2844,18 +2852,67 @@ H5Fget_info(hid_t obj_id, H5F_info_t *finfo)
HDassert(f->shared);
/* Reset file info struct */
- HDmemset(finfo, 0, sizeof(H5F_info_t));
+ HDmemset(finfo, 0, sizeof(*finfo));
+
+ /* Get the size of the superblock and any superblock extensions */
+ if(H5F_super_size(f, H5AC_ind_dxpl_id, &finfo->super.super_size, &finfo->super.super_ext_size) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "Unable to retrieve superblock sizes")
- /* Check for superblock extension info */
- if(H5F_super_size(f, H5AC_ind_dxpl_id, NULL, &finfo->super_ext_size) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "Unable to retrieve superblock extension size")
+ /* Get the size of any persistent free space */
+ if(H5MF_get_freespace(f, H5AC_ind_dxpl_id, &finfo->free.tot_space, &finfo->free.meta_size) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "Unable to retrieve free space information")
/* Check for SOHM info */
if(H5F_addr_defined(f->shared->sohm_addr))
- if(H5SM_ih_size(f, H5AC_ind_dxpl_id, finfo) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "Unable to retrieve SOHM btree & heap storage info")
+ if(H5SM_ih_size(f, H5AC_ind_dxpl_id, &finfo->sohm.hdr_size, &finfo->sohm.msgs_info) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "Unable to retrieve SOHM index & heap storage info")
+
+ /* Set version # fields */
+ finfo->super.version = f->shared->sblock->super_vers;
+ finfo->sohm.version = f->shared->sohm_vers;
+ finfo->free.version = HDF5_FREESPACE_VERSION;
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Fget_info2() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Fget_free_sections
+ *
+ * Purpose: To get free-space section information for free-space manager with
+ * TYPE that is associated with file FILE_ID.
+ * If SECT_INFO is null, this routine returns the total # of free-space
+ * sections.
+ *
+ * Return: Success: non-negative, the total # of free space sections
+ * Failure: negative
+ *
+ * Programmer: Vailin Choi; July 1st, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+ssize_t
+H5Fget_free_sections(hid_t file_id, H5F_mem_t type, size_t nsects,
+ H5F_sect_info_t *sect_info/*out*/)
+{
+ H5F_t *file; /* Top file in mount hierarchy */
+ ssize_t ret_value; /* Return value */
+
+ FUNC_ENTER_API(H5Fget_free_sections, FAIL)
+ H5TRACE4("Zs", "iFmzx", file_id, type, nsects, sect_info);
+
+ /* Check args */
+ if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID")
+ if(sect_info && nsects == 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "nsects must be > 0")
+
+ /* Go get the free-space section information in the file */
+ if((ret_value = H5MF_get_free_sections(file, H5AC_ind_dxpl_id, type, nsects, sect_info)) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file")
done:
FUNC_LEAVE_API(ret_value)
-} /* end H5Fget_info() */
+} /* end H5Fget_free_sections() */