summaryrefslogtreecommitdiffstats
path: root/src/H5B.c
diff options
context:
space:
mode:
authorBill Wendling <wendling@ncsa.uiuc.edu>2003-09-18 19:27:27 (GMT)
committerBill Wendling <wendling@ncsa.uiuc.edu>2003-09-18 19:27:27 (GMT)
commitfec0297f869e1f34bd4bb4fc0cb91ac403b73ccb (patch)
treee56930c56bd7f8ad7058bf5438dbe8b8da36c00e /src/H5B.c
parent2e3693aa8be42bfd1d30adda1dd3b278c9d450ec (diff)
downloadhdf5-fec0297f869e1f34bd4bb4fc0cb91ac403b73ccb.zip
hdf5-fec0297f869e1f34bd4bb4fc0cb91ac403b73ccb.tar.gz
hdf5-fec0297f869e1f34bd4bb4fc0cb91ac403b73ccb.tar.bz2
[svn-r7489] Purpose:
Update Description: A lot of modifications for the FPHDF5 stuff: H5AC.c H5ACprivate.h - Removed AC_find (it's replaced with AC_protect and AC_unprotect). Added flushing if it's an FPHDF5 driver and we're doing an AC_set or AC_unprotect with the dirty flag set. H5B.c - Split up the B_flush function into different functions since the one function was doing serialization which is better left as a separate entity. H5D.c - Removed some FPHDF5 code that was incorrect H5F.c - Split up the F_flush function so that it no longer allocates file space. Created new functions (F_init_superblock, F_read_superblock, and F_write_superblock) for greater modularity and so that the FPHDF5 non-captain processes can read the superblock after the captain process writes it. H5FD.c - Error message correction. H5FDfphdf5.c - Removed MPI barrier call that wasn't needed. H5FPclient.c H5FPserver.c - Modified so that if a process requests data that isn't exactly aligned, we can return it if we have the block that contains the requested address. H5G.c H5Gent.c H5Gnode.c H5HL.c H5HLpkg.h H5HLprivate.h H5Oefl.c - Removed the H5HL_peek function since it was doing a (now unsafe) holding of the information in the cache. Replaced with protect and unprotect calls. H5TB.c - Error fix. The TB_dless function wasn't working properly. H5Gstab.c - Format change. H5err.txt H5Edefin.h H5Einit.h H5Epubgen.h H5Eterm.h - Added new error code. Platforms tested: Modi4 (paralle, Fortran) Sol (Fortran) Linux (C++, Fortran) Copper (Parallel, Fortran) Misc. update:
Diffstat (limited to 'src/H5B.c')
-rw-r--r--src/H5B.c191
1 files changed, 132 insertions, 59 deletions
diff --git a/src/H5B.c b/src/H5B.c
index 23a0607..1d24ded 100644
--- a/src/H5B.c
+++ b/src/H5B.c
@@ -145,6 +145,8 @@ static herr_t H5B_split(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_t
const double split_ratios[], void *udata,
haddr_t *new_addr/*out*/);
static H5B_t * H5B_copy(const H5F_t *f, const H5B_t *old_bt);
+static herr_t H5B_serialize(H5F_t *f, H5B_t *bt, uint8_t *buf);
+static size_t H5B_size(H5F_t *f, H5B_t *bt);
#ifdef H5B_DEBUG
static herr_t H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type,
void *udata);
@@ -403,6 +405,78 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5B_serialize
+ *
+ * Purpose: Serialize the data structure for writing to disk or
+ * storing on the SAP (for FPHDF5).
+ *
+ * Return: Success: SUCCEED
+ * Failure: FAIL
+ *
+ * Programmer: Bill Wendling
+ * wendling@ncsa.uiuc.edu
+ * Sept. 15, 2003
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5B_serialize(H5F_t *f, H5B_t *bt, uint8_t *buf)
+{
+ unsigned u;
+ uint8_t *p = NULL;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5B_serialize, FAIL)
+
+ /* check arguments */
+ assert(f);
+ assert(bt);
+ assert(bt->page);
+ assert(bt->type);
+
+ p = buf;
+
+ /* magic number */
+ HDmemcpy(p, H5B_MAGIC, H5B_SIZEOF_MAGIC);
+ p += 4;
+
+ /* node type and level */
+ *p++ = bt->type->id;
+ H5_CHECK_OVERFLOW(bt->level, int, uint8_t);
+ *p++ = (uint8_t)bt->level;
+
+ /* entries used */
+ UINT16ENCODE(p, bt->nchildren);
+
+ /* sibling pointers */
+ H5F_addr_encode(f, &p, bt->left);
+ H5F_addr_encode(f, &p, bt->right);
+
+ /* child keys and pointers */
+ for (u = 0; u <= bt->nchildren; ++u) {
+ /* encode the key */
+ assert(bt->key[u].rkey == p);
+ p += bt->sizeof_rkey;
+
+ /* encode the key */
+ if (bt->key[u].dirty && bt->key[u].nkey)
+ if (bt->type->encode(f, bt, bt->key[u].rkey, bt->key[u].nkey) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree key")
+
+ /* encode the child address */
+ if (u < bt->ndirty)
+ H5F_addr_encode(f, &p, bt->child[u]);
+ else
+ p += H5F_SIZEOF_ADDR(f);
+ }
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+}
+
+/*-------------------------------------------------------------------------
* Function: H5B_flush
*
* Purpose: Flushes a dirty B-tree node to disk.
@@ -414,92 +488,61 @@ done:
* Jun 23 1997
*
* Modifications:
- * rky 980828
- * Only p0 writes metadata to disk.
+ * rky 980828
+ * Only p0 writes metadata to disk.
*
- * Robb Matzke, 1999-07-28
- * The ADDR argument is passed by value.
+ * Robb Matzke, 1999-07-28
+ * The ADDR argument is passed by value.
*
* Quincey Koziol, 2002-7-180
* Added dxpl parameter to allow more control over I/O from metadata
* cache.
+ *
+ * Bill Wendling, 2003-09-15
+ * Separated out the bit of code that serializes the B-Tree
+ * structure.
+ *
*-------------------------------------------------------------------------
*/
static herr_t
H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B_t *bt)
{
- size_t size = 0;
- uint8_t *p = bt->page;
- unsigned u; /* Local index variable */
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5B_flush, FAIL)
- /*
- * Check arguments.
- */
+ /* check arguments */
assert(f);
assert(H5F_addr_defined(addr));
assert(bt);
assert(bt->type);
assert(bt->type->encode);
- size = H5B_nodesize(f, bt->type, NULL, bt->sizeof_rkey);
-
if (bt->cache_info.dirty) {
+ unsigned u;
- /* magic number */
- HDmemcpy(p, H5B_MAGIC, H5B_SIZEOF_MAGIC);
- p += 4;
-
- /* node type and level */
- *p++ = bt->type->id;
- H5_CHECK_OVERFLOW(bt->level,int,uint8_t);
- *p++ = (uint8_t)bt->level;
-
- /* entries used */
- UINT16ENCODE(p, bt->nchildren);
-
- /* sibling pointers */
- H5F_addr_encode(f, &p, bt->left);
- H5F_addr_encode(f, &p, bt->right);
-
- /* child keys and pointers */
- for (u=0; u<=bt->nchildren; u++) {
+ if (H5B_serialize(f, bt, bt->page) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTSERIALIZE, FAIL, "unable to serialize B-tree")
- /* encode the key */
- assert(bt->key[u].rkey == p);
- if (bt->key[u].dirty) {
- if (bt->key[u].nkey) {
- if ((bt->type->encode) (f, bt, bt->key[u].rkey, bt->key[u].nkey) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree key")
- }
- bt->key[u].dirty = FALSE;
- }
- p += bt->sizeof_rkey;
-
- /* encode the child address */
- if (u < bt->ndirty) {
- H5F_addr_encode(f, &p, bt->child[u]);
- } else {
- p += H5F_SIZEOF_ADDR(f);
- }
- }
+ /* child keys and pointers */
+ for (u = 0; u <= bt->nchildren; ++u)
+ bt->key[u].dirty = FALSE;
/*
- * Write the disk page. We always write the header, but we don't
- * bother writing data for the child entries that don't exist or
- * for the final unchanged children.
+ * Write the disk page. We always write the header, but we don't
+ * bother writing data for the child entries that don't exist or
+ * for the final unchanged children.
*/
- if (H5F_block_write(f, H5FD_MEM_BTREE, addr, size, dxpl_id, bt->page)<0)
+ if (H5F_block_write(f, H5FD_MEM_BTREE, addr, H5B_size(f, bt), dxpl_id, bt->page) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL, "unable to save B-tree node to disk")
+
bt->cache_info.dirty = FALSE;
bt->ndirty = 0;
}
- if (destroy) {
- if(H5B_dest(f,bt)<0)
+
+ if (destroy)
+ if (H5B_dest(f,bt) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree node")
- }
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -588,6 +631,38 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5B_size
+ *
+ * Purpose: Get the size of the B-tree node on disk.
+ *
+ * Return: Doesn't fail.
+ *
+ * Programmer: Bill Wendling
+ * wendling@ncsa.uiuc.edu
+ * Sept. 16, 2003
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static size_t
+H5B_size(H5F_t *f, H5B_t *bt)
+{
+ size_t ret_value = 0;
+
+ FUNC_ENTER_NOINIT(H5B_size)
+
+ /* check args */
+ assert(f);
+ assert(bt);
+ assert(bt->type);
+
+ ret_value = H5B_nodesize(f, bt->type, NULL, bt->sizeof_rkey);
+ FUNC_LEAVE_NOAPI(ret_value);
+}
+
+
+/*-------------------------------------------------------------------------
* Function: H5B_find
*
* Purpose: Locate the specified information in a B-tree and return
@@ -977,9 +1052,7 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
FUNC_ENTER_NOAPI(H5B_insert, FAIL)
- /*
- * Check arguments.
- */
+ /* Check arguments. */
assert(f);
assert(type);
assert(type->sizeof_nkey <= sizeof _lt_key);