From 92b1407a53c1de3a1ec2fdc19fc3f40b6b8c2483 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Thu, 30 Jul 2009 22:36:04 -0500 Subject: [svn-r17282] Description: Bring r17281 from trunk to 1.8 branch: Further refactoring of the dataset layout information, to separate the storage information from the layout info. Tested on: Mac OS X/32 10.5.7 (amazon) debug & production h5committested on trunk --- src/H5Dchunk.c | 59 +++++++++++++++++++++++++++++--------------------------- src/H5Dcompact.c | 43 +++++++++++++++++++++++++---------------- src/H5Dcontig.c | 35 +++++++++++++++------------------ src/H5Dint.c | 14 +++++++------- src/H5Dio.c | 6 +++--- src/H5Doh.c | 2 +- src/H5Dpkg.h | 23 +++++++++++++--------- src/H5Dprivate.h | 7 +++++++ src/H5Odtype.c | 1 + src/H5Olayout.c | 31 +++++++++++++---------------- src/H5Opkg.h | 7 ------- src/H5Opline.c | 1 + src/H5Osdspace.c | 1 + src/H5Pdcpl.c | 2 +- 14 files changed, 122 insertions(+), 110 deletions(-) diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 4b19e73..4266e30 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -191,7 +191,7 @@ H5D_nonexistent_readvv(const H5D_io_info_t *io_info, size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[]); /* Helper routines */ -static herr_t H5D_chunk_set_info_real(H5O_layout_t *layout, unsigned ndims, +static herr_t H5D_chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims, const hsize_t *curr_dims); static void *H5D_chunk_alloc(size_t size, const H5O_pline_t *pline); static void *H5D_chunk_xfree(void *chk, const H5O_pline_t *pline); @@ -287,8 +287,8 @@ H5FL_DEFINE_STATIC(H5D_chunk_prune_stack_t); * *------------------------------------------------------------------------- */ -herr_t -H5D_chunk_set_info_real(H5O_layout_t *layout, unsigned ndims, const hsize_t *curr_dims) +static herr_t +H5D_chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims, const hsize_t *curr_dims) { unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -301,16 +301,16 @@ H5D_chunk_set_info_real(H5O_layout_t *layout, unsigned ndims, const hsize_t *cur HDassert(curr_dims); /* Compute the # of chunks in dataset dimensions */ - for(u = 0, layout->u.chunk.nchunks = 1; u < ndims; u++) { + for(u = 0, layout->nchunks = 1; u < ndims; u++) { /* Round up to the next integer # of chunks, to accomodate partial chunks */ - layout->u.chunk.chunks[u] = ((curr_dims[u] + layout->u.chunk.dim[u]) - 1) / layout->u.chunk.dim[u]; + layout->chunks[u] = ((curr_dims[u] + layout->dim[u]) - 1) / layout->dim[u]; /* Accumulate the # of chunks */ - layout->u.chunk.nchunks *= layout->u.chunk.chunks[u]; + layout->nchunks *= layout->chunks[u]; } /* end for */ /* Get the "down" sizes for each dimension */ - if(H5V_array_down(ndims, layout->u.chunk.chunks, layout->u.chunk.down_chunks) < 0) + if(H5V_array_down(ndims, layout->chunks, layout->down_chunks) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't compute 'down' chunk size value") done: @@ -349,7 +349,7 @@ H5D_chunk_set_info(const H5D_t *dset) H5_ASSIGN_OVERFLOW(ndims, sndims, int, unsigned); /* Set the base layout information */ - if(H5D_chunk_set_info_real(&dset->shared->layout, ndims, curr_dims) < 0) + if(H5D_chunk_set_info_real(&dset->shared->layout.u.chunk, ndims, curr_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set layout's chunk info") /* Call the index's "resize" callback */ @@ -532,17 +532,17 @@ done: *------------------------------------------------------------------------- */ hbool_t -H5D_chunk_is_space_alloc(const H5O_layout_t *layout) +H5D_chunk_is_space_alloc(const H5O_storage_t *storage) { hbool_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOFUNC(H5D_chunk_is_space_alloc) /* Sanity checks */ - HDassert(layout); + HDassert(storage); /* Query index layer */ - ret_value = (layout->storage.u.chunk.ops->is_space_alloc)(&layout->storage.u.chunk); + ret_value = (storage->u.chunk.ops->is_space_alloc)(&storage->u.chunk); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_chunk_is_space_alloc() */ @@ -4288,8 +4288,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D_chunk_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst, - H5O_layout_t *layout_dst, const H5S_extent_t *ds_extent_src, +H5D_chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, + H5O_layout_chunk_t *layout_src, H5F_t *f_dst, H5O_storage_chunk_t *storage_dst, + H5O_layout_chunk_t *layout_dst, const H5S_extent_t *ds_extent_src, const H5T_t *dt_src, const H5O_pline_t *pline_src, H5O_copy_t *cpy_info, hid_t dxpl_id) { @@ -4318,9 +4319,11 @@ H5D_chunk_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst, /* Check args */ HDassert(f_src); + HDassert(layout_src); + HDassert(storage_src); HDassert(f_dst); - HDassert(layout_src && H5D_CHUNKED == layout_src->type); - HDassert(layout_dst && H5D_CHUNKED == layout_dst->type); + HDassert(layout_dst); + HDassert(storage_dst); HDassert(ds_extent_src); HDassert(dt_src); @@ -4333,7 +4336,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->storage.u.chunk, TRUE) < 0) + if(H5D_chunk_idx_reset(storage_dst, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to reset chunked storage index in dest") /* Initialize layout information */ @@ -4360,17 +4363,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->u.chunk; - idx_info_src.storage = &layout_src->storage.u.chunk; + idx_info_src.layout = layout_src; + idx_info_src.storage = storage_src; 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->u.chunk; - idx_info_dst.storage = &layout_dst->storage.u.chunk; + idx_info_dst.layout = layout_dst; + idx_info_dst.storage = storage_dst; /* Call the index-specific "copy setup" routine */ - if((layout_src->storage.u.chunk.ops->copy_setup)(&idx_info_src, &idx_info_dst) < 0) + if((storage_src->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; @@ -4420,8 +4423,8 @@ H5D_chunk_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst, /* Compute the number of elements per chunk */ nelmts = 1; - for(u = 0; u < (layout_src->u.chunk.ndims - 1); u++) - nelmts *= layout_src->u.chunk.dim[u]; + for(u = 0; u < (layout_src->ndims - 1); u++) + nelmts *= layout_src->dim[u]; /* Create the space and set the initial extent */ buf_dim = nelmts; @@ -4451,7 +4454,7 @@ H5D_chunk_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst, do_convert = TRUE; } /* end if */ - H5_ASSIGN_OVERFLOW(buf_size, layout_src->u.chunk.size, uint32_t, size_t); + H5_ASSIGN_OVERFLOW(buf_size, layout_src->size, uint32_t, size_t); reclaim_buf_size = 0; } /* end else */ @@ -4474,8 +4477,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.layout = &layout_src->u.chunk; - udata.common.storage = &layout_src->storage.u.chunk; + udata.common.layout = layout_src; + udata.common.storage = storage_src; udata.file_src = f_src; udata.idx_info_dst = &idx_info_dst; udata.buf = buf; @@ -4496,7 +4499,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->storage.u.chunk.ops->iterate)(&idx_info_src, H5D_chunk_copy_cb, &udata) < 0) + if((storage_src->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 */ @@ -4524,7 +4527,7 @@ done: /* Clean up any index information */ if(copy_setup_done) - if((layout_src->storage.u.chunk.ops->copy_shutdown)(&layout_src->storage.u.chunk, &layout_dst->storage.u.chunk, dxpl_id) < 0) + if((storage_src->ops->copy_shutdown)(storage_src, storage_dst, dxpl_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to shut down index copying info") FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c index ae6a72e..831ab13 100644 --- a/src/H5Dcompact.c +++ b/src/H5Dcompact.c @@ -38,6 +38,7 @@ #include "H5FDprivate.h" /* File drivers */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ #include "H5Oprivate.h" /* Object headers */ #include "H5Vprivate.h" /* Vector and array functions */ @@ -58,7 +59,7 @@ /* Layout operation callbacks */ static herr_t H5D_compact_construct(H5F_t *f, H5D_t *dset); -static hbool_t H5D_compact_is_space_alloc(const H5O_layout_t *layout); +static hbool_t H5D_compact_is_space_alloc(const H5O_storage_t *storage); static herr_t H5D_compact_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t *cm); @@ -213,12 +214,12 @@ done: *------------------------------------------------------------------------- */ static hbool_t -H5D_compact_is_space_alloc(const H5O_layout_t UNUSED *layout) +H5D_compact_is_space_alloc(const H5O_storage_t UNUSED *storage) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_compact_is_space_alloc) /* Sanity checks */ - HDassert(layout); + HDassert(storage); /* Compact storage is currently always allocated */ FUNC_LEAVE_NOAPI(TRUE) @@ -380,8 +381,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D_compact_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst, - H5O_layout_t *layout_dst, H5T_t *dt_src, H5O_copy_t *cpy_info, hid_t dxpl_id) +H5D_compact_copy(H5F_t *f_src, H5O_storage_compact_t *storage_src, H5F_t *f_dst, + H5O_storage_compact_t *storage_dst, H5T_t *dt_src, H5O_copy_t *cpy_info, + hid_t dxpl_id) { hid_t tid_src = -1; /* Datatype ID for source datatype */ hid_t tid_dst = -1; /* Datatype ID for destination datatype */ @@ -395,15 +397,19 @@ H5D_compact_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst, FUNC_ENTER_NOAPI(H5D_compact_copy, FAIL) /* Check args */ - HDassert(layout_src && H5D_COMPACT == layout_src->type); HDassert(f_src); + HDassert(storage_src); HDassert(f_dst); - HDassert(layout_dst && H5D_COMPACT == layout_dst->type); + HDassert(storage_dst); HDassert(dt_src); + /* Allocate space for destination data */ + if(NULL == (storage_dst->buf = H5MM_malloc(storage_src->size))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate memory for compact dataset") + /* Create datatype ID for src datatype, so it gets freed */ if((tid_src = H5I_register(H5I_DATATYPE, dt_src, FALSE)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register source file datatype") + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register source file datatype") /* If there's a VLEN source datatype, do type conversion information */ if(H5T_detect_class(dt_src, H5T_VLEN) > 0) { @@ -449,7 +455,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->storage.u.compact.size / src_dt_size)) + if(0 == (nelmts = storage_src->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 +482,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->storage.u.compact.buf, layout_src->storage.u.compact.size); + HDmemcpy(buf, storage_src->buf, storage_src->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 +498,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->storage.u.compact.buf, buf, layout_dst->storage.u.compact.size); + HDmemcpy(storage_dst->buf, buf, storage_dst->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 +510,27 @@ 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->storage.u.compact.size / H5T_get_size(dt_src); + ref_count = storage_src->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->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) + if(H5O_copy_expand_ref(f_src, storage_src->buf, dxpl_id, f_dst, + storage_dst->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->storage.u.compact.buf, 0, layout_src->storage.u.compact.size); + HDmemset(storage_dst->buf, 0, storage_src->size); } /* end if */ else /* Type conversion not necessary */ - HDmemcpy(layout_dst->storage.u.compact.buf, layout_src->storage.u.compact.buf, layout_src->storage.u.compact.size); + HDmemcpy(storage_dst->buf, storage_src->buf, storage_src->size); } /* end if */ else /* Type conversion not necessary */ - HDmemcpy(layout_dst->storage.u.compact.buf, layout_src->storage.u.compact.buf, layout_src->storage.u.compact.size); + HDmemcpy(storage_dst->buf, storage_src->buf, storage_src->size); + + /* Mark destination buffer as dirty */ + storage_dst->dirty = TRUE; done: if(buf_sid > 0 && H5I_dec_ref(buf_sid, FALSE) < 0) diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c index 62b63a5..712b17c 100644 --- a/src/H5Dcontig.c +++ b/src/H5Dcontig.c @@ -62,7 +62,6 @@ /* Layout operation callbacks */ static herr_t H5D_contig_construct(H5F_t *f, H5D_t *dset); -static hbool_t H5D_contig_is_space_alloc(const H5O_layout_t *layout); static herr_t H5D_contig_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t *cm); @@ -121,7 +120,7 @@ H5FL_BLK_EXTERN(type_conv); *------------------------------------------------------------------------- */ herr_t -H5D_contig_alloc(H5F_t *f, hid_t dxpl_id, H5O_layout_t *layout /*out */ ) +H5D_contig_alloc(H5F_t *f, hid_t dxpl_id, H5O_storage_contig_t *storage /*out */ ) { herr_t ret_value = SUCCEED; /* Return value */ @@ -129,10 +128,10 @@ H5D_contig_alloc(H5F_t *f, hid_t dxpl_id, H5O_layout_t *layout /*out */ ) /* check args */ HDassert(f); - HDassert(layout); + HDassert(storage); /* Allocate space for the contiguous data */ - if(HADDR_UNDEF == (layout->storage.u.contig.addr = H5MF_alloc(f, H5FD_MEM_DRAW, dxpl_id, layout->storage.u.contig.size))) + if(HADDR_UNDEF == (storage->addr = H5MF_alloc(f, H5FD_MEM_DRAW, dxpl_id, storage->size))) HGOTO_ERROR(H5E_IO, H5E_NOSPACE, FAIL, "unable to reserve file space") done: @@ -445,18 +444,18 @@ done: * *------------------------------------------------------------------------- */ -static hbool_t -H5D_contig_is_space_alloc(const H5O_layout_t *layout) +hbool_t +H5D_contig_is_space_alloc(const H5O_storage_t *storage) { hbool_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_contig_is_space_alloc) /* Sanity checks */ - HDassert(layout); + HDassert(storage); /* Set return value */ - ret_value = (hbool_t)H5F_addr_defined(layout->storage.u.contig.addr); + ret_value = (hbool_t)H5F_addr_defined(storage->u.contig.addr); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_contig_is_space_alloc() */ @@ -1215,14 +1214,12 @@ done: * Programmer: Quincey Koziol * Monday, November 21, 2005 * - * Modifier: Peter Cao - * Saturday, January 07, 2006 - * Add case to deal with compressed variable length datasets *------------------------------------------------------------------------- */ herr_t -H5D_contig_copy(H5F_t *f_src, const H5O_layout_t *layout_src, H5F_t *f_dst, - H5O_layout_t *layout_dst, H5T_t *dt_src, H5O_copy_t *cpy_info, hid_t dxpl_id) +H5D_contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, + H5F_t *f_dst, H5O_storage_contig_t *storage_dst, H5T_t *dt_src, + H5O_copy_t *cpy_info, hid_t dxpl_id) { haddr_t addr_src; /* File offset in source dataset */ haddr_t addr_dst; /* File offset in destination dataset */ @@ -1256,18 +1253,18 @@ H5D_contig_copy(H5F_t *f_src, const H5O_layout_t *layout_src, H5F_t *f_dst, /* Check args */ HDassert(f_src); - HDassert(layout_src && H5D_CONTIGUOUS == layout_src->type); + HDassert(storage_src); HDassert(f_dst); - HDassert(layout_dst && H5D_CONTIGUOUS == layout_dst->type); + HDassert(storage_dst); HDassert(dt_src); /* Allocate space for destination raw data */ - if(H5D_contig_alloc(f_dst, dxpl_id, layout_dst) < 0) + if(H5D_contig_alloc(f_dst, dxpl_id, storage_dst) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to allocate contiguous storage") /* 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->storage.u.contig.size; + total_src_nbytes = storage_dst->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 +1362,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->storage.u.contig.addr; - addr_dst = layout_dst->storage.u.contig.addr; + addr_src = storage_src->addr; + addr_dst = storage_dst->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/H5Dint.c b/src/H5Dint.c index bfa4d02..7bdf75d 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -1299,7 +1299,7 @@ H5D_open_oid(H5D_t *dataset, hid_t dapl_id, hid_t dxpl_id) * be fully allocated before I/O can happen. */ if((H5F_INTENT(dataset->oloc.file) & H5F_ACC_RDWR) - && !(*dataset->shared->layout.ops->is_space_alloc)(&dataset->shared->layout) + && !(*dataset->shared->layout.ops->is_space_alloc)(&dataset->shared->layout.storage) && IS_H5FD_MPI(dataset->oloc.file)) { if(H5D_alloc_storage(dataset, dxpl_id, H5D_ALLOC_OPEN, FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file storage") @@ -1580,9 +1580,9 @@ H5D_alloc_storage(H5D_t *dset/*in,out*/, hid_t dxpl_id, H5D_time_alloc_t time_al switch(layout->type) { case H5D_CONTIGUOUS: - if(!(*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout)) { + if(!(*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) { /* Reserve space in the file for the entire array */ - if(H5D_contig_alloc(f, dxpl_id, layout/*out*/) < 0) + if(H5D_contig_alloc(f, dxpl_id, &layout->storage.u.contig/*out*/) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to initialize contiguous storage") /* Indicate that we set the storage addr */ @@ -1594,7 +1594,7 @@ H5D_alloc_storage(H5D_t *dset/*in,out*/, hid_t dxpl_id, H5D_time_alloc_t time_al break; case H5D_CHUNKED: - if(!(*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout)) { + if(!(*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) { /* Create the root of the B-tree that describes chunked storage */ if(H5D_chunk_create(dset /*in,out*/, dxpl_id) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to initialize chunked storage") @@ -1773,7 +1773,7 @@ H5D_get_storage_size(H5D_t *dset, hid_t dxpl_id) switch(dset->shared->layout.type) { case H5D_CHUNKED: - if((*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout)) { + if((*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) { if(H5D_chunk_allocated(dset, dxpl_id, &ret_value) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't retrieve chunked dataset allocated size") } /* end if */ @@ -1783,7 +1783,7 @@ 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)) + if((*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) ret_value = dset->shared->layout.storage.u.contig.size; else ret_value = 0; @@ -2164,7 +2164,7 @@ H5D_set_extent(H5D_t *dset, const hsize_t *size, hid_t dxpl_id) *------------------------------------------------------------------------- */ if(shrink && H5D_CHUNKED == dset->shared->layout.type && - (*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout)) { + (*dset->shared->layout.ops->is_space_alloc)(&dset->shared->layout.storage)) { /* Remove excess chunks */ if(H5D_chunk_prune_by_extent(dset, dxpl_id, curr_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to remove chunks ") diff --git a/src/H5Dio.c b/src/H5Dio.c index cc75981..463c56e 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -350,7 +350,7 @@ H5D_read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, * has been overwritten. So just proceed in reading. */ if(nelmts > 0 && dataset->shared->dcpl_cache.efl.nused == 0 && - !(*dataset->shared->layout.ops->is_space_alloc)(&dataset->shared->layout)) { + !(*dataset->shared->layout.ops->is_space_alloc)(&dataset->shared->layout.storage)) { H5D_fill_value_t fill_status; /* Whether/How the fill value is defined */ /* Retrieve dataset's fill-value properties */ @@ -384,7 +384,7 @@ H5D_read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, /* Sanity check that space is allocated, if there are elements */ if(nelmts > 0) - HDassert((*dataset->shared->layout.ops->is_space_alloc)(&dataset->shared->layout) + HDassert((*dataset->shared->layout.ops->is_space_alloc)(&dataset->shared->layout.storage) || dataset->shared->dcpl_cache.efl.nused > 0 || dataset->shared->layout.type == H5D_COMPACT); @@ -534,7 +534,7 @@ H5D_write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, /* Allocate data space and initialize it if it hasn't been. */ if(nelmts > 0 && dataset->shared->dcpl_cache.efl.nused == 0 && - !(*dataset->shared->layout.ops->is_space_alloc)(&dataset->shared->layout)) { + !(*dataset->shared->layout.ops->is_space_alloc)(&dataset->shared->layout.storage)) { hssize_t file_nelmts; /* Number of elements in file dataset's dataspace */ hbool_t full_overwrite; /* Whether we are over-writing all the elements */ diff --git a/src/H5Doh.c b/src/H5Doh.c index 93fd21a..d2649f7 100644 --- a/src/H5Doh.c +++ b/src/H5Doh.c @@ -376,7 +376,7 @@ H5O_dset_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5_ih_info_t *bh_info) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't find layout message") /* Check for chunked dataset storage */ - if(layout.type == H5D_CHUNKED && H5D_chunk_is_space_alloc(&layout)) { + if(layout.type == H5D_CHUNKED && H5D_chunk_is_space_alloc(&layout.storage)) { H5O_pline_t pline; /* I/O pipeline message */ htri_t exists; /* Flag if header message of interest exists */ diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index de7d568..fc31ea6 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -101,7 +101,7 @@ struct H5D_chunk_map_t; typedef herr_t (*H5D_layout_construct_func_t)(H5F_t *f, H5D_t *dset); typedef herr_t (*H5D_layout_init_func_t)(H5F_t *f, hid_t dxpl_id, const H5D_t *dset, hid_t dapl_id); -typedef hbool_t (*H5D_layout_is_space_alloc_func_t)(const H5O_layout_t *layout); +typedef hbool_t (*H5D_layout_is_space_alloc_func_t)(const H5O_storage_t *storage); typedef herr_t (*H5D_layout_io_init_func_t)(const struct H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, @@ -571,7 +571,9 @@ H5_DLL herr_t H5D_layout_oh_write(H5D_t *dataset, hid_t dxpl_id, H5O_t *oh, unsigned update_flags); /* Functions that operate on contiguous storage */ -H5_DLL herr_t H5D_contig_alloc(H5F_t *f, hid_t dxpl_id, H5O_layout_t *layout); +H5_DLL herr_t H5D_contig_alloc(H5F_t *f, hid_t dxpl_id, + H5O_storage_contig_t *storage); +H5_DLL hbool_t H5D_contig_is_space_alloc(const H5O_storage_t *storage); H5_DLL herr_t H5D_contig_fill(H5D_t *dset, hid_t dxpl_id); H5_DLL haddr_t H5D_contig_get_addr(const H5D_t *dset); H5_DLL herr_t H5D_contig_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, @@ -586,8 +588,9 @@ H5_DLL ssize_t H5D_contig_readvv(const H5D_io_info_t *io_info, H5_DLL ssize_t H5D_contig_writevv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[]); -H5_DLL herr_t H5D_contig_copy(H5F_t *f_src, const H5O_layout_t *layout_src, H5F_t *f_dst, - H5O_layout_t *layout_dst, H5T_t *src_dtype, H5O_copy_t *cpy_info, hid_t dxpl_id); +H5_DLL herr_t H5D_contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, + H5F_t *f_dst, H5O_storage_contig_t *storage_dst, H5T_t *src_dtype, + H5O_copy_t *cpy_info, hid_t dxpl_id); /* Functions that operate on chunked dataset storage */ H5_DLL htri_t H5D_chunk_cacheable(const H5D_io_info_t *io_info, haddr_t caddr, @@ -597,7 +600,7 @@ H5_DLL herr_t H5D_chunk_create(H5D_t *dset /*in,out*/, hid_t dxpl_id); H5_DLL herr_t H5D_chunk_set_info(const H5D_t *dset); H5_DLL herr_t H5D_chunk_init(H5F_t *f, hid_t dxpl_id, const H5D_t *dset, hid_t dapl_id); -H5_DLL hbool_t H5D_chunk_is_space_alloc(const H5O_layout_t *layout); +H5_DLL hbool_t H5D_chunk_is_space_alloc(const H5O_storage_t *storage); H5_DLL herr_t H5D_chunk_get_info(const H5D_t *dset, hid_t dxpl_id, const hsize_t *chunk_offset, H5D_chunk_ud_t *udata); H5_DLL void *H5D_chunk_lock(const H5D_io_info_t *io_info, @@ -613,8 +616,9 @@ H5_DLL herr_t H5D_chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, H5_DLL herr_t H5D_chunk_addrmap(const H5D_io_info_t *io_info, haddr_t chunk_addr[]); #endif /* H5_HAVE_PARALLEL */ H5_DLL herr_t H5D_chunk_update_cache(H5D_t *dset, hid_t dxpl_id); -H5_DLL herr_t H5D_chunk_copy(H5F_t *f_src, H5O_layout_t *layout_src, - H5F_t *f_dst, H5O_layout_t *layout_dst, const H5S_extent_t *ds_extent_src, +H5_DLL herr_t H5D_chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, + H5O_layout_chunk_t *layout_src, H5F_t *f_dst, H5O_storage_chunk_t *storage_dst, + H5O_layout_chunk_t *layout_dst, const H5S_extent_t *ds_extent_src, const H5T_t *dt_src, const H5O_pline_t *pline_src, H5O_copy_t *cpy_info, hid_t dxpl_id); H5_DLL herr_t H5D_chunk_bh_info(H5F_t *f, hid_t dxpl_id, H5O_layout_t *layout, @@ -627,8 +631,9 @@ H5_DLL herr_t H5D_chunk_stats(const H5D_t *dset, hbool_t headers); /* Functions that operate on compact dataset storage */ H5_DLL herr_t H5D_compact_fill(H5D_t *dset, hid_t dxpl_id); -H5_DLL herr_t H5D_compact_copy(H5F_t *f_src, H5O_layout_t *layout_src, - H5F_t *f_dst, H5O_layout_t *layout_dst, H5T_t *src_dtype, H5O_copy_t *cpy_info, hid_t dxpl_id); +H5_DLL herr_t H5D_compact_copy(H5F_t *f_src, H5O_storage_compact_t *storage_src, + H5F_t *f_dst, H5O_storage_compact_t *storage_dst, H5T_t *src_dtype, + H5O_copy_t *cpy_info, hid_t dxpl_id); /* Functions that perform fill value operations on datasets */ H5_DLL herr_t H5D_fill(const void *fill, const H5T_t *fill_type, void *buf, diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index 277b87a..4c6ed79 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -139,6 +139,13 @@ typedef struct H5D_dcpl_cache_t { H5O_efl_t efl; /* External file list info (H5D_CRT_EXT_FILE_LIST_NAME) */ } H5D_dcpl_cache_t; +/* Callback information for copying dataset */ +typedef struct H5D_copy_file_ud_t { + struct H5S_extent_t *src_space_extent; /* Copy of dataspace extent for dataset */ + H5T_t *src_dtype; /* Copy of datatype for dataset */ + H5O_pline_t *src_pline; /* Copy of filter pipeline for dataet */ +} H5D_copy_file_ud_t; + /*****************************/ /* Library Private Variables */ diff --git a/src/H5Odtype.c b/src/H5Odtype.c index 63b2aaf..83dbabc 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -17,6 +17,7 @@ #define H5T_PACKAGE /*prevent warning from including H5Tpkg */ #include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* Files */ #include "H5FLprivate.h" /* Free Lists */ diff --git a/src/H5Olayout.c b/src/H5Olayout.c index b8a56f7..13e095e 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -375,7 +375,7 @@ H5O_layout_copy(const void *_mesg, void *_dest) /* check args */ HDassert(mesg); if(!dest && NULL == (dest = H5FL_MALLOC(H5O_layout_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "memory allocation failed") /* copy */ *dest = *mesg; @@ -384,7 +384,7 @@ H5O_layout_copy(const void *_mesg, void *_dest) if(mesg->type == H5D_COMPACT && mesg->storage.u.compact.size > 0) { /* Allocate memory for the raw data */ 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") + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "unable to allocate memory for compact dataset") /* Copy over the raw data */ HDmemcpy(dest->storage.u.compact.buf, mesg->storage.u.compact.buf, dest->storage.u.compact.size); @@ -588,23 +588,18 @@ H5O_layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, /* Allocate space for the destination layout */ if(NULL == (layout_dst = H5FL_MALLOC(H5O_layout_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "memory allocation failed") /* Copy the "top level" information */ - HDmemcpy(layout_dst, layout_src, sizeof(H5O_layout_t)); + *layout_dst = *layout_src; /* Copy the layout type specific information */ switch(layout_src->type) { case H5D_COMPACT: 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->storage.u.compact.dirty = TRUE; + if(H5D_compact_copy(file_src, &layout_src->storage.u.compact, file_dst, &layout_dst->storage.u.compact, udata->src_dtype, cpy_info, dxpl_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy chunked storage") } /* end if */ break; @@ -617,18 +612,18 @@ H5O_layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, 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->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") + if(H5D_contig_is_space_alloc(&layout_src->storage)) { + /* copy contiguous raw data */ + if(H5D_contig_copy(file_src, &layout_src->storage.u.contig, file_dst, &layout_dst->storage.u.contig, udata->src_dtype, cpy_info, dxpl_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy contiguous storage") } /* end if */ break; case H5D_CHUNKED: - if(H5D_chunk_is_space_alloc(layout_src)) { + if(H5D_chunk_is_space_alloc(&layout_src->storage)) { /* Create chunked layout */ - if(H5D_chunk_copy(file_src, layout_src, file_dst, layout_dst, udata->src_space_extent, udata->src_dtype, udata->src_pline, cpy_info, dxpl_id) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy chunked storage") + if(H5D_chunk_copy(file_src, &layout_src->storage.u.chunk, &layout_src->u.chunk, file_dst, &layout_dst->storage.u.chunk, &layout_dst->u.chunk, udata->src_space_extent, udata->src_dtype, udata->src_pline, cpy_info, dxpl_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy chunked storage") } /* end if */ break; diff --git a/src/H5Opkg.h b/src/H5Opkg.h index 8569119..c2e58dd 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -310,13 +310,6 @@ struct H5O_t { H5O_chunk_t *chunk; /*array of chunks */ }; -/* Callback information for copying dataset */ -typedef struct H5D_copy_file_ud_t { - struct H5S_extent_t *src_space_extent; /* Copy of dataspace extent for dataset */ - H5T_t *src_dtype; /* Copy of datatype for dataset */ - H5O_pline_t *src_pline; /* Copy of filter pipeline for dataet */ -} H5D_copy_file_ud_t; - /* Class for types of objects in file */ typedef struct H5O_obj_class_t { H5O_type_t type; /*object type on disk */ diff --git a/src/H5Opline.c b/src/H5Opline.c index 070ab87..cc00996 100644 --- a/src/H5Opline.c +++ b/src/H5Opline.c @@ -24,6 +24,7 @@ #define H5Z_PACKAGE /*suppress error about including H5Zpkg */ #include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5MMprivate.h" /* Memory management */ diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c index 23af101..d7dccbd 100644 --- a/src/H5Osdspace.c +++ b/src/H5Osdspace.c @@ -17,6 +17,7 @@ #define H5S_PACKAGE /*prevent warning from including H5Spkg.h */ #include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free lists */ #include "H5Gprivate.h" /* Groups */ diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index d8ff5db..8314c72 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -777,7 +777,7 @@ H5P_init_def_layout(void) H5D_def_layout_compact_g.u.compact = def_layout_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.storage.u.chunk = def_store_chunk; + H5D_def_layout_chunk_g.storage.u.chunk = def_store_chunk; /* Note that we've initialized the default values */ H5P_dcrt_def_layout_init_g = TRUE; -- cgit v0.12