summaryrefslogtreecommitdiffstats
path: root/src/H5EAhdr.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2008-11-18 03:42:13 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2008-11-18 03:42:13 (GMT)
commita19434caa09bce8d1d7cdc97911b35b3201c8d4e (patch)
tree4903b5a03996f8e1f6802f6725634d5929d80634 /src/H5EAhdr.c
parenta28e8407cf5a526a20ad682382f0faed58aace76 (diff)
downloadhdf5-a19434caa09bce8d1d7cdc97911b35b3201c8d4e.zip
hdf5-a19434caa09bce8d1d7cdc97911b35b3201c8d4e.tar.gz
hdf5-a19434caa09bce8d1d7cdc97911b35b3201c8d4e.tar.bz2
[svn-r16094] Description:
Add initial support for data block 'page init' bitmasks to super blocks. Tested on: Mac OS X/32 10.5.5 (amazon) in debug mode Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode 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-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
Diffstat (limited to 'src/H5EAhdr.c')
-rw-r--r--src/H5EAhdr.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/H5EAhdr.c b/src/H5EAhdr.c
index e0e97e8..c6cda2c 100644
--- a/src/H5EAhdr.c
+++ b/src/H5EAhdr.c
@@ -53,6 +53,10 @@
/* Max. # of bits for max. nelmts index */
#define H5EA_MAX_NELMTS_IDX_MAX 64
+/* # of elements in a data block for a particular super block */
+#define H5EA_SBLK_DBLK_NELMTS(s, m) \
+ (size_t)H5_EXP2(((s) + 1) / 2) * (m)
+
/******************/
/* Local Typedefs */
@@ -125,6 +129,9 @@ H5EA__hdr_alloc(H5F_t *f, const H5EA_class_t *cls))
if(NULL == (hdr = H5FL_CALLOC(H5EA_hdr_t)))
H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header")
+ /* Set non-zero internal fields */
+ hdr->addr = HADDR_UNDEF;
+
/* Set the internal parameters for the array */
hdr->f = f;
hdr->sizeof_addr = H5F_SIZEOF_ADDR(f);
@@ -197,6 +204,7 @@ H5EA__hdr_init(H5EA_hdr_t *hdr))
/* Compute general information */
hdr->nsblks = 1 + (hdr->cparam.max_nelmts_bits - H5V_log2_of2(hdr->cparam.data_blk_min_elmts));
+ hdr->dblk_page_nelmts = (size_t)1 << hdr->cparam.max_dblk_page_nelmts_bits;
hdr->arr_off_size = H5EA_SIZEOF_OFFSET_BITS(hdr->cparam.max_nelmts_bits);
#ifdef QAK
HDfprintf(stderr, "%s: hdr->nsblks = %Zu\n", FUNC, hdr->nsblks);
@@ -211,7 +219,7 @@ HDfprintf(stderr, "%s: hdr->nsblks = %Zu\n", FUNC, hdr->nsblks);
start_dblk = 0;
for(u = 0; u < hdr->nsblks; u++) {
hdr->sblk_info[u].ndblks = (size_t)H5_EXP2(u / 2);
- hdr->sblk_info[u].dblk_nelmts = (size_t)H5_EXP2((u + 1) / 2) * hdr->cparam.data_blk_min_elmts;
+ hdr->sblk_info[u].dblk_nelmts = H5EA_SBLK_DBLK_NELMTS(u, hdr->cparam.data_blk_min_elmts);
hdr->sblk_info[u].start_idx = start_idx;
hdr->sblk_info[u].start_dblk = start_dblk;
#ifdef QAK
@@ -359,7 +367,7 @@ haddr_t, HADDR_UNDEF, HADDR_UNDEF,
H5EA__hdr_create(H5F_t *f, hid_t dxpl_id, const H5EA_create_t *cparam))
/* Local variables */
- H5EA_hdr_t *hdr; /* Extensible array header */
+ H5EA_hdr_t *hdr = NULL; /* Extensible array header */
#ifdef QAK
HDfprintf(stderr, "%s: Called\n", FUNC);
@@ -370,6 +378,11 @@ HDfprintf(stderr, "%s: Called\n", FUNC);
HDassert(cparam);
#ifndef NDEBUG
+{
+ unsigned sblk_idx; /* Super block index for first "actual" super block */
+ size_t dblk_nelmts; /* Number of data block elements */
+ size_t dblk_page_nelmts; /* Number of elements in a data block page */
+
/* Check for valid parameters */
if(cparam->raw_elmt_size == 0)
H5E_THROW(H5E_BADVALUE, "element size must be greater than zero")
@@ -383,8 +396,19 @@ HDfprintf(stderr, "%s: Called\n", FUNC);
H5E_THROW(H5E_BADVALUE, "min # of data block pointers in super block must be power of two")
if(!POWER_OF_TWO(cparam->data_blk_min_elmts))
H5E_THROW(H5E_BADVALUE, "min # of elements per data block must be power of two")
+ dblk_page_nelmts = (size_t)1 << cparam->max_dblk_page_nelmts_bits;
+ if(dblk_page_nelmts < cparam->idx_blk_elmts)
+ H5E_THROW(H5E_BADVALUE, "# of elements per data block page must be greater than # of elements in index block")
+
+ /* Compute the number of elements in data blocks for first actual super block */
+ sblk_idx = H5EA_SBLK_FIRST_IDX(cparam->sup_blk_min_data_ptrs);
+ dblk_nelmts = H5EA_SBLK_DBLK_NELMTS(sblk_idx, cparam->data_blk_min_elmts);
+ if(dblk_page_nelmts < dblk_nelmts)
+ H5E_THROW(H5E_BADVALUE, "max. # of elements per data block page bits must be > # of elements in first data block from super block")
+
if(cparam->max_dblk_page_nelmts_bits > cparam->max_nelmts_bits)
H5E_THROW(H5E_BADVALUE, "max. # of elements per data block page bits must be <= max. # of elements bits")
+}
#endif /* NDEBUG */
/* Allocate space for the shared information */
@@ -413,6 +437,16 @@ HDfprintf(stderr, "%s: Called\n", FUNC);
ret_value = hdr->addr;
CATCH
+ if(!H5F_addr_defined(ret_value))
+ if(hdr) {
+ /* Release header's disk space */
+ if(H5F_addr_defined(hdr->addr) && H5MF_xfree(f, H5FD_MEM_EARRAY_HDR, dxpl_id, hdr->addr, (hsize_t)hdr->size) < 0)
+ H5E_THROW(H5E_CANTFREE, "unable to free extensible array header")
+
+ /* Destroy header */
+ if(H5EA__hdr_dest(hdr) < 0)
+ H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array header")
+ } /* end if */
END_FUNC(PKG) /* end H5EA__hdr_create() */