diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2009-05-27 23:21:24 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2009-05-27 23:21:24 (GMT) |
commit | bae373c32236ad99425154f5fcec4cb185e583d0 (patch) | |
tree | 9ba2bd0e8e3157eafc9c5ff84d1cb45762639672 /src | |
parent | 29d45ed0d13493d07d7d744950e1fe1b6d5bbff1 (diff) | |
download | hdf5-bae373c32236ad99425154f5fcec4cb185e583d0.zip hdf5-bae373c32236ad99425154f5fcec4cb185e583d0.tar.gz hdf5-bae373c32236ad99425154f5fcec4cb185e583d0.tar.bz2 |
[svn-r16988] Description:
Refactor layout initialization so that chunk index information can be
set for extensible array indices.
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.6 (amazon) in debug mode
Mac OS X/32 10.5.6 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Dbtree.c | 6 | ||||
-rw-r--r-- | src/H5Dchunk.c | 187 | ||||
-rw-r--r-- | src/H5Dcompact.c | 8 | ||||
-rw-r--r-- | src/H5Dcontig.c | 7 | ||||
-rw-r--r-- | src/H5Dearray.c | 54 | ||||
-rw-r--r-- | src/H5Defl.c | 8 | ||||
-rw-r--r-- | src/H5Dint.c | 35 | ||||
-rw-r--r-- | src/H5Dpkg.h | 18 | ||||
-rw-r--r-- | src/H5Dproxy.c | 2 | ||||
-rw-r--r-- | src/H5Olayout.c | 2 | ||||
-rw-r--r-- | src/H5Oprivate.h | 1 |
11 files changed, 190 insertions, 138 deletions
diff --git a/src/H5Dbtree.c b/src/H5Dbtree.c index 3674ae3..1195c80 100644 --- a/src/H5Dbtree.c +++ b/src/H5Dbtree.c @@ -135,7 +135,8 @@ static herr_t H5D_btree_debug_key(FILE *stream, H5F_t *f, hid_t dxpl_id, int indent, int fwidth, const void *key, const void *udata); /* Chunked layout indexing callbacks */ -static herr_t H5D_btree_idx_init(const H5D_chk_idx_info_t *idx_info); +static herr_t H5D_btree_idx_init(const H5D_chk_idx_info_t *idx_info, + 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 herr_t H5D_btree_idx_insert(const H5D_chk_idx_info_t *idx_info, @@ -845,7 +846,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D_btree_idx_init(const H5D_chk_idx_info_t *idx_info) +H5D_btree_idx_init(const H5D_chk_idx_info_t *idx_info, haddr_t UNUSED dset_ohdr_addr) { herr_t ret_value = SUCCEED; /* Return value */ @@ -856,6 +857,7 @@ H5D_btree_idx_init(const H5D_chk_idx_info_t *idx_info) HDassert(idx_info->f); HDassert(idx_info->pline); HDassert(idx_info->layout); + HDassert(H5F_addr_defined(dset_ohdr_addr)); /* Allocate the shared structure */ if(H5D_btree_shared_create(idx_info->f, idx_info->layout) < 0) diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index a5a76b2..d052ff1 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -173,8 +173,7 @@ typedef struct H5D_chunk_it_ud4_t { /********************/ /* Chunked layout operation callbacks */ -static herr_t H5D_chunk_construct(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset, - const H5P_genplist_t *dc_plist); +static herr_t H5D_chunk_construct(H5F_t *f, H5D_t *dset); static herr_t H5D_chunk_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 *fm); @@ -217,6 +216,7 @@ static herr_t H5D_chunk_mem_cb(void *elem, hid_t type_id, unsigned ndims, /* Chunked storage layout I/O ops */ const H5D_layout_ops_t H5D_LOPS_CHUNK[1] = {{ H5D_chunk_construct, + H5D_chunk_init, H5D_chunk_is_space_alloc, H5D_chunk_io_init, H5D_chunk_read, @@ -242,6 +242,7 @@ const H5D_layout_ops_t H5D_LOPS_NONEXISTENT[1] = {{ NULL, NULL, NULL, + NULL, #ifdef H5_HAVE_PARALLEL NULL, NULL, @@ -285,8 +286,7 @@ H5FL_DEFINE_STATIC(H5D_chunk_prune_stack_t); *------------------------------------------------------------------------- */ static herr_t -H5D_chunk_construct(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset, - const H5P_genplist_t *dc_plist) +H5D_chunk_construct(H5F_t *f, H5D_t *dset) { const H5T_t *type = dset->shared->type; /* Convenience pointer to dataset's datatype */ hsize_t max_dim[H5O_LAYOUT_NDIMS]; /* Maximum size of data in elements */ @@ -300,7 +300,6 @@ H5D_chunk_construct(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset, /* Sanity checks */ HDassert(f); HDassert(dset); - HDassert(dc_plist); /* Set up layout information */ if((ndims = H5S_GET_EXTENT_NDIMS(dset->shared->space)) < 0) @@ -349,16 +348,89 @@ H5D_chunk_construct(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset, if(H5D_chunk_idx_reset(&dset->shared->layout, TRUE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to reset chunked storage index") - /* Initialize the chunk cache for the dataset */ - if(H5D_chunk_init(f, dapl_id, dxpl_id, dset) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize chunk cache") - done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_chunk_construct() */ /*------------------------------------------------------------------------- + * Function: H5D_chunk_init + * + * Purpose: Initialize the raw data chunk cache for a dataset. This is + * called when the dataset is initialized. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Robb Matzke + * Monday, May 18, 1998 + * + *------------------------------------------------------------------------- + */ +herr_t +H5D_chunk_init(H5F_t *f, hid_t dxpl_id, const H5D_t *dset, hid_t dapl_id) +{ + H5D_chk_idx_info_t idx_info; /* Chunked index info */ + H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /* Convenience pointer to dataset's chunk cache */ + H5P_genplist_t *dapl; /* Data access property list object pointer */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5D_chunk_init, FAIL) + + /* Sanity check */ + HDassert(f); + HDassert(dset); + HDassert((H5D_CHUNK_EARRAY == dset->shared->layout.u.chunk.idx_type && + H5D_COPS_EARRAY == dset->shared->layout.u.chunk.ops) || + (H5D_CHUNK_BTREE == dset->shared->layout.u.chunk.idx_type && + H5D_COPS_BTREE == dset->shared->layout.u.chunk.ops)); + + if(NULL == (dapl = (H5P_genplist_t *)H5I_object(dapl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for fapl ID"); + + /* Use the properties in dapl_id if they have been set, otherwise use the properties from the file */ + if(H5P_get(dapl, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &rdcc->nslots) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache number of slots"); + if(rdcc->nslots == H5D_CHUNK_CACHE_NSLOTS_DEFAULT) + rdcc->nslots = H5F_RDCC_NSLOTS(f); + + if(H5P_get(dapl, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &rdcc->nbytes_max) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache byte size"); + if(rdcc->nbytes_max == H5D_CHUNK_CACHE_NBYTES_DEFAULT) + rdcc->nbytes_max = H5F_RDCC_NBYTES(f); + + if(H5P_get(dapl, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &rdcc->w0) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get preempt read chunks"); + if(rdcc->w0 < 0) + rdcc->w0 = H5F_RDCC_W0(f); + + /* If nbytes_max or nslots is 0, set them both to 0 and avoid allocating space */ + if(!rdcc->nbytes_max || !rdcc->nslots) + rdcc->nbytes_max = rdcc->nslots = 0; + else { + rdcc->slot = H5FL_SEQ_CALLOC(H5D_rdcc_ent_ptr_t, rdcc->nslots); + if(NULL == rdcc->slot) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + + /* Reset any cached chunk info for this dataset */ + H5D_chunk_cinfo_cache_reset(&(rdcc->last)); + } /* end else */ + + /* Compose chunked index info struct */ + idx_info.f = f; + idx_info.dxpl_id = dxpl_id; + idx_info.pline = &dset->shared->dcpl_cache.pline; + idx_info.layout = &dset->shared->layout; + + /* Allocate any indexing structures */ + if(dset->shared->layout.u.chunk.ops->init && (dset->shared->layout.u.chunk.ops->init)(&idx_info, dset->oloc.addr) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize indexing information") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D_chunk_init() */ + + +/*------------------------------------------------------------------------- * Function: H5D_chunk_is_space_alloc * * Purpose: Query if space is allocated for layout @@ -1835,83 +1907,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5D_chunk_init - * - * Purpose: Initialize the raw data chunk cache for a dataset. This is - * called when the dataset is initialized. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Monday, May 18, 1998 - * - *------------------------------------------------------------------------- - */ -herr_t -H5D_chunk_init(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, const H5D_t *dset) -{ - H5D_chk_idx_info_t idx_info; /* Chunked index info */ - H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /* Convenience pointer to dataset's chunk cache */ - H5P_genplist_t *dapl; /* Data access property list object pointer */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(H5D_chunk_init, FAIL) - - /* Sanity check */ - HDassert(f); - HDassert(dset); - HDassert((H5D_CHUNK_EARRAY == dset->shared->layout.u.chunk.idx_type && - H5D_COPS_EARRAY == dset->shared->layout.u.chunk.ops) || - (H5D_CHUNK_BTREE == dset->shared->layout.u.chunk.idx_type && - H5D_COPS_BTREE == dset->shared->layout.u.chunk.ops)); - - if(NULL == (dapl = (H5P_genplist_t *)H5I_object(dapl_id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for fapl ID"); - - /* Use the properties in dapl_id if they have been set, otherwise use the properties from the file */ - if(H5P_get(dapl, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &rdcc->nslots) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache number of slots"); - if(rdcc->nslots == H5D_CHUNK_CACHE_NSLOTS_DEFAULT) - rdcc->nslots = H5F_RDCC_NSLOTS(f); - - if(H5P_get(dapl, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &rdcc->nbytes_max) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache byte size"); - if(rdcc->nbytes_max == H5D_CHUNK_CACHE_NBYTES_DEFAULT) - rdcc->nbytes_max = H5F_RDCC_NBYTES(f); - - if(H5P_get(dapl, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &rdcc->w0) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get preempt read chunks"); - if(rdcc->w0 < 0) - rdcc->w0 = H5F_RDCC_W0(f); - - /* If nbytes_max or nslots is 0, set them both to 0 and avoid allocating space */ - if(!rdcc->nbytes_max || !rdcc->nslots) - rdcc->nbytes_max = rdcc->nslots = 0; - else { - rdcc->slot = H5FL_SEQ_CALLOC(H5D_rdcc_ent_ptr_t, rdcc->nslots); - if(NULL == rdcc->slot) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - - /* Reset any cached chunk info for this dataset */ - H5D_chunk_cinfo_cache_reset(&(rdcc->last)); - } /* end else */ - - /* Compose chunked index info struct */ - idx_info.f = f; - idx_info.dxpl_id = dxpl_id; - idx_info.pline = &dset->shared->dcpl_cache.pline; - idx_info.layout = &dset->shared->layout; - - /* Allocate any indexing structures */ - if(dset->shared->layout.u.chunk.ops->init && (dset->shared->layout.u.chunk.ops->init)(&idx_info) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize indexing information") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D_chunk_init() */ - - -/*------------------------------------------------------------------------- * Function: H5D_chunk_idx_reset * * Purpose: Reset index information @@ -2311,7 +2306,7 @@ H5D_chunk_flush_entry(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t * /* Check for SWMR writes to the file */ if(dset->shared->layout.u.chunk.ops->can_swim && H5F_INTENT(dset->oloc.file) & H5F_ACC_SWMR_WRITE) { /* Mark the proxy entry in the cache as clean */ - if(H5D_chunk_proxy_mark(dset, dxpl_id, ent, FALSE) < 0) + if(H5D_chunk_proxy_mark(dset, ent, FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTMARKDIRTY, FAIL, "can't mark proxy for chunk from metadata cache as clean") } /* end if */ @@ -2747,7 +2742,7 @@ H5D_chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, * flush dependencies are maintained in the proper way for SWMR * access to work. */ - if(H5D_chunk_proxy_create(io_info->dset, io_info->dxpl_id, udata, ent) < 0) + if(H5D_chunk_proxy_create(io_info->dset, io_info->dxpl_id, (H5D_chunk_common_ud_t *)udata, ent) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, NULL, "can't insert proxy for chunk in metadata cache") } /* end if */ @@ -2855,16 +2850,16 @@ H5D_chunk_unlock(const H5D_io_info_t *io_info, const H5D_chunk_ud_t *udata, * don't discard the `const' qualifier. */ if(dirty) { - H5D_rdcc_ent_t ent; /* "fake" chunk cache entry */ + H5D_rdcc_ent_t fake_ent; /* "fake" chunk cache entry */ - HDmemset(&ent, 0, sizeof(ent)); - ent.dirty = TRUE; - HDmemcpy(ent.offset, io_info->store->chunk.offset, layout->u.chunk.ndims * sizeof(ent.offset[0])); + HDmemset(&fake_ent, 0, sizeof(fake_ent)); + fake_ent.dirty = TRUE; + HDmemcpy(fake_ent.offset, io_info->store->chunk.offset, layout->u.chunk.ndims * sizeof(fake_ent.offset[0])); HDassert(layout->u.chunk.size > 0); - ent.chunk_addr = udata->addr; - ent.chunk = (uint8_t *)chunk; + fake_ent.chunk_addr = udata->addr; + fake_ent.chunk = (uint8_t *)chunk; - if(H5D_chunk_flush_entry(io_info->dset, io_info->dxpl_id, io_info->dxpl_cache, &ent, TRUE) < 0) + if(H5D_chunk_flush_entry(io_info->dset, io_info->dxpl_id, io_info->dxpl_cache, &fake_ent, TRUE) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer") } /* end if */ else { @@ -2891,7 +2886,7 @@ H5D_chunk_unlock(const H5D_io_info_t *io_info, const H5D_chunk_ud_t *udata, if(io_info->dset->shared->layout.u.chunk.ops->can_swim && H5F_INTENT(io_info->dset->oloc.file) & H5F_ACC_SWMR_WRITE) { /* Mark the proxy entry in the cache as dirty */ - if(H5D_chunk_proxy_mark(io_info->dset, io_info->dxpl_id, ent, TRUE) < 0) + if(H5D_chunk_proxy_mark(io_info->dset, ent, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTMARKDIRTY, FAIL, "can't mark proxy for chunk from metadata cache as dirty") } /* end if */ } /* end if */ diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c index f773f5f..09abee0 100644 --- a/src/H5Dcompact.c +++ b/src/H5Dcompact.c @@ -57,8 +57,7 @@ /********************/ /* Layout operation callbacks */ -static herr_t H5D_compact_construct(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset, - const H5P_genplist_t *dc_plist); +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 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, @@ -78,6 +77,7 @@ static ssize_t H5D_compact_writevv(const H5D_io_info_t *io_info, /* Compact storage layout I/O ops */ const H5D_layout_ops_t H5D_LOPS_COMPACT[1] = {{ H5D_compact_construct, + NULL, H5D_compact_is_space_alloc, H5D_compact_io_init, H5D_contig_read, @@ -167,8 +167,7 @@ done: */ /* ARGSUSED */ static herr_t -H5D_compact_construct(H5F_t *f, hid_t UNUSED dapl_id, hid_t UNUSED dxpl_id, H5D_t *dset, - const H5P_genplist_t UNUSED *dc_plist) +H5D_compact_construct(H5F_t *f, H5D_t *dset) { hssize_t tmp_size; /* Temporary holder for raw data size */ hsize_t comp_data_size; /* Size of compact data */ @@ -179,7 +178,6 @@ H5D_compact_construct(H5F_t *f, hid_t UNUSED dapl_id, hid_t UNUSED dxpl_id, H5D_ /* Sanity checks */ HDassert(f); HDassert(dset); - HDassert(dc_plist); /* * Compact dataset is stored in dataset object header message of diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c index 1275ee1..887f37a 100644 --- a/src/H5Dcontig.c +++ b/src/H5Dcontig.c @@ -61,8 +61,7 @@ /********************/ /* Layout operation callbacks */ -static herr_t H5D_contig_construct(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset, - const H5P_genplist_t *dc_plist); +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, @@ -80,6 +79,7 @@ static herr_t H5D_contig_write_one(H5D_io_info_t *io_info, hsize_t offset, /* Contiguous storage layout I/O ops */ const H5D_layout_ops_t H5D_LOPS_CONTIG[1] = {{ H5D_contig_construct, + NULL, H5D_contig_is_space_alloc, H5D_contig_io_init, H5D_contig_read, @@ -373,8 +373,7 @@ H5D_contig_get_addr(const H5D_t *dset) */ /* ARGSUSED */ static herr_t -H5D_contig_construct(H5F_t *f, hid_t UNUSED dapl_id, hid_t UNUSED dxpl_id, H5D_t *dset, - const H5P_genplist_t UNUSED *dc_plist) +H5D_contig_construct(H5F_t *f, H5D_t *dset) { hssize_t snelmts; /* Temporary holder for number of elements in dataspace */ hsize_t nelmts; /* Number of elements in dataspace */ diff --git a/src/H5Dearray.c b/src/H5Dearray.c index 9862a15..66de57d 100644 --- a/src/H5Dearray.c +++ b/src/H5Dearray.c @@ -114,6 +114,8 @@ static herr_t H5D_earray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt); /* Chunked layout indexing callbacks */ +static herr_t H5D_earray_idx_init(const H5D_chk_idx_info_t *idx_info, + haddr_t dset_ohdr_addr); static herr_t H5D_earray_idx_create(const H5D_chk_idx_info_t *idx_info); static hbool_t H5D_earray_idx_is_space_alloc(const H5O_layout_t *layout); static herr_t H5D_earray_idx_insert(const H5D_chk_idx_info_t *idx_info, @@ -148,7 +150,7 @@ static herr_t H5D_earray_idx_dest(const H5D_chk_idx_info_t *idx_info); /* Extensible array indexed chunk I/O ops */ const H5D_chunk_ops_t H5D_COPS_EARRAY[1] = {{ TRUE, /* Extensible array indices support SWMR access */ - NULL, + H5D_earray_idx_init, H5D_earray_idx_create, H5D_earray_idx_is_space_alloc, H5D_earray_idx_insert, @@ -598,8 +600,12 @@ H5D_earray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, /*------------------------------------------------------------------------- * Function: H5D_earray_idx_open * - * Purpose: Opens an existing extensible array and initializes - * the layout struct with information about the storage. + * Purpose: Opens an existing extensible array. + * + * Note: This information is passively initialized from each index + * operation callback because those abstract chunk index operations + * are designed to work with the v1 B-tree chunk indices also, + * which don't require an 'open' for the data structure. * * Return: Success: non-negative * Failure: negative @@ -642,6 +648,37 @@ done: /*------------------------------------------------------------------------- + * Function: H5D_earray_idx_init + * + * Purpose: Initialize the indexing information for a dataset. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Wednesday, May 27, 2009 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D_earray_idx_init(const H5D_chk_idx_info_t *idx_info, haddr_t dset_ohdr_addr) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_earray_idx_init) + + /* Check args */ + HDassert(idx_info); + HDassert(idx_info->f); + HDassert(idx_info->pline); + HDassert(idx_info->layout); + HDassert(H5F_addr_defined(dset_ohdr_addr)); + + /* Store the dataset's object header address for later */ + idx_info->layout->u.chunk.u.earray.dset_ohdr_addr = dset_ohdr_addr; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5D_earray_idx_init() */ + + +/*------------------------------------------------------------------------- * Function: H5D_earray_idx_create * * Purpose: Creates a new indexed-storage extensible array and initializes @@ -1277,7 +1314,6 @@ static herr_t H5D_earray_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, const H5D_chk_idx_info_t *idx_info_dst) { - H5EA_t *ea_src; /* Pointer to extensible array structure */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_earray_idx_copy_setup) @@ -1299,9 +1335,6 @@ H5D_earray_idx_copy_setup(const H5D_chk_idx_info_t *idx_info_src, HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open extensible array") } /* end if */ - /* Set convenience pointer to extensible array structure */ - ea_src = idx_info_src->layout->u.chunk.u.earray.ea; - /* Create the extensible array that describes chunked storage in the dest. file */ if(H5D_earray_idx_create(idx_info_dst) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize chunked storage") @@ -1430,8 +1463,10 @@ H5D_earray_idx_reset(H5O_layout_t *layout, hbool_t reset_addr) HDassert(layout); /* Reset index info */ - if(reset_addr) + if(reset_addr) { layout->u.chunk.u.earray.addr = HADDR_UNDEF; + layout->u.chunk.u.earray.dset_ohdr_addr = HADDR_UNDEF; + } /* end if */ layout->u.chunk.u.earray.ea = NULL; FUNC_LEAVE_NOAPI(SUCCEED) @@ -1593,6 +1628,9 @@ H5D_earray_idx_dest(const H5D_chk_idx_info_t *idx_info) /* Check if the extensible array is open */ if(idx_info->layout->u.chunk.u.earray.ea) { + /* Sanity check */ + HDassert(H5F_addr_defined(idx_info->layout->u.chunk.u.earray.dset_ohdr_addr)); + if(H5EA_close(idx_info->layout->u.chunk.u.earray.ea, idx_info->dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to close extensible array") idx_info->layout->u.chunk.u.earray.ea = NULL; diff --git a/src/H5Defl.c b/src/H5Defl.c index a22ca2d..cb31630 100644 --- a/src/H5Defl.c +++ b/src/H5Defl.c @@ -49,8 +49,7 @@ /********************/ /* Layout operation callbacks */ -static herr_t H5D_efl_construct(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset, - const H5P_genplist_t *dc_plist); +static herr_t H5D_efl_construct(H5F_t *f, H5D_t *dset); static hbool_t H5D_efl_is_space_alloc(const H5O_layout_t *layout); static herr_t H5D_efl_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, @@ -76,6 +75,7 @@ static herr_t H5D_efl_write(const H5O_efl_t *efl, haddr_t addr, size_t size, /* External File List (EFL) storage layout I/O ops */ const H5D_layout_ops_t H5D_LOPS_EFL[1] = {{ H5D_efl_construct, + NULL, H5D_efl_is_space_alloc, H5D_efl_io_init, H5D_contig_read, @@ -109,8 +109,7 @@ const H5D_layout_ops_t H5D_LOPS_EFL[1] = {{ *------------------------------------------------------------------------- */ static herr_t -H5D_efl_construct(H5F_t *f, hid_t UNUSED dapl_id, hid_t UNUSED dxpl_id, H5D_t *dset, - const H5P_genplist_t *dc_plist) +H5D_efl_construct(H5F_t *f, H5D_t *dset) { size_t dt_size; /* Size of datatype */ hsize_t dim[H5O_LAYOUT_NDIMS]; /* Current size of data in elements */ @@ -127,7 +126,6 @@ H5D_efl_construct(H5F_t *f, hid_t UNUSED dapl_id, hid_t UNUSED dxpl_id, H5D_t *d /* Sanity checks */ HDassert(f); HDassert(dset); - HDassert(dc_plist); /* * The maximum size of the dataset cannot exceed the storage size. diff --git a/src/H5Dint.c b/src/H5Dint.c index 1ab6dce..a83f186 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -65,7 +65,8 @@ static herr_t H5D_init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type); static herr_t H5D_init_space(H5F_t *file, const H5D_t *dset, const H5S_t *space); static herr_t H5D_set_io_ops(H5D_t *dataset); -static herr_t H5D_update_oh_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset); +static herr_t H5D_update_oh_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, + hid_t dapl_id); static herr_t H5D_open_oid(H5D_t *dataset, hid_t dapl_id, hid_t dxpl_id); static herr_t H5D_flush_real(H5D_t *dataset, hid_t dxpl_id, unsigned flags); @@ -767,7 +768,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D_update_oh_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset) +H5D_update_oh_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, hid_t dapl_id) { H5O_t *oh = NULL; /* Pointer to dataset's object header */ size_t ohdr_size = H5D_MINHDR_SIZE; /* Size of dataset's object header */ @@ -778,6 +779,7 @@ H5D_update_oh_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset) H5O_fill_t *fill_prop; /* Pointer to dataset's fill value information */ H5D_fill_value_t fill_status; /* Fill value status */ hbool_t fill_changed = FALSE; /* Flag indicating the fill value was changed */ + hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_update_oh_info) @@ -894,6 +896,13 @@ H5D_update_oh_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update filter header message") } /* end if */ + /* Initialize the layout information for the new dataset */ + if(dset->shared->layout.ops->init && (dset->shared->layout.ops->init)(file, dxpl_id, dset, dapl_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize layout information") + + /* Indicate that the layout information was initialized */ + layout_init = TRUE; + /* * Allocate storage if space allocate time is early; otherwise delay * allocation until later. @@ -995,6 +1004,14 @@ done: if(H5O_unprotect(oloc, oh) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTUNPROTECT, FAIL, "unable to unprotect dataset object header") + /* Error cleanup */ + if(ret_value < 0) { + if(dset->shared->layout.type == H5D_CHUNKED && layout_init) { + if(H5D_chunk_dest(file, dxpl_id, dset) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy chunk cache") + } /* end if */ + } /* end if */ + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_update_oh_info() */ @@ -1152,16 +1169,16 @@ H5D_create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize I/O operations") /* Create the layout information for the new dataset */ - if((new_dset->shared->layout.ops->construct)(file, dapl_id, dxpl_id, new_dset, dc_plist) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize layout information") - - /* Indicate that the layout information was initialized */ - layout_init = TRUE; + if((new_dset->shared->layout.ops->construct)(file, new_dset) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to construct layout information") /* Update the dataset's object header info. */ - if(H5D_update_oh_info(file, dxpl_id, new_dset) != SUCCEED) + if(H5D_update_oh_info(file, dxpl_id, new_dset, dapl_id) != SUCCEED) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't update the metadata cache") + /* Indicate that the layout information was initialized */ + layout_init = TRUE; + /* Add the dataset to the list of opened objects in the file */ if(H5FO_top_incr(new_dset->oloc.file, new_dset->oloc.addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINC, NULL, "can't incr object ref. count") @@ -1443,7 +1460,7 @@ H5D_open_oid(H5D_t *dataset, hid_t dapl_id, hid_t dxpl_id) case H5D_CHUNKED: /* Initialize the chunk cache for the dataset */ - if(H5D_chunk_init(dataset->oloc.file, dapl_id, dxpl_id, dataset) < 0) + if(H5D_chunk_init(dataset->oloc.file, dxpl_id, dataset, dapl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize chunk cache") break; diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index f67c7e1..6e15c16 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -98,8 +98,9 @@ struct H5D_io_info_t; struct H5D_chunk_map_t; /* Function pointers for I/O on particular types of dataset layouts */ -typedef herr_t (*H5D_layout_construct_func_t)(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, - H5D_t *dset, const H5P_genplist_t *dc_plist); +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 herr_t (*H5D_layout_io_init_func_t)(const struct H5D_io_info_t *io_info, const H5D_type_info_t *type_info, @@ -121,7 +122,8 @@ typedef herr_t (*H5D_layout_io_term_func_t)(const struct H5D_chunk_map_t *cm); /* Typedef for grouping layout I/O routines */ typedef struct H5D_layout_ops_t { - H5D_layout_construct_func_t construct; /* Layout constructor for new datasets */ + H5D_layout_construct_func_t construct; /* Layout constructor for new datasets */ + H5D_layout_init_func_t init; /* Layout initializer for dataset */ H5D_layout_is_space_alloc_func_t is_space_alloc; /* Query routine to determine if storage is allocated */ H5D_layout_io_init_func_t io_init; /* I/O initialization routine */ H5D_layout_read_func_t ser_read; /* High-level I/O routine for reading data in serial */ @@ -263,7 +265,8 @@ typedef int (*H5D_chunk_cb_func_t)(const H5D_chunk_rec_t *chunk_rec, void *udata); /* Typedefs for chunk operations */ -typedef herr_t (*H5D_chunk_init_func_t)(const H5D_chk_idx_info_t *idx_info); +typedef herr_t (*H5D_chunk_init_func_t)(const H5D_chk_idx_info_t *idx_info, + 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 herr_t (*H5D_chunk_insert_func_t)(const H5D_chk_idx_info_t *idx_info, @@ -593,7 +596,8 @@ H5_DLL htri_t H5D_chunk_cacheable(const H5D_io_info_t *io_info, haddr_t caddr, hbool_t write_op); H5_DLL herr_t H5D_chunk_cinfo_cache_reset(H5D_chunk_cached_t *last); H5_DLL herr_t H5D_chunk_create(H5D_t *dset /*in,out*/, hid_t dxpl_id); -H5_DLL herr_t H5D_chunk_init(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, 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 herr_t H5D_chunk_get_info(const H5D_t *dset, hid_t dxpl_id, const hsize_t *chunk_offset, H5D_chunk_ud_t *udata); @@ -649,8 +653,8 @@ H5_DLL herr_t H5D_chunk_proxy_create(H5D_t *dset, hid_t dxpl_id, H5D_chunk_common_ud_t *udata, H5D_rdcc_ent_t *ent); H5_DLL herr_t H5D_chunk_proxy_remove(const H5D_t *dset, hid_t dxpl_it, H5D_rdcc_ent_t *ent); -H5_DLL herr_t H5D_chunk_proxy_mark(const H5D_t *dset, hid_t dxpl_id, - const H5D_rdcc_ent_t *ent, hbool_t dirty); +H5_DLL herr_t H5D_chunk_proxy_mark(const H5D_t *dset, const H5D_rdcc_ent_t *ent, + hbool_t dirty); #ifdef H5_HAVE_PARALLEL diff --git a/src/H5Dproxy.c b/src/H5Dproxy.c index e2c6450..7d57ac2 100644 --- a/src/H5Dproxy.c +++ b/src/H5Dproxy.c @@ -467,7 +467,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D_chunk_proxy_mark(const H5D_t *dset, hid_t dxpl_id, const H5D_rdcc_ent_t *ent, +H5D_chunk_proxy_mark(const H5D_t *dset, const H5D_rdcc_ent_t *ent, hbool_t dirty) { herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Olayout.c b/src/H5Olayout.c index c79f328..dae37b0 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -395,7 +395,7 @@ H5O_layout_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const voi else { /* Encoded # of bytes for each chunk dimension */ HDassert(mesg->u.chunk.enc_bytes_per_dim > 0 && mesg->u.chunk.enc_bytes_per_dim <= 8); - *p++ = mesg->u.chunk.enc_bytes_per_dim; + *p++ = (uint8_t)mesg->u.chunk.enc_bytes_per_dim; /* Number of dimensions */ HDassert(mesg->u.chunk.ndims > 0 && mesg->u.chunk.ndims <= H5O_LAYOUT_NDIMS); diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 4e4844e..c16905d 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -367,6 +367,7 @@ struct H5EA_t; /* Defined in H5EAprivate.h */ typedef struct H5O_layout_chunk_earray_t { haddr_t addr; /* File address of extensible array */ + haddr_t dset_ohdr_addr; /* File address dataset's object header */ struct H5EA_t *ea; /* Pointer to extensible array struct */ } H5O_layout_chunk_earray_t; |