From 59bb0124f92d915f03ffb5654d078631da8927f1 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Fri, 15 Jan 2016 13:53:37 -0500 Subject: [svn-r28912] Merge of r28908 from revise_chunks. Tested on: 64-bit Ubuntu 15.10 (Linux 4.2.0 x86_64) gcc 5.2.1 autotools serial w/ C++ and Fortran --- src/H5B2.c | 32 ++++++ src/H5B2private.h | 1 + src/H5Dbtree2.c | 12 ++- src/H5Dearray.c | 12 ++- src/H5Dfarray.c | 12 ++- src/H5Dio.c | 6 ++ src/H5EA.c | 33 ++++++ src/H5EAprivate.h | 1 + src/H5FA.c | 33 ++++++ src/H5FAprivate.h | 1 + src/H5T.c | 29 ++++++ test/tfile.c | 293 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 12 files changed, 456 insertions(+), 9 deletions(-) diff --git a/src/H5B2.c b/src/H5B2.c index b1371d9..bdc79bd 100644 --- a/src/H5B2.c +++ b/src/H5B2.c @@ -1538,3 +1538,35 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2_depend() */ +/*------------------------------------------------------------------------- + * Function: H5B2_patch_file + * + * Purpose: Patch the top-level file pointer contained in bt2 + * to point to idx_info->f if they are different. + * This is possible because the file pointer in bt2 can be + * closed out if bt2 remains open. + * + * Return: SUCCEED + * + *------------------------------------------------------------------------- + */ +herr_t +H5B2_patch_file(H5B2_t *bt2, H5F_t *f) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + +#ifdef QAK +HDfprintf(stderr, "%s: Called\n", FUNC); +#endif /* QAK */ + + /* + * Check arguments. + */ + HDassert(bt2); + HDassert(f); + + if(bt2->f != f || bt2->hdr->f != f) + bt2->f = bt2->hdr->f = f; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5B2_patch_file() */ diff --git a/src/H5B2private.h b/src/H5B2private.h index cc60c9b..dbc5d47 100644 --- a/src/H5B2private.h +++ b/src/H5B2private.h @@ -159,6 +159,7 @@ H5_DLL htri_t H5B2_support(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5_DLL herr_t H5B2_unsupport(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5AC_info_t *child); H5_DLL herr_t H5B2_depend(H5AC_info_t *parent_entry, H5B2_t *bt2); +H5_DLL herr_t H5B2_patch_file(H5B2_t *fa, H5F_t *f); /* Statistics routines */ H5_DLL herr_t H5B2_stat_info(H5B2_t *bt2, H5B2_stat_t *info); diff --git a/src/H5Dbtree2.c b/src/H5Dbtree2.c index f286db2..8d005fd 100644 --- a/src/H5Dbtree2.c +++ b/src/H5Dbtree2.c @@ -1014,10 +1014,12 @@ H5D__bt2_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, HDassert(H5F_addr_defined(udata->chunk_block.offset)); /* Check if the v2 B-tree is open yet */ - if(NULL == idx_info->storage->u.btree2.bt2) + if(NULL == idx_info->storage->u.btree2.bt2) { /* Open existing v2 B-tree */ if(H5D__bt2_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree") + } else /* Patch the top level file pointer contained in bt2 if needed */ + H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f); /* Set convenience pointer to v2 B-tree structure */ bt2 = idx_info->storage->u.btree2.bt2; @@ -1114,10 +1116,12 @@ H5D__bt2_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata) HDassert(udata); /* Check if the v2 B-tree is open yet */ - if(NULL == idx_info->storage->u.btree2.bt2) + if(NULL == idx_info->storage->u.btree2.bt2) { /* Open existing v2 B-tree */ if(H5D__bt2_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree") + } else /* Patch the top level file pointer contained in bt2 if needed */ + H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f); /* Set convenience pointer to v2 B-tree structure */ bt2 = idx_info->storage->u.btree2.bt2; @@ -1233,10 +1237,12 @@ H5D__bt2_idx_iterate(const H5D_chk_idx_info_t *idx_info, HDassert(chunk_udata); /* Check if the v2 B-tree is open yet */ - if(NULL == idx_info->storage->u.btree2.bt2) + if(NULL == idx_info->storage->u.btree2.bt2) { /* Open existing v2 B-tree */ if(H5D__bt2_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open v2 B-tree") + } else /* Patch the top level file pointer contained in bt2 if needed */ + H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f); /* Set convenience pointer to v2 B-tree structure */ bt2 = idx_info->storage->u.btree2.bt2; diff --git a/src/H5Dearray.c b/src/H5Dearray.c index 84c26bf..3896172 100644 --- a/src/H5Dearray.c +++ b/src/H5Dearray.c @@ -1038,10 +1038,12 @@ H5D__earray_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata HDassert(udata); /* Check if the extensible array is open yet */ - if(NULL == idx_info->storage->u.earray.ea) + if(NULL == idx_info->storage->u.earray.ea) { /* Open the extensible array in file */ if(H5D__earray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open extensible array") + } else /* Patch the top level file pointer contained in ea if needed */ + H5EA_patch_file(idx_info->storage->u.earray.ea, idx_info->f); /* Set convenience pointer to extensible array structure */ ea = idx_info->storage->u.earray.ea; @@ -1107,10 +1109,12 @@ H5D__earray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *uda HDassert(udata); /* Check if the extensible array is open yet */ - if(NULL == idx_info->storage->u.earray.ea) + if(NULL == idx_info->storage->u.earray.ea) { /* Open the extensible array in file */ if(H5D__earray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open extensible array") + } else /* Patch the top level file pointer contained in ea if needed */ + H5EA_patch_file(idx_info->storage->u.earray.ea, idx_info->f); /* Set convenience pointer to extensible array structure */ ea = idx_info->storage->u.earray.ea; @@ -1309,10 +1313,12 @@ H5D__earray_idx_iterate(const H5D_chk_idx_info_t *idx_info, HDassert(chunk_udata); /* Check if the extensible array is open yet */ - if(NULL == idx_info->storage->u.earray.ea) + if(NULL == idx_info->storage->u.earray.ea) { /* Open the extensible array in file */ if(H5D__earray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open extensible array") + } else /* Patch the top level file pointer contained in ea if needed */ + H5EA_patch_file(idx_info->storage->u.earray.ea, idx_info->f); /* Set convenience pointer to extensible array structure */ ea = idx_info->storage->u.earray.ea; diff --git a/src/H5Dfarray.c b/src/H5Dfarray.c index 2958a66..e5541c7 100644 --- a/src/H5Dfarray.c +++ b/src/H5Dfarray.c @@ -989,10 +989,12 @@ H5D__farray_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata HDassert(udata); /* Check if the fixed array is open yet */ - if(NULL == idx_info->storage->u.farray.fa) + if(NULL == idx_info->storage->u.farray.fa) { /* Open the fixed array in file */ if(H5D__farray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open fixed array") + } else /* Patch the top level file pointer contained in fa if needed */ + H5FA_patch_file(idx_info->storage->u.farray.fa, idx_info->f); /* Set convenience pointer to fixed array structure */ fa = idx_info->storage->u.farray.fa; @@ -1058,10 +1060,12 @@ H5D__farray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *uda HDassert(udata); /* Check if the fixed array is open yet */ - if(NULL == idx_info->storage->u.farray.fa) + if(NULL == idx_info->storage->u.farray.fa) { /* Open the fixed array in file */ if(H5D__farray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open fixed array") + } else /* Patch the top level file pointer contained in fa if needed */ + H5FA_patch_file(idx_info->storage->u.farray.fa, idx_info->f); /* Set convenience pointer to fixed array structure */ fa = idx_info->storage->u.farray.fa; @@ -1196,10 +1200,12 @@ H5D__farray_idx_iterate(const H5D_chk_idx_info_t *idx_info, HDassert(chunk_udata); /* Check if the fixed array is open yet */ - if(NULL == idx_info->storage->u.farray.fa) + if(NULL == idx_info->storage->u.farray.fa) { /* Open the fixed array in file */ if(H5D__farray_idx_open(idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't open fixed array") + } else /* Patch the top level file pointer contained in fa if needed */ + H5FA_patch_file(idx_info->storage->u.farray.fa, idx_info->f); /* Set convenience pointer to fixed array structure */ fa = idx_info->storage->u.farray.fa; diff --git a/src/H5Dio.c b/src/H5Dio.c index c0aa83e..ac5c82b 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -412,6 +412,9 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, if(H5D__get_dxpl_cache(dxpl_id, &dxpl_cache) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't fill dxpl cache") + /* Patch the top level file pointer for dt->shared->u.vlen.f if needed */ + H5T_patch_vlen_file(dataset->shared->type, dataset->oloc.file); + /* Set up datatype info for operation */ if(H5D__typeinfo_init(dataset, dxpl_cache, dxpl_id, mem_type_id, FALSE, &type_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set up type info") @@ -632,6 +635,9 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, if(H5D__get_dxpl_cache(dxpl_id, &dxpl_cache) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't fill dxpl cache") + /* Patch the top level file pointer for dt->shared->u.vlen.f if needed */ + H5T_patch_vlen_file(dataset->shared->type, dataset->oloc.file); + /* Set up datatype info for operation */ if(H5D__typeinfo_init(dataset, dxpl_cache, dxpl_id, mem_type_id, TRUE, &type_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set up type info") diff --git a/src/H5EA.c b/src/H5EA.c index bf18239..6648bcf 100644 --- a/src/H5EA.c +++ b/src/H5EA.c @@ -1115,3 +1115,36 @@ CATCH elmt = H5FL_BLK_FREE(ea_native_elmt, elmt); END_FUNC(PRIV) /* end H5EA_iterate() */ + +/*------------------------------------------------------------------------- + * Function: H5EA_patch_file + * + * Purpose: Patch the top-level file pointer contained in ea + * to point to idx_info->f if they are different. + * This is possible because the file pointer in ea can be + * closed out if ea remains open. + * + * Return: SUCCEED + * + *------------------------------------------------------------------------- + */ +BEGIN_FUNC(PRIV, NOERR, +herr_t, SUCCEED, -, +H5EA_patch_file(H5EA_t *ea, H5F_t *f)) + + /* Local variables */ + +#ifdef H5EA_DEBUG +HDfprintf(stderr, "%s: Called\n", FUNC); +#endif /* H5EA_DEBUG */ + + /* + * Check arguments. + */ + HDassert(ea); + HDassert(f); + + if(ea->f != f || ea->hdr->f != f) + ea->f = ea->hdr->f = f; + +END_FUNC(PRIV) /* end H5EA_patch_file() */ diff --git a/src/H5EAprivate.h b/src/H5EAprivate.h index c00e118..78bcca8 100644 --- a/src/H5EAprivate.h +++ b/src/H5EAprivate.h @@ -146,6 +146,7 @@ H5_DLL herr_t H5EA_depend(H5AC_info_t *parent_entry, H5EA_t *ea); H5_DLL herr_t H5EA_iterate(H5EA_t *fa, hid_t dxpl_id, H5EA_operator_t op, void *udata); H5_DLL herr_t H5EA_close(H5EA_t *ea, hid_t dxpl_id); H5_DLL herr_t H5EA_delete(H5F_t *f, hid_t dxpl_id, haddr_t ea_addr, void *ctx_udata); +H5_DLL herr_t H5EA_patch_file(H5EA_t *fa, H5F_t *f); /* Statistics routines */ H5_DLL herr_t H5EA_get_stats(const H5EA_t *ea, H5EA_stat_t *stats); diff --git a/src/H5FA.c b/src/H5FA.c index a1b4fbc..70a4b56 100644 --- a/src/H5FA.c +++ b/src/H5FA.c @@ -850,3 +850,36 @@ HDfprintf(stderr, "%s: Called\n", FUNC); CATCH END_FUNC(PRIV) /* end H5FA_undepend() */ + +/*------------------------------------------------------------------------- + * Function: H5FA_patch_file + * + * Purpose: Patch the top-level file pointer contained in fa + * to point to idx_info->f if they are different. + * This is possible because the file pointer in fa can be + * closed out if fa remains open. + * + * Return: SUCCEED + * + *------------------------------------------------------------------------- + */ +BEGIN_FUNC(PRIV, NOERR, +herr_t, SUCCEED, -, +H5FA_patch_file(H5FA_t *fa, H5F_t *f)) + + /* Local variables */ + +#ifdef H5FA_DEBUG +HDfprintf(stderr, "%s: Called\n", FUNC); +#endif /* H5FA_DEBUG */ + + /* + * Check arguments. + */ + HDassert(fa); + HDassert(f); + + if(fa->f != f || fa->hdr->f != f) + fa->f = fa->hdr->f = f; + +END_FUNC(PRIV) /* end H5FA_patch_file() */ diff --git a/src/H5FAprivate.h b/src/H5FAprivate.h index b7c141a..2ce9cbb 100644 --- a/src/H5FAprivate.h +++ b/src/H5FAprivate.h @@ -131,6 +131,7 @@ H5_DLL herr_t H5FA_depend(H5AC_info_t *parent_entry, H5FA_t *fa); H5_DLL herr_t H5FA_iterate(H5FA_t *fa, hid_t dxpl_id, H5FA_operator_t op, void *udata); H5_DLL herr_t H5FA_close(H5FA_t *fa, hid_t dxpl_id); H5_DLL herr_t H5FA_delete(H5F_t *f, hid_t dxpl_id, haddr_t fa_addr, void *ctx_udata); +H5_DLL herr_t H5FA_patch_file(H5FA_t *fa, H5F_t *f); /* Statistics routines */ H5_DLL herr_t H5FA_get_stats(const H5FA_t *ea, H5FA_stat_t *stats); diff --git a/src/H5T.c b/src/H5T.c index 030f5a7..6514a35 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -5466,6 +5466,35 @@ done: /*------------------------------------------------------------------------- + * Function: H5T_patch_vlen_file + * + * Purpose: Patch the top-level file pointer contained in (dt->shared->u.vlen.f) + * to point to f. This is possible because + * the top-level file pointer can be closed out from under + * dt while dt is contained in the shared file's cache. + * + * Return: SUCCEED + * + *------------------------------------------------------------------------- + */ +herr_t +H5T_patch_vlen_file(H5T_t *dt, H5F_t *f) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Sanity check */ + HDassert(dt); + HDassert(dt->shared); + HDassert(f); + + if((dt->shared->type == H5T_VLEN) && dt->shared->u.vlen.f != f) + dt->shared->u.vlen.f = f; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5T_patch_vlen_file() */ + + +/*------------------------------------------------------------------------- * Function: H5Tflush * * Purpose: Flushes all buffers associated with a named datatype to disk. diff --git a/test/tfile.c b/test/tfile.c index 3fbfce3..0974416 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -2123,6 +2123,297 @@ test_file_double_dataset_open(void) /**************************************************************** ** +** test_file_double_file_dataset_open(): +** This test checks multi-opens of files & datasets: +** It simulates the multi-thread test program from DLS +** which exposes the file pointer segmentation fault failure. +** NOTE: The order on when the files and datasets are open/close +** is important. +** +*****************************************************************/ +static void +test_file_double_file_dataset_open(hbool_t new) +{ + hid_t fapl = -1; /* File access property list */ + hid_t dcpl = -1; /* Dataset creation property list */ + hid_t fid1 = -1, fid2 = -1; /* File IDs */ + hid_t did1 = -1, did2 = -1; /* Dataset IDs */ + hid_t sid1 = -1, sid2 = -1; /* Dataspace IDs */ + hid_t tid1 = -1, tid2 = -1; /* Datatype IDs */ + hsize_t dims[1] = {4}, dims2[2] = {1, 4}; /* Dimension sizes */ + hsize_t max_dims0[1] = {8}; /* Maximum dimension sizes */ + hsize_t max_dims1[1] = {H5S_UNLIMITED}; /* Maximum dimesion sizes for extensible array index */ + hsize_t max_dims2[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes for v2 B-tree index */ + hsize_t chunks[1] = {4}, chunks2[2] = {4, 5}; /* Chunk dimension sizes */ + char* data[] = {"String 1", "String 2", "String 3", "String 4"}; /* Input Data */ + char* buffer[4]; /* Output buffer */ + int wbuf[4] = {1, 2, 3, 4}; /* Input data */ + herr_t ret; /* Generic return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing double file and dataset open/close\n")); + + /* Setting up test file */ + + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + if(new) { + ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); + CHECK(ret, FAIL, "H5Pset_libver_bounds"); + } + + /* Create the test file */ + fid1 = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); + CHECK(fid1, FAIL, "H5Fcreate"); + + /* Create a chunked dataset with fixed array indexing */ + sid1 = H5Screate_simple(1, dims, max_dims0); + CHECK(sid1, FAIL, "H5Screate"); + tid1 = H5Tcopy(H5T_C_S1); + CHECK(tid1, FAIL, "H5Tcopy"); + ret = H5Tset_size(tid1, H5T_VARIABLE); + CHECK(ret, FAIL, "H5Tset_size"); + + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + ret = H5Pset_chunk(dcpl, 1, chunks); + CHECK(ret, FAIL, "H5Pset_chunk"); + + did1 = H5Dcreate2(fid1, "dset_fa", tid1, sid1, H5P_DEFAULT, dcpl, H5P_DEFAULT); + CHECK(did1, FAIL, "H5Dcreate2"); + + /* Closing */ + ret = H5Dclose(did1); + CHECK(ret, FAIL, "H5Dclose"); + ret = H5Tclose(tid1); + CHECK(ret, FAIL, "H5Tclose"); + ret = H5Sclose(sid1); + CHECK(ret, FAIL, "H5Sclose"); + ret = H5Pclose(dcpl); + CHECK(ret, FAIL, "H5Dclose"); + + /* Create a chunked dataset with extensible array indexing */ + sid1 = H5Screate_simple(1, dims, max_dims1); + CHECK(sid1, FAIL, "H5Screate"); + tid1 = H5Tcopy(H5T_C_S1); + CHECK(tid1, FAIL, "H5Tcopy"); + ret = H5Tset_size(tid1, H5T_VARIABLE); + CHECK(ret, FAIL, "H5Tset_size"); + + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + ret = H5Pset_chunk(dcpl, 1, chunks); + CHECK(ret, FAIL, "H5Pset_chunk"); + + did1 = H5Dcreate2(fid1, "dset_ea", tid1, sid1, H5P_DEFAULT, dcpl, H5P_DEFAULT); + CHECK(did1, FAIL, "H5Dcreate2"); + + /* Write to the dataset */ + ret = H5Dwrite(did1, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); + CHECK(ret, FAIL, "H5Dwrite"); + + /* Closing */ + ret = H5Dclose(did1); + CHECK(ret, FAIL, "H5Dclose"); + ret = H5Tclose(tid1); + CHECK(ret, FAIL, "H5Tclose"); + ret = H5Sclose(sid1); + CHECK(ret, FAIL, "H5Sclose"); + ret = H5Pclose(dcpl); + CHECK(ret, FAIL, "H5Dclose"); + + /* Create a chunked dataset with v2 btree indexing */ + sid2 = H5Screate_simple(2, dims2, max_dims2); + CHECK(sid2, FAIL, "H5Screate"); + + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + ret = H5Pset_chunk(dcpl, 2, chunks2); + CHECK(ret, FAIL, "H5Pset_chunk"); + + did2 = H5Dcreate2(fid1, "dset_bt2", H5T_NATIVE_INT, sid2, H5P_DEFAULT, dcpl, H5P_DEFAULT); + CHECK(did2, FAIL, "H5Dcreate2"); + + /* Write to the dataset */ + ret = H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); + CHECK(ret, FAIL, "H5Dwrite"); + + /* Closing */ + ret = H5Dclose(did2); + CHECK(ret, FAIL, "H5Dclose"); + + ret = H5Sclose(sid2); + CHECK(ret, FAIL, "H5Sclose"); + ret = H5Pclose(dcpl); + CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); + ret = H5Fclose(fid1); + CHECK(ret, FAIL, "H5Fclose"); + + /* + * Scenario 1 + */ + + /* First file open */ + fid1 = H5Fopen(FILE1, H5F_ACC_RDWR, H5P_DEFAULT); + CHECK(fid1, FAIL, "H5Fopen"); + + /* First file's dataset open */ + did1 = H5Dopen2(fid1, "/dset_fa", H5P_DEFAULT); + CHECK(did1, FAIL, "H5Dopen2"); + + tid1 = H5Tcopy(did1); + CHECK(tid1, FAIL, "H5Tcopy"); + + /* First file's dataset write */ + ret = H5Dwrite(did1, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); + CHECK(ret, FAIL, "H5Dwrite"); + + /* Second file open */ + fid2 = H5Fopen(FILE1, H5F_ACC_RDWR, H5P_DEFAULT); + CHECK(fid2, FAIL, "H5Fopen"); + + /* Second file's dataset open */ + did2 = H5Dopen2(fid2, "/dset_fa", H5P_DEFAULT ); + CHECK(did2, FAIL, "H5Dopen2"); + + tid2 = H5Tcopy(did2); + CHECK(tid2, FAIL, "H5Tcopy"); + + /* First file's dataset close */ + ret = H5Dclose(did1); + CHECK(ret, FAIL, "H5Dclose"); + + /* First file close */ + ret = H5Fclose(fid1); + CHECK(ret, FAIL, "H5Fclose"); + + /* Second file's dataset write */ + ret = H5Dwrite(did2, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); + CHECK(ret, FAIL, "H5Dwrite"); + + /* Second file's dataset close */ + ret = H5Dclose(did2); + CHECK(ret, FAIL, "H5Dclose"); + + /* Second file close */ + ret = H5Fclose(fid2); + CHECK(ret, FAIL, "H5Fclose"); + + /* Closing */ + ret = H5Tclose(tid1); + CHECK(ret, FAIL, "H5Tclose"); + ret = H5Tclose(tid2); + CHECK(ret, FAIL, "H5Tclose"); + + /* + * Scenario 2 + */ + + /* First file open */ + fid1 = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT); + CHECK(fid1, FAIL, "H5Fopen"); + + /* Second file open */ + fid2 = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT); + CHECK(fid2, FAIL, "H5Fopen"); + + /* Second file's dataset open */ + did2 = H5Dopen2(fid2, "/dset_ea", H5P_DEFAULT ); + CHECK(did2, FAIL, "H5Dopen2"); + + tid2 = H5Tcopy(did2); + CHECK(tid2, FAIL, "H5Tcopy"); + + /* First file's dataset open */ + did1 = H5Dopen2(fid1, "/dset_ea", H5P_DEFAULT); + CHECK(did1, FAIL, "H5Dopen2"); + + tid1 = H5Tcopy(did1); + CHECK(tid1, FAIL, "H5Tcopy"); + + /* Second file's dataset read */ + HDmemset(buffer, 0, sizeof(char*) * 4); + ret = H5Dread(did2, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buffer); + CHECK(ret, FAIL, "H5Dread"); + + /* Second file's dataset close */ + ret = H5Dclose(did2); + CHECK(ret, FAIL, "H5Dclose"); + + /* Second file close */ + ret = H5Fclose(fid2); + CHECK(ret, FAIL, "H5Fclose"); + + /* First file's dataset read */ + HDmemset(buffer, 0, sizeof(char*) * 4); + ret = H5Dread(did1, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, buffer); + + /* First file's dataset close */ + ret = H5Dclose(did1); + CHECK(ret, FAIL, "H5Dclose"); + + /* First file close */ + ret = H5Fclose(fid1); + CHECK(ret, FAIL, "H5Fclose"); + + /* Closing */ + ret = H5Tclose(tid1); + CHECK(ret, FAIL, "H5Tclose"); + + ret = H5Tclose(tid2); + CHECK(ret, FAIL, "H5Tclose"); + + /* + * Scenario 3 + */ + + /* First file open */ + fid1 = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT); + CHECK(fid1, FAIL, "H5Fopen"); + + /* First file's dataset open */ + did1 = H5Dopen2(fid1, "/dset_bt2", H5P_DEFAULT); + CHECK(did1, FAIL, "H5Dopen2"); + + /* First file's get storage size */ + ret = H5Dget_storage_size(did1); + CHECK(ret, FAIL, "H5Dget_storage_size"); + + /* Second file open */ + fid2 = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT); + CHECK(fid2, FAIL, "H5Fopen"); + + /* Second file's dataset open */ + did2 = H5Dopen2(fid2, "/dset_bt2", H5P_DEFAULT ); + CHECK(did2, FAIL, "H5Dopen2"); + + /* First file's dataset close */ + ret = H5Dclose(did1); + CHECK(ret, FAIL, "H5Dclose"); + + /* First file close */ + ret = H5Fclose(fid1); + CHECK(ret, FAIL, "H5Fclose"); + + /* Second file's get storage size */ + ret = H5Dget_storage_size(did2); + CHECK(ret, FAIL, "H5Dget_storage_size"); + + /* Second file's dataset close */ + ret = H5Dclose(did2); + CHECK(ret, FAIL, "H5Dclose"); + + /* Second file close */ + ret = H5Fclose(fid2); + CHECK(ret, FAIL, "H5Fclose"); + +} /* end test_file_double_dataset_open() */ + +/**************************************************************** +** ** test_file_double_datatype_open(): low-level file test routine. ** This test checks whether opening the same named datatype from two ** different files works correctly. @@ -3694,6 +3985,8 @@ test_file(void) test_file_double_group_open(); /* Test opening same group from two files works properly */ test_file_double_dataset_open(); /* Test opening same dataset from two files works properly */ test_file_double_datatype_open(); /* Test opening same named datatype from two files works properly */ + test_file_double_file_dataset_open(TRUE); + test_file_double_file_dataset_open(FALSE); test_userblock_file_size(); /* Tests that files created with a userblock have the correct size */ test_cached_stab_info(); /* Tests that files are created with cached stab info in the superblock */ test_rw_noupdate(); /* Test to ensure that RW permissions don't write the file unless dirtied */ -- cgit v0.12