From fe4fe14515ae5db886e4e2b10b50d7f12ca1320d Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Tue, 18 Aug 2020 07:23:19 -0700 Subject: Merge of develop PRs to 1.10 --- src/H5Dvirtual.c | 204 ++++++++++++++++++++++++++++-------------------------- src/H5FDcore.c | 4 ++ src/H5FDlog.c | 21 ++++++ src/H5FDprivate.h | 2 + src/H5FDsec2.c | 21 ++++++ 5 files changed, 155 insertions(+), 97 deletions(-) diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c index 6cd6263..0136509 100644 --- a/src/H5Dvirtual.c +++ b/src/H5Dvirtual.c @@ -313,6 +313,8 @@ done: herr_t H5D_virtual_update_min_dims(H5O_layout_t *layout, size_t idx) { + H5O_storage_virtual_t *virt = &layout->storage.u.virt; + H5O_storage_virtual_ent_t *ent = &virt->list[idx]; H5S_sel_type sel_type; int rank; hsize_t bounds_start[H5S_MAX_RANK]; @@ -324,10 +326,10 @@ H5D_virtual_update_min_dims(H5O_layout_t *layout, size_t idx) HDassert(layout); HDassert(layout->type == H5D_VIRTUAL); - HDassert(idx < layout->storage.u.virt.list_nalloc); + HDassert(idx < virt->list_nalloc); /* Get type of selection */ - if(H5S_SEL_ERROR == (sel_type = H5S_GET_SELECT_TYPE(layout->storage.u.virt.list[idx].source_dset.virtual_select))) + if(H5S_SEL_ERROR == (sel_type = H5S_GET_SELECT_TYPE(ent->source_dset.virtual_select))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get selection type") /* Do not update min_dims for "all" or "none" selections */ @@ -335,19 +337,19 @@ H5D_virtual_update_min_dims(H5O_layout_t *layout, size_t idx) HGOTO_DONE(SUCCEED) /* Get rank of vspace */ - if((rank = H5S_GET_EXTENT_NDIMS(layout->storage.u.virt.list[idx].source_dset.virtual_select)) < 0) + if((rank = H5S_GET_EXTENT_NDIMS(ent->source_dset.virtual_select)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get number of dimensions") /* Get selection bounds */ - if(H5S_SELECT_BOUNDS(layout->storage.u.virt.list[idx].source_dset.virtual_select, bounds_start, bounds_end) < 0) + if(H5S_SELECT_BOUNDS(ent->source_dset.virtual_select, bounds_start, bounds_end) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get selection bounds") /* Update min_dims */ for(i = 0; i < rank; i++) /* Don't check unlimited dimensions in the selection */ - if((i != layout->storage.u.virt.list[idx].unlim_dim_virtual) - && (bounds_end[i] >= layout->storage.u.virt.min_dims[i])) - layout->storage.u.virt.min_dims[i] = bounds_end[i] + (hsize_t)1; + if((i != ent->unlim_dim_virtual) + && (bounds_end[i] >= virt->min_dims[i])) + virt->min_dims[i] = bounds_end[i] + (hsize_t)1; done: FUNC_LEAVE_NOAPI(ret_value) @@ -419,6 +421,7 @@ done: herr_t H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout) { + H5O_storage_virtual_t *virt = &layout->storage.u.virt; uint8_t *heap_block = NULL; /* Block to add to heap */ size_t *str_size = NULL; /* Array for VDS entry string lengths */ uint8_t *heap_block_p; /* Pointer into the heap block, while encoding */ @@ -433,16 +436,16 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout) /* Sanity checking */ HDassert(f); HDassert(layout); - HDassert(layout->storage.u.virt.serial_list_hobjid.addr == HADDR_UNDEF); + HDassert(virt->serial_list_hobjid.addr == HADDR_UNDEF); /* Create block if # of used entries > 0 */ - if(layout->storage.u.virt.list_nused > 0) { + if(virt->list_nused > 0) { /* Set the low/high bounds according to 'f' for the API context */ H5CX_set_libver_bounds(f); /* Allocate array for caching results of strlen */ - if(NULL == (str_size = (size_t *)H5MM_malloc(2 * layout->storage.u.virt.list_nused * sizeof(size_t)))) + if(NULL == (str_size = (size_t *)H5MM_malloc(2 * virt->list_nused * sizeof(size_t)))) HGOTO_ERROR(H5E_OHDR, H5E_RESOURCE, FAIL, "unable to allocate string length array") /* @@ -453,29 +456,30 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout) block_size = (size_t)1 + H5F_SIZEOF_SIZE(f); /* Calculate size of each entry */ - for(i = 0; i < layout->storage.u.virt.list_nused; i++) { + for(i = 0; i < virt->list_nused; i++) { + H5O_storage_virtual_ent_t *ent = &virt->list[i]; hssize_t select_serial_size; /* Size of serialized selection */ - HDassert(layout->storage.u.virt.list[i].source_file_name); - HDassert(layout->storage.u.virt.list[i].source_dset_name); - HDassert(layout->storage.u.virt.list[i].source_select); - HDassert(layout->storage.u.virt.list[i].source_dset.virtual_select); + HDassert(ent->source_file_name); + HDassert(ent->source_dset_name); + HDassert(ent->source_select); + HDassert(ent->source_dset.virtual_select); /* Source file name */ - str_size[2 * i] = HDstrlen(layout->storage.u.virt.list[i].source_file_name) + (size_t)1; + str_size[2 * i] = HDstrlen(ent->source_file_name) + (size_t)1; block_size += str_size[2 * i]; /* Source dset name */ - str_size[(2 * i) + 1] = HDstrlen(layout->storage.u.virt.list[i].source_dset_name) + (size_t)1; + str_size[(2 * i) + 1] = HDstrlen(ent->source_dset_name) + (size_t)1; block_size += str_size[(2 * i) + 1]; /* Source selection */ - if((select_serial_size = H5S_SELECT_SERIAL_SIZE(layout->storage.u.virt.list[i].source_select)) < 0) + if((select_serial_size = H5S_SELECT_SERIAL_SIZE(ent->source_select)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to check dataspace selection size") block_size += (size_t)select_serial_size; /* Virtual dataset selection */ - if((select_serial_size = H5S_SELECT_SERIAL_SIZE(layout->storage.u.virt.list[i].source_dset.virtual_select)) < 0) + if((select_serial_size = H5S_SELECT_SERIAL_SIZE(ent->source_dset.virtual_select)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to check dataspace selection size") block_size += (size_t)select_serial_size; } /* end for */ @@ -498,25 +502,26 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout) *heap_block_p++ = (uint8_t)H5O_LAYOUT_VDS_GH_ENC_VERS; /* Number of entries */ - tmp_nentries = (hsize_t)layout->storage.u.virt.list_nused; + tmp_nentries = (hsize_t)virt->list_nused; H5F_ENCODE_LENGTH(f, heap_block_p, tmp_nentries) /* Encode each entry */ - for(i = 0; i < layout->storage.u.virt.list_nused; i++) { + for(i = 0; i < virt->list_nused; i++) { + H5O_storage_virtual_ent_t *ent = &virt->list[i]; /* Source file name */ - H5MM_memcpy((char *)heap_block_p, layout->storage.u.virt.list[i].source_file_name, str_size[2 * i]); + H5MM_memcpy((char *)heap_block_p, ent->source_file_name, str_size[2 * i]); heap_block_p += str_size[2 * i]; /* Source dataset name */ - H5MM_memcpy((char *)heap_block_p, layout->storage.u.virt.list[i].source_dset_name, str_size[(2 * i) + 1]); + H5MM_memcpy((char *)heap_block_p, ent->source_dset_name, str_size[(2 * i) + 1]); heap_block_p += str_size[(2 * i) + 1]; /* Source selection */ - if(H5S_SELECT_SERIALIZE(layout->storage.u.virt.list[i].source_select, &heap_block_p) < 0) + if(H5S_SELECT_SERIALIZE(ent->source_select, &heap_block_p) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to serialize source selection") /* Virtual selection */ - if(H5S_SELECT_SERIALIZE(layout->storage.u.virt.list[i].source_dset.virtual_select, &heap_block_p) < 0) + if(H5S_SELECT_SERIALIZE(ent->source_dset.virtual_select, &heap_block_p) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to serialize virtual selection") } /* end for */ @@ -525,7 +530,7 @@ H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout) UINT32ENCODE(heap_block_p, chksum) /* Insert block into global heap */ - if(H5HG_insert(f, block_size, heap_block, &(layout->storage.u.virt.serial_list_hobjid)) < 0) /* Casting away const OK --NAF */ + if(H5HG_insert(f, block_size, heap_block, &(virt->serial_list_hobjid)) < 0) /* Casting away const OK --NAF */ HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to insert virtual dataset heap block") } /* end if */ @@ -556,6 +561,7 @@ herr_t H5D__virtual_copy_layout(H5O_layout_t *layout) { H5O_storage_virtual_ent_t *orig_list = NULL; + H5O_storage_virtual_t *virt = &layout->storage.u.virt; hid_t orig_source_fapl; hid_t orig_source_dapl; H5P_genplist_t *plist; @@ -569,127 +575,129 @@ H5D__virtual_copy_layout(H5O_layout_t *layout) /* Save original entry list and top-level property lists and reset in layout * so the originals aren't closed on error */ - orig_source_fapl = layout->storage.u.virt.source_fapl; - layout->storage.u.virt.source_fapl = -1; - orig_source_dapl = layout->storage.u.virt.source_dapl; - layout->storage.u.virt.source_dapl = -1; - orig_list = layout->storage.u.virt.list; - layout->storage.u.virt.list = NULL; + orig_source_fapl = virt->source_fapl; + virt->source_fapl = -1; + orig_source_dapl = virt->source_dapl; + virt->source_dapl = -1; + orig_list = virt->list; + virt->list = NULL; /* Copy entry list */ - if(layout->storage.u.virt.list_nused > 0) { + if(virt->list_nused > 0) { HDassert(orig_list); /* Allocate memory for the list */ - if(NULL == (layout->storage.u.virt.list = (H5O_storage_virtual_ent_t *)H5MM_calloc(layout->storage.u.virt.list_nused * sizeof(H5O_storage_virtual_ent_t)))) + if(NULL == (virt->list = H5MM_calloc(virt->list_nused * sizeof(virt->list[0])))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate memory for virtual dataset entry list") - layout->storage.u.virt.list_nalloc = layout->storage.u.virt.list_nused; + virt->list_nalloc = virt->list_nused; /* Copy the list entries, though set source_dset.dset and sub_dset to * NULL */ - for(i = 0; i < layout->storage.u.virt.list_nused; i++) { + for(i = 0; i < virt->list_nused; i++) { + H5O_storage_virtual_ent_t *ent = &virt->list[i]; + /* Copy virtual selection */ - if(NULL == (layout->storage.u.virt.list[i].source_dset.virtual_select + if(NULL == (ent->source_dset.virtual_select = H5S_copy(orig_list[i].source_dset.virtual_select, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy virtual selection") /* Copy original source names */ - if(NULL == (layout->storage.u.virt.list[i].source_file_name + if(NULL == (ent->source_file_name = H5MM_strdup(orig_list[i].source_file_name))) HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source file name") - if(NULL == (layout->storage.u.virt.list[i].source_dset_name + if(NULL == (ent->source_dset_name = H5MM_strdup(orig_list[i].source_dset_name))) HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source dataset name") /* Copy source selection */ - if(NULL == (layout->storage.u.virt.list[i].source_select + if(NULL == (ent->source_select = H5S_copy(orig_list[i].source_select, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy source selection") /* Initialize clipped selections */ if(orig_list[i].unlim_dim_virtual < 0) { - layout->storage.u.virt.list[i].source_dset.clipped_source_select = layout->storage.u.virt.list[i].source_select; - layout->storage.u.virt.list[i].source_dset.clipped_virtual_select = layout->storage.u.virt.list[i].source_dset.virtual_select; + ent->source_dset.clipped_source_select = ent->source_select; + ent->source_dset.clipped_virtual_select = ent->source_dset.virtual_select; } /* end if */ /* Copy parsed names */ - if(H5D__virtual_copy_parsed_name(&layout->storage.u.virt.list[i].parsed_source_file_name, orig_list[i].parsed_source_file_name) < 0) + if(H5D__virtual_copy_parsed_name(&ent->parsed_source_file_name, orig_list[i].parsed_source_file_name) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy parsed source file name") - layout->storage.u.virt.list[i].psfn_static_strlen = orig_list[i].psfn_static_strlen; - layout->storage.u.virt.list[i].psfn_nsubs = orig_list[i].psfn_nsubs; - if(H5D__virtual_copy_parsed_name(&layout->storage.u.virt.list[i].parsed_source_dset_name, orig_list[i].parsed_source_dset_name) < 0) + ent->psfn_static_strlen = orig_list[i].psfn_static_strlen; + ent->psfn_nsubs = orig_list[i].psfn_nsubs; + if(H5D__virtual_copy_parsed_name(&ent->parsed_source_dset_name, orig_list[i].parsed_source_dset_name) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy parsed source dataset name") - layout->storage.u.virt.list[i].psdn_static_strlen = orig_list[i].psdn_static_strlen; - layout->storage.u.virt.list[i].psdn_nsubs = orig_list[i].psdn_nsubs; + ent->psdn_static_strlen = orig_list[i].psdn_static_strlen; + ent->psdn_nsubs = orig_list[i].psdn_nsubs; /* Copy source names in source dset or add reference as appropriate */ if(orig_list[i].source_dset.file_name) { if(orig_list[i].source_dset.file_name == orig_list[i].source_file_name) - layout->storage.u.virt.list[i].source_dset.file_name = layout->storage.u.virt.list[i].source_file_name; + ent->source_dset.file_name = ent->source_file_name; else if(orig_list[i].parsed_source_file_name && (orig_list[i].source_dset.file_name != orig_list[i].parsed_source_file_name->name_segment)) { - HDassert(layout->storage.u.virt.list[i].parsed_source_file_name); - HDassert(layout->storage.u.virt.list[i].parsed_source_file_name->name_segment); - layout->storage.u.virt.list[i].source_dset.file_name = layout->storage.u.virt.list[i].parsed_source_file_name->name_segment; + HDassert(ent->parsed_source_file_name); + HDassert(ent->parsed_source_file_name->name_segment); + ent->source_dset.file_name = ent->parsed_source_file_name->name_segment; } /* end if */ else - if(NULL == (layout->storage.u.virt.list[i].source_dset.file_name + if(NULL == (ent->source_dset.file_name = H5MM_strdup(orig_list[i].source_dset.file_name))) HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source file name") } /* end if */ if(orig_list[i].source_dset.dset_name) { if(orig_list[i].source_dset.dset_name == orig_list[i].source_dset_name) - layout->storage.u.virt.list[i].source_dset.dset_name = layout->storage.u.virt.list[i].source_dset_name; + ent->source_dset.dset_name = ent->source_dset_name; else if(orig_list[i].parsed_source_dset_name && (orig_list[i].source_dset.dset_name != orig_list[i].parsed_source_dset_name->name_segment)) { - HDassert(layout->storage.u.virt.list[i].parsed_source_dset_name); - HDassert(layout->storage.u.virt.list[i].parsed_source_dset_name->name_segment); - layout->storage.u.virt.list[i].source_dset.dset_name = layout->storage.u.virt.list[i].parsed_source_dset_name->name_segment; + HDassert(ent->parsed_source_dset_name); + HDassert(ent->parsed_source_dset_name->name_segment); + ent->source_dset.dset_name = ent->parsed_source_dset_name->name_segment; } /* end if */ else - if(NULL == (layout->storage.u.virt.list[i].source_dset.dset_name + if(NULL == (ent->source_dset.dset_name = H5MM_strdup(orig_list[i].source_dset.dset_name))) HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source dataset name") } /* end if */ /* Copy other fields in entry */ - layout->storage.u.virt.list[i].unlim_dim_source = orig_list[i].unlim_dim_source; - layout->storage.u.virt.list[i].unlim_dim_virtual = orig_list[i].unlim_dim_virtual; - layout->storage.u.virt.list[i].unlim_extent_source = orig_list[i].unlim_extent_source; - layout->storage.u.virt.list[i].unlim_extent_virtual = orig_list[i].unlim_extent_virtual; - layout->storage.u.virt.list[i].clip_size_source = orig_list[i].clip_size_source; - layout->storage.u.virt.list[i].clip_size_virtual = orig_list[i].clip_size_virtual; - layout->storage.u.virt.list[i].source_space_status = orig_list[i].source_space_status; - layout->storage.u.virt.list[i].virtual_space_status = orig_list[i].virtual_space_status; + ent->unlim_dim_source = orig_list[i].unlim_dim_source; + ent->unlim_dim_virtual = orig_list[i].unlim_dim_virtual; + ent->unlim_extent_source = orig_list[i].unlim_extent_source; + ent->unlim_extent_virtual = orig_list[i].unlim_extent_virtual; + ent->clip_size_source = orig_list[i].clip_size_source; + ent->clip_size_virtual = orig_list[i].clip_size_virtual; + ent->source_space_status = orig_list[i].source_space_status; + ent->virtual_space_status = orig_list[i].virtual_space_status; } /* end for */ } /* end if */ else { /* Zero out other fields related to list, just to be sure */ - layout->storage.u.virt.list = NULL; - layout->storage.u.virt.list_nalloc = 0; + virt->list = NULL; + virt->list_nalloc = 0; } /* end else */ /* Copy property lists */ if(orig_source_fapl >= 0) { if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(orig_source_fapl, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - if((layout->storage.u.virt.source_fapl = H5P_copy_plist(plist, FALSE)) < 0) + if((virt->source_fapl = H5P_copy_plist(plist, FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy fapl") } /* end if */ if(orig_source_dapl >= 0) { if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(orig_source_dapl, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - if((layout->storage.u.virt.source_dapl = H5P_copy_plist(plist, FALSE)) < 0) + if((virt->source_dapl = H5P_copy_plist(plist, FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy dapl") } /* end if */ /* New layout is not fully initialized */ - layout->storage.u.virt.init = FALSE; + virt->init = FALSE; done: /* Release allocated resources on failure */ @@ -721,6 +729,7 @@ herr_t H5D__virtual_reset_layout(H5O_layout_t *layout) { size_t i, j; + H5O_storage_virtual_t *virt = &layout->storage.u.virt; herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -731,53 +740,54 @@ H5D__virtual_reset_layout(H5O_layout_t *layout) /* Free the list entries. Note we always attempt to free everything even in * the case of a failure. Because of this, and because we free the list * afterwards, we do not need to zero out the memory in the list. */ - for(i = 0; i < layout->storage.u.virt.list_nused; i++) { + for(i = 0; i < virt->list_nused; i++) { + H5O_storage_virtual_ent_t *ent = &virt->list[i]; /* Free source_dset */ - if(H5D__virtual_reset_source_dset(&layout->storage.u.virt.list[i], &layout->storage.u.virt.list[i].source_dset) < 0) + if(H5D__virtual_reset_source_dset(ent, &ent->source_dset) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to reset source dataset") /* Free original source names */ - (void)H5MM_xfree(layout->storage.u.virt.list[i].source_file_name); - (void)H5MM_xfree(layout->storage.u.virt.list[i].source_dset_name); + (void)H5MM_xfree(ent->source_file_name); + (void)H5MM_xfree(ent->source_dset_name); /* Free sub_dset */ - for(j = 0; j < layout->storage.u.virt.list[i].sub_dset_nalloc; j++) - if(H5D__virtual_reset_source_dset(&layout->storage.u.virt.list[i], &layout->storage.u.virt.list[i].sub_dset[j]) < 0) + for(j = 0; j < ent->sub_dset_nalloc; j++) + if(H5D__virtual_reset_source_dset(ent, &ent->sub_dset[j]) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to reset source dataset") - layout->storage.u.virt.list[i].sub_dset = (H5O_storage_virtual_srcdset_t *)H5MM_xfree(layout->storage.u.virt.list[i].sub_dset); + ent->sub_dset = H5MM_xfree(ent->sub_dset); /* Free source_select */ - if(layout->storage.u.virt.list[i].source_select) - if(H5S_close(layout->storage.u.virt.list[i].source_select) < 0) + if(ent->source_select) + if(H5S_close(ent->source_select) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release source selection") /* Free parsed_source_file_name */ - H5D_virtual_free_parsed_name(layout->storage.u.virt.list[i].parsed_source_file_name); + H5D_virtual_free_parsed_name(ent->parsed_source_file_name); /* Free parsed_source_dset_name */ - H5D_virtual_free_parsed_name(layout->storage.u.virt.list[i].parsed_source_dset_name); - } /* end for */ + H5D_virtual_free_parsed_name(ent->parsed_source_dset_name); + } /* Free the list */ - layout->storage.u.virt.list = (H5O_storage_virtual_ent_t *)H5MM_xfree(layout->storage.u.virt.list); - layout->storage.u.virt.list_nalloc = (size_t)0; - layout->storage.u.virt.list_nused = (size_t)0; - (void)HDmemset(layout->storage.u.virt.min_dims, 0, sizeof(layout->storage.u.virt.min_dims)); + virt->list = H5MM_xfree(virt->list); + virt->list_nalloc = (size_t)0; + virt->list_nused = (size_t)0; + (void)HDmemset(virt->min_dims, 0, sizeof(virt->min_dims)); /* Close access property lists */ - if(layout->storage.u.virt.source_fapl >= 0) { - if(H5I_dec_ref(layout->storage.u.virt.source_fapl) < 0) + if(virt->source_fapl >= 0) { + if(H5I_dec_ref(virt->source_fapl) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't close source fapl") - layout->storage.u.virt.source_fapl = -1; - } /* end if */ - if(layout->storage.u.virt.source_dapl >= 0) { - if(H5I_dec_ref(layout->storage.u.virt.source_dapl) < 0) + virt->source_fapl = -1; + } + if(virt->source_dapl >= 0) { + if(H5I_dec_ref(virt->source_dapl) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't close source dapl") - layout->storage.u.virt.source_dapl = -1; - } /* end if */ + virt->source_dapl = -1; + } /* The list is no longer initialized */ - layout->storage.u.virt.init = FALSE; + virt->init = FALSE; /* 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 */ @@ -2781,7 +2791,7 @@ H5D__virtual_write_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, * extent in the unlimited dimension. -NAF */ /* Project intersection of file space and mapping virtual space onto * mapping source space */ - if(H5S_select_project_intersection(source_dset->virtual_select, source_dset->clipped_source_select, file_space, &projected_src_space, TRUE) < 0) + if(H5S_select_project_intersection(source_dset->clipped_virtual_select, source_dset->clipped_source_select, file_space, &projected_src_space, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "can't project virtual intersection onto source space") /* Perform write on source dataset */ diff --git a/src/H5FDcore.c b/src/H5FDcore.c index 7608d61..14c896a 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -381,7 +381,9 @@ H5FD__core_write_to_bstore(H5FD_core_t *file, haddr_t addr, size_t size) int myerrno = errno; time_t mytime = HDtime(NULL); +#ifndef H5_HAVE_PREADWRITE offset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR); +#endif /* H5_HAVE_PREADWRITE */ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "write to backing store failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', ptr = %p, total write size = %llu, bytes this sub-write = %llu, bytes actually written = %llu, offset = %llu", HDctime(&mytime), file->name, file->fd, myerrno, HDstrerror(myerrno), ptr, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_wrote, (unsigned long long)offset); } /* end if */ @@ -803,7 +805,9 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr int myerrno = errno; time_t mytime = HDtime(NULL); +#ifndef H5_HAVE_PREADWRITE offset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR); +#endif /* H5_HAVE_PREADWRITE */ HGOTO_ERROR(H5E_IO, H5E_READERROR, NULL, "file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', file->mem = %p, total read size = %llu, bytes this sub-read = %llu, bytes actually read = %llu, offset = %llu", HDctime(&mytime), file->name, file->fd, myerrno, HDstrerror(myerrno), file->mem, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_read, (unsigned long long)offset); } /* end if */ diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 5d1b536..cbd475f 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -81,8 +81,10 @@ typedef struct H5FD_log_t { int fd; /* the unix file */ haddr_t eoa; /* end of allocated region */ haddr_t eof; /* end of file; current file size */ +#ifndef H5_HAVE_PREADWRITE haddr_t pos; /* current file I/O position */ H5FD_file_op_t op; /* last operation */ +#endif /* H5_HAVE_PREADWRITE */ hbool_t ignore_disabled_file_locks; char filename[H5FD_MAX_FILENAME_LEN]; /* Copy of file name from open operation */ #ifndef H5_HAVE_WIN32_API @@ -571,8 +573,10 @@ H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) file->fd = fd; H5_CHECKED_ASSIGN(file->eof, haddr_t, sb.st_size, h5_stat_size_t); +#ifndef H5_HAVE_PREADWRITE file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; +#endif /* H5_HAVE_PREADWRITE */ #ifdef H5_HAVE_WIN32_API file->hFile = (HANDLE)_get_osfhandle(fd); if(INVALID_HANDLE_VALUE == file->hFile) @@ -1280,7 +1284,9 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had int myerrno = errno; time_t mytime = HDtime(NULL); +#ifndef H5_HAVE_PREADWRITE offset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR); +#endif /* H5_HAVE_PREADWRITE */ if(file->fa.flags & H5FD_LOG_LOC_READ) HDfprintf(file->logfp, "Error! Reading: %10a-%10a (%10Zu bytes)\n", orig_addr, (orig_addr + orig_size) - 1, orig_size); @@ -1337,15 +1343,19 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had HDfprintf(file->logfp, "\n"); } /* end if */ +#ifndef H5_HAVE_PREADWRITE /* Update current position */ file->pos = addr; file->op = OP_READ; +#endif /* H5_HAVE_PREADWRITE */ done: if(ret_value < 0) { +#ifndef H5_HAVE_PREADWRITE /* Reset last file I/O information */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; +#endif /* H5_HAVE_PREADWRITE */ } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -1489,7 +1499,9 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha int myerrno = errno; time_t mytime = HDtime(NULL); +#ifndef H5_HAVE_PREADWRITE offset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR); +#endif /* H5_HAVE_PREADWRITE */ if(file->fa.flags & H5FD_LOG_LOC_WRITE) HDfprintf(file->logfp, "Error! Writing: %10a-%10a (%10Zu bytes)\n", orig_addr, (orig_addr + orig_size) - 1, orig_size); @@ -1541,17 +1553,24 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha HDfprintf(file->logfp, "\n"); } /* end if */ +#ifndef H5_HAVE_PREADWRITE /* Update current position and eof */ file->pos = addr; file->op = OP_WRITE; if(file->pos > file->eof) file->eof = file->pos; +#else /* H5_HAVE_PREADWRITE */ + if(addr > file->eof) + file->eof = addr; +#endif /* H5_HAVE_PREADWRITE */ done: if(ret_value < 0) { +#ifndef H5_HAVE_PREADWRITE /* Reset last file I/O information */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; +#endif /* H5_HAVE_PREADWRITE */ } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -1656,9 +1675,11 @@ H5FD__log_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_ /* Update the eof value */ file->eof = file->eoa; +#ifndef H5_HAVE_PREADWRITE /* Reset last file I/O information */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; +#endif /* H5_HAVE_PREADWRITE */ } /* end if */ done: diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h index c5bc043..c7994ac 100644 --- a/src/H5FDprivate.h +++ b/src/H5FDprivate.h @@ -59,12 +59,14 @@ typedef struct H5FD_class_mpi_t { /* Library Private Typedefs */ /****************************/ +#ifndef H5_HAVE_PREADWRITE /* File operations */ typedef enum { OP_UNKNOWN = 0, /* Unknown last file operation */ OP_READ = 1, /* Last file I/O operation was a read */ OP_WRITE = 2 /* Last file I/O operation was a write */ } H5FD_file_op_t; +#endif /* H5_HAVE_PREADWRITE */ /* Define structure to hold initial file image and other relevant information */ diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index 147d08f..6a16838 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -58,8 +58,10 @@ typedef struct H5FD_sec2_t { int fd; /* the filesystem file descriptor */ haddr_t eoa; /* end of allocated region */ haddr_t eof; /* end of file; current file size */ +#ifndef H5_HAVE_PREADWRITE haddr_t pos; /* current file I/O position */ H5FD_file_op_t op; /* last operation */ +#endif /* H5_HAVE_PREADWRITE */ hbool_t ignore_disabled_file_locks; char filename[H5FD_MAX_FILENAME_LEN]; /* Copy of file name from open operation */ #ifndef H5_HAVE_WIN32_API @@ -369,8 +371,10 @@ H5FD__sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr file->fd = fd; H5_CHECKED_ASSIGN(file->eof, haddr_t, sb.st_size, h5_stat_size_t); +#ifndef H5_HAVE_PREADWRITE file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; +#endif /* H5_HAVE_PREADWRITE */ #ifdef H5_HAVE_WIN32_API file->hFile = (HANDLE)_get_osfhandle(fd); if(INVALID_HANDLE_VALUE == file->hFile) @@ -748,7 +752,9 @@ H5FD__sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU int myerrno = errno; time_t mytime = HDtime(NULL); +#ifndef H5_HAVE_PREADWRITE offset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR); +#endif /* H5_HAVE_PREADWRITE */ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', buf = %p, total read size = %llu, bytes this sub-read = %llu, bytes actually read = %llu, offset = %llu", HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_read, (unsigned long long)offset); } /* end if */ @@ -767,15 +773,19 @@ H5FD__sec2_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU buf = (char *)buf + bytes_read; } /* end while */ +#ifndef H5_HAVE_PREADWRITE /* Update current position */ file->pos = addr; file->op = OP_READ; +#endif /* H5_HAVE_PREADWRITE */ done: if(ret_value < 0) { +#ifndef H5_HAVE_PREADWRITE /* Reset last file I/O information */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; +#endif /* H5_HAVE_PREADWRITE */ } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -851,7 +861,9 @@ H5FD__sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN int myerrno = errno; time_t mytime = HDtime(NULL); +#ifndef H5_HAVE_PREADWRITE offset = HDlseek(file->fd, (HDoff_t)0, SEEK_CUR); +#endif /* H5_HAVE_PREADWRITE */ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed: time = %s, filename = '%s', file descriptor = %d, errno = %d, error message = '%s', buf = %p, total write size = %llu, bytes this sub-write = %llu, bytes actually written = %llu, offset = %llu", HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_wrote, (unsigned long long)offset); } /* end if */ @@ -864,17 +876,24 @@ H5FD__sec2_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN buf = (const char *)buf + bytes_wrote; } /* end while */ +#ifndef H5_HAVE_PREADWRITE /* Update current position and eof */ file->pos = addr; file->op = OP_WRITE; if(file->pos > file->eof) file->eof = file->pos; +#else /* H5_HAVE_PREADWRITE */ + if(addr > file->eof) + file->eof = addr; +#endif /* H5_HAVE_PREADWRITE */ done: if(ret_value < 0) { +#ifndef H5_HAVE_PREADWRITE /* Reset last file I/O information */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; +#endif /* H5_HAVE_PREADWRITE */ } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -940,9 +959,11 @@ H5FD__sec2_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR /* Update the eof value */ file->eof = file->eoa; +#ifndef H5_HAVE_PREADWRITE /* Reset last file I/O information */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; +#endif /* H5_HAVE_PREADWRITE */ } /* end if */ done: -- cgit v0.12