summaryrefslogtreecommitdiffstats
path: root/test/vfd_swmr.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/vfd_swmr.c')
-rw-r--r--test/vfd_swmr.c1378
1 files changed, 1174 insertions, 204 deletions
diff --git a/test/vfd_swmr.c b/test/vfd_swmr.c
index 3ed73c1..e93a399 100644
--- a/test/vfd_swmr.c
+++ b/test/vfd_swmr.c
@@ -41,6 +41,7 @@
#define FS_PAGE_SIZE 512
#define FILENAME "vfd_swmr_file.h5"
#define MD_FILENAME "vfd_swmr_metadata_file"
+#define UD_FILENAME "vfd_swmr_updater_file"
#define FILENAME2 "vfd_swmr_file2.h5"
#define MD_FILENAME2 "vfd_swmr_metadata_file2"
@@ -48,61 +49,50 @@
#define FILENAME3 "vfd_swmr_file3.h5"
#define MD_FILENAME3 "vfd_swmr_metadata_file3"
+#define FILENAME4 "vfd_swmr_file4.h5"
+#define MD_FILE "vfd_swmr_md_file"
+#define UD_FILE "vfd_swmr_ud_file"
+
#define FNAME "non_vfd_swmr_file.h5"
-/* test routines for VFD SWMR */
-static unsigned test_fapl(void);
-static unsigned test_file_end_tick(void);
-static unsigned test_file_fapl(void);
-static unsigned test_writer_md(void);
+/* Defines used by verify_updater_flags() and verify_ud_chk() helper routine */
-/* helper routines */
-static hid_t init_vfd_swmr_config_fapl(H5F_vfd_swmr_config_t *config, uint32_t tick_len, uint32_t max_lag,
- hbool_t is_writer, uint32_t md_pages_reserved,
- const char *md_file_path, size_t pbuf_size);
+/* Offset of "flags" in updater file header */
+#define UD_HD_FLAGS_OFFSET 6
-/*-------------------------------------------------------------------------
- * Function: init_vfd_swmr_config_fapl
- *
- * Purpose: Helper routine to initialize the fields for VFD SWMR configuration
- *
- * Return: void
- *
- *-------------------------------------------------------------------------
- */
-static hid_t
-init_vfd_swmr_config_fapl(H5F_vfd_swmr_config_t *config, uint32_t tick_len, uint32_t max_lag,
- hbool_t is_writer, uint32_t md_pages_reserved, const char *md_file_path,
- size_t pbuf_size)
-{
- hid_t fapl;
+/* Offset of "sequence number" in updater file header */
+#define UD_HD_SEQ_NUM_OFFSET 12
- HDmemset(config, 0, sizeof(*config));
+/* Offset of "change list length" in updater file header */
+#define UD_HD_CHANGE_LIST_LEN_OFFSET 36
- config->version = H5F__CURR_VFD_SWMR_CONFIG_VERSION;
- config->tick_len = tick_len;
- config->max_lag = max_lag;
- config->writer = is_writer;
- config->md_pages_reserved = md_pages_reserved;
- HDstrcpy(config->md_file_path, md_file_path);
+/* Offset of "number of change list entries" in updater file change list header */
+#define UD_CL_NUM_CHANGE_LIST_ENTRIES_OFFSET H5F_UD_HEADER_SIZE + 44
- /* Create a copy of the file access property list */
- if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
- return H5I_INVALID_HID;
+/* Size of "sequence number", "tick number" and "change list length" fields in the updater file header */
+#define UD_SIZE_8 8
- if (H5Pset_vfd_swmr_config(fapl, config) < 0) {
- (void)H5Pclose(fapl);
- return H5I_INVALID_HID;
- }
+/* Size of checksum and "number of change list entries" field in the updater change list header */
+#define UD_SIZE_4 4
- /* Enable page buffering */
- if (pbuf_size != 0 && H5Pset_page_buffer_size(fapl, pbuf_size, 0, 0) < 0) {
- (void)H5Pclose(fapl);
- return H5I_INVALID_HID;
- }
+/* Size of "flags" field in the updater file header */
+#define UD_SIZE_2 2
+
+/* test routines for VFD SWMR */
+static unsigned test_fapl(void);
+static unsigned test_file_end_tick(void);
+static unsigned test_file_fapl(void);
+static unsigned test_writer_md(void);
+
+static unsigned test_updater_flags(void);
+static unsigned test_updater_flags_same_file_opens(void);
+static herr_t verify_updater_flags(char *ud_name, uint16_t expected_flags);
+
+static void clean_chk_ud_files(char *md_file_path, char *updater_file_path);
+static herr_t verify_ud_chk(char *md_file_path, char *ud_file_path);
+static herr_t md_ck_cb(char *md_file_path, uint64_t tick_num);
+static unsigned test_updater_generate_md_checksums(hbool_t file_create);
- return fapl;
-} /* init_vfd_swmr_config_fapl() */
/*-------------------------------------------------------------------------
* Function: test_fapl()
@@ -114,6 +104,12 @@ init_vfd_swmr_config_fapl(H5F_vfd_swmr_config_t *config, uint32_t tick_len, uint
* --max_lag: should be >= 3
* --md_pages_reserved: should be >= 2
* --md_file_path: should contain the metadata file path (POSIX)
+ * --at least one of maintain_metadata_file and generate_updater_files
+ * must be true
+ * --if both the writer and maintain_metadata_file fields are true,
+ * then md_file_path field shouldn't be empty
+ * --if both the writer and generate_updater_files fields are true,
+ * then updater_file_path field shouldn't be empty
* B) Verify that info set in the fapl is retrieved correctly.
*
* Return: 0 if test is sucessful
@@ -195,9 +191,40 @@ test_fapl(void)
if (ret >= 0)
TEST_ERROR;
+ my_config->writer = TRUE;
+ /* Should fail: at least one of maintain_metadata_file and generate_updater_files must be true */
+ H5E_BEGIN_TRY
+ {
+ ret = H5Pset_vfd_swmr_config(fapl, my_config);
+ }
+ H5E_END_TRY;
+ if (ret >= 0)
+ TEST_ERROR;
+
+ my_config->writer = TRUE;
+ my_config->maintain_metadata_file = TRUE;
+ /* Should fail: empty md_file_path */
+ H5E_BEGIN_TRY
+ {
+ ret = H5Pset_vfd_swmr_config(fapl, my_config);
+ }
+ H5E_END_TRY;
+ if (ret >= 0)
+ TEST_ERROR;
+
+ my_config->generate_updater_files = TRUE;
+ /* Should fail: empty updater_file_path */
+ H5E_BEGIN_TRY
+ {
+ ret = H5Pset_vfd_swmr_config(fapl, my_config);
+ }
+ H5E_END_TRY;
+ if (ret >= 0)
+ TEST_ERROR;
+
/* Set md_file_path */
HDstrcpy(my_config->md_file_path, MD_FILENAME);
- my_config->writer = TRUE;
+ my_config->generate_updater_files = FALSE;
/* Should succeed in setting the configuration info */
if (H5Pset_vfd_swmr_config(fapl, my_config) < 0)
@@ -215,6 +242,33 @@ test_fapl(void)
TEST_ERROR;
if (my_config->md_pages_reserved != 2)
TEST_ERROR;
+ if (my_config->generate_updater_files)
+ TEST_ERROR;
+ if (HDstrcmp(my_config->md_file_path, MD_FILENAME) != 0)
+ TEST_ERROR;
+
+ my_config->generate_updater_files = TRUE;
+ /* Set updater_file_path */
+ HDstrcpy(my_config->updater_file_path, UD_FILENAME);
+
+ /* Should succeed in setting the configuration info */
+ if (H5Pset_vfd_swmr_config(fapl, my_config) < 0)
+ TEST_ERROR;
+
+ /* Clear the configuration structure */
+ HDmemset(my_config, 0, sizeof(H5F_vfd_swmr_config_t));
+
+ /* Retrieve the configuration info just set */
+ if (H5Pget_vfd_swmr_config(fapl, my_config) < 0)
+ TEST_ERROR;
+
+ /* Verify the configuration info */
+ if (!my_config->generate_updater_files)
+ TEST_ERROR;
+ if (HDstrcmp(my_config->updater_file_path, UD_FILENAME) != 0)
+ TEST_ERROR;
+ if (!my_config->maintain_metadata_file)
+ TEST_ERROR;
if (HDstrcmp(my_config->md_file_path, MD_FILENAME) != 0)
TEST_ERROR;
@@ -290,8 +344,17 @@ test_file_fapl(void)
if ((file_config = (H5F_vfd_swmr_config_t *)HDmalloc(sizeof(H5F_vfd_swmr_config_t))) == NULL)
FAIL_STACK_ERROR;
- /* Configured as VFD SWMR reader + no page buffering */
- fapl1 = init_vfd_swmr_config_fapl(config1, 4, 6, FALSE, 2, MD_FILENAME, 0);
+
+ /*
+ * Configured as VFD SWMR reader + no page buffering
+ */
+
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config1, 4, 7, FALSE, TRUE, FALSE, TRUE, 2, MD_FILENAME, NULL);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl1 = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, 0, config1);
if (fapl1 == H5I_INVALID_HID)
TEST_ERROR
@@ -307,8 +370,17 @@ test_file_fapl(void)
if (H5Pclose(fapl1) < 0)
FAIL_STACK_ERROR
- /* Configured as VFD SWMR writer + no page buffering */
- fapl1 = init_vfd_swmr_config_fapl(config1, 4, 6, TRUE, 2, MD_FILENAME, 0);
+ /*
+ * Configured as VFD SWMR writer + no page buffering
+ */
+
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config1, 4, 7, TRUE, TRUE, TRUE, TRUE, 2, MD_FILENAME, UD_FILENAME);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl1 = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, 0, config1);
+
if (fapl1 == H5I_INVALID_HID)
TEST_ERROR
@@ -321,13 +393,10 @@ test_file_fapl(void)
if (fid >= 0)
TEST_ERROR;
- /* Create a copy of the file creation property list */
- if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
+ if ((fcpl = vfd_swmr_create_fcpl(H5F_FSPACE_STRATEGY_PAGE, 4096)) < 0) {
+ HDprintf("vfd_swmr_create_fcpl() failed");
FAIL_STACK_ERROR
-
- /* Set file space strategy */
- if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0)
- FAIL_STACK_ERROR;
+ }
/* Should fail to create: no page buffering */
H5E_BEGIN_TRY
@@ -341,8 +410,17 @@ test_file_fapl(void)
if (H5Pclose(fapl1) < 0)
FAIL_STACK_ERROR
- /* Configured as VFD SWMR writer + page buffering */
- fapl1 = init_vfd_swmr_config_fapl(config1, 4, 6, TRUE, 2, MD_FILENAME, 4096);
+ /*
+ * Configured as VFD SWMR writer + page buffering
+ */
+
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config1, 4, 7, TRUE, TRUE, FALSE, TRUE, 2, MD_FILENAME, NULL);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl1 = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, 4096, config1);
+
if (fapl1 == H5I_INVALID_HID)
TEST_ERROR
@@ -404,8 +482,17 @@ test_file_fapl(void)
if (H5Pclose(fapl1) < 0)
FAIL_STACK_ERROR;
- /* Set up different VFD SWMR configuration + page_buffering */
- fapl2 = init_vfd_swmr_config_fapl(config2, 4, 10, TRUE, 2, MD_FILENAME, 4096);
+ /*
+ * Set up different VFD SWMR configuration + page_buffering
+ */
+
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config2, 4, 10, TRUE, TRUE, FALSE, TRUE, 2, MD_FILENAME, NULL);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl2 = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, 4096, config2);
+
if (fapl2 == H5I_INVALID_HID)
TEST_ERROR
@@ -435,10 +522,20 @@ test_file_fapl(void)
/* The file previously opened as VDF SWMR writer is still open */
/* with VFD SWMR configuration in config2 */
- /* Set up as VFD SWMR writer in config1 but different from config2 */
- fapl1 = init_vfd_swmr_config_fapl(config1, 3, 8, TRUE, 3, MD_FILENAME, 4096);
+
+ /*
+ * Set up as VFD SWMR writer in config1 but different from config2
+ */
+
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config1, 3, 8, TRUE, TRUE, FALSE, TRUE, 3, MD_FILENAME, NULL);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl1 = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, 4096, config1);
+
if (fapl1 == H5I_INVALID_HID)
- TEST_ERROR;
+ TEST_ERROR
/* Re-open the same file with config1 */
/* Should fail to open since config1 is different from config2 setting */
@@ -454,10 +551,17 @@ test_file_fapl(void)
if (H5Pclose(fapl1) < 0)
FAIL_STACK_ERROR;
- /* Set up as VFD SWMR reader in config1 which is same as config2 */
- fapl1 = init_vfd_swmr_config_fapl(config1, 4, 10, TRUE, 2, MD_FILENAME, 4096);
+ /*
+ * Set up as VFD SWMR reader in config1 which is same as config2
+ */
+
+ init_vfd_swmr_config(config1, 4, 10, TRUE, TRUE, FALSE, TRUE, 2, MD_FILENAME, NULL);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl1 = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, 4096, config1);
+
if (fapl1 == H5I_INVALID_HID)
- TEST_ERROR;
+ TEST_ERROR
/* Re-open the same file as VFD SWMR writer */
/* Should succeed since config1 is same as the setting in config2 */
@@ -530,6 +634,7 @@ error:
return 1;
} /* test_file_fapl() */
+
/*-------------------------------------------------------------------------
* Function: test_file_end_tick()
*
@@ -589,28 +694,52 @@ test_file_end_tick(void)
if ((config3 = HDmalloc(sizeof(*config3))) == NULL)
FAIL_STACK_ERROR;
- /* Configured file 1 as VFD SWMR writer + page buffering */
- fapl1 = init_vfd_swmr_config_fapl(config1, 10, 15, TRUE, 2, MD_FILENAME, 4096);
+ /*
+ * Configured file 1 as VFD SWMR writer + page buffering
+ */
+
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config1, 10, 15, TRUE, TRUE, FALSE, TRUE, 2, MD_FILENAME, NULL);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl1 = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, 4096, config1);
+
if (fapl1 == H5I_INVALID_HID)
- FAIL_STACK_ERROR;
+ TEST_ERROR
+
+ /*
+ * Configured file 2 as VFD SWMR writer + page buffering
+ */
+
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config2, 5, 6, TRUE, TRUE, FALSE, TRUE, 2, MD_FILENAME2, NULL);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl2 = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, 4096, config2);
- /* Configured file 2 as VFD SWMR writer + page buffering */
- fapl2 = init_vfd_swmr_config_fapl(config2, 5, 6, TRUE, 2, MD_FILENAME2, 4096);
if (fapl2 == H5I_INVALID_HID)
- FAIL_STACK_ERROR;
+ TEST_ERROR
- /* Configured file 3 as VFD SWMR writer + page buffering */
- fapl3 = init_vfd_swmr_config_fapl(config3, 3, 6, TRUE, 2, MD_FILENAME3, 4096);
- if (fapl3 == H5I_INVALID_HID)
- FAIL_STACK_ERROR;
+ /*
+ * Configured file 3 as VFD SWMR writer + page buffering
+ */
- /* Create a copy of the file creation property list */
- if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
- FAIL_STACK_ERROR
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config3, 3, 6, TRUE, TRUE, FALSE, TRUE, 2, MD_FILENAME3, NULL);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl3 = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, 4096, config3);
+
+ if (fapl3 == H5I_INVALID_HID)
+ TEST_ERROR
- /* Set file space strategy */
- if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0)
+ if ((fcpl = vfd_swmr_create_fcpl(H5F_FSPACE_STRATEGY_PAGE, 4096)) < 0) {
+ HDprintf("vfd_swmr_create_fcpl() failed");
FAIL_STACK_ERROR;
+ }
/* Create file 1 with VFD SWMR writer */
if ((fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl1)) < 0)
@@ -776,18 +905,23 @@ test_writer_create_open_flush(void)
if ((my_config = HDmalloc(sizeof(H5F_vfd_swmr_config_t))) == NULL)
FAIL_STACK_ERROR;
- /* Set up the VFD SWMR configuration + page buffering */
- fapl = init_vfd_swmr_config_fapl(my_config, 1, 3, TRUE, 2, MD_FILENAME, 4096);
- if (fapl == H5I_INVALID_HID)
- FAIL_STACK_ERROR;
+ /*
+ * Set up the VFD SWMR configuration + page buffering
+ */
- /* Create a copy of the file creation property list */
- if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
- FAIL_STACK_ERROR
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(my_config, 1, 3, TRUE, TRUE, FALSE, TRUE, 2, MD_FILENAME, NULL);
- /* Set file space strategy */
- if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0)
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, 4096, my_config);
+ if (fapl == H5I_INVALID_HID)
+ TEST_ERROR
+
+ if ((fcpl = vfd_swmr_create_fcpl(H5F_FSPACE_STRATEGY_PAGE, 4096)) < 0) {
+ HDprintf("vfd_swmr_create_fcpl() failed");
FAIL_STACK_ERROR;
+ }
/* Create an HDF5 file with VFD SWMR configured */
if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0)
@@ -797,7 +931,6 @@ test_writer_create_open_flush(void)
if (H5F__vfd_swmr_writer_create_open_flush_test(fid, TRUE) < 0)
FAIL_STACK_ERROR;
-#ifdef LATER /* Will activate the test when flush is implemented */
/* Flush the HDF5 file */
if (H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0)
FAIL_STACK_ERROR
@@ -805,7 +938,6 @@ test_writer_create_open_flush(void)
/* Verify info in metadata file when flushing the HDF5 file */
if (H5F__vfd_swmr_writer_create_open_flush_test(fid, FALSE) < 0)
FAIL_STACK_ERROR
-#endif
/* Close the file */
if (H5Fclose(fid) < 0)
@@ -891,6 +1023,7 @@ test_writer_md(void)
hsize_t chunk_dims[2] = {2, 5}; /* Dataset chunked dimension sizes */
H5FD_vfd_swmr_idx_entry_t *index = NULL; /* Pointer to the index entries */
H5F_vfd_swmr_config_t * my_config = NULL; /* Configuration for VFD SWMR */
+ H5F_t * f = NULL; /* Internal file object pointer */
TESTING("Verify the metadata file for VFD SWMR writer");
@@ -898,25 +1031,28 @@ test_writer_md(void)
if ((my_config = HDmalloc(sizeof(H5F_vfd_swmr_config_t))) == NULL)
FAIL_STACK_ERROR;
- /* Set up the VFD SWMR configuration + page buffering */
- fapl = init_vfd_swmr_config_fapl(my_config, 1, 3, TRUE, 256, MD_FILENAME, FS_PAGE_SIZE);
- if (fapl == H5I_INVALID_HID)
- FAIL_STACK_ERROR
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(my_config, 1, 3, TRUE, TRUE, FALSE, TRUE, 256, MD_FILENAME, NULL);
- /* Create a copy of the file creation property list */
- if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
- FAIL_STACK_ERROR
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, FS_PAGE_SIZE, my_config);
+ if (fapl == H5I_INVALID_HID)
+ TEST_ERROR
- /* Set file space strategy */
- if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0)
- FAIL_STACK_ERROR;
- if (H5Pset_file_space_page_size(fcpl, FS_PAGE_SIZE) < 0)
+ if ((fcpl = vfd_swmr_create_fcpl(H5F_FSPACE_STRATEGY_PAGE, FS_PAGE_SIZE)) < 0) {
+ HDprintf("vfd_swmr_create_fcpl() failed");
FAIL_STACK_ERROR;
+ }
/* Create an HDF5 file with VFD SWMR configured */
if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0)
FAIL_STACK_ERROR;
+ /* Get a pointer to the internal file object */
+ if (NULL == (f = (H5F_t *)H5VL_object(fid)))
+ FAIL_STACK_ERROR;
+
/* Allocate num_entries for the data buffer */
if ((buf = HDcalloc(num_entries, FS_PAGE_SIZE)) == NULL)
FAIL_STACK_ERROR;
@@ -932,6 +1068,7 @@ test_writer_md(void)
index[i].md_file_page_offset = 1 + (num_entries - i) * 5;
index[i].length = (uint32_t)FS_PAGE_SIZE;
index[i].entry_ptr = &buf[i * FS_PAGE_SIZE];
+ index[i].tick_of_last_change = f->shared->tick_num;
}
/* Update with index and verify info in the metadata file */
@@ -970,8 +1107,10 @@ test_writer_md(void)
}
/* (B) Update every other entry in the index */
- for (i = 0; i < num_entries; i += 2)
+ for (i = 0; i < num_entries; i += 2) {
index[i].entry_ptr = &buf[i * FS_PAGE_SIZE];
+ index[i].tick_of_last_change = f->shared->tick_num;
+ }
/* Update with index and verify info in the metadata file */
/* Also verify that 5 entries will be on the delayed list */
@@ -1007,8 +1146,10 @@ test_writer_md(void)
}
/* (C) Update every 3 entry in the index */
- for (i = 0; i < num_entries; i += 3)
+ for (i = 0; i < num_entries; i += 3) {
index[i].entry_ptr = &buf[i * FS_PAGE_SIZE];
+ index[i].tick_of_last_change = f->shared->tick_num;
+ }
/* Update with index and verify info in the metadata file */
/* Also verify that 4 entries will be on the delayed list */
@@ -1042,7 +1183,9 @@ test_writer_md(void)
/* (D) Update two entries in the index */
index[1].entry_ptr = &buf[1 * FS_PAGE_SIZE];
+ index[1].tick_of_last_change = f->shared->tick_num;
index[5].entry_ptr = &buf[5 * FS_PAGE_SIZE];
+ index[5].tick_of_last_change = f->shared->tick_num;
/* Update with index and verify info in the metadata file */
/* Also verify that 2 entries will be on the delayed list */
@@ -1202,21 +1345,23 @@ test_reader_md_concur(void)
if ((config_writer = HDmalloc(sizeof(*config_writer))) == NULL)
FAIL_STACK_ERROR;
- /* Set up the VFD SWMR configuration + page buffering */
- fapl_writer = init_vfd_swmr_config_fapl(config_writer, 1, 3, TRUE, 256, MD_FILENAME, FS_PAGE_SIZE);
- if (fapl_writer == H5I_INVALID_HID)
- FAIL_STACK_ERROR;
+ /*
+ * Set up the VFD SWMR configuration + page buffering
+ */
- /* Create a copy of the file creation property list */
- if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
- FAIL_STACK_ERROR
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config_writer, 1, 3, TRUE, TRUE, FALSE, TRUE, 256, MD_FILENAME, NULL);
- /* Set file space strategy */
- if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0)
- FAIL_STACK_ERROR;
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl_writer = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, FS_PAGE_SIZE, config_writer);
+ if (fapl_writer == H5I_INVALID_HID)
+ TEST_ERROR
- if (H5Pset_file_space_page_size(fcpl, FS_PAGE_SIZE) < 0)
+ if ((fcpl = vfd_swmr_create_fcpl(H5F_FSPACE_STRATEGY_PAGE, FS_PAGE_SIZE)) < 0) {
+ HDprintf("vfd_swmr_create_fcpl() failed");
FAIL_STACK_ERROR;
+ }
/* Create an HDF5 file with VFD SWMR configured */
if ((fid_writer = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl_writer)) < 0)
@@ -1276,10 +1421,19 @@ test_reader_md_concur(void)
if ((config_reader = HDmalloc(sizeof(*config_reader))) == NULL)
HDexit(EXIT_FAILURE);
- /* Set up the VFD SWMR configuration as reader + page buffering */
- fapl_reader = init_vfd_swmr_config_fapl(config_reader, 1, 3, FALSE, 256, MD_FILENAME, FS_PAGE_SIZE);
+ /*
+ * Set up the VFD SWMR configuration as reader + page buffering
+ */
+
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config_reader, 1, 3, FALSE, TRUE, FALSE, TRUE, 256, MD_FILENAME, NULL);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl_reader = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, FS_PAGE_SIZE, config_reader);
+
if (fapl_reader == H5I_INVALID_HID)
- HDexit(EXIT_FAILURE);
+ TEST_ERROR
/* Open the test file as reader */
if ((fid_reader = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl_reader)) < 0)
@@ -1479,6 +1633,9 @@ test_reader_md_concur(void)
if ((fid_writer = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl_writer)) < 0)
FAIL_STACK_ERROR;
+ /* Get the file pointer */
+ file_writer = H5VL_object(fid_writer);
+
/* Send notification 1 to reader to start verfication */
notify = 1;
if (HDwrite(parent_pfd[1], &notify, sizeof(int)) < 0)
@@ -1544,11 +1701,9 @@ test_reader_md_concur(void)
index[i].md_file_page_offset = 1 + (num_entries - i) * 5;
index[i].length = (uint32_t)FS_PAGE_SIZE;
index[i].entry_ptr = &buf[i * FS_PAGE_SIZE];
+ index[i].tick_of_last_change = file_writer->shared->tick_num;
}
- /* Get the file pointer */
- file_writer = H5VL_object(fid_writer);
-
/* Update the metadata file with the index */
if (H5F_update_vfd_swmr_metadata_file(file_writer, num_entries, index) < 0)
TEST_ERROR;
@@ -1605,8 +1760,10 @@ test_reader_md_concur(void)
/* Update 3 entries in the index */
num_entries = 3;
- for (i = 0; i < num_entries; i++)
+ for (i = 0; i < num_entries; i++) {
index[i].entry_ptr = &buf[i * FS_PAGE_SIZE];
+ index[i].tick_of_last_change = file_writer->shared->tick_num;
+ }
/* Update the metadata file with the index */
if (H5F_update_vfd_swmr_metadata_file(file_writer, num_entries, index) < 0)
@@ -1658,8 +1815,10 @@ test_reader_md_concur(void)
/* Update 5 entries in the index */
num_entries = 5;
- for (i = 0; i < num_entries; i++)
+ for (i = 0; i < num_entries; i++) {
index[i].entry_ptr = &buf[i * FS_PAGE_SIZE];
+ index[i].tick_of_last_change = file_writer->shared->tick_num;
+ }
/* Update the metadata file with the index */
if (H5F_update_vfd_swmr_metadata_file(file_writer, num_entries, index) < 0)
@@ -1816,16 +1975,10 @@ test_multiple_file_opens_concur(void)
TESTING("EOT queue entries when opening files concurrently with VFD SWMR");
- /* Create a copy of the file creation property list */
- if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
- FAIL_STACK_ERROR
-
- /* Set file space strategy */
- if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0)
- FAIL_STACK_ERROR;
-
- if (H5Pset_file_space_page_size(fcpl, FS_PAGE_SIZE) < 0)
+ if ((fcpl = vfd_swmr_create_fcpl(H5F_FSPACE_STRATEGY_PAGE, FS_PAGE_SIZE)) < 0) {
+ HDprintf("vfd_swmr_create_fcpl() failed");
FAIL_STACK_ERROR;
+ }
/* Create file A */
if ((fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0)
@@ -1886,7 +2039,14 @@ test_multiple_file_opens_concur(void)
HDexit(EXIT_FAILURE);
/* Set the VFD SWMR configuration in fapl_writer + page buffering */
- fapl_writer = init_vfd_swmr_config_fapl(config_writer, 1, 3, TRUE, 256, MD_FILENAME2, FS_PAGE_SIZE);
+
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config_writer, 1, 3, TRUE, TRUE, FALSE, TRUE, 256, MD_FILENAME2, NULL);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl_writer = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, FS_PAGE_SIZE, config_writer);
+
if (fapl_writer == H5I_INVALID_HID)
HDexit(EXIT_FAILURE);
@@ -1948,8 +2108,13 @@ test_multiple_file_opens_concur(void)
if ((config1 = HDmalloc(sizeof(*config1))) == NULL)
FAIL_STACK_ERROR
- /* Set the VFD SWMR configuration in fapl1 + page buffering */
- fapl1 = init_vfd_swmr_config_fapl(config1, 7, 10, TRUE, 256, MD_FILENAME, FS_PAGE_SIZE);
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config1, 7, 10, TRUE, TRUE, FALSE, TRUE, 256, MD_FILENAME, NULL);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl1 = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, FS_PAGE_SIZE, config1);
+
if (fapl1 == H5I_INVALID_HID)
FAIL_STACK_ERROR
@@ -1986,8 +2151,13 @@ test_multiple_file_opens_concur(void)
if ((config2 = HDmalloc(sizeof(*config2))) == NULL)
FAIL_STACK_ERROR
- /* Set the VFD SWMR configuration in fapl2 + page buffering */
- fapl2 = init_vfd_swmr_config_fapl(config2, 1, 3, FALSE, 256, MD_FILENAME2, FS_PAGE_SIZE);
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config2, 1, 3, FALSE, TRUE, FALSE, TRUE, 256, MD_FILENAME2, NULL);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl2 = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, FS_PAGE_SIZE, config2);
+
if (fapl2 == H5I_INVALID_HID)
FAIL_STACK_ERROR
@@ -2120,21 +2290,24 @@ test_disable_enable_eot_concur(void)
if ((config_writer = HDmalloc(sizeof(*config_writer))) == NULL)
FAIL_STACK_ERROR;
- /* Set up the VFD SWMR configuration + page buffering */
- fapl_writer = init_vfd_swmr_config_fapl(config_writer, 1, 3, TRUE, 256, MD_FILENAME, FS_PAGE_SIZE);
- if (fapl_writer == H5I_INVALID_HID)
- FAIL_STACK_ERROR;
+ /*
+ * Set up the VFD SWMR configuration + page buffering
+ */
- /* Create a copy of the file creation property list */
- if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
- FAIL_STACK_ERROR
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config_writer, 1, 3, TRUE, TRUE, FALSE, TRUE, 256, MD_FILENAME, NULL);
- /* Set file space strategy */
- if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0)
- FAIL_STACK_ERROR;
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl_writer = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, FS_PAGE_SIZE, config_writer);
- if (H5Pset_file_space_page_size(fcpl, FS_PAGE_SIZE) < 0)
- FAIL_STACK_ERROR;
+ if (fapl_writer == H5I_INVALID_HID)
+ FAIL_STACK_ERROR
+
+ if ((fcpl = vfd_swmr_create_fcpl(H5F_FSPACE_STRATEGY_PAGE, FS_PAGE_SIZE)) < 0) {
+ HDprintf("vfd_swmr_create_fcpl() failed");
+ FAIL_STACK_ERROR
+ }
/* Create an HDF5 file with VFD SWMR configured */
if ((fid_writer = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl_writer)) < 0)
@@ -2197,10 +2370,19 @@ test_disable_enable_eot_concur(void)
if ((config_reader = HDmalloc(sizeof(*config_reader))) == NULL)
HDexit(EXIT_FAILURE);
- /* Set up the VFD SWMR configuration as reader + page buffering */
- fapl_reader = init_vfd_swmr_config_fapl(config_reader, 1, 3, FALSE, 256, MD_FILENAME, FS_PAGE_SIZE);
+ /*
+ * Set up the VFD SWMR configuration as reader + page buffering
+ */
+
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config_reader, 1, 3, FALSE, TRUE, FALSE, TRUE, 256, MD_FILENAME, NULL);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl_reader = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, FS_PAGE_SIZE, config_reader);
+
if (fapl_reader == H5I_INVALID_HID)
- FAIL_STACK_ERROR;
+ FAIL_STACK_ERROR
/* Open the test file as reader */
if ((fid_reader = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl_reader)) < 0)
@@ -2400,21 +2582,24 @@ test_file_end_tick_concur(void)
if ((config_writer = HDmalloc(sizeof(*config_writer))) == NULL)
FAIL_STACK_ERROR;
- /* Set up the VFD SWMR configuration + page buffering */
- fapl_writer = init_vfd_swmr_config_fapl(config_writer, 1, 3, TRUE, 256, MD_FILENAME, FS_PAGE_SIZE);
- if (fapl_writer == H5I_INVALID_HID)
- FAIL_STACK_ERROR;
+ /*
+ * Set up the VFD SWMR configuration + page buffering
+ */
- /* Create a copy of the file creation property list */
- if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
- FAIL_STACK_ERROR
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config_writer, 1, 3, TRUE, TRUE, FALSE, TRUE, 256, MD_FILENAME, NULL);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl_writer = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, FS_PAGE_SIZE, config_writer);
- /* Set file space strategy */
- if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0)
+ if (fapl_writer == H5I_INVALID_HID)
FAIL_STACK_ERROR;
- if (H5Pset_file_space_page_size(fcpl, FS_PAGE_SIZE) < 0)
+ if ((fcpl = vfd_swmr_create_fcpl(H5F_FSPACE_STRATEGY_PAGE, FS_PAGE_SIZE)) < 0) {
+ HDprintf("vfd_swmr_create_fcpl() failed");
FAIL_STACK_ERROR;
+ }
/* Create an HDF5 file with VFD SWMR configured */
if ((fid_writer = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl_writer)) < 0)
@@ -2477,10 +2662,15 @@ test_file_end_tick_concur(void)
if ((config_reader = HDmalloc(sizeof(*config_reader))) == NULL)
HDexit(EXIT_FAILURE);
- /* Set up the VFD SWMR configuration as reader + page buffering */
- fapl_reader = init_vfd_swmr_config_fapl(config_reader, 1, 3, FALSE, 256, MD_FILENAME, FS_PAGE_SIZE);
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config_reader, 1, 3, FALSE, TRUE, FALSE, TRUE, 256, MD_FILENAME, NULL);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl_reader = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, FS_PAGE_SIZE, config_reader);
+
if (fapl_reader == H5I_INVALID_HID)
- FAIL_STACK_ERROR;
+ FAIL_STACK_ERROR
/* Open the test file as reader */
if ((fid_reader1 = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl_reader)) < 0)
@@ -2667,23 +2857,33 @@ test_multiple_file_opens(void)
if ((config2 = HDmalloc(sizeof(*config2))) == NULL)
FAIL_STACK_ERROR;
- /* Configured as VFD SWMR writer + page buffering */
- fapl1 = init_vfd_swmr_config_fapl(config1, 4, 6, TRUE, 2, MD_FILENAME, 4096);
+ /*
+ * Configured as VFD SWMR writer + page buffering
+ */
+
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config1, 4, 6, TRUE, TRUE, FALSE, TRUE, 2, MD_FILENAME, NULL);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl1 = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, 4096, config1);
if (fapl1 == H5I_INVALID_HID)
FAIL_STACK_ERROR;
- /* Configured as VFD SWMR writer + page buffering */
- fapl2 = init_vfd_swmr_config_fapl(config2, 4, 6, TRUE, 2, MD_FILENAME2, 4096);
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config2, 4, 6, TRUE, TRUE, FALSE, TRUE, 2, MD_FILENAME2, NULL);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl2 = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, 4096, config2);
+
if (fapl2 == H5I_INVALID_HID)
FAIL_STACK_ERROR;
- /* Create a copy of the file creation property list */
- if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
- FAIL_STACK_ERROR
-
- /* Set file space strategy */
- if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0)
+ if ((fcpl = vfd_swmr_create_fcpl(H5F_FSPACE_STRATEGY_PAGE, 4096)) < 0) {
+ HDprintf("vfd_swmr_create_fcpl() failed");
FAIL_STACK_ERROR;
+ }
/* Create a file without VFD SWMR */
if ((fid = H5Fcreate(FNAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
@@ -2854,13 +3054,10 @@ test_same_file_opens(void)
if ((config2 = HDmalloc(sizeof(*config2))) == NULL)
FAIL_STACK_ERROR;
- /* Create a copy of the file creation property list */
- if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
+ if ((fcpl = vfd_swmr_create_fcpl(H5F_FSPACE_STRATEGY_PAGE, 4096)) < 0) {
+ HDprintf("vfd_swmr_create_fcpl() failed");
FAIL_STACK_ERROR
-
- /* Set file space strategy */
- if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0)
- FAIL_STACK_ERROR;
+ }
/*
* Tests for first column
@@ -2874,8 +3071,17 @@ test_same_file_opens(void)
if (H5Fclose(fid) < 0)
FAIL_STACK_ERROR;
- /* Set the VFD SWMR configuration in fapl1 + page buffering */
- fapl1 = init_vfd_swmr_config_fapl(config1, 4, 10, TRUE, 2, MD_FILENAME, 4096);
+ /*
+ * Set the VFD SWMR configuration in fapl1 + page buffering
+ */
+
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config1, 4, 10, TRUE, TRUE, FALSE, TRUE, 2, MD_FILENAME, NULL);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl1 = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, 4096, config1);
+
if (fapl1 == H5I_INVALID_HID)
FAIL_STACK_ERROR;
@@ -2893,8 +3099,17 @@ test_same_file_opens(void)
if (H5Fclose(fid2) < 0)
FAIL_STACK_ERROR;
- /* Set the VFD SWMR configuration in fapl2 + page buffering */
- fapl2 = init_vfd_swmr_config_fapl(config2, 3, 8, FALSE, 3, MD_FILENAME, 4096);
+ /*
+ * Set the VFD SWMR configuration in fapl2 + page buffering
+ */
+
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config2, 3, 8, FALSE, TRUE, FALSE, TRUE, 3, MD_FILENAME, NULL);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl2 = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, 4096, config2);
+
if (fapl2 == H5I_INVALID_HID)
FAIL_STACK_ERROR;
@@ -2939,8 +3154,18 @@ test_same_file_opens(void)
* Tests for second column
*/
- /* Set up as VFD SWMR reader + page buffering */
- fapl1 = init_vfd_swmr_config_fapl(config1, 4, 10, FALSE, 2, MD_FILENAME, 4096);
+
+ /*
+ * Set up as VFD SWMR reader + page buffering
+ */
+
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config1, 4, 10, FALSE, TRUE, FALSE, TRUE, 2, MD_FILENAME, NULL);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl1 = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, 4096, config1);
+
if (fapl1 == H5I_INVALID_HID)
FAIL_STACK_ERROR;
@@ -2967,8 +3192,17 @@ test_same_file_opens(void)
if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
TEST_ERROR;
- /* Set up as VFD SWMR writer + page buffering */
- fapl1 = init_vfd_swmr_config_fapl(config1, 4, 10, TRUE, 2, MD_FILENAME, 4096);
+ /*
+ * Set up as VFD SWMR writer + page buffering
+ */
+
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config1, 4, 10, TRUE, TRUE, FALSE, TRUE, 2, MD_FILENAME, NULL);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl1 = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, 4096, config1);
+
if (fapl1 == H5I_INVALID_HID)
FAIL_STACK_ERROR;
@@ -3014,8 +3248,17 @@ test_same_file_opens(void)
if ((fid = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
TEST_ERROR;
- /* Set up as VFD SWMR writer + page buffering */
- fapl1 = init_vfd_swmr_config_fapl(config1, 4, 10, TRUE, 2, MD_FILENAME, 4096);
+ /*
+ * Set up as VFD SWMR writer + page buffering
+ */
+
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config1, 4, 10, TRUE, TRUE, FALSE, TRUE, 2, MD_FILENAME, NULL);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl1 = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, 4096, config1);
+
if (fapl1 == H5I_INVALID_HID)
FAIL_STACK_ERROR;
@@ -3216,28 +3459,52 @@ test_enable_disable_eot(void)
if ((config3 = HDmalloc(sizeof(*config3))) == NULL)
FAIL_STACK_ERROR;
- /* Configured first file as VFD SWMR writer + page buffering */
- fapl1 = init_vfd_swmr_config_fapl(config1, 4, 6, TRUE, 2, MD_FILENAME, 4096);
+ /*
+ * Configured first file as VFD SWMR writer + page buffering
+ */
+
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config1, 4, 6, TRUE, TRUE, FALSE, TRUE, 2, MD_FILENAME, NULL);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl1 = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, 4096, config1);
+
if (fapl1 == H5I_INVALID_HID)
FAIL_STACK_ERROR;
- /* Configured second file as VFD SWMR writer + page buffering */
- fapl2 = init_vfd_swmr_config_fapl(config2, 4, 6, TRUE, 2, MD_FILENAME2, 4096);
+ /*
+ * Configured second file as VFD SWMR writer + page buffering
+ */
+
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config2, 4, 6, TRUE, TRUE, FALSE, TRUE, 2, MD_FILENAME2, NULL);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl2 = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, 4096, config2);
+
if (fapl2 == H5I_INVALID_HID)
FAIL_STACK_ERROR;
- /* Configured third file as VFD SWMR writer + page buffering */
- fapl3 = init_vfd_swmr_config_fapl(config3, 4, 6, TRUE, 2, MD_FILENAME3, 4096);
+ /*
+ * Configured third file as VFD SWMR writer + page buffering
+ */
+
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config3, 4, 6, TRUE, TRUE, FALSE, TRUE, 2, MD_FILENAME3, NULL);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl3 = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, 4096, config3);
+
if (fapl3 == H5I_INVALID_HID)
FAIL_STACK_ERROR;
- /* Create a copy of the file creation property list */
- if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
+ if ((fcpl = vfd_swmr_create_fcpl(H5F_FSPACE_STRATEGY_PAGE, 4096)) < 0) {
+ HDprintf("vfd_swmr_create_fcpl() failed");
FAIL_STACK_ERROR
-
- /* Set file space strategy */
- if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, FALSE, 1) < 0)
- FAIL_STACK_ERROR;
+ }
/* Create a file without VFD SWMR */
if ((fid = H5Fcreate(FNAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
@@ -3425,6 +3692,703 @@ error:
} /* test_enable_disable_eot() */
/*-------------------------------------------------------------------------
+ * Function: verify_updater_flags()
+ *
+ * Purpose: This is the helper routine used to verify whether
+ * "flags" in the updater file is as expected.
+ *
+ * Return: 0 if test is sucessful
+ * 1 if test fails
+ *
+ * Programmer: Vailin Choi; October 2021
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+verify_updater_flags(char *ud_name, uint16_t expected_flags)
+{
+ FILE* ud_fp; /* Updater file pointer */
+ uint16_t flags;
+ size_t ret; /* Return value */
+
+
+ /* Open the updater file */
+ if((ud_fp = HDfopen(ud_name, "r")) == NULL)
+ FAIL_STACK_ERROR;
+
+ /* Seek to the position of "flags" in the updater file's header */
+ if(HDfseek(ud_fp, (HDoff_t)UD_HD_FLAGS_OFFSET, SEEK_SET) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Read "flags" from the updater file */
+ if((ret = HDfread(&flags, UD_SIZE_2, 1, ud_fp)) != (size_t)1)
+ FAIL_STACK_ERROR;
+
+ if (flags != expected_flags)
+ TEST_ERROR;
+
+ if (HDfclose(ud_fp) < 0)
+ FAIL_STACK_ERROR;
+
+ return 0;
+
+error:
+ return 1;
+
+} /* verify_updater_flags() */
+
+/*-------------------------------------------------------------------------
+ * Function: test_updater_flags
+ *
+ * Purpose: Verify "flags" in the updater file is as expected for
+ * file creation.
+ *
+ * Return: 0 if test is sucessful
+ * 1 if test fails
+ *
+ * Programmer: Vailin Choi; October 2021
+ *
+ *-------------------------------------------------------------------------
+ */
+static unsigned
+test_updater_flags(void)
+{
+ hid_t fid = -1; /* File ID */
+ hid_t fcpl = -1; /* File creation property list ID */
+ hid_t fapl = -1; /* File access property list ID */
+ hid_t file_fapl = -1; /* File access property list ID associated with the file */
+ H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */
+ H5F_vfd_swmr_config_t *file_config = NULL; /* Configuration for VFD SWMR */
+ uint64_t seq_num = 0; /* Sequence number for updater file */
+ uint64_t i = 0; /* Local index variable */
+ char namebuf[H5F__MAX_VFD_SWMR_FILE_NAME_LEN]; /* Updater file path */
+ h5_stat_t sb; /* Info returned by stat system call */
+
+ TESTING("VFD SWMR updater file flags");
+
+ /* Should succeed without VFD SWMR configured */
+ if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* Close the file */
+ if (H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Allocate memory for the configuration structure */
+ if ((config = (H5F_vfd_swmr_config_t *)HDmalloc(sizeof(H5F_vfd_swmr_config_t))) == NULL)
+ FAIL_STACK_ERROR;
+ if ((file_config = (H5F_vfd_swmr_config_t *)HDmalloc(sizeof(H5F_vfd_swmr_config_t))) == NULL)
+ FAIL_STACK_ERROR;
+
+ /*
+ * Configured as VFD SWMR writer + page buffering + generate updater files
+ */
+
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config, 4, 7, TRUE, TRUE, TRUE, TRUE, 2, MD_FILENAME, UD_FILENAME);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, 4096, config);
+
+ if (fapl == H5I_INVALID_HID)
+ TEST_ERROR
+
+ if ((fcpl = vfd_swmr_create_fcpl(H5F_FSPACE_STRATEGY_PAGE, 4096)) < 0) {
+ HDprintf("vfd_swmr_create_fcpl() failed");
+ FAIL_STACK_ERROR
+ }
+
+ if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0)
+ TEST_ERROR;
+
+ /* Get the file's file access property list */
+ if ((file_fapl = H5Fget_access_plist(fid)) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Retrieve the VFD SWMR configuration from file_fapl */
+ if (H5Pget_vfd_swmr_config(file_fapl, file_config) < 0)
+ TEST_ERROR;
+
+ /* Verify the retrieved info is the same as config1 */
+ if (HDmemcmp(config, file_config, sizeof(H5F_vfd_swmr_config_t)) != 0)
+ TEST_ERROR;
+
+ /* Verify the first updater file: "flags" field and file size */
+ HDsprintf(namebuf, "%s.%lu", UD_FILENAME, seq_num);
+
+ /* Verify "flags" of the first updater file */
+ if(verify_updater_flags(namebuf, CREATE_METADATA_FILE_ONLY_FLAG) < 0)
+ TEST_ERROR;
+
+ /* Check updater file size */
+ if (HDstat(namebuf, &sb) == 0 && sb.st_size != H5F_UD_HEADER_SIZE)
+ TEST_ERROR;
+
+ /* Closing */
+ if (H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Look for the last updater file */
+ for (seq_num = 0; ; seq_num++) {
+ HDsprintf(namebuf, "%s.%lu", UD_FILENAME, seq_num);
+ if (HDaccess(namebuf, F_OK) != 0)
+ break;
+ }
+ HDsprintf(namebuf, "%s.%lu", UD_FILENAME, seq_num-1);
+
+ /* Verify "flags" of the last updater file */
+ if(verify_updater_flags(namebuf, FINAL_UPDATE_FLAG) < 0)
+ TEST_ERROR;
+
+ if (H5Pclose(file_fapl) < 0)
+ FAIL_STACK_ERROR;
+ if (H5Pclose(fapl) < 0)
+ FAIL_STACK_ERROR;
+ if (H5Pclose(fcpl) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Remove updater files */
+ for (i = 0; i < seq_num; i++) {
+ HDsprintf(namebuf, "%s.%lu", UD_FILENAME, i);
+ HDremove(namebuf);
+ }
+
+ /* Free buffers */
+ if (config)
+ HDfree(config);
+ if (file_config)
+ HDfree(file_config);
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY
+ {
+ H5Pclose(fapl);
+ H5Pclose(file_fapl);
+ H5Pclose(fcpl);
+ H5Fclose(fid);
+ }
+ H5E_END_TRY;
+ if (config)
+ HDfree(config);
+ if (file_config)
+ HDfree(file_config);
+
+ return 1;
+} /* test_updater_flags() */
+
+/*-------------------------------------------------------------------------
+ * Function: test_updater_flags_same_file_opens()
+ *
+ * Purpose: Verify "flags" in the updater file is as expected for
+ * multiple opens of the same file.
+ *
+ * Return: 0 if test is sucessful
+ * 1 if test fails
+ *
+ * Programmer: Vailin Choi; October 2021
+ *
+ *-------------------------------------------------------------------------
+ */
+static unsigned
+test_updater_flags_same_file_opens(void)
+{
+ hid_t fid = -1; /* File ID */
+ hid_t fid2 = -1; /* File ID */
+ hid_t fcpl = -1; /* File creation property list ID */
+ hid_t fapl1 = -1; /* File access property list ID */
+ H5F_vfd_swmr_config_t *config1 = NULL; /* Configuration for VFD SWMR */
+ uint64_t seq_num = 0; /* Sequence number for updater file */
+ uint64_t i = 0; /* Local index variable */
+ char namebuf[H5F__MAX_VFD_SWMR_FILE_NAME_LEN]; /* Updater file path */
+
+ TESTING("VFD SWMR updater file flags for multiple opens of the same file");
+
+ /* Should succeed without VFD SWMR configured */
+ if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* Close the file */
+ if (H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Allocate memory for the configuration structure */
+ if ((config1 = HDmalloc(sizeof(*config1))) == NULL)
+ FAIL_STACK_ERROR;
+
+ if ((fcpl = vfd_swmr_create_fcpl(H5F_FSPACE_STRATEGY_PAGE, 4096)) < 0) {
+ HDprintf("vfd_swmr_create_fcpl() failed");
+ FAIL_STACK_ERROR
+ }
+
+ /* Create the test file */
+ if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* Close the file */
+ if (H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR;
+
+ /*
+ * Set the VFD SWMR configuration in fapl1 + page buffering
+ */
+
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(config1, 4, 10, TRUE, TRUE, TRUE, TRUE, 2, MD_FILENAME, UD_FILENAME);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl1 = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, 4096, config1);
+
+ if (fapl1 == H5I_INVALID_HID)
+ FAIL_STACK_ERROR;
+
+ /* Open the file as VFD SWMR writer */
+ /* Keep the file open */
+ if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl1)) < 0)
+ TEST_ERROR;
+
+ /* Open the same file again as VFD SWMR writer */
+ /* Should succeed: 1st open--VFD SWMR writer, 2nd open--VFD SWMR writer */
+ if ((fid2 = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl1)) < 0)
+ TEST_ERROR;
+
+ /* Close the second file open */
+ if (H5Fclose(fid2) < 0)
+ FAIL_STACK_ERROR;
+
+
+ /* Verify the first updater file for first file open */
+ HDsprintf(namebuf, "%s.%lu", UD_FILENAME, seq_num);
+
+ /* Verify "flags" of the first updater file is 0*/
+ if(verify_updater_flags(namebuf, 0) < 0)
+ TEST_ERROR;
+
+ /* Look for the last updater file */
+ for (seq_num = 0; ; seq_num++) {
+ HDsprintf(namebuf, "%s.%lu", UD_FILENAME, seq_num);
+ if (HDaccess(namebuf, F_OK) != 0)
+ break;
+ }
+ HDsprintf(namebuf, "%s.%lu", UD_FILENAME, seq_num-1);
+
+ /* Verify "flags" of the last updater file is 0 */
+ if(verify_updater_flags(namebuf, 0) < 0)
+ TEST_ERROR;
+
+ /* Close the 1st open file */
+ if (H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Look for the last updater file */
+ for (seq_num = 0; ; seq_num++) {
+ HDsprintf(namebuf, "%s.%lu", UD_FILENAME, seq_num);
+ if (HDaccess(namebuf, F_OK) != 0)
+ break;
+ }
+ HDsprintf(namebuf, "%s.%lu", UD_FILENAME, seq_num-1);
+
+ /* Verify "flags" of the last updater file after closing file */
+ if(verify_updater_flags(namebuf, FINAL_UPDATE_FLAG) < 0)
+ TEST_ERROR;
+
+ /* Clean up updater files */
+ for (i = 0; i < seq_num; i++) {
+ HDsprintf(namebuf, "%s.%lu", UD_FILENAME, i);
+ HDremove(namebuf);
+ }
+
+ if (H5Pclose(fcpl) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Free buffers */
+ if (config1)
+ HDfree(config1);
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY
+ {
+ H5Pclose(fapl1);
+ H5Pclose(fcpl);
+ H5Fclose(fid);
+ H5Fclose(fid2);
+ }
+ H5E_END_TRY;
+ if (config1)
+ HDfree(config1);
+ return 1;
+} /* test_updater_flags_same_file_opens() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: clean_chk_ud_files()
+ *
+ * Purpose: This is the helper routine used to clean up
+ * the checksum file and the updater files.
+ *
+ * Return: void
+ *
+ * Programmer: Vailin Choi; October 2021
+ *
+ *-------------------------------------------------------------------------
+ */
+static void
+clean_chk_ud_files(char *md_file_path, char *updater_file_path)
+{
+ char chk_name[1024 + 4];
+ char ud_name[1024 + 4];
+ uint64_t i;
+
+ /* Name of the checksum file: <md_file_path>.chk */
+ HDsprintf(chk_name, "%s.chk", md_file_path);
+
+ /* Remove the checksum file if exists.
+ If not, the callback will just continue appending
+ checksums to the existing file */
+ if(HDaccess(chk_name, F_OK) == 0) {
+ HDremove(chk_name);
+ }
+
+ /* Remove all the updater files if exist: <updater_file_path>.<i> */
+ for(i = 0; ; i++) {
+ sprintf(ud_name, "%s.%lu", updater_file_path, i);
+ if(HDaccess(ud_name, F_OK) != 0)
+ break;
+ HDremove(ud_name);
+ }
+
+} /* clean_chk_ud_files() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: verify_ud_chk()
+ *
+ * Purpose: This is the helper routine used by
+ * test_updater_generate_md_checksums() to verify
+ * contents of the checksum file and the updater files.
+ * --verify the sequence number in each updater's file header
+ * corresponds to the ith sequence number of the updater
+ * file name.
+ * --verify the tick number in each updater's file header
+ * corresponds to the tick number stored in the checksum file
+ * --verify the change_list_len in each updater's file header
+ * is consistent with num_change_list_entries in each updater's
+ * change list header
+ *
+ * Return: 0 if test is sucessful
+ * 1 if test fails
+ *
+ * Programmer: Vailin Choi; October 2021
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+verify_ud_chk(char *md_file_path, char *ud_file_path)
+{
+ char chk_name[1024 + 4]; /* Checksum file name */
+ char ud_name[1024 + 4]; /* Updater file name */
+ FILE* chk_fp; /* Checksum file pointer */
+ FILE* ud_fp; /* Updater file pointer */
+ uint64_t ud_seq_num; /* Sequence number in the updater file */
+ uint64_t chk_ud_seq_num; /* Updater sequence number in the checksum file */
+ uint64_t i; /* Local index variable */
+ long size = 0; /* Size of the file */
+ size_t change_list_len; /* change_list_len in the updater file header */
+ uint32_t num_change_list_entries; /* num_change_list_entries in the updater change list header */
+
+ /* Open the checksum file */
+ HDsprintf(chk_name, "%s.chk", md_file_path);
+ if((chk_fp = HDfopen(chk_name, "r")) == NULL)
+ FAIL_STACK_ERROR;
+
+ for(i = 0; ; i++) {
+ /* Generate updater file name: <ud_file_path>.<i> */
+ HDsprintf(ud_name, "%s.%lu", ud_file_path, i);
+
+ /* Open the updater file */
+ if ((ud_fp = HDfopen(ud_name, "r")) == NULL)
+ break;
+ else {
+ /* Seek to the position of the sequence number in the updater file's header */
+ if(HDfseek(ud_fp, (off_t)UD_HD_SEQ_NUM_OFFSET, SEEK_SET) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Read the sequence number from the updater file */
+ if(HDfread(&ud_seq_num, UD_SIZE_8, 1, ud_fp) != 1)
+ FAIL_STACK_ERROR;
+
+ /* Compare the sequence number with i */
+ if(ud_seq_num != i)
+ TEST_ERROR;
+
+ /* Read change_list_len from updater file's header */
+ if(HDfseek(ud_fp, (off_t)UD_HD_CHANGE_LIST_LEN_OFFSET, SEEK_SET) < 0)
+ FAIL_STACK_ERROR;
+
+ if(HDfread(&change_list_len, UD_SIZE_8, 1, ud_fp) != 1)
+ FAIL_STACK_ERROR;
+
+ if(i != 0) {
+
+ /* Read num_change_list_entries from updater file's change list */
+ if(HDfseek(ud_fp, (off_t)UD_CL_NUM_CHANGE_LIST_ENTRIES_OFFSET, SEEK_SET) < 0)
+ FAIL_STACK_ERROR;
+
+ if(HDfread(&num_change_list_entries, UD_SIZE_4, 1, ud_fp) != 1)
+ FAIL_STACK_ERROR;
+
+ if(num_change_list_entries == 0) {
+ if(change_list_len != H5F_UD_CL_SIZE(0))
+ TEST_ERROR;
+ } else {
+ if (change_list_len != H5F_UD_CL_SIZE(num_change_list_entries))
+ TEST_ERROR
+ }
+ }
+
+ /* Close the updater file */
+ if(HDfclose(ud_fp) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Read the updater sequence number from checksum file */
+ if(HDfread(&chk_ud_seq_num, UD_SIZE_8, 1, chk_fp) != 1)
+ FAIL_STACK_ERROR;
+
+ /* Compare sequence number in updater file with sequence number in checksum file */
+ if (ud_seq_num != chk_ud_seq_num)
+ TEST_ERROR;
+
+ /* Advance checksum file to the next sequence number */
+ if(HDfseek(chk_fp, (off_t)UD_SIZE_4, SEEK_CUR) < 0)
+ FAIL_STACK_ERROR;
+ }
+ }
+
+ /* Get the size of the chksum file */
+ if ((size = HDftell(chk_fp)) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Size of sequence number and checksum in the checksum file */
+ if((unsigned)size != (i * (UD_SIZE_8 + UD_SIZE_4)))
+ TEST_ERROR;
+
+ return 0;
+
+error:
+ return (-1);
+
+} /* verify_ud_chk() */
+
+/*-------------------------------------------------------------------------
+ * Function: md_ck_cb()
+ *
+ * Purpose: This is the callback function used by
+ * test_updater_generate_md_checksums() when the
+ * H5F_ACS_GENERATE_MD_CK_CB_NAME property is set in fapl.
+ * --Opens and read the metadata file into a buffer.
+ * --Generate checksum for the metadata file
+ * --Write the tick number and the checksum to the checksum file
+ *
+ * Return: 0 if test is sucessful
+ * 1 if test fails
+ *
+ * Programmer: Vailin Choi; October 2021
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+md_ck_cb(char *md_file_path, uint64_t updater_seq_num)
+{
+ FILE* md_fp = NULL; /* Metadata file pointer */
+ FILE* chk_fp = NULL; /* Checksum file pointer */
+ long size = 0; /* File size returned from HDftell() */
+ void *buf = NULL; /* Buffer for holding the metadata file content */
+ uint32_t chksum = 0; /* The checksum generated for the metadata file */
+ char chk_name[1024 + 4]; /* Buffer for the checksum file name */
+ size_t ret; /* Return value */
+
+ /* Open the metadata file */
+ if((md_fp = HDfopen(md_file_path, "r")) == NULL)
+ FAIL_STACK_ERROR;
+
+ /* Set file pointer at end of file.*/
+ if(HDfseek(md_fp, 0, SEEK_END) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Get the current position of the file pointer.*/
+ if ((size = HDftell(md_fp)) < 0)
+ FAIL_STACK_ERROR;
+
+ if(size != 0) {
+
+ HDrewind(md_fp);
+
+ if((buf = HDmalloc((size_t)size)) == NULL)
+ FAIL_STACK_ERROR;
+
+ /* Read the metadata file to buf */
+ if ((ret = HDfread(buf, 1, (size_t)size, md_fp)) != (size_t)size)
+ FAIL_STACK_ERROR;
+
+ /* Calculate checksum of the metadata file */
+ chksum = H5_checksum_metadata(buf, (size_t)size, 0);
+ }
+
+ /* Close the metadata file */
+ if(md_fp && HDfclose(md_fp) < 0)
+ FAIL_STACK_ERROR;
+
+ /*
+ * Checksum file
+ */
+
+ /* Generate checksum file name: <md_file_path>.chk */
+ HDsprintf(chk_name, "%s.chk", md_file_path);
+
+ /* Open checksum file for append */
+ if((chk_fp = HDfopen(chk_name, "a")) == NULL)
+ FAIL_STACK_ERROR;
+
+ /* Write the updater sequence number to the checksum file */
+ if((ret = HDfwrite(&updater_seq_num, sizeof(uint64_t), 1, chk_fp)) != 1)
+ FAIL_STACK_ERROR;
+
+ /* Write the checksum to the checksum file */
+ if((ret = HDfwrite(&chksum, sizeof(uint32_t), 1, chk_fp)) != 1)
+ FAIL_STACK_ERROR;
+
+ /* Close the checksum file */
+ if(chk_fp && HDfclose(chk_fp) != 0)
+ FAIL_STACK_ERROR;
+
+ if(buf)
+ HDfree(buf);
+
+ return 0;
+
+error:
+ if(buf)
+ HDfree(buf);
+ if(md_fp)
+ HDfclose(md_fp);
+ if(chk_fp)
+ HDfclose(chk_fp);
+
+ return -1;
+} /* md_ck_cb() */
+
+/*-------------------------------------------------------------------------
+ * Function: test_updater_generate_md_checksums()
+ *
+ * Purpose: It enables the generation of checksums for the metadata file
+ * created by the writer end of tick function.
+ * It also verifies the contents of the checksum file and the
+ * updater files.
+ *
+ * The test is invoked when the file is created via H5Fcreate()
+ * and via H5Fopen().
+ *
+ * Return: 0 if test is sucessful
+ * 1 if test fails
+ *
+ * Programmer: Vailin Choi; October 2021
+ *
+ * Note: It is important to clean up the checksum file and the updater files.
+ *
+ *-------------------------------------------------------------------------
+ */
+static unsigned
+test_updater_generate_md_checksums(hbool_t file_create)
+{
+ hid_t fid = -1; /* File ID */
+ hid_t fcpl = -1; /* File creation property list ID */
+ hid_t fapl = -1; /* File access property list ID */
+ H5F_vfd_swmr_config_t config; /* Configuration for VFD SWMR */
+ H5F_generate_md_ck_cb_t cb_info; /* Callback */
+
+ if(file_create) {
+ TESTING("VFD SWMR updater generate checksums for metadata file with H5Fcreate");
+ } else {
+ TESTING("VFD SWMR updater generate checksums for metadata file with H5Fopen");
+ }
+
+ /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files,
+ * flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */
+ init_vfd_swmr_config(&config, 4, 7, TRUE, TRUE, TRUE, TRUE, 2, MD_FILE, UD_FILE);
+
+ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */
+ fapl = vfd_swmr_create_fapl(TRUE, TRUE, FALSE, 4096, &config);
+
+ if (fapl == H5I_INVALID_HID)
+ TEST_ERROR
+
+ if ((fcpl = vfd_swmr_create_fcpl(H5F_FSPACE_STRATEGY_PAGE, 4096)) < 0) {
+ HDprintf("vfd_swmr_create_fcpl() failed");
+ FAIL_STACK_ERROR
+ }
+
+ /* Set up callback to generate checksums for updater's metadata files */
+ cb_info.func = md_ck_cb;
+
+ /* Activate private property to generate checksums for updater's metadata file */
+ H5Pset(fapl, H5F_ACS_GENERATE_MD_CK_CB_NAME, &cb_info);
+
+ /* Use file creation or file open for testing */
+ if(file_create) {
+ if((fid = H5Fcreate(FILENAME4, H5F_ACC_TRUNC, fcpl, fapl)) < 0)
+ TEST_ERROR;
+ } else {
+ fid = H5Fcreate(FILENAME4, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT);
+ H5Fclose(fid);
+
+ fid = H5Fopen(FILENAME4, H5F_ACC_RDWR, fapl);
+ }
+
+ /* Close the file */
+ if (H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR;
+
+ if (H5Pclose(fapl) < 0)
+ FAIL_STACK_ERROR;
+ if (H5Pclose(fcpl) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Verify contents of checksum file and updater files */
+ if(verify_ud_chk(config.md_file_path, config.updater_file_path) < 0)
+ TEST_ERROR;
+
+ /* It's important to clean up the chechsum and updater files. */
+ clean_chk_ud_files(config.md_file_path, config.updater_file_path);
+
+ PASSED();
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY
+ {
+ H5Pclose(fapl);
+ H5Pclose(fcpl);
+ H5Fclose(fid);
+ }
+ H5E_END_TRY;
+
+ /* It's important to clean up the chechsum and updater files. */
+ clean_chk_ud_files(config.md_file_path, config.updater_file_path);
+
+ return 1;
+
+} /* test_updater_generate_md_checksums() */
+
+
+/*-------------------------------------------------------------------------
* Function: main()
*
* Purpose: Main function for VFD SWMR tests.
@@ -3481,9 +4445,15 @@ main(void)
PUTS_ERROR("Can't get VFD-dependent fapl")
}
+ /* Add nfs/updater testing in this routine */
nerrors += test_fapl();
if (use_file_locking) {
+ nerrors += test_updater_flags();
+ nerrors += test_updater_flags_same_file_opens();
+ nerrors += test_updater_generate_md_checksums(TRUE);
+ nerrors += test_updater_generate_md_checksums(FALSE);
+
nerrors += test_shadow_index_lookup();
nerrors += test_file_fapl();