diff options
-rw-r--r-- | src/H5AC.c | 3 | ||||
-rw-r--r-- | src/H5ACprivate.h | 3 | ||||
-rw-r--r-- | src/H5B2dbg.c | 12 | ||||
-rw-r--r-- | src/H5B2private.h | 2 | ||||
-rw-r--r-- | src/H5BT.c | 110 | ||||
-rw-r--r-- | src/H5BTbtree2.c | 218 | ||||
-rw-r--r-- | src/H5BTcache.c | 331 | ||||
-rw-r--r-- | src/H5BTdbg.c | 104 | ||||
-rw-r--r-- | src/H5BTpkg.h | 109 | ||||
-rw-r--r-- | src/H5BTprivate.h | 52 | ||||
-rw-r--r-- | src/H5BTpublic.h | 52 | ||||
-rw-r--r-- | src/H5Edefin.h | 1 | ||||
-rw-r--r-- | src/H5Einit.h | 5 | ||||
-rw-r--r-- | src/H5Epubgen.h | 2 | ||||
-rw-r--r-- | src/H5Eterm.h | 1 | ||||
-rw-r--r-- | src/H5FDpublic.h | 5 | ||||
-rw-r--r-- | src/H5err.txt | 1 | ||||
-rwxr-xr-x | src/Makefile.am | 5 | ||||
-rw-r--r-- | src/Makefile.in | 12 | ||||
-rw-r--r-- | test/Makefile.am | 4 | ||||
-rw-r--r-- | test/Makefile.in | 38 | ||||
-rw-r--r-- | test/blocktrack.c | 138 | ||||
-rw-r--r-- | tools/misc/h5debug.c | 68 |
23 files changed, 1201 insertions, 75 deletions
@@ -346,7 +346,8 @@ static const char * H5AC_entry_type_names[H5AC_NTYPES] = "object headers", "v2 B-tree headers", "v2 B-tree internal nodes", - "v2 B-tree leaf nodes" + "v2 B-tree leaf nodes", + "block tracker nodes" }; herr_t diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index 44bd862..bdfc57b 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -47,7 +47,8 @@ #define H5AC_BT2_HDR_ID 5 /*v2 B-tree header */ #define H5AC_BT2_INT_ID 6 /*v2 B-tree internal node */ #define H5AC_BT2_LEAF_ID 7 /*v2 B-tree leaf node */ -#define H5AC_NTYPES 8 +#define H5AC_BLTR_ID 8 /*block tracker */ +#define H5AC_NTYPES 9 /* H5AC_DUMP_STATS_ON_CLOSE should always be FALSE when * H5C_COLLECT_CACHE_STATS is FALSE. diff --git a/src/H5B2dbg.c b/src/H5B2dbg.c index 0801a6f..b73bf49 100644 --- a/src/H5B2dbg.c +++ b/src/H5B2dbg.c @@ -80,7 +80,7 @@ H5B2_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Tree type ID:", ((shared->type->id)==H5B2_TEST_ID ? "H5B2_TEST_ID" : - ((shared->type->id)==H5B2_GRP_NAME_ID ? "H5B2_GRP_NAME_ID" : + ((shared->type->id)==H5B2_BLK_TRK_ID ? "H5B2_BLK_TRK_ID" : "Unknown!"))); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Size of node:", @@ -133,7 +133,7 @@ done: HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree header") FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5B2_hdr_debug() */ /*------------------------------------------------------------------------- @@ -198,7 +198,7 @@ H5B2_int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Tree type ID:", ((shared->type->id)==H5B2_TEST_ID ? "H5B2_TEST_ID" : - ((shared->type->id)==H5B2_GRP_NAME_ID ? "H5B2_GRP_NAME_ID" : + ((shared->type->id)==H5B2_BLK_TRK_ID ? "H5B2_BLK_TRK_ID" : "Unknown!"))); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Size of node:", @@ -245,7 +245,7 @@ done: HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree internal node") FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5B2_int_debug() */ /*------------------------------------------------------------------------- @@ -310,7 +310,7 @@ H5B2_leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Tree type ID:", ((shared->type->id)==H5B2_TEST_ID ? "H5B2_TEST_ID" : - ((shared->type->id)==H5B2_GRP_NAME_ID ? "H5B2_GRP_NAME_ID" : + ((shared->type->id)==H5B2_BLK_TRK_ID ? "H5B2_BLK_TRK_ID" : "Unknown!"))); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Size of node:", @@ -341,5 +341,5 @@ done: HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree leaf node") FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5B2_leaf_debug() */ diff --git a/src/H5B2private.h b/src/H5B2private.h index 5c71674..c0abff9 100644 --- a/src/H5B2private.h +++ b/src/H5B2private.h @@ -52,7 +52,7 @@ /* B-tree IDs for various internal things. */ typedef enum H5B2_subid_t { H5B2_TEST_ID = 0, /* B-tree is for testing (do not use for actual data) */ - H5B2_GRP_NAME_ID, /* B-tree is for group links, ordered by name */ + H5B2_BLK_TRK_ID, /* B-tree is for block tracker records */ H5B2_NUM_BTREE_ID /* Number of B-tree IDs (must be last) */ } H5B2_subid_t; diff --git a/src/H5BT.c b/src/H5BT.c new file mode 100644 index 0000000..c24ce06 --- /dev/null +++ b/src/H5BT.c @@ -0,0 +1,110 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5BT.c + * Mar 9 2005 + * Quincey Koziol <koziol@ncsa.uiuc.edu> + * + * Purpose: Tracks blocks of bytes in a file + * + *------------------------------------------------------------------------- + */ + +#define H5BT_PACKAGE /*suppress error about including H5BTpkg */ + +/* Private headers */ +#include "H5private.h" /* Generic Functions */ +#include "H5BTpkg.h" /* Block tracker */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MFprivate.h" /* File memory management */ + +/* Local macros */ + +/* v2 B-tree info */ +#define H5BT_BT2_NODE_SIZE 512 +#define H5BT_BT2_RREC_SIZE(f) (H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f)) /* Offset & length of block tracked */ +#define H5BT_BT2_SPLIT_PERC 100 +#define H5BT_BT2_MERGE_PERC 40 + +/* Local typedefs */ + +/* Local prototypes */ + +/* Package variables */ + +/* Declare a free list to manage the H5BT_t struct */ +H5FL_DEFINE(H5BT_t); + +/* Static variables */ + + +/*------------------------------------------------------------------------- + * Function: H5BT_create + * + * Purpose: Creates a new empty block tracker in the file. + * + * Return: Non-negative on success (with address of new block tracker + * filled in), negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Mar 10 2005 + * + *------------------------------------------------------------------------- + */ +herr_t +H5BT_create(H5F_t *f, hid_t dxpl_id, haddr_t *addr_p) +{ + H5BT_t *bt = NULL; /* The new B-tree header information */ + herr_t ret_value=SUCCEED; + + FUNC_ENTER_NOAPI(H5BT_create, FAIL) + + /* + * Check arguments. + */ + HDassert(f); + + /* + * Allocate file and memory data structures. + */ + if (NULL==(bt = H5FL_CALLOC(H5BT_t))) + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for block tracker info") + + /* Assign internal information */ + bt->cache_info.is_dirty = TRUE; + + /* Allocate space for the header on disk */ + if (HADDR_UNDEF==(*addr_p=H5MF_alloc(f, H5FD_MEM_BLKTRK, dxpl_id, (hsize_t)H5BT_SIZE(f)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for block tracker info") + + /* Create a B-tree for storing the block info records */ + if (H5B2_create(f, dxpl_id, H5B2_BLKTRK, H5BT_BT2_NODE_SIZE, H5BT_BT2_RREC_SIZE(f), H5BT_BT2_SPLIT_PERC, H5BT_BT2_MERGE_PERC, &bt->bt2_addr/*out*/)<0) + HGOTO_ERROR(H5E_BLKTRK, H5E_CANTINIT, FAIL, "can't create B-tree for storing block info") + + /* Cache the new B-tree node */ + if (H5AC_set(f, dxpl_id, H5AC_BLTR, *addr_p, bt, H5AC__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_BLKTRK, H5E_CANTINIT, FAIL, "can't add block tracker info to cache") + +done: + if (ret_value<0) { + if (bt) + (void)H5BT_cache_dest(f,bt); + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5BT_create() */ + diff --git a/src/H5BTbtree2.c b/src/H5BTbtree2.c new file mode 100644 index 0000000..4c37004 --- /dev/null +++ b/src/H5BTbtree2.c @@ -0,0 +1,218 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu> + * Thursday, March 10, 2005 + * + * Purpose: v2 B-tree callback routines for block info records + */ + +#define H5BT_PACKAGE /*suppress error about including H5BTpkg */ + +/* Private headers */ +#include "H5private.h" /* Generic Functions */ +#include "H5BTpkg.h" /* Block tracker */ +#include "H5Eprivate.h" /* Error handling */ + +/* Static Prototypes */ +static herr_t H5BT_store(void *nrecord, const void *udata); +static herr_t H5BT_retrieve(void *udata, const void *nrecord); +static herr_t H5BT_compare(const void *rec1, const void *rec2); +static herr_t H5BT_encode(const H5F_t *f, uint8_t *raw, + const void *nrecord); +static herr_t H5BT_decode(const H5F_t *f, const uint8_t *raw, + void *nrecord); +static herr_t H5BT_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, + int indent, int fwidth, const void *record, const void *_udata); + +/* Package variables */ +const H5B2_class_t H5B2_BLKTRK[1]={{ /* B-tree class information */ + H5B2_BLK_TRK_ID, /* Type of B-tree */ + sizeof(hsize_t), /* Size of native key */ + H5BT_store, /* Record storage callback */ + H5BT_retrieve, /* Record retrieval callback */ + H5BT_compare, /* Record comparison callback */ + H5BT_encode, /* Record encoding callback */ + H5BT_decode, /* Record decoding callback */ + H5BT_debug /* Record debugging callback */ +}}; + + +/*------------------------------------------------------------------------- + * Function: H5BT_store + * + * Purpose: Store native information into record for B-tree + * + * Return: Success: non-negative + * + * Failure: negative + * + * Programmer: Quincey Koziol + * Thursday, March 10, 2005 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5BT_store(void *nrecord, const void *udata) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5BT_store) + + *(H5BT_blk_info_t *)nrecord=*(const H5BT_blk_info_t *)udata; + + FUNC_LEAVE_NOAPI(SUCCEED); +} /* H5BT_store() */ + + +/*------------------------------------------------------------------------- + * Function: H5BT_retrieve + * + * Purpose: Retrieve native information from record for B-tree + * + * Return: Success: non-negative + * + * Failure: negative + * + * Programmer: Quincey Koziol + * Thursday, March 10, 2005 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5BT_retrieve(void *udata, const void *nrecord) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5BT_retrieve) + + *(H5BT_blk_info_t *)udata=*(const H5BT_blk_info_t *)nrecord; + + FUNC_LEAVE_NOAPI(SUCCEED); +} /* H5BT_retrieve() */ + + +/*------------------------------------------------------------------------- + * Function: H5BT_compare + * + * Purpose: Compare two native information records, according to some key + * + * Return: <0 if rec1 < rec2 + * =0 if rec1 == rec2 + * >0 if rec1 > rec2 + * + * Programmer: Quincey Koziol + * Thursday, March 10, 2005 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5BT_compare(const void *rec1, const void *rec2) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5BT_compare) + + FUNC_LEAVE_NOAPI(H5F_addr_cmp(((const H5BT_blk_info_t *)rec1)->addr,((const H5BT_blk_info_t *)rec2)->addr)); +} /* H5BT_compare() */ + + +/*------------------------------------------------------------------------- + * Function: H5BT_encode + * + * Purpose: Encode native information into raw form for storing on disk + * + * Return: Success: non-negative + * + * Failure: negative + * + * Programmer: Quincey Koziol + * Thursday, March 10, 2005 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5BT_encode(const H5F_t *f, uint8_t *raw, const void *nrecord) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5BT_encode) + + H5F_addr_encode(f, &raw, ((const H5BT_blk_info_t *)nrecord)->addr); + H5F_ENCODE_LENGTH(f, raw, ((const H5BT_blk_info_t *)nrecord)->len); + + FUNC_LEAVE_NOAPI(SUCCEED); +} /* H5BT_encode() */ + + +/*------------------------------------------------------------------------- + * Function: H5BT_decode + * + * Purpose: Decode raw disk form of record into native form + * + * Return: Success: non-negative + * + * Failure: negative + * + * Programmer: Quincey Koziol + * Thursday, March 10, 2005 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5BT_decode(const H5F_t *f, const uint8_t *raw, void *nrecord) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5BT_decode) + + H5F_addr_decode(f, &raw, &(((H5BT_blk_info_t *)nrecord)->addr)); + H5F_DECODE_LENGTH(f, raw, ((H5BT_blk_info_t *)nrecord)->len); + + FUNC_LEAVE_NOAPI(SUCCEED); +} /* H5BT_decode() */ + + +/*------------------------------------------------------------------------- + * Function: H5BT_debug + * + * Purpose: Debug native form of record + * + * Return: Success: non-negative + * + * Failure: negative + * + * Programmer: Quincey Koziol + * Thursday, March 10, 2005 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5BT_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id, int indent, int fwidth, + const void *record, const void UNUSED *_udata) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5BT_debug) + + HDassert (record); + + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Block Address:", + ((const H5BT_blk_info_t *)record)->addr); + HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, "Block Length:", + ((const H5BT_blk_info_t *)record)->len); + + FUNC_LEAVE_NOAPI(SUCCEED); +} /* H5BT_debug() */ + diff --git a/src/H5BTcache.c b/src/H5BTcache.c new file mode 100644 index 0000000..60c31b3 --- /dev/null +++ b/src/H5BTcache.c @@ -0,0 +1,331 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5BTcache.c + * Mar 10 2005 + * Quincey Koziol <koziol@ncsa.uiuc.edu> + * + * Purpose: Implement block tracker metadata cache methods. + * + *------------------------------------------------------------------------- + */ + +#define H5BT_PACKAGE /*suppress error about including H5B2pkg */ + +/* Private headers */ +#include "H5private.h" /* Generic Functions */ +#include "H5BTpkg.h" /* Block tracker */ +#include "H5Eprivate.h" /* Error handling */ + +/* Local macros */ + +/* Block tracker format version #'s */ +#define H5BT_VERSION 0 + + +/* Local typedefs */ + +/* Local prototypes */ + +/* Metadata cache callbacks */ +static H5BT_t *H5BT_cache_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata); +static herr_t H5BT_cache_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5BT_t *b); +static herr_t H5BT_cache_clear(H5F_t *f, H5BT_t *b, hbool_t destroy); +static herr_t H5BT_cache_size(const H5F_t *f, const H5BT_t *bt, size_t *size_ptr); + +/* Package variables */ + +/* H5BT inherits cache-like properties from H5AC */ +const H5AC_class_t H5AC_BLTR[1] = {{ + H5AC_BLTR_ID, + (H5AC_load_func_t)H5BT_cache_load, + (H5AC_flush_func_t)H5BT_cache_flush, + (H5AC_dest_func_t)H5BT_cache_dest, + (H5AC_clear_func_t)H5BT_cache_clear, + (H5AC_size_func_t)H5BT_cache_size, +}}; + +/* Static variables */ + +/* Declare a free list to manage block tracker data to/from disk */ +H5FL_BLK_DEFINE_STATIC(info_block); + + + +/*------------------------------------------------------------------------- + * Function: H5BT_cache_load + * + * Purpose: Loads block tracker info from the disk. + * + * Return: Success: Pointer to a new block tracker + * + * Failure: NULL + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Mar 10 2005 + * + *------------------------------------------------------------------------- + */ +static H5BT_t * +H5BT_cache_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1, void UNUSED *udata2) +{ + H5BT_t *bt = NULL; + size_t size; + uint8_t *buf = NULL; + uint8_t *p; /* Pointer into raw data buffer */ + H5BT_t *ret_value; + + FUNC_ENTER_NOAPI(H5BT_cache_load, NULL) + + /* Check arguments */ + HDassert(f); + HDassert(H5F_addr_defined(addr)); + + if (NULL==(bt = H5FL_MALLOC(H5BT_t))) + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + HDmemset(&bt->cache_info,0,sizeof(H5AC_info_t)); + + /* Compute the size of the B-tree header on disk */ + size = H5BT_SIZE(f); + + /* Allocate temporary buffer */ + if ((buf=H5FL_BLK_MALLOC(info_block,size))==NULL) + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + + /* Read header from disk */ + if (H5F_block_read(f, H5FD_MEM_BLKTRK, addr, size, dxpl_id, buf)<0) + HGOTO_ERROR(H5E_BLKTRK, H5E_READERROR, NULL, "can't read block tracker info") + + p = buf; + + /* magic number */ + if (HDmemcmp(p, H5BT_MAGIC, H5BT_SIZEOF_MAGIC)) + HGOTO_ERROR(H5E_BLKTRK, H5E_CANTLOAD, NULL, "wrong block tracker info signature") + p += H5BT_SIZEOF_MAGIC; + + /* version */ + if (*p++ != H5BT_VERSION) + HGOTO_ERROR(H5E_BLKTRK, H5E_CANTLOAD, NULL, "wrong block tracker info version") + + /* Size status information */ + bt->status = *p++; + + /* Max. block size info */ + H5F_DECODE_LENGTH(f, p, bt->max_block_size); + UINT32DECODE(p, bt->max_block_cnt); + + /* Min. block size info */ + H5F_DECODE_LENGTH(f, p, bt->min_block_size); + UINT32DECODE(p, bt->min_block_cnt); + + /* Total size of all blocks tracked */ + H5F_DECODE_LENGTH(f, p, bt->tot_block_size); + + /* Address of B-tree for blocks */ + H5F_addr_decode(f, (const uint8_t **)&p, &(bt->bt2_addr)); + + /* Set return value */ + ret_value = bt; + +done: + if(buf) + H5FL_BLK_FREE(info_block,buf); + if (!ret_value && bt) + (void)H5BT_cache_dest(f,bt); + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5BT_cache_load() */ + + +/*------------------------------------------------------------------------- + * Function: H5BT_cache_flush + * + * Purpose: Flushes dirty block tracker info to disk. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Mar 10 2005 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5BT_cache_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5BT_t *bt) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5BT_cache_flush, FAIL) + + /* check arguments */ + HDassert(f); + HDassert(H5F_addr_defined(addr)); + HDassert(bt); + + if (bt->cache_info.is_dirty) { + uint8_t *buf = NULL; + uint8_t *p; /* Pointer into raw data buffer */ + size_t size; + + /* Compute the size of the B-tree header on disk */ + size = H5BT_SIZE(f); + + /* Allocate temporary buffer */ + if ((buf=H5FL_BLK_MALLOC(info_block,size))==NULL) + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + + p = buf; + + /* magic number */ + HDmemcpy(p, H5BT_MAGIC, H5BT_SIZEOF_MAGIC); + p += H5BT_SIZEOF_MAGIC; + + /* version # */ + *p++ = H5BT_VERSION; + + /* Size status information */ + *p++ = bt->status; + + /* Max. block size info */ + H5F_ENCODE_LENGTH(f, p, bt->max_block_size); + UINT32ENCODE(p, bt->max_block_cnt); + + /* Min. block size info */ + H5F_ENCODE_LENGTH(f, p, bt->min_block_size); + UINT32ENCODE(p, bt->min_block_cnt); + + /* Total size of all blocks tracked */ + H5F_ENCODE_LENGTH(f, p, bt->tot_block_size); + + /* Address of B-tree for blocks */ + H5F_addr_encode(f, &p, bt->bt2_addr); + + /* Write the block tracker info. */ + if (H5F_block_write(f, H5FD_MEM_BLKTRK, addr, size, dxpl_id, buf) < 0) + HGOTO_ERROR(H5E_BLKTRK, H5E_CANTFLUSH, FAIL, "unable to save block tracker info to disk") + + H5FL_BLK_FREE(info_block,buf); + + bt->cache_info.is_dirty = FALSE; + } /* end if */ + + if (destroy) + if (H5BT_cache_dest(f,bt) < 0) + HGOTO_ERROR(H5E_BLKTRK, H5E_CANTFREE, FAIL, "unable to destroy block tracker info") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5BT_cache_flush() */ + + +/*------------------------------------------------------------------------- + * Function: H5B_cache_dest + * + * Purpose: Destroys a block tracker in memory. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Mar 10 2005 + * + *------------------------------------------------------------------------- + */ +/* ARGSUSED */ +herr_t +H5BT_cache_dest(H5F_t UNUSED *f, H5BT_t *bt) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5BT_cache_dest) + + /* + * Check arguments. + */ + HDassert(bt); + + /* Free block tracker info */ + H5FL_FREE(H5BT_t,bt); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5BT_cache_dest() */ + + +/*------------------------------------------------------------------------- + * Function: H5BT_cache_clear + * + * Purpose: Mark a block tracker info in memory as non-dirty. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Mar 10 2005 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5BT_cache_clear(H5F_t *f, H5BT_t *bt, hbool_t destroy) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT(H5BT_cache_clear) + + /* + * Check arguments. + */ + HDassert(bt); + + /* Reset the dirty flag. */ + bt->cache_info.is_dirty = FALSE; + + if (destroy) + if (H5BT_cache_dest(f, bt) < 0) + HGOTO_ERROR(H5E_BLKTRK, H5E_CANTFREE, FAIL, "unable to destroy block tracker info") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5BT_cache_clear() */ + + +/*------------------------------------------------------------------------- + * Function: H5BT_cache_size + * + * Purpose: Compute the size in bytes of a block tracker info + * on disk, and return it in *size_ptr. On failure, + * the value of *size_ptr is undefined. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Mar 10 2005 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5BT_cache_size(const H5F_t *f, const H5BT_t UNUSED *bt, size_t *size_ptr) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5BT_cache_size) + + /* check arguments */ + HDassert(f); + HDassert(size_ptr); + + /* Set size value */ + *size_ptr = H5BT_SIZE(f); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5BT_cache_size() */ + diff --git a/src/H5BTdbg.c b/src/H5BTdbg.c new file mode 100644 index 0000000..a926801 --- /dev/null +++ b/src/H5BTdbg.c @@ -0,0 +1,104 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5BTdbg.c + * Mar 10 2005 + * Quincey Koziol <koziol@ncsa.uiuc.edu> + * + * Purpose: Dump debugging information about a block tracker + * + *------------------------------------------------------------------------- + */ + +#define H5BT_PACKAGE /*suppress error about including H5BTpkg */ + +/* Private headers */ +#include "H5private.h" /* Generic Functions */ +#include "H5BTpkg.h" /* B-trees */ +#include "H5Eprivate.h" /* Error handling */ + + +/*------------------------------------------------------------------------- + * Function: H5BT_debug + * + * Purpose: Prints debugging info about a block tracker info + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Mar 10 2005 + * + *------------------------------------------------------------------------- + */ +herr_t +H5BT_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int fwidth) +{ + H5BT_t *bt = NULL; + herr_t ret_value=SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5BT_hdr_debug, FAIL) + + /* + * Check arguments. + */ + assert(f); + assert(H5F_addr_defined(addr)); + assert(stream); + assert(indent >= 0); + assert(fwidth >= 0); + + /* + * Load the block tracker info + */ + if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BLTR, addr, NULL, NULL, H5AC_READ))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load block tracker info") + + /* + * Print the values. + */ + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, + "Dirty flag:", + bt->cache_info.is_dirty ? "True" : "False"); + HDfprintf(stream, "%*s%-*s %x\n", indent, "", fwidth, + "Status:", + (unsigned)bt->status); + HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, + "Max. Size of Block Tracked:", + bt->max_block_size); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, + "Ref. Count of Max. Block Tracked:", + (unsigned)bt->max_block_cnt); + HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, + "Min. Size of Block Tracked:", + bt->min_block_size); + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, + "Ref. Count of Min. Block Tracked:", + (unsigned)bt->min_block_cnt); + HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, + "Total Size of All Blocks Tracked:", + bt->tot_block_size); + HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, + "Address of v2 B-tree Storing Block Info Records:", + bt->bt2_addr); + +done: + if (bt && H5AC_unprotect(f, dxpl_id, H5AC_BLTR, addr, bt, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release block tracker info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5BT_debug() */ + diff --git a/src/H5BTpkg.h b/src/H5BTpkg.h new file mode 100644 index 0000000..83dfbe0 --- /dev/null +++ b/src/H5BTpkg.h @@ -0,0 +1,109 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu> + * Thursday, March 10, 2005 + * + * Purpose: This file contains declarations which are visible only within + * the H5BT package. Source files outside the H5BT package should + * include H5BTprivate.h instead. + */ +#ifndef H5BT_PACKAGE +#error "Do not include this file outside the H5BT package!" +#endif + +#ifndef _H5BTpkg_H +#define _H5BTpkg_H + +/* Get package's private header */ +#include "H5BTprivate.h" + +/* Other private headers needed by this file */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5B2private.h" /* v2 B-trees */ +#include "H5FLprivate.h" /* Free Lists */ + +/**************************/ +/* Package Private Macros */ +/**************************/ + +/* Size of signature information (on disk) */ +#define H5BT_SIZEOF_MAGIC 4 + +/* Block Tracker signature */ +#define H5BT_MAGIC "BLTR" + +/* Size of the Block Tracker info on disk */ +#define H5BT_SIZE(f) ( \ + 4 + /* Signature */ \ + 1 + /* Version */ \ + 1 + /* Status flags */ \ + H5F_SIZEOF_SIZE(f) + /* Max. size block tracked (can be 0 for "unknown") */ \ + 4 + /* Reference count of max. size block tracked */ \ + H5F_SIZEOF_SIZE(f) + /* Min. size block tracked (can be 0 for "unknown") */ \ + 4 + /* Reference count of min. size block tracked */ \ + H5F_SIZEOF_SIZE(f) + /* Total number of bytes tracked */ \ + H5F_SIZEOF_ADDR(f)) /* Address of v2 B-tree which holds block inf */ + + +/****************************/ +/* Package Private Typedefs */ +/****************************/ + +/* The block tracker information */ +typedef struct H5BT_t { + /* Information for H5AC cache functions, _must_ be first field in structure */ + H5AC_info_t cache_info; + + /* Internal block tracking information */ + unsigned char status; /* Status flags for max & min values */ + hsize_t max_block_size; /* Maximum size of a block tracked */ + uint32_t max_block_cnt; /* Count of max. block tracked */ + hsize_t min_block_size; /* Minimum size of a block tracked */ + uint32_t min_block_cnt; /* Count of min. block tracked */ + hsize_t tot_block_size; /* Total size of all blocks tracked */ + haddr_t bt2_addr; /* Address of v2 B-tree that holds block info */ +} H5BT_t; + +/* Info for a single block */ +typedef struct H5BT_blk_info_t { + haddr_t addr; /* Address (offset) of block in file */ + hsize_t len; /* Length of block in file */ +} H5BT_blk_info_t; + + +/*****************************/ +/* Package Private Variables */ +/*****************************/ + +/* H5BT inherits cache-like properties from H5AC */ +H5_DLLVAR const H5AC_class_t H5AC_BLTR[1]; + +/* v2 B-tree class for block info records */ +H5_DLLVAR const H5B2_class_t H5B2_BLKTRK[1]; + +/* Declare a free list to manage the H5BT_t struct */ +H5FL_EXTERN(H5BT_t); + + +/******************************/ +/* Package Private Prototypes */ +/******************************/ +H5_DLL herr_t H5BT_cache_dest(H5F_t *f, H5BT_t *b); +H5_DLL herr_t H5BT_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, + int indent, int fwidth); + +#endif /* _H5BTpkg_H */ + diff --git a/src/H5BTprivate.h b/src/H5BTprivate.h new file mode 100644 index 0000000..e506051 --- /dev/null +++ b/src/H5BTprivate.h @@ -0,0 +1,52 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5BTprivate.h + * Mar 10 2005 + * Quincey Koziol <koziol@ncsa.uiuc.edu> + * + * Purpose: Private header for library accessible block tracker routines. + * + *------------------------------------------------------------------------- + */ + +#ifndef _H5BTprivate_H +#define _H5BTprivate_H + +/* Include package's public header */ +#include "H5BTpublic.h" + +/* Private headers needed by this file */ +#include "H5Fprivate.h" /* File access */ + +/**************************/ +/* Library Private Macros */ +/**************************/ + + +/****************************/ +/* Library Private Typedefs */ +/****************************/ + + +/***************************************/ +/* Library-private Function Prototypes */ +/***************************************/ +H5_DLL herr_t H5BT_create(H5F_t *f, hid_t dxpl_id, haddr_t *addr_p); + +#endif /* _H5BTprivate_H */ + + diff --git a/src/H5BTpublic.h b/src/H5BTpublic.h new file mode 100644 index 0000000..f37f2d1 --- /dev/null +++ b/src/H5BTpublic.h @@ -0,0 +1,52 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5BTpublic.h + * Mar 10 2005 + * Quincey Koziol <koziol@ncsa.uiuc.edu> + * + * Purpose: Public declarations for the H5BT package. + * + *------------------------------------------------------------------------- + */ +#ifndef _H5BTpublic_H +#define _H5BTpublic_H + +/* Public headers needed by this file */ +#include "H5public.h" + +/*****************/ +/* Public Macros */ +/*****************/ + +/*******************/ +/* Public Typedefs */ +/*******************/ + +/**********************************/ +/* Public API Function Prototypes */ +/**********************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _H5BTpublic_H */ + diff --git a/src/H5Edefin.h b/src/H5Edefin.h index b081b16..d911107 100644 --- a/src/H5Edefin.h +++ b/src/H5Edefin.h @@ -41,6 +41,7 @@ hid_t H5E_TBBT_g = FAIL; /* Threaded, Balanced, Binary Trees */ hid_t H5E_ATOM_g = FAIL; /* Object atom */ hid_t H5E_ATTR_g = FAIL; /* Attribute */ hid_t H5E_IO_g = FAIL; /* Low-level I/O */ +hid_t H5E_BLKTRK_g = FAIL; /* Block tracker */ hid_t H5E_SLIST_g = FAIL; /* Skip Lists */ hid_t H5E_EFL_g = FAIL; /* External file list */ hid_t H5E_TST_g = FAIL; /* Ternary Search Trees */ diff --git a/src/H5Einit.h b/src/H5Einit.h index 8164584..bb8a04d 100644 --- a/src/H5Einit.h +++ b/src/H5Einit.h @@ -128,6 +128,11 @@ if((msg = H5E_create_msg(cls, H5E_MAJOR, "Low-level I/O"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") if((H5E_IO_g = H5I_register(H5I_ERROR_MSG, msg))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_BLKTRK_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MAJOR, "Block tracker"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_BLKTRK_g = H5I_register(H5I_ERROR_MSG, msg))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") assert(H5E_SLIST_g==(-1)); if((msg = H5E_create_msg(cls, H5E_MAJOR, "Skip Lists"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") diff --git a/src/H5Epubgen.h b/src/H5Epubgen.h index 6a4fcd1..773368f 100644 --- a/src/H5Epubgen.h +++ b/src/H5Epubgen.h @@ -44,6 +44,7 @@ #define H5E_ATOM (H5OPEN H5E_ATOM_g) #define H5E_ATTR (H5OPEN H5E_ATTR_g) #define H5E_IO (H5OPEN H5E_IO_g) +#define H5E_BLKTRK (H5OPEN H5E_BLKTRK_g) #define H5E_SLIST (H5OPEN H5E_SLIST_g) #define H5E_EFL (H5OPEN H5E_EFL_g) #define H5E_TST (H5OPEN H5E_TST_g) @@ -72,6 +73,7 @@ H5_DLLVAR hid_t H5E_TBBT_g; /* Threaded, Balanced, Binary Trees */ H5_DLLVAR hid_t H5E_ATOM_g; /* Object atom */ H5_DLLVAR hid_t H5E_ATTR_g; /* Attribute */ H5_DLLVAR hid_t H5E_IO_g; /* Low-level I/O */ +H5_DLLVAR hid_t H5E_BLKTRK_g; /* Block tracker */ H5_DLLVAR hid_t H5E_SLIST_g; /* Skip Lists */ H5_DLLVAR hid_t H5E_EFL_g; /* External file list */ H5_DLLVAR hid_t H5E_TST_g; /* Ternary Search Trees */ diff --git a/src/H5Eterm.h b/src/H5Eterm.h index 67b3415..6bef264 100644 --- a/src/H5Eterm.h +++ b/src/H5Eterm.h @@ -42,6 +42,7 @@ H5E_TBBT_g= H5E_ATOM_g= H5E_ATTR_g= H5E_IO_g= +H5E_BLKTRK_g= H5E_SLIST_g= H5E_EFL_g= H5E_TST_g= diff --git a/src/H5FDpublic.h b/src/H5FDpublic.h index 596e0f1..6606b80 100644 --- a/src/H5FDpublic.h +++ b/src/H5FDpublic.h @@ -43,6 +43,11 @@ typedef enum H5FD_mem_t { H5FD_MEM_NTYPES /*must be last*/ } H5FD_mem_t; +/* Map "block tracker" header blocks to 'ohdr' type file memory, since its + * a fair amount of work to add a new kind of file memory, they are similar + * enough to object headers and probably too minor to deserve their own type. -QAK */ +#define H5FD_MEM_BLKTRK H5FD_MEM_OHDR + /* * A free-list map which maps all types of allocation requests to a single * free list. This is useful for drivers that don't really care about diff --git a/src/H5err.txt b/src/H5err.txt index dcfb5b0..61bb74c 100644 --- a/src/H5err.txt +++ b/src/H5err.txt @@ -72,6 +72,7 @@ MAJOR, H5E_TST, Ternary Search Trees MAJOR, H5E_RS, Reference Counted Strings MAJOR, H5E_ERROR, Error API MAJOR, H5E_SLIST, Skip Lists +MAJOR, H5E_BLKTRK, Block tracker # Sections (for grouping minor errors) SECTION, ARGS, Argument errors diff --git a/src/Makefile.am b/src/Makefile.am index 08e7364..8d65b31 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -37,7 +37,7 @@ DISTCLEAN=libhdf5.settings # library sources libhdf5_la_SOURCES= H5.c H5A.c H5AC.c H5B.c H5B2.c H5B2cache.c H5B2dbg.c \ - H5B2test.c H5C.c \ + H5B2test.c H5BT.c H5BTbtree2.c H5BTcache.c H5BTdbg.c H5C.c \ H5D.c \ H5Dcontig.c \ H5Dcompact.c \ @@ -63,7 +63,7 @@ libhdf5_la_SOURCES= H5.c H5A.c H5AC.c H5B.c H5B2.c H5B2cache.c H5B2dbg.c \ # Public headers include_HEADERS =H5public.h H5Apublic.h H5ACpublic.h H5Bpublic.h H5B2public.h \ - H5Cpublic.h H5Dpublic.h \ + H5BTpublic.h H5Cpublic.h H5Dpublic.h \ H5Epubgen.h H5Epublic.h H5Fpublic.h H5FDpublic.h H5FDcore.h H5FDfamily.h \ H5FDfphdf5.h H5FDlog.h H5FDmpi.h H5FDmpio.h H5FDmpiposix.h \ H5FDmulti.h H5FDsec2.h H5FDsrb.h H5FDstdio.h H5FDstream.h H5FPpublic.h \ @@ -74,6 +74,7 @@ include_HEADERS =H5public.h H5Apublic.h H5ACpublic.h H5Bpublic.h H5B2public.h \ # Private headers #noinst_HEADERS =H5private.h H5Aprivate.h H5Apkg.h H5ACprivate.h H5Bprivate.h \ # H5B2private.h \ +# H5BTprivate.h \ # H5Dprivate.h H5Eprivate.h H5Fprivate.h H5FDprivate.h H5FLprivate.h \ # H5FOprivate.h H5FSprivate.h H5Gprivate.h H5Gpkg.h \ # H5HGprivate.h H5HLprivate.h H5HPprivate.h H5Iprivate.h H5MFprivate.h \ diff --git a/src/Makefile.in b/src/Makefile.in index 84006b4..e096942 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -82,7 +82,8 @@ libLTLIBRARIES_INSTALL = $(INSTALL) LTLIBRARIES = $(lib_LTLIBRARIES) libhdf5_la_LIBADD = am_libhdf5_la_OBJECTS = H5.lo H5A.lo H5AC.lo H5B.lo H5B2.lo \ - H5B2cache.lo H5B2dbg.lo H5B2test.lo H5C.lo H5D.lo H5Dcontig.lo \ + H5B2cache.lo H5B2dbg.lo H5B2test.lo H5BT.lo H5BTbtree2.lo \ + H5BTcache.lo H5BTdbg.lo H5C.lo H5D.lo H5Dcontig.lo \ H5Dcompact.lo H5Defl.lo H5Dio.lo H5Distore.lo H5Dmpio.lo \ H5Dselect.lo H5Dtest.lo H5E.lo H5F.lo H5Fdbg.lo H5FD.lo \ H5FDcore.lo H5FDfamily.lo H5FDfphdf5.lo H5FDlog.lo H5FDmpi.lo \ @@ -332,7 +333,7 @@ DISTCLEAN = libhdf5.settings # library sources libhdf5_la_SOURCES = H5.c H5A.c H5AC.c H5B.c H5B2.c H5B2cache.c H5B2dbg.c \ - H5B2test.c H5C.c \ + H5B2test.c H5BT.c H5BTbtree2.c H5BTcache.c H5BTdbg.c H5C.c \ H5D.c \ H5Dcontig.c \ H5Dcompact.c \ @@ -358,7 +359,7 @@ libhdf5_la_SOURCES = H5.c H5A.c H5AC.c H5B.c H5B2.c H5B2cache.c H5B2dbg.c \ # Public headers include_HEADERS = H5public.h H5Apublic.h H5ACpublic.h H5Bpublic.h H5B2public.h \ - H5Cpublic.h H5Dpublic.h \ + H5BTpublic.h H5Cpublic.h H5Dpublic.h \ H5Epubgen.h H5Epublic.h H5Fpublic.h H5FDpublic.h H5FDcore.h H5FDfamily.h \ H5FDfphdf5.h H5FDlog.h H5FDmpi.h H5FDmpio.h H5FDmpiposix.h \ H5FDmulti.h H5FDsec2.h H5FDsrb.h H5FDstdio.h H5FDstream.h H5FPpublic.h \ @@ -370,6 +371,7 @@ include_HEADERS = H5public.h H5Apublic.h H5ACpublic.h H5Bpublic.h H5B2public.h \ # Private headers #noinst_HEADERS =H5private.h H5Aprivate.h H5Apkg.h H5ACprivate.h H5Bprivate.h \ # H5B2private.h \ +# H5BTprivate.h \ # H5Dprivate.h H5Eprivate.h H5Fprivate.h H5FDprivate.h H5FLprivate.h \ # H5FOprivate.h H5FSprivate.h H5Gprivate.h H5Gpkg.h \ # H5HGprivate.h H5HLprivate.h H5HPprivate.h H5Iprivate.h H5MFprivate.h \ @@ -501,6 +503,10 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5B2cache.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5B2dbg.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5B2test.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5BT.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5BTbtree2.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5BTcache.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5BTdbg.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5C.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5D.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Dcompact.Plo@am__quote@ diff --git a/test/Makefile.am b/test/Makefile.am index 9744c54..a7db7d9 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -33,7 +33,7 @@ TEST_PROG=testhdf5 lheap ohdr stab gheap cache hyperslab istore bittests \ fillval mount flush1 flush2 enum \ set_extent srb_write srb_append srb_read ttsafe stream_test \ getname file_handle ntypes dangle dtransform filename reserved \ - btree2 + btree2 blocktrack # List programs to be built when testing here. error_test and err_compat are # built at the same time as the other tests, but executed by testerror.sh. @@ -88,7 +88,7 @@ MOSTLYCLEANFILES=cmpd_dset.h5 compact_dataset.h5 dataset.h5 extend.h5 istore.h5\ family_file000[0-3][0-9].h5 multi_file-[rs].h5 core_file \ new_move_[ab].h5 ntypes.h5 dangle.h5 error_test.h5 err_compat.h5 \ dtransform.h5 test_filters.h5 get_file_name.h5 tstint[1-2].h5 \ - unlink_chunked.h5 btree2.h5 + unlink_chunked.h5 btree2.h5 blocktrack.h5 # Sources for testhdf5 executable testhdf5_SOURCES=testhdf5.c tarray.c tattr.c tconfig.c tfile.c tgenprop.c \ diff --git a/test/Makefile.in b/test/Makefile.in index c30bac5..74639c8 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -29,7 +29,7 @@ # # HDF5 Library Test Makefile(.in) # -SOURCES = $(libh5test_la_SOURCES) big.c bittests.c btree2.c cache.c cmpd_dset.c dangle.c dsets.c dtransform.c dtypes.c enum.c err_compat.c error_test.c extend.c external.c file_handle.c filename.c fillval.c flush1.c flush2.c getname.c gheap.c hyperslab.c istore.c lheap.c links.c mount.c mtime.c ntypes.c ohdr.c reserved.c set_extent.c srb_append.c srb_read.c srb_write.c stab.c stream_test.c $(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c +SOURCES = $(libh5test_la_SOURCES) big.c bittests.c blocktrack.c btree2.c cache.c cmpd_dset.c dangle.c dsets.c dtransform.c dtypes.c enum.c err_compat.c error_test.c extend.c external.c file_handle.c filename.c fillval.c flush1.c flush2.c getname.c gheap.c hyperslab.c istore.c lheap.c links.c mount.c mtime.c ntypes.c ohdr.c reserved.c set_extent.c srb_append.c srb_read.c srb_write.c stab.c stream_test.c $(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c srcdir = @srcdir@ top_srcdir = @top_srcdir@ @@ -81,7 +81,7 @@ am__EXEEXT_1 = testhdf5$(EXEEXT) lheap$(EXEEXT) ohdr$(EXEEXT) \ ttsafe$(EXEEXT) stream_test$(EXEEXT) getname$(EXEEXT) \ file_handle$(EXEEXT) ntypes$(EXEEXT) dangle$(EXEEXT) \ dtransform$(EXEEXT) filename$(EXEEXT) reserved$(EXEEXT) \ - btree2$(EXEEXT) + btree2$(EXEEXT) blocktrack$(EXEEXT) big_SOURCES = big.c big_OBJECTS = big.$(OBJEXT) big_LDADD = $(LDADD) @@ -90,6 +90,10 @@ bittests_SOURCES = bittests.c bittests_OBJECTS = bittests.$(OBJEXT) bittests_LDADD = $(LDADD) bittests_DEPENDENCIES = libh5test.la $(am__DEPENDENCIES_1) +blocktrack_SOURCES = blocktrack.c +blocktrack_OBJECTS = blocktrack.$(OBJEXT) +blocktrack_LDADD = $(LDADD) +blocktrack_DEPENDENCIES = libh5test.la $(am__DEPENDENCIES_1) btree2_SOURCES = btree2.c btree2_OBJECTS = btree2.$(OBJEXT) btree2_LDADD = $(LDADD) @@ -261,17 +265,17 @@ LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \ CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ -SOURCES = $(libh5test_la_SOURCES) big.c bittests.c btree2.c cache.c \ - cmpd_dset.c dangle.c dsets.c dtransform.c dtypes.c enum.c \ - err_compat.c error_test.c extend.c external.c file_handle.c \ - filename.c fillval.c flush1.c flush2.c getname.c gheap.c \ - hyperslab.c istore.c lheap.c links.c mount.c mtime.c ntypes.c \ - ohdr.c reserved.c set_extent.c srb_append.c srb_read.c \ - srb_write.c stab.c stream_test.c $(testhdf5_SOURCES) \ - testmeta.c $(ttsafe_SOURCES) unlink.c -DIST_SOURCES = $(libh5test_la_SOURCES) big.c bittests.c btree2.c \ - cache.c cmpd_dset.c dangle.c dsets.c dtransform.c dtypes.c \ - enum.c err_compat.c error_test.c extend.c external.c \ +SOURCES = $(libh5test_la_SOURCES) big.c bittests.c blocktrack.c \ + btree2.c cache.c cmpd_dset.c dangle.c dsets.c dtransform.c \ + dtypes.c enum.c err_compat.c error_test.c extend.c external.c \ + file_handle.c filename.c fillval.c flush1.c flush2.c getname.c \ + gheap.c hyperslab.c istore.c lheap.c links.c mount.c mtime.c \ + ntypes.c ohdr.c reserved.c set_extent.c srb_append.c \ + srb_read.c srb_write.c stab.c stream_test.c \ + $(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c +DIST_SOURCES = $(libh5test_la_SOURCES) big.c bittests.c blocktrack.c \ + btree2.c cache.c cmpd_dset.c dangle.c dsets.c dtransform.c \ + dtypes.c enum.c err_compat.c error_test.c extend.c external.c \ file_handle.c filename.c fillval.c flush1.c flush2.c getname.c \ gheap.c hyperslab.c istore.c lheap.c links.c mount.c mtime.c \ ntypes.c ohdr.c reserved.c set_extent.c srb_append.c \ @@ -485,7 +489,7 @@ TEST_PROG = testhdf5 lheap ohdr stab gheap cache hyperslab istore bittests \ fillval mount flush1 flush2 enum \ set_extent srb_write srb_append srb_read ttsafe stream_test \ getname file_handle ntypes dangle dtransform filename reserved \ - btree2 + btree2 blocktrack # The libh5test.a library provides common support code for the tests. @@ -524,7 +528,7 @@ MOSTLYCLEANFILES = cmpd_dset.h5 compact_dataset.h5 dataset.h5 extend.h5 istore.h family_file000[0-3][0-9].h5 multi_file-[rs].h5 core_file \ new_move_[ab].h5 ntypes.h5 dangle.h5 error_test.h5 err_compat.h5 \ dtransform.h5 test_filters.h5 get_file_name.h5 tstint[1-2].h5 \ - unlink_chunked.h5 btree2.h5 + unlink_chunked.h5 btree2.h5 blocktrack.h5 # Sources for testhdf5 executable @@ -602,6 +606,9 @@ big$(EXEEXT): $(big_OBJECTS) $(big_DEPENDENCIES) bittests$(EXEEXT): $(bittests_OBJECTS) $(bittests_DEPENDENCIES) @rm -f bittests$(EXEEXT) $(LINK) $(bittests_LDFLAGS) $(bittests_OBJECTS) $(bittests_LDADD) $(LIBS) +blocktrack$(EXEEXT): $(blocktrack_OBJECTS) $(blocktrack_DEPENDENCIES) + @rm -f blocktrack$(EXEEXT) + $(LINK) $(blocktrack_LDFLAGS) $(blocktrack_OBJECTS) $(blocktrack_LDADD) $(LIBS) btree2$(EXEEXT): $(btree2_OBJECTS) $(btree2_DEPENDENCIES) @rm -f btree2$(EXEEXT) $(LINK) $(btree2_LDFLAGS) $(btree2_OBJECTS) $(btree2_LDADD) $(LIBS) @@ -725,6 +732,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/big.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bittests.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/blocktrack.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/btree2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cache.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cmpd_dset.Po@am__quote@ diff --git a/test/blocktrack.c b/test/blocktrack.c new file mode 100644 index 0000000..992e54d --- /dev/null +++ b/test/blocktrack.c @@ -0,0 +1,138 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu> + * Wednesday, March 9, 2005 + */ +#include "h5test.h" + +/* + * This file needs to access private datatypes from the H5BT package. + */ +#define H5BT_PACKAGE +#include "H5BTpkg.h" + +/* Other private headers that this test requires */ +#include "H5Iprivate.h" + +const char *FILENAME[] = { + "blocktrack", + NULL +}; + + +/*------------------------------------------------------------------------- + * Function: test_create + * + * Purpose: Basic tests for the block tracker code + * + * Return: Success: 0 + * + * Failure: 1 + * + * Programmer: Quincey Koziol + * Wednesday, March 9, 2005 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +test_create(hid_t fapl) +{ + hid_t file=-1; + char filename[1024]; + H5F_t *f=NULL; + haddr_t bt_addr; /* Address of block tracker created */ + + h5_fixname(FILENAME[0], fapl, filename, sizeof filename); + + /* Create the file to work on */ + if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) TEST_ERROR; + + /* Get a pointer to the internal file object */ + if (NULL==(f=H5I_object(file))) { + H5Eprint_stack(H5E_DEFAULT, stdout); + TEST_ERROR; + } + + /* + * Test block tracker creation + */ + TESTING("Block tracker creation"); + if (H5BT_create(f, H5P_DATASET_XFER_DEFAULT, &bt_addr/*out*/)<0) { + H5_FAILED(); + H5Eprint_stack(H5E_DEFAULT, stdout); + goto error; + } + PASSED(); + + if (H5Fclose(file)<0) TEST_ERROR; + + return 0; + +error: + H5E_BEGIN_TRY { + H5Fclose(file); + } H5E_END_TRY; + return 1; +} /* test_create() */ + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Test the block tracker code + * + * Return: Success: + * + * Failure: + * + * Programmer: Quincey Koziol + * Wednesday, March 9, 2005 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ + hid_t fapl=-1; + int nerrors=0; + + /* Reset library */ + h5_reset(); + fapl = h5_fileaccess(); + + /* Test block tracker creation */ + nerrors += test_create(fapl); + + if (nerrors) goto error; + puts("All block tracker tests passed."); +#ifndef QAK + h5_cleanup(FILENAME, fapl); +#else /* QAK */ +HDfprintf(stderr,"Uncomment cleanup!\n"); +#endif /* QAK */ + return 0; + +error: + puts("*** TESTS FAILED ***"); + H5E_BEGIN_TRY { + H5Pclose(fapl); + } H5E_END_TRY; + return 1; +} + diff --git a/tools/misc/h5debug.c b/tools/misc/h5debug.c index 04e2b22..dca6216 100644 --- a/tools/misc/h5debug.c +++ b/tools/misc/h5debug.c @@ -28,10 +28,12 @@ #define H5O_PACKAGE /*suppress error about including H5Opkg */ #define H5B2_PACKAGE /*suppress error about including H5B2pkg */ #define H5B2_TESTING /*suppress warning about H5B2 testing funcs*/ +#define H5BT_PACKAGE /*suppress error about including H5BTpkg */ #include "H5private.h" /* Generic Functions */ #include "H5Bprivate.h" #include "H5B2pkg.h" /* B-trees */ +#include "H5BTpkg.h" /* Block tracker */ #include "H5Dprivate.h" #include "H5Fpkg.h" #include "H5Gprivate.h" @@ -114,7 +116,7 @@ main(int argc, char *argv[]) * Parse command arguments. */ if (argc > 2) { - printf("New address: %s\n", argv[2]); +/* printf("New address: %s\n", argv[2]); */ addr = HDstrtoll(argv[2], NULL, 0); } if (argc > 3) { @@ -187,27 +189,19 @@ main(int argc, char *argv[]) */ H5B2_subid_t subtype = (H5B_subid_t)sig[H5B2_SIZEOF_MAGIC+1]; -#ifdef NOT_YET - unsigned ndims; - switch (subtype) { - case H5B_SNODE_ID: - status = H5G_node_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, extra); + case H5B2_TEST_ID: + status = H5B2_hdr_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5B2_TEST); break; - case H5B_ISTORE_ID: - ndims = (unsigned)extra; - status = H5D_istore_debug (f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, ndims); + case H5B2_BLK_TRK_ID: + status = H5B2_hdr_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5B2_BLKTRK); break; default: fprintf(stderr, "Unknown B-tree subtype %u\n", (unsigned)(subtype)); HDexit(4); - } -#else /* NOT_YET */ -fprintf(stderr,"B-tree subtype=%u\n",(unsigned)subtype); - status = H5B2_hdr_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5B2_TEST); -#endif /* NOT_YET */ + } /* end switch */ } else if (!HDmemcmp(sig, H5B2_INT_MAGIC, H5B2_SIZEOF_MAGIC)) { /* @@ -216,30 +210,20 @@ fprintf(stderr,"B-tree subtype=%u\n",(unsigned)subtype); * B-tree signature. */ H5B2_subid_t subtype = (H5B_subid_t)sig[H5B2_SIZEOF_MAGIC+1]; - unsigned nrecs; -#ifdef NOT_YET - unsigned ndims; - switch (subtype) { - case H5B_SNODE_ID: - status = H5G_node_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, extra); + case H5B2_TEST_ID: + status = H5B2_int_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5B2_TEST, extra, (unsigned)extra2); break; - case H5B_ISTORE_ID: - ndims = (unsigned)extra; - status = H5D_istore_debug (f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, ndims); + case H5B2_BLK_TRK_ID: + status = H5B2_int_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5B2_BLKTRK, extra, (unsigned)extra2); break; default: fprintf(stderr, "Unknown B-tree subtype %u\n", (unsigned)(subtype)); HDexit(4); - } -#else /* NOT_YET */ -fprintf(stderr,"B-tree subtype=%u\n",(unsigned)subtype); - nrecs = (unsigned)extra2; - status = H5B2_int_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5B2_TEST, extra, nrecs); -#endif /* NOT_YET */ + } /* end switch */ } else if (!HDmemcmp(sig, H5B2_LEAF_MAGIC, H5B2_SIZEOF_MAGIC)) { /* @@ -248,30 +232,26 @@ fprintf(stderr,"B-tree subtype=%u\n",(unsigned)subtype); * B-tree signature. */ H5B2_subid_t subtype = (H5B_subid_t)sig[H5B2_SIZEOF_MAGIC+1]; - unsigned nrecs; -#ifdef NOT_YET - unsigned ndims; - switch (subtype) { - case H5B_SNODE_ID: - status = H5G_node_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, extra); + case H5B2_TEST_ID: + status = H5B2_leaf_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5B2_TEST, extra, (unsigned)extra2); break; - case H5B_ISTORE_ID: - ndims = (unsigned)extra; - status = H5D_istore_debug (f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, ndims); + case H5B2_BLK_TRK_ID: + status = H5B2_leaf_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5B2_BLKTRK, extra, (unsigned)extra2); break; default: fprintf(stderr, "Unknown B-tree subtype %u\n", (unsigned)(subtype)); HDexit(4); - } -#else /* NOT_YET */ -fprintf(stderr,"B-tree subtype=%u\n",(unsigned)subtype); - nrecs = (unsigned)extra2; - status = H5B2_leaf_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5B2_TEST, extra, nrecs); -#endif /* NOT_YET */ + } /* end switch */ + + } else if (!HDmemcmp(sig, H5BT_MAGIC, H5BT_SIZEOF_MAGIC)) { + /* + * Debug a block tracker info + */ + status = H5BT_hdr_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL); } else if (sig[0] == H5O_VERSION) { /* |