summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2015-07-11 17:39:57 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2015-07-11 17:39:57 (GMT)
commitabecd36aa31c9c92f4f8a16d4eb85fc57800efd7 (patch)
tree54e658671de3181139a6055863d1591a213c1f2f
parentc948f9f3f94d90b79b999cf7ca2bb8652edcace9 (diff)
downloadhdf5-abecd36aa31c9c92f4f8a16d4eb85fc57800efd7.zip
hdf5-abecd36aa31c9c92f4f8a16d4eb85fc57800efd7.tar.gz
hdf5-abecd36aa31c9c92f4f8a16d4eb85fc57800efd7.tar.bz2
[svn-r27370] (1) Fix for test/dsets.c failure when enable-debug=all
(2) Modify message when file failed to open due to file consistency flag Tested on jam, ostrich, koala, platypus.
-rw-r--r--src/H5AC.c8
-rw-r--r--src/H5Fint.c4
-rw-r--r--test/dsets.c79
3 files changed, 85 insertions, 6 deletions
diff --git a/src/H5AC.c b/src/H5AC.c
index 1135b3e..3662905 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -924,6 +924,14 @@ H5AC_insert_entry(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t add
if(0 == (H5F_INTENT(f) & H5F_ACC_RDWR))
HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "no write intent on file")
+ /* FIXME: (temporary)
+ * Check to ensure that version 1 B-tree nodes are not being protected
+ * under SWMR writes. This will be replaced with a more extensive
+ * SWMR-safe metadata check in the future.
+ */
+ if((H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) && H5AC_BT_ID == type->id)
+ HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "can't insert/write version 1 B-tree nodes under SWMR writes")
+
#if H5AC__TRACE_FILE_ENABLED
/* For the insert, only the addr, size, type id and flags are really
* necessary in the trace file. Write the result to catch occult
diff --git a/src/H5Fint.c b/src/H5Fint.c
index 9b75b3d..6ea4544 100644
--- a/src/H5Fint.c
+++ b/src/H5Fint.c
@@ -1268,7 +1268,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id,
if(H5F_INTENT(file) & H5F_ACC_RDWR) { /* Set and check consistency of status_flags */
if(file->shared->sblock->status_flags & H5F_SUPER_WRITE_ACCESS ||
file->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS)
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file is already open for write or SWMR write")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file is already open for write/SWMR write (may use <h5clear file> to clear file consistency flags)")
file->shared->sblock->status_flags |= H5F_SUPER_WRITE_ACCESS;
@@ -1289,7 +1289,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id,
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file is not already open for SWMR writing")
} else if((file->shared->sblock->status_flags & H5F_SUPER_WRITE_ACCESS) ||
(file->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS))
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file is already open for writing")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file is already open for write (may use <h5clear file> to clear file consistency flags)")
}
} /* end if set_flag */
diff --git a/test/dsets.c b/test/dsets.c
index 9a56073..41fb839 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -9843,14 +9843,15 @@ test_swmr_v1_btree_ci_fail(const char *env_h5_driver, hid_t fapl)
/* Reopen the file with SWMR write access */
if((fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fh_fapl)) < 0) FAIL_STACK_ERROR
- /* Attempt to write to a dataset that uses v-1 B-tree chunk indexing under
- * SWMR semantics.
+ /*
+ * Attempt to write to a dataset that uses v-1 B-tree chunk indexing with SWMR access.
+ * (dataset is empty)
*/
did = -1;
err = -1;
H5E_BEGIN_TRY {
did = H5Dopen2(fid, DSET_DEFAULT_NAME, H5P_DEFAULT);
- if(did >= 0) {
+ if(did >= 0) { /* should fail to write */
err = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &data);
}
} H5E_END_TRY;
@@ -9862,9 +9863,79 @@ test_swmr_v1_btree_ci_fail(const char *env_h5_driver, hid_t fapl)
goto error;
}
- /* Close everything */
+ /* Close the dataset */
if(did >= 0)
if(H5Dclose(did) < 0) FAIL_STACK_ERROR
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
+
+
+ /* Reopen the file with write access */
+ if((fid = H5Fopen(filename, H5F_ACC_RDWR, fh_fapl)) < 0) FAIL_STACK_ERROR
+
+ /* Open the dataset */
+ if((did = H5Dopen2(fid, DSET_DEFAULT_NAME, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Write to the dataset */
+ if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &data) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close the dataset */
+ if(H5Dclose(did) < 0) FAIL_STACK_ERROR
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
+
+
+ /* Reopen the file with SWMR write access */
+ if((fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fh_fapl)) < 0) FAIL_STACK_ERROR
+
+ /*
+ * Attempt to write to a dataset that uses v-1 B-tree chunk indexing with SWMR access.
+ * (dataset is non-empty)
+ */
+ did = -1;
+ err = -1;
+ H5E_BEGIN_TRY {
+ did = H5Dopen2(fid, DSET_DEFAULT_NAME, H5P_DEFAULT);
+ if(did >= 0) { /* should fail to write */
+ err = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &data);
+ }
+ } H5E_END_TRY;
+
+ /* Fail on successful write */
+ if(did >= 0 && err >= 0) {
+ H5_FAILED();
+ puts(" library allowed writing to a version 1 B-tree indexed dataset under SWMR semantics");
+ goto error;
+ }
+
+ /* Close the dataset */
+ if(did >= 0)
+ if(H5Dclose(did) < 0) FAIL_STACK_ERROR
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
+
+ /* Reopen the file with SWMR read access */
+ if((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fh_fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Open the dataset */
+ if((did = H5Dopen2(fid, DSET_DEFAULT_NAME, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Should read the correct data from the dataset */
+ data = 0;
+ if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &data) < 0)
+ TEST_ERROR
+ if(data != 42)
+ TEST_ERROR
+
+ /* Closing */
+ if(H5Dclose(did) < 0) FAIL_STACK_ERROR
if(H5Pclose(v1_fapl) < 0) FAIL_STACK_ERROR
if(H5Pclose(fh_fapl) < 0) FAIL_STACK_ERROR
if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR