diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2009-07-30 17:51:49 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2009-07-30 17:51:49 (GMT) |
commit | e1ceea54ff06ffef0029b20007cd7685e000fdec (patch) | |
tree | 3aacc0bfbc6762d7c28f53df2183b797e9d32854 | |
parent | f0ce4df67f82ee7308ad812a1772079fcb141182 (diff) | |
download | hdf5-e1ceea54ff06ffef0029b20007cd7685e000fdec.zip hdf5-e1ceea54ff06ffef0029b20007cd7685e000fdec.tar.gz hdf5-e1ceea54ff06ffef0029b20007cd7685e000fdec.tar.bz2 |
[svn-r17275] Description:
Refactor dataet storage information further, moving the chunk operations
into the storage struct and also fine-tune the chunk index structure for index
callbacks.
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-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.5.7 (amazon) in debug mode
Mac OS X/32 10.5.7 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
-rw-r--r-- | src/H5Dbtree.c | 245 | ||||
-rw-r--r-- | src/H5Dchunk.c | 171 | ||||
-rw-r--r-- | src/H5Dcompact.c | 36 | ||||
-rw-r--r-- | src/H5Dcontig.c | 34 | ||||
-rw-r--r-- | src/H5Ddbg.c | 2 | ||||
-rw-r--r-- | src/H5Defl.c | 2 | ||||
-rw-r--r-- | src/H5Dint.c | 22 | ||||
-rw-r--r-- | src/H5Dlayout.c | 8 | ||||
-rw-r--r-- | src/H5Dpkg.h | 22 | ||||
-rw-r--r-- | src/H5Dprivate.h | 6 | ||||
-rw-r--r-- | src/H5Dtest.c | 2 | ||||
-rw-r--r-- | src/H5Olayout.c | 110 | ||||
-rw-r--r-- | src/H5Oprivate.h | 20 | ||||
-rw-r--r-- | src/H5Pdcpl.c | 22 |
14 files changed, 371 insertions, 331 deletions
diff --git a/src/H5Dbtree.c b/src/H5Dbtree.c index 0e4ee6f..7dfc288 100644 --- a/src/H5Dbtree.c +++ b/src/H5Dbtree.c @@ -83,16 +83,6 @@ typedef struct H5D_btree_key_t { unsigned filter_mask; /*excluded filters */ } H5D_btree_key_t; -/* - * Data exchange structure for indexed storage nodes. This structure is - * passed through the B-link tree layer to the methods for the objects - * to which the B-link tree points for operations which require no - * additional information. - * - * (Just an alias for the "common" info). - */ -typedef H5D_chunk_common_ud_t H5D_btree_ud0_t; - /* B-tree callback info for iteration over chunks */ typedef struct H5D_btree_it_ud_t { H5D_chunk_common_ud_t common; /* Common info for B-tree user data (must be first) */ @@ -105,7 +95,8 @@ typedef struct H5D_btree_it_ud_t { /* Local Prototypes */ /********************/ -static herr_t H5D_btree_shared_create(const H5F_t *f, H5O_layout_t *layout); +static herr_t H5D_btree_shared_create(const H5F_t *f, H5O_storage_chunk_t *store, + unsigned ndims); /* B-tree iterator callbacks */ static int H5D_btree_idx_iterate_cb(H5F_t *f, hid_t dxpl_id, const void *left_key, @@ -138,7 +129,7 @@ static herr_t H5D_btree_debug_key(FILE *stream, H5F_t *f, hid_t dxpl_id, static herr_t H5D_btree_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t *space, haddr_t dset_ohdr_addr); static herr_t H5D_btree_idx_create(const H5D_chk_idx_info_t *idx_info); -static hbool_t H5D_btree_idx_is_space_alloc(const H5O_layout_t *layout); +static hbool_t H5D_btree_idx_is_space_alloc(const H5O_storage_chunk_t *storage); static herr_t H5D_btree_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata); static herr_t H5D_btree_idx_get_addr(const H5D_chk_idx_info_t *idx_info, @@ -150,12 +141,12 @@ static herr_t H5D_btree_idx_remove(const H5D_chk_idx_info_t *idx_info, static herr_t H5D_btree_idx_delete(const H5D_chk_idx_info_t *idx_info); static herr_t H5D_btree_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, const H5D_chk_idx_info_t *idx_info_dst); -static herr_t H5D_btree_idx_copy_shutdown(H5O_layout_t *layout_src, - H5O_layout_t *layout_dst, hid_t dxpl_id); +static herr_t H5D_btree_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, + H5O_storage_chunk_t *storage_dst, hid_t dxpl_id); static herr_t H5D_btree_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *size); -static herr_t H5D_btree_idx_reset(H5O_layout_t *layout, hbool_t reset_addr); -static herr_t H5D_btree_idx_dump(const H5D_chk_idx_info_t *idx_info, +static herr_t H5D_btree_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); +static herr_t H5D_btree_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream); static herr_t H5D_btree_idx_dest(const H5D_chk_idx_info_t *idx_info); @@ -230,20 +221,20 @@ H5B_class_t H5B_BTREE[1] = {{ static H5RC_t * H5D_btree_get_shared(const H5F_t UNUSED *f, const void *_udata) { - const H5D_btree_ud0_t *udata = (const H5D_btree_ud0_t *) _udata; + const H5D_chunk_common_ud_t *udata = (const H5D_chunk_common_ud_t *) _udata; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_btree_get_shared) HDassert(udata); - HDassert(udata->mesg); - HDassert(udata->mesg->u.chunk.idx_type == H5D_CHUNK_BTREE); - HDassert(udata->mesg->u.chunk.u.btree.shared); + HDassert(udata->storage); + HDassert(udata->storage->idx_type == H5D_CHUNK_BTREE); + HDassert(udata->storage->u.btree.shared); /* Increment reference count on B-tree info */ - H5RC_INC(udata->mesg->u.chunk.u.btree.shared); + H5RC_INC(udata->storage->u.btree.shared); /* Return the pointer to the ref-count object */ - FUNC_LEAVE_NOAPI(udata->mesg->u.chunk.u.btree.shared) + FUNC_LEAVE_NOAPI(udata->storage->u.btree.shared) } /* end H5D_btree_get_shared() */ @@ -283,7 +274,7 @@ H5D_btree_new_node(H5F_t *f, hid_t dxpl_id, H5B_ins_t op, HDassert(lt_key); HDassert(rt_key); HDassert(udata); - HDassert(udata->common.mesg->u.chunk.ndims > 0 && udata->common.mesg->u.chunk.ndims < H5O_LAYOUT_NDIMS); + HDassert(udata->common.layout->ndims > 0 && udata->common.layout->ndims < H5O_LAYOUT_NDIMS); HDassert(addr_p); /* Allocate new storage */ @@ -299,7 +290,7 @@ H5D_btree_new_node(H5F_t *f, hid_t dxpl_id, H5B_ins_t op, */ lt_key->nbytes = udata->nbytes; lt_key->filter_mask = udata->filter_mask; - for(u = 0; u < udata->common.mesg->u.chunk.ndims; u++) + for(u = 0; u < udata->common.layout->ndims; u++) lt_key->offset[u] = udata->common.offset[u]; /* @@ -309,10 +300,10 @@ H5D_btree_new_node(H5F_t *f, hid_t dxpl_id, H5B_ins_t op, if(H5B_INS_LEFT != op) { rt_key->nbytes = 0; rt_key->filter_mask = 0; - for(u = 0; u < udata->common.mesg->u.chunk.ndims; u++) { - HDassert(udata->common.offset[u] + udata->common.mesg->u.chunk.dim[u] > + for(u = 0; u < udata->common.layout->ndims; u++) { + HDassert(udata->common.offset[u] + udata->common.layout->dim[u] > udata->common.offset[u]); - rt_key->offset[u] = udata->common.offset[u] + udata->common.mesg->u.chunk.dim[u]; + rt_key->offset[u] = udata->common.offset[u] + udata->common.layout->dim[u]; } /* end if */ } /* end if */ @@ -347,7 +338,7 @@ H5D_btree_cmp2(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, void *_udat { H5D_btree_key_t *lt_key = (H5D_btree_key_t *) _lt_key; H5D_btree_key_t *rt_key = (H5D_btree_key_t *) _rt_key; - H5D_btree_ud0_t *udata = (H5D_btree_ud0_t *) _udata; + H5D_chunk_common_ud_t *udata = (H5D_chunk_common_ud_t *) _udata; int ret_value; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_btree_cmp2) @@ -355,10 +346,10 @@ H5D_btree_cmp2(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, void *_udat HDassert(lt_key); HDassert(rt_key); HDassert(udata); - HDassert(udata->mesg->u.chunk.ndims > 0 && udata->mesg->u.chunk.ndims <= H5O_LAYOUT_NDIMS); + HDassert(udata->layout->ndims > 0 && udata->layout->ndims <= H5O_LAYOUT_NDIMS); /* Compare the offsets but ignore the other fields */ - ret_value = H5V_vector_cmp_u(udata->mesg->u.chunk.ndims, lt_key->offset, rt_key->offset); + ret_value = H5V_vector_cmp_u(udata->layout->ndims, lt_key->offset, rt_key->offset); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_btree_cmp2() */ @@ -398,7 +389,7 @@ H5D_btree_cmp3(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, void *_udat { H5D_btree_key_t *lt_key = (H5D_btree_key_t *) _lt_key; H5D_btree_key_t *rt_key = (H5D_btree_key_t *) _rt_key; - H5D_btree_ud0_t *udata = (H5D_btree_ud0_t *) _udata; + H5D_chunk_common_ud_t *udata = (H5D_chunk_common_ud_t *) _udata; int ret_value = 0; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_btree_cmp3) @@ -406,7 +397,7 @@ H5D_btree_cmp3(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, void *_udat HDassert(lt_key); HDassert(rt_key); HDassert(udata); - HDassert(udata->mesg->u.chunk.ndims > 0 && udata->mesg->u.chunk.ndims <= H5O_LAYOUT_NDIMS); + HDassert(udata->layout->ndims > 0 && udata->layout->ndims <= H5O_LAYOUT_NDIMS); /* Special case for faster checks on 1-D chunks */ /* (Checking for ndims==2 because last dimension is the datatype size) */ @@ -414,7 +405,7 @@ H5D_btree_cmp3(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, void *_udat /* slightly odd way the library initializes the right-most node in the */ /* indexed storage B-tree... */ /* (Dump the B-tree with h5debug to look at it) -QAK */ - if(udata->mesg->u.chunk.ndims == 2) { + if(udata->layout->ndims == 2) { if(udata->offset[0] > rt_key->offset[0]) ret_value = 1; else if(udata->offset[0] == rt_key->offset[0] && @@ -424,9 +415,9 @@ H5D_btree_cmp3(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, void *_udat ret_value = (-1); } /* end if */ else { - if(H5V_vector_ge_u(udata->mesg->u.chunk.ndims, udata->offset, rt_key->offset)) + if(H5V_vector_ge_u(udata->layout->ndims, udata->offset, rt_key->offset)) ret_value = 1; - else if(H5V_vector_lt_u(udata->mesg->u.chunk.ndims, udata->offset, lt_key->offset)) + else if(H5V_vector_lt_u(udata->layout->ndims, udata->offset, lt_key->offset)) ret_value = (-1); } /* end else */ @@ -477,8 +468,8 @@ H5D_btree_found(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, haddr_t addr, const void HDassert(lt_key); /* Is this *really* the requested chunk? */ - for(u = 0; u < udata->common.mesg->u.chunk.ndims; u++) - if(udata->common.offset[u] >= lt_key->offset[u] + udata->common.mesg->u.chunk.dim[u]) + for(u = 0; u < udata->common.layout->ndims; u++) + if(udata->common.offset[u] >= lt_key->offset[u] + udata->common.layout->dim[u]) HGOTO_DONE(FALSE) /* Initialize return values */ @@ -555,7 +546,7 @@ H5D_btree_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key, /* Negative indices not supported yet */ HGOTO_ERROR(H5E_STORAGE, H5E_UNSUPPORTED, H5B_INS_ERROR, "internal error") - } else if(H5V_vector_eq_u(udata->common.mesg->u.chunk.ndims, + } else if(H5V_vector_eq_u(udata->common.layout->ndims, udata->common.offset, lt_key->offset) && lt_key->nbytes > 0) { /* @@ -594,20 +585,20 @@ H5D_btree_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key, ret_value = H5B_INS_NOOP; } - } else if (H5V_hyper_disjointp(udata->common.mesg->u.chunk.ndims, - lt_key->offset, udata->common.mesg->u.chunk.dim, - udata->common.offset, udata->common.mesg->u.chunk.dim)) { - HDassert(H5V_hyper_disjointp(udata->common.mesg->u.chunk.ndims, - rt_key->offset, udata->common.mesg->u.chunk.dim, - udata->common.offset, udata->common.mesg->u.chunk.dim)); + } else if (H5V_hyper_disjointp(udata->common.layout->ndims, + lt_key->offset, udata->common.layout->dim, + udata->common.offset, udata->common.layout->dim)) { + HDassert(H5V_hyper_disjointp(udata->common.layout->ndims, + rt_key->offset, udata->common.layout->dim, + udata->common.offset, udata->common.layout->dim)); /* * Split this node, inserting the new new node to the right of the * current node. The MD_KEY is where the split occurs. */ md_key->nbytes = udata->nbytes; md_key->filter_mask = udata->filter_mask; - for(u = 0; u < udata->common.mesg->u.chunk.ndims; u++) { - HDassert(0 == udata->common.offset[u] % udata->common.mesg->u.chunk.dim[u]); + for(u = 0; u < udata->common.layout->ndims; u++) { + HDassert(0 == udata->common.offset[u] % udata->common.layout->dim[u]); md_key->offset[u] = udata->common.offset[u]; } /* end for */ @@ -771,7 +762,7 @@ H5D_btree_debug_key(FILE *stream, H5F_t UNUSED *f, hid_t UNUSED dxpl_id, int ind const void *_key, const void *_udata) { const H5D_btree_key_t *key = (const H5D_btree_key_t *)_key; - const H5D_btree_ud0_t *udata = (const H5D_btree_ud0_t *)_udata; + const unsigned *ndims = (const unsigned *)_udata; unsigned u; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_btree_debug_key) @@ -781,7 +772,7 @@ H5D_btree_debug_key(FILE *stream, H5F_t UNUSED *f, hid_t UNUSED dxpl_id, int ind HDfprintf(stream, "%*s%-*s %u bytes\n", indent, "", fwidth, "Chunk size:", (unsigned)key->nbytes); HDfprintf(stream, "%*s%-*s 0x%08x\n", indent, "", fwidth, "Filter mask:", key->filter_mask); HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Logical offset:"); - for(u = 0; u < udata->mesg->u.chunk.ndims; u++) + for(u = 0; u < *ndims; u++) HDfprintf(stream, "%s%Hd", u?", ":"", key->offset[u]); HDfputs("}\n", stream); @@ -802,7 +793,7 @@ H5D_btree_debug_key(FILE *stream, H5F_t UNUSED *f, hid_t UNUSED dxpl_id, int ind *------------------------------------------------------------------------- */ static herr_t -H5D_btree_shared_create(const H5F_t *f, H5O_layout_t *layout) +H5D_btree_shared_create(const H5F_t *f, H5O_storage_chunk_t *store, unsigned ndims) { H5B_shared_t *shared; /* Shared B-tree node info */ size_t sizeof_rkey; /* Size of raw (disk) key */ @@ -811,9 +802,9 @@ H5D_btree_shared_create(const H5F_t *f, H5O_layout_t *layout) FUNC_ENTER_NOAPI_NOINIT(H5D_btree_shared_create) /* Set the raw key size */ - sizeof_rkey = 4 + /*storage size */ - 4 + /*filter mask */ - layout->u.chunk.ndims * 8; /*dimension indices */ + sizeof_rkey = 4 + /*storage size */ + 4 + /*filter mask */ + ndims * 8; /*dimension indices */ /* Allocate & initialize global info for the shared structure */ if(NULL == (shared = H5B_shared_new(f, H5B_BTREE, sizeof_rkey))) @@ -823,7 +814,7 @@ H5D_btree_shared_create(const H5F_t *f, H5O_layout_t *layout) /* <none> */ /* Make shared B-tree info reference counted */ - if(NULL == (layout->u.chunk.u.btree.shared = H5RC_create(shared, H5B_shared_free))) + if(NULL == (store->u.btree.shared = H5RC_create(shared, H5B_shared_free))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't create ref-count wrapper for shared B-tree info") done: @@ -856,10 +847,11 @@ H5D_btree_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t UNUSED *space HDassert(idx_info->f); HDassert(idx_info->pline); HDassert(idx_info->layout); + HDassert(idx_info->storage); HDassert(H5F_addr_defined(dset_ohdr_addr)); /* Allocate the shared structure */ - if(H5D_btree_shared_create(idx_info->f, idx_info->layout) < 0) + if(H5D_btree_shared_create(idx_info->f, idx_info->storage, idx_info->layout->ndims) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create wrapper for shared B-tree info") done: @@ -888,7 +880,7 @@ done: static herr_t H5D_btree_idx_create(const H5D_chk_idx_info_t *idx_info) { - H5D_btree_ud0_t udata; /* User data for B-tree callback */ + H5D_chunk_common_ud_t udata; /* User data for B-tree callback */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_btree_idx_create) @@ -898,13 +890,15 @@ H5D_btree_idx_create(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->f); HDassert(idx_info->pline); HDassert(idx_info->layout); - HDassert(!H5F_addr_defined(idx_info->layout->store.u.chunk.idx_addr)); + HDassert(idx_info->storage); + HDassert(!H5F_addr_defined(idx_info->storage->idx_addr)); /* Initialize "user" data for B-tree callbacks, etc. */ - udata.mesg = idx_info->layout; + udata.layout = idx_info->layout; + udata.storage = idx_info->storage; /* Create the v1 B-tree for the chunk index */ - if(H5B_create(idx_info->f, idx_info->dxpl_id, H5B_BTREE, &udata, &(idx_info->layout->store.u.chunk.idx_addr)/*out*/) < 0) + if(H5B_create(idx_info->f, idx_info->dxpl_id, H5B_BTREE, &udata, &(idx_info->storage->idx_addr)/*out*/) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create B-tree") done: @@ -925,17 +919,17 @@ done: *------------------------------------------------------------------------- */ static hbool_t -H5D_btree_idx_is_space_alloc(const H5O_layout_t *layout) +H5D_btree_idx_is_space_alloc(const H5O_storage_chunk_t *storage) { hbool_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_btree_idx_is_space_alloc) /* Check args */ - HDassert(layout); + HDassert(storage); /* Set return value */ - ret_value = (hbool_t)H5F_addr_defined(layout->store.u.chunk.idx_addr); + ret_value = (hbool_t)H5F_addr_defined(storage->idx_addr); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_btree_idx_is_space_alloc() */ @@ -965,14 +959,15 @@ H5D_btree_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata) HDassert(idx_info->f); HDassert(idx_info->pline); HDassert(idx_info->layout); - HDassert(H5F_addr_defined(idx_info->layout->store.u.chunk.idx_addr)); + HDassert(idx_info->storage); + HDassert(H5F_addr_defined(idx_info->storage->idx_addr)); HDassert(udata); /* * Create the chunk it if it doesn't exist, or reallocate the chunk if * its size changed. */ - if(H5B_insert(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->layout->store.u.chunk.idx_addr, udata) < 0) + if(H5B_insert(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->storage->idx_addr, udata) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to allocate chunk") done: @@ -1005,11 +1000,13 @@ H5D_btree_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata HDassert(idx_info->f); HDassert(idx_info->pline); HDassert(idx_info->layout); - HDassert(idx_info->layout->u.chunk.ndims > 0); + HDassert(idx_info->layout->ndims > 0); + HDassert(idx_info->storage); + HDassert(H5F_addr_defined(idx_info->storage->idx_addr)); HDassert(udata); /* Go get the chunk information from the B-tree */ - if(H5B_find(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->layout->store.u.chunk.idx_addr, udata) < 0) + if(H5B_find(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->storage->idx_addr, udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk info") done: @@ -1091,18 +1088,20 @@ H5D_btree_idx_iterate(const H5D_chk_idx_info_t *idx_info, HDassert(idx_info->f); HDassert(idx_info->pline); HDassert(idx_info->layout); - HDassert(H5F_addr_defined(idx_info->layout->store.u.chunk.idx_addr)); + HDassert(idx_info->storage); + HDassert(H5F_addr_defined(idx_info->storage->idx_addr)); HDassert(chunk_cb); HDassert(chunk_udata); /* Initialize userdata */ HDmemset(&udata, 0, sizeof udata); - udata.common.mesg = idx_info->layout; + udata.common.layout = idx_info->layout; + udata.common.storage = idx_info->storage; udata.cb = chunk_cb; udata.udata = chunk_udata; /* Iterate over existing chunks */ - if((ret_value = H5B_iterate(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->layout->store.u.chunk.idx_addr, H5D_btree_idx_iterate_cb, &udata)) < 0) + if((ret_value = H5B_iterate(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->storage->idx_addr, H5D_btree_idx_iterate_cb, &udata)) < 0) HERROR(H5E_DATASET, H5E_BADITER, "unable to iterate over chunk B-tree"); FUNC_LEAVE_NOAPI(ret_value) @@ -1132,13 +1131,14 @@ H5D_btree_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t * HDassert(idx_info->f); HDassert(idx_info->pline); HDassert(idx_info->layout); - HDassert(H5F_addr_defined(idx_info->layout->store.u.chunk.idx_addr)); + HDassert(idx_info->storage); + HDassert(H5F_addr_defined(idx_info->storage->idx_addr)); HDassert(udata); /* Remove the chunk from the v1 B-tree index and release the space for the * chunk (in the B-tree callback). */ - if(H5B_remove(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->layout->store.u.chunk.idx_addr, udata) < 0) + if(H5B_remove(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->storage->idx_addr, udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to remove chunk entry") done: @@ -1172,29 +1172,33 @@ H5D_btree_idx_delete(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->f); HDassert(idx_info->pline); HDassert(idx_info->layout); + HDassert(idx_info->storage); /* Check if the index data structure has been allocated */ - if(H5F_addr_defined(idx_info->layout->store.u.chunk.idx_addr)) { - H5O_layout_t tmp_layout; /* Local copy of layout info */ - H5D_btree_ud0_t udata; /* User data for B-tree iterator call */ + if(H5F_addr_defined(idx_info->storage->idx_addr)) { + H5O_storage_chunk_t tmp_storage; /* Local copy of storage info */ + H5D_chunk_common_ud_t udata; /* User data for B-tree operations */ - /* Set up user data for B-tree deletion */ - HDmemset(&udata, 0, sizeof udata); - tmp_layout = *idx_info->layout; - udata.mesg = &tmp_layout; + /* Set up temporary chunked storage info */ + tmp_storage = *idx_info->storage; /* Set up the shared structure */ - if(H5D_btree_shared_create(idx_info->f, &tmp_layout) < 0) + if(H5D_btree_shared_create(idx_info->f, &tmp_storage, idx_info->layout->ndims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create wrapper for shared B-tree info") + /* Set up B-tree user data */ + HDmemset(&udata, 0, sizeof udata); + udata.layout = idx_info->layout; + udata.storage = &tmp_storage; + /* Delete entire B-tree */ - if(H5B_delete(idx_info->f, idx_info->dxpl_id, H5B_BTREE, tmp_layout.store.u.chunk.idx_addr, &udata) < 0) + if(H5B_delete(idx_info->f, idx_info->dxpl_id, H5B_BTREE, tmp_storage.idx_addr, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to delete chunk B-tree") - /* Free the raw B-tree node buffer */ - if(NULL == tmp_layout.u.chunk.u.btree.shared) + /* Release the shared B-tree page */ + if(NULL == tmp_storage.u.btree.shared) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "ref-counted page nil") - if(H5RC_DEC(tmp_layout.u.chunk.u.btree.shared) < 0) + if(H5RC_DEC(tmp_storage.u.btree.shared) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to decrement ref-counted page") } /* end if */ @@ -1227,22 +1231,24 @@ H5D_btree_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, HDassert(idx_info_src->f); HDassert(idx_info_src->pline); HDassert(idx_info_src->layout); + HDassert(idx_info_src->storage); HDassert(idx_info_dst); HDassert(idx_info_dst->f); HDassert(idx_info_dst->pline); HDassert(idx_info_dst->layout); - HDassert(!H5F_addr_defined(idx_info_dst->layout->store.u.chunk.idx_addr)); + HDassert(idx_info_dst->storage); + HDassert(!H5F_addr_defined(idx_info_dst->storage->idx_addr)); /* Create shared B-tree info for each file */ - if(H5D_btree_shared_create(idx_info_src->f, idx_info_src->layout) < 0) + if(H5D_btree_shared_create(idx_info_src->f, idx_info_src->storage, idx_info_src->layout->ndims) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create wrapper for source shared B-tree info") - if(H5D_btree_shared_create(idx_info_dst->f, idx_info_dst->layout) < 0) + if(H5D_btree_shared_create(idx_info_dst->f, idx_info_dst->storage, idx_info_dst->layout->ndims) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create wrapper for destination shared B-tree info") /* Create the root of the B-tree that describes chunked storage in the dest. file */ if(H5D_btree_idx_create(idx_info_dst) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to initialize chunked storage") - HDassert(H5F_addr_defined(idx_info_dst->layout->store.u.chunk.idx_addr)); + HDassert(H5F_addr_defined(idx_info_dst->storage->idx_addr)); done: FUNC_LEAVE_NOAPI(ret_value) @@ -1262,20 +1268,21 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D_btree_idx_copy_shutdown(H5O_layout_t *layout_src, H5O_layout_t *layout_dst, +H5D_btree_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, + H5O_storage_chunk_t *storage_dst, hid_t UNUSED dxpl_id) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_btree_idx_copy_shutdown) - HDassert(layout_src); - HDassert(layout_dst); + HDassert(storage_src); + HDassert(storage_dst); /* Decrement refcount on shared B-tree info */ - if(H5RC_DEC(layout_src->u.chunk.u.btree.shared) < 0) + if(H5RC_DEC(storage_src->u.btree.shared) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to decrement ref-counted page") - if(H5RC_DEC(layout_dst->u.chunk.u.btree.shared) < 0) + if(H5RC_DEC(storage_dst->u.btree.shared) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to decrement ref-counted page") done: @@ -1299,7 +1306,7 @@ done: static herr_t H5D_btree_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) { - H5D_btree_ud0_t udata; /* User-data for loading B-tree nodes */ + H5D_chunk_common_ud_t udata; /* User-data for loading B-tree nodes */ H5B_info_t bt_info; /* B-tree info */ hbool_t shared_init = FALSE; /* Whether shared B-tree info is initialized */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1311,19 +1318,21 @@ H5D_btree_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) HDassert(idx_info->f); HDassert(idx_info->pline); HDassert(idx_info->layout); + HDassert(idx_info->storage); HDassert(index_size); /* Initialize the shared info for the B-tree traversal */ - if(H5D_btree_shared_create(idx_info->f, idx_info->layout) < 0) + if(H5D_btree_shared_create(idx_info->f, idx_info->storage, idx_info->layout->ndims) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create wrapper for shared B-tree info") shared_init = TRUE; /* Initialize B-tree node user-data */ HDmemset(&udata, 0, sizeof udata); - udata.mesg = idx_info->layout; + udata.layout = idx_info->layout; + udata.storage = idx_info->storage; /* Get metadata information for B-tree */ - if(H5B_get_info(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->layout->store.u.chunk.idx_addr, &bt_info, NULL, &udata) < 0) + if(H5B_get_info(idx_info->f, idx_info->dxpl_id, H5B_BTREE, idx_info->storage->idx_addr, &bt_info, NULL, &udata) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to iterate over chunk B-tree") /* Set the size of the B-tree */ @@ -1331,9 +1340,9 @@ H5D_btree_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) done: if(shared_init) { - if(NULL == idx_info->layout->u.chunk.u.btree.shared) + if(NULL == idx_info->storage->u.btree.shared) HDONE_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "ref-counted page nil") - if(H5RC_DEC(idx_info->layout->u.chunk.u.btree.shared) < 0) + if(H5RC_DEC(idx_info->storage->u.btree.shared) < 0) HDONE_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted page") } /* end if */ @@ -1354,16 +1363,16 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D_btree_idx_reset(H5O_layout_t *layout, hbool_t reset_addr) +H5D_btree_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_btree_idx_reset) - HDassert(layout); + HDassert(storage); /* Reset index info */ if(reset_addr) - layout->store.u.chunk.idx_addr = HADDR_UNDEF; - layout->u.chunk.u.btree.shared = NULL; + storage->idx_addr = HADDR_UNDEF; + storage->u.btree.shared = NULL; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D_btree_idx_reset() */ @@ -1382,17 +1391,14 @@ H5D_btree_idx_reset(H5O_layout_t *layout, hbool_t reset_addr) *------------------------------------------------------------------------- */ static herr_t -H5D_btree_idx_dump(const H5D_chk_idx_info_t *idx_info, FILE *stream) +H5D_btree_idx_dump(const H5O_storage_chunk_t *storage, FILE *stream) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_btree_idx_dump) - HDassert(idx_info); - HDassert(idx_info->f); - HDassert(idx_info->pline); - HDassert(idx_info->layout); + HDassert(storage); HDassert(stream); - HDfprintf(stream, " Address: %a\n", idx_info->layout->store.u.chunk.idx_addr); + HDfprintf(stream, " Address: %a\n", storage->idx_addr); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D_btree_idx_dump() */ @@ -1421,11 +1427,12 @@ H5D_btree_idx_dest(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->f); HDassert(idx_info->pline); HDassert(idx_info->layout); + HDassert(idx_info->storage); /* Free the raw B-tree node buffer */ - if(NULL == idx_info->layout->u.chunk.u.btree.shared) + if(NULL == idx_info->storage->u.btree.shared) HGOTO_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "ref-counted page nil") - if(H5RC_DEC(idx_info->layout->u.chunk.u.btree.shared) < 0) + if(H5RC_DEC(idx_info->storage->u.btree.shared) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted page") done: @@ -1449,33 +1456,29 @@ herr_t H5D_btree_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int fwidth, unsigned ndims) { - H5D_btree_ud0_t udata; /* B-tree user data */ - H5O_layout_t layout; /* Layout information for B-tree callback */ + H5O_storage_chunk_t storage; /* Storage information for B-tree callback */ hbool_t shared_init = FALSE; /* Whether B-tree shared info is initialized */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_btree_debug, FAIL) - /* Set up "fake" layout info */ - layout.u.chunk.ndims = ndims; + /* Reset "fake" storage info */ + HDmemset(&storage, 0, sizeof(storage)); /* Allocate the shared structure */ - if(H5D_btree_shared_create(f, &layout) < 0) + if(H5D_btree_shared_create(f, &storage, ndims) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "can't create wrapper for shared B-tree info") shared_init = TRUE; - /* Set up B-tree user data */ - HDmemset(&udata, 0, sizeof udata); - udata.mesg = &layout; - - (void)H5B_debug(f, dxpl_id, addr, stream, indent, fwidth, H5B_BTREE, &udata); + /* Dump the records for the B-tree */ + (void)H5B_debug(f, dxpl_id, addr, stream, indent, fwidth, H5B_BTREE, &ndims); done: if(shared_init) { /* Free the raw B-tree node buffer */ - if(NULL == layout.u.chunk.u.btree.shared) + if(NULL == storage.u.btree.shared) HDONE_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "ref-counted page nil") - if(H5RC_DEC(layout.u.chunk.u.btree.shared) < 0) + if(H5RC_DEC(storage.u.btree.shared) < 0) HDONE_ERROR(H5E_IO, H5E_CANTFREE, FAIL, "unable to decrement ref-counted page") } /* end if */ diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 51c14e6..4b19e73 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -353,7 +353,7 @@ H5D_chunk_set_info(const H5D_t *dset) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set layout's chunk info") /* Call the index's "resize" callback */ - if(dset->shared->layout.u.chunk.ops->resize && (dset->shared->layout.u.chunk.ops->resize)(&dset->shared->layout) < 0) + if(dset->shared->layout.storage.u.chunk.ops->resize && (dset->shared->layout.storage.u.chunk.ops->resize)(&dset->shared->layout.u.chunk) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to resize chunk index information") done: @@ -433,7 +433,7 @@ H5D_chunk_construct(H5F_t *f, H5D_t *dset) H5_ASSIGN_OVERFLOW(dset->shared->layout.u.chunk.size, chunk_size, uint64_t, uint32_t); /* Reset address and pointer of the array struct for the chunked storage index */ - if(H5D_chunk_idx_reset(&dset->shared->layout, TRUE) < 0) + if(H5D_chunk_idx_reset(&dset->shared->layout.storage.u.chunk, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to reset chunked storage index") done: @@ -503,10 +503,11 @@ H5D_chunk_init(H5F_t *f, hid_t dxpl_id, const H5D_t *dset, hid_t dapl_id) idx_info.f = f; idx_info.dxpl_id = dxpl_id; idx_info.pline = &dset->shared->dcpl_cache.pline; - idx_info.layout = &dset->shared->layout; + idx_info.layout = &dset->shared->layout.u.chunk; + idx_info.storage = &dset->shared->layout.storage.u.chunk; /* Allocate any indexing structures */ - if(dset->shared->layout.u.chunk.ops->init && (dset->shared->layout.u.chunk.ops->init)(&idx_info, dset->shared->space, dset->oloc.addr) < 0) + if(dset->shared->layout.storage.u.chunk.ops->init && (dset->shared->layout.storage.u.chunk.ops->init)(&idx_info, dset->shared->space, dset->oloc.addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize indexing information") /* Set the number of chunks in dataset */ @@ -541,7 +542,7 @@ H5D_chunk_is_space_alloc(const H5O_layout_t *layout) HDassert(layout); /* Query index layer */ - ret_value = (layout->u.chunk.ops->is_space_alloc)(layout); + ret_value = (layout->storage.u.chunk.ops->is_space_alloc)(&layout->storage.u.chunk); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_chunk_is_space_alloc() */ @@ -1883,13 +1884,14 @@ H5D_chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, idx_info.f = io_info->dset->oloc.file; idx_info.dxpl_id = io_info->dxpl_id; idx_info.pline = &(io_info->dset->shared->dcpl_cache.pline); - idx_info.layout = &(io_info->dset->shared->layout); + idx_info.layout = &(io_info->dset->shared->layout.u.chunk); + idx_info.storage = &(io_info->dset->shared->layout.storage.u.chunk); /* Set up the size of chunk for user data */ udata.nbytes = io_info->dset->shared->layout.u.chunk.size; /* Create the chunk */ - if((io_info->dset->shared->layout.u.chunk.ops->insert)(&idx_info, &udata) < 0) + if((io_info->dset->shared->layout.storage.u.chunk.ops->insert)(&idx_info, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert/resize chunk") /* Make sure the address of the chunk is returned. */ @@ -2047,18 +2049,18 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D_chunk_idx_reset(H5O_layout_t *layout, hbool_t reset_addr) +H5D_chunk_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_chunk_idx_reset, FAIL) /* Sanity checks */ - HDassert(layout); - HDassert(layout->u.chunk.ops); + HDassert(storage); + HDassert(storage->ops); /* Reset index structures */ - if((layout->u.chunk.ops->reset)(layout, reset_addr) < 0) + if((storage->ops->reset)(storage, reset_addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to reset chunk index info") done: @@ -2115,11 +2117,12 @@ H5D_chunk_cinfo_cache_update(H5D_chunk_cached_t *last, const H5D_chunk_ud_t *uda /* Sanity check */ HDassert(last); HDassert(udata); - HDassert(udata->common.mesg); + HDassert(udata->common.layout); + HDassert(udata->common.storage); HDassert(udata->common.offset); /* Stored the information to cache */ - for(u = 0; u < udata->common.mesg->u.chunk.ndims; u++) + for(u = 0; u < udata->common.layout->ndims; u++) last->offset[u] = udata->common.offset[u]; last->nbytes = udata->nbytes; last->filter_mask = udata->filter_mask; @@ -2154,7 +2157,8 @@ H5D_chunk_cinfo_cache_found(const H5D_chunk_cached_t *last, H5D_chunk_ud_t *udat /* Sanity check */ HDassert(last); HDassert(udata); - HDassert(udata->common.mesg); + HDassert(udata->common.layout); + HDassert(udata->common.storage); HDassert(udata->common.offset); /* Check if the cached information is what is desired */ @@ -2162,7 +2166,7 @@ H5D_chunk_cinfo_cache_found(const H5D_chunk_cached_t *last, H5D_chunk_ud_t *udat unsigned u; /* Local index variable */ /* Check that the offset is the same */ - for(u = 0; u < udata->common.mesg->u.chunk.ndims; u++) + for(u = 0; u < udata->common.layout->ndims; u++) if(last->offset[u] != udata->common.offset[u]) HGOTO_DONE(FALSE) @@ -2220,10 +2224,11 @@ H5D_chunk_create(H5D_t *dset /*in,out*/, hid_t dxpl_id) idx_info.f = dset->oloc.file; idx_info.dxpl_id = dxpl_id; idx_info.pline = &dset->shared->dcpl_cache.pline; - idx_info.layout = &dset->shared->layout; + idx_info.layout = &dset->shared->layout.u.chunk; + idx_info.storage = &dset->shared->layout.storage.u.chunk; /* Create the index for the chunks */ - if((dset->shared->layout.u.chunk.ops->create)(&idx_info) < 0) + if((dset->shared->layout.storage.u.chunk.ops->create)(&idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create chunk index") done: @@ -2259,7 +2264,8 @@ H5D_chunk_get_info(const H5D_t *dset, hid_t dxpl_id, const hsize_t *chunk_offset HDassert(udata); /* Initialize the query information about the chunk we are looking for */ - udata->common.mesg = &(dset->shared->layout); + udata->common.layout = &(dset->shared->layout.u.chunk); + udata->common.storage = &(dset->shared->layout.storage.u.chunk); udata->common.offset = chunk_offset; /* Reset information about the chunk we are looking for */ @@ -2275,10 +2281,11 @@ H5D_chunk_get_info(const H5D_t *dset, hid_t dxpl_id, const hsize_t *chunk_offset idx_info.f = dset->oloc.file; idx_info.dxpl_id = dxpl_id; idx_info.pline = &dset->shared->dcpl_cache.pline; - idx_info.layout = &dset->shared->layout; + idx_info.layout = &dset->shared->layout.u.chunk; + idx_info.storage = &dset->shared->layout.storage.u.chunk; /* Go get the chunk information */ - if((dset->shared->layout.u.chunk.ops->get_addr)(&idx_info, udata) < 0) + if((dset->shared->layout.storage.u.chunk.ops->get_addr)(&idx_info, udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query chunk address") /* Cache the information retrieved */ @@ -2327,7 +2334,8 @@ H5D_chunk_flush_entry(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t * hbool_t must_insert = FALSE; /* Whether the chunk must go through the "insert" method */ /* Set up user data for index callbacks */ - udata.common.mesg = &dset->shared->layout; + udata.common.layout = &dset->shared->layout.u.chunk; + udata.common.storage = &dset->shared->layout.storage.u.chunk; udata.common.offset = ent->offset; udata.filter_mask = 0; udata.nbytes = dset->shared->layout.u.chunk.size; @@ -2388,12 +2396,13 @@ H5D_chunk_flush_entry(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t * idx_info.f = dset->oloc.file; idx_info.dxpl_id = dxpl_id; idx_info.pline = &dset->shared->dcpl_cache.pline; - idx_info.layout = &dset->shared->layout; + idx_info.layout = &dset->shared->layout.u.chunk; + idx_info.storage = &dset->shared->layout.storage.u.chunk; /* Create the chunk it if it doesn't exist, or reallocate the chunk * if its size changed. */ - if((dset->shared->layout.u.chunk.ops->insert)(&idx_info, &udata) < 0) + if((dset->shared->layout.storage.u.chunk.ops->insert)(&idx_info, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert/resize chunk") /* Update the chunk entry's address, in case it was allocated or relocated */ @@ -3045,10 +3054,11 @@ H5D_chunk_allocated(H5D_t *dset, hid_t dxpl_id, hsize_t *nbytes) idx_info.f = dset->oloc.file; idx_info.dxpl_id = dxpl_id; idx_info.pline = &dset->shared->dcpl_cache.pline; - idx_info.layout = &dset->shared->layout; + idx_info.layout = &dset->shared->layout.u.chunk; + idx_info.storage = &dset->shared->layout.storage.u.chunk; /* Iterate over the chunks */ - if((dset->shared->layout.u.chunk.ops->iterate)(&idx_info, H5D_chunk_allocated_cb, &chunk_bytes) < 0) + if((dset->shared->layout.storage.u.chunk.ops->iterate)(&idx_info, H5D_chunk_allocated_cb, &chunk_bytes) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve allocated chunk information from index") /* Set number of bytes for caller */ @@ -3077,7 +3087,7 @@ herr_t H5D_chunk_allocate(H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite) { H5D_chk_idx_info_t idx_info; /* Chunked index info */ - const H5D_chunk_ops_t *ops = dset->shared->layout.u.chunk.ops; /* Chunk operations */ + const H5D_chunk_ops_t *ops = dset->shared->layout.storage.u.chunk.ops; /* Chunk operations */ hsize_t chunk_offset[H5O_LAYOUT_NDIMS]; /* Offset of current chunk */ size_t orig_chunk_size; /* Original size of chunk in bytes */ unsigned filter_mask = 0; /* Filter mask for chunks that have them */ @@ -3196,7 +3206,8 @@ H5D_chunk_allocate(H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite) idx_info.f = dset->oloc.file; idx_info.dxpl_id = dxpl_id; idx_info.pline = &dset->shared->dcpl_cache.pline; - idx_info.layout = &dset->shared->layout; + idx_info.layout = &dset->shared->layout.u.chunk; + idx_info.storage = &dset->shared->layout.storage.u.chunk; /* Reset the chunk offset indices */ HDmemset(chunk_offset, 0, (layout->u.chunk.ndims * sizeof(chunk_offset[0]))); @@ -3270,7 +3281,8 @@ H5D_chunk_allocate(H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite) chunk_size = orig_chunk_size; /* Initialize the chunk information */ - udata.common.mesg = layout; + udata.common.layout = &layout->u.chunk; + udata.common.storage = &layout->storage.u.chunk; udata.common.offset = chunk_offset; H5_ASSIGN_OVERFLOW(udata.nbytes, chunk_size, size_t, uint32_t); udata.filter_mask = filter_mask; @@ -3371,7 +3383,7 @@ H5D_chunk_prune_fill(const H5D_chunk_rec_t *chunk_rec, H5D_chunk_it_ud1_t *udata const H5D_io_info_t *io_info = udata->io_info; /* Local pointer to I/O info */ H5D_t *dset = io_info->dset; /* Local pointer to the dataset info */ const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset's layout */ - unsigned rank = udata->common.mesg->u.chunk.ndims - 1; /* Dataset rank */ + unsigned rank = udata->common.layout->ndims - 1; /* Dataset rank */ H5S_sel_iter_t chunk_iter; /* Memory selection iteration info */ hssize_t sel_nelmts; /* Number of elements in selection */ hsize_t count[H5O_LAYOUT_NDIMS]; /* Element count of hyperslab */ @@ -3416,7 +3428,8 @@ H5D_chunk_prune_fill(const H5D_chunk_rec_t *chunk_rec, H5D_chunk_it_ud1_t *udata /* Lock the chunk into the cache, to get a pointer to the chunk buffer */ /* (Casting away const OK -QAK) */ io_info->store->chunk.offset = (hsize_t *)chunk_rec->offset; - chk_udata.common.mesg = layout; + chk_udata.common.layout = &layout->u.chunk; + chk_udata.common.storage = &layout->storage.u.chunk; chk_udata.common.offset = chunk_rec->offset; chk_udata.nbytes = chunk_rec->nbytes; chk_udata.filter_mask = chunk_rec->filter_mask; @@ -3498,7 +3511,7 @@ H5D_chunk_prune_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) FUNC_ENTER_NOAPI_NOINIT(H5D_chunk_prune_cb) /* Figure out what chunks are no longer in use for the specified extent and release them */ - rank = udata->common.mesg->u.chunk.ndims - 1; + rank = udata->common.layout->ndims - 1; for(u = 0; u < rank; u++) /* The chunk record points to a chunk of storage that contains the * beginning of the logical address space represented by UDATA. @@ -3512,7 +3525,7 @@ H5D_chunk_prune_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) break; } /* end if */ /* Check for chunk that overlaps new extent and will need fill values */ - else if((chunk_rec->offset[u] + udata->common.mesg->u.chunk.dim[u]) > udata->dims[u]) + else if((chunk_rec->offset[u] + udata->common.layout->dim[u]) > udata->dims[u]) /* Indicate that the chunk needs filling */ /* (but continue in loop, since it could be outside the extent in * another dimension -QAK) @@ -3721,11 +3734,13 @@ H5D_chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dims) idx_info.f = dset->oloc.file; idx_info.dxpl_id = dxpl_id; idx_info.pline = &dset->shared->dcpl_cache.pline; - idx_info.layout = &dset->shared->layout; + idx_info.layout = &dset->shared->layout.u.chunk; + idx_info.storage = &dset->shared->layout.storage.u.chunk; /* Initialize the user data for the iteration */ HDmemset(&udata, 0, sizeof udata); - udata.common.mesg = layout; + udata.common.layout = &layout->u.chunk; + udata.common.storage = &layout->storage.u.chunk; udata.io_info = &chk_io_info; udata.idx_info = &idx_info; udata.dims = curr_dims; @@ -3794,19 +3809,20 @@ H5D_chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dims) } /* end while */ /* Iterate over the chunks */ - if((dset->shared->layout.u.chunk.ops->iterate)(&idx_info, H5D_chunk_prune_cb, &udata) < 0) + if((dset->shared->layout.storage.u.chunk.ops->iterate)(&idx_info, H5D_chunk_prune_cb, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve prune chunks from index") /* Traverse the stack of chunks to be deleted, removing each. We will free * the nodes later in the "done" section. */ - idx_udata.mesg = layout; + idx_udata.layout = &layout->u.chunk; + idx_udata.storage = &layout->storage.u.chunk; tmp_stack = udata.rm_stack; while(tmp_stack) { /* Update the offset in idx_udata */ idx_udata.offset = tmp_stack->rec.offset; /* Remove the chunk from disk */ - if((layout->u.chunk.ops->remove)(&idx_info, &idx_udata) < 0) + if((layout->storage.u.chunk.ops->remove)(&idx_info, &idx_udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, H5_ITER_ERROR, "unable to remove chunk entry from index") /* Advance the stack pointer */ @@ -3865,14 +3881,14 @@ static int H5D_chunk_addrmap_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) { H5D_chunk_it_ud2_t *udata = (H5D_chunk_it_ud2_t *)_udata; /* User data for callback */ - unsigned rank = udata->common.mesg->u.chunk.ndims - 1; /* # of dimensions of dataset */ + unsigned rank = udata->common.layout->ndims - 1; /* # of dimensions of dataset */ hsize_t chunk_index; int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_chunk_addrmap_cb) /* Compute the index for this chunk */ - if(H5V_chunk_index(rank, chunk_rec->offset, udata->common.mesg->u.chunk.dim, udata->common.mesg->u.chunk.down_chunks, &chunk_index) < 0) + if(H5V_chunk_index(rank, chunk_rec->offset, udata->common.layout->dim, udata->common.layout->down_chunks, &chunk_index) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, H5_ITER_ERROR, "can't get chunk index") /* Set it in the userdata to return */ @@ -3912,17 +3928,19 @@ H5D_chunk_addrmap(const H5D_io_info_t *io_info, haddr_t chunk_addr[]) /* Set up user data for B-tree callback */ HDmemset(&udata, 0, sizeof(udata)); - udata.common.mesg = &dset->shared->layout; + udata.common.layout = &dset->shared->layout.u.chunk; + udata.common.storage = &dset->shared->layout.storage.u.chunk; udata.chunk_addr = chunk_addr; /* Compose chunked index info struct */ idx_info.f = dset->oloc.file; idx_info.dxpl_id = io_info->dxpl_id; idx_info.pline = &dset->shared->dcpl_cache.pline; - idx_info.layout = &dset->shared->layout; + idx_info.layout = &dset->shared->layout.u.chunk; + idx_info.storage = &dset->shared->layout.storage.u.chunk; /* Iterate over chunks to build mapping of chunk addresses */ - if((dset->shared->layout.u.chunk.ops->iterate)(&idx_info, H5D_chunk_addrmap_cb, &udata) < 0) + if((dset->shared->layout.storage.u.chunk.ops->iterate)(&idx_info, H5D_chunk_addrmap_cb, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to iterate over chunk index to build address map") done: @@ -3945,9 +3963,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D_chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_layout_t *layout) +H5D_chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_storage_t *storage) { H5D_chk_idx_info_t idx_info; /* Chunked index info */ + H5O_layout_t layout; /* Dataset layout message */ H5O_pline_t pline; /* I/O pipeline message */ htri_t exists; /* Flag if header message of interest exists */ herr_t ret_value = SUCCEED; /* Return value */ @@ -3957,26 +3976,37 @@ H5D_chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_layout_t *layout) /* Sanity check */ HDassert(f); HDassert(oh); - HDassert(layout); + HDassert(storage); /* Check for I/O pipeline message */ if((exists = H5O_msg_exists_oh(oh, H5O_PLINE_ID)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read object header") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to check for object header message") else if(exists) { if(NULL == H5O_msg_read_oh(f, dxpl_id, oh, H5O_PLINE_ID, &pline)) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't find I/O pipeline message") + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get I/O pipeline message") } /* end else if */ else HDmemset(&pline, 0, sizeof(pline)); + /* Retrieve dataset layout message */ + if((exists = H5O_msg_exists_oh(oh, H5O_LAYOUT_ID)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to check for object header message") + else if(exists) { + if(NULL == H5O_msg_read_oh(f, dxpl_id, oh, H5O_LAYOUT_ID, &layout)) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get layout message") + } /* end else if */ + else + HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "can't find layout message") + /* Compose chunked index info struct */ idx_info.f = f; idx_info.dxpl_id = dxpl_id; idx_info.pline = &pline; - idx_info.layout = layout; + idx_info.layout = &layout.u.chunk; + idx_info.storage = &storage->u.chunk; /* Delete the chunked storage information in the file */ - if((layout->u.chunk.ops->idx_delete)(&idx_info) < 0) + if((storage->u.chunk.ops->idx_delete)(&idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to delete chunk index") done: @@ -4209,7 +4239,8 @@ H5D_chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) } /* end if */ /* Set up destination chunk callback information for insertion */ - udata_dst.common.mesg = udata->idx_info_dst->layout; + udata_dst.common.layout = udata->idx_info_dst->layout; + udata_dst.common.storage = udata->idx_info_dst->storage; udata_dst.common.offset = chunk_rec->offset; udata_dst.nbytes = chunk_rec->nbytes; udata_dst.filter_mask = chunk_rec->filter_mask; @@ -4230,7 +4261,7 @@ H5D_chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) } /* end if */ /* Insert chunk into the destination index */ - if((udata->idx_info_dst->layout->u.chunk.ops->insert)(udata->idx_info_dst, &udata_dst) < 0) + if((udata->idx_info_dst->storage->ops->insert)(udata->idx_info_dst, &udata_dst) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert chunk into index") /* Write chunk data to destination file */ @@ -4302,7 +4333,7 @@ H5D_chunk_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst, pline = pline_src; /* Layout is not created in the destination file, reset index address */ - if(H5D_chunk_idx_reset(layout_dst, TRUE) < 0) + if(H5D_chunk_idx_reset(&layout_dst->storage.u.chunk, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to reset chunked storage index in dest") /* Initialize layout information */ @@ -4329,15 +4360,17 @@ H5D_chunk_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst, idx_info_src.f = f_src; idx_info_src.dxpl_id = dxpl_id; idx_info_src.pline = pline; - idx_info_src.layout = layout_src; + idx_info_src.layout = &layout_src->u.chunk; + idx_info_src.storage = &layout_src->storage.u.chunk; idx_info_dst.f = f_dst; idx_info_dst.dxpl_id = dxpl_id; idx_info_dst.pline = pline; /* Use same I/O filter pipeline for dest. */ - idx_info_dst.layout = layout_dst; + idx_info_dst.layout = &layout_dst->u.chunk; + idx_info_dst.storage = &layout_dst->storage.u.chunk; /* Call the index-specific "copy setup" routine */ - if((layout_src->u.chunk.ops->copy_setup)(&idx_info_src, &idx_info_dst) < 0) + if((layout_src->storage.u.chunk.ops->copy_setup)(&idx_info_src, &idx_info_dst) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set up index-specific chunk copying information") copy_setup_done = TRUE; @@ -4441,7 +4474,8 @@ H5D_chunk_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst, /* Initialize the callback structure for the source */ HDmemset(&udata, 0, sizeof udata); - udata.common.mesg = layout_src; + udata.common.layout = &layout_src->u.chunk; + udata.common.storage = &layout_src->storage.u.chunk; udata.file_src = f_src; udata.idx_info_dst = &idx_info_dst; udata.buf = buf; @@ -4462,7 +4496,7 @@ H5D_chunk_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst, udata.cpy_info = cpy_info; /* Iterate over chunks to copy data */ - if((layout_src->u.chunk.ops->iterate)(&idx_info_src, H5D_chunk_copy_cb, &udata) < 0) + if((layout_src->storage.u.chunk.ops->iterate)(&idx_info_src, H5D_chunk_copy_cb, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to iterate over chunk index to copy data") /* I/O buffers may have been re-allocated */ @@ -4490,7 +4524,7 @@ done: /* Clean up any index information */ if(copy_setup_done) - if((layout_src->u.chunk.ops->copy_shutdown)(layout_src, layout_dst, dxpl_id) < 0) + if((layout_src->storage.u.chunk.ops->copy_shutdown)(&layout_src->storage.u.chunk, &layout_dst->storage.u.chunk, dxpl_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to shut down index copying info") FUNC_LEAVE_NOAPI(ret_value) @@ -4529,10 +4563,11 @@ H5D_chunk_bh_info(H5F_t *f, hid_t dxpl_id, H5O_layout_t *layout, idx_info.f = f; idx_info.dxpl_id = dxpl_id; idx_info.pline = pline; - idx_info.layout = layout; + idx_info.layout = &layout->u.chunk; + idx_info.storage = &layout->storage.u.chunk; /* Get size of index structure */ - if((layout->u.chunk.ops->size)(&idx_info, index_size) < 0) + if((layout->storage.u.chunk.ops->size)(&idx_info, index_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve chunk index info") done: @@ -4615,15 +4650,16 @@ H5D_chunk_dump_index(H5D_t *dset, hid_t dxpl_id, FILE *stream) H5D_chk_idx_info_t idx_info; /* Chunked index info */ H5D_chunk_it_ud4_t udata; /* User data for callback */ + /* Display info for index */ + if((dset->shared->layout.storage.u.chunk.ops->dump)(&dset->shared->layout.storage.u.chunk, stream) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to dump chunk index info") + /* Compose chunked index info struct */ idx_info.f = dset->oloc.file; idx_info.dxpl_id = dxpl_id; idx_info.pline = &dset->shared->dcpl_cache.pline; - idx_info.layout = &dset->shared->layout; - - /* Display info for index */ - if((dset->shared->layout.u.chunk.ops->dump)(&idx_info, stream) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to dump chunk index info") + idx_info.layout = &dset->shared->layout.u.chunk; + idx_info.storage = &dset->shared->layout.storage.u.chunk; /* Set up user data for callback */ udata.stream = stream; @@ -4631,7 +4667,7 @@ H5D_chunk_dump_index(H5D_t *dset, hid_t dxpl_id, FILE *stream) udata.ndims = dset->shared->layout.u.chunk.ndims; /* Iterate over index and dump chunk info */ - if((dset->shared->layout.u.chunk.ops->iterate)(&idx_info, H5D_chunk_dump_index_cb, &udata) < 0) + if((dset->shared->layout.storage.u.chunk.ops->iterate)(&idx_info, H5D_chunk_dump_index_cb, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to iterate over chunk index to dump chunk info") } /* end if */ @@ -4691,10 +4727,11 @@ H5D_chunk_dest(H5F_t *f, hid_t dxpl_id, H5D_t *dset) idx_info.f = f; idx_info.dxpl_id = dxpl_id; idx_info.pline = &dset->shared->dcpl_cache.pline; - idx_info.layout = &dset->shared->layout; + idx_info.layout = &dset->shared->layout.u.chunk; + idx_info.storage = &dset->shared->layout.storage.u.chunk; /* Free any index structures */ - if((dset->shared->layout.u.chunk.ops->dest)(&idx_info) < 0) + if((dset->shared->layout.storage.u.chunk.ops->dest)(&idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to release chunk index info") done: diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c index 17bf531..ae6a72e 100644 --- a/src/H5Dcompact.c +++ b/src/H5Dcompact.c @@ -127,16 +127,16 @@ H5D_compact_fill(H5D_t *dset, hid_t dxpl_id) /* Check args */ HDassert(TRUE == H5P_isa_class(dxpl_id, H5P_DATASET_XFER)); HDassert(dset && H5D_COMPACT == dset->shared->layout.type); - HDassert(dset->shared->layout.store.u.compact.buf); + HDassert(dset->shared->layout.storage.u.compact.buf); HDassert(dset->shared->type); HDassert(dset->shared->space); /* Initialize the fill value buffer */ /* (use the compact dataset storage buffer as the fill value buffer) */ - if(H5D_fill_init(&fb_info, dset->shared->layout.store.u.compact.buf, FALSE, + if(H5D_fill_init(&fb_info, dset->shared->layout.storage.u.compact.buf, FALSE, NULL, NULL, NULL, NULL, &dset->shared->dcpl_cache.fill, dset->shared->type, - dset->shared->type_id, (size_t)0, dset->shared->layout.store.u.compact.size, dxpl_id) < 0) + dset->shared->type_id, (size_t)0, dset->shared->layout.storage.u.compact.size, dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize fill buffer info") fb_info_init = TRUE; @@ -186,13 +186,13 @@ H5D_compact_construct(H5F_t *f, H5D_t *dset) * layout. */ tmp_size = H5S_GET_EXTENT_NPOINTS(dset->shared->space) * H5T_get_size(dset->shared->type); - H5_ASSIGN_OVERFLOW(dset->shared->layout.store.u.compact.size, tmp_size, hssize_t, size_t); + H5_ASSIGN_OVERFLOW(dset->shared->layout.storage.u.compact.size, tmp_size, hssize_t, size_t); /* Verify data size is smaller than maximum header message size * (64KB) minus other layout message fields. */ max_comp_data_size = H5O_MESG_MAX_SIZE - H5D_layout_meta_size(f, &(dset->shared->layout), FALSE); - if(dset->shared->layout.store.u.compact.size > max_comp_data_size) + if(dset->shared->layout.storage.u.compact.size > max_comp_data_size) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "compact dataset size is bigger than header message maximum size") done: @@ -244,8 +244,8 @@ H5D_compact_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t UNUSED * { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_compact_io_init) - io_info->store->compact.buf = io_info->dset->shared->layout.store.u.compact.buf; - io_info->store->compact.dirty = &io_info->dset->shared->layout.store.u.compact.dirty; + io_info->store->compact.buf = io_info->dset->shared->layout.storage.u.compact.buf; + io_info->store->compact.dirty = &io_info->dset->shared->layout.storage.u.compact.dirty; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D_compact_io_init() */ @@ -356,10 +356,10 @@ H5D_compact_flush(H5D_t *dset, hid_t dxpl_id, unsigned UNUSED flags) HDassert(dset); /* Check if the buffered compact information is dirty */ - if(dset->shared->layout.store.u.compact.dirty) { + if(dset->shared->layout.storage.u.compact.dirty) { if(H5O_msg_write(&(dset->oloc), H5O_LAYOUT_ID, 0, H5O_UPDATE_TIME, &(dset->shared->layout), dxpl_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update layout message") - dset->shared->layout.store.u.compact.dirty = FALSE; + dset->shared->layout.storage.u.compact.dirty = FALSE; } /* end if */ done: @@ -449,7 +449,7 @@ H5D_compact_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst, max_dt_size = MAX(max_dt_size, tmp_dt_size); /* Set number of whole elements that fit in buffer */ - if(0 == (nelmts = layout_src->store.u.compact.size / src_dt_size)) + if(0 == (nelmts = layout_src->storage.u.compact.size / src_dt_size)) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "element size too large") /* Set up number of bytes to copy, and initial buffer size */ @@ -476,7 +476,7 @@ H5D_compact_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst, if(NULL == (buf = H5FL_BLK_MALLOC(type_conv, buf_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - HDmemcpy(buf, layout_src->store.u.compact.buf, layout_src->store.u.compact.size); + HDmemcpy(buf, layout_src->storage.u.compact.buf, layout_src->storage.u.compact.size); /* Convert from source file to memory */ if(H5T_convert(tpath_src_mem, tid_src, tid_mem, nelmts, (size_t)0, (size_t)0, buf, NULL, dxpl_id) < 0) @@ -492,7 +492,7 @@ H5D_compact_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst, if(H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, bkg, dxpl_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed") - HDmemcpy(layout_dst->store.u.compact.buf, buf, layout_dst->store.u.compact.size); + HDmemcpy(layout_dst->storage.u.compact.buf, buf, layout_dst->storage.u.compact.size); if(H5D_vlen_reclaim(tid_mem, buf_space, H5P_DATASET_XFER_DEFAULT, reclaim_buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to reclaim variable-length data") @@ -504,24 +504,24 @@ H5D_compact_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst, size_t ref_count; /* Determine # of reference elements to copy */ - ref_count = layout_src->store.u.compact.size / H5T_get_size(dt_src); + ref_count = layout_src->storage.u.compact.size / H5T_get_size(dt_src); /* Copy objects referenced in source buffer to destination file and set destination elements */ - if(H5O_copy_expand_ref(f_src, layout_src->store.u.compact.buf, dxpl_id, f_dst, - layout_dst->store.u.compact.buf, ref_count, H5T_get_ref_type(dt_src), cpy_info) < 0) + if(H5O_copy_expand_ref(f_src, layout_src->storage.u.compact.buf, dxpl_id, f_dst, + layout_dst->storage.u.compact.buf, ref_count, H5T_get_ref_type(dt_src), cpy_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy reference attribute") } /* end if */ else /* Reset value to zero */ - HDmemset(layout_dst->store.u.compact.buf, 0, layout_src->store.u.compact.size); + HDmemset(layout_dst->storage.u.compact.buf, 0, layout_src->storage.u.compact.size); } /* end if */ else /* Type conversion not necessary */ - HDmemcpy(layout_dst->store.u.compact.buf, layout_src->store.u.compact.buf, layout_src->store.u.compact.size); + HDmemcpy(layout_dst->storage.u.compact.buf, layout_src->storage.u.compact.buf, layout_src->storage.u.compact.size); } /* end if */ else /* Type conversion not necessary */ - HDmemcpy(layout_dst->store.u.compact.buf, layout_src->store.u.compact.buf, layout_src->store.u.compact.size); + HDmemcpy(layout_dst->storage.u.compact.buf, layout_src->storage.u.compact.buf, layout_src->storage.u.compact.size); done: if(buf_sid > 0 && H5I_dec_ref(buf_sid, FALSE) < 0) diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c index 66427a3..62b63a5 100644 --- a/src/H5Dcontig.c +++ b/src/H5Dcontig.c @@ -132,7 +132,7 @@ H5D_contig_alloc(H5F_t *f, hid_t dxpl_id, H5O_layout_t *layout /*out */ ) HDassert(layout); /* Allocate space for the contiguous data */ - if(HADDR_UNDEF == (layout->store.u.contig.addr = H5MF_alloc(f, H5FD_MEM_DRAW, dxpl_id, layout->store.u.contig.size))) + if(HADDR_UNDEF == (layout->storage.u.contig.addr = H5MF_alloc(f, H5FD_MEM_DRAW, dxpl_id, layout->storage.u.contig.size))) HGOTO_ERROR(H5E_IO, H5E_NOSPACE, FAIL, "unable to reserve file space") done: @@ -179,8 +179,8 @@ H5D_contig_fill(H5D_t *dset, hid_t dxpl_id) /* Check args */ HDassert(TRUE == H5P_isa_class(dxpl_id, H5P_DATASET_XFER)); HDassert(dset && H5D_CONTIGUOUS == dset->shared->layout.type); - HDassert(H5F_addr_defined(dset->shared->layout.store.u.contig.addr)); - HDassert(dset->shared->layout.store.u.contig.size > 0); + HDassert(H5F_addr_defined(dset->shared->layout.storage.u.contig.addr)); + HDassert(dset->shared->layout.storage.u.contig.size > 0); HDassert(dset->shared->space); HDassert(dset->shared->type); @@ -214,8 +214,8 @@ H5D_contig_fill(H5D_t *dset, hid_t dxpl_id) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't fill dxpl cache") /* Initialize storage info for this dataset */ - store.contig.dset_addr = dset->shared->layout.store.u.contig.addr; - store.contig.dset_size = dset->shared->layout.store.u.contig.size; + store.contig.dset_addr = dset->shared->layout.storage.u.contig.addr; + store.contig.dset_size = dset->shared->layout.storage.u.contig.size; /* Get the number of elements in the dataset's dataspace */ snpoints = H5S_GET_EXTENT_NPOINTS(dset->shared->space); @@ -317,7 +317,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D_contig_delete(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout) +H5D_contig_delete(H5F_t *f, hid_t dxpl_id, const H5O_storage_t *storage) { herr_t ret_value = SUCCEED; /* Return value */ @@ -325,11 +325,11 @@ H5D_contig_delete(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout) /* check args */ HDassert(f); - HDassert(layout); + HDassert(storage); /* Free the file space for the chunk */ - if(H5MF_xfree(f, H5FD_MEM_DRAW, dxpl_id, layout->store.u.contig.addr, layout->store.u.contig.size) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free object header") + if(H5MF_xfree(f, H5FD_MEM_DRAW, dxpl_id, storage->u.contig.addr, storage->u.contig.size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to free contiguous storage space") done: FUNC_LEAVE_NOAPI(ret_value) @@ -357,7 +357,7 @@ H5D_contig_get_addr(const H5D_t *dset) HDassert(dset); HDassert(dset->shared->layout.type == H5D_CONTIGUOUS); - FUNC_LEAVE_NOAPI(dset->shared->layout.store.u.contig.addr) + FUNC_LEAVE_NOAPI(dset->shared->layout.storage.u.contig.addr) } /* end H5D_contig_get_addr() */ @@ -423,7 +423,7 @@ H5D_contig_construct(H5F_t *f, H5D_t *dset) HGOTO_ERROR(H5E_DATASET, H5E_OVERFLOW, FAIL, "size of dataset's storage overflowed") /* Assign the dataset's contiguous storage size */ - dset->shared->layout.store.u.contig.size = tmp_size; + dset->shared->layout.storage.u.contig.size = tmp_size; /* Get the sieve buffer size for this dataset */ dset->shared->cache.contig.sieve_buf_size = H5F_SIEVE_BUF_SIZE(f); @@ -456,7 +456,7 @@ H5D_contig_is_space_alloc(const H5O_layout_t *layout) HDassert(layout); /* Set return value */ - ret_value = (hbool_t)H5F_addr_defined(layout->store.u.contig.addr); + ret_value = (hbool_t)H5F_addr_defined(layout->storage.u.contig.addr); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_contig_is_space_alloc() */ @@ -481,8 +481,8 @@ H5D_contig_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t UNUSED *t { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_contig_io_init) - io_info->store->contig.dset_addr = io_info->dset->shared->layout.store.u.contig.addr; - io_info->store->contig.dset_size = io_info->dset->shared->layout.store.u.contig.size; + io_info->store->contig.dset_addr = io_info->dset->shared->layout.storage.u.contig.addr; + io_info->store->contig.dset_size = io_info->dset->shared->layout.storage.u.contig.size; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D_contig_io_init() */ @@ -1267,7 +1267,7 @@ H5D_contig_copy(H5F_t *f_src, const H5O_layout_t *layout_src, H5F_t *f_dst, /* Set up number of bytes to copy, and initial buffer size */ /* (actually use the destination size, which has been fixed up, if necessary) */ - total_src_nbytes = layout_dst->store.u.contig.size; + total_src_nbytes = layout_dst->storage.u.contig.size; H5_CHECK_OVERFLOW(total_src_nbytes, hsize_t, size_t); buf_size = MIN(H5D_TEMP_BUF_SIZE, (size_t)total_src_nbytes); @@ -1365,8 +1365,8 @@ H5D_contig_copy(H5F_t *f_src, const H5O_layout_t *layout_src, H5F_t *f_dst, } /* end if */ /* Loop over copying data */ - addr_src = layout_src->store.u.contig.addr; - addr_dst = layout_dst->store.u.contig.addr; + addr_src = layout_src->storage.u.contig.addr; + addr_dst = layout_dst->storage.u.contig.addr; while(total_src_nbytes > 0) { /* Check if we should reduce the number of bytes to transfer */ if(total_src_nbytes < src_nbytes) { diff --git a/src/H5Ddbg.c b/src/H5Ddbg.c index a7e7fa9..fa4c54c 100644 --- a/src/H5Ddbg.c +++ b/src/H5Ddbg.c @@ -115,7 +115,7 @@ H5Ddebug(hid_t dset_id) if(H5D_CHUNKED == dset->shared->layout.type) (void)H5D_chunk_dump_index(dset, H5AC_dxpl_id, stdout); else if(H5D_CONTIGUOUS == dset->shared->layout.type) - HDfprintf(stdout, " %-10s %a\n", "Address:", dset->shared->layout.store.u.contig.addr); + HDfprintf(stdout, " %-10s %a\n", "Address:", dset->shared->layout.storage.u.contig.addr); done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Defl.c b/src/H5Defl.c index c884fd0..af57eff 100644 --- a/src/H5Defl.c +++ b/src/H5Defl.c @@ -159,7 +159,7 @@ H5D_efl_construct(H5F_t *f, H5D_t *dset) /* Compute the total size of dataset */ tmp_size = H5S_GET_EXTENT_NPOINTS(dset->shared->space) * dt_size; - H5_ASSIGN_OVERFLOW(dset->shared->layout.store.u.contig.size, tmp_size, hssize_t, hsize_t); + H5_ASSIGN_OVERFLOW(dset->shared->layout.storage.u.contig.size, tmp_size, hssize_t, hsize_t); /* Get the sieve buffer size for this dataset */ dset->shared->cache.contig.sieve_buf_size = H5F_SIEVE_BUF_SIZE(f); diff --git a/src/H5Dint.c b/src/H5Dint.c index c8a75b1..bfa4d02 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -784,7 +784,7 @@ H5D_update_oh_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, hid_t dapl_id) /* Add the dataset's raw data size to the size of the header, if the raw data will be stored as compact */ if(layout->type == H5D_COMPACT) - ohdr_size += layout->store.u.compact.size; + ohdr_size += layout->storage.u.compact.size; /* Create an object header for the dataset */ if(H5O_create(file, dxpl_id, ohdr_size, dset->shared->dcpl_id, oloc/*out*/) < 0) @@ -1403,7 +1403,7 @@ H5D_close(H5D_t *dataset) case H5D_COMPACT: /* Free the buffer for the raw data for compact datasets */ - dataset->shared->layout.store.u.compact.buf = H5MM_xfree(dataset->shared->layout.store.u.compact.buf); + dataset->shared->layout.storage.u.compact.buf = H5MM_xfree(dataset->shared->layout.storage.u.compact.buf); break; default: @@ -1617,14 +1617,14 @@ H5D_alloc_storage(H5D_t *dset/*in,out*/, hid_t dxpl_id, H5D_time_alloc_t time_al case H5D_COMPACT: /* Check if space is already allocated */ - if(NULL == layout->store.u.compact.buf) { + if(NULL == layout->storage.u.compact.buf) { /* Reserve space in layout header message for the entire array. */ - HDassert(layout->store.u.compact.size > 0); - if(NULL == (layout->store.u.compact.buf = H5MM_malloc(layout->store.u.compact.size))) + HDassert(layout->storage.u.compact.size > 0); + if(NULL == (layout->storage.u.compact.buf = H5MM_malloc(layout->storage.u.compact.size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory for compact dataset") if(!full_overwrite) - HDmemset(layout->store.u.compact.buf, 0, layout->store.u.compact.size); - layout->store.u.compact.dirty = TRUE; + HDmemset(layout->storage.u.compact.buf, 0, layout->storage.u.compact.size); + layout->storage.u.compact.dirty = TRUE; /* Indicate that we should initialize storage space */ must_init_space = TRUE; @@ -1784,13 +1784,13 @@ H5D_get_storage_size(H5D_t *dset, hid_t dxpl_id) case H5D_CONTIGUOUS: /* Datasets which are not allocated yet are using no space on disk */ if((*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout)) - ret_value = dset->shared->layout.store.u.contig.size; + ret_value = dset->shared->layout.storage.u.contig.size; else ret_value = 0; break; case H5D_COMPACT: - ret_value = dset->shared->layout.store.u.compact.size; + ret_value = dset->shared->layout.storage.u.compact.size; break; default: @@ -1834,9 +1834,9 @@ H5D_get_offset(const H5D_t *dset) case H5D_CONTIGUOUS: /* If dataspace hasn't been allocated or dataset is stored in * an external file, the value will be HADDR_UNDEF. */ - if(dset->shared->dcpl_cache.efl.nused == 0 || H5F_addr_defined(dset->shared->layout.store.u.contig.addr)) + if(dset->shared->dcpl_cache.efl.nused == 0 || H5F_addr_defined(dset->shared->layout.storage.u.contig.addr)) /* Return the absolute dataset offset from the beginning of file. */ - ret_value = dset->shared->layout.store.u.contig.addr + H5F_BASE_ADDR(dset->oloc.file); + ret_value = dset->shared->layout.storage.u.contig.addr + H5F_BASE_ADDR(dset->oloc.file); break; default: diff --git a/src/H5Dlayout.c b/src/H5Dlayout.c index 6e7686b..8e139ae 100644 --- a/src/H5Dlayout.c +++ b/src/H5Dlayout.c @@ -96,8 +96,8 @@ H5D_layout_set_io_ops(const H5D_t *dataset) dataset->shared->layout.ops = H5D_LOPS_CHUNK; /* Set the chunk operations */ - /* (Only "B-tree" indexing type currently supported */ - dataset->shared->layout.u.chunk.ops = H5D_COPS_BTREE; + /* (Only "B-tree" indexing type currently supported) */ + dataset->shared->layout.storage.u.chunk.ops = H5D_COPS_BTREE; break; case H5D_COMPACT: @@ -147,7 +147,7 @@ H5D_layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t include /* Size of raw data */ ret_value += 2; if(include_compact_data) - ret_value += layout->store.u.compact.size;/* data for compact dataset */ + ret_value += layout->storage.u.compact.size;/* data for compact dataset */ break; case H5D_CONTIGUOUS: @@ -407,7 +407,7 @@ H5D_layout_oh_read(H5D_t *dataset, hid_t dxpl_id, hid_t dapl_id, H5P_genplist_t HGOTO_ERROR(H5E_DATASET, H5E_OVERFLOW, FAIL, "size of dataset's storage overflowed") /* Assign the dataset's contiguous storage size */ - dataset->shared->layout.store.u.contig.size = tmp_size; + dataset->shared->layout.storage.u.contig.size = tmp_size; } /* end if */ /* Get the sieve buffer size for this dataset */ diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index b77c391..de7d568 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -221,7 +221,8 @@ typedef struct H5D_chk_idx_info_t { H5F_t *f; /* File pointer for operation */ hid_t dxpl_id; /* DXPL ID for operation */ const H5O_pline_t *pline; /* I/O pipeline info */ - H5O_layout_t *layout; /* Layout info for chunks */ + H5O_layout_chunk_t *layout; /* Chunk layout description */ + H5O_storage_chunk_t *storage; /* Chunk storage description */ } H5D_chk_idx_info_t; /* @@ -237,7 +238,7 @@ typedef struct H5D_chk_idx_info_t { */ typedef struct H5D_chunk_rec_t { uint32_t nbytes; /* Size of stored data */ - hsize_t offset[H5O_LAYOUT_NDIMS]; /* Logical offset to start*/ + hsize_t offset[H5O_LAYOUT_NDIMS]; /* Logical offset to start */ unsigned filter_mask; /* Excluded filters */ haddr_t chunk_addr; /* Address of chunk in file */ } H5D_chunk_rec_t; @@ -249,8 +250,9 @@ typedef struct H5D_chunk_rec_t { */ typedef struct H5D_chunk_common_ud_t { /* downward */ - const H5O_layout_t *mesg; /*layout message */ - const hsize_t *offset; /*logical offset of chunk*/ + const H5O_layout_chunk_t *layout; /* Chunk layout description */ + const H5O_storage_chunk_t *storage; /* Chunk storage description */ + const hsize_t *offset; /* Logical offset of chunk */ } H5D_chunk_common_ud_t; /* B-tree callback info for various operations */ @@ -271,12 +273,12 @@ typedef int (*H5D_chunk_cb_func_t)(const H5D_chunk_rec_t *chunk_rec, typedef herr_t (*H5D_chunk_init_func_t)(const H5D_chk_idx_info_t *idx_info, const H5S_t *space, haddr_t dset_ohdr_addr); typedef herr_t (*H5D_chunk_create_func_t)(const H5D_chk_idx_info_t *idx_info); -typedef hbool_t (*H5D_chunk_is_space_alloc_func_t)(const H5O_layout_t *layout); +typedef hbool_t (*H5D_chunk_is_space_alloc_func_t)(const H5O_storage_chunk_t *storage); typedef herr_t (*H5D_chunk_insert_func_t)(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata); typedef herr_t (*H5D_chunk_get_addr_func_t)(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata); -typedef herr_t (*H5D_chunk_resize_func_t)(H5O_layout_t *layout); +typedef herr_t (*H5D_chunk_resize_func_t)(H5O_layout_chunk_t *layout); typedef int (*H5D_chunk_iterate_func_t)(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, void *chunk_udata); typedef herr_t (*H5D_chunk_remove_func_t)(const H5D_chk_idx_info_t *idx_info, @@ -284,12 +286,12 @@ typedef herr_t (*H5D_chunk_remove_func_t)(const H5D_chk_idx_info_t *idx_info, typedef herr_t (*H5D_chunk_delete_func_t)(const H5D_chk_idx_info_t *idx_info); typedef herr_t (*H5D_chunk_copy_setup_func_t)(const H5D_chk_idx_info_t *idx_info_src, const H5D_chk_idx_info_t *idx_info_dst); -typedef herr_t (*H5D_chunk_copy_shutdown_func_t)(H5O_layout_t *layout_src, - H5O_layout_t *layout_dst, hid_t dxpl_id); +typedef herr_t (*H5D_chunk_copy_shutdown_func_t)(H5O_storage_chunk_t *storage_src, + H5O_storage_chunk_t *storage_dst, hid_t dxpl_id); typedef herr_t (*H5D_chunk_size_func_t)(const H5D_chk_idx_info_t *idx_info, hsize_t *idx_size); -typedef herr_t (*H5D_chunk_reset_func_t)(H5O_layout_t *layout, hbool_t reset_addr); -typedef herr_t (*H5D_chunk_dump_func_t)(const H5D_chk_idx_info_t *idx_info, +typedef herr_t (*H5D_chunk_reset_func_t)(H5O_storage_chunk_t *storage, hbool_t reset_addr); +typedef herr_t (*H5D_chunk_dump_func_t)(const H5O_storage_chunk_t *storage, FILE *stream); typedef herr_t (*H5D_chunk_dest_func_t)(const H5D_chk_idx_info_t *idx_info); diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index ad9c795..277b87a 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -163,12 +163,12 @@ H5_DLL herr_t H5D_vlen_reclaim(hid_t type_id, H5S_t *space, hid_t plist_id, /* Functions that operate on contiguous storage */ H5_DLL herr_t H5D_contig_delete(H5F_t *f, hid_t dxpl_id, - const H5O_layout_t *layout); + const H5O_storage_t *store); /* Functions that operate on chunked storage */ -H5_DLL herr_t H5D_chunk_idx_reset(H5O_layout_t *layout, hbool_t reset_addr); +H5_DLL herr_t H5D_chunk_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr); H5_DLL herr_t H5D_chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh, - H5O_layout_t *layout); + H5O_storage_t *store); /* Functions that operate on indexed storage */ H5_DLL herr_t H5D_btree_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, diff --git a/src/H5Dtest.c b/src/H5Dtest.c index 79568fe..a4537ae 100644 --- a/src/H5Dtest.c +++ b/src/H5Dtest.c @@ -128,7 +128,7 @@ H5D_layout_contig_size_test(hid_t did, hsize_t *size) if(size) { HDassert(dset->shared->layout.type == H5D_CONTIGUOUS); - *size = dset->shared->layout.store.u.contig.size; + *size = dset->shared->layout.storage.u.contig.size; } /* end if */ done: diff --git a/src/H5Olayout.c b/src/H5Olayout.c index 919dceb..b8a56f7 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -131,21 +131,21 @@ H5O_layout_decode(H5F_t *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh, /* Address */ if(mesg->type == H5D_CONTIGUOUS) { - H5F_addr_decode(f, &p, &(mesg->store.u.contig.addr)); + H5F_addr_decode(f, &p, &(mesg->storage.u.contig.addr)); /* Set the layout operations */ mesg->ops = H5D_LOPS_CONTIG; } /* end if */ else if(mesg->type == H5D_CHUNKED) { - H5F_addr_decode(f, &p, &(mesg->store.u.chunk.idx_addr)); + H5F_addr_decode(f, &p, &(mesg->storage.u.chunk.idx_addr)); /* Set the layout operations */ mesg->ops = H5D_LOPS_CHUNK; /* Set the chunk operations */ /* (Only "btree" indexing type currently supported in this version) */ - mesg->u.chunk.idx_type = H5D_CHUNK_BTREE; - mesg->u.chunk.ops = H5D_COPS_BTREE; + mesg->storage.u.chunk.idx_type = H5D_CHUNK_BTREE; + mesg->storage.u.chunk.ops = H5D_COPS_BTREE; } /* end if */ else { /* Sanity check */ @@ -176,12 +176,12 @@ H5O_layout_decode(H5F_t *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh, } /* end if */ if(mesg->type == H5D_COMPACT) { - UINT32DECODE(p, mesg->store.u.compact.size); - if(mesg->store.u.compact.size > 0) { - if(NULL == (mesg->store.u.compact.buf = H5MM_malloc(mesg->store.u.compact.size))) + UINT32DECODE(p, mesg->storage.u.compact.size); + if(mesg->storage.u.compact.size > 0) { + if(NULL == (mesg->storage.u.compact.buf = H5MM_malloc(mesg->storage.u.compact.size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for compact data buffer") - HDmemcpy(mesg->store.u.compact.buf, p, mesg->store.u.compact.size); - p += mesg->store.u.compact.size; + HDmemcpy(mesg->storage.u.compact.buf, p, mesg->storage.u.compact.size); + p += mesg->storage.u.compact.size; } /* end if */ } /* end if */ } /* end if */ @@ -192,12 +192,12 @@ H5O_layout_decode(H5F_t *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh, /* Interpret the rest of the message according to the layout class */ switch(mesg->type) { case H5D_COMPACT: - UINT16DECODE(p, mesg->store.u.compact.size); - if(mesg->store.u.compact.size > 0) { - if(NULL == (mesg->store.u.compact.buf = H5MM_malloc(mesg->store.u.compact.size))) + UINT16DECODE(p, mesg->storage.u.compact.size); + if(mesg->storage.u.compact.size > 0) { + if(NULL == (mesg->storage.u.compact.buf = H5MM_malloc(mesg->storage.u.compact.size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for compact data buffer") - HDmemcpy(mesg->store.u.compact.buf, p, mesg->store.u.compact.size); - p += mesg->store.u.compact.size; + HDmemcpy(mesg->storage.u.compact.buf, p, mesg->storage.u.compact.size); + p += mesg->storage.u.compact.size; } /* end if */ /* Set the layout operations */ @@ -205,8 +205,8 @@ H5O_layout_decode(H5F_t *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh, break; case H5D_CONTIGUOUS: - H5F_addr_decode(f, &p, &(mesg->store.u.contig.addr)); - H5F_DECODE_LENGTH(f, p, mesg->store.u.contig.size); + H5F_addr_decode(f, &p, &(mesg->storage.u.contig.addr)); + H5F_DECODE_LENGTH(f, p, mesg->storage.u.contig.size); /* Set the layout operations */ mesg->ops = H5D_LOPS_CONTIG; @@ -219,7 +219,7 @@ H5O_layout_decode(H5F_t *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh, HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "dimensionality is too large") /* B-tree address */ - H5F_addr_decode(f, &p, &(mesg->store.u.chunk.idx_addr)); + H5F_addr_decode(f, &p, &(mesg->storage.u.chunk.idx_addr)); /* Chunk dimensions */ for(u = 0; u < mesg->u.chunk.ndims; u++) @@ -231,8 +231,8 @@ H5O_layout_decode(H5F_t *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh, /* Set the chunk operations */ /* (Only "btree" indexing type supported with v3 of message format) */ - mesg->u.chunk.idx_type = H5D_CHUNK_BTREE; - mesg->u.chunk.ops = H5D_COPS_BTREE; + mesg->storage.u.chunk.idx_type = H5D_CHUNK_BTREE; + mesg->storage.u.chunk.ops = H5D_COPS_BTREE; /* Set the layout operations */ mesg->ops = H5D_LOPS_CHUNK; @@ -309,21 +309,21 @@ H5O_layout_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const voi switch(mesg->type) { case H5D_COMPACT: /* Size of raw data */ - UINT16ENCODE(p, mesg->store.u.compact.size); + UINT16ENCODE(p, mesg->storage.u.compact.size); /* Raw data */ - if(mesg->store.u.compact.size > 0) { - if(mesg->store.u.compact.buf) - HDmemcpy(p, mesg->store.u.compact.buf, mesg->store.u.compact.size); + if(mesg->storage.u.compact.size > 0) { + if(mesg->storage.u.compact.buf) + HDmemcpy(p, mesg->storage.u.compact.buf, mesg->storage.u.compact.size); else - HDmemset(p, 0, mesg->store.u.compact.size); - p += mesg->store.u.compact.size; + HDmemset(p, 0, mesg->storage.u.compact.size); + p += mesg->storage.u.compact.size; } /* end if */ break; case H5D_CONTIGUOUS: - H5F_addr_encode(f, &p, mesg->store.u.contig.addr); - H5F_ENCODE_LENGTH(f, p, mesg->store.u.contig.size); + H5F_addr_encode(f, &p, mesg->storage.u.contig.addr); + H5F_ENCODE_LENGTH(f, p, mesg->storage.u.contig.size); break; case H5D_CHUNKED: @@ -332,7 +332,7 @@ H5O_layout_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const voi *p++ = (uint8_t)mesg->u.chunk.ndims; /* B-tree address */ - H5F_addr_encode(f, &p, mesg->store.u.chunk.idx_addr); + H5F_addr_encode(f, &p, mesg->storage.u.chunk.idx_addr); /* Dimension sizes */ for(u = 0; u < mesg->u.chunk.ndims; u++) @@ -381,18 +381,18 @@ H5O_layout_copy(const void *_mesg, void *_dest) *dest = *mesg; /* Deep copy the buffer for compact datasets also */ - if(mesg->type == H5D_COMPACT && mesg->store.u.compact.size > 0) { + if(mesg->type == H5D_COMPACT && mesg->storage.u.compact.size > 0) { /* Allocate memory for the raw data */ - if(NULL == (dest->store.u.compact.buf = H5MM_malloc(dest->store.u.compact.size))) + if(NULL == (dest->storage.u.compact.buf = H5MM_malloc(dest->storage.u.compact.size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate memory for compact dataset") /* Copy over the raw data */ - HDmemcpy(dest->store.u.compact.buf, mesg->store.u.compact.buf, dest->store.u.compact.size); + HDmemcpy(dest->storage.u.compact.buf, mesg->storage.u.compact.buf, dest->storage.u.compact.size); } /* end if */ /* Reset the pointer of the chunked storage index but not the address */ - if(dest->type == H5D_CHUNKED && dest->u.chunk.ops) - H5D_chunk_idx_reset(dest, FALSE); + if(dest->type == H5D_CHUNKED && dest->storage.u.chunk.ops) + H5D_chunk_idx_reset(&dest->storage.u.chunk, FALSE); /* Set return value */ ret_value = dest; @@ -461,7 +461,7 @@ H5O_layout_reset(void *_mesg) if(mesg) { /* Free the compact storage buffer */ if(H5D_COMPACT == mesg->type) - mesg->store.u.compact.buf = H5MM_xfree(mesg->store.u.compact.buf); + mesg->storage.u.compact.buf = H5MM_xfree(mesg->storage.u.compact.buf); /* Reset the message */ mesg->type = H5D_CONTIGUOUS; @@ -481,26 +481,26 @@ H5O_layout_reset(void *_mesg) * Programmer: Quincey Koziol * Saturday, March 11, 2000 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t H5O_layout_free(void *_mesg) { H5O_layout_t *mesg = (H5O_layout_t *) _mesg; + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_layout_free) + FUNC_ENTER_NOAPI_NOINIT(H5O_layout_free) HDassert(mesg); - /* Free the compact storage buffer */ - if(H5D_COMPACT == mesg->type) - mesg->store.u.compact.buf = H5MM_xfree(mesg->store.u.compact.buf); + /* Free resources within the message */ + if(H5O_layout_reset(mesg) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free message resources") (void)H5FL_FREE(H5O_layout_t, mesg); - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_layout_free() */ @@ -514,8 +514,6 @@ H5O_layout_free(void *_mesg) * Programmer: Quincey Koziol * Wednesday, March 19, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -539,13 +537,13 @@ H5O_layout_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, void *_mesg) case H5D_CONTIGUOUS: /* Contiguous block on disk */ /* Free the file space for the raw data */ - if(H5D_contig_delete(f, dxpl_id, mesg) < 0) + if(H5D_contig_delete(f, dxpl_id, &mesg->storage) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free raw data") break; case H5D_CHUNKED: /* Chunked blocks on disk */ /* Free the file space for the index & chunk raw data */ - if(H5D_chunk_delete(f, dxpl_id, open_oh, mesg) < 0) + if(H5D_chunk_delete(f, dxpl_id, open_oh, &mesg->storage) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free raw data") break; @@ -598,15 +596,15 @@ H5O_layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, /* Copy the layout type specific information */ switch(layout_src->type) { case H5D_COMPACT: - if(layout_src->store.u.compact.buf) { - if(NULL == (layout_dst->store.u.compact.buf = H5MM_malloc(layout_src->store.u.compact.size))) + if(layout_src->storage.u.compact.buf) { + if(NULL == (layout_dst->storage.u.compact.buf = H5MM_malloc(layout_src->storage.u.compact.size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate memory for compact dataset") /* copy compact raw data */ if(H5D_compact_copy(file_src, layout_src, file_dst, layout_dst, udata->src_dtype, cpy_info, dxpl_id) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, "unable to copy chunked storage") - layout_dst->store.u.compact.dirty = TRUE; + layout_dst->storage.u.compact.dirty = TRUE; } /* end if */ break; @@ -616,10 +614,10 @@ H5O_layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, * truncate the dimension sizes to 32-bits of information. - QAK 5/26/04 */ if(layout_src->version < 3) - layout_dst->store.u.contig.size = H5S_extent_nelem(udata->src_space_extent) * + layout_dst->storage.u.contig.size = H5S_extent_nelem(udata->src_space_extent) * H5T_get_size(udata->src_dtype); - if(H5F_addr_defined(layout_src->store.u.contig.addr)) { + if(H5F_addr_defined(layout_src->storage.u.contig.addr)) { /* create contig layout */ if(H5D_contig_copy(file_src, layout_src, file_dst, layout_dst, udata->src_dtype, cpy_info, dxpl_id) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, "unable to copy contiguous storage") @@ -700,17 +698,17 @@ H5O_layout_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, HDfprintf(stream, "}\n"); /* Index information */ - switch(mesg->u.chunk.idx_type) { + switch(mesg->storage.u.chunk.idx_type) { case H5D_CHUNK_BTREE: HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Index Type:", "v1 B-tree"); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "B-tree address:", mesg->store.u.chunk.idx_addr); + "B-tree address:", mesg->storage.u.chunk.idx_addr); break; default: HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, - "Index Type:", "Unknown", (unsigned)mesg->u.chunk.idx_type); + "Index Type:", "Unknown", (unsigned)mesg->storage.u.chunk.idx_type); break; } /* end switch */ break; @@ -719,16 +717,16 @@ H5O_layout_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Type:", "Contiguous"); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, - "Data address:", mesg->store.u.contig.addr); + "Data address:", mesg->storage.u.contig.addr); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, - "Data Size:", mesg->store.u.contig.size); + "Data Size:", mesg->storage.u.contig.size); break; case H5D_COMPACT: HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Type:", "Compact"); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, - "Data Size:", mesg->store.u.compact.size); + "Data Size:", mesg->storage.u.compact.size); break; default: diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index d6b3cd0..6aa9c5d 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -358,8 +358,17 @@ typedef struct H5O_storage_contig_t { hsize_t size; /* Size of data in bytes */ } H5O_storage_contig_t; +typedef struct H5O_storage_chunk_btree_t { + H5RC_t *shared; /* Ref-counted shared info for B-tree nodes */ +} H5O_storage_chunk_btree_t; + typedef struct H5O_storage_chunk_t { + H5D_chunk_index_t idx_type; /* Type of chunk index */ haddr_t idx_addr; /* File address of chunk index */ + const struct H5D_chunk_ops_t *ops; /* Pointer to chunked storage operations */ + union { + H5O_storage_chunk_btree_t btree; /* Information for v1 B-tree index */ + } u; } H5O_storage_chunk_t; typedef struct H5O_storage_compact_t { @@ -377,22 +386,13 @@ typedef struct H5O_storage_t { } u; } H5O_storage_t; -typedef struct H5O_layout_chunk_btree_t { - H5RC_t *shared; /* Ref-counted shared info for B-tree nodes */ -} H5O_layout_chunk_btree_t; - typedef struct H5O_layout_chunk_t { - H5D_chunk_index_t idx_type; /* Type of chunk index */ unsigned ndims; /* Num dimensions in chunk */ uint32_t dim[H5O_LAYOUT_NDIMS]; /* Size of chunk in elements */ uint32_t size; /* Size of chunk in bytes */ hsize_t nchunks; /* Number of chunks in dataset */ hsize_t chunks[H5O_LAYOUT_NDIMS]; /* # of chunks in dataset dimensions */ hsize_t down_chunks[H5O_LAYOUT_NDIMS]; /* "down" size of number of chunks in each dimension */ - const struct H5D_chunk_ops_t *ops; /* Pointer to chunked layout operations */ - union { - H5O_layout_chunk_btree_t btree; /* Information for v1 B-tree index */ - } u; } H5O_layout_chunk_t; typedef struct H5O_layout_t { @@ -402,7 +402,7 @@ typedef struct H5O_layout_t { union { H5O_layout_chunk_t chunk; /* Information for chunked layout */ } u; - H5O_storage_t store; /* Information for storing dataset elements */ + H5O_storage_t storage; /* Information for storing dataset elements */ } H5O_layout_t; /* Enable reading/writing "bogus" messages */ diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 92f2475..d8ff5db 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -50,8 +50,8 @@ /* Define default layout information */ #define H5D_DEF_STORAGE_COMPACT_INIT {(hbool_t)FALSE, (size_t)0, NULL} #define H5D_DEF_STORAGE_CONTIG_INIT {HADDR_UNDEF, (hsize_t)0} -#define H5D_DEF_STORAGE_CHUNK_INIT {HADDR_UNDEF} -#define H5D_DEF_LAYOUT_CHUNK_INIT {H5D_CHUNK_BTREE, (unsigned)1, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, (uint32_t)0, (hsize_t)0, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, NULL, {{NULL}}} +#define H5D_DEF_STORAGE_CHUNK_INIT {H5D_CHUNK_BTREE, HADDR_UNDEF, NULL, {{NULL}}} +#define H5D_DEF_LAYOUT_CHUNK_INIT {(unsigned)1, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, (uint32_t)0, (hsize_t)0, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}} #ifdef H5_HAVE_C99_DESIGNATED_INITIALIZER #define H5D_DEF_STORAGE_COMPACT {H5D_COMPACT, { .compact = H5D_DEF_STORAGE_COMPACT_INIT }} #define H5D_DEF_STORAGE_CONTIG {H5D_CONTIGUOUS, { .contig = H5D_DEF_STORAGE_CONTIG_INIT }} @@ -268,13 +268,13 @@ H5P_dcrt_copy(hid_t dst_plist_id, hid_t src_plist_id, void UNUSED *copy_data) dst_layout.ops = NULL; switch(dst_layout.type) { case H5D_COMPACT: - dst_layout.store.u.compact.buf = H5MM_xfree(dst_layout.store.u.compact.buf); - HDmemset(&dst_layout.store.u.compact, 0, sizeof(dst_layout.store.u.compact)); + dst_layout.storage.u.compact.buf = H5MM_xfree(dst_layout.storage.u.compact.buf); + HDmemset(&dst_layout.storage.u.compact, 0, sizeof(dst_layout.storage.u.compact)); break; case H5D_CONTIGUOUS: - dst_layout.store.u.contig.addr = HADDR_UNDEF; - dst_layout.store.u.contig.size = 0; + dst_layout.storage.u.contig.addr = HADDR_UNDEF; + dst_layout.storage.u.contig.size = 0; break; case H5D_CHUNKED: @@ -282,13 +282,13 @@ H5P_dcrt_copy(hid_t dst_plist_id, hid_t src_plist_id, void UNUSED *copy_data) dst_layout.u.chunk.size = 0; /* Reset index info, if the chunk ops are set */ - if(dst_layout.u.chunk.ops) + if(dst_layout.storage.u.chunk.ops) /* Reset address and pointer of the array struct for the chunked storage index */ - if(H5D_chunk_idx_reset(&dst_layout, TRUE) < 0) + if(H5D_chunk_idx_reset(&dst_layout.storage.u.chunk, TRUE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to reset chunked storage index in dest") /* Reset chunk index ops */ - dst_layout.u.chunk.ops = NULL; + dst_layout.storage.u.chunk.ops = NULL; break; default: @@ -775,9 +775,9 @@ H5P_init_def_layout(void) /* Initialize the default layout info for non-contigous layouts */ H5D_def_layout_compact_g.u.compact = def_layout_compact; - H5D_def_layout_compact_g.store.u.compact = def_store_compact; + H5D_def_layout_compact_g.storage.u.compact = def_store_compact; H5D_def_layout_chunk_g.u.chunk = def_chunk; - H5D_def_layout_compact_g.store.u.chunk = def_store_chunk; + H5D_def_layout_compact_g.storage.u.chunk = def_store_chunk; /* Note that we've initialized the default values */ H5P_dcrt_def_layout_init_g = TRUE; |