summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2015-02-20 21:53:35 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2015-02-20 21:53:35 (GMT)
commit88b7d8d34cd1c645c22197d440115c05435c816a (patch)
treea9bd6c3e425bbf6a8a5e25094b2c0d07e2b8b25b /src
parenta5460b731d7f98296a8f76fcca293e6cc9521eb1 (diff)
downloadhdf5-88b7d8d34cd1c645c22197d440115c05435c816a.zip
hdf5-88b7d8d34cd1c645c22197d440115c05435c816a.tar.gz
hdf5-88b7d8d34cd1c645c22197d440115c05435c816a.tar.bz2
[svn-r26261] Commit working but incomplete prototype. Does not perform I/O.
Tested: ummon
Diffstat (limited to 'src')
-rw-r--r--src/H5Dint.c3
-rw-r--r--src/H5Dlayout.c1
-rw-r--r--src/H5Doh.c11
-rw-r--r--src/H5Dpkg.h3
-rw-r--r--src/H5Dprivate.h5
-rw-r--r--src/H5Dvirtual.c33
-rw-r--r--src/H5HG.c44
-rw-r--r--src/H5HGprivate.h1
-rw-r--r--src/H5Olayout.c15
-rw-r--r--src/H5Pdcpl.c113
10 files changed, 130 insertions, 99 deletions
diff --git a/src/H5Dint.c b/src/H5Dint.c
index 61a2ed7..056b07b 100644
--- a/src/H5Dint.c
+++ b/src/H5Dint.c
@@ -1912,9 +1912,10 @@ H5D__get_offset(const H5D_t *dset)
HDassert(dset);
switch(dset->shared->layout.type) {
+ case H5D_VIRTUAL:
+ HDassert(0 && "checking code coverage...");//VDSINC
case H5D_CHUNKED:
case H5D_COMPACT:
- case H5D_VIRTUAL:
break;
case H5D_CONTIGUOUS:
diff --git a/src/H5Dlayout.c b/src/H5Dlayout.c
index 0dbe4db..5929163 100644
--- a/src/H5Dlayout.c
+++ b/src/H5Dlayout.c
@@ -174,7 +174,6 @@ H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t includ
break;
case H5D_VIRTUAL:
- HDassert((layout->storage.u.virt.list_nused > 0) && "checking code coverage...");//VDSINC
ret_value += H5F_SIZEOF_ADDR(f); /* Address of global heap */
ret_value += 4; /* Global heap index */
break;
diff --git a/src/H5Doh.c b/src/H5Doh.c
index a688fe7..39a270f 100644
--- a/src/H5Doh.c
+++ b/src/H5Doh.c
@@ -399,7 +399,16 @@ 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 determine chunked dataset btree info")
} /* end if */
else if(layout.type == H5D_VIRTUAL && H5D__virtual_is_space_alloc(&layout.storage)) {
- HDassert(0 && "Not yet implemented...");//VDSINC
+ size_t virtual_heap_size;
+ /* Need to write a test for this. No assert here for now because the
+ * code is reached by h5_verify_cached_stabs() but it is not properly
+ * tested. VDSINC */
+ /* Get size of global heap object for virtual dataset */
+ if(H5HG_get_obj_size(f, dxpl_id, &(layout.storage.u.virt.serial_list_hobjid), &virtual_heap_size) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get global heap size for virtual dataset mapping")
+
+ /* Return heap size */
+ bh_info->heap_size = (hsize_t)virtual_heap_size;
} /* end if */
/* Check for External File List message in the object header */
diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h
index ac6896f..847cec9 100644
--- a/src/H5Dpkg.h
+++ b/src/H5Dpkg.h
@@ -654,6 +654,9 @@ H5_DLL herr_t H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *storage_src
H5O_copy_t *cpy_info, hid_t dxpl_id);
/* Functions that operate on virtual dataset storage */
+H5_DLL herr_t H5D__virtual_copy_layout(H5O_layout_t *layout);
+H5_DLL herr_t H5D__virtual_reset_layout(H5O_layout_t *layout);
+H5_DLL herr_t H5D__virtual_delete(H5F_t *f, hid_t dxpl_id, H5O_storage_t *storage);
H5_DLL herr_t H5D__virtual_copy(H5F_t *f_src,
const H5O_storage_virtual_t *storage_src, H5F_t *f_dst,
H5O_storage_virtual_t *storage_dst, H5T_t *dt_src, H5O_copy_t *cpy_info,
diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h
index 11c9fac..b2d88ee 100644
--- a/src/H5Dprivate.h
+++ b/src/H5Dprivate.h
@@ -177,11 +177,6 @@ H5_DLL herr_t H5D_vlen_reclaim(hid_t type_id, H5S_t *space, hid_t plist_id,
/* Functions that operate on chunked storage */
H5_DLL herr_t H5D_chunk_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr);
-/* Functions that operate on virtual storage */
-herr_t H5D_virtual_copy_layout(H5O_layout_t *layout);
-herr_t H5D_virtual_reset_layout(H5O_layout_t *layout);
-herr_t H5D_virtual_delete(H5F_t *f, hid_t dxpl_id, H5O_storage_t *storage);
-
/* 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,
int indent, int fwidth, unsigned ndims);
diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c
index 5e9decd..7e74af7 100644
--- a/src/H5Dvirtual.c
+++ b/src/H5Dvirtual.c
@@ -99,7 +99,7 @@ const H5D_layout_ops_t H5D_LOPS_VIRTUAL[1] = {{
/*-------------------------------------------------------------------------
- * Function: H5D_virtual_copy_layout
+ * Function: H5D__virtual_copy_layout
*
* Purpose: Deep copies virtual storage layout message in memory.
* This function assumes that the top-level struct has
@@ -114,19 +114,18 @@ const H5D_layout_ops_t H5D_LOPS_VIRTUAL[1] = {{
*-------------------------------------------------------------------------
*/
herr_t
-H5D_virtual_copy_layout(H5O_layout_t *layout)
+H5D__virtual_copy_layout(H5O_layout_t *layout)
{
H5O_storage_virtual_ent_t *orig_list = NULL;
size_t i;
herr_t ret_value = SUCCEED;
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_PACKAGE
HDassert(layout);
HDassert(layout->type == H5D_VIRTUAL);
if(layout->storage.u.virt.list_nused > 0) {
- HDassert(0 && "checking code coverage...");//VDSINC
HDassert(layout->storage.u.virt.list);
/* Save original entry list for use as the "source" */
@@ -164,15 +163,15 @@ done:
/* Release allocated resources on failure */
if((ret_value < 0) && orig_list
&& (orig_list != layout->storage.u.virt.list))
- if(H5D_virtual_reset_layout(layout) < 0)
+ if(H5D__virtual_reset_layout(layout) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to reset virtual layout")
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5D_virtual_copy_layout() */
+} /* end H5D__virtual_copy_layout() */
/*-------------------------------------------------------------------------
- * Function: H5D_virtual_reset_layout
+ * Function: H5D__virtual_reset_layout
*
* Purpose: Frees internal structures in a virtual storage layout
* message in memory. This function is safe to use on
@@ -188,12 +187,12 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5D_virtual_reset_layout(H5O_layout_t *layout)
+H5D__virtual_reset_layout(H5O_layout_t *layout)
{
size_t i;
herr_t ret_value = SUCCEED;
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_PACKAGE
HDassert(layout);
HDassert(layout->type == H5D_VIRTUAL);
@@ -215,15 +214,16 @@ H5D_virtual_reset_layout(H5O_layout_t *layout)
} /* end for */
/* Free the list */
- layout->storage.u.virt.list = (H5O_storage_virtual_ent_t *)(layout->storage.u.virt.list);
+ layout->storage.u.virt.list = (H5O_storage_virtual_ent_t *)H5MM_xfree(layout->storage.u.virt.list);
-done:
+ /* Note the lack of a done: label. This is because there are no HGOTO_ERROR
+ * calls. If one is added, a done: label must also be added */
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5D_virtual_reset_layout() */
+} /* end H5D__virtual_reset_layout() */
/*-------------------------------------------------------------------------
- * Function: H5D_virtual_delete
+ * Function: H5D__virtual_delete
*
* Purpose: Delete the file space for a virtual dataset
*
@@ -235,7 +235,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5D_virtual_delete(H5F_t *f, hid_t dxpl_id, H5O_storage_t *storage)
+H5D__virtual_delete(H5F_t *f, hid_t dxpl_id, H5O_storage_t *storage)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -258,7 +258,7 @@ H5D_virtual_delete(H5F_t *f, hid_t dxpl_id, H5O_storage_t *storage)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5D_virtual_delete */
+} /* end H5D__virtual_delete */
/*-------------------------------------------------------------------------
@@ -279,7 +279,6 @@ H5D__virtual_construct(H5F_t UNUSED *f, H5D_t UNUSED *dset)
FUNC_ENTER_STATIC_NOERR
/* No-op for now VDSINC */
- HDassert(0 && "checking code coverage...");//VDSINC
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5D__virtual_construct() */
@@ -306,7 +305,6 @@ H5D__virtual_is_space_alloc(const H5O_storage_t *storage)
FUNC_ENTER_PACKAGE_NOERR
- HDassert(0 && "checking code coverage...");//VDSINC
/* Need to decide what to do here. For now just return TRUE if the global
* heap block has been allocated. VDSINC */
ret_value = storage->u.virt.serial_list_hobjid.addr != HADDR_UNDEF;
@@ -408,7 +406,6 @@ H5D__virtual_flush(H5D_t UNUSED *dset, hid_t UNUSED dxpl_id)
FUNC_ENTER_STATIC_NOERR
/* No-op for now VDSINC */
- HDassert(0 && "checking code coverage...");//VDSINC
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5D__virtual_flush() */
diff --git a/src/H5HG.c b/src/H5HG.c
index d55eaab..71520f1 100644
--- a/src/H5HG.c
+++ b/src/H5HG.c
@@ -718,6 +718,50 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5HG_get_obj_size
+ *
+ * Purpose: Returns the size of a global heap object.
+ * Return: Success: Non-negative
+ *
+ * Failure: Negative
+ *
+ * Programmer: Neil Fortner
+ * Thursday, February 12, 2015
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5HG_get_obj_size(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, size_t *obj_size)
+{
+ H5HG_heap_t *heap = NULL; /* Pointer to global heap object */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__GLOBALHEAP_TAG, FAIL)
+
+ /* Check args */
+ HDassert(f);
+ HDassert(hobj);
+ HDassert(obj_size);
+
+ /* Load the heap */
+ if(NULL == (heap = H5HG_protect(f, dxpl_id, hobj->addr, H5AC_READ)))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect global heap")
+
+ HDassert(hobj->idx < heap->nused);
+ HDassert(heap->obj[hobj->idx].begin);
+
+ /* Set object size */
+ *obj_size = heap->obj[hobj->idx].size;
+
+done:
+ if(heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, H5AC__NO_FLAGS_SET) < 0)
+ HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
+
+ FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL)
+} /* end H5HG_get_obj_size() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5HG_remove
*
* Purpose: Removes the specified object from the global heap.
diff --git a/src/H5HGprivate.h b/src/H5HGprivate.h
index 3765c47..ad0da76 100644
--- a/src/H5HGprivate.h
+++ b/src/H5HGprivate.h
@@ -60,6 +60,7 @@ H5_DLL herr_t H5HG_insert(H5F_t *f, hid_t dxpl_id, size_t size, void *obj,
H5HG_t *hobj/*out*/);
H5_DLL void *H5HG_read(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, void *object, size_t *buf_size/*out*/);
H5_DLL int H5HG_link(H5F_t *f, hid_t dxpl_id, const H5HG_t *hobj, int adjust);
+H5_DLL herr_t H5HG_get_obj_size(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, size_t *obj_size);
H5_DLL herr_t H5HG_remove(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj);
/* Support routines */
diff --git a/src/H5Olayout.c b/src/H5Olayout.c
index 0e43824..9d4fff7 100644
--- a/src/H5Olayout.c
+++ b/src/H5Olayout.c
@@ -317,6 +317,9 @@ H5O_layout_decode(H5F_t *f, hid_t dxpl_id, H5O_t UNUSED *open_oh,
HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "incorrect heap block size")
} /* end if */
+ /* Set the layout operations */
+ mesg->ops = H5D_LOPS_VIRTUAL;
+
break;
case H5D_LAYOUT_ERROR:
@@ -333,7 +336,7 @@ done:
if(ret_value == NULL)
if(mesg) {
if(mesg->type == H5D_VIRTUAL)
- if(H5D_virtual_reset_layout(mesg) < 0)
+ if(H5D__virtual_reset_layout(mesg) < 0)
HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, NULL, "unable to reset virtual layout")
mesg = H5FL_FREE(H5O_layout_t, mesg);
} /* end if */
@@ -596,11 +599,9 @@ H5O_layout_copy(const void *_mesg, void *_dest)
H5D_chunk_idx_reset(&dest->storage.u.chunk, FALSE);
/* Deep copy the entry list for virtual datasets */
- if(mesg->type == H5D_VIRTUAL) {
- HDassert((mesg->storage.u.virt.list_nused > 0) && "checking code coverage...");//VDSINC
- if(H5D_virtual_copy_layout(dest) < 0)
+ if(mesg->type == H5D_VIRTUAL)
+ if(H5D__virtual_copy_layout(dest) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy virtual layout")
- } //VDSINC
/* Set return value */
ret_value = dest;
@@ -677,7 +678,7 @@ H5O_layout_reset(void *_mesg)
mesg->storage.u.compact.buf = H5MM_xfree(mesg->storage.u.compact.buf);
else if(H5D_VIRTUAL == mesg->type)
/* Free the virtual entry list */
- if(H5D_virtual_reset_layout(mesg) < 0)
+ if(H5D__virtual_reset_layout(mesg) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to reset virtual layout")
/* Reset the message */
@@ -768,7 +769,7 @@ H5O_layout_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, void *_mesg)
case H5D_VIRTUAL: /* Virtual dataset */
HDassert(0 && "checking code coverage...");//VDSINC
/* Free the file space virtual dataset */
- if(H5D_virtual_delete(f, dxpl_id, &mesg->storage) < 0)
+ if(H5D__virtual_delete(f, dxpl_id, &mesg->storage) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free raw data")
break;
diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c
index 6abe17d..ebd1e0a 100644
--- a/src/H5Pdcpl.c
+++ b/src/H5Pdcpl.c
@@ -85,7 +85,6 @@
#define H5D_CRT_LAYOUT_ENC H5P__dcrt_layout_enc
#define H5D_CRT_LAYOUT_DEC H5P__dcrt_layout_dec
#define H5D_CRT_LAYOUT_DEL H5P__dcrt_layout_del
-#define H5D_CRT_LAYOUT_COPY H5P__dcrt_layout_copy
#define H5D_CRT_LAYOUT_CMP H5P__dcrt_layout_cmp
#define H5D_CRT_LAYOUT_CLOSE H5P__dcrt_layout_close
/* Definitions for fill value. size=0 means fill value will be 0 as
@@ -137,7 +136,6 @@ static herr_t H5P__dcrt_close(hid_t dxpl_id, void *close_data);
static herr_t H5P__dcrt_layout_enc(const void *value, void **pp, size_t *size);
static herr_t H5P__dcrt_layout_dec(const void **pp, void *value);
static herr_t H5P__dcrt_layout_del(hid_t prop_id, const char *name, size_t size, void *value);
-static herr_t H5P__dcrt_layout_copy(const char *name, size_t size, void *value);
static int H5P__dcrt_layout_cmp(const void *value1, const void *value2, size_t size);
static herr_t H5P__dcrt_layout_close(const char *name, size_t size, void *value);
static herr_t H5P__fill_value_enc(const void *value, void **pp, size_t *size);
@@ -226,7 +224,7 @@ H5P__dcrt_reg_prop(H5P_genclass_t *pclass)
/* Register the storage layout property */
if(H5P_register_real(pclass, H5D_CRT_LAYOUT_NAME, H5D_CRT_LAYOUT_SIZE, &H5D_def_layout_g,
NULL, NULL, NULL, H5D_CRT_LAYOUT_ENC, H5D_CRT_LAYOUT_DEC,
- H5D_CRT_LAYOUT_DEL, H5D_CRT_LAYOUT_COPY, H5D_CRT_LAYOUT_CMP, H5D_CRT_LAYOUT_CLOSE) < 0)
+ H5D_CRT_LAYOUT_DEL, NULL, H5D_CRT_LAYOUT_CMP, H5D_CRT_LAYOUT_CLOSE) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
/* Register the fill value property */
@@ -330,6 +328,7 @@ H5P__dcrt_copy(hid_t dst_plist_id, hid_t src_plist_id, void UNUSED *copy_data)
case H5D_VIRTUAL:
dst_layout.storage.u.virt.serial_list_hobjid.addr = HADDR_UNDEF;
dst_layout.storage.u.virt.serial_list_hobjid.idx = 0;
+ break;
case H5D_LAYOUT_ERROR:
case H5D_NLAYOUTS:
@@ -585,58 +584,23 @@ done:
static herr_t
H5P__dcrt_layout_del(hid_t UNUSED prop_id, const char UNUSED *name, size_t UNUSED size, void *value)
{
- H5O_layout_t *layout = (H5O_layout_t *)value; /* Create local aliases for values */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
/* Sanity check */
- HDassert(layout);
+ HDassert(value);
- /* Reset the old layout befopre overwriting it if necessary */
- if(layout->type == H5D_VIRTUAL)
- if(H5D_virtual_reset_layout(layout) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "unable to reset virtual layout")
+ /* Reset the old layout */
+ if(((H5O_layout_t *)value)->type == H5D_VIRTUAL) /* Temp hack until proper fix is in trunk */
+ if(H5O_msg_reset(H5O_LAYOUT_ID, value) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't release layout message")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P__dcrt_layout_del() */
-/*--------------------------------------------------------------------------
- * Function: H5P__dcrt_layout_copy
- *
- * Purpose: Copy the layout property
- *
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: Neil Fortner
- * Monday, Feb 9, 2015
- *
- *--------------------------------------------------------------------------
- */
-static herr_t
-H5P__dcrt_layout_copy(const char UNUSED *name, size_t UNUSED size, void *value)
-{
- H5O_layout_t *layout = (H5O_layout_t *)value; /* Create local aliases for values */
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER_STATIC
-
- HDassert(layout);
-
- layout = (H5O_layout_t *)value;
-
- if(layout->type == H5D_VIRTUAL)
- if(H5D_virtual_copy_layout(layout) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy virtual layout")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5P__dcrt_layout_copy() */
-
-
/*-------------------------------------------------------------------------
* Function: H5P__dcrt_layout_cmp
*
@@ -728,18 +692,17 @@ done:
static herr_t
H5P__dcrt_layout_close(const char UNUSED *name, size_t UNUSED size, void *value)
{
- H5O_layout_t *layout = (H5O_layout_t *)value; /* Create local aliases for values */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
/* Sanity check */
- HDassert(layout);
+ HDassert(value);
- /* Reset the old layout befopre overwriting it if necessary */
- if(layout->type == H5D_VIRTUAL)
- if(H5D_virtual_reset_layout(layout) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "unable to reset virtual layout")
+ /* Reset the old layout */
+ if(((H5O_layout_t *)value)->type == H5D_VIRTUAL) /* Temp hack until proper fix is in trunk */
+ if(H5O_msg_reset(H5O_LAYOUT_ID, value) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't release layout message")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1291,12 +1254,9 @@ H5P__set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout)
if(H5P_get(plist, H5D_CRT_LAYOUT_NAME, &old_layout) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get layout")
- /* Reset the old layout before overwriting it if necessary */
- if(old_layout.type == H5D_VIRTUAL) {
- HDassert((layout->storage.u.virt.list_nused > 0) && "checking code coverage...");//VDSINC
- if(H5D_virtual_reset_layout(&old_layout) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "unable to reset virtual layout")
- } //VDSINC
+ /* Reset the old layout before overwriting it */
+ if(H5O_msg_reset(H5O_LAYOUT_ID, &old_layout) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't release layout message")
/* Set layout value */
if(H5P_set(plist, H5D_CRT_LAYOUT_NAME, layout) < 0)
@@ -1684,6 +1644,7 @@ H5Pset_virtual(hid_t dcpl_id, hid_t vspace_id, const char *src_file_name,
/* Allocate initial entry list */
if(NULL == (layout.storage.u.virt.list = (H5O_storage_virtual_ent_t *)H5MM_calloc(H5D_VIRTUAL_DEF_LIST_SIZE * sizeof(H5O_storage_virtual_ent_t))))
HGOTO_ERROR(H5E_PLIST, H5E_RESOURCE, FAIL, "can't allocate virtual dataset mapping list")
+ layout.storage.u.virt.list_nalloc = H5D_VIRTUAL_DEF_LIST_SIZE;
} /* end if */
else if(layout.storage.u.virt.list_nused
== layout.storage.u.virt.list_nalloc) {
@@ -1708,10 +1669,17 @@ H5Pset_virtual(hid_t dcpl_id, hid_t vspace_id, const char *src_file_name,
layout.storage.u.virt.list_nused++;
adding_entry = FALSE;
- /* Set chunk information in property list if we are adding a new layout */
- if(new_layout)
+ /* Set chunk information in property list. If we are adding a new layout,
+ * use H5P__set_layout so other fields are initialized properly. If we are
+ * extending the layout, just use H5P_set directly so we don't mess with
+ * anything else. */
+ if(new_layout) {
if(H5P__set_layout(plist, &layout) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set layout")
+ } /* end if */
+ else
+ if(H5P_set(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set layout")
done:
if(adding_entry) {
@@ -1752,7 +1720,6 @@ H5Pget_virtual_count(hid_t dcpl_id, size_t *count/*out*/)
FUNC_ENTER_API(FAIL)
H5TRACE2("e", "ix", dcpl_id, count);
- HDassert(0 && "checking code coverage...");//VDSINC
if(count) {
/* Get the plist structure */
@@ -1791,12 +1758,11 @@ H5Pget_virtual_vspace(hid_t dcpl_id, size_t index)
{
H5P_genplist_t *plist; /* Property list pointer */
H5O_layout_t layout; /* Layout information */
- H5S_t *space; /* Dataspace pointer */
+ H5S_t *space = NULL; /* Dataspace pointer */
hid_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE2("i", "iz", dcpl_id, index);
- HDassert(0 && "checking code coverage...");//VDSINC
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE)))
@@ -1809,8 +1775,9 @@ H5Pget_virtual_vspace(hid_t dcpl_id, size_t index)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a virtual storage layout")
/* Get the virtual space */
- if(index >= layout.storage.u.virt.list_nalloc)
+ if(index >= layout.storage.u.virt.list_nused)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid index (out of range)")
+ HDassert(layout.storage.u.virt.list_nused <= layout.storage.u.virt.list_nalloc);
if(NULL == (space = H5S_copy(layout.storage.u.virt.list[index].virtual_select, FALSE, TRUE)))
HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy virtual selection")
@@ -1819,6 +1786,11 @@ H5Pget_virtual_vspace(hid_t dcpl_id, size_t index)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data space")
done:
+ /* Free space on failure */
+ if((ret_value < 0) && space)
+ if(H5S_close(space) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release source selection")
+
FUNC_LEAVE_API(ret_value)
} /* end H5Pget_virtual_vspace() */
@@ -1840,12 +1812,11 @@ H5Pget_virtual_srcspace(hid_t dcpl_id, size_t index)
{
H5P_genplist_t *plist; /* Property list pointer */
H5O_layout_t layout; /* Layout information */
- H5S_t *space; /* Dataspace pointer */
+ H5S_t *space = NULL; /* Dataspace pointer */
hid_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE2("i", "iz", dcpl_id, index);
- HDassert(0 && "checking code coverage...");//VDSINC
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE)))
@@ -1858,8 +1829,9 @@ H5Pget_virtual_srcspace(hid_t dcpl_id, size_t index)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a virtual storage layout")
/* Get the virtual space */
- if(index >= layout.storage.u.virt.list_nalloc)
+ if(index >= layout.storage.u.virt.list_nused)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid index (out of range)")
+ HDassert(layout.storage.u.virt.list_nused <= layout.storage.u.virt.list_nalloc);
if(NULL == (space = H5S_copy(layout.storage.u.virt.list[index].source_select, FALSE, TRUE)))
HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy source selection")
@@ -1868,6 +1840,11 @@ H5Pget_virtual_srcspace(hid_t dcpl_id, size_t index)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data space")
done:
+ /* Free space on failure */
+ if((ret_value < 0) && space)
+ if(H5S_close(space) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release source selection")
+
FUNC_LEAVE_API(ret_value)
} /* end H5Pget_virtual_srcspace() */
@@ -1894,7 +1871,6 @@ H5Pget_virtual_filename(hid_t dcpl_id, size_t index, char *name/*out*/,
FUNC_ENTER_API(FAIL)
H5TRACE4("Zs", "izxz", dcpl_id, index, name, size);
- HDassert(0 && "checking code coverage...");//VDSINC
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE)))
@@ -1907,6 +1883,9 @@ H5Pget_virtual_filename(hid_t dcpl_id, size_t index, char *name/*out*/,
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a virtual storage layout")
/* Get the virtual filename */
+ if(index >= layout.storage.u.virt.list_nused)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid index (out of range)")
+ HDassert(layout.storage.u.virt.list_nused <= layout.storage.u.virt.list_nalloc);
HDassert(layout.storage.u.virt.list[index].source_file_name);
if(name && (size > 0))
(void)HDstrncpy(name, layout.storage.u.virt.list[index].source_file_name, size);
@@ -1939,7 +1918,6 @@ H5Pget_virtual_dsetname(hid_t dcpl_id, size_t index, char *name/*out*/,
FUNC_ENTER_API(FAIL)
H5TRACE4("Zs", "izxz", dcpl_id, index, name, size);
- HDassert(0 && "checking code coverage...");//VDSINC
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE)))
@@ -1952,6 +1930,9 @@ H5Pget_virtual_dsetname(hid_t dcpl_id, size_t index, char *name/*out*/,
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a virtual storage layout")
/* Get the virtual filename */
+ if(index >= layout.storage.u.virt.list_nused)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid index (out of range)")
+ HDassert(layout.storage.u.virt.list_nused <= layout.storage.u.virt.list_nalloc);
HDassert(layout.storage.u.virt.list[index].source_dset_name);
if(name && (size > 0))
(void)HDstrncpy(name, layout.storage.u.virt.list[index].source_dset_name, size);