summaryrefslogtreecommitdiffstats
path: root/tools/src
diff options
context:
space:
mode:
Diffstat (limited to 'tools/src')
-rw-r--r--tools/src/h5dump/h5dump_ddl.c33
-rw-r--r--tools/src/h5repack/h5repack.c6
-rw-r--r--tools/src/h5repack/h5repack.h16
-rw-r--r--tools/src/h5repack/h5repack_copy.c74
-rw-r--r--tools/src/h5repack/h5repack_main.c81
-rw-r--r--tools/src/h5repack/h5repack_verify.c112
-rw-r--r--tools/src/h5stat/h5stat.c25
-rw-r--r--tools/src/misc/h5clear.c255
8 files changed, 441 insertions, 161 deletions
diff --git a/tools/src/h5dump/h5dump_ddl.c b/tools/src/h5dump/h5dump_ddl.c
index 182d570..c78f325 100644
--- a/tools/src/h5dump/h5dump_ddl.c
+++ b/tools/src/h5dump/h5dump_ddl.c
@@ -1186,9 +1186,11 @@ dump_fcpl(hid_t fid)
hsize_t userblock; /* userblock size retrieved from FCPL */
size_t off_size; /* size of offsets in the file */
size_t len_size; /* size of lengths in the file */
- H5F_file_space_type_t fs_strategy; /* file space strategy */
- hsize_t fs_threshold; /* free-space section threshold */
- H5F_info2_t finfo; /* file information */
+ H5F_fspace_strategy_t fs_strategy; /* file space strategy */
+ hbool_t fs_persist; /* Persisting free-space or not */
+ hsize_t fs_threshold; /* free-space section threshold */
+ hsize_t fsp_size; /* file space page size */
+ H5F_info2_t finfo; /* file information */
#ifdef SHOW_FILE_DRIVER
hid_t fapl; /* file access property list ID */
hid_t fdriver; /* file driver */
@@ -1204,7 +1206,8 @@ dump_fcpl(hid_t fid)
H5Pget_sizes(fcpl,&off_size,&len_size);
H5Pget_sym_k(fcpl,&sym_ik,&sym_lk);
H5Pget_istore_k(fcpl,&istore_ik);
- H5Pget_file_space(fcpl, &fs_strategy, &fs_threshold);
+ H5Pget_file_space_strategy(fcpl, &fs_strategy, &fs_persist, &fs_threshold);
+ H5Pget_file_space_page_size(fcpl, &fsp_size);
H5Pclose(fcpl);
#ifdef SHOW_FILE_DRIVER
fapl=h5_fileaccess();
@@ -1265,18 +1268,22 @@ dump_fcpl(hid_t fid)
PRINTSTREAM(rawoutstream, "%s %u\n","ISTORE_K", istore_ik);
indentation(dump_indent + COL);
- if(fs_strategy == H5F_FILE_SPACE_ALL_PERSIST) {
- PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FILE_SPACE_ALL_PERSIST");
- } else if(fs_strategy == H5F_FILE_SPACE_ALL) {
- PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FILE_SPACE_ALL");
- } else if(fs_strategy == H5F_FILE_SPACE_AGGR_VFD) {
- PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FILE_SPACE_AGGR_VFD");
- } else if(fs_strategy == H5F_FILE_SPACE_VFD) {
- PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FILE_SPACE_VFD");
+ if(fs_strategy == H5F_FSPACE_STRATEGY_FSM_AGGR) {
+ PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FSPACE_STRATEGY_FSM_AGGR");
+ } else if(fs_strategy == H5F_FSPACE_STRATEGY_PAGE) {
+ PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FSPACE_STRATEGY_PAGE");
+ } else if(fs_strategy == H5F_FSPACE_STRATEGY_AGGR) {
+ PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FSPACE_STRATEGY_AGGR");
+ } else if(fs_strategy == H5F_FSPACE_STRATEGY_NONE) {
+ PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "H5F_FSPACE_STRATEGY_NONE");
} else
PRINTSTREAM(rawoutstream, "%s %s\n", "FILE_SPACE_STRATEGY", "Unknown strategy");
indentation(dump_indent + COL);
- PRINTSTREAM(rawoutstream, "%s %Hu\n","FREE_SPACE_THRESHOLD", fs_threshold);
+ PRINTSTREAM(rawoutstream, "%s %s\n","FREE_SPACE_PERSIST", fs_persist ? "TRUE" : "FALSE");
+ indentation(dump_indent + COL);
+ PRINTSTREAM(rawoutstream, "%s %Hu\n","FREE_SPACE_SECTION_THRESHOLD", fs_threshold);
+ indentation(dump_indent + COL);
+ PRINTSTREAM(rawoutstream, "%s %Hu\n","FILE_SPACE_PAGE_SIZE", fsp_size);
/*-------------------------------------------------------------------------
* USER_BLOCK
diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c
index c79db1c..c09dee6 100644
--- a/tools/src/h5repack/h5repack.c
+++ b/tools/src/h5repack/h5repack.c
@@ -78,8 +78,7 @@ int h5repack(const char* infile, const char* outfile, pack_opt_t *options) {
*-------------------------------------------------------------------------
*/
int
-h5repack_init(pack_opt_t *options, int verbose, hbool_t latest,
- H5F_file_space_type_t strategy, hsize_t threshold)
+h5repack_init(pack_opt_t *options, int verbose, hbool_t latest)
{
int k, n;
@@ -96,9 +95,6 @@ h5repack_init(pack_opt_t *options, int verbose, hbool_t latest,
options->filter_g[n].cd_values[k] = 0;
}
- options->fs_strategy = strategy;
- options->fs_threshold = threshold;
-
return (options_table_init(&(options->op_tbl)));
}
diff --git a/tools/src/h5repack/h5repack.h b/tools/src/h5repack/h5repack.h
index d2ab923..5ad0b80 100644
--- a/tools/src/h5repack/h5repack.h
+++ b/tools/src/h5repack/h5repack.h
@@ -30,6 +30,13 @@
#define FORMAT_OBJ_ATTR " %-27s %s\n" /* obj type, name */
#define MAX_COMPACT_DSIZE 64512 /* max data size for compact layout. -1k for header size */
+/* File space default information */
+#define FS_PAGESIZE_DEF 4096
+#define FS_STRATEGY_DEF H5F_FSPACE_STRATEGY_FSM_AGGR
+#define FS_PERSIST_DEF FALSE
+#define FS_THRESHOLD_DEF 1
+
+
/*-------------------------------------------------------------------------
* data structures for command line options
*-------------------------------------------------------------------------
@@ -115,8 +122,10 @@ typedef struct {
hsize_t meta_block_size; /* metadata aggregation block size (for H5Pset_meta_block_size) */
hsize_t threshold; /* alignment threshold for H5Pset_alignment */
hsize_t alignment; /* alignment for H5Pset_alignment */
- H5F_file_space_type_t fs_strategy; /* File space handling strategy */
- hsize_t fs_threshold; /* Free space section threshold */
+ H5F_fspace_strategy_t fs_strategy; /* File space handling strategy */
+ int fs_persist; /* Free space section threshold */
+ long fs_threshold; /* Free space section threshold */
+ long long fs_pagesize; /* File space page size */
} pack_opt_t;
@@ -138,8 +147,7 @@ extern "C" {
int h5repack(const char* infile, const char* outfile, pack_opt_t *options);
int h5repack_addfilter(const char* str, pack_opt_t *options);
int h5repack_addlayout(const char* str, pack_opt_t *options);
-int h5repack_init(pack_opt_t *options, int verbose, hbool_t latest,
- H5F_file_space_type_t strategy, hsize_t threshold);
+int h5repack_init(pack_opt_t *options, int verbose, hbool_t latest);
int h5repack_end(pack_opt_t *options);
int h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options);
int h5repack_cmp_pl(const char *fname1, const char *fname2);
diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c
index 1519053..45d52bf 100644
--- a/tools/src/h5repack/h5repack_copy.c
+++ b/tools/src/h5repack/h5repack_copy.c
@@ -96,6 +96,14 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
hsize_t ub_size = 0; /* size of user block */
hid_t fcpl = H5P_DEFAULT; /* file creation property list ID */
hid_t fapl = H5P_DEFAULT; /* file access property list ID */
+ H5F_fspace_strategy_t set_strategy; /* Strategy to be set in outupt file */
+ hbool_t set_persist; /* Persist free-space status to be set in output file */
+ hsize_t set_threshold; /* Free-space section threshold to be set in output file */
+ hsize_t set_pagesize; /* File space page size to be set in output file */
+ H5F_fspace_strategy_t in_strategy; /* Strategy from input file */
+ hbool_t in_persist; /* Persist free-space status from input file */
+ hsize_t in_threshold; /* Free-space section threshold from input file */
+ hsize_t in_pagesize; /* File space page size from input file */
/*-------------------------------------------------------------------------
* open input file
@@ -106,7 +114,7 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
- /* get user block size and file space strategy/threshold */
+ /* get user block size and file space strategy/persist/threshold */
{
hid_t fcpl_in; /* file creation property list ID for input file */
@@ -120,19 +128,17 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
- if (!options->fs_strategy) {
- if (H5Pget_file_space(fcpl_in, &options->fs_strategy, NULL) < 0) {
- error_msg("failed to retrieve file space strategy\n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
- }
+ /* If the -S option is not set, get "strategy" from the input file */
+ if(H5Pget_file_space_strategy(fcpl_in, &in_strategy, &in_persist, &in_threshold) < 0) {
+ error_msg("failed to retrieve file space strategy\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
- if (!options->fs_threshold) {
- if (H5Pget_file_space(fcpl_in, NULL, &options->fs_threshold) < 0) {
- error_msg("failed to retrieve file space threshold\n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
- }
- }
+ /* If the -G option is not set, get "pagesize" from the input file */
+ if(H5Pget_file_space_page_size(fcpl_in, &in_pagesize) < 0) {
+ error_msg("failed to retrieve file space threshold\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+ }
if (H5Pclose(fcpl_in) < 0) {
error_msg("failed to close property list\n");
@@ -291,9 +297,9 @@ print_user_block(fnamein, fidin);
}
/*-------------------------------------------------------------------------
- * set free-space strategy options
- *-------------------------------------------------------------------------
- */
+ * Set file space information
+ *-------------------------------------------------------------------------
+ */
/* either use the FCPL already created or create a new one */
if (fcpl == H5P_DEFAULT) {
@@ -304,12 +310,44 @@ print_user_block(fnamein, fidin);
}
}
- /* set file space strategy and free space threshold */
- if (H5Pset_file_space(fcpl, options->fs_strategy, options->fs_threshold) < 0) {
- error_msg("failed to set file space strategy & threshold \n");
+ /* Set file space info to those from input file */
+ set_strategy = in_strategy;
+ set_persist = in_persist;
+ set_threshold = in_threshold;
+ set_pagesize = in_pagesize;
+
+ if(options->fs_strategy == (H5F_fspace_strategy_t)-1) /* A default strategy is specified by user */
+ set_strategy = FS_STRATEGY_DEF;
+ else if(options->fs_strategy != (H5F_fspace_strategy_t)0) /* Set strategy as specified by user */
+ set_strategy = options->fs_strategy;
+
+ if(options->fs_persist == -1) /* A default "persist" is specified by user */
+ set_persist = FS_PERSIST_DEF;
+ else if(options->fs_persist != 0) /* Set "persist" as specified by user */
+ set_persist = (hbool_t)options->fs_persist;
+
+ if(options->fs_threshold == -1) /* A "0" threshold is specified by user */
+ set_threshold = (hsize_t)0;
+ else if(options->fs_threshold != 0) /* Set threshold as specified by user */
+ set_threshold = (hsize_t)options->fs_threshold;
+
+ /* Set file space information as specified */
+ if(H5Pset_file_space_strategy(fcpl, set_strategy, set_persist, set_threshold) < 0) {
+ error_msg("failed to set file space strategy\n");
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
}
+ if(options->fs_pagesize == -1) /* A "0" file space page size is specified by user */
+ set_pagesize = (hsize_t)0;
+ else if(options->fs_pagesize != 0) /* Set file space page size as specified by user */
+ set_pagesize = (hsize_t)options->fs_pagesize;
+
+ if(set_pagesize != FS_PAGESIZE_DEF) /* Set non-default file space page size as specified */
+ if(H5Pset_file_space_page_size(fcpl, set_pagesize) < 0) {
+ error_msg("failed to set file space page size\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
+ }
+
/*-------------------------------------------------------------------------
* create the output file
*-------------------------------------------------------------------------
diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c
index 1807056..a8b4cfe 100644
--- a/tools/src/h5repack/h5repack_main.c
+++ b/tools/src/h5repack/h5repack_main.c
@@ -33,7 +33,7 @@ const char *outfile = NULL;
* Command-line options: The user can specify short or long-named
* parameters.
*/
-static const char *s_opts = "hVvf:l:m:e:nLc:d:s:u:b:M:t:a:i:o:S:T:E";
+static const char *s_opts = "hVvf:l:m:e:nLc:d:s:u:b:M:t:a:i:o:S:P:T:G:E";
static struct long_options l_opts[] = {
{ "help", no_arg, 'h' },
{ "version", no_arg, 'V' },
@@ -55,7 +55,9 @@ static struct long_options l_opts[] = {
{ "infile", require_arg, 'i' }, /* -i for backward compability */
{ "outfile", require_arg, 'o' }, /* -o for backward compability */
{ "fs_strategy", require_arg, 'S' },
+ { "fs_persist", require_arg, 'P' },
{ "fs_threshold", require_arg, 'T' },
+ { "fs_pagesize", require_arg, 'G' },
{ "enable-error-stack", no_arg, 'E' },
{ NULL, 0, '\0' }
};
@@ -92,8 +94,10 @@ static void usage(const char *prog) {
PRINTVALSTREAM(rawoutstream, " -a A, --alignment=A Alignment value for H5Pset_alignment\n");
PRINTVALSTREAM(rawoutstream, " -f FILT, --filter=FILT Filter type\n");
PRINTVALSTREAM(rawoutstream, " -l LAYT, --layout=LAYT Layout type\n");
- PRINTVALSTREAM(rawoutstream, " -S FS_STRGY, --fs_strategy=FS_STRGY File space management strategy\n");
- PRINTVALSTREAM(rawoutstream, " -T FS_THRD, --fs_threshold=FS_THRD Free-space section threshold\n");
+ PRINTVALSTREAM(rawoutstream, " -S FS_STRATEGY, --fs_strategy=FS_STRATEGY File space management strategy for H5Pset_file_space_strategy\n");
+ PRINTVALSTREAM(rawoutstream, " -P FS_PERSIST, --fs_persist=FS_PERSIST Persisting or not persisting free-space for H5Pset_file_space_strategy\n");
+ PRINTVALSTREAM(rawoutstream, " -T FS_THRESHOLD, --fs_threshold=FS_THRESHOLD Free-space section threshold for H5Pset_file_space_strategy\n");
+ PRINTVALSTREAM(rawoutstream, " -G FS_PAGESIZE, --fs_pagesize=FS_PAGESIZE File space page size for H5Pset_file_space_page_size\n");
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, " M - is an integer greater than 1, size of dataset in bytes (default is 0) \n");
PRINTVALSTREAM(rawoutstream, " E - is a filename.\n");
@@ -109,18 +113,27 @@ static void usage(const char *prog) {
PRINTVALSTREAM(rawoutstream, " --enable-error-stack Prints messages from the HDF5 error stack as they\n");
PRINTVALSTREAM(rawoutstream, " occur.\n");
PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " FS_STRGY is the file space management strategy to use for the output file.\n");
- PRINTVALSTREAM(rawoutstream, " It is a string as listed below:\n");
- PRINTVALSTREAM(rawoutstream, " ALL_PERSIST - Use persistent free-space managers, aggregators and virtual file driver\n");
- PRINTVALSTREAM(rawoutstream, " for file space allocation\n");
- PRINTVALSTREAM(rawoutstream, " ALL - Use non-persistent free-space managers, aggregators and virtual file driver\n");
- PRINTVALSTREAM(rawoutstream, " for file space allocation\n");
- PRINTVALSTREAM(rawoutstream, " AGGR_VFD - Use aggregators and virtual file driver for file space allocation\n");
- PRINTVALSTREAM(rawoutstream, " VFD - Use virtual file driver for file space allocation\n");
+ PRINTVALSTREAM(rawoutstream, " FS_STRATEGY is a string indicating the file space strategy used:\n");
+ PRINTVALSTREAM(rawoutstream, " FSM_AGGR:\n");
+ PRINTVALSTREAM(rawoutstream, " The mechanisms used in managing file space are free-space managers, aggregators and virtual file driver.\n");
+ PRINTVALSTREAM(rawoutstream, " PAGE:\n");
+ PRINTVALSTREAM(rawoutstream, " The mechanisms used in managing file space are free-space managers with embedded paged aggregation and virtual file driver.\n");
+ PRINTVALSTREAM(rawoutstream, " AGGR:\n");
+ PRINTVALSTREAM(rawoutstream, " The mechanisms used in managing file space are aggregators and virtual file driver.\n");
+ PRINTVALSTREAM(rawoutstream, " NONE:\n");
+ PRINTVALSTREAM(rawoutstream, " The mechanisms used in managing file space are virtual file driver.\n");
+ PRINTVALSTREAM(rawoutstream, " The default strategy when not set is FSM_AGGR without persisting free-space.\n");
PRINTVALSTREAM(rawoutstream, "\n");
- PRINTVALSTREAM(rawoutstream, " FS_THRD is the free-space section threshold to use for the output file.\n");
- PRINTVALSTREAM(rawoutstream, " It is the minimum size (in bytes) of free-space sections to be tracked\n");
- PRINTVALSTREAM(rawoutstream, " by the the library's free-space managers.\n");
+ PRINTVALSTREAM(rawoutstream, " FS_PERSIST is 1 to persisting free-space or 0 to not persisting free-space.\n");
+ PRINTVALSTREAM(rawoutstream, " The default when not set is not persisting free-space.\n");
+ PRINTVALSTREAM(rawoutstream, " The value is ignored for AGGR and NONE strategies.\n");
+ PRINTVALSTREAM(rawoutstream, "\n");
+ PRINTVALSTREAM(rawoutstream, " FS_THRESHOLD is the minimum size (in bytes) of free-space sections to be tracked by the library.\n");
+ PRINTVALSTREAM(rawoutstream, " The default when not set is 1.\n");
+ PRINTVALSTREAM(rawoutstream, " The value is ignored for AGGR and NONE strategies.\n");
+ PRINTVALSTREAM(rawoutstream, "\n");
+ PRINTVALSTREAM(rawoutstream, " FS_PAGESIZE is the size (in bytes) >=512 that is used by the library when the file space strategy PAGE is used.\n");
+ PRINTVALSTREAM(rawoutstream, " The default when not set is 4096.\n");
PRINTVALSTREAM(rawoutstream, "\n");
PRINTVALSTREAM(rawoutstream, " FILT - is a string with the format:\n");
PRINTVALSTREAM(rawoutstream, "\n");
@@ -521,25 +534,45 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
char strategy[MAX_NC_NAME];
HDstrcpy(strategy, opt_arg);
- if(!HDstrcmp(strategy, "ALL_PERSIST"))
- options->fs_strategy = H5F_FILE_SPACE_ALL_PERSIST;
- else if(!HDstrcmp(strategy, "ALL"))
- options->fs_strategy = H5F_FILE_SPACE_ALL;
- else if(!HDstrcmp(strategy, "AGGR_VFD"))
- options->fs_strategy = H5F_FILE_SPACE_AGGR_VFD;
- else if(!HDstrcmp(strategy, "VFD"))
- options->fs_strategy = H5F_FILE_SPACE_VFD;
+ if(!HDstrcmp(strategy, "FSM_AGGR"))
+ options->fs_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR;
+ else if(!HDstrcmp(strategy, "PAGE"))
+ options->fs_strategy = H5F_FSPACE_STRATEGY_PAGE;
+ else if(!HDstrcmp(strategy, "AGGR"))
+ options->fs_strategy = H5F_FSPACE_STRATEGY_AGGR;
+ else if(!HDstrcmp(strategy, "NONE"))
+ options->fs_strategy = H5F_FSPACE_STRATEGY_NONE;
else {
error_msg("invalid file space management strategy\n", opt_arg);
h5tools_setstatus(EXIT_FAILURE);
ret_value = -1;
goto done;
}
+ if(options->fs_strategy == (H5F_fspace_strategy_t)0)
+ /* To distinguish the "specified" zero value */
+ options->fs_strategy = (H5F_fspace_strategy_t)-1;
}
break;
+ case 'P':
+ options->fs_persist = HDatoi( opt_arg );
+ if(options->fs_persist == 0)
+ /* To distinguish the "specified" zero value */
+ options->fs_persist = -1;
+ break;
+
case 'T':
- options->fs_threshold = (hsize_t) HDatol( opt_arg );
+ options->fs_threshold = HDatol( opt_arg );
+ if(options->fs_threshold == 0)
+ /* To distinguish the "specified" zero value */
+ options->fs_threshold = -1;
+ break;
+
+ case 'G':
+ options->fs_pagesize = HDatoll( opt_arg );
+ if(options->fs_pagesize == 0)
+ /* To distinguish the "specified" zero value */
+ options->fs_pagesize = -1;
break;
case 'E':
@@ -611,7 +644,7 @@ int main(int argc, const char **argv)
}
/* initialize options */
- h5repack_init(&options, 0, FALSE, H5F_FILE_SPACE_DEFAULT, (hsize_t) 0);
+ h5repack_init(&options, 0, FALSE);
if (parse_command_line(argc, argv, &options) < 0)
goto done;
diff --git a/tools/src/h5repack/h5repack_verify.c b/tools/src/h5repack/h5repack_verify.c
index 58dea03..1022d7a 100644
--- a/tools/src/h5repack/h5repack_verify.c
+++ b/tools/src/h5repack/h5repack_verify.c
@@ -58,8 +58,10 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
int ok = 1;
hid_t fcpl_in = -1; /* file creation property for input file */
hid_t fcpl_out = -1; /* file creation property for output file */
- H5F_file_space_type_t in_strat, out_strat; /* file space handling strategy for in/output file */
- hsize_t in_thresh, out_thresh; /* free space section threshold for in/output file */
+ H5F_fspace_strategy_t in_strategy, out_strategy; /* file space handling strategy for in/output file */
+ hbool_t in_persist, out_persist; /* free-space persist status for in/output file */
+ hsize_t in_threshold, out_threshold; /* free-space section threshold for in/output file */
+ hsize_t in_pagesize, out_pagesize; /* file space page size for input/output file */
/* open the output file */
if((fidout = H5Fopen(out_fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0 )
@@ -196,8 +198,7 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
}
/*-------------------------------------------------------------------------
- * Verify that file space strategy and free space threshold
- * are set as expected
+ * Verify that file space info are set as expected
*-------------------------------------------------------------------------
*/
@@ -211,12 +212,18 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fget_create_plist failed");
}
- /* Get file space management info for input file */
- if(H5Pget_file_space(fcpl_in, &in_strat, &in_thresh) < 0) {
+ /* Get file space info for input file */
+ if(H5Pget_file_space_strategy(fcpl_in, &in_strategy, &in_persist, &in_threshold) < 0) {
error_msg("failed to retrieve file space strategy & threshold\n");
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_file_space failed");
}
+ /* Get file space page size for input file */
+ if(H5Pget_file_space_page_size(fcpl_in, &in_pagesize) < 0) {
+ error_msg("failed to retrieve file space page size\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fget_create_plist failed");
+ }
+
/* Output file is already opened */
/* Get file creation property list for output file */
if((fcpl_out = H5Fget_create_plist(fidout)) < 0) {
@@ -224,45 +231,84 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fget_create_plist failed");
}
- /* Get file space management info for output file */
- if(H5Pget_file_space(fcpl_out, &out_strat, &out_thresh) < 0) {
+ /* Get file space info for output file */
+ if(H5Pget_file_space_strategy(fcpl_out, &out_strategy, &out_persist, &out_threshold) < 0) {
error_msg("failed to retrieve file space strategy & threshold\n");
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_file_space failed");
}
+ /* Get file space page size for output file */
+ if(H5Pget_file_space_page_size(fcpl_out, &out_pagesize) < 0) {
+ error_msg("failed to retrieve file space page size\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fget_create_plist failed");
+ }
+
/*
- * If the strategy option is not set,
- * file space handling strategy should be the same for both
- * input & output files.
- * If the strategy option is set,
- * the output file's file space handling strategy should be the same
- * as what is set via the strategy option
+ * If -S option is set, the file space handling strategy should be set as specified.
+ * If -S option is not set, the file space handling strategy should be
+ * the same as the input file's strategy.
*/
- if(!options->fs_strategy && out_strat != in_strat) {
- error_msg("file space strategy not set as unexpected\n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected");
-
+ if(options->fs_strategy) {
+ if(out_strategy != (options->fs_strategy == (-1) ? 0 : options->fs_strategy)) {
+ error_msg("file space strategy not set as unexpected\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected");
+ }
+ } else {
+ if(out_strategy != in_strategy) {
+ error_msg("file space strategy not set as unexpected\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected");
+ }
}
- else if(options->fs_strategy && out_strat!= options->fs_strategy) {
- error_msg("file space strategy not set as unexpected\n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected");
+
+ /*
+ * If the -P option is set, the free-space persist status should be set as specified.
+ * If the -P option is not set, the free-space persist status should be
+ * the same as the input file's free-space persist status
+ */
+ if(options->fs_persist) {
+ if(out_persist != (hbool_t)(options->fs_persist == (-1) ? FALSE : options->fs_persist)) {
+ error_msg("free-space persist status is not set as unexpected\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected");
+ }
+ } else {
+ if(out_persist != in_persist) {
+ error_msg("free-space persist status is not set as unexpected\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected");
+ }
}
/*
- * If the threshold option is not set,
- * the free space section threshold should be the same for both
- * input & output files.
- * If the threshold option is set,
- * the output file's free space section threshold should be the same
- * as what is set via the threshold option.
+ * If the -T option is set, the threshold size should be set as specified.
+ * If the -T option is not set, the threshold should be the same as the
+ * input file's threshold size.
*/
- if(!options->fs_threshold && out_thresh != in_thresh) {
- error_msg("free space threshold not set as unexpected\n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "free space threshold not set as unexpected");
+ if(options->fs_threshold) {
+ if(out_threshold != (hsize_t)(options->fs_threshold == (-1) ? 0 : options->fs_threshold)) {
+ error_msg("threshold is not set as unexpectec\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected");
+ }
+ } else {
+ if(out_threshold != in_threshold) {
+ error_msg("threshold is not set as unexpected\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected");
+ }
}
- else if(options->fs_threshold && out_thresh != options->fs_threshold) {
- error_msg("free space threshold not set as unexpected\n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "free space threshold not set as unexpected");
+
+ /*
+ * If the -G option is set, the file space page size should be set as specified.
+ * If the -G option is not set, the file space page size should be
+ * the same as the input file's file space page size.
+ */
+ if(options->fs_pagesize) {
+ if(out_pagesize != (hsize_t)(options->fs_pagesize == (-1) ? 0 : options->fs_pagesize)) {
+ error_msg("file space page size is not set as unexpected\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected");
+ }
+ } else { /* "-G" is not set */
+ if(out_pagesize != in_pagesize) {
+ error_msg("file space page size is not set as unexpected\n");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected");
+ }
}
/* Closing */
diff --git a/tools/src/h5stat/h5stat.c b/tools/src/h5stat/h5stat.c
index a331014..f99bab0 100644
--- a/tools/src/h5stat/h5stat.c
+++ b/tools/src/h5stat/h5stat.c
@@ -40,11 +40,11 @@
/* File space management strategies: see H5Fpublic.h for declarations */
const char *FS_STRATEGY_NAME[] = {
+ "H5F_FSPACE_STRATEGY_FSM_AGGR",
+ "H5F_FSPACE_STRATEGY_PAGE",
+ "H5F_FSPACE_STRATEGY_AGGR",
+ "H5F_FSPACE_STRATEGY_NONE",
"unknown",
- "H5F_FILE_SPACE_ALL_PERSIST",
- "H5F_FILE_SPACE_ALL",
- "H5F_FILE_SPACE_AGGR_VFD",
- "H5F_FILE_SPACE_VFD",
NULL
};
@@ -106,10 +106,12 @@ typedef struct iter_t {
hsize_t super_size; /* superblock size */
hsize_t super_ext_size; /* superblock extension size */
hsize_t ublk_size; /* user block size (if exists) */
- H5F_file_space_type_t fs_strategy; /* File space management strategy */
+ H5F_fspace_strategy_t fs_strategy; /* File space management strategy */
+ hbool_t fs_persist; /* Free-space persist or not */
hsize_t fs_threshold; /* Free-space section threshold */
- hsize_t free_space; /* amount of freespace in the file */
- hsize_t free_hdr; /* size of free space manager metadata in the file */
+ hsize_t fsp_size; /* File space page size */
+ hsize_t free_space; /* Amount of freespace in the file */
+ hsize_t free_hdr; /* Size of free space manager metadata in the file */
unsigned long num_small_sects[SIZE_SMALL_SECTS]; /* Size of small free-space sections */
unsigned sect_nbins; /* Number of bins for free-space section sizes */
unsigned long *sect_bins; /* Pointer to array of bins for free-space section sizes */
@@ -1501,6 +1503,7 @@ print_freespace_info(const iter_t *iter)
unsigned long total; /* Total count for various statistics */
unsigned u; /* Local index variable */
+ HDfprintf(stdout, "Free-space persist: %s\n", iter->fs_persist ? "TRUE" : "FALSE");
HDfprintf(stdout, "Free-space section threshold: %Hu bytes\n", iter->fs_threshold);
printf("Small size free-space sections (< %u bytes):\n", (unsigned)SIZE_SMALL_SECTS);
total = 0;
@@ -1551,6 +1554,7 @@ print_storage_summary(const iter_t *iter)
double percent = 0.0f;
HDfprintf(stdout, "File space management strategy: %s\n", FS_STRATEGY_NAME[iter->fs_strategy]);
+ HDfprintf(stdout, "File space page size: %Hu bytes\n", iter->fsp_size);
printf("Summary of file space information:\n");
total_meta =
iter->super_size + iter->super_ext_size + iter->ublk_size +
@@ -1772,9 +1776,12 @@ main(int argc, const char *argv[])
if(H5Pget_userblock(fcpl, &iter.ublk_size) < 0)
warn_msg("Unable to retrieve userblock size\n");
- if(H5Pget_file_space(fcpl, &iter.fs_strategy, &iter.fs_threshold) < 0)
+ if(H5Pget_file_space_strategy(fcpl, &iter.fs_strategy, &iter.fs_persist, &iter.fs_threshold) < 0)
warn_msg("Unable to retrieve file space information\n");
- HDassert(iter.fs_strategy != 0 && iter.fs_strategy < H5F_FILE_SPACE_NTYPES);
+ HDassert(iter.fs_strategy >= 0 && iter.fs_strategy < H5F_FSPACE_STRATEGY_NTYPES);
+
+ if(H5Pget_file_space_page_size(fcpl, &iter.fsp_size) < 0)
+ warn_msg("Unable to retrieve file space page size\n");
/* get information for free-space sections */
if(freespace_stats(fid, &iter) < 0)
diff --git a/tools/src/misc/h5clear.c b/tools/src/misc/h5clear.c
index 481c6db..b6c6ea3 100644
--- a/tools/src/misc/h5clear.c
+++ b/tools/src/misc/h5clear.c
@@ -14,11 +14,10 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer:
- *
- * Purpose:
+ * Purpose: A tool to clear the status_flags field from the file's superblock via -s option.
+ * A tool to remove cache image from the file via -m option.
+ *
*/
-
#include "hdf5.h"
#include "H5private.h"
#include "h5tools.h"
@@ -30,59 +29,171 @@
/* Make this private property (defined in H5Fprivate.h) available to h5clear. */
#define H5F_ACS_CLEAR_STATUS_FLAGS_NAME "clear_status_flags"
+static char *fname_g = NULL;
+static hbool_t clear_status_flags = FALSE;
+static hbool_t remove_cache_image = FALSE;
+
+/*
+ * Command-line options: The user can specify short or long-named
+ * parameters.
+ */
+static const char *s_opts = "hVsm";
+static struct long_options l_opts[] = {
+ { "help", no_arg, 'h' },
+ { "hel", no_arg, 'h'},
+ { "he", no_arg, 'h'},
+ { "version", no_arg, 'V' },
+ { "version", no_arg, 'V' },
+ { "versio", no_arg, 'V' },
+ { "versi", no_arg, 'V' },
+ { "vers", no_arg, 'V' },
+ { "status", no_arg, 's' },
+ { "statu", no_arg, 's' },
+ { "stat", no_arg, 's' },
+ { "sta", no_arg, 's' },
+ { "st", no_arg, 's' },
+ { "image", no_arg, 'm' },
+ { "imag", no_arg, 'm' },
+ { "ima", no_arg, 'm' },
+ { "im", no_arg, 'm' },
+ { NULL, 0, '\0' }
+};
+
+
+
/*-------------------------------------------------------------------------
- * Function: leave
+ * Function: usage
*
- * Purpose: Close the tools library and exit
+ * Purpose: Prints a usage message
*
- * Return: Does not return
+ * Return: void
*
*-------------------------------------------------------------------------
*/
-static void
-leave(int ret)
+static void usage(const char *prog)
{
- h5tools_close();
- HDexit(ret);
-} /* leave() */
+ HDfprintf(stdout, "usage: %s [OPTIONS] file_name\n", prog);
+ HDfprintf(stdout, " OPTIONS\n");
+ HDfprintf(stdout, " -h, --help Print a usage message and exit\n");
+ HDfprintf(stdout, " -V, --version Print version number and exit\n");
+ HDfprintf(stdout, " -s, --status Clear the status_flags field in the file's superblock\n");
+ HDfprintf(stdout, " -m, --image Remove the metadata cache image from the file\n");
+ HDfprintf(stdout, "\n");
+ HDfprintf(stdout, "Examples of use:\n");
+ HDfprintf(stdout, "\n");
+ HDfprintf(stdout, "h5clear -s file_name\n");
+ HDfprintf(stdout, " Clear the status_flags field in the superblock of the HDF5 file <file_name>.\n");
+ HDfprintf(stdout, "\n");
+ HDfprintf(stdout, "h5clear -m file_name\n");
+ HDfprintf(stdout, " Remove the metadata cache image from the HDF5 file <file_name>.\n");
+} /* usage() */
+
/*-------------------------------------------------------------------------
- * Function: usage
+ * Function: parse_command_line
*
- * Purpose: Prints a usage message
+ * Purpose: Parses command line and sets up global variable to control output
+ *
+ * Return: Success: 0
*
- * Return: void
+ * Failure: -1
*
*-------------------------------------------------------------------------
*/
-static void
-usage(void)
+static int
+parse_command_line(int argc, const char **argv)
{
- HDfprintf(stdout, "usage: h5clear filename\n");
+ int opt;
-} /* usage() */
+ /* no arguments */
+ if (argc == 1) {
+ usage(h5tools_getprogname());
+ h5tools_setstatus(EXIT_FAILURE);
+ goto error;
+ }
+
+ /* parse command line options */
+ while((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
+ switch((char)opt) {
+ case 'h':
+ usage(h5tools_getprogname());
+ h5tools_setstatus(EXIT_SUCCESS);
+ goto done;
+
+ case 'V':
+ print_version(h5tools_getprogname());
+ h5tools_setstatus(EXIT_SUCCESS);
+ goto done;
+
+ case 's':
+ clear_status_flags = TRUE;
+ break;
+
+ case 'm':
+ remove_cache_image = TRUE;
+ break;
+
+ default:
+ usage(h5tools_getprogname());
+ h5tools_setstatus(EXIT_FAILURE);
+ goto error;
+ } /* end switch */
+ } /* end while */
+
+ /* check for file name to be processed */
+ if(argc <= opt_ind) {
+ error_msg("missing file name\n");
+ usage(h5tools_getprogname());
+ h5tools_setstatus(EXIT_FAILURE);
+ goto error;
+ } /* end if */
+
+ fname_g = HDstrdup(argv[opt_ind]);
+
+done:
+ return(0);
+
+error:
+ return -1;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: leave
+ *
+ * Purpose: Close the tools library and exit
+ *
+ * Return: Does not return
+ *
+ *-------------------------------------------------------------------------
+ */
+static void
+leave(int ret)
+{
+ h5tools_close();
+ HDexit(ret);
+} /* leave() */
/*-------------------------------------------------------------------------
* Function: main
*
- * Purpose:
- *
- * Return: Success:
- * Failure:
+ * Purpose: To clear the status_flags field in the file's superblock (-s option).
+ * To remove the cache image from the file (-m option).
*
- * Programmer:
+ * Return: Success: 0
+ * Failure: 1
*
*-------------------------------------------------------------------------
*/
int
-main (int argc, char *argv[])
+main (int argc, const char *argv[])
{
- char *fname; /* File name */
- hbool_t clear = TRUE; /* To clear the status_flags in the file's superblock */
- hid_t fapl = -1; /* File access property list */
+ char *fname = NULL; /* File name */
+ hid_t fapl = -1; /* File access property list */
hid_t fid = -1; /* File ID */
+ haddr_t image_addr;
+ hsize_t image_len;
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
@@ -93,46 +204,80 @@ main (int argc, char *argv[])
/* initialize h5tools lib */
h5tools_init();
- /* Check for the # of arguments */
- if(argc != 2) {
- usage();
- leave(EXIT_FAILURE);
+ /* Parse command line options */
+ if(parse_command_line(argc, argv) < 0)
+ goto done;
+
+ if(fname_g == NULL)
+ goto done;
+
+ if(!clear_status_flags && !remove_cache_image) {
+ usage(h5tools_getprogname());
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
+ /* Duplicate the file name */
+ fname = HDstrdup(fname_g);
+
/* Get a copy of the file access property list */
if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
error_msg("H5Pcreate\n");
- leave(EXIT_FAILURE);
- }
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
- /* Set to clear the status_flags in the file's superblock */
- /* This is a private property used by h5clear only */
- if(H5Pset(fapl, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, &clear) < 0) {
- error_msg("H5Pset\n");
- leave(EXIT_FAILURE);
+ /* -s option */
+ if(clear_status_flags) {
+ /* Set to clear the status_flags in the file's superblock */
+ /* This is a private property used by h5clear only */
+ if(H5Pset(fapl, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, &clear_status_flags) < 0) {
+ error_msg("H5Pset\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
}
- /* Duplicate the file name */
- fname = HDstrdup(argv[opt_ind]);
-
if((fid = h5tools_fopen(fname, H5F_ACC_RDWR, fapl, NULL, NULL, (size_t)0)) < 0) {
error_msg("h5tools_fopen\n");
- HDfree(fname);
- leave(EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
- HDfree(fname);
- /* Close the file */
- if(H5Fclose(fid) < 0) {
- error_msg("H5Fclose\n");
- leave(EXIT_FAILURE);
- }
+ /* -m option */
+ if(remove_cache_image) {
+ H5AC_cache_image_config_t config;
- /* CLose the property list */
- if(H5Pclose(fapl) < 0) {
- error_msg("H5Pclose\n");
- leave(EXIT_FAILURE);
- }
+ /* Retrieve cache image config */
+ if((fapl = H5Fget_access_plist(fid)) < 0) {
+ error_msg("H5Fget_access_plist\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+ config.version = H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION;
+ if(H5Pget_mdc_image_config(fapl, &config) < 0) {
+ error_msg("H5Pget_mdc_image_config\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+
+ /* Check for image */
+ if(!config.generate_image)
+ warn_msg("No cache image in the file\n");
+ }
+
+ h5tools_setstatus(EXIT_SUCCESS);
+
+done:
+ if(fname)
+ HDfree(fname);
+ if(fname_g)
+ HDfree(fname_g);
+
+ H5E_BEGIN_TRY {
+ H5Pclose(fapl);
+ H5Fclose(fid);
+ } H5E_END_TRY
leave(h5tools_getstatus());
} /* main() */