summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2018-03-12 23:00:05 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2018-03-12 23:00:05 (GMT)
commita8afb3ab3b32b07611fb5932303dd0594a1c9658 (patch)
tree670003b264edae0bd2f4ee60233fe5be3dd2a0f2
parent612fefc435a9bc07ada6a380a54878f1cf71ae09 (diff)
parentf08b8fa10e7bac5ae26e3b06f938d38ebb3f28e1 (diff)
downloadhdf5-a8afb3ab3b32b07611fb5932303dd0594a1c9658.zip
hdf5-a8afb3ab3b32b07611fb5932303dd0594a1c9658.tar.gz
hdf5-a8afb3ab3b32b07611fb5932303dd0594a1c9658.tar.bz2
Merge pull request #931 in HDFFV/hdf5 from ~VCHOI/my_hdf5_fork:develop to develop
* commit 'f08b8fa10e7bac5ae26e3b06f938d38ebb3f28e1': Enhancement to the tool h5clear (HDFFV-10360) Fix for HDFFV-10209 VDS SWMR test failure Free the object header when there are chksum retries.
-rw-r--r--MANIFEST23
-rw-r--r--src/H5F.c94
-rw-r--r--src/H5Fint.c41
-rw-r--r--src/H5Fpkg.h3
-rw-r--r--src/H5Fprivate.h4
-rw-r--r--src/H5Fpublic.h2
-rw-r--r--src/H5Fsuper.c112
-rw-r--r--src/H5Ocache.c39
-rw-r--r--src/H5Oint.c1
-rw-r--r--src/H5Opkg.h1
-rw-r--r--src/H5Pfapl.c21
-rw-r--r--test/tfile.c128
-rw-r--r--tools/src/misc/h5clear.c158
-rw-r--r--tools/test/misc/CMakeTestsClear.cmake100
-rw-r--r--tools/test/misc/h5clear_gentest.c369
-rw-r--r--tools/test/misc/testfiles/h5clear_equal_after_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_equal_before_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_fsm_persist_equal.h5bin0 -> 2565 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_fsm_persist_greater.h5bin0 -> 2565 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_fsm_persist_less.h5bin0 -> 2565 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_fsm_persist_noclose.h5bin0 -> 2448 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_fsm_persist_user_equal.h5bin0 -> 3077 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_fsm_persist_user_greater.h5bin0 -> 3077 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_fsm_persist_user_less.h5bin0 -> 3077 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_greater_after_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_greater_before_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_less_after_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_less_before_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_missing_file.ddl10
-rw-r--r--tools/test/misc/testfiles/h5clear_noclose_after_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_noclose_before_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_status_noclose.h5bin0 -> 2448 bytes
-rw-r--r--tools/test/misc/testfiles/h5clear_status_noclose_after_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_usage.ddl10
-rw-r--r--tools/test/misc/testfiles/h5clear_user_equal_after_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_user_equal_before_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_user_greater_after_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_user_greater_before_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_user_less_after_size.ddl1
-rw-r--r--tools/test/misc/testfiles/h5clear_user_less_before_size.ddl1
-rw-r--r--tools/test/misc/testh5clear.sh.in122
41 files changed, 1148 insertions, 105 deletions
diff --git a/MANIFEST b/MANIFEST
index 7d28f12..df368aa 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1488,15 +1488,38 @@
./tools/test/misc/testh5mkgrp.sh.in
./tools/test/misc/testh5repart.sh.in
./tools/test/misc/talign.c
+./tools/test/misc/testfiles/h5clear_equal_after_size.ddl
+./tools/test/misc/testfiles/h5clear_equal_before_size.ddl
+./tools/test/misc/testfiles/h5clear_greater_after_size.ddl
+./tools/test/misc/testfiles/h5clear_greater_before_size.ddl
+./tools/test/misc/testfiles/h5clear_less_after_size.ddl
+./tools/test/misc/testfiles/h5clear_less_before_size.ddl
./tools/test/misc/testfiles/h5clear_missing_file.ddl
+./tools/test/misc/testfiles/h5clear_noclose_after_size.ddl
+./tools/test/misc/testfiles/h5clear_noclose_before_size.ddl
./tools/test/misc/testfiles/h5clear_no_mdc_image.ddl
./tools/test/misc/testfiles/h5clear_open_fail.ddl
+./tools/test/misc/testfiles/h5clear_status_noclose_after_size.ddl
./tools/test/misc/testfiles/h5clear_usage.ddl
+./tools/test/misc/testfiles/h5clear_user_equal_after_size.ddl
+./tools/test/misc/testfiles/h5clear_user_equal_before_size.ddl
+./tools/test/misc/testfiles/h5clear_user_greater_after_size.ddl
+./tools/test/misc/testfiles/h5clear_user_greater_before_size.ddl
+./tools/test/misc/testfiles/h5clear_user_less_after_size.ddl
+./tools/test/misc/testfiles/h5clear_user_less_before_size.ddl
+./tools/test/misc/testfiles/h5clear_fsm_persist_equal.h5
+./tools/test/misc/testfiles/h5clear_fsm_persist_greater.h5
+./tools/test/misc/testfiles/h5clear_fsm_persist_less.h5
+./tools/test/misc/testfiles/h5clear_fsm_persist_noclose.h5
+./tools/test/misc/testfiles/h5clear_fsm_persist_user_equal.h5
+./tools/test/misc/testfiles/h5clear_fsm_persist_user_greater.h5
+./tools/test/misc/testfiles/h5clear_fsm_persist_user_less.h5
./tools/test/misc/testfiles/h5clear_log_v3.h5
./tools/test/misc/testfiles/h5clear_mdc_image.h5
./tools/test/misc/testfiles/h5clear_sec2_v0.h5
./tools/test/misc/testfiles/h5clear_sec2_v2.h5
./tools/test/misc/testfiles/h5clear_sec2_v3.h5
+./tools/test/misc/testfiles/h5clear_status_noclose.h5
./tools/test/misc/testfiles/latest_h5clear_log_v3.h5
./tools/test/misc/testfiles/latest_h5clear_sec2_v3.h5
./tools/test/misc/testfiles/mod_h5clear_mdc_image.h5
diff --git a/src/H5F.c b/src/H5F.c
index 8e5f65a..2cd65cb 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -845,8 +845,6 @@ herr_t
H5Fget_filesize(hid_t file_id, hsize_t *size)
{
H5F_t *file; /* File object for file ID */
- haddr_t eof; /* End of file address */
- haddr_t eoa; /* End of allocation address */
haddr_t max_eof_eoa; /* Maximum of the EOA & EOF */
haddr_t base_addr; /* Base address for the file */
herr_t ret_value = SUCCEED; /* Return value */
@@ -859,11 +857,9 @@ H5Fget_filesize(hid_t file_id, hsize_t *size)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID")
/* Go get the actual file size */
- eof = H5FD_get_eof(file->shared->lf, H5FD_MEM_DEFAULT);
- eoa = H5FD_get_eoa(file->shared->lf, H5FD_MEM_DEFAULT);
- max_eof_eoa = MAX(eof, eoa);
- if(HADDR_UNDEF == max_eof_eoa)
- HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file get eof/eoa requests failed")
+ if(H5F__get_max_eof_eoa(file, &max_eof_eoa) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ")
+
base_addr = H5FD_get_base_addr(file->shared->lf);
if(size)
@@ -1949,3 +1945,87 @@ done:
FUNC_LEAVE_API(ret_value)
} /* H5Fget_mdc_image_info() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5Fget_eoa
+ *
+ * Purpose: Returns the address of the first byte after the last
+ * allocated memory in the file.
+ * (See H5FDget_eoa() in H5FD.c)
+ *
+ * Return: Success: First byte after allocated memory.
+ * Failure: HADDR_UNDEF
+ *
+ * Return: Non-negative on success/Negative on errors
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Fget_eoa(hid_t file_id, haddr_t *eoa)
+{
+ H5F_t *file; /* File object for file ID */
+ haddr_t rel_eoa; /* Relative address of EOA */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE2("e", "i*a", file_id, eoa);
+
+ /* Check args */
+ if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID")
+
+ /* This public routine will work only for drivers with this feature enabled.*/
+ /* We might introduce a new feature flag in the future */
+ if(!H5F_HAS_FEATURE(file, H5FD_FEAT_SUPPORTS_SWMR_IO))
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must use a SWMR-compatible VFD for this public routine")
+
+ /* The real work */
+ if(HADDR_UNDEF == (rel_eoa = H5FD_get_eoa(file->shared->lf, H5FD_MEM_DEFAULT)))
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "get_eoa request failed")
+
+ /* (Note compensating for base address subtraction in internal routine) */
+ if(eoa)
+ *eoa = rel_eoa + H5FD_get_base_addr(file->shared->lf);
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* H5Fget_eoa() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Fincrement_filesize
+ *
+ * Purpose: Set the EOA for the file to the maximum of (EOA, EOF) + increment
+ *
+ * Return: Non-negative on success/Negative on errors
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Fincrement_filesize(hid_t file_id, hsize_t increment)
+{
+ H5F_t *file; /* File object for file ID */
+ haddr_t max_eof_eoa; /* Maximum of the relative EOA & EOF */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE2("e", "ih", file_id, increment);
+
+ /* Check args */
+ if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID")
+
+ /* This public routine will work only for drivers with this feature enabled.*/
+ /* We might introduce a new feature flag in the future */
+ if(!H5F_HAS_FEATURE(file, H5FD_FEAT_SUPPORTS_SWMR_IO))
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must use a SWMR-compatible VFD for this public routine")
+
+ /* Get the maximum of EOA and EOF */
+ if(H5F__get_max_eof_eoa(file, &max_eof_eoa) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ")
+
+ /* Set EOA to the maximum value + increment */
+ /* H5FD_set_eoa() will add base_addr to max_eof_eoa */
+ if(H5FD_set_eoa(file->shared->lf, H5FD_MEM_DEFAULT, max_eof_eoa + increment) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set_eoa request failed")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* H5Fincrement_filesize() */
diff --git a/src/H5Fint.c b/src/H5Fint.c
index cc5931a..24844a4 100644
--- a/src/H5Fint.c
+++ b/src/H5Fint.c
@@ -124,7 +124,6 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref)
H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */
hbool_t driver_prop_copied = FALSE; /* Whether the driver property has been set up */
unsigned efc_size = 0;
- hbool_t latest_format = FALSE; /* Always use the latest format? */
hid_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -820,7 +819,6 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t
else {
H5P_genplist_t *plist; /* Property list */
unsigned efc_size; /* External file cache size */
- hbool_t latest_format; /* Always use the latest format? */
size_t u; /* Local index variable */
HDassert(lf != NULL);
@@ -1602,7 +1600,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id,
} /* end if */
else if (1 == shared->nrefs) {
/* Read the superblock if it hasn't been read before. */
- if(H5F__super_read(file, meta_dxpl_id, raw_dxpl_id, TRUE) < 0)
+ if(H5F__super_read(file, meta_dxpl_id, raw_dxpl_id, fapl_id, TRUE) < 0)
HGOTO_ERROR(H5E_FILE, H5E_READERROR, NULL, "unable to read superblock")
/* Create the page buffer before initializing the superblock */
@@ -2921,6 +2919,43 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F__set_paged_aggr() */
+/*-------------------------------------------------------------------------
+ * Function: H5F__get_max_eof_eoa
+ *
+ * Purpose: Determine the maximum of (EOA, EOF) for the file
+ *
+ * Return: Non-negative on success/Negative on failure
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5F__get_max_eof_eoa(const H5F_t *f, haddr_t *max_eof_eoa)
+{
+ haddr_t eof; /* Relative address for EOF */
+ haddr_t eoa; /* Relative address for EOA */
+ haddr_t tmp_max;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_PACKAGE
+
+ /* Sanity checks */
+ HDassert(f);
+ HDassert(f->shared);
+
+ /* Get the relative EOA and EOF */
+ eoa = H5FD_get_eoa(f->shared->lf, H5FD_MEM_DEFAULT);
+ eof = H5FD_get_eof(f->shared->lf, H5FD_MEM_DEFAULT);
+
+ /* Determine the maximum */
+ tmp_max = MAX(eof, eoa);
+ if(HADDR_UNDEF == tmp_max)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file get eof/eoa requests failed")
+
+ *max_eof_eoa = tmp_max;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5F__get_max_eof_eoa() */
+
#ifdef H5_HAVE_PARALLEL
/*-------------------------------------------------------------------------
diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h
index c9aba56..a4c1a24 100644
--- a/src/H5Fpkg.h
+++ b/src/H5Fpkg.h
@@ -412,7 +412,7 @@ H5_DLL herr_t H5F_mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nop
/* Superblock related routines */
H5_DLL herr_t H5F__super_init(H5F_t *f, hid_t dxpl_id);
-H5_DLL herr_t H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id,
+H5_DLL herr_t H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hid_t fapl_id,
hbool_t initial_read);
H5_DLL herr_t H5F__super_size(H5F_t *f, hid_t dxpl_id, hsize_t *super_size, hsize_t *super_ext_size);
H5_DLL herr_t H5F__super_free(H5F_super_t *sblock);
@@ -457,6 +457,7 @@ H5_DLL htri_t H5F_try_extend(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type,
H5_DLL herr_t H5F__set_eoa(const H5F_t *f, H5F_mem_t type, haddr_t addr);
H5_DLL herr_t H5F__set_base_addr(const H5F_t *f, haddr_t addr);
H5_DLL herr_t H5F__set_paged_aggr(const H5F_t *f, hbool_t paged);
+H5_DLL herr_t H5F__get_max_eof_eoa(const H5F_t *f, haddr_t *max_eof_eoa);
/* Functions that flush or evict */
H5_DLL herr_t H5F__evict_cache_entries(H5F_t *f, hid_t dxpl_id);
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index 856e618..28ebbd2 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -492,6 +492,10 @@ typedef struct H5F_t H5F_t;
#define H5F_ACS_EFC_SIZE_NAME "efc_size" /* Size of external file cache */
#define H5F_ACS_FILE_IMAGE_INFO_NAME "file_image_info" /* struct containing initial file image and callback info */
#define H5F_ACS_CLEAR_STATUS_FLAGS_NAME "clear_status_flags" /* Whether to clear superblock status_flags (private property only used by h5clear) */
+#define H5F_ACS_NULL_FSM_ADDR_NAME "null_fsm_addr" /* Nullify addresses of free-space managers */
+ /* Private property used only by h5clear */
+#define H5F_ACS_SKIP_EOF_CHECK_NAME "skip_eof_check" /* Skip EOF check */
+ /* Private property used only by h5clear */
#define H5F_ACS_USE_MDC_LOGGING_NAME "use_mdc_logging" /* Whether to use metadata cache logging */
#define H5F_ACS_MDC_LOG_LOCATION_NAME "mdc_log_location" /* Name of metadata cache log location */
#define H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME "start_mdc_log_on_access" /* Whether logging starts on file create/open */
diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h
index d333fa7..73c59f5 100644
--- a/src/H5Fpublic.h
+++ b/src/H5Fpublic.h
@@ -241,6 +241,8 @@ H5_DLL herr_t H5Fmount(hid_t loc, const char *name, hid_t child, hid_t plist);
H5_DLL herr_t H5Funmount(hid_t loc, const char *name);
H5_DLL hssize_t H5Fget_freespace(hid_t file_id);
H5_DLL herr_t H5Fget_filesize(hid_t file_id, hsize_t *size);
+H5_DLL herr_t H5Fget_eoa(hid_t file_id, haddr_t *eoa);
+H5_DLL herr_t H5Fincrement_filesize(hid_t file_id, hsize_t increment);
H5_DLL ssize_t H5Fget_file_image(hid_t file_id, void * buf_ptr, size_t buf_len);
H5_DLL herr_t H5Fget_mdc_config(hid_t file_id,
H5AC_cache_config_t * config_ptr);
diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c
index 4250ff0..3db9b2f 100644
--- a/src/H5Fsuper.c
+++ b/src/H5Fsuper.c
@@ -324,7 +324,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t initial_read)
+H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hid_t fapl_id, hbool_t initial_read)
{
H5P_genplist_t *dxpl = NULL; /* DXPL object */
H5AC_ring_t ring, orig_ring = H5AC_RING_INV;
@@ -337,7 +337,8 @@ H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t initial
haddr_t eof; /* End of file address */
unsigned rw_flags; /* Read/write permissions for file */
hbool_t skip_eof_check = FALSE; /* Whether to skip checking the EOF value */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5P_genplist_t *a_plist; /* File access property list */
+ herr_t ret_value = SUCCEED; /* Return value */
#ifdef H5_HAVE_PARALLEL
int mpi_rank = 0, mpi_size = 1;
int mpi_result;
@@ -595,6 +596,20 @@ H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t initial
* as the file can appear truncated if only part of it has been
* been flushed to disk by the SWMR writer process.
*/
+ /* The EOF check is also skipped when the private property
+ * H5F_ACS_SKIP_EOF_CHECK_NAME exists in the fapl.
+ * This property is enabled by the tool h5clear with these
+ * two options: (1) --filesize (2) --increment
+ */
+
+ /* Check if this private property exists in fapl */
+ if(NULL == (a_plist = (H5P_genplist_t *)H5I_object(fapl_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list")
+ if(H5P_exist_plist(a_plist, H5F_ACS_SKIP_EOF_CHECK_NAME) > 0) {
+ if(H5P_get(a_plist, H5F_ACS_SKIP_EOF_CHECK_NAME, &skip_eof_check) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get clearance for persisting fsm addr")
+ }
+
if(H5F_INTENT(f) & H5F_ACC_SWMR_READ) {
/*
* When the file is opened for SWMR read access, skip the check if:
@@ -757,6 +772,7 @@ H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t initial
if(status) {
H5O_fsinfo_t fsinfo; /* File space info message from superblock extension */
uint8_t flags; /* Message flags */
+ hbool_t null_fsm_addr = FALSE; /* Whether to drop free-space to the floor */
/* Get message flags */
if(H5O_msg_get_flags(&ext_loc, H5O_FSINFO_ID, meta_dxpl_id, &flags) < 0)
@@ -765,6 +781,13 @@ H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t initial
/* If message is NOT marked "unknown"--set up file space info */
if(!(flags & H5O_MSG_FLAG_WAS_UNKNOWN)) {
+ /* The tool h5clear uses this property to tell the library
+ to drop free-space to the floor */
+ if(H5P_exist_plist(a_plist, H5F_ACS_NULL_FSM_ADDR_NAME) > 0) {
+ if(H5P_get(a_plist, H5F_ACS_NULL_FSM_ADDR_NAME, &null_fsm_addr) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get clearance for persisting fsm addr")
+ }
+
/* Retrieve the 'file space info' structure */
if(NULL == H5O_msg_read(&ext_loc, H5O_FSINFO_ID, &fsinfo, meta_dxpl_id))
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get free-space manager info message")
@@ -808,13 +831,30 @@ H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t initial
if(f->shared->eoa_pre_fsm_fsalloc != fsinfo.eoa_pre_fsm_fsalloc)
f->shared->eoa_pre_fsm_fsalloc = fsinfo.eoa_pre_fsm_fsalloc;
- /* f->shared->eoa_pre_fsm_fsalloc must always be HADDR_UNDEF
- * in the absence of persistant free space managers.
+ /* f->shared->eoa_pre_fsm_fsalloc must always be HADDR_UNDEF
+ * in the absence of persistant free space managers.
+ */
+ /* If the following two conditions are true:
+ * (1) skipping EOF check (skip_eof_check)
+ * (2) dropping free-space to the floor (null_fsm_addr)
+ * skip the asserts as "eoa_pre_fsm_fsalloc" may be undefined
+ * for a crashed file with persistant free space managers.
+ * #1 and #2 are enabled when the tool h5clear --increment
+ * option is used.
*/
- HDassert((!f->shared->fs_persist) || (f->shared->eoa_pre_fsm_fsalloc != HADDR_UNDEF));
- HDassert(!f->shared->first_alloc_dealloc);
+ if(!skip_eof_check && !null_fsm_addr) {
+ HDassert((!f->shared->fs_persist) || (f->shared->eoa_pre_fsm_fsalloc != HADDR_UNDEF));
+ HDassert(!f->shared->first_alloc_dealloc);
+ }
- if((f->shared->eoa_pre_fsm_fsalloc != HADDR_UNDEF) &&
+ /* As "eoa_pre_fsm_fsalloc" may be undefined for a crashed file
+ * with persistant free space managers, therefore, set
+ * "first_alloc_dealloc" when the condition
+ * "dropping free-space to the floor is true.
+ * This will ensure that no action is done to settle things on file
+ * close via H5MF_settle_meta_data_fsm() and H5MF_settle_raw_data_fsm().
+ */
+ if((f->shared->eoa_pre_fsm_fsalloc != HADDR_UNDEF || null_fsm_addr) &&
(H5F_INTENT(f) & H5F_ACC_RDWR))
f->shared->first_alloc_dealloc = TRUE;
@@ -822,7 +862,20 @@ H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t initial
for(u = 1; u < NELMTS(f->shared->fs_addr); u++)
f->shared->fs_addr[u] = fsinfo.fs_addr[u - 1];
- if(fsinfo.mapped && (rw_flags & H5AC__READ_ONLY_FLAG) == 0) {
+ /* If the following two conditions are true:
+ * (1) file is persisting free-space
+ * (2) dropping free-space to the floor (null_fsm_addr)
+ * nullify the addresses of the FSMs
+ */
+ if(f->shared->fs_persist && null_fsm_addr) {
+ for(u = 0; u < NELMTS(fsinfo.fs_addr); u++)
+ f->shared->fs_addr[u] = fsinfo.fs_addr[u] = HADDR_UNDEF;
+ }
+
+ /* For fsinfo.mapped: remove the FSINFO message from the superblock extension
+ and write a new message to the extension */
+ /* For null_fsm_addr: just update FSINFO message in the superblock extension */
+ if(((fsinfo.mapped || null_fsm_addr) && (rw_flags & H5AC__READ_ONLY_FLAG) == 0)) {
/* Do the same kluge until we know for sure. VC */
#if 1 /* bug fix test code -- tidy this up if all goes well */ /* JRM */
@@ -836,11 +889,16 @@ H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t initial
f->shared->sblock = sblock;
#endif /* JRM */
- if(H5F_super_ext_remove_msg(f, meta_dxpl_id, H5O_FSINFO_ID) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTDELETE, FAIL, "error in removing message from superblock extension")
+ if(null_fsm_addr) {
+ if(H5F_super_ext_write_msg(f, meta_dxpl_id, H5O_FSINFO_ID, &fsinfo, FALSE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error in writing fsinfo message to superblock extension")
+ } else {
+ if(H5F_super_ext_remove_msg(f, meta_dxpl_id, H5O_FSINFO_ID) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTDELETE, FAIL, "error in removing message from superblock extension")
- if(H5F_super_ext_write_msg(f, meta_dxpl_id, H5O_FSINFO_ID, &fsinfo, TRUE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error in writing fsinfo message to superblock extension")
+ if(H5F_super_ext_write_msg(f, meta_dxpl_id, H5O_FSINFO_ID, &fsinfo, TRUE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error in writing fsinfo message to superblock extension")
+ }
#if 1 /* bug fix test code -- tidy this up if all goes well */ /* JRM */
f->shared->sblock = NULL;
#endif /* JRM */
@@ -1637,13 +1695,13 @@ H5F_super_ext_write_msg(H5F_t *f, hid_t dxpl_id, unsigned id, void *mesg,
/* Open/create the superblock extension object header */
if(H5F_addr_defined(f->shared->sblock->ext_addr)) {
- if(H5F_super_ext_open(f, f->shared->sblock->ext_addr, &ext_loc) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, FAIL, "unable to open file's superblock extension")
+ if(H5F_super_ext_open(f, f->shared->sblock->ext_addr, &ext_loc) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENOBJ, FAIL, "unable to open file's superblock extension")
} /* end if */
else {
HDassert(may_create);
- if(H5F_super_ext_create(f, dxpl_id, &ext_loc) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "unable to create file's superblock extension")
+ if(H5F_super_ext_create(f, dxpl_id, &ext_loc) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "unable to create file's superblock extension")
ext_created = TRUE;
} /* end else */
HDassert(H5F_addr_defined(ext_loc.addr));
@@ -1651,24 +1709,24 @@ H5F_super_ext_write_msg(H5F_t *f, hid_t dxpl_id, unsigned id, void *mesg,
/* Check if message with ID does not exist in the object header */
if((status = H5O_msg_exists(&ext_loc, id, dxpl_id)) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to check object header for message or message exists")
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to check object header for message or message exists")
/* Check for creating vs. writing */
if(may_create) {
- if(status)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "Message should not exist")
+ if(status)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "Message should not exist")
- /* Create the message with ID in the superblock extension */
- if(H5O_msg_create(&ext_loc, id, (mesg_flags | H5O_MSG_FLAG_DONTSHARE), H5O_UPDATE_TIME, mesg, dxpl_id) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to create the message in object header")
+ /* Create the message with ID in the superblock extension */
+ if(H5O_msg_create(&ext_loc, id, (mesg_flags | H5O_MSG_FLAG_DONTSHARE), H5O_UPDATE_TIME, mesg, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to create the message in object header")
} /* end if */
else {
- if(!status)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "Message should exist")
+ if(!status)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "Message should exist")
- /* Update the message with ID in the superblock extension */
- if(H5O_msg_write(&ext_loc, id, (mesg_flags | H5O_MSG_FLAG_DONTSHARE), H5O_UPDATE_TIME, mesg, dxpl_id) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to write the message in object header")
+ /* Update the message with ID in the superblock extension */
+ if(H5O_msg_write(&ext_loc, id, (mesg_flags | H5O_MSG_FLAG_DONTSHARE), H5O_UPDATE_TIME, mesg, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to write the message in object header")
} /* end else */
done:
diff --git a/src/H5Ocache.c b/src/H5Ocache.c
index 94049ef..2260e12 100644
--- a/src/H5Ocache.c
+++ b/src/H5Ocache.c
@@ -262,12 +262,23 @@ H5O__cache_verify_chksum(const void *_image, size_t len, void *_udata)
uint32_t stored_chksum; /* Stored metadata checksum value */
uint32_t computed_chksum; /* Computed metadata checksum value */
- /* Get stored and computed checksums */
- H5F_get_checksums(image, len, &stored_chksum, &computed_chksum);
-
- if(stored_chksum != computed_chksum)
- ret_value = FALSE;
+ /* Get stored and computed checksums */
+ H5F_get_checksums(image, len, &stored_chksum, &computed_chksum);
+
+ if(stored_chksum != computed_chksum) {
+ /* These fields are not deserialized yet in H5O__prefix_deserialize() */
+ HDassert(udata->oh->chunk == NULL);
+ HDassert(udata->oh->mesg == NULL);
+ HDassert(udata->oh->proxy == NULL);
+
+ /* Indicate that udata->oh is to be freed later
+ in H5O__prefix_deserialize() */
+ udata->free_oh = TRUE;
+ ret_value = FALSE;
+ } /* end if */
} /* end if */
+ else
+ HDassert(!(udata->common.file_intent & H5F_ACC_SWMR_WRITE));
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O__cache_verify_chksum() */
@@ -1263,8 +1274,22 @@ H5O__prefix_deserialize(const uint8_t *_image, H5O_cache_ud_t *udata)
/* Verify object header prefix length */
HDassert((size_t)(image - _image) == (size_t)(H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh)));
- /* Save the object header for later use in 'deserialize' callback */
- udata->oh = oh;
+ /* If udata->oh is to be freed (see H5O__cache_verify_chksum),
+ save the pointer to udata->oh and free it later after setting
+ udata->oh with the new object header */
+ if(udata->free_oh) {
+ H5O_t *saved_oh = udata->oh;
+ HDassert(udata->oh);
+
+ /* Save the object header for later use in 'deserialize' callback */
+ udata->oh = oh;
+ if(H5O__free(saved_oh) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't destroy object header")
+ udata->free_oh = FALSE;
+ } else
+ /* Save the object header for later use in 'deserialize' callback */
+ udata->oh = oh;
+
oh = NULL;
done:
diff --git a/src/H5Oint.c b/src/H5Oint.c
index 08eb28d..2351779 100644
--- a/src/H5Oint.c
+++ b/src/H5Oint.c
@@ -875,6 +875,7 @@ H5O_protect(const H5O_loc_t *loc, hid_t dxpl_id, unsigned prot_flags,
udata.v1_pfx_nmesgs = 0;
udata.chunk0_size = 0;
udata.oh = NULL;
+ udata.free_oh = FALSE;
udata.common.f = loc->file;
udata.common.dxpl_id = dxpl_id;
udata.common.file_intent = file_intent;
diff --git a/src/H5Opkg.h b/src/H5Opkg.h
index e970406..9392fa8 100644
--- a/src/H5Opkg.h
+++ b/src/H5Opkg.h
@@ -379,6 +379,7 @@ typedef struct H5O_cache_ud_t {
unsigned v1_pfx_nmesgs; /* Number of messages from v1 prefix header */
size_t chunk0_size; /* Size of serialized first chunk */
H5O_t *oh; /* Partially deserialized object header, for later use */
+ hbool_t free_oh; /* Whether to free the object header or not */
H5O_common_cache_ud_t common; /* Common object header cache callback info */
} H5O_cache_ud_t;
diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c
index 148c247..eded286 100644
--- a/src/H5Pfapl.c
+++ b/src/H5Pfapl.c
@@ -193,6 +193,14 @@
/* Definition for status_flags in the superblock */
#define H5F_ACS_CLEAR_STATUS_FLAGS_SIZE sizeof(hbool_t)
#define H5F_ACS_CLEAR_STATUS_FLAGS_DEF FALSE
+
+/* Definition for dropping free-space to the floor when reading in the superblock */
+#define H5F_ACS_NULL_FSM_ADDR_SIZE sizeof(hbool_t)
+#define H5F_ACS_NULL_FSM_ADDR_DEF FALSE
+/* Definition for skipping EOF check when reading in the superblock */
+#define H5F_ACS_SKIP_EOF_CHECK_SIZE sizeof(hbool_t)
+#define H5F_ACS_SKIP_EOF_CHECK_DEF FALSE
+
/* Definition for 'use metadata cache logging' flag */
#define H5F_ACS_USE_MDC_LOGGING_SIZE sizeof(hbool_t)
#define H5F_ACS_USE_MDC_LOGGING_DEF FALSE
@@ -374,6 +382,9 @@ static const size_t H5F_def_core_write_tracking_page_size_g = H5F_ACS_CORE_WRITE
static const unsigned H5F_def_metadata_read_attempts_g = H5F_ACS_METADATA_READ_ATTEMPTS_DEF; /* Default setting for the # of metadata read attempts */
static const H5F_object_flush_t H5F_def_object_flush_cb_g = H5F_ACS_OBJECT_FLUSH_CB_DEF; /* Default setting for object flush callback */
static const hbool_t H5F_def_clear_status_flags_g = H5F_ACS_CLEAR_STATUS_FLAGS_DEF; /* Default to clear the superblock status_flags */
+static const hbool_t H5F_def_skip_eof_check_g = H5F_ACS_SKIP_EOF_CHECK_DEF; /* Default setting for skipping EOF check */
+static const hbool_t H5F_def_null_fsm_addr_g = H5F_ACS_NULL_FSM_ADDR_DEF; /* Default setting for dropping free-space to the floor */
+
static const hbool_t H5F_def_use_mdc_logging_g = H5F_ACS_USE_MDC_LOGGING_DEF; /* Default metadata cache logging flag */
static const char *H5F_def_mdc_log_location_g = H5F_ACS_MDC_LOG_LOCATION_DEF; /* Default mdc log location */
static const hbool_t H5F_def_start_mdc_log_on_access_g = H5F_ACS_START_MDC_LOG_ON_ACCESS_DEF; /* Default mdc log start on access flag */
@@ -565,6 +576,16 @@ H5P__facc_reg_prop(H5P_genclass_t *pclass)
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+ /* Register the private property of whether to skip EOF check. It's used by h5clear only. */
+ if(H5P_register_real(pclass, H5F_ACS_SKIP_EOF_CHECK_NAME, H5F_ACS_SKIP_EOF_CHECK_SIZE, &H5F_def_skip_eof_check_g,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+
+ /* Register the private property of whether to drop free-space to the floor. It's used by h5clear only. */
+ if(H5P_register_real(pclass, H5F_ACS_NULL_FSM_ADDR_NAME, H5F_ACS_NULL_FSM_ADDR_SIZE, &H5F_def_null_fsm_addr_g,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+
/* Register the metadata cache logging flag. */
if(H5P_register_real(pclass, H5F_ACS_USE_MDC_LOGGING_NAME, H5F_ACS_USE_MDC_LOGGING_SIZE, &H5F_def_use_mdc_logging_g,
NULL, NULL, NULL, H5F_ACS_USE_MDC_LOGGING_ENC, H5F_ACS_USE_MDC_LOGGING_DEC, NULL, NULL, NULL, NULL) < 0)
diff --git a/test/tfile.c b/test/tfile.c
index f3d5a8f..80c1e11 100644
--- a/test/tfile.c
+++ b/test/tfile.c
@@ -134,6 +134,9 @@
#define NGROUPS 2
#define NDSETS 4
+/* Declaration for test_incr_filesize() */
+#define FILE8 "tfile8.h5" /* Test file */
+
/* Files created under 1.6 branch and 1.8 branch--used in test_filespace_compatible() */
const char *OLD_FILENAME[] = {
"filespace_1_6.h5", /* 1.6 HDF5 file */
@@ -6926,6 +6929,130 @@ test_libver_macros2(void)
/****************************************************************
**
+** test_filesize():
+** Verify H5Fincrement_filesize() and H5Fget_eoa() works as
+** indicated in the "RFC: Enhancement to the tool h5clear".
+**
+****************************************************************/
+static void
+test_incr_filesize(const char *env_h5_drvr)
+{
+ hid_t fid; /* File opened with read-write permission */
+ h5_stat_size_t filesize; /* Size of file when empty */
+ hid_t fcpl; /* File creation property list */
+ hid_t fapl; /* File access property list */
+ hid_t dspace; /* Dataspace ID */
+ hid_t dset; /* Dataset ID */
+ hid_t dcpl; /* Dataset creation property list */
+ unsigned u; /* Local index variable */
+ char filename[FILENAME_LEN]; /* Filename to use */
+ char name[32]; /* Dataset name */
+ haddr_t stored_eoa; /* The stored EOA value */
+ hid_t driver_id = -1; /* ID for this VFD */
+ unsigned long driver_flags = 0; /* VFD feature flags */
+ herr_t ret; /* Return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing H5Fincrement_filesize() and H5Fget_eoa())\n"));
+
+ fapl = h5_fileaccess();
+ h5_fixname(FILE8, fapl, filename, sizeof filename);
+
+ /* Get the VFD feature flags */
+ driver_id = H5Pget_driver(fapl);
+ CHECK(driver_id, FAIL, "H5Pget_driver");
+
+ ret = H5FDdriver_query(driver_id, &driver_flags);
+ CHECK(ret, FAIL, "H5PDdriver_query");
+
+ /* Check whether the VFD feature flag supports these two public routines */
+ if(driver_flags & H5FD_FEAT_SUPPORTS_SWMR_IO) {
+
+ fcpl = H5Pcreate(H5P_FILE_CREATE);
+ CHECK(fcpl, FAIL, "H5Pcreate");
+
+ /* Set file space strategy */
+ ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, FALSE, (hsize_t)1);
+ CHECK(ret, FAIL, "H5P_set_file_space_strategy");
+
+ /* Create the test file */
+ fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl);
+ CHECK(fid, FAIL, "H5Fcreate");
+
+ /* Create dataspace for datasets */
+ dspace = H5Screate(H5S_SCALAR);
+ CHECK(dspace, FAIL, "H5Screate");
+
+ /* Create a dataset creation property list */
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+
+ /* Set the space allocation time to early */
+ ret = H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY);
+ CHECK(ret, FAIL, "H5Pset_alloc_time");
+
+ /* Create datasets in file */
+ for(u = 0; u < 10; u++) {
+ sprintf(name, "Dataset %u", u);
+ dset = H5Dcreate2(fid, name, H5T_STD_U32LE, dspace, H5P_DEFAULT, dcpl, H5P_DEFAULT);
+ CHECK(dset, FAIL, "H5Dcreate2");
+
+ ret = H5Dclose(dset);
+ CHECK(ret, FAIL, "H5Dclose");
+ } /* end for */
+
+ /* Close dataspace */
+ ret = H5Sclose(dspace);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Close dataset creation property list */
+ ret = H5Pclose(dcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Get the file size */
+ filesize = h5_get_file_size(filename, fapl);
+
+ /* Open the file */
+ fid = H5Fopen(filename, H5F_ACC_RDWR, fapl);
+ CHECK(fid, FAIL, "H5Fopen");
+
+ /* Get the stored EOA */
+ ret = H5Fget_eoa(fid, &stored_eoa);
+ CHECK(ret, FAIL, "H5Fget_eoa");
+
+ /* Verify the stored EOA is the same as filesize */
+ VERIFY(filesize, stored_eoa, "file size");
+
+ /* Set the EOA to the MAX(EOA, EOF) + 512 */
+ ret = H5Fincrement_filesize(fid, 512);
+ CHECK(ret, FAIL, "H5Fincrement_filesize");
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Get the file size */
+ filesize = h5_get_file_size(filename, fapl);
+
+ /* Verify the filesize is the previous stored_eoa + 512 */
+ VERIFY(filesize, stored_eoa+512, "file size");
+
+ /* Close the file access property list */
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+
+ /* Close the file creation property list */
+ ret = H5Pclose(fcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+ }
+} /* end test_incr_filesize() */
+
+/****************************************************************
+**
** test_deprec():
** Test deprecated functionality.
**
@@ -7210,6 +7337,7 @@ test_file(void)
test_libver_bounds_low_high();
test_libver_macros(); /* Test the macros for library version comparison */
test_libver_macros2(); /* Test the macros for library version comparison */
+ test_incr_filesize(env_h5_drvr); /* Test H5Fincrement_filesize() and H5Fget_eoa() */
#ifndef H5_NO_DEPRECATED_SYMBOLS
test_deprec(); /* Test deprecated routines */
#endif /* H5_NO_DEPRECATED_SYMBOLS */
diff --git a/tools/src/misc/h5clear.c b/tools/src/misc/h5clear.c
index e3b989d..5724e1b 100644
--- a/tools/src/misc/h5clear.c
+++ b/tools/src/misc/h5clear.c
@@ -12,9 +12,11 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * 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.
- *
+ * Purpose: A tool used to do the following:
+ * (1) -s, --status: clear the status_flags field from the file's superblock
+ * (2) -m, --image: remove the metadata cache image from the file
+ * (3) --increment=C: set the file's EOA to the maximum of (EOA, EOF) + C
+ * (4) --filesize: print the file's EOA and EOF
*/
#include "hdf5.h"
#include "H5private.h"
@@ -24,18 +26,25 @@
/* Name of tool */
#define PROGRAMNAME "h5clear"
-/* Make this private property (defined in H5Fprivate.h) available to h5clear. */
-#define H5F_ACS_CLEAR_STATUS_FLAGS_NAME "clear_status_flags"
+/* Make these private properties (defined in H5Fprivate.h) available to h5clear. */
+#define H5F_ACS_CLEAR_STATUS_FLAGS_NAME "clear_status_flags"
+#define H5F_ACS_NULL_FSM_ADDR_NAME "null_fsm_addr"
+#define H5F_ACS_SKIP_EOF_CHECK_NAME "skip_eof_check"
+
+/* Default increment is 1 megabytes for the --increment option */
+#define DEFAULT_INCREMENT 1024*1024
static char *fname_g = NULL;
static hbool_t clear_status_flags = FALSE;
static hbool_t remove_cache_image = FALSE;
+static hbool_t print_filesize = FALSE;
+static hbool_t increment_eoa_eof = FALSE;
+static hsize_t increment = DEFAULT_INCREMENT;
/*
- * Command-line options: The user can specify short or long-named
- * parameters.
+ * Command-line options: only publicize long options
*/
-static const char *s_opts = "hVsm";
+static const char *s_opts = "hVsmzi*";
static struct long_options l_opts[] = {
{ "help", no_arg, 'h' },
{ "hel", no_arg, 'h'},
@@ -54,6 +63,21 @@ static struct long_options l_opts[] = {
{ "imag", no_arg, 'm' },
{ "ima", no_arg, 'm' },
{ "im", no_arg, 'm' },
+ { "filesize", no_arg, 'z' },
+ { "filesiz", no_arg, 'z' },
+ { "filesi", no_arg, 'z' },
+ { "files", no_arg, 'z' },
+ { "file", no_arg, 'z' },
+ { "fil", no_arg, 'z' },
+ { "fi", no_arg, 'z' },
+ { "increment", optional_arg, 'i' },
+ { "incremen", optional_arg, 'i' },
+ { "increme", optional_arg, 'i' },
+ { "increm", optional_arg, 'i' },
+ { "incre", optional_arg, 'i' },
+ { "incr", optional_arg, 'i' },
+ { "inc", optional_arg, 'i' },
+ { "in", optional_arg, 'i' },
{ NULL, 0, '\0' }
};
@@ -76,6 +100,9 @@ static void usage(const char *prog)
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, " --filesize Print the file's EOA and EOF\n");
+ HDfprintf(stdout, " --increment=C Set the file's EOA to the maximum of (EOA, EOF) + C for the file <file_name>\n");
+ HDfprintf(stdout, " C is >= 0; C is optional and will default to 1M when not set");
HDfprintf(stdout, "\n");
HDfprintf(stdout, "Examples of use:\n");
HDfprintf(stdout, "\n");
@@ -84,6 +111,12 @@ static void usage(const char *prog)
HDfprintf(stdout, "\n");
HDfprintf(stdout, "h5clear -m file_name\n");
HDfprintf(stdout, " Remove the metadata cache image from the HDF5 file <file_name>.\n");
+ HDfprintf(stdout, "\n");
+ HDfprintf(stdout, "h5clear --increment file_name\n");
+ HDfprintf(stdout, " Set the EOA to the maximum of (EOA, EOF) + 1M for the file <file_name>.\n");
+ HDfprintf(stdout, "\n");
+ HDfprintf(stdout, "h5clear --increment=512 file_name\n");
+ HDfprintf(stdout, " Set the EOA to the maximum of (EOA, EOF) + 512 for the file <file_name>.\n");
} /* usage() */
@@ -131,6 +164,18 @@ parse_command_line(int argc, const char **argv)
remove_cache_image = TRUE;
break;
+ case 'z':
+ print_filesize = TRUE;
+ break;
+
+ case 'i':
+ increment_eoa_eof = TRUE;
+ if(opt_arg != NULL && (increment = HDatoi(opt_arg)) < 0) {
+ usage(h5tools_getprogname());
+ goto done;
+ }
+ break;
+
default:
usage(h5tools_getprogname());
h5tools_setstatus(EXIT_FAILURE);
@@ -176,8 +221,24 @@ leave(int ret)
/*-------------------------------------------------------------------------
* Function: main
*
- * Purpose: To clear the status_flags field in the file's superblock (-s option).
- * To remove the cache image from the file (-m option).
+ * Purpose: The options are:
+ * (1) -s, --status: clear the status_flags field from the file's superblock
+ * (2) -m, --image: remove the metadata cache image from the file
+ * (3) --increment=C: set the file's EOA to the maximum of (EOA, EOF) + C
+ * (4) --filesize: print the file's EOA and EOF
+ *
+ * The three options: -s, -m, and --increment will modify the file
+ * so the file is opened with write access.
+ * The --filesize option just prints the EOA and EOF, so the file
+ * is opened with read access.
+ *
+ * The -s option will activate the private property:
+ * --H5F_ACS_CLEAR_STATUS_FLAGS_NAME
+ * The --increment option will active these two private properties:
+ * --H5F_ACS_NULL_FSM_ADDR_NAME
+ * --H5F_ACS_SKIP_EOF_CHECK_NAME
+ * The --filesize will activate the private property:
+ * --H5F_ACS_SKIP_EOF_CHECK_NAME
*
* Return: Success: 0
* Failure: 1
@@ -187,11 +248,12 @@ leave(int ret)
int
main (int argc, const char *argv[])
{
- char *fname = NULL; /* File name */
- hid_t fapl = -1; /* File access property list */
- hid_t fid = -1; /* File ID */
+ 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;
+ unsigned flags = H5F_ACC_RDWR; /* file access flags */
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
@@ -209,12 +271,22 @@ main (int argc, const char *argv[])
if(fname_g == NULL)
goto done;
- if(!clear_status_flags && !remove_cache_image) {
+ /* Print usage/exit if not using at least one of the options */
+ if(!clear_status_flags && !remove_cache_image &&
+ !increment_eoa_eof && !print_filesize) {
usage(h5tools_getprogname());
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
+ /* Cannot combine the --filesize option with other options */
+ if(print_filesize &&
+ (clear_status_flags || remove_cache_image || increment_eoa_eof)) {
+ error_msg("Cannot combine --filesize with other options\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+
/* Duplicate the file name */
fname = HDstrdup(fname_g);
@@ -228,7 +300,7 @@ main (int argc, const char *argv[])
/* -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 */
+ /* Activate this private property */
if(H5Pset(fapl, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, &clear_status_flags) < 0) {
error_msg("H5Pset\n");
h5tools_setstatus(EXIT_FAILURE);
@@ -236,12 +308,64 @@ main (int argc, const char *argv[])
}
}
- if((fid = h5tools_fopen(fname, H5F_ACC_RDWR, fapl, NULL, NULL, (size_t)0)) < 0) {
+ /* --increment option */
+ if(increment_eoa_eof) {
+ /* Activate this private property */
+ if(H5Pset(fapl, H5F_ACS_SKIP_EOF_CHECK_NAME, &increment_eoa_eof) < 0) {
+ error_msg("H5Pset\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+ /* Activate this private property */
+ if(H5Pset(fapl, H5F_ACS_NULL_FSM_ADDR_NAME, &increment_eoa_eof) < 0) {
+ error_msg("H5Pset\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+ }
+
+ /* --filesize option; open the file read-only */
+ if(print_filesize) {
+ /* Activate this private property */
+ if(H5Pset(fapl, H5F_ACS_SKIP_EOF_CHECK_NAME, &print_filesize) < 0) {
+ error_msg("H5Pset\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+ flags = H5F_ACC_RDONLY;
+ }
+
+ /* Open the file */
+ if((fid = h5tools_fopen(fname, flags, fapl, NULL, NULL, (size_t)0)) < 0) {
error_msg("h5tools_fopen\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
+ /* --filesize option */
+ if(print_filesize) {
+ h5_stat_t st; /* Stat info call */
+ haddr_t eoa; /* The EOA value */
+
+ /* Get the file's EOA and EOF */
+ if(H5Fget_eoa(fid, &eoa) < 0 || HDstat(fname, &st) < 0) {
+ error_msg("H5Fget_eoa or HDstat\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+ HDfprintf(stdout, "EOA is %a; EOF is %a \n", eoa, st.st_size);
+ }
+
+ /* --increment option */
+ if(increment_eoa_eof) {
+ /* Set the file's EOA to the maximum of (EOA, EOF) + increment */
+ if(H5Fincrement_filesize(fid, increment) < 0) {
+ error_msg("H5Fset_eoa\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+ }
+
/* -m option */
if(remove_cache_image) {
if(H5Fget_mdc_image_info(fid, &image_addr, &image_len) < 0) {
@@ -253,7 +377,9 @@ main (int argc, const char *argv[])
warn_msg("No cache image in the file\n");
}
+
h5tools_setstatus(EXIT_SUCCESS);
+
done:
if(fname)
HDfree(fname);
diff --git a/tools/test/misc/CMakeTestsClear.cmake b/tools/test/misc/CMakeTestsClear.cmake
index 942ae7a..5efce0a 100644
--- a/tools/test/misc/CMakeTestsClear.cmake
+++ b/tools/test/misc/CMakeTestsClear.cmake
@@ -20,11 +20,19 @@
# Copy all the HDF5 files from the source directory into the test directory
# --------------------------------------------------------------------
set (HDF5_TEST_FILES
+ h5clear_fsm_persist_equal.h5
+ h5clear_fsm_persist_greater.h5
+ h5clear_fsm_persist_less.h5
+ h5clear_fsm_persist_noclose.h5
+ h5clear_fsm_persist_user_equal.h5
+ h5clear_fsm_persist_user_greater.h5
+ h5clear_fsm_persist_user_less.h5
h5clear_log_v3.h5
h5clear_mdc_image.h5
- mod_h5clear_mdc_image.h5
+ h5clear_status_noclose.h5
latest_h5clear_log_v3.h5
latest_h5clear_sec2_v3.h5
+ mod_h5clear_mdc_image.h5
)
set (HDF5_SEC2_TEST_FILES
h5clear_sec2_v0.h5
@@ -32,10 +40,25 @@
h5clear_sec2_v3.h5
)
set (HDF5_REFERENCE_TEST_FILES
- h5clear_usage.ddl
- h5clear_open_fail.ddl
+ h5clear_equal_after_size.ddl
+ h5clear_equal_before_size.ddl
+ h5clear_greater_after_size.ddl
+ h5clear_greater_before_size.ddl
+ h5clear_less_after_size.ddl
+ h5clear_less_before_size.ddl
h5clear_missing_file.ddl
+ h5clear_noclose_after_size.ddl
+ h5clear_noclose_before_size.ddl
h5clear_no_mdc_image.ddl
+ h5clear_open_fail.ddl
+ h5clear_status_noclose_after_size.ddl
+ h5clear_usage.ddl
+ h5clear_user_equal_after_size.ddl
+ h5clear_user_equal_before_size.ddl
+ h5clear_user_greater_after_size.ddl
+ h5clear_user_greater_before_size.ddl
+ h5clear_user_less_after_size.ddl
+ h5clear_user_less_before_size.ddl
)
foreach (h5_file ${HDF5_TEST_FILES} ${HDF5_SEC2_TEST_FILES} ${HDF5_REFERENCE_TEST_FILES})
@@ -270,3 +293,74 @@ endif()
ADD_H5_TEST (latest_h5clr_log_v3 latest_h5clear_log_v3 "true")
ADD_H5_TEST (h5clr_sec2_v0 h5clear_sec2_v0 "false")
ADD_H5_TEST (h5clr_sec2_v2 h5clear_sec2_v2 "false")
+#
+#
+#
+# The following tests verify the filesize, increment the filesize, then verify the filesize again.
+#
+# (1) h5clear_status_noclose.h5
+# "h5clear --filesize h5clear_status_noclose.h5" (unable to open the file because status_flags is enabled)
+# "h5clear -s --increment=0 h5clear_status_noclose.h5" (clear status_flag, EOA = MAX(EOA, EOF) + 0)
+# (no output, check exit code)
+# "h5clear --filesize h5clear_status_noclose.h5" (print EOA/EOF after the last action)
+ ADD_H5_CMP (h5clr_open_fail_s h5clear_open_fail 1 "--filesize" h5clear_status_noclose.h5)
+ ADD_H5_RETTEST (h5clr_mdc_image "false" "-s" "--increment=0" h5clear_status_noclose.h5)
+ ADD_H5_CMP (h5clr_no_mdc_image_m h5clear_status_noclose_after_size 0 "--filesize" h5clear_status_noclose.h5)
+#
+# (2) h5clear_fsm_persist_noclose.h5
+# "h5clear --filesize h5clear_fsm_persist_noclose.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=0 h5clear_fsm_persist_noclose.h5" (EOA = MAX(EOA, EOF)) (no output, just check exit code)
+# "h5clear --filesize h5clear_fsm_persist_noclose.h5" (print EOA/EOF after the last action)
+ ADD_H5_CMP (h5clr_open_fail_s h5clear_noclose_before_size 0 "--filesize" h5clear_fsm_persist_noclose.h5)
+ ADD_H5_RETTEST (h5clr_mdc_image "false" "--increment=0" h5clear_fsm_persist_noclose.h5)
+ ADD_H5_CMP (h5clr_no_mdc_image_m h5clear_noclose_after_size 0 "--filesize" h5clear_fsm_persist_noclose.h5)
+#
+# (3) h5clear_fsm_persist_equal.h5
+# "h5clear --filesize h5clear_fsm_persist_equal.h5" (print EOA/EOF before the next action)
+# "h5clear --increment h5clear_fsm_persist_equal.h5" (EOA = MAX(EOA, EOF) + 1M) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_equal.h5" (print EOA/EOF after the last action)
+ ADD_H5_CMP (h5clr_equal_before_size h5clear_equal_before_size 0 "--filesize" h5clear_fsm_persist_equal.h5)
+ ADD_H5_RETTEST (h5clr_equal_incr "false" "--increment" h5clear_fsm_persist_equal.h5)
+ ADD_H5_CMP (h5clr_equal_after_size h5clear_equal_after_size 0 "--filesize" h5clear_fsm_persist_equal.h5)
+#
+# (4) h5clear_fsm_persist_greater.h5
+# "h5clear --filesize h5clear_fsm_persist_greater.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=0 h5clear_fsm_persist_greater.h5" (EOA = MAX(EOA, EOF) + 0) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_greater.h5" (print EOA/EOF after the last action)
+ ADD_H5_CMP (h5clr_greater_before_size h5clear_greater_before_size 0 "--filesize" h5clear_fsm_persist_greater.h5)
+ ADD_H5_RETTEST (h5clr_greater_incr "false" "--increment=0" h5clear_fsm_persist_greater.h5)
+ ADD_H5_CMP (h5clr_greater_after_size h5clear_greater_after_size 0 "--filesize" h5clear_fsm_persist_greater.h5)
+#
+# (5) h5clear_fsm_persist_less.h5
+# "h5clear --filesize h5clear_fsm_persist_less.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=200 h5clear_fsm_persist_less.h5" (EOA = MAX(EOA, EOF) + 200) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_less.h5" (print EOA/EOF after the last action)
+ ADD_H5_CMP (h5clr_less_before_size h5clear_less_before_size 0 "--filesize" h5clear_fsm_persist_less.h5)
+ ADD_H5_RETTEST (h5clr_less_incr "false" "--increment=200" h5clear_fsm_persist_less.h5)
+ ADD_H5_CMP (h5clr_less_after_size h5clear_less_after_size 0 "--filesize" h5clear_fsm_persist_less.h5)
+#
+# (6) h5clear_fsm_persist_user_equal.h5
+# "h5clear --filesize h5clear_fsm_persist_user_equal.h5" (print EOA/EOF before the next action)
+# "h5clear --increment h5clear_fsm_persist_user_equal.h5" (EOA = MAX(EOA, EOF) + 1M) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_user_equal.h5" (print EOA/EOF after the last action)
+ ADD_H5_CMP (h5clr_user_equal_before_size h5clear_user_equal_before_size 0 "--filesize" h5clear_fsm_persist_user_equal.h5)
+ ADD_H5_RETTEST (h5clr_user_equal_incr "false" "--increment" h5clear_fsm_persist_user_equal.h5)
+ ADD_H5_CMP (h5clr_user_equal_after_size h5clear_user_equal_after_size 0 "--filesize" h5clear_fsm_persist_user_equal.h5)
+#
+# (7) h5clear_fsm_persist_user_greater.h5
+# "h5clear --filesize h5clear_fsm_persist_user_greater.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=0 h5clear_fsm_persist_user_greater.h5" (EOA = MAX(EOA, EOF) + 0) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_user_greater.h5" (print EOA/EOF after the last action)
+ ADD_H5_CMP (h5clr_user_greater_before_size h5clear_user_greater_before_size 0 "--filesize" h5clear_fsm_persist_user_greater.h5)
+ ADD_H5_RETTEST (h5clr_user_greater_incr "false" "--increment=0" h5clear_fsm_persist_user_greater.h5)
+ ADD_H5_CMP (h5clr_user_greater_after_size h5clear_user_greater_after_size 0 "--filesize" h5clear_fsm_persist_user_greater.h5)
+#
+# (8) h5clear_fsm_persist_user_less.h5
+# "h5clear --filesize h5clear_fsm_persist_user_greater.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=0 h5clear_fsm_persist_user_greater.h5" (EOA = MAX(EOA, EOF) + 0) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_user_greater.h5" (print EOA/EOF after the last action)
+ ADD_H5_CMP (h5clr_user_less_before_size h5clear_user_less_before_size 0 "--filesize" h5clear_fsm_persist_user_less.h5)
+ ADD_H5_RETTEST (h5clr_user_less_incr "false" "--increment=0" h5clear_fsm_persist_user_less.h5)
+ ADD_H5_CMP (h5clr_user_less_after_size h5clear_user_less_after_size 0 "--filesize" h5clear_fsm_persist_user_less.h5)
+#
+#
diff --git a/tools/test/misc/h5clear_gentest.c b/tools/test/misc/h5clear_gentest.c
index 326109c..ccb510f 100644
--- a/tools/test/misc/h5clear_gentest.c
+++ b/tools/test/misc/h5clear_gentest.c
@@ -21,10 +21,25 @@ const char *FILENAME[] = {
"h5clear_sec2_v2.h5" /* 3 -- sec2 file with superblock version 2 */
};
+const char *FILENAME_ENHANCE[] = {
+ "h5clear_fsm_persist_equal.h5", /* 0: persisting free-space, stored EOA = actual EOF */
+ "h5clear_fsm_persist_greater.h5", /* 1: persisting free-space, stored EOA > actual EOF */
+ "h5clear_fsm_persist_less.h5", /* 2: persisting free-space, stored EOA < actual EOF */
+ "h5clear_fsm_persist_user_equal.h5", /* 3: user block, persisting free-space, stored EOA = actual EOF */
+ "h5clear_fsm_persist_user_greater.h5", /* 4: user block, persisting free-space, stored EOA > actual EOF */
+ "h5clear_fsm_persist_user_less.h5", /* 5: user block, persisting free-space, stored EOA < actual EOF */
+ "h5clear_status_noclose.h5", /* 6 -- v3 superblock, nonzero status_flags, no flush, exit,
+ stored EOA < actual EOF */
+ "h5clear_fsm_persist_noclose.h5" /* 7 -- persisting free-space, no flush, exit, stored EOA < actual EOF */
+};
+
#define KB 1024U
#define CACHE_IMAGE_FILE "h5clear_mdc_image.h5"
#define DSET "DSET"
+#define DATASET "dset"
+#define NUM_ELMTS 100
+#define USERBLOCK 512
/*-------------------------------------------------------------------------
* Function: gen_cache_image_file
@@ -118,26 +133,224 @@ error:
H5Pclose(dcpl);
} H5E_END_TRY;
return 1;
-}
+} /* gen_cache_image_file() */
+
+/*-------------------------------------------------------------------------
+ * Function: gen_enhance_files
+ *
+ * Purpose: To create the first 6 files in FILENAME_ENHANCE[]:
+ * (0) FILENAME_ENHANCE[0]: "h5clear_fsm_persist_equal.h5"
+ * (1) FILENAME_ENHANCE[1]: "h5clear_fsm_persist_greater.h5"
+ * (2) FILENAME_ENHANCE[2]: "h5clear_fsm_persist_less.h5"
+ * (3) FILENAME_ENHANCE[3]: "h5clear_user_fsm_persist_equal.h5"
+ * (4) FILENAME_ENHANCE[4]: "h5clear_user_fsm_persist_greater.h5"
+ * (5) FILENAME_ENHANCE[5]: "h5clear_user_fsm_persist_less.h5"
+ * After creating the files for #1, #2, #4 #5, write invalid EOA
+ * value to the location where the EOA is stored in the superblock.
+ * Also modify the chksum in the superblock due to this change.
+ *
+ * The first call to this routine (without user block) will generate
+ * the first 3 files.
+ * The second call to this routine (with user block) will generate
+ * the last 3 files.
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Vailin Choi; March 2017
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+gen_enhance_files(hbool_t user)
+{
+ hid_t fid = -1; /* File ID */
+ hid_t fcpl = -1; /* File creation property list */
+ hid_t fapl = -1; /* File access property list */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t did = -1; /* Dataset ID */
+ hsize_t dim[1]; /* Dimension sizes */
+ int data[NUM_ELMTS]; /* Buffer for data */
+ int fd = -1; /* The file descriptor ID */
+ int64_t eoa; /* The EOA value */
+ int32_t chksum; /* The chksum value */
+ int i = 0 , j = 0, u = 0; /* Local index variable */
+
+ /* Get a copy of the default file creation property */
+ if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
+ goto error;
+
+ /* Check to see if user block will be added */
+ if(user) {
+ if(H5Pset_userblock(fcpl, (hsize_t)USERBLOCK) < 0)
+ goto error;
+ u = 3;
+ }
+
+ /* Set file space strategy and persisting free-space */
+ if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0)
+ goto error;
+
+ /*
+ * Create the file, then write invalid EOA to the file.
+ */
+ for(i = 0+u; i < 3+u; i++) {
+
+ /* Create the file with the file space strategy and persisting free-space */
+ if((fid = H5Fcreate(FILENAME_ENHANCE[i], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0)
+ goto error;
+
+ /* Create the dataset */
+ dim[0] = NUM_ELMTS;
+ if((sid = H5Screate_simple(1, dim, NULL)) < 0)
+ goto error;
+ if((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto error;
+
+ for(j = 0; j < NUM_ELMTS; j++)
+ data[j] = j;
+
+ /* Write the dataset */
+ if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
+ goto error;
+
+ /* Closing */
+ if(H5Dclose(did) < 0)
+ goto error;
+ if(H5Sclose(sid) < 0)
+ goto error;
+ if(H5Fclose(fid) < 0)
+ goto error;
+
+ /*
+ * No further action for:
+ * --FILENAME_ENHANCE[0]: "h5clear_fsm_persist_equal.h5"
+ * --FILENAME_ENHANCE[3]: "h5clear_fsm_persist_user_equal.h5",
+ */
+ if(!(i % 3))
+ continue;
+ /*
+ * For the following files:
+ * --FILENAME_ENHANCE[1]: "h5clear_fsm_persist_greater.h5"
+ * --FILENAME_ENHANCE[2]: "h5clear_fsm_persist_less.h5"
+ * --FILENAME_ENHANCE[4]: "h5clear_fsm_persist_greater.h5"
+ * --FILENAME_ENHANCE[5]: "h5clear_fsm_persist_less.h5"
+ *
+ * Write invalid value to the location for stored eoa and
+ * update the chksum value.
+ */
+ /* Open the file */
+ if((fd = open(FILENAME_ENHANCE[i], O_RDWR, 0663)) < 0)
+ goto error;
+
+ switch(i) {
+ case 1: /* stored EOA is > EOF */
+ eoa = 3048;
+ chksum = 268376587;
+ break;
+
+ case 2: /* stored EOA is < EOF */
+ eoa = 512;
+ chksum = 372920305;
+ break;
+
+ case 4: /* with userblock, stored EOA > EOF */
+ eoa = 4000;
+ chksum = 4168810027;
+ break;
+
+ case 5: /* with userblock, stored EOA < EOF */
+ eoa = 3000;
+ chksum = 3716054346;
+ break;
+
+ default:
+ break;
+ }
+
+ /* location of "end of file address" */
+ if(lseek(fd, (off_t)(28+(user?USERBLOCK:0)), SEEK_SET) < 0)
+ goto error;
+
+ /* Write the bad eoa value to the file */
+ if(write(fd, &eoa, sizeof(eoa)) < 0)
+ goto error;
+
+ /* location of "superblock checksum" */
+ if(lseek(fd, (off_t)(44+(user?USERBLOCK:0)), SEEK_SET) < 0)
+ goto error;
+
+ /* Write the chksum value to the file */
+ if(write(fd, &chksum, sizeof(chksum)) < 0)
+ goto error;
+
+ /* Close the file */
+ if(close(fd) < 0)
+ goto error;
+
+ } /* end for */
+
+ /* Close the property list */
+ if(H5Pclose(fcpl) < 0)
+ goto error;
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Sclose(sid);
+ H5Dclose(did);
+ H5Fclose(fid);
+ H5Pclose(fcpl);
+ } H5E_END_TRY;
+ return 1;
+} /* gen_enhance_files() */
/*-------------------------------------------------------------------------
* Function: main
*
- * Purpose: To create HDF5 files with non-zero status_flags in the superblock
- * via flushing and exiting without closing the library.
+ * Purpose: Generate test files used by h5clear.
*
- * Due to file locking, status_flags in the superblock will be
- * nonzero after H5Fcreate. The library will clear status_flags
- * on file closing. This program, after "H5Fcreate" the files,
- * exits without going through library closing. Thus, status_flags
- * for these files are not cleared.
- * The library will check consistency of status_flags when opening
- * a file with superblock >= v3 and will return error accordingly.
- * The library will not check status_flags when opening a file
- * with < v3 superblock.
+ * (A) gen_cache_image_file():
+ * --generate a file with cache image feature
+ * --"h5clear_mdc_image.h5"
+ * (B) gen_enhance_files():
+ * --generate the first 6 files in FILENAME_ENHANCE[]:
+ * (0) "h5clear_fsm_persist_equal.h5"
+ * (1) "h5clear_fsm_persist_greater.h5"
+ * (2) "h5clear_fsm_persist_less.h5"
+ * (3) "h5clear_fsm_persist_user_equal.h5"
+ * (4) "h5clear_fsm_persist_user_greater.h5"
+ * (5) "h5clear_fsm_persist_user_less.h5"
*
- * These files are used by "h5clear" to see if the tool clears
- * status_flags properly so users can open the files afterwards.
+ * (C) Generate the following FILENAME[] files in main():
+ * (0a) "h5clear_sec2_v3.h5"
+ * (0b) "latest_h5clear_sec2_v3.h5"
+ * (1a) "h5clear_log_v3.h5",
+ * (1b) "latest_h5clear_log_v3.h5"
+ * (2) "h5clear_sec2_v0.h5"
+ * (3) "h5clear_sec2_v2.h5"
+ *
+ * These HDF5 files are created with non-zero status_flags in
+ * the superblock via flushing and exiting without closing the
+ * library.
+ * Due to file locking, status_flags in the superblock will be
+ * nonzero after H5Fcreate. The library will clear status_flags
+ * on file closing.
+ * This program, after "H5Fcreate" the files, exits without
+ * going through library closing. Thus, status_flags for these
+ * files are not cleared.
+ * The library will check consistency of status_flags when
+ * opening a file with superblock >= v3 and will return error
+ * accordingly.
+ * The library will not check status_flags when opening a file
+ * with < v3 superblock.
+ * These files are used by "h5clear" to see if the tool clears
+ * status_flags properly so users can open the files afterwards.
+ *
+ * (D) Generate the last two files in FILENAME_ENHANCE[] in main():
+ * (6) "h5clear_status_noclose.h5",
+ * (7) "h5clear_fsm_persist_noclose.h5"
*
* Return: Success: 0
* Failure: 1
@@ -149,20 +362,30 @@ error:
int
main(void)
{
- hid_t fid; /* File ID */
- hid_t fcpl; /* File creation property list */
- hid_t fapl, new_fapl; /* File access property lists */
+ hid_t fid = -1; /* File ID */
+ hid_t fcpl = -1; /* File creation property list */
+ hid_t fapl = -1, new_fapl = -1; /* File access property lists */
char fname[512]; /* File name */
- unsigned new_format; /* To use latest library format or not */
+ unsigned new_format; /* To use latest library format or not */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t did = -1; /* Dataset ID */
+ hsize_t dim[1]; /* Dimension sizes */
+ int data[NUM_ELMTS]; /* Buffer for data */
+ int i; /* Local index variables */
/* Generate a file with cache image feature enabled */
if(gen_cache_image_file(CACHE_IMAGE_FILE) < 0)
goto error;
+ /* Generate the first 6 files in FILENAME_ENHANCE[] */
+ if(gen_enhance_files(FALSE) < 0)
+ goto error;
+ if(gen_enhance_files(TRUE) < 0)
+ goto error;
+
/*
- * Generate files with invalid status_flags
+ * Generate files in FILENAME[]
*/
-
/* Create a copy of the file access property list */
if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
goto error;
@@ -174,7 +397,11 @@ main(void)
if(H5Pset_libver_bounds(new_fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
goto error;
- /* Files created within this for loop will have v3 superblock and nonzero status_flags */
+ /*
+ * Files created within this for loop will have v3 superblock and nonzero status_flags
+ * --FILENAME[0]: "h5clear_sec2_v3.h5", "latest_h5clear_sec2_v3.h5"
+ * --FILENAME[1]: "h5clear_log_v3.h5", "latest_h5clear_log_v3.h5"
+ */
for(new_format = FALSE; new_format <= TRUE; new_format++) {
hid_t fapl2, my_fapl; /* File access property lists */
@@ -228,7 +455,8 @@ main(void)
} /* end for */
/*
- * Create a sec2 file with v0 superblock but nonzero status_flags
+ * Create a sec2 file with v0 superblock but nonzero status_flags:
+ * FILENAME[2]: "h5clear_sec2_v0.h5"
*/
if((fid = H5Fcreate(FILENAME[2], H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
goto error;
@@ -239,7 +467,8 @@ main(void)
/*
- * Create a sec2 file with v2 superblock but nonzero status_flags
+ * Create a sec2 file with v2 superblock but nonzero status_flags:
+ * FILENAME[3]: "h5clear_sec2_v2.h5"
*/
if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
goto error;
@@ -264,6 +493,100 @@ main(void)
if(H5Pclose(fcpl) < 0)
goto error;
+ /*
+ * Create the last two files in FILENAME_ENHANCE[]:
+ * --FILENAME_ENHANCE[6]: h5clear_status_noclose.h5
+ * --FILENAME_ENHANCE[7]: h5clear_fsm_persist_noclose.h5
+ */
+ /*
+ * FILENAME_ENHANCE[6]: h5clear_status_noclose.h5
+ * --stored EOA < actual EOF
+ * --version 3 superblock
+ * --nonzero status_flags
+ * --does not persist free-space
+ * --does not flush the file, just exit without closing file:
+ * --this file is similar to the user-suppplied test file attached with HDFFV-10347
+ */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ goto error;
+
+ /* Set to latest format */
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ goto error;
+
+ /* Create file with SWMR-write access */
+ if((fid = H5Fcreate(FILENAME_ENHANCE[6], H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0)
+ goto error;
+
+ /* Create the dataset */
+ dim[0] = NUM_ELMTS;
+ if((sid = H5Screate_simple(1, dim, NULL)) < 0)
+ goto error;
+ if((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto error;
+
+ for(i = 0; i < NUM_ELMTS; i++)
+ data[i] = i;
+
+ /* Write the dataset */
+ if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
+ goto error;
+
+ /* Closing */
+ if(H5Dclose(did) < 0)
+ goto error;
+ if(H5Sclose(sid) < 0)
+ goto error;
+ if(H5Pclose(fapl) < 0)
+ goto error;
+
+ /* Does not flush and does not close the file */
+
+
+ /*
+ * FILENAME_ENHANCE[7]: h5clear_fsm_persist_noclose.h5
+ * --stored EOA < actual EOF
+ * --persisting free-space
+ * --undefined fsinfo.eoa_pre_fsm_fsalloc
+ * --undefined fsinfo.fs_addr
+ * --does not flush the file, just exit without closing
+ */
+ if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
+ goto error;
+
+ /* Set file space strategy and persisting free-space */
+ if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, (hsize_t)1) < 0)
+ goto error;
+
+ /* Create the file with the set file space info */
+ if((fid = H5Fcreate(FILENAME_ENHANCE[7], H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0)
+ goto error;
+
+ /* Create the dataset */
+ dim[0] = NUM_ELMTS;
+ if((sid = H5Screate_simple(1, dim, NULL)) < 0)
+ goto error;
+ if((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto error;
+
+ for(i = 0; i < NUM_ELMTS; i++)
+ data[i] = i;
+
+ /* Write the dataset */
+ if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
+ goto error;
+
+ /* Closing */
+ if(H5Dclose(did) < 0)
+ goto error;
+ if(H5Sclose(sid) < 0)
+ goto error;
+ if(H5Pclose(fcpl) < 0)
+ goto error;
+
+ /* Does not flush and does not close the file */
+
+
fflush(stdout);
fflush(stderr);
diff --git a/tools/test/misc/testfiles/h5clear_equal_after_size.ddl b/tools/test/misc/testfiles/h5clear_equal_after_size.ddl
new file mode 100644
index 0000000..1b9a4e4
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_equal_after_size.ddl
@@ -0,0 +1 @@
+EOA is 1051141; EOF is 1051141
diff --git a/tools/test/misc/testfiles/h5clear_equal_before_size.ddl b/tools/test/misc/testfiles/h5clear_equal_before_size.ddl
new file mode 100644
index 0000000..9beed42
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_equal_before_size.ddl
@@ -0,0 +1 @@
+EOA is 2565; EOF is 2565
diff --git a/tools/test/misc/testfiles/h5clear_fsm_persist_equal.h5 b/tools/test/misc/testfiles/h5clear_fsm_persist_equal.h5
new file mode 100644
index 0000000..0577690
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_fsm_persist_equal.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_fsm_persist_greater.h5 b/tools/test/misc/testfiles/h5clear_fsm_persist_greater.h5
new file mode 100644
index 0000000..6358878
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_fsm_persist_greater.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_fsm_persist_less.h5 b/tools/test/misc/testfiles/h5clear_fsm_persist_less.h5
new file mode 100644
index 0000000..c1f3221
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_fsm_persist_less.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_fsm_persist_noclose.h5 b/tools/test/misc/testfiles/h5clear_fsm_persist_noclose.h5
new file mode 100644
index 0000000..57462db
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_fsm_persist_noclose.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_fsm_persist_user_equal.h5 b/tools/test/misc/testfiles/h5clear_fsm_persist_user_equal.h5
new file mode 100644
index 0000000..5389c41
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_fsm_persist_user_equal.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_fsm_persist_user_greater.h5 b/tools/test/misc/testfiles/h5clear_fsm_persist_user_greater.h5
new file mode 100644
index 0000000..f40e760
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_fsm_persist_user_greater.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_fsm_persist_user_less.h5 b/tools/test/misc/testfiles/h5clear_fsm_persist_user_less.h5
new file mode 100644
index 0000000..55d0cc5
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_fsm_persist_user_less.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_greater_after_size.ddl b/tools/test/misc/testfiles/h5clear_greater_after_size.ddl
new file mode 100644
index 0000000..74c8f19
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_greater_after_size.ddl
@@ -0,0 +1 @@
+EOA is 3048; EOF is 3048
diff --git a/tools/test/misc/testfiles/h5clear_greater_before_size.ddl b/tools/test/misc/testfiles/h5clear_greater_before_size.ddl
new file mode 100644
index 0000000..03b22fb
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_greater_before_size.ddl
@@ -0,0 +1 @@
+EOA is 3048; EOF is 2565
diff --git a/tools/test/misc/testfiles/h5clear_less_after_size.ddl b/tools/test/misc/testfiles/h5clear_less_after_size.ddl
new file mode 100644
index 0000000..bedf0d2
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_less_after_size.ddl
@@ -0,0 +1 @@
+EOA is 2765; EOF is 2765
diff --git a/tools/test/misc/testfiles/h5clear_less_before_size.ddl b/tools/test/misc/testfiles/h5clear_less_before_size.ddl
new file mode 100644
index 0000000..50ba4c4
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_less_before_size.ddl
@@ -0,0 +1 @@
+EOA is 512; EOF is 2565
diff --git a/tools/test/misc/testfiles/h5clear_missing_file.ddl b/tools/test/misc/testfiles/h5clear_missing_file.ddl
index 1e5150c..13eb2c9 100644
--- a/tools/test/misc/testfiles/h5clear_missing_file.ddl
+++ b/tools/test/misc/testfiles/h5clear_missing_file.ddl
@@ -4,7 +4,9 @@ usage: h5clear [OPTIONS] file_name
-V, --version Print version number and exit
-s, --status Clear the status_flags field in the file's superblock
-m, --image Remove the metadata cache image from the file
-
+ --filesize Print the file's EOA and EOF
+ --increment=C Set the file's EOA to the maximum of (EOA, EOF) + C for the file <file_name>
+ C is >= 0; C is optional and will default to 1M when not set
Examples of use:
h5clear -s file_name
@@ -12,4 +14,10 @@ h5clear -s file_name
h5clear -m file_name
Remove the metadata cache image from the HDF5 file <file_name>.
+
+h5clear --increment file_name
+ Set the EOA to the maximum of (EOA, EOF) + 1M for the file <file_name>.
+
+h5clear --increment=512 file_name
+ Set the EOA to the maximum of (EOA, EOF) + 512 for the file <file_name>.
h5clear error: missing file name
diff --git a/tools/test/misc/testfiles/h5clear_noclose_after_size.ddl b/tools/test/misc/testfiles/h5clear_noclose_after_size.ddl
new file mode 100644
index 0000000..7846b47
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_noclose_after_size.ddl
@@ -0,0 +1 @@
+EOA is 2448; EOF is 2448
diff --git a/tools/test/misc/testfiles/h5clear_noclose_before_size.ddl b/tools/test/misc/testfiles/h5clear_noclose_before_size.ddl
new file mode 100644
index 0000000..f294a6d
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_noclose_before_size.ddl
@@ -0,0 +1 @@
+EOA is 2048; EOF is 2448
diff --git a/tools/test/misc/testfiles/h5clear_status_noclose.h5 b/tools/test/misc/testfiles/h5clear_status_noclose.h5
new file mode 100644
index 0000000..94a950d
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_status_noclose.h5
Binary files differ
diff --git a/tools/test/misc/testfiles/h5clear_status_noclose_after_size.ddl b/tools/test/misc/testfiles/h5clear_status_noclose_after_size.ddl
new file mode 100644
index 0000000..7846b47
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_status_noclose_after_size.ddl
@@ -0,0 +1 @@
+EOA is 2448; EOF is 2448
diff --git a/tools/test/misc/testfiles/h5clear_usage.ddl b/tools/test/misc/testfiles/h5clear_usage.ddl
index a399ae7..32dd549 100644
--- a/tools/test/misc/testfiles/h5clear_usage.ddl
+++ b/tools/test/misc/testfiles/h5clear_usage.ddl
@@ -4,7 +4,9 @@ usage: h5clear [OPTIONS] file_name
-V, --version Print version number and exit
-s, --status Clear the status_flags field in the file's superblock
-m, --image Remove the metadata cache image from the file
-
+ --filesize Print the file's EOA and EOF
+ --increment=C Set the file's EOA to the maximum of (EOA, EOF) + C for the file <file_name>
+ C is >= 0; C is optional and will default to 1M when not set
Examples of use:
h5clear -s file_name
@@ -12,3 +14,9 @@ h5clear -s file_name
h5clear -m file_name
Remove the metadata cache image from the HDF5 file <file_name>.
+
+h5clear --increment file_name
+ Set the EOA to the maximum of (EOA, EOF) + 1M for the file <file_name>.
+
+h5clear --increment=512 file_name
+ Set the EOA to the maximum of (EOA, EOF) + 512 for the file <file_name>.
diff --git a/tools/test/misc/testfiles/h5clear_user_equal_after_size.ddl b/tools/test/misc/testfiles/h5clear_user_equal_after_size.ddl
new file mode 100644
index 0000000..028e134
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_user_equal_after_size.ddl
@@ -0,0 +1 @@
+EOA is 1051653; EOF is 1051653
diff --git a/tools/test/misc/testfiles/h5clear_user_equal_before_size.ddl b/tools/test/misc/testfiles/h5clear_user_equal_before_size.ddl
new file mode 100644
index 0000000..ef7c391
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_user_equal_before_size.ddl
@@ -0,0 +1 @@
+EOA is 3077; EOF is 3077
diff --git a/tools/test/misc/testfiles/h5clear_user_greater_after_size.ddl b/tools/test/misc/testfiles/h5clear_user_greater_after_size.ddl
new file mode 100644
index 0000000..9d7de6f
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_user_greater_after_size.ddl
@@ -0,0 +1 @@
+EOA is 4000; EOF is 4000
diff --git a/tools/test/misc/testfiles/h5clear_user_greater_before_size.ddl b/tools/test/misc/testfiles/h5clear_user_greater_before_size.ddl
new file mode 100644
index 0000000..c3fe625
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_user_greater_before_size.ddl
@@ -0,0 +1 @@
+EOA is 4000; EOF is 3077
diff --git a/tools/test/misc/testfiles/h5clear_user_less_after_size.ddl b/tools/test/misc/testfiles/h5clear_user_less_after_size.ddl
new file mode 100644
index 0000000..02c0d2a
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_user_less_after_size.ddl
@@ -0,0 +1 @@
+EOA is 3277; EOF is 3277
diff --git a/tools/test/misc/testfiles/h5clear_user_less_before_size.ddl b/tools/test/misc/testfiles/h5clear_user_less_before_size.ddl
new file mode 100644
index 0000000..0651c2b
--- /dev/null
+++ b/tools/test/misc/testfiles/h5clear_user_less_before_size.ddl
@@ -0,0 +1 @@
+EOA is 3000; EOF is 3077
diff --git a/tools/test/misc/testh5clear.sh.in b/tools/test/misc/testh5clear.sh.in
index 2966b2c..11c2ff9 100644
--- a/tools/test/misc/testh5clear.sh.in
+++ b/tools/test/misc/testh5clear.sh.in
@@ -66,6 +66,21 @@ $SRC_H5CLEAR_TESTFILES/h5clear_usage.ddl
$SRC_H5CLEAR_TESTFILES/h5clear_open_fail.ddl
$SRC_H5CLEAR_TESTFILES/h5clear_missing_file.ddl
$SRC_H5CLEAR_TESTFILES/h5clear_no_mdc_image.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_status_noclose_after_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_noclose_before_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_noclose_after_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_equal_before_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_equal_after_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_greater_before_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_greater_after_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_less_before_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_less_after_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_user_equal_before_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_user_equal_after_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_user_greater_before_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_user_greater_after_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_user_less_before_size.ddl
+$SRC_H5CLEAR_TESTFILES/h5clear_user_less_after_size.ddl
$SRC_H5CLEAR_TESTFILES/h5clear_sec2_v0.h5
$SRC_H5CLEAR_TESTFILES/h5clear_sec2_v2.h5
$SRC_H5CLEAR_TESTFILES/h5clear_sec2_v3.h5
@@ -74,6 +89,14 @@ $SRC_H5CLEAR_TESTFILES/latest_h5clear_log_v3.h5
$SRC_H5CLEAR_TESTFILES/latest_h5clear_sec2_v3.h5
$SRC_H5CLEAR_TESTFILES/h5clear_mdc_image.h5
$SRC_H5CLEAR_TESTFILES/mod_h5clear_mdc_image.h5
+$SRC_H5CLEAR_TESTFILES/h5clear_status_noclose.h5
+$SRC_H5CLEAR_TESTFILES/h5clear_fsm_persist_noclose.h5
+$SRC_H5CLEAR_TESTFILES/h5clear_fsm_persist_equal.h5
+$SRC_H5CLEAR_TESTFILES/h5clear_fsm_persist_greater.h5
+$SRC_H5CLEAR_TESTFILES/h5clear_fsm_persist_less.h5
+$SRC_H5CLEAR_TESTFILES/h5clear_fsm_persist_user_equal.h5
+$SRC_H5CLEAR_TESTFILES/h5clear_fsm_persist_user_greater.h5
+$SRC_H5CLEAR_TESTFILES/h5clear_fsm_persist_user_less.h5
"
COPY_TESTFILES_TO_TESTDIR()
@@ -152,7 +175,8 @@ TOOLTEST_OUT() {
fname=$1
option1=$2
option2=$3
- expected=$4
+ option3=$4
+ expected=$5
# Prepare expected and actual output
expect="$TESTDIR/$expected"
actual="$TESTDIR/`basename $expected .ddl`.out"
@@ -161,10 +185,10 @@ TOOLTEST_OUT() {
actual_err_sav=${actual_err}-sav
# Run test.
- TESTING $H5CLEAR $option1 $option2 $fname
+ TESTING $H5CLEAR $option1 $option2 $option3 $option4 $fname
(
cd $TESTDIR
- $RUNSERIAL $H5CLEAR_BIN $option1 $option2 $fname
+ $RUNSERIAL $H5CLEAR_BIN $option1 $option2 $option3 $option4 $fname
) >$actual 2>$actual_err
cp $actual $actual_sav
cp $actual_err $actual_err_sav
@@ -245,17 +269,16 @@ $CP -f $TESTDIR/h5clear_sec2_v3.h5 $TESTDIR/orig_h5clear_sec2_v3.h5
# "h5clear -m -s junk.h5" (valid 2 options, nonexisting file)
# "h5clear -m orig_h5clear_sec2_v2.h5" (valid 1 option, existing file, no cache image)
# "h5clear -s -m orig_h5clear_sec2_v0.h5" (valid 2 options, existing file, no cache image)
-TOOLTEST_OUT "" -h "" h5clear_usage.ddl
-TOOLTEST_OUT "" "" "" h5clear_usage.ddl
-TOOLTEST_OUT junk.h5 "" "" h5clear_usage.ddl
-TOOLTEST_OUT orig_h5clear_sec2_v3.h5 "" "" h5clear_usage.ddl
-TOOLTEST_OUT "" -m "" h5clear_missing_file.ddl
-TOOLTEST_OUT junk.h5 -s "" h5clear_open_fail.ddl
-TOOLTEST_OUT "" -m -s h5clear_missing_file.ddl
-TOOLTEST_OUT junk.h5 -m -s h5clear_open_fail.ddl
-TOOLTEST_OUT orig_h5clear_sec2_v2.h5 -m "" h5clear_no_mdc_image.ddl
-TOOLTEST_OUT orig_h5clear_sec2_v0.h5 -s -m h5clear_no_mdc_image.ddl
-#
+TOOLTEST_OUT "" -h "" "" h5clear_usage.ddl
+TOOLTEST_OUT "" "" "" "" h5clear_usage.ddl
+TOOLTEST_OUT junk.h5 "" "" "" h5clear_usage.ddl
+TOOLTEST_OUT orig_h5clear_sec2_v3.h5 "" "" "" h5clear_usage.ddl
+TOOLTEST_OUT "" -m "" "" h5clear_missing_file.ddl
+TOOLTEST_OUT junk.h5 -s "" "" h5clear_open_fail.ddl
+TOOLTEST_OUT "" -m -s "" h5clear_missing_file.ddl
+TOOLTEST_OUT junk.h5 -m -s "" h5clear_open_fail.ddl
+TOOLTEST_OUT orig_h5clear_sec2_v2.h5 -m "" "" h5clear_no_mdc_image.ddl
+TOOLTEST_OUT orig_h5clear_sec2_v0.h5 -s -m "" h5clear_no_mdc_image.ddl
#
#
# The following are tests to verify the expected exit code from h5clear:
@@ -285,8 +308,8 @@ TOOLTEST h5clear_sec2_v0.h5 -l -m $FAIL
#
#
# h5clear_mdc_image.h5 already has cache image removed earlier, verify the expected warning from h5clear:
-TOOLTEST_OUT mod_h5clear_mdc_image.h5 -m "" h5clear_no_mdc_image.ddl
-TOOLTEST_OUT mod_h5clear_mdc_image.h5 -s -m h5clear_no_mdc_image.ddl
+TOOLTEST_OUT mod_h5clear_mdc_image.h5 -m "" "" h5clear_no_mdc_image.ddl
+TOOLTEST_OUT mod_h5clear_mdc_image.h5 -s -m "" h5clear_no_mdc_image.ddl
#
#
#
@@ -319,6 +342,73 @@ OPEN_CHK h5clear_sec2_v2.h5 $SUCCEED
#
#
#
+# (1) h5clear_status_noclose.h5
+# "h5clear --filesize h5clear_status_noclose.h5" (unable to open the file because status_flag is on)
+# "h5clear -s --increment=0 h5clear_status_noclose.h5" (clear status_flag, EOA = MAX(EOA, EOF) + 0)
+# (no output, check exit code)
+# "h5clear --filesize h5clear_status_noclose_user.h5" (print EOA/EOF after the last action)
+TOOLTEST_OUT h5clear_status_noclose.h5 --filesize "" "" h5clear_open_fail.ddl
+TOOLTEST h5clear_status_noclose.h5 -s --increment=0 $SUCCEED
+TOOLTEST_OUT h5clear_status_noclose.h5 --filesize "" "" h5clear_status_noclose_after_size.ddl
+#
+# (2) h5clear_fsm_persist_noclose.h5
+# "h5clear --filesize h5clear_fsm_persist_noclose.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=0 h5clear_fsm_persist_noclose.h5" (EOA = MAX(EOA, EOF)) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_noclose.h5" (print EOA/EOF after the last action)
+TOOLTEST_OUT h5clear_fsm_persist_noclose.h5 --filesize "" "" h5clear_noclose_before_size.ddl
+TOOLTEST h5clear_fsm_persist_noclose.h5 --increment=0 "" $SUCCEED
+TOOLTEST_OUT h5clear_fsm_persist_noclose.h5 --filesize "" "" h5clear_noclose_after_size.ddl
+#
+# (3) h5clear_fsm_persist_equal.h5
+# "h5clear --filesize h5clear_fsm_persist_equal.h5" (print EOA/EOF before the next action)
+# "h5clear --increment h5clear_fsm_persist_equal.h5" (EOA = MAX(EOA, EOF) + 1M) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_equal.h5" (print EOA/EOF after the last action)
+TOOLTEST_OUT h5clear_fsm_persist_equal.h5 --filesize "" "" h5clear_equal_before_size.ddl
+TOOLTEST h5clear_fsm_persist_equal.h5 --increment "" $SUCCEED
+TOOLTEST_OUT h5clear_fsm_persist_equal.h5 --filesize "" "" h5clear_equal_after_size.ddl
+#
+# (4) h5clear_fsm_persist_greater.h5
+# "h5clear --filesize h5clear_fsm_persist_greater.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=0 h5clear_fsm_persist_greater.h5" (EOA = MAX(EOA, EOF) + 0) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_greater.h5" (print EOA/EOF after the last action)
+TOOLTEST_OUT h5clear_fsm_persist_greater.h5 --filesize "" "" h5clear_greater_before_size.ddl
+TOOLTEST h5clear_fsm_persist_greater.h5 --increment=0 "" $SUCCEED
+TOOLTEST_OUT h5clear_fsm_persist_greater.h5 --filesize "" "" h5clear_greater_after_size.ddl
+#
+# (5) h5clear_fsm_persist_less.h5
+# "h5clear --filesize h5clear_fsm_persist_less.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=200 h5clear_fsm_persist_less.h5" (EOA = MAX(EOA, EOF) + 200) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_less.h5" (print EOA/EOF after the last action)
+TOOLTEST_OUT h5clear_fsm_persist_less.h5 --filesize "" "" h5clear_less_before_size.ddl
+TOOLTEST h5clear_fsm_persist_less.h5 --increment=200 "" $SUCCEED
+TOOLTEST_OUT h5clear_fsm_persist_less.h5 --filesize "" "" h5clear_less_after_size.ddl
+#
+# (6) h5clear_fsm_persist_user_equal.h5
+# "h5clear --filesize h5clear_fsm_persist_user_equal.h5" (print EOA/EOF before the next action)
+# "h5clear --increment h5clear_fsm_persist_user_equal.h5" (EOA = MAX(EOA, EOF) + 1M) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_user_equal.h5" (print EOA/EOF after the last action)
+TOOLTEST_OUT h5clear_fsm_persist_user_equal.h5 --filesize "" "" h5clear_user_equal_before_size.ddl
+TOOLTEST h5clear_fsm_persist_user_equal.h5 --increment "" $SUCCEED
+TOOLTEST_OUT h5clear_fsm_persist_user_equal.h5 --filesize "" "" h5clear_user_equal_after_size.ddl
+#
+# (7) h5clear_fsm_persist_user_greater.h5
+# "h5clear --filesize h5clear_fsm_persist_user_greater.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=0 h5clear_fsm_persist_user_greater.h5" (EOA = MAX(EOA, EOF) + 0) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_user_greater.h5" (print EOA/EOF after the last action)
+TOOLTEST_OUT h5clear_fsm_persist_user_greater.h5 --filesize "" "" h5clear_user_greater_before_size.ddl
+TOOLTEST h5clear_fsm_persist_user_greater.h5 --increment=0 "" $SUCCEED
+TOOLTEST_OUT h5clear_fsm_persist_user_greater.h5 --filesize "" "" h5clear_user_greater_after_size.ddl
+#
+# (8) h5clear_fsm_persist_user_less.h5
+# "h5clear --filesize h5clear_fsm_persist_user_less.h5" (print EOA/EOF before the next action)
+# "h5clear --increment=200 h5clear_fsm_persist_user_less.h5" (EOA = MAX(EOA, EOF) + 200) (no output, check exit code)
+# "h5clear --filesize h5clear_fsm_persist_user_less.h5" (print EOA/EOF after the last action)
+TOOLTEST_OUT h5clear_fsm_persist_user_less.h5 --filesize "" "" h5clear_user_less_before_size.ddl
+TOOLTEST h5clear_fsm_persist_user_less.h5 --increment=200 "" $SUCCEED
+TOOLTEST_OUT h5clear_fsm_persist_user_less.h5 --filesize "" "" h5clear_user_less_after_size.ddl
+#
+#
+#
# Clean up test files
if test -z "$HDF5_NOCLEANUP"; then
rm -f h5clear_*.h5 latest_h5clear*.h5