summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2016-01-20 23:17:01 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2016-01-20 23:17:01 (GMT)
commit1ede7af7841a9ba323a63f9bda6372274e8092bc (patch)
tree689f7a2bf706f9ee726b1c31c97906b248c83bc0
parentc5a58dc53f460a0535e4b083f91eb16d2e3e8e67 (diff)
downloadhdf5-1ede7af7841a9ba323a63f9bda6372274e8092bc.zip
hdf5-1ede7af7841a9ba323a63f9bda6372274e8092bc.tar.gz
hdf5-1ede7af7841a9ba323a63f9bda6372274e8092bc.tar.bz2
[svn-r28940] Merge revision #28852 from hdf5_1_10_alpha1 to revise_chunks.
This is the fix to downgrade superblock version for the tool h5format_convert so DLS can use 1.8 h5dump on the converted file. Tested on jam, platypus, moohan, osx1010test.
-rw-r--r--src/H5F.c59
-rw-r--r--src/H5Fpublic.h1
-rw-r--r--tools/h5format_convert/h5fc_gentest.c18
-rw-r--r--tools/h5format_convert/h5format_convert.c40
-rw-r--r--tools/h5format_convert/testfiles/h5fc_v_all.ddl1
-rw-r--r--tools/h5format_convert/testfiles/h5fc_v_bt1.ddl1
-rw-r--r--tools/h5format_convert/testfiles/h5fc_v_n_1d.ddl1
-rw-r--r--tools/h5format_convert/testfiles/h5fc_v_n_all.ddl1
-rw-r--r--tools/h5format_convert/testfiles/h5fc_v_ndata_bt1.ddl1
-rw-r--r--tools/h5format_convert/testfiles/h5fc_v_non_chunked.ddl1
10 files changed, 122 insertions, 2 deletions
diff --git a/src/H5F.c b/src/H5F.c
index 9c4b1c9..a822132 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -1870,3 +1870,62 @@ done:
FUNC_LEAVE_API(ret_value)
} /* H5Fstop_mdc_logging() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Fformat_convert_super (Internal)
+ *
+ * Purpose: Downgrade the superblock version for the tool h5format_convert.
+ * (NOTE: more needs to be done to this routine)
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Vailin Choi; Jan 2016
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Fformat_convert_super(hid_t fid)
+{
+ H5F_t *f = NULL; /* File to flush */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE1("e", "i", fid);
+
+ switch(H5I_get_type(fid)) {
+ case H5I_FILE:
+ if(NULL == (f = (H5F_t *)H5I_object(fid)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ if(f->shared->sblock->super_vers < HDF5_SUPERBLOCK_VERSION_LATEST)
+ HGOTO_DONE(SUCCEED)
+ f->shared->sblock->super_vers = HDF5_SUPERBLOCK_VERSION_LATEST - 1;
+
+ /* Mark superblock as dirty */
+ if(H5F_super_dirty(f) < 0)
+ HDONE_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty")
+
+ break;
+
+ case H5I_GROUP:
+ case H5I_DATATYPE:
+ case H5I_DATASET:
+ case H5I_ATTR:
+ case H5I_UNINIT:
+ case H5I_BADID:
+ case H5I_DATASPACE:
+ case H5I_REFERENCE:
+ case H5I_VFL:
+ case H5I_GENPROP_CLS:
+ case H5I_GENPROP_LST:
+ case H5I_ERROR_CLASS:
+ case H5I_ERROR_MSG:
+ case H5I_ERROR_STACK:
+ case H5I_NTYPES:
+ default:
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
+ } /* end switch */
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Fformat_convert_super() */
diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h
index 5b50385..937e29f 100644
--- a/src/H5Fpublic.h
+++ b/src/H5Fpublic.h
@@ -254,6 +254,7 @@ H5_DLL herr_t H5Fstop_mdc_logging(hid_t file_id);
H5_DLL herr_t H5Fget_mdc_logging_status(hid_t file_id,
/*OUT*/ hbool_t *is_enabled,
/*OUT*/ hbool_t *is_currently_logging);
+H5_DLL herr_t H5Fformat_convert_super(hid_t fid);
#ifdef H5_HAVE_PARALLEL
H5_DLL herr_t H5Fset_mpi_atomicity(hid_t file_id, hbool_t flag);
H5_DLL herr_t H5Fget_mpi_atomicity(hid_t file_id, hbool_t *flag);
diff --git a/tools/h5format_convert/h5fc_gentest.c b/tools/h5format_convert/h5fc_gentest.c
index 4dcc286..888aa27 100644
--- a/tools/h5format_convert/h5fc_gentest.c
+++ b/tools/h5format_convert/h5fc_gentest.c
@@ -172,6 +172,7 @@ gen_latest(const char *fname)
{
hid_t fid = -1; /* file id */
hid_t fapl = -1; /* file access property list */
+ hid_t fcpl = -1; /* file creation property list */
hid_t gid = -1; /* group id */
hid_t sid = -1; /* space id */
hid_t dcpl = -1; /* dataset creation property id */
@@ -188,7 +189,12 @@ gen_latest(const char *fname)
if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
goto error;
- if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
+ goto error;
+ if(H5Pset_shared_mesg_nindexes(fcpl, 4) < 0)
+ goto error;
+
+ if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, fcpl, fapl)) < 0)
goto error;
/* Create a group */
@@ -365,6 +371,7 @@ static void
gen_non(const char *fname)
{
hid_t fid = -1; /* file id */
+ hid_t fcpl = -1; /* file creation property list */
hid_t gid = -1; /* group id */
hid_t sid = -1; /* space id */
hid_t dcpl = -1; /* dataset creation property id */
@@ -376,8 +383,15 @@ gen_non(const char *fname)
int i; /* local index variable */
int buf[24]; /* data buffer */
+ if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
+ goto error;
+ if(H5Pset_shared_mesg_nindexes(fcpl, 4) < 0)
+ goto error;
+ if(H5Pset_istore_k(fcpl, 64) < 0)
+ goto error;
+
/* Create a new file with SWMR_WRITE + non-latest-format */
- if((fid = H5Fcreate(fname, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if((fid = H5Fcreate(fname, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, fcpl, H5P_DEFAULT)) < 0)
goto error;
/* Create a group */
diff --git a/tools/h5format_convert/h5format_convert.c b/tools/h5format_convert/h5format_convert.c
index 7686acc..a80e332 100644
--- a/tools/h5format_convert/h5format_convert.c
+++ b/tools/h5format_convert/h5format_convert.c
@@ -377,6 +377,9 @@ main(int argc, const char *argv[])
H5E_auto2_t func;
void *edata;
hid_t fid = -1;
+ hid_t fcpl = -1;
+ H5F_file_space_type_t strategy;
+ hsize_t threshold;
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
@@ -405,6 +408,28 @@ main(int argc, const char *argv[])
} else if(verbose_g)
printf("Open the file %s\n", fname_g);
+ /* A temporaray fix:
+ * need to handle H5O_FSINFO_ID message when downgrade superblock version from 3 to 2
+ */
+ if((fcpl = H5Fget_create_plist(fid)) < 0) {
+ error_msg("unable to get file creation property list for \"%s\"\n", fname_g);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+ if(H5Pget_file_space(fcpl, &strategy, &threshold) < 0) {
+ error_msg("unable to get file space strategy/threshold\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+ /* Check for non-default strategy/threshold:
+ * --whether there is H5O_FSINFO_ID message in the superblock extension
+ */
+ if(strategy != H5F_FILE_SPACE_ALL || threshold != 1) {
+ error_msg("unable to convert due to non-default file space strategy/threshold\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+
if(dset_g) { /* Convert a specified dataset in the file */
if(verbose_g)
printf("Going to process dataset: %s...\n", dname_g);
@@ -417,6 +442,21 @@ main(int argc, const char *argv[])
goto done;
}
+ if(verbose_g) {
+ if(noop_g) {
+ printf("Not processing the file's superblock version...\n");
+ h5tools_setstatus(EXIT_SUCCESS);
+ goto done;
+ }
+ printf("Processing the file's superblock version...\n");
+ }
+
+ if(H5Fformat_convert_super(fid) < 0) {
+ error_msg("unable to convert file's superblock version\"%s\"\n", fname_g);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+
done:
/* Close the file */
if(fid >= 0) {
diff --git a/tools/h5format_convert/testfiles/h5fc_v_all.ddl b/tools/h5format_convert/testfiles/h5fc_v_all.ddl
index 3f474fe..5a35c55 100644
--- a/tools/h5format_convert/testfiles/h5fc_v_all.ddl
+++ b/tools/h5format_convert/testfiles/h5fc_v_all.ddl
@@ -23,4 +23,5 @@ Retrieve the dataset's chunk indexing type
Chunk indexing type is already version 1 B-tree: no further action
Close the dataset
Close the dataset creation property list
+Processing the file's superblock version...
Close the file
diff --git a/tools/h5format_convert/testfiles/h5fc_v_bt1.ddl b/tools/h5format_convert/testfiles/h5fc_v_bt1.ddl
index abb0a89..c96b647 100644
--- a/tools/h5format_convert/testfiles/h5fc_v_bt1.ddl
+++ b/tools/h5format_convert/testfiles/h5fc_v_bt1.ddl
@@ -8,4 +8,5 @@ Retrieve the dataset's chunk indexing type
Chunk indexing type is already version 1 B-tree: no further action
Close the dataset
Close the dataset creation property list
+Processing the file's superblock version...
Close the file
diff --git a/tools/h5format_convert/testfiles/h5fc_v_n_1d.ddl b/tools/h5format_convert/testfiles/h5fc_v_n_1d.ddl
index a26dc66..a7a622a 100644
--- a/tools/h5format_convert/testfiles/h5fc_v_n_1d.ddl
+++ b/tools/h5format_convert/testfiles/h5fc_v_n_1d.ddl
@@ -10,4 +10,5 @@ Verify the dataset's chunk indexing type is not version 1 B-tree
Not converting the dataset
Close the dataset
Close the dataset creation property list
+Not processing the file's superblock version...
Close the file
diff --git a/tools/h5format_convert/testfiles/h5fc_v_n_all.ddl b/tools/h5format_convert/testfiles/h5fc_v_n_all.ddl
index 76c70ee..3e92568 100644
--- a/tools/h5format_convert/testfiles/h5fc_v_n_all.ddl
+++ b/tools/h5format_convert/testfiles/h5fc_v_n_all.ddl
@@ -44,4 +44,5 @@ Retrieve the dataset's layout
Dataset is not chunked: no further action
Close the dataset
Close the dataset creation property list
+Not processing the file's superblock version...
Close the file
diff --git a/tools/h5format_convert/testfiles/h5fc_v_ndata_bt1.ddl b/tools/h5format_convert/testfiles/h5fc_v_ndata_bt1.ddl
index 86081f3..bdf3380 100644
--- a/tools/h5format_convert/testfiles/h5fc_v_ndata_bt1.ddl
+++ b/tools/h5format_convert/testfiles/h5fc_v_ndata_bt1.ddl
@@ -9,4 +9,5 @@ Retrieve the dataset's chunk indexing type
Chunk indexing type is already version 1 B-tree: no further action
Close the dataset
Close the dataset creation property list
+Not processing the file's superblock version...
Close the file
diff --git a/tools/h5format_convert/testfiles/h5fc_v_non_chunked.ddl b/tools/h5format_convert/testfiles/h5fc_v_non_chunked.ddl
index baba0e4..4caafe9 100644
--- a/tools/h5format_convert/testfiles/h5fc_v_non_chunked.ddl
+++ b/tools/h5format_convert/testfiles/h5fc_v_non_chunked.ddl
@@ -6,4 +6,5 @@ Retrieve the dataset's layout
Dataset is not chunked: no further action
Close the dataset
Close the dataset creation property list
+Processing the file's superblock version...
Close the file