summaryrefslogtreecommitdiffstats
path: root/src/H5Fsuper.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-08-12 22:04:35 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-08-12 22:04:35 (GMT)
commit328d540a34a6ccabd9a354453b38accef0dd6682 (patch)
tree3f2338d555f4b059fbfd34c49ce3d2d49321b150 /src/H5Fsuper.c
parent7a1fcfa41974c02b1b7787e2f9627e0027868860 (diff)
downloadhdf5-328d540a34a6ccabd9a354453b38accef0dd6682.zip
hdf5-328d540a34a6ccabd9a354453b38accef0dd6682.tar.gz
hdf5-328d540a34a6ccabd9a354453b38accef0dd6682.tar.bz2
[svn-r17347] Description:
Bring r17299:17346 from trunk to revise_chunks branch (including rerunning bin/reconfigure, after the autotools update in 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/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-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Diffstat (limited to 'src/H5Fsuper.c')
-rw-r--r--src/H5Fsuper.c292
1 files changed, 229 insertions, 63 deletions
diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c
index 32541ae..f5973e9 100644
--- a/src/H5Fsuper.c
+++ b/src/H5Fsuper.c
@@ -110,6 +110,10 @@
/********************/
/* 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_write_msg(H5F_t *f, hid_t dxpl_id, void *mesg, unsigned id, hbool_t may_create);
+static herr_t H5F_super_ext_close(H5F_t *f, H5O_loc_t *ext_ptr);
/*********************/
@@ -214,6 +218,114 @@ done:
/*-------------------------------------------------------------------------
+ * 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
*
* Purpose: Reads the superblock from the file or from the BUF. If
@@ -584,14 +696,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 +754,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 +892,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 +937,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:
@@ -1015,7 +1110,6 @@ H5F_super_write(H5F_t *f, hid_t dxpl_id)
/* Check for driver info message */
H5_ASSIGN_OVERFLOW(driver_size, H5FD_sb_size(f->shared->lf), hsize_t, size_t);
if(driver_size > 0) {
- H5O_loc_t ext_loc; /* "Object location" for superblock extension */
H5O_drvinfo_t drvinfo; /* Driver info */
uint8_t dbuf[H5F_MAX_DRVINFOBLOCK_SIZE]; /* Driver info block encoding buffer */
@@ -1026,28 +1120,11 @@ 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")
-
/* Write driver info information to the superblock extension */
drvinfo.len = driver_size;
drvinfo.buf = dbuf;
- 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--;
+ if(H5F_super_ext_write_msg(f, dxpl_id, &drvinfo, H5O_DRVINFO_ID, FALSE) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "unable to update driver info header message")
} /* end if */
} /* end if */
@@ -1057,8 +1134,9 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5F_super_ext_size
- * Get storage size of the superblock extension
+ * Function: H5F_super_size
+ *
+ * Purpose: Get storage size of the superblock and superblock extension
*
* Return: Success: non-negative on success
* Failure: Negative
@@ -1068,31 +1146,119 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5F_super_ext_size(H5F_t *f, hid_t dxpl_id, hsize_t *super_ext_size)
+H5F_super_size(H5F_t *f, hid_t dxpl_id, hsize_t *super_size, hsize_t *super_ext_size)
{
- H5O_loc_t ext_loc; /* "Object location" for superblock extension */
- H5O_info_t oinfo; /* Object info for superblock extension */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5F_super_ext_size, FAIL)
+ FUNC_ENTER_NOAPI(H5F_super_size, FAIL)
/* Sanity check */
HDassert(f);
- HDassert(super_ext_size);
- /* Set up "fake" object location for superblock extension */
- H5O_loc_reset(&ext_loc);
- ext_loc.file = f;
- ext_loc.addr = f->shared->extension_addr;
+ /* Set the superblock size */
+ if(super_size) {
+ H5P_genplist_t *plist; /* File creation property list */
+ unsigned super_vers; /* Superblock version */
- /* Get object header info for superblock extension */
- if(H5O_get_info(&ext_loc, dxpl_id, FALSE, &oinfo) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve superblock extension info")
+ /* Get the shared file creation property list */
+ if(NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
+
+ /* Grab values from property list */
+ if(H5P_get(plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get superblock version")
+
+ /* Set the superblock size */
+ *super_size = H5F_SUPERBLOCK_SIZE(super_vers, f);
+ } /* end if */
/* Set the superblock extension size */
- *super_ext_size = oinfo.hdr.space.total;
+ if(super_ext_size) {
+ if(H5F_addr_defined(f->shared->extension_addr)) {
+ H5O_loc_t ext_loc; /* "Object location" for superblock extension */
+ H5O_info_t oinfo; /* Object info for superblock extension */
+
+ /* Set up "fake" object location for superblock extension */
+ H5O_loc_reset(&ext_loc);
+ ext_loc.file = f;
+ ext_loc.addr = f->shared->extension_addr;
+
+ /* Get object header info for superblock extension */
+ if(H5O_get_info(&ext_loc, dxpl_id, FALSE, &oinfo) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve superblock extension info")
+
+ /* Set the superblock extension size */
+ *super_ext_size = oinfo.hdr.space.total;
+ } /* end if */
+ else
+ /* Set the superblock extension size to zero */
+ *super_ext_size = (hsize_t)0;
+ } /* end if */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5F_super_size() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5F_super_ext_write_msg()
+ *
+ * Purpose: Write the message with ID to the superblock extension
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Vailin Choi; Feb 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5F_super_ext_write_msg(H5F_t *f, hid_t dxpl_id, void *mesg, unsigned id, hbool_t may_create)
+{
+ H5O_loc_t ext_loc; /* "Object location" for superblock extension */
+ htri_t status; /* Indicate whether the message exists or not */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5F_super_ext_write_msg)
+
+ /* Open/create the superblock extension object header */
+ if(H5F_addr_defined(f->shared->extension_addr)) {
+ if(H5F_super_ext_open(f, &ext_loc) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, FAIL, "unable to open file's superblock extension")
+ } /* end if */
+ else {
+ HDassert(may_create);
+ if(H5F_super_ext_create(f, dxpl_id, &ext_loc) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "unable to create file's superblock extension")
+ } /* end else */
+ HDassert(H5F_addr_defined(ext_loc.addr));
+
+ /* Check if message with ID does not exist in the object header */
+ if((status = H5O_msg_exists(&ext_loc, id, dxpl_id)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to check object header for message or message exists")
+
+ /* Check for creating vs. writing */
+ if(may_create) {
+ if(status)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "Message should not exist")
+
+ /* Create the message with ID in the superblock extension */
+ if(H5O_msg_create(&ext_loc, id, H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, mesg, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to create the message in object header")
+ } /* end if */
+ else {
+ if(!status)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "Message should exist")
+
+ /* Update the message with ID in the superblock extension */
+ if(H5O_msg_write(&ext_loc, id, H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, mesg, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to write the message in object header")
+ } /* end else */
+
+ /* Close the superblock extension object header */
+ if(H5F_super_ext_close(f, &ext_loc) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to close file's superblock extension")
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5F_super_ext_size() */
+} /* H5F_super_ext_write_msg() */