diff options
author | vchoi-hdfgroup <55293060+vchoi-hdfgroup@users.noreply.github.com> | 2022-05-13 17:20:39 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-13 17:20:39 (GMT) |
commit | 469e8da61e393a380d5af55da6ad2c8ff834dd67 (patch) | |
tree | 7e323366351b281e465d002e1407ad53993c6a84 | |
parent | 2f86cba3ec7b9f46b84e8cd239a1fee242c15049 (diff) | |
parent | b2e1a59c73a0b5272047ed4a803e04d92f86015c (diff) | |
download | hdf5-469e8da61e393a380d5af55da6ad2c8ff834dd67.zip hdf5-469e8da61e393a380d5af55da6ad2c8ff834dd67.tar.gz hdf5-469e8da61e393a380d5af55da6ad2c8ff834dd67.tar.bz2 |
Merge pull request #63 from HDFGroup/feature/vfd_swmr
Feature/vfd swmr
46 files changed, 2220 insertions, 780 deletions
diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c index c26697c..c7d47ef 100644 --- a/src/H5Dvirtual.c +++ b/src/H5Dvirtual.c @@ -912,16 +912,10 @@ H5D__virtual_open_source_dset(const H5D_t *vdset, H5O_storage_virtual_ent_t *vir /* Get the virtual dataset's file open flags ("intent") */ intent = H5F_INTENT(vdset->oloc.file); - /* Try opening the file */ - /* XXX Pass the special file-access property list ID, - * H5P_FILE_ACCESS_ANY_VFD, so that if the file is already open in - * VFD SWMR mode, the library just creates a new H5F_t for the file - * instead of returning an error because of the discrepancy between - * the default file-access properties and the already-open file's - * VFD SWMR properties. - */ + /* Remove H5P_FILE_ACCESS_ANY_VFD and restore the original code */ src_file = H5F_prefix_open_file(vdset->oloc.file, H5F_PREFIX_VDS, vdset->shared->vds_prefix, - source_dset->file_name, intent, H5P_FILE_ACCESS_ANY_VFD); + source_dset->file_name, intent, + vdset->shared->layout.storage.u.virt.source_fapl); /* If we opened the source file here, we should close it when leaving */ if (src_file) diff --git a/src/H5FDcore.c b/src/H5FDcore.c index 4022e82..a207e9e 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -1153,6 +1153,8 @@ H5FD__core_query(const H5FD_t *_file, unsigned long *flags /* out */) *flags |= H5FD_FEAT_ALLOW_FILE_IMAGE; /* OK to use file image feature with this VFD */ *flags |= H5FD_FEAT_CAN_USE_FILE_IMAGE_CALLBACKS; /* OK to use file image callbacks with this VFD */ + *flags |= H5FD_FEAT_SUPPORTS_VFD_SWMR; /* VFD supports the VFD SWMR */ + /* These feature flags are only applicable if the backing store is enabled */ if(file && file->fd >= 0 && file->backing_store) { *flags |= H5FD_FEAT_POSIX_COMPAT_HANDLE; /* get_handle callback returns a POSIX file descriptor */ diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h index fa51574..dae38b6 100644 --- a/src/H5FDprivate.h +++ b/src/H5FDprivate.h @@ -370,11 +370,15 @@ H5_DLL herr_t H5FD_set_paged_aggr(H5FD_t *file, hbool_t paged); H5_DLL herr_t H5FD_init(void); /* Function prototypes for VFD SWMR */ -H5_DLL herr_t H5FD_vfd_swmr_get_tick_and_idx(H5FD_t *_file, hbool_t read_index, uint64_t *tick_ptr, - uint32_t *num_entries_ptr, H5FD_vfd_swmr_idx_entry_t index[]); -H5_DLL void H5FD_vfd_swmr_dump_status(H5FD_t *file, uint64_t page); -H5_DLL void H5FD_vfd_swmr_set_pb_configured(H5FD_t *_file); -H5_DLL void H5FD_vfd_swmr_record_elapsed_ticks(H5FD_t *_file, uint64_t elapsed); +H5_DLL herr_t H5FD_vfd_swmr_get_tick_and_idx(H5FD_t *_file, hbool_t read_index, uint64_t *tick_ptr, + uint32_t *num_entries_ptr, H5FD_vfd_swmr_idx_entry_t index[]); +H5_DLL void H5FD_vfd_swmr_dump_status(H5FD_t *file, uint64_t page); +H5_DLL void H5FD_vfd_swmr_set_pb_configured(H5FD_t *_file); +H5_DLL void H5FD_vfd_swmr_record_elapsed_ticks(H5FD_t *_file, uint64_t elapsed); +H5_DLL void H5FD_vfd_swmr_get_md_path_name(H5FD_t *_file, char **name); +H5_DLL hbool_t H5FD_vfd_swmr_get_make_believe(H5FD_t *_file); +H5_DLL void H5FD_vfd_swmr_set_make_believe(H5FD_t *_file, hbool_t make_believe); +H5_DLL htri_t H5FD_vfd_swmr_assess_make_believe(H5FD_t *_file); H5_DLL H5FD_t *H5FD_vfd_swmr_dedup(H5FD_t *_self, H5FD_t *_other, hid_t fapl_id); /* Function prototypes for MPI based VFDs*/ diff --git a/src/H5FDpublic.h b/src/H5FDpublic.h index a8d85c6..9411874 100644 --- a/src/H5FDpublic.h +++ b/src/H5FDpublic.h @@ -179,6 +179,12 @@ * operations when appropriate. */ #define H5FD_FEAT_MEMMANAGE 0x00010000 +/* + * Defining H5FD_FEAT_SUPPORTS_VFD_SWMR for a VFL driver means that the + * driver supports the SWMR feature that is implemented in a more modular + * fashion and simplifies maintenance. + */ +#define H5FD_FEAT_SUPPORTS_VFD_SWMR 0x00020000 /* ctl function definitions: */ #define H5FD_CTL_OPC_RESERVED 512 /* Opcodes below this value are reserved for library use */ diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index 384ca11..accacb6 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -545,6 +545,7 @@ H5FD__sec2_query(const H5FD_t *_file, unsigned long *flags /* out */) *flags |= H5FD_FEAT_POSIX_COMPAT_HANDLE; /* get_handle callback returns a POSIX file descriptor */ *flags |= H5FD_FEAT_SUPPORTS_SWMR_IO; /* VFD supports the single-writer/multiple-readers (SWMR) pattern */ + *flags |= H5FD_FEAT_SUPPORTS_VFD_SWMR; /* VFD supports the VFD SWMR */ *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default VFD */ diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index 122379a..b59aae3 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -606,6 +606,7 @@ H5FD_stdio_query(const H5FD_t *_f, unsigned long /*OUT*/ *flags) *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default VFD */ + *flags |= H5FD_FEAT_SUPPORTS_VFD_SWMR; /* VFD supports the VFD SWMR */ } return 0; diff --git a/src/H5FDvfd_swmr.c b/src/H5FDvfd_swmr.c index fb88de3..892d084 100644 --- a/src/H5FDvfd_swmr.c +++ b/src/H5FDvfd_swmr.c @@ -15,9 +15,10 @@ */ #include "H5FDdrvr_module.h" /* This source code file is part of the H5FD driver module */ +#define H5F_FRIEND /* Suppress error about including H5Fpkg */ #include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ +#include "H5Fpkg.h" /* Files */ #include "H5FDprivate.h" /* File drivers */ #include "H5FDvfd_swmr.h" /* VFD SWMR file driver */ #include "H5FLprivate.h" /* Free Lists */ @@ -40,9 +41,9 @@ typedef struct H5FD_vfd_swmr_t { /* Metadata file */ int md_fd; /* File descriptor for the metadata file */ uint32_t md_pages_reserved; /* # of pages reserved at the head of the metadata file */ - char md_file_path[H5FD_MAX_FILENAME_LEN]; /* Name of the metadate file */ - H5FD_vfd_swmr_md_header md_header; /* Metadata file header */ - H5FD_vfd_swmr_md_index md_index; /* Metadata file index */ + char md_file_path_name[H5FD_MAX_FILENAME_LEN + 1]; /* Name of the metadate file */ + H5FD_vfd_swmr_md_header md_header; /* Metadata file header */ + H5FD_vfd_swmr_md_index md_index; /* Metadata file index */ /* Histogram of ticks elapsed inside the API (reader only). * api_elapsed_ticks[elapsed] is the number of times @@ -60,10 +61,15 @@ typedef struct H5FD_vfd_swmr_t { * to the lower VFD instance. */ hbool_t writer; + /* + * Indicate whether we are in make_believe state or not + */ + hbool_t make_believe; } H5FD_vfd_swmr_t; -#define MAXADDR (((haddr_t)1 << (8 * sizeof(HDoff_t) - 1)) - 1) +#define MAXADDR (((haddr_t)1 << (8 * sizeof(HDoff_t) - 1)) - 1) +#define VFD_SWMR_MD_SUFFIX ".md" /* Prototypes */ static herr_t H5FD__vfd_swmr_term(void); @@ -217,6 +223,10 @@ done: * * Return: SUCCEED/FAIL * + * Modifications: + * Vailin Choi: 2/18/2022 + * VDS changes: Try opening metadata file and loading header/index if make_believe is FALSE. + * *------------------------------------------------------------------------- */ static herr_t @@ -235,30 +245,119 @@ H5FD__swmr_reader_open(H5FD_vfd_swmr_t *file) if (file->api_elapsed_ticks == NULL) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "could not allocate API elapsed ticks") - /* Retry on opening the metadata file */ - for (do_try = H5_retry_init(&retry, H5FD_VFD_SWMR_MD_FILE_RETRY_MAX, H5_RETRY_DEFAULT_MINIVAL, - H5_RETRY_DEFAULT_MAXIVAL); - do_try; do_try = H5_retry_next(&retry)) { - if ((file->md_fd = HDopen(file->md_file_path, O_RDONLY)) >= 0) - break; - } + if (!file->make_believe) { + /* Retry on opening the metadata file */ + for (do_try = H5_retry_init(&retry, H5FD_VFD_SWMR_MD_FILE_RETRY_MAX, H5_RETRY_DEFAULT_MINIVAL, + H5_RETRY_DEFAULT_MAXIVAL); + do_try; do_try = H5_retry_next(&retry)) { + if ((file->md_fd = HDopen(file->md_file_path_name, O_RDONLY)) >= 0) + break; + } - /* Exhaust all retries for opening the md file */ - if (!do_try) - HGOTO_ERROR(H5E_VFL, H5E_OPENERROR, FAIL, - "unable to open the metadata file after all retry attempts"); + /* Exhaust all retries for opening the md file */ + if (!do_try) + HGOTO_ERROR(H5E_VFL, H5E_OPENERROR, FAIL, + "unable to open the metadata file after all retry attempts"); - /* Retry on loading and decoding the header and index in the - * metadata file - */ - if (H5FD__vfd_swmr_load_hdr_and_idx(file, TRUE) < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "unable to load/decode the md file header/index"); + /* Retry on loading and decoding the header and index in the + * metadata file + */ + if (H5FD__vfd_swmr_load_hdr_and_idx(file, TRUE) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "unable to load/decode the md file header/index"); + } done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__swmr_reader_open() */ /*------------------------------------------------------------------------- + * + * Function: H5FD__vfd_swmr_build_md_path_name + * + * Purpose: To construct the metadata file's full name based on config's + * md_file_path and md_file_name. See RFC for details. + * + * + * Return: Success: SUCCEED + * Failure: FAIL + * + * Programmer: Vailin Choi -- 1/13/2022 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5FD__vfd_swmr_build_md_path_name(H5F_vfd_swmr_config_t *config, const char *hdf5_filename, + char *name /*out*/) +{ + size_t tot_len = 0; + size_t tmp_len = 0; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if ((tot_len = HDstrlen(config->md_file_path)) != 0) { + + /* md_file_path + '/' */ + if (++tot_len > H5F__MAX_VFD_SWMR_FILE_NAME_LEN) + HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "md_file_path and md_file_name exceeds maximum"); + HDstrcat(name, config->md_file_path); + HDstrcat(name, "/"); + } + + if ((tmp_len = HDstrlen(config->md_file_name)) != 0) { + if ((tot_len += tmp_len) > H5F__MAX_VFD_SWMR_FILE_NAME_LEN) + HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "md_file_path and md_file_name exceeds maximum"); + HDstrcat(name, config->md_file_name); + } + else { + /* Automatic generation of metadata file name based on hdf5_filename + '.md' */ + if ((tot_len += (HDstrlen(hdf5_filename) + 3)) > H5F__MAX_VFD_SWMR_FILE_NAME_LEN) + HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "md_file_path and md_file_name maximum"); + + HDstrcat(name, hdf5_filename); + HDstrcat(name, VFD_SWMR_MD_SUFFIX); + } + +done: + + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5FD__vfd_swmr_build_md_path_name() */ + +/*------------------------------------------------------------------------- + * Function: H5FD__vfd_swmr_create_make_believe_data + * + * Purpose: Set up pretend data when make_believe is true + * + * Return: VOID + * + * Programmer: Vailin Choi -- 1/13/2022 + * + *------------------------------------------------------------------------- + */ +static void +H5FD__vfd_swmr_create_make_believe_data(H5FD_vfd_swmr_t *_file) +{ + H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; + + FUNC_ENTER_PACKAGE_NOERR + + HDassert(file->make_believe); + + /* Create make_believe data: empty header and index */ + file->md_header.fs_page_size = 0; + file->md_header.tick_num = 0; + file->md_header.index_offset = H5FD_MD_HEADER_SIZE; + file->md_header.index_length = H5FD_MD_INDEX_SIZE(0); + + file->md_index.tick_num = 0; + file->md_index.num_entries = 0; + + FUNC_LEAVE_NOAPI_VOID + +} /* H5FD__vfd_swmr_create_make_believe_data() */ + +/*------------------------------------------------------------------------- * Function: H5FD__vfd_swmr_open * * Purpose: Open the metadata file and the underlying HDF5 file @@ -268,6 +367,11 @@ done: * caller, which is always H5FD_open(). * Failure: NULL * + * Modifications: + * Vailin Choi: 2/18/2022 + * VDS changes: --Build metadata file name + * --Determine make_believe or not + * *------------------------------------------------------------------------- */ static H5FD_t * @@ -278,6 +382,7 @@ H5FD__vfd_swmr_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t max H5P_genplist_t * plist; H5F_vfd_swmr_config_t *vfd_swmr_config; H5FD_t * ret_value = NULL; /* Return value */ + htri_t is_hdf5; FUNC_ENTER_PACKAGE @@ -314,16 +419,32 @@ H5FD__vfd_swmr_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t max file->hdf5_filename[sizeof(file->hdf5_filename) - 1] = '\0'; /* Retain a copy of the metadata file name */ - HDstrncpy(file->md_file_path, vfd_swmr_config->md_file_path, sizeof(file->md_file_path)); - file->md_file_path[sizeof(file->md_file_path) - 1] = '\0'; + if (H5FD__vfd_swmr_build_md_path_name(vfd_swmr_config, name, file->md_file_path_name) < 0) + HGOTO_ERROR(H5E_VFL, H5E_OPENERROR, NULL, "building md_file_path and md_file_name failed") + + file->md_file_path_name[sizeof(file->md_file_path_name) - 1] = '\0'; file->writer = vfd_swmr_config->writer; - /* Ensure that this is the reader */ - if (!vfd_swmr_config->writer && H5FD__swmr_reader_open(file) < 0) - HGOTO_ERROR(H5E_VFL, H5E_OPENERROR, NULL, "perform reader-specific opening steps failed") + /* Make sure the hdf5 file exists and is valid */ + is_hdf5 = H5F__is_hdf5(name, H5P_FILE_ACCESS_DEFAULT); + + /* Ensure reader */ + if (!vfd_swmr_config->writer) { + /* Metadata file does not exist, presume_posix is true, HDF5 file exist */ + if (HDaccess(file->md_file_path_name, F_OK) < 0 && vfd_swmr_config->presume_posix_semantics && + is_hdf5 == TRUE) { + + file->make_believe = TRUE; + H5FD__vfd_swmr_create_make_believe_data(file); + } + if (H5FD__swmr_reader_open(file) < 0) + HGOTO_ERROR(H5E_VFL, H5E_OPENERROR, NULL, "perform reader-specific opening steps failed") + } /* Hard-wired to open the underlying HDF5 file with SEC2 */ + /* H5FD_SEC2 is the default driver for H5P_FILE_ACCESS_DEFAULT except when + the environment variable HDF5_DRIVER is set to otherwise */ if ((file->hdf5_file_lf = H5FD_open(name, flags, H5P_FILE_ACCESS_DEFAULT, maxaddr)) == NULL) HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, NULL, "can't set driver info"); @@ -453,10 +574,10 @@ H5FD__vfd_swmr_cmp(const H5FD_t *_f1, const H5FD_t *_f2) ret_value = H5FD_cmp(f1->hdf5_file_lf, f2->hdf5_file_lf); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_vfd__swmr_cmp() */ +} /* end H5FD__vfd__swmr_cmp() */ /*------------------------------------------------------------------------- - * Function: H5FD_vfd_swmr_dedup + * Function: H5FD_vfd_swmr_dedup (original description with H5P_FILE_ACCESS_ANY_VFD) * * Purpose: Compare the already-opened VFD instance `_self` with the * VFD instance `_other` newly-opened with file-access properties @@ -497,6 +618,42 @@ H5FD__vfd_swmr_cmp(const H5FD_t *_f1, const H5FD_t *_f2) * Failure: NULL *------------------------------------------------------------------------- */ +/*------------------------------------------------------------------------- + * Function: H5FD_vfd_swmr_dedup (modified version without H5P_FILE_ACCESS_ANY_VFD) + * + * Purpose: Compare the already-opened VFD instance `_self` with the + * VFD instance `_other` newly-opened with file-access properties + * `fapl_id` and indicate whether the instances duplicate each + * other, if they conflict with each other, or if they are + * dissimilar. + * + * If `_self` duplicates `_other`, return `_self`. + * + * Return NULL on error, or if `_other` and `_self` refer to the + * same file but the file-access properties, `fapl_id`, conflict + * with the properties of `_self`. + * + * If `_other` neither duplicates nor conflicts with `_self`, + * then return `_other`. + * + * NOTE: Judging duplicate/conflicting/dissimilar VFD instances + * + * `_self` DUPLICATES `_other` if `_other` is also an instance + * of SWMR class, the instances' lower files are equal under + * `H5FD_cmp()`, and the file-access properties of `_self` match + * `fapl_id`. + * + * `_self` and `_other` CONFLICT if both are SWMR instances + * referring to the same lower file, and their file-access + * properties differ. + * + * `_self` and `_other` CONFLICT if `_other` is not a SWMR + * instance, it equals the lower file of `_self`. + * + * Return: Success: `_self' or `_other', as described above + * Failure: NULL + *------------------------------------------------------------------------- + */ H5FD_t * H5FD_vfd_swmr_dedup(H5FD_t *_self, H5FD_t *_other, hid_t fapl_id) { @@ -523,12 +680,6 @@ H5FD_vfd_swmr_dedup(H5FD_t *_self, H5FD_t *_other, hid_t fapl_id) if (H5FD_cmp(self->hdf5_file_lf, other->hdf5_file_lf) != 0) HGOTO_DONE(_other) - /* If fapl_id == _ANY_VFD, then the match between lower files is - * sufficient. - */ - if (fapl_id == H5P_FILE_ACCESS_ANY_VFD) - HGOTO_DONE(_self) - /* If fapl_id != _ANY_VFD, then we have either a duplicate or * a conflict. If the VFD SWMR parameters match, then * return `self` to indicate a duplicate. Otherwise, return @@ -552,7 +703,7 @@ H5FD_vfd_swmr_dedup(H5FD_t *_self, H5FD_t *_other, hid_t fapl_id) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "inconsistent VFD SWMR config") } else if (H5FD_cmp(self->hdf5_file_lf, _other) == 0) - ret_value = (fapl_id == H5P_FILE_ACCESS_ANY_VFD) ? _self : NULL; + ret_value = NULL; else ret_value = _other; @@ -752,6 +903,11 @@ done: * buffer BUF. * Failure: FAIL, Contents of buffer BUF are undefined. * + * Modifications: + * Vailin Choi: 2/18/2022 + * VDS changes: If fs_page_size is 0, i.e. in make_believe state, + * read from the underlying HDF5 file + * *------------------------------------------------------------------------- */ static herr_t @@ -780,10 +936,17 @@ H5FD__vfd_swmr_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id num_entries = file->md_index.num_entries; fs_page_size = file->md_header.fs_page_size; - /* Try finding the addr from the index */ - target_page = addr / fs_page_size; + if (!fs_page_size) { + HDassert(!num_entries); + HDassert(file->make_believe); + entry = NULL; + } + else { + /* Try finding the addr from the index */ + target_page = addr / fs_page_size; - entry = H5FD_vfd_swmr_pageno_to_mdf_idx_entry(index, num_entries, target_page, FALSE); + entry = H5FD_vfd_swmr_pageno_to_mdf_idx_entry(index, num_entries, target_page, FALSE); + } if (entry == NULL) { /* Cannot find addr in index, read from the underlying hdf5 file */ @@ -1008,6 +1171,10 @@ done: * Return: Success: SUCCEED * Failure: FAIL * + * Modifications: + * Vailin Choi: 2/18/2022 + * VDS changes: Update the header's fs_page size if it is still 0 + * *------------------------------------------------------------------------- */ static herr_t @@ -1113,6 +1280,14 @@ H5FD__vfd_swmr_load_hdr_and_idx(H5FD_vfd_swmr_t *file, hbool_t open) md_index.entries = NULL; done: + /* Need to update the header's fs_page_size if it is still 0 + because it is possible that md_header.tick_num == file->md_header.tick_num + and the loading is not done */ + if (ret_value == SUCCEED && !file->md_header.fs_page_size) { + HDassert(md_header.fs_page_size); + HDassert(file->make_believe); + file->md_header.fs_page_size = md_header.fs_page_size; + } FUNC_LEAVE_NOAPI(ret_value) @@ -1501,3 +1676,138 @@ H5FD_vfd_swmr_record_elapsed_ticks(H5FD_t *_file, uint64_t elapsed) FUNC_LEAVE_NOAPI_VOID } /* end H5FD_vfd_swmr_record_elapsed_ticks() */ + +/*------------------------------------------------------------------------- + * Function: H5FD_vfd_swmr_get_md_name + * + * Purpose: To retrieve the metadata file's full name + * + * Return: VOID + * + * Programmer: Vailin Choi; 02/18/2022 + * + *------------------------------------------------------------------------- + * + */ +void +H5FD_vfd_swmr_get_md_path_name(H5FD_t *_file, char **name) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; + + *name = H5MM_xstrdup(file->md_file_path_name); + + FUNC_LEAVE_NOAPI_VOID + +} /* H5FD_vfd_swmr_get_md_path_name() */ + +/*------------------------------------------------------------------------- + * Function: H5FD_vfd_swmr_get_make_believe + * + * Purpose: To retrieve the value of make_believe + * + * Return: TRUE/FALSE + * + * Programmer: Vailin Choi; 02/18/2022 + * + *------------------------------------------------------------------------- + * + */ +hbool_t +H5FD_vfd_swmr_get_make_believe(H5FD_t *_file) +{ + H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(file); + + FUNC_LEAVE_NOAPI(file->make_believe) + +} /* H5FD_vfd_swmr_get_make_believe() */ + +/*------------------------------------------------------------------------- + * Function: H5FD_vfd_swmr_set_make_believe + * + * Purpose: To set the VFD's make believe to the + * parameter "make_believe" + * + * Return: VOID + * + * Programmer: Vailin Choi; 02/18/2022 + * + *------------------------------------------------------------------------- + * + */ +void +H5FD_vfd_swmr_set_make_believe(H5FD_t *_file, hbool_t make_believe) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; + + HDassert(file); + + /* Set return value */ + file->make_believe = make_believe; + + FUNC_LEAVE_NOAPI_VOID + +} /* H5FD_vfd_swmr_make_believe() */ + +/*------------------------------------------------------------------------- + * Function: H5FD_vfd_swmr_assess_make_believe + * + * Purpose: To determine whether continuing with make_believe or not. + * Return TRUE: + * --if metadata file does not exist, continue with make_believe + * Return FALSE: + * --if metadata file exists and can be opened successfully, + * discontinue with make_believe + * Return FAIL: + * --error in opening the metadata file + * + * + * Return: TRUE/FALSE/FAIL + * + * Programmer: Vailin Choi; 02/18/2022 + *------------------------------------------------------------------------- + */ +htri_t +H5FD_vfd_swmr_assess_make_believe(H5FD_t *_file) +{ + H5FD_vfd_swmr_t *file = (H5FD_vfd_swmr_t *)_file; /* VFD SWMR file struct */ + h5_retry_t retry; + hbool_t do_try; /* more tries remain */ + htri_t ret_value = TRUE; /* Return value */ + + FUNC_ENTER_NOAPI(FALSE) + + HDassert(file->make_believe); + + if (HDaccess(file->md_file_path_name, F_OK) >= 0) { + /* MD file exists now, proceed to open it */ + HDassert(file->md_fd < 0); + + /* Retry on opening the metadata file */ + for (do_try = H5_retry_init(&retry, H5FD_VFD_SWMR_MD_FILE_RETRY_MAX, H5_RETRY_DEFAULT_MINIVAL, + H5_RETRY_DEFAULT_MAXIVAL); + do_try; do_try = H5_retry_next(&retry)) { + if ((file->md_fd = HDopen(file->md_file_path_name, O_RDONLY)) >= 0) + break; + } + + /* Exhaust all retries for opening the md file */ + if (!do_try) + HGOTO_ERROR(H5E_VFL, H5E_OPENERROR, FAIL, + "unable to open the metadata file after all retry attempts"); + + /* Succeed in opening the MD file, discontinue make_believe */ + ret_value = FALSE; + } + +done: + FUNC_LEAVE_NOAPI(ret_value) + +} /* end H5FD_vfd_swmr_assess_make_believe() */ diff --git a/src/H5Fint.c b/src/H5Fint.c index 2822d9d..9880126 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -1828,10 +1828,25 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) FUNC_ENTER_NOAPI(NULL) + /* + * If the driver has a 'cmp' method then the driver is capable of + * determining when two file handles refer to the same file and the + * library can insure that when the application opens a file twice + * that the two handles coordinate their operations appropriately. + * Otherwise it is the application's responsibility to never open the + * same file more than once at a time. + */ + if (NULL == (drvr = H5FD_get_class(fapl_id))) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "unable to retrieve VFL class") + /* Get the file access property list, for future queries */ if (NULL == (a_plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list") + /* Check if we are using file locking */ + if (H5F__check_if_using_file_locks(a_plist, &use_file_locking) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "unable to get file locking flag") + /* Allocate space for VFD SWMR configuration info */ if (NULL == (vfd_swmr_config_ptr = H5MM_calloc(sizeof(H5F_vfd_swmr_config_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't allocate memory for mdc log file name") @@ -1851,26 +1866,10 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) /* Retrieve the private property for VFD SWMR testing */ if (H5P_get(a_plist, H5F_ACS_GENERATE_MD_CK_CB_NAME, &cb_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get generate_md_ck_cb info") - } - /* - * If the driver has a 'cmp' method then the driver is capable of - * determining when two file handles refer to the same file and the - * library can insure that when the application opens a file twice - * that the two handles coordinate their operations appropriately. - * Otherwise it is the application's responsibility to never open the - * same file more than once at a time. - */ - if (NULL == (drvr = H5FD_get_class(fapl_id))) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "unable to retrieve VFL class") - - /* Get the file access property list, for future queries */ - if (NULL == (a_plist = (H5P_genplist_t *)H5I_object(fapl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list") - - /* Check if we are using file locking */ - if (H5F__check_if_using_file_locks(a_plist, &use_file_locking) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "unable to get file locking flag") + if (!vfd_swmr_config_ptr->writer) + use_file_locking = FALSE; + } /* * Opening a file is a two step process. First we try to open the diff --git a/src/H5Fio.c b/src/H5Fio.c index ca069e0..7193199 100644 --- a/src/H5Fio.c +++ b/src/H5Fio.c @@ -83,7 +83,8 @@ herr_t H5F_shared_block_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, void *buf /*out*/) { - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_mem_t map_type = type; /* Mapped memory type */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -96,8 +97,12 @@ H5F_shared_block_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t if (H5F_addr_le(f_sh->tmp_addr, (addr + size))) HGOTO_ERROR(H5E_IO, H5E_BADRANGE, FAIL, "attempting I/O in temporary file space") + if (!H5F_SHARED_USE_VFD_SWMR(f_sh)) + /* Treat global heap as raw data */ + map_type = (type == H5FD_MEM_GHEAP) ? H5FD_MEM_DRAW : type; + /* Pass through page buffer layer */ - if (H5PB_read(f_sh, type, addr, size, buf) < 0) + if (H5PB_read(f_sh, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "read through page buffer failed") done: @@ -141,7 +146,8 @@ H5F_block_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, void *buf / herr_t H5F_shared_block_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf) { - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_mem_t map_type = type; /* Mapped memory type */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -155,8 +161,12 @@ H5F_shared_block_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t if (H5F_addr_le(f_sh->tmp_addr, (addr + size))) HGOTO_ERROR(H5E_IO, H5E_BADRANGE, FAIL, "attempting I/O in temporary file space") + if (!H5F_SHARED_USE_VFD_SWMR(f_sh)) + /* Treat global heap as raw data */ + map_type = (type == H5FD_MEM_GHEAP) ? H5FD_MEM_DRAW : type; + /* Pass through page buffer layer */ - if (H5PB_write(f_sh, type, addr, size, buf) < 0) + if (H5PB_write(f_sh, map_type, addr, size, buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "write through page buffer failed") done: diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index ca714c1..95854cb 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -512,22 +512,24 @@ struct H5F_shared_t { uint32_t old_mdf_idx_entries_used; /* Metadata file and updater file for VFD SWMR writer */ - int vfd_swmr_md_fd; /* POSIX: file descriptor for the - * metadata file or -1 if the metadata file - * is not currently open. - * The vfd_swmr_config.generate_updater_files - * is FALSE. - */ - /* NFS: - * The vfd_swmr_config.generate_updater_files - * is TRUE and: - * --if vfd_swmr_config.writer is FALSE, - * this field is the file descriptor of the local - * copy of the metadata file, or -1 if the local - * copy is not currently open. - * --if vfd_swmr_config.writer is TRUE, this field - * is not used and is set to -1. - */ + int vfd_swmr_md_fd; /* POSIX: file descriptor for the + * metadata file or -1 if the metadata file + * is not currently open. + * The vfd_swmr_config.generate_updater_files + * is FALSE. + */ + /* NFS: + * The vfd_swmr_config.generate_updater_files + * is TRUE and: + * --if vfd_swmr_config.writer is FALSE, + * this field is the file descriptor of the local + * copy of the metadata file, or -1 if the local + * copy is not currently open. + * --if vfd_swmr_config.writer is TRUE, this field + * is not used and is set to -1. + */ + char *md_file_path_name; /* Name composed of md_file_path and md_file_name from vfd_swmr_config */ + H5F_generate_md_ck_t generate_md_ck_cb; /* For testing only: * Invoke the user-defined callback if exists to diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index ffc369b..c594ed8 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -374,6 +374,7 @@ typedef struct H5F_t H5F_t; #define H5F_THRESHOLD(F) ((F)->shared->threshold) #define H5F_PGEND_META_THRES(F) ((F)->shared->fs.pgend_meta_thres) #define H5F_POINT_OF_NO_RETURN(F) ((F)->shared->fs.point_of_no_return) +#define H5F_SHARED_USE_VFD_SWMR(F_SH) ((F_SH)->vfd_swmr) #define H5F_USE_VFD_SWMR(F) ((F)->shared->vfd_swmr) #define H5F_NULL_FSM_ADDR(F) ((F)->shared->null_fsm_addr) #define H5F_GET_MIN_DSET_OHDR(F) ((F)->shared->crt_dset_min_ohdr_flag) @@ -438,6 +439,7 @@ typedef struct H5F_t H5F_t; #define H5F_THRESHOLD(F) (H5F_get_threshold(F)) #define H5F_PGEND_META_THRES(F) (H5F_get_pgend_meta_thres(F)) #define H5F_POINT_OF_NO_RETURN(F) (H5F_get_point_of_no_return(F)) +#define H5F_SHARED_USE_VFD_SWMR(F_SH) (H5F_shared_get_use_vfd_swmr(F_SH)) #define H5F_USE_VFD_SWMR(F) (H5F_get_use_vfd_swmr(F)) #define H5F_NULL_FSM_ADDR(F) (H5F_get_null_fsm_addr(F)) #define H5F_GET_MIN_DSET_OHDR(F) (H5F_get_min_dset_ohdr(F)) @@ -628,6 +630,7 @@ typedef struct H5F_t H5F_t; /* int32_t version = */ 0, \ /* int32_t tick_len = */ 0, \ /* int32_t max_lag = */ 0, \ + /* hbool_t presume_posix_semantics = */ FALSE, \ /* hbool_t vfd_swmr_writer = */ FALSE, \ /* hbool_t maintain_metadata_file = */ FALSE, \ /* hbool_t generate_updater_files = */ FALSE, \ @@ -635,6 +638,7 @@ typedef struct H5F_t H5F_t; /* int32_t md_pages_reserved = */ 0, \ /* int32_t pb_expansion_threshold = */ 0, \ /* char md_file_path[] = */ "", \ + /* char md_file_name[] = */ "", \ /* char updater_file_path[] = */ "", \ /* char log_file_path[] = */ "" \ } diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h index e9d3340..0e8eda6 100644 --- a/src/H5Fpublic.h +++ b/src/H5Fpublic.h @@ -271,6 +271,20 @@ typedef herr_t (*H5F_flush_cb_t)(hid_t object_id, void *udata); * between the writer and the readers. This value must be at least 3, * with 10 being the recommended minimum value. * + * presume_posix_semantics + * A boolean flag that is only relevant to the reader. + * This flag should be set to TRUE if both of the following conditions hold: + * 1) Both the metadata file and HDF5 file are being written on a POSIX + * file system that is local to the reader. + * 2) The metadata file is being maintained directly by the VFD SWMR + * writer (i.e. without use of updater files and the auxiliary process.) + * If this flag is FALSE, the VFD SWMR reader must make the two adjustments: + * 1) Per legacy SWMR, the VFD that reads the HDF5 file proper must allow + * reads past EOF without error. + * 2) The VFD SWMR reader is not permitted to open an existing HDF5 file + * either before the VFD SWMR writer has opened it, or after it has + * closed it. + * * writer: * A boolean flag indicating whether the file opened with this FAPL entry * will be opened R/W. (i.e. as a VFD SWMR writer) @@ -333,9 +347,19 @@ typedef herr_t (*H5F_flush_cb_t)(hid_t object_id, void *udata); * * md_file_path: * If both the writer and maintain_metadata_file fields are TRUE, this - * field contains the path of the metadata file. - * If writer is FALSE, this field contains the path of the (possibly - * local copy of the) metadata file. + * field contains the path but not the name of the metadata file. + * If writer is FALSE, this field contains the path (but not the name) + * of the (possibly local copy of the) metadata file. + * + * md_file_name: + * If both the writer and maintain_metadata_file fields are TRUE, this + * field is defined, and must contain the name (but not the path) of + * the metadata file, or NULL. + * If writer is FALSE, this field is defined, and must contain either + * the name (but not the path) of the metadata file, or NULL. + * If the field is defined but NULL, the metadata file name is + * generated by adding the ".md" suffix to the HDF5 file name. + * If the field is not NULL, the metadata file name is used as provided. * * updater_file_path: * If generate_updater_files is TRUE, the contents of this field depends @@ -353,6 +377,7 @@ typedef struct H5F_vfd_swmr_config_t { int32_t version; uint32_t tick_len; uint32_t max_lag; + hbool_t presume_posix_semantics; hbool_t writer; hbool_t maintain_metadata_file; hbool_t generate_updater_files; @@ -360,6 +385,7 @@ typedef struct H5F_vfd_swmr_config_t { uint32_t md_pages_reserved; uint32_t pb_expansion_threshold; char md_file_path[H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1]; + char md_file_name[H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1]; char updater_file_path[H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1]; char log_file_path[H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1]; } H5F_vfd_swmr_config_t; diff --git a/src/H5Fquery.c b/src/H5Fquery.c index acdf521..22b9f78 100644 --- a/src/H5Fquery.c +++ b/src/H5Fquery.c @@ -1344,6 +1344,25 @@ H5F_get_file_locking(const H5F_t *f) } /* end H5F_get_file_locking */ /*------------------------------------------------------------------------- + * Function: H5F_shared_get_use_vfd_swmr + * + * Purpose: Determine if VFD SWMR is enabled for this file. + * + * Return: TRUE/FALSE + *------------------------------------------------------------------------- + */ +unsigned +H5F_shared_get_use_vfd_swmr(const H5F_shared_t *f_sh) +{ + /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(f_sh); + + FUNC_LEAVE_NOAPI(f_sh->vfd_swmr) +} /* end H5F_shared_get_use_vfd_swmr() */ + +/*------------------------------------------------------------------------- * Function: H5F_get_use_vfd_swmr * * Purpose: Determine if VFD SWMR is enabled for this file. diff --git a/src/H5Ftest.c b/src/H5Ftest.c index 0213cd1..86b3c0b 100644 --- a/src/H5Ftest.c +++ b/src/H5Ftest.c @@ -338,11 +338,11 @@ H5F__vfd_swmr_writer_create_open_flush_test(hid_t file_id, hbool_t file_create) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Open the metadata file */ - if ((md_fd = HDopen(f->shared->vfd_swmr_config.md_file_path, O_RDONLY)) < 0) + if ((md_fd = HDopen(f->shared->md_file_path_name, O_RDONLY)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "error opening metadata file") /* Verify the minimum size for the metadata file */ - if (HDstat(f->shared->vfd_swmr_config.md_file_path, &stat_buf) < 0) + if (HDstat(f->shared->md_file_path_name, &stat_buf) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to stat the metadata file") if (file_create) { /* Creating file */ @@ -634,7 +634,7 @@ H5F__vfd_swmr_writer_md_test(hid_t file_id, unsigned num_entries, H5FD_vfd_swmr_ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "incorrect # of entries in the delayed list") /* Open the metadata file */ - if ((md_fd = HDopen(f->shared->vfd_swmr_config.md_file_path, O_RDONLY)) < 0) + if ((md_fd = HDopen(f->shared->md_file_path_name, O_RDONLY)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "error opening metadata file") /* Decode the header in the metadata file */ diff --git a/src/H5Fvfd_swmr.c b/src/H5Fvfd_swmr.c index cd3a345..9c4360e 100644 --- a/src/H5Fvfd_swmr.c +++ b/src/H5Fvfd_swmr.c @@ -186,9 +186,11 @@ H5F_vfd_swmr_init(H5F_t *f, hbool_t file_create) shared->vfd_swmr_writer = TRUE; shared->tick_num = 0; - /* Create the metadata file */ - if (((shared->vfd_swmr_md_fd = HDopen(shared->vfd_swmr_config.md_file_path, - O_CREAT | O_RDWR | O_TRUNC, H5_POSIX_CREATE_MODE_RW))) < 0) + /* Retrieve the metadata filename built with md_file_path and md_file_name */ + H5FD_vfd_swmr_get_md_path_name(f->shared->lf, &shared->md_file_path_name); + + if (((shared->vfd_swmr_md_fd = HDopen(shared->md_file_path_name, O_CREAT | O_RDWR | O_TRUNC, + H5_POSIX_CREATE_MODE_RW))) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to create the metadata file") md_size = (hsize_t)shared->vfd_swmr_config.md_pages_reserved * shared->fs_page_size; @@ -215,7 +217,7 @@ H5F_vfd_swmr_init(H5F_t *f, hbool_t file_create) /* For VFD SWMR testing: invoke callback if set to generate metadata file checksum */ if (shared->generate_md_ck_cb) { - if (shared->generate_md_ck_cb(shared->vfd_swmr_config.md_file_path, shared->updater_seq_num) < 0) + if (shared->generate_md_ck_cb(shared->md_file_path_name, shared->updater_seq_num) < 0) HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "error from generate_md_ck_cb()") } @@ -331,14 +333,16 @@ H5F_vfd_swmr_close_or_flush(H5F_t *f, hbool_t closing) /* For VFD SWMR testing: invoke callback if set to generate metadata file checksum */ if (shared->generate_md_ck_cb) { - if (shared->generate_md_ck_cb(shared->vfd_swmr_config.md_file_path, shared->updater_seq_num) < 0) + if (shared->generate_md_ck_cb(shared->md_file_path_name, shared->updater_seq_num) < 0) HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "error from generate_md_ck_cb()") } /* Unlink the md file */ - if (HDunlink(shared->vfd_swmr_config.md_file_path) < 0) + if (HDunlink(shared->md_file_path_name) < 0) HSYS_GOTO_ERROR(H5E_FILE, H5E_CANTREMOVE, FAIL, "unable to unlink the metadata file") + shared->md_file_path_name = (char *)H5MM_xfree(shared->md_file_path_name); + /* Close the free-space manager for the metadata file */ if (H5MV_close(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, @@ -571,7 +575,7 @@ H5F_update_vfd_swmr_metadata_file(H5F_t *f, uint32_t num_entries, H5FD_vfd_swmr_ /* For VFD SWMR testing: invoke callback if set to generate metadata file checksum */ if (shared->generate_md_ck_cb) { - if (shared->generate_md_ck_cb(shared->vfd_swmr_config.md_file_path, shared->updater_seq_num) < 0) + if (shared->generate_md_ck_cb(shared->md_file_path_name, shared->updater_seq_num) < 0) HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "error from generate_md_ck_cb()") } @@ -1031,6 +1035,14 @@ H5F_vfd_swmr_writer_dump_index(H5F_shared_t *shared) * 9) Increment the tick, and update the end of tick. * * Return: SUCCEED/FAIL + * + * Programmer: John Mainzer 12/29/18 + * + * Changes: + * VDS changes: Check make_believe whether to continue the same or + * get out of make_believe and load header/index. + * For details, see RFC for VDS changes. + * *------------------------------------------------------------------------- */ herr_t @@ -1053,6 +1065,7 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, hbool_t entering_api) herr_t ret_value = SUCCEED; uint32_t i, j, nchanges; H5FD_t * file = shared->lf; + htri_t ret; FUNC_ENTER_NOAPI(FAIL) @@ -1071,9 +1084,35 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, hbool_t entering_api) * so as to detect the need to allocate more space for the * index. */ - if (H5FD_vfd_swmr_get_tick_and_idx(file, TRUE, &tmp_tick_num, &vfd_entries, NULL) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "error in retrieving tick_num from driver") + /* Check if make_believe is set */ + if (H5FD_vfd_swmr_get_make_believe(file)) { + + /* Return value is TRUE: metadata file is not found, continue with make_believe + and skip eot processing */ + if ((ret = H5FD_vfd_swmr_assess_make_believe(file)) == TRUE) { + /* Skip most of the EOT processing */ + goto reader_update_eot; + } + else if (ret == FAIL) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "error in assessing make_believe from driver") + + /* Return value is FALSE i.e. found the metadata file */ + HDassert(!ret); + + /* Try to load the metadata file header and index */ + if (H5FD_vfd_swmr_get_tick_and_idx(file, TRUE, &tmp_tick_num, &vfd_entries, NULL) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "error in retrieving tick_num from driver") + + /* Set make_believe to FALSE; + get out from make_believe state, continue normal processing */ + H5FD_vfd_swmr_set_make_believe(file, FALSE); + } + else { + /* make_believe is not set, continue normal processing */ + if (H5FD_vfd_swmr_get_tick_and_idx(file, TRUE, &tmp_tick_num, &vfd_entries, NULL) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "error in retrieving tick_num from driver") + } /* This is ok if we're entering the API, but it should * not happen if we're exiting the API. @@ -1288,6 +1327,8 @@ H5F_vfd_swmr_reader_end_of_tick(H5F_t *f, hbool_t entering_api) } } +reader_update_eot: + /* Remove the entry from the EOT queue */ if (H5F_vfd_swmr_remove_entry_eot(f) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to remove entry from EOT queue") @@ -2305,7 +2346,8 @@ H5F__generate_updater_file(H5F_t *f, uint32_t num_entries, uint16_t flags, uint8 if (sz > H5F__MAX_VFD_SWMR_FILE_NAME_LEN) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "string passed to snprintf would be truncated") newname[H5F__MAX_VFD_SWMR_FILE_NAME_LEN - 1] = '\0'; - HDrename(namebuf, newname); + if (HDrename(namebuf, newname) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "error from renaming the updater file") ++shared->updater_seq_num; diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index 7d3cf57..f900965 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -863,12 +863,6 @@ H5P__facc_reg_prop(H5P_genclass_t *pclass) H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - if (H5P_LST_FILE_ACCESS_ANY_VFD_g == H5I_INVALID_HID) { - H5P_LST_FILE_ACCESS_ANY_VFD_g = H5P_create_id(pclass, false); - if (H5P_LST_FILE_ACCESS_ANY_VFD_g == H5I_INVALID_HID) { - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't create any-vfd fapl"); - } - } done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_reg_prop() */ @@ -4637,6 +4631,7 @@ H5P__facc_vfd_swmr_config_enc(const void *value, void **_pp, size_t *size) INT32ENCODE(*pp, (int32_t)config->version); INT32ENCODE(*pp, (int32_t)config->tick_len); INT32ENCODE(*pp, (int32_t)config->max_lag); + H5_ENCODE_UNSIGNED(*pp, config->presume_posix_semantics); H5_ENCODE_UNSIGNED(*pp, config->writer); H5_ENCODE_UNSIGNED(*pp, config->maintain_metadata_file); H5_ENCODE_UNSIGNED(*pp, config->generate_updater_files); @@ -4645,6 +4640,8 @@ H5P__facc_vfd_swmr_config_enc(const void *value, void **_pp, size_t *size) INT32ENCODE(*pp, (int32_t)config->pb_expansion_threshold); HDmemcpy(*pp, (const uint8_t *)(config->md_file_path), (size_t)(H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1)); *pp += H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1; + HDmemcpy(*pp, (const uint8_t *)(config->md_file_name), (size_t)(H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1)); + *pp += H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1; HDmemcpy(*pp, (const uint8_t *)(config->updater_file_path), (size_t)(H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1)); *pp += H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1; @@ -4655,7 +4652,7 @@ H5P__facc_vfd_swmr_config_enc(const void *value, void **_pp, size_t *size) } /* end if */ /* Compute encoded size */ - *size += ((5 * sizeof(int32_t)) + (4 * sizeof(unsigned)) + (3 * (H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1))); + *size += ((5 * sizeof(int32_t)) + (5 * sizeof(unsigned)) + (4 * (H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1))); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__facc_vfd_swmr_config_enc() */ @@ -4694,6 +4691,7 @@ H5P__facc_vfd_swmr_config_dec(const void **_pp, void *_value) INT32DECODE(*pp, config->version); UINT32DECODE(*pp, config->tick_len); UINT32DECODE(*pp, config->max_lag); + UINT32DECODE(*pp, config->presume_posix_semantics); H5_DECODE_UNSIGNED(*pp, config->writer); H5_DECODE_UNSIGNED(*pp, config->maintain_metadata_file); @@ -4707,6 +4705,9 @@ H5P__facc_vfd_swmr_config_dec(const void **_pp, void *_value) HDstrcpy(config->md_file_path, (const char *)(*pp)); *pp += H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1; + HDstrcpy(config->md_file_name, (const char *)(*pp)); + *pp += H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1; + HDstrcpy(config->updater_file_path, (const char *)(*pp)); *pp += H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1; @@ -6257,14 +6258,13 @@ H5Pset_vfd_swmr_config(hid_t plist_id, H5F_vfd_swmr_config_t *config_ptr) "either maintain_metadata_file or generate_updater_files must be TRUE") } - if ((config_ptr->writer && config_ptr->maintain_metadata_file) || !config_ptr->writer) { - /* Must provide the path and base name of the metadata file */ - name_len = HDstrlen(config_ptr->md_file_path); - if (name_len == 0) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "md_file_path is empty") - else if (name_len > H5F__MAX_VFD_SWMR_FILE_NAME_LEN) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "md_file_path is too long") - } + /* md_file_path can be "" or a name (+"/")*/ + /* md_file_name can be "" (+ ".md") or a name */ + /* <md_file_path, md_file_name> pattern: <null, null> <null, name> <name, null> <name, name> */ + /* Can only validate for <null, name>, <name, name> cases */ + name_len = HDstrlen(config_ptr->md_file_path) + HDstrlen(config_ptr->md_file_name); + if (name_len > H5F__MAX_VFD_SWMR_FILE_NAME_LEN) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "md_file_name + md_file_path is too long") if (config_ptr->writer && config_ptr->generate_updater_files) { /* Must provide the path and base name of the metadata updater files */ diff --git a/src/H5Pint.c b/src/H5Pint.c index 400795a..da8ca1c 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -182,7 +182,6 @@ hid_t H5P_LST_DATASET_CREATE_ID_g = H5I_INVALID_HID; hid_t H5P_LST_DATASET_XFER_ID_g = H5I_INVALID_HID; hid_t H5P_LST_DATATYPE_ACCESS_ID_g = H5I_INVALID_HID; hid_t H5P_LST_DATATYPE_CREATE_ID_g = H5I_INVALID_HID; -hid_t H5P_LST_FILE_ACCESS_ANY_VFD_g = H5I_INVALID_HID; hid_t H5P_LST_FILE_ACCESS_ID_g = H5I_INVALID_HID; hid_t H5P_LST_FILE_CREATE_ID_g = H5I_INVALID_HID; hid_t H5P_LST_FILE_MOUNT_ID_g = H5I_INVALID_HID; @@ -605,7 +604,6 @@ H5P_term_package(void) H5P_LST_DATASET_XFER_ID_g = H5I_INVALID_HID; H5P_LST_DATATYPE_ACCESS_ID_g = H5I_INVALID_HID; H5P_LST_DATATYPE_CREATE_ID_g = H5I_INVALID_HID; - H5P_LST_FILE_ACCESS_ANY_VFD_g = H5I_INVALID_HID; H5P_LST_FILE_ACCESS_ID_g = H5I_INVALID_HID; H5P_LST_FILE_CREATE_ID_g = H5I_INVALID_HID; H5P_LST_FILE_MOUNT_ID_g = H5I_INVALID_HID; @@ -660,7 +658,6 @@ H5P_term_package(void) H5P_CLS_DATASET_XFER_ID_g = H5I_INVALID_HID; H5P_CLS_DATATYPE_ACCESS_ID_g = H5I_INVALID_HID; H5P_CLS_DATATYPE_CREATE_ID_g = H5I_INVALID_HID; - H5P_LST_FILE_ACCESS_ANY_VFD_g = H5I_INVALID_HID; H5P_CLS_FILE_ACCESS_ID_g = H5I_INVALID_HID; H5P_CLS_FILE_CREATE_ID_g = H5I_INVALID_HID; H5P_CLS_FILE_MOUNT_ID_g = H5I_INVALID_HID; diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index ed9db10..4262026 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -78,7 +78,6 @@ */ #define H5P_FILE_CREATE_DEFAULT (H5OPEN H5P_LST_FILE_CREATE_ID_g) #define H5P_FILE_ACCESS_DEFAULT (H5OPEN H5P_LST_FILE_ACCESS_ID_g) -#define H5P_FILE_ACCESS_ANY_VFD (H5OPEN H5P_LST_FILE_ACCESS_ANY_VFD_g) #define H5P_DATASET_CREATE_DEFAULT (H5OPEN H5P_LST_DATASET_CREATE_ID_g) #define H5P_DATASET_ACCESS_DEFAULT (H5OPEN H5P_LST_DATASET_ACCESS_ID_g) #define H5P_DATASET_XFER_DEFAULT (H5OPEN H5P_LST_DATASET_XFER_ID_g) @@ -397,7 +396,6 @@ H5_DLLVAR hid_t H5P_CLS_REFERENCE_ACCESS_ID_g; /* (Internal to library, do not use! Use macros above) */ H5_DLLVAR hid_t H5P_LST_FILE_CREATE_ID_g; H5_DLLVAR hid_t H5P_LST_FILE_ACCESS_ID_g; -H5_DLLVAR hid_t H5P_LST_FILE_ACCESS_ANY_VFD_g; H5_DLLVAR hid_t H5P_LST_DATASET_CREATE_ID_g; H5_DLLVAR hid_t H5P_LST_DATASET_ACCESS_ID_g; H5_DLLVAR hid_t H5P_LST_DATASET_XFER_ID_g; diff --git a/test/page_buffer.c b/test/page_buffer.c index c3555aa..7aa8858 100644 --- a/test/page_buffer.c +++ b/test/page_buffer.c @@ -115,7 +115,9 @@ swmr_fapl_augment(hid_t fapl, const char *filename, uint32_t max_lag) HDfprintf(stderr, "H5_basename() failed\n"); return -1; } - HDsnprintf(config.md_file_path, sizeof(config.md_file_path), "%s/%s.shadow", dname, bname); + HDsnprintf(config.md_file_path, sizeof(config.md_file_path), "%s", dname); + HDsnprintf(config.md_file_name, sizeof(config.md_file_name), "%s.shadow", bname); + HDfree(dname); HDfree(bname); @@ -4107,10 +4109,12 @@ error: int main(void) { - hid_t fapl = -1; /* File access property list for data files */ - unsigned nerrors = 0; /* Cumulative error count */ - const char *env_h5_drvr = NULL; /* File Driver value from environment */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + hid_t fapl = -1; /* File access property list for data files */ + unsigned nerrors = 0; /* Cumulative error count */ + const char * env_h5_drvr = NULL; /* File Driver value from environment */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + hid_t driver_id = -1; /* ID for this VFD */ + unsigned long driver_flags = 0; /* VFD feature flags */ h5_reset(); @@ -4119,6 +4123,7 @@ main(void) if (env_h5_drvr == NULL) env_h5_drvr = "nomatch"; +#if 0 /* Temporary skip testing with multi/split drivers: * Page buffering depends on paged aggregation which is * currently disabled for multi/split drivers. @@ -4130,12 +4135,26 @@ main(void) HDputs("Furthermore, VFD SWMR is not (yet) expected to work with multi/split drivers"); HDexit(EXIT_SUCCESS); } /* end if */ +#endif if ((fapl = h5_fileaccess()) < 0) { nerrors++; PUTS_ERROR("Can't get VFD-dependent fapl") } /* end if */ + /* Get the VFD feature flags for this VFD */ + if ((driver_id = H5Pget_driver(fapl)) < 0) + PUTS_ERROR("Can't get driver set in fapl") + if (H5FDdriver_query(driver_id, &driver_flags) < 0) + PUTS_ERROR("Can't query driver flags") + + /* Check whether the VFD feature flag supports VFD SWMR */ + if (!(driver_flags & H5FD_FEAT_SUPPORTS_VFD_SWMR)) { + SKIPPED(); + HDprintf("The %s driver does not support VFD SWMR feature.\n", env_h5_drvr); + HDexit(EXIT_SUCCESS); + } + /* Push API context */ if (H5CX_push() < 0) FAIL_STACK_ERROR diff --git a/test/test_vfd_swmr.sh.in b/test/test_vfd_swmr.sh.in index 08d2706..3c4d9b4 100644 --- a/test/test_vfd_swmr.sh.in +++ b/test/test_vfd_swmr.sh.in @@ -152,14 +152,15 @@ catch_out_err_and_rc() # Check to see if the VFD specified by the HDF5_DRIVER environment variable # supports SWMR. -$utils_testdir/swmr_check_compat_vfd +$utils_testdir/vfd_swmr_check_compat_vfd rc=$? if [ $rc -ne 0 ] ; then echo - echo "The VFD specified by the HDF5_DRIVER environment variable" - echo "does not support SWMR." + echo "Either the VFD specified by the HDF5_DRIVER environment variable" + echo "does not support SWMR or this is parallel HDF5, which does not" + echo "support VFD SWMR due to a lack of page buffer support." echo - echo "SWMR acceptance tests skipped" + echo "VFD SWMR acceptance tests skipped" echo exit 0 fi @@ -1095,6 +1096,9 @@ for options in "-d 1" "-d 1 -F" "-d 2 -l 16" "-d 2 -F -l 16" "-d 1 -t" "-d 1 -t if [ ${do_many_small:-no} = no ]; then continue fi + + rm vfd_swmr_bigset*.h5 2> /dev/null + # # Test many small datasets of two or three dimensions. # @@ -1188,6 +1192,9 @@ for options in "-d 1" "-d 1 -F" "-d 2 -l 10" "-d 2 -F -l 10" "-d 1 -t -l 10" "-d if [ ${do_few_big:-no} = no ]; then continue fi + + rm vfd_swmr_bigset*.h5 2> /dev/null + echo launch vfd_swmr_bigset_writer few big, options $options ......may take some time...... # Launch the auxiliary process for testing NFS if the --enable-aux-process option is enabled for configuration. @@ -1609,12 +1616,12 @@ if [ ${do_gfail_checksum:-no} = yes ]; then rm -f ./$GFAIL_FIFO_READER_TO_WRITER fi - echo launch vfd_swmr_gfail_writer -q -n 420000 ......may take some time...... + echo launch vfd_swmr_gfail_writer -q -n 420000 ...may take some time...error stack messages expected catch_out_err_and_rc vfd_swmr_gfail_checksum_writer \ $testdir/vfd_swmr_gfail_writer -q -m 50 -t 10 -n 4000000 & pid_writer=$! - echo launch vfd_swmr_gfail_reader -n 420000 ......may take some time...... + echo launch vfd_swmr_gfail_reader -n 420000 ...may take some time...error stack messages expected catch_out_err_and_rc vfd_swmr_gfail_checksum_reader \ $testdir/vfd_swmr_gfail_reader -q -m 50 -t 10 -n 4000000 & pid_reader=$! @@ -177,12 +177,15 @@ test_sec2(void) TEST_ERROR if (!(driver_flags & H5FD_FEAT_SUPPORTS_SWMR_IO)) TEST_ERROR + if (!(driver_flags & H5FD_FEAT_SUPPORTS_VFD_SWMR)) + TEST_ERROR if (!(driver_flags & H5FD_FEAT_DEFAULT_VFD_COMPATIBLE)) TEST_ERROR /* Check for extra flags not accounted for above */ - if (driver_flags != (H5FD_FEAT_AGGREGATE_METADATA | H5FD_FEAT_ACCUMULATE_METADATA | H5FD_FEAT_DATA_SIEVE | - H5FD_FEAT_AGGREGATE_SMALLDATA | H5FD_FEAT_POSIX_COMPAT_HANDLE | - H5FD_FEAT_SUPPORTS_SWMR_IO | H5FD_FEAT_DEFAULT_VFD_COMPATIBLE)) + if (driver_flags != + (H5FD_FEAT_AGGREGATE_METADATA | H5FD_FEAT_ACCUMULATE_METADATA | H5FD_FEAT_DATA_SIEVE | + H5FD_FEAT_AGGREGATE_SMALLDATA | H5FD_FEAT_POSIX_COMPAT_HANDLE | H5FD_FEAT_SUPPORTS_SWMR_IO | + H5FD_FEAT_SUPPORTS_VFD_SWMR | H5FD_FEAT_DEFAULT_VFD_COMPATIBLE)) TEST_ERROR if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) @@ -319,12 +322,14 @@ test_core(void) TEST_ERROR if (!(driver_flags & H5FD_FEAT_ALLOW_FILE_IMAGE)) TEST_ERROR + if (!(driver_flags & H5FD_FEAT_SUPPORTS_VFD_SWMR)) + TEST_ERROR if (!(driver_flags & H5FD_FEAT_CAN_USE_FILE_IMAGE_CALLBACKS)) TEST_ERROR /* Check for extra flags not accounted for above */ - if (driver_flags != - (H5FD_FEAT_AGGREGATE_METADATA | H5FD_FEAT_ACCUMULATE_METADATA | H5FD_FEAT_DATA_SIEVE | - H5FD_FEAT_AGGREGATE_SMALLDATA | H5FD_FEAT_ALLOW_FILE_IMAGE | H5FD_FEAT_CAN_USE_FILE_IMAGE_CALLBACKS)) + if (driver_flags != (H5FD_FEAT_AGGREGATE_METADATA | H5FD_FEAT_ACCUMULATE_METADATA | H5FD_FEAT_DATA_SIEVE | + H5FD_FEAT_AGGREGATE_SMALLDATA | H5FD_FEAT_ALLOW_FILE_IMAGE | + H5FD_FEAT_SUPPORTS_VFD_SWMR | H5FD_FEAT_CAN_USE_FILE_IMAGE_CALLBACKS)) TEST_ERROR if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) @@ -2034,13 +2039,16 @@ test_stdio(void) TEST_ERROR if (!(driver_flags & H5FD_FEAT_DATA_SIEVE)) TEST_ERROR + if (!(driver_flags & H5FD_FEAT_SUPPORTS_VFD_SWMR)) + TEST_ERROR if (!(driver_flags & H5FD_FEAT_AGGREGATE_SMALLDATA)) TEST_ERROR if (!(driver_flags & H5FD_FEAT_DEFAULT_VFD_COMPATIBLE)) TEST_ERROR /* Check for extra flags not accounted for above */ - if (driver_flags != (H5FD_FEAT_AGGREGATE_METADATA | H5FD_FEAT_ACCUMULATE_METADATA | H5FD_FEAT_DATA_SIEVE | - H5FD_FEAT_AGGREGATE_SMALLDATA | H5FD_FEAT_DEFAULT_VFD_COMPATIBLE)) + if (driver_flags != + (H5FD_FEAT_AGGREGATE_METADATA | H5FD_FEAT_ACCUMULATE_METADATA | H5FD_FEAT_DATA_SIEVE | + H5FD_FEAT_SUPPORTS_VFD_SWMR | H5FD_FEAT_AGGREGATE_SMALLDATA | H5FD_FEAT_DEFAULT_VFD_COMPATIBLE)) TEST_ERROR if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) @@ -2158,12 +2166,15 @@ test_windows(void) TEST_ERROR if (!(driver_flags & H5FD_FEAT_SUPPORTS_SWMR_IO)) TEST_ERROR + if (!(driver_flags & H5FD_FEAT_SUPPORTS_VFD_SWMR)) + TEST_ERROR if (!(driver_flags & H5FD_FEAT_DEFAULT_VFD_COMPATIBLE)) TEST_ERROR /* Check for extra flags not accounted for above */ - if (driver_flags != (H5FD_FEAT_AGGREGATE_METADATA | H5FD_FEAT_ACCUMULATE_METADATA | H5FD_FEAT_DATA_SIEVE | - H5FD_FEAT_AGGREGATE_SMALLDATA | H5FD_FEAT_POSIX_COMPAT_HANDLE | - H5FD_FEAT_SUPPORTS_SWMR_IO | H5FD_FEAT_DEFAULT_VFD_COMPATIBLE)) + if (driver_flags != + (H5FD_FEAT_AGGREGATE_METADATA | H5FD_FEAT_ACCUMULATE_METADATA | H5FD_FEAT_DATA_SIEVE | + H5FD_FEAT_AGGREGATE_SMALLDATA | H5FD_FEAT_POSIX_COMPAT_HANDLE | H5FD_FEAT_SUPPORTS_SWMR_IO | + H5FD_FEAT_SUPPORTS_VFD_SWMR | H5FD_FEAT_DEFAULT_VFD_COMPATIBLE)) TEST_ERROR if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) diff --git a/test/vfd_swmr.c b/test/vfd_swmr.c index e7eb3da..2db2245 100644 --- a/test/vfd_swmr.c +++ b/test/vfd_swmr.c @@ -16,8 +16,12 @@ * * Tests the VFD SWMR Feature. * + * Note: Relevant tests in this file are modified to reflect the + * changes to the fapl for VDS. See latest RFC. + * *************************************************************/ +#include "H5queue.h" #include "h5test.h" #include "vfd_swmr_common.h" @@ -38,21 +42,33 @@ #include "H5FDpkg.h" #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 FILENAME "vfd_swmr_file" +#define FILENAME2 "vfd_swmr_file2.h5" +#define FILENAME3 "vfd_swmr_file3.h5" +#define FILENAME4 "vfd_swmr_file4.h5" +#define FNAME "non_vfd_swmr_file" + +static const char *namebases[] = {FILENAME, FILENAME2, FILENAME3, FNAME, NULL}; +#define namebase FILENAME +#define namebase2 FILENAME2 +#define namebase3 FILENAME3 +#define namebase4 FILENAME4 +#define non_namebase FNAME + +/* FILENAME */ +#define MD_FILENAME "vfd_swmr_metadata_file" +#define UD_FILENAME "vfd_swmr_updater_file" + +/* FILENAME2 */ #define MD_FILENAME2 "vfd_swmr_metadata_file2" -#define FILENAME3 "vfd_swmr_file3.h5" +/* FILENAME3 */ #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" +/* FILENAME4 */ +#define MD_FILE "vfd_swmr_md_file" +#define UD_FILE "vfd_swmr_ud_file" #define FILE_NAME_LEN 1024 @@ -80,19 +96,70 @@ #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_fapl(hid_t orig_fapl); +static unsigned test_file_fapl(hid_t orig_fapl); +static unsigned test_shadow_index_lookup(void); + +static unsigned test_writer_md(hid_t orig_fapl); +static unsigned test_writer_create_open_flush(hid_t orig_fapl); + +static unsigned test_enable_disable_eot(hid_t orig_fapl); +static unsigned test_enable_disable_eot_concur(hid_t orig_fapl); + +static unsigned test_file_end_tick(hid_t orig_fapl); +static unsigned test_file_end_tick_concur(hid_t orig_fapl); -static unsigned test_updater_flags(void); -static unsigned test_updater_flags_same_file_opens(void); +static unsigned test_same_file_opens(hid_t orig_fapl, hbool_t presume); + +static unsigned test_multiple_file_opens(hid_t orig_fapl); +static unsigned test_multiple_file_opens_concur(hid_t orig_fapl); + +static unsigned test_reader_md_concur(hid_t orig_fapl); + +static unsigned test_make_believe_multiple_file_opens_concur(hid_t orig_fapl); +static unsigned test_auto_generate_md(hid_t orig_fapl, const char *md_path); +static unsigned test_long_md_path_name(hid_t orig_fapl); +static unsigned test_auto_long_md_path_name(hid_t orig_fapl); + +static unsigned test_updater_flags(hid_t orig_fapl); +static unsigned test_updater_flags_same_file_opens(hid_t orig_fapl); static herr_t verify_updater_flags(char *ud_name, uint16_t expected_flags); +static unsigned test_updater_generate_md_checksums(hid_t orig_fapl, hbool_t file_create); 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); + +/*------------------------------------------------------------------------- + * + * Function vfd_swmr_fapl_augment() + * A Helper routine to set up fapl for VFD SWMR + * + *------------------------------------------------------------------------- + */ +static int +vfd_swmr_fapl_augment(hid_t fapl, bool use_latest_format, bool only_meta_pages, size_t page_buf_size, + H5F_vfd_swmr_config_t *config) +{ + if (use_latest_format) { + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + return -1; + } + else { /* Currently this is used only for old-styled group implementation tests.*/ + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST) < 0) + return -1; + } + + /* Enable page buffering */ + if (H5Pset_page_buffer_size(fapl, page_buf_size, only_meta_pages ? 100 : 0, 0) < 0) + return -1; + + /* Enable VFD SWMR configuration */ + if (H5Pset_vfd_swmr_config(fapl, config) < 0) + return -1; + + return 0; +} /* vfd_swmr_fapl_augment() */ /*------------------------------------------------------------------------- * Function: test_fapl() @@ -103,11 +170,8 @@ static unsigned test_updater_generate_md_checksums(hbool_t file_create); * --tick_len: should be >= 0 * --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. @@ -120,7 +184,7 @@ static unsigned test_updater_generate_md_checksums(hbool_t file_create); *------------------------------------------------------------------------- */ static unsigned -test_fapl(void) +test_fapl(hid_t orig_fapl) { hid_t fapl = H5I_INVALID_HID; /* File access property list */ H5F_vfd_swmr_config_t *my_config = NULL; /* Configuration for VFD SWMR */ @@ -128,6 +192,9 @@ test_fapl(void) TESTING("Configure VFD SWMR with fapl"); + if ((fapl = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; + /* Allocate memory for the configuration structure */ if ((my_config = HDmalloc(sizeof(*my_config))) == NULL) FAIL_STACK_ERROR; @@ -182,16 +249,8 @@ test_fapl(void) /* Set valid md_pages_reserved */ my_config->md_pages_reserved = 2; - /* 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->writer = TRUE; - my_config->writer = TRUE; /* Should fail: at least one of maintain_metadata_file and generate_updater_files must be true */ H5E_BEGIN_TRY { @@ -203,16 +262,8 @@ test_fapl(void) 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 { @@ -222,8 +273,8 @@ test_fapl(void) if (ret >= 0) TEST_ERROR; - /* Set md_file_path */ - HDstrcpy(my_config->md_file_path, MD_FILENAME); + /* Set md_file_name */ + HDstrcpy(my_config->md_file_name, MD_FILENAME); my_config->generate_updater_files = FALSE; /* Should succeed in setting the configuration info */ @@ -244,7 +295,9 @@ test_fapl(void) TEST_ERROR; if (my_config->generate_updater_files) TEST_ERROR; - if (HDstrcmp(my_config->md_file_path, MD_FILENAME) != 0) + + /* Check md_file_name instead of md_file_path */ + if (HDstrcmp(my_config->md_file_name, MD_FILENAME) != 0) TEST_ERROR; my_config->generate_updater_files = TRUE; @@ -269,7 +322,9 @@ test_fapl(void) TEST_ERROR; if (!my_config->maintain_metadata_file) TEST_ERROR; - if (HDstrcmp(my_config->md_file_path, MD_FILENAME) != 0) + + /* Check md_file_name instead of md_file_path */ + if (HDstrcmp(my_config->md_file_name, MD_FILENAME) != 0) TEST_ERROR; /* Close the file access property list */ @@ -314,13 +369,14 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_file_fapl(void) +test_file_fapl(hid_t orig_fapl) { + char filename[FILE_NAME_LEN]; /* Filename to use */ hid_t fid = H5I_INVALID_HID; /* File ID */ hid_t fid2 = H5I_INVALID_HID; /* File ID */ hid_t fcpl = H5I_INVALID_HID; /* File creation property list ID */ - hid_t fapl1 = H5I_INVALID_HID; /* File access property list ID */ - hid_t fapl2 = H5I_INVALID_HID; /* File access property list ID */ + hid_t fapl1 = H5I_INVALID_HID; /* File access property list ID associated with the file */ + hid_t fapl2 = H5I_INVALID_HID; /* File access property list ID associated with the file */ hid_t file_fapl = H5I_INVALID_HID; /* File access property list ID associated with the file */ H5F_vfd_swmr_config_t *config1 = NULL; /* Configuration for VFD SWMR */ H5F_vfd_swmr_config_t *config2 = NULL; /* Configuration for VFD SWMR */ @@ -328,8 +384,10 @@ test_file_fapl(void) TESTING("VFD SWMR configuration for the file and fapl"); + h5_fixname(namebase, orig_fapl, filename, sizeof(filename)); + /* Should succeed without VFD SWMR configured */ - if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Close the file */ @@ -348,19 +406,22 @@ test_file_fapl(void) * 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); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config1, 4, 7, FALSE, FALSE, TRUE, FALSE, TRUE, 2, NULL, 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; + if ((fapl1 = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; + + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl1, FALSE, FALSE, 0, config1) < 0) + FAIL_STACK_ERROR; /* Should fail to create: file access is writer but VFD SWMR config is reader */ H5E_BEGIN_TRY { - fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl1); + fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl1); } H5E_END_TRY; if (fid >= 0) @@ -373,20 +434,22 @@ test_file_fapl(void) * 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); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config1, 4, 7, FALSE, TRUE, TRUE, TRUE, TRUE, 2, NULL, 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 = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; - if (fapl1 == H5I_INVALID_HID) - TEST_ERROR; + /* use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl1, FALSE, FALSE, 0, config1) < 0) + FAIL_STACK_ERROR; /* Should fail to create: page buffering and paged aggregation not enabled */ H5E_BEGIN_TRY { - fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl1); + fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl1); } H5E_END_TRY; if (fid >= 0) @@ -400,7 +463,7 @@ test_file_fapl(void) /* Should fail to create: no page buffering */ H5E_BEGIN_TRY { - fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl1); + fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl1); } H5E_END_TRY; if (fid >= 0) @@ -413,18 +476,20 @@ test_file_fapl(void) * 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); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config1, 4, 7, FALSE, TRUE, TRUE, FALSE, TRUE, 2, NULL, 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 = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; - if (fapl1 == H5I_INVALID_HID) - TEST_ERROR; + /* use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl1, FALSE, FALSE, 4096, config1) < 0) + FAIL_STACK_ERROR; /* Should succeed to create the file: paged aggregation and page buffering enabled */ - if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl1)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl1)) < 0) TEST_ERROR; /* Get the file's file access property list */ @@ -448,14 +513,14 @@ test_file_fapl(void) /* Should fail to open: file access is reader but VFD SWMR config is writer */ H5E_BEGIN_TRY { - fid = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl1); + fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl1); } H5E_END_TRY; if (fid >= 0) TEST_ERROR; /* Should succeed to open: file access and VFD SWMR config are consistent */ - if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl1)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl1)) < 0) TEST_ERROR; /* Get the file's file access property list */ @@ -485,18 +550,20 @@ test_file_fapl(void) * 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); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config2, 4, 10, FALSE, TRUE, TRUE, FALSE, TRUE, 2, NULL, 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 = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; - if (fapl2 == H5I_INVALID_HID) - TEST_ERROR; + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl2, FALSE, FALSE, 4096, config2) < 0) + FAIL_STACK_ERROR; /* Should succeed to open the file as VFD SWMR writer */ - if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl2)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl2)) < 0) TEST_ERROR; /* Get the file's file access property list */ @@ -525,21 +592,23 @@ test_file_fapl(void) * 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); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config1, 3, 8, FALSE, TRUE, TRUE, FALSE, TRUE, 3, NULL, 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 = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; - if (fapl1 == H5I_INVALID_HID) - TEST_ERROR; + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl1, FALSE, FALSE, 4096, config1) < 0) + FAIL_STACK_ERROR; /* Re-open the same file with config1 */ /* Should fail to open since config1 is different from config2 setting */ H5E_BEGIN_TRY { - fid2 = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl1); + fid2 = H5Fopen(filename, H5F_ACC_RDWR, fapl1); } H5E_END_TRY; if (fid2 >= 0) @@ -553,17 +622,21 @@ test_file_fapl(void) * 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); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config1, 4, 10, FALSE, TRUE, TRUE, FALSE, TRUE, 2, NULL, 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 = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; - if (fapl1 == H5I_INVALID_HID) - TEST_ERROR; + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl1, FALSE, FALSE, 4096, config1) < 0) + FAIL_STACK_ERROR; /* Re-open the same file as VFD SWMR writer */ /* Should succeed since config1 is same as the setting in config2 */ - if ((fid2 = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl1)) < 0) + if ((fid2 = H5Fopen(filename, H5F_ACC_RDWR, fapl1)) < 0) TEST_ERROR; /* Close fapl1 */ @@ -594,10 +667,6 @@ test_file_fapl(void) if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; - if (H5Pclose(fapl2) < 0) - FAIL_STACK_ERROR; - if (H5Pclose(file_fapl) < 0) - FAIL_STACK_ERROR; if (H5Pclose(fcpl) < 0) FAIL_STACK_ERROR; @@ -612,10 +681,10 @@ test_file_fapl(void) error: H5E_BEGIN_TRY { - H5Pclose(fapl1); - H5Pclose(fapl2); H5Pclose(file_fapl); H5Pclose(fcpl); + H5Pclose(fapl1); + H5Pclose(fapl2); H5Fclose(fid); H5Fclose(fid2); } @@ -642,8 +711,11 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_file_end_tick(void) +test_file_end_tick(hid_t orig_fapl) { + char filename[FILE_NAME_LEN]; /* Filename to use */ + char filename2[FILE_NAME_LEN]; /* Filename to use */ + char filename3[FILE_NAME_LEN]; /* Filename to use */ hid_t fid1 = H5I_INVALID_HID; /* File ID */ hid_t fid2 = H5I_INVALID_HID; /* File ID */ hid_t fid3 = H5I_INVALID_HID; /* File ID */ @@ -662,8 +734,12 @@ test_file_end_tick(void) TESTING("H5Fvfd_swmr_end_tick()"); + h5_fixname(namebase, orig_fapl, filename, sizeof(filename)); + h5_fixname(namebase2, orig_fapl, filename2, sizeof(filename2)); + h5_fixname(namebase3, orig_fapl, filename3, sizeof(filename3)); + /* Create a file without VFD SWMR configured */ - if ((fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid1 = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Should fail to trigger EOT */ @@ -691,43 +767,49 @@ test_file_end_tick(void) * 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); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config1, 10, 15, FALSE, TRUE, TRUE, FALSE, TRUE, 2, NULL, 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 = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; - if (fapl1 == H5I_INVALID_HID) - TEST_ERROR; + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl1, FALSE, FALSE, 4096, config1) < 0) + FAIL_STACK_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); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config2, 5, 6, FALSE, TRUE, TRUE, FALSE, TRUE, 2, NULL, 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 = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; - if (fapl2 == H5I_INVALID_HID) - TEST_ERROR; + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl2, FALSE, FALSE, 4096, config2) < 0) + FAIL_STACK_ERROR; /* * Configured file 3 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, 3, 6, TRUE, TRUE, FALSE, TRUE, 2, MD_FILENAME3, NULL); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config3, 3, 6, FALSE, TRUE, TRUE, FALSE, TRUE, 2, NULL, 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 = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; - if (fapl3 == H5I_INVALID_HID) - TEST_ERROR; + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl3, FALSE, FALSE, 4096, config3) < 0) + FAIL_STACK_ERROR; if ((fcpl = vfd_swmr_create_fcpl(H5F_FSPACE_STRATEGY_PAGE, 4096)) < 0) { HDprintf("vfd_swmr_create_fcpl() failed"); @@ -735,28 +817,28 @@ test_file_end_tick(void) } /* Create file 1 with VFD SWMR writer */ - if ((fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl1)) < 0) + if ((fid1 = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl1)) < 0) TEST_ERROR; /* Keep file 1 opened */ /* Create file 2 with VFD SWMR writer */ - if ((fid2 = H5Fcreate(FILENAME2, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) TEST_ERROR; if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR; /* Create file 3 with VFD SWMR writer */ - if ((fid3 = H5Fcreate(FILENAME3, H5F_ACC_TRUNC, fcpl, fapl3)) < 0) + if ((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, fcpl, fapl3)) < 0) TEST_ERROR; if (H5Fclose(fid3) < 0) FAIL_STACK_ERROR; /* Open file 2 as VFD SWMR writer */ - if ((fid2 = H5Fopen(FILENAME2, H5F_ACC_RDWR, fapl2)) < 0) + if ((fid2 = H5Fopen(filename2, H5F_ACC_RDWR, fapl2)) < 0) TEST_ERROR; /* Open file 3 as VFD SWMR writer */ - if ((fid3 = H5Fopen(FILENAME3, H5F_ACC_RDWR, fapl3)) < 0) + if ((fid3 = H5Fopen(filename3, H5F_ACC_RDWR, fapl3)) < 0) TEST_ERROR; /* Get file pointer for the 3 files */ @@ -879,15 +961,18 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_writer_create_open_flush(void) +test_writer_create_open_flush(hid_t orig_fapl) { - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list */ - hid_t fcpl = -1; /* File creation property list */ - H5F_vfd_swmr_config_t *my_config = NULL; /* Configuration for VFD SWMR */ + char filename[FILE_NAME_LEN]; /* Filename to use */ + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list */ + hid_t fcpl = -1; /* File creation property list */ + H5F_vfd_swmr_config_t *my_config = NULL; /* Configuration for VFD SWMR */ TESTING("Create/Open/Flush an HDF5 file for VFD SWMR"); + h5_fixname(namebase, orig_fapl, filename, sizeof(filename)); + /* Allocate memory for the configuration structure */ if ((my_config = HDmalloc(sizeof(H5F_vfd_swmr_config_t))) == NULL) FAIL_STACK_ERROR; @@ -896,14 +981,17 @@ test_writer_create_open_flush(void) * Set up the 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(my_config, 1, 3, TRUE, TRUE, FALSE, TRUE, 2, MD_FILENAME, NULL); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(my_config, 1, 3, FALSE, TRUE, TRUE, FALSE, TRUE, 2, NULL, MD_FILENAME, NULL); - /* 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 ((fapl = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; + + /* use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl, FALSE, FALSE, 4096, my_config) < 0) + FAIL_STACK_ERROR; if ((fcpl = vfd_swmr_create_fcpl(H5F_FSPACE_STRATEGY_PAGE, 4096)) < 0) { HDprintf("vfd_swmr_create_fcpl() failed"); @@ -911,7 +999,7 @@ test_writer_create_open_flush(void) } /* Create an HDF5 file with VFD SWMR configured */ - if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR; /* Verify info in metadata file when creating the HDF5 file */ @@ -931,7 +1019,7 @@ test_writer_create_open_flush(void) FAIL_STACK_ERROR; /* Re-open the file as VFD SWMR writer */ - if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR; /* Verify info in metadata file when reopening the HDF5 file */ @@ -990,8 +1078,9 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_writer_md(void) +test_writer_md(hid_t orig_fapl) { + char filename[FILE_NAME_LEN]; /* Filename to use */ hid_t fid = H5I_INVALID_HID; /* File ID */ hid_t fapl = H5I_INVALID_HID; /* File access property list */ hid_t fcpl = H5I_INVALID_HID; /* File creation property list */ @@ -1013,18 +1102,23 @@ test_writer_md(void) TESTING("Verify the metadata file for VFD SWMR writer"); + h5_fixname(namebase, orig_fapl, filename, sizeof(filename)); + /* Allocate memory for the configuration structure */ if ((my_config = HDmalloc(sizeof(H5F_vfd_swmr_config_t))) == NULL) 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); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(my_config, 1, 3, FALSE, TRUE, TRUE, FALSE, TRUE, 256, NULL, MD_FILENAME, NULL); - /* 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; + if ((fapl = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; + + /* use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl, FALSE, FALSE, FS_PAGE_SIZE, my_config) < 0) + FAIL_STACK_ERROR; if ((fcpl = vfd_swmr_create_fcpl(H5F_FSPACE_STRATEGY_PAGE, FS_PAGE_SIZE)) < 0) { HDprintf("vfd_swmr_create_fcpl() failed"); @@ -1032,7 +1126,7 @@ test_writer_md(void) } /* Create an HDF5 file with VFD SWMR configured */ - if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR; /* Get a pointer to the internal file object */ @@ -1222,7 +1316,7 @@ error: #ifndef H5_HAVE_UNISTD_H static unsigned -test_reader_md_concur(void) +test_reader_md_concur(hid_t orig_fapl) { /* Output message about test being performed */ TESTING("Verify the metadata file for VFD SWMR reader"); @@ -1233,7 +1327,7 @@ test_reader_md_concur(void) } /* test_reader_md_concur() */ static unsigned -test_multiple_file_opens_concur(void) +test_multiple_file_opens_concur(hid_t orig_fapl) { /* Output message about test being performed */ TESTING("EOT queue entries when opening files concurrently with VFD SWMR"); @@ -1244,7 +1338,7 @@ test_multiple_file_opens_concur(void) } /* test_multiple_file_opens_concur() */ static unsigned -test_disable_enable_eot_concur(void) +test_enable_disable_eot_concur(hid_t orig_fapl) { /* Output message about test being performed */ TESTING("Verify concurrent H5Fvfd_swmr_enable/disable_end_of_tick()"); @@ -1252,10 +1346,10 @@ test_disable_enable_eot_concur(void) HDputs(" Test skipped (unistd.h not present)"); return 0; -} /* test_disable_enble_eot_concur() */ +} /* test_enable_disable_eot_concur() */ static unsigned -test_file_end_tick_concur(void) +test_file_end_tick_concur(hid_t orig_fapl) { /* Output message about test being performed */ TESTING("Verify concurrent H5Fvfd_swmr_end_tick()"); @@ -1263,7 +1357,18 @@ test_file_end_tick_concur(void) HDputs(" Test skipped (unistd.h not present)"); return 0; -} /* test_disable_enble_eot_concur() */ +} /* test_file_end_tick_concur() */ + +static unsigned +test_make_believe_multiple_file_opens_concur(hid_t orig_fapl) +{ + /* Output message about test being performed */ + TESTING("Opening files concurrently as VFD SWMR reader and then as VFD SWMR writer"); + SKIPPED(); + HDputs(" Test skipped (unistd.h not present)"); + return 0; + +} /* test_make_believe_multiple_file_opens_concur() */ #else /* H5_HAVE_UNISTD_H */ @@ -1285,8 +1390,9 @@ test_file_end_tick_concur(void) *------------------------------------------------------------------------- */ static unsigned -test_reader_md_concur(void) +test_reader_md_concur(hid_t orig_fapl) { + char filename[FILE_NAME_LEN]; /* Filename to use */ unsigned i = 0; /* Local index variables */ uint8_t * buf = NULL; /* Data page from the page buffer */ hid_t dcpl = H5I_INVALID_HID; /* Dataset creation property list */ @@ -1319,21 +1425,26 @@ test_reader_md_concur(void) TESTING("Verify the metadata file for VFD SWMR reader"); + h5_fixname(namebase, orig_fapl, filename, sizeof(filename)); + /* Allocate memory for the configuration structure */ if ((config_writer = HDmalloc(sizeof(*config_writer))) == NULL) FAIL_STACK_ERROR; /* - * Set up the VFD SWMR configuration + page buffering + * Set up VFD SWMR configuration as writer in fapl_writer */ - /* 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); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config_writer, 1, 3, FALSE, TRUE, TRUE, FALSE, TRUE, 256, NULL, 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); - if (fapl_writer == H5I_INVALID_HID) + if ((fapl_writer = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; + + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl_writer, FALSE, FALSE, FS_PAGE_SIZE, config_writer) < 0) TEST_ERROR; if ((fcpl = vfd_swmr_create_fcpl(H5F_FSPACE_STRATEGY_PAGE, FS_PAGE_SIZE)) < 0) { @@ -1342,7 +1453,7 @@ test_reader_md_concur(void) } /* Create an HDF5 file with VFD SWMR configured */ - if ((fid_writer = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl_writer)) < 0) + if ((fid_writer = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl_writer)) < 0) FAIL_STACK_ERROR; /* Close the file */ @@ -1400,21 +1511,24 @@ test_reader_md_concur(void) HDexit(EXIT_FAILURE); /* - * Set up the VFD SWMR configuration as reader + page buffering + * Set up VFD SWMR configuration as reader in fapl_reader */ - /* 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); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config_reader, 1, 3, FALSE, FALSE, TRUE, FALSE, TRUE, 256, NULL, 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 = H5Pcopy(orig_fapl)) < 0) + HDexit(EXIT_FAILURE); - if (fapl_reader == H5I_INVALID_HID) - TEST_ERROR; + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl_reader, FALSE, FALSE, FS_PAGE_SIZE, config_reader) < 0) + HDexit(EXIT_FAILURE); /* Open the test file as reader */ - if ((fid_reader = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl_reader)) < 0) + if ((fid_reader = H5Fopen(filename, H5F_ACC_RDONLY, fapl_reader)) < 0) HDexit(EXIT_FAILURE); /* Get file pointer */ @@ -1606,7 +1720,7 @@ test_reader_md_concur(void) */ /* Open as VFD SWMR writer */ - if ((fid_writer = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl_writer)) < 0) + if ((fid_writer = H5Fopen(filename, H5F_ACC_RDWR, fapl_writer)) < 0) FAIL_STACK_ERROR; /* Get the file pointer */ @@ -1923,8 +2037,10 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_multiple_file_opens_concur(void) +test_multiple_file_opens_concur(hid_t orig_fapl) { + char filename[FILE_NAME_LEN]; /* Filename to use */ + char filename2[FILE_NAME_LEN]; /* Filename to use */ hid_t fcpl = H5I_INVALID_HID; pid_t tmppid; /* Child process ID returned by waitpid */ pid_t childpid = 0; /* Child process ID */ @@ -1945,13 +2061,16 @@ test_multiple_file_opens_concur(void) TESTING("EOT queue entries when opening files concurrently with VFD SWMR"); + h5_fixname(namebase, orig_fapl, filename, sizeof(filename)); + h5_fixname(namebase2, orig_fapl, filename2, sizeof(filename2)); + 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) + if ((fid1 = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Close the file */ @@ -1959,7 +2078,7 @@ test_multiple_file_opens_concur(void) FAIL_STACK_ERROR; /* Create file B */ - if ((fid2 = H5Fcreate(FILENAME2, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Close the file */ @@ -2008,20 +2127,23 @@ test_multiple_file_opens_concur(void) if ((config_writer = HDmalloc(sizeof(*config_writer))) == NULL) HDexit(EXIT_FAILURE); - /* Set the VFD SWMR configuration in fapl_writer + page buffering */ + /* Set up VFD SWMR configuration in fapl_writer */ - /* 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); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config_writer, 1, 3, FALSE, TRUE, TRUE, FALSE, TRUE, 256, NULL, 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 = H5Pcopy(orig_fapl)) < 0) + HDexit(EXIT_FAILURE); - if (fapl_writer == H5I_INVALID_HID) + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl_writer, FALSE, FALSE, FS_PAGE_SIZE, config_writer) < 0) HDexit(EXIT_FAILURE); /* Open file B as VFD SWMR writer */ - if ((fid_writer = H5Fopen(FILENAME2, H5F_ACC_RDWR, fapl_writer)) < 0) + if ((fid_writer = H5Fopen(filename2, H5F_ACC_RDWR, fapl_writer)) < 0) HDexit(EXIT_FAILURE); /* Send notification 2 to parent that file B is open */ @@ -2077,18 +2199,20 @@ test_multiple_file_opens_concur(void) if ((config1 = HDmalloc(sizeof(*config1))) == NULL) 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(config1, 7, 10, TRUE, TRUE, FALSE, TRUE, 256, MD_FILENAME, NULL); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config1, 7, 10, FALSE, TRUE, TRUE, FALSE, TRUE, 256, NULL, 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 = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; - if (fapl1 == H5I_INVALID_HID) + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl1, FALSE, FALSE, FS_PAGE_SIZE, config1) < 0) FAIL_STACK_ERROR; /* Open file A as VFD SWMR writer */ - if ((fid1 = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl1)) < 0) + if ((fid1 = H5Fopen(filename, H5F_ACC_RDWR, fapl1)) < 0) FAIL_STACK_ERROR; /* Get a pointer to the internal file object */ @@ -2120,18 +2244,20 @@ test_multiple_file_opens_concur(void) if ((config2 = HDmalloc(sizeof(*config2))) == NULL) 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(config2, 1, 3, FALSE, TRUE, FALSE, TRUE, 256, MD_FILENAME2, NULL); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config2, 1, 3, FALSE, FALSE, TRUE, FALSE, TRUE, 256, NULL, 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 = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; - if (fapl2 == H5I_INVALID_HID) + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl2, FALSE, FALSE, FS_PAGE_SIZE, config2) < 0) FAIL_STACK_ERROR; /* Open file B as VFD SWMR reader */ - if ((fid2 = H5Fopen(FILENAME2, H5F_ACC_RDONLY, fapl2)) < 0) + if ((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl2)) < 0) FAIL_STACK_ERROR; /* Get a pointer to the internal file object */ @@ -2220,8 +2346,8 @@ error: * Function: test_enable_disable_eot_concur() * * Purpose: Verify the public routines: - * H5Fvfd_swmr_disable_end_of_tick() * H5Fvfd_swmr_enable_end_of_tick() + * H5Fvfd_swmr_disable_end_of_tick() * enables/disables EOT when the files are opened * concurrently. * @@ -2233,8 +2359,9 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_disable_enable_eot_concur(void) +test_enable_disable_eot_concur(hid_t orig_fapl) { + char filename[FILE_NAME_LEN]; /* Filename to use */ hid_t fcpl = H5I_INVALID_HID; /* File creation property list */ hid_t fid_writer = H5I_INVALID_HID; /* File ID for writer */ hid_t fapl_writer = H5I_INVALID_HID; /* File access property list for writer */ @@ -2251,6 +2378,8 @@ test_disable_enable_eot_concur(void) TESTING("Verify concurrent H5Fvfd_swmr_enable/disable_end_of_tick()"); + h5_fixname(namebase, orig_fapl, filename, sizeof(filename)); + /* Allocate memory for the configuration structure */ if ((config_writer = HDmalloc(sizeof(*config_writer))) == NULL) FAIL_STACK_ERROR; @@ -2259,14 +2388,16 @@ test_disable_enable_eot_concur(void) * Set up the 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(config_writer, 1, 3, TRUE, TRUE, FALSE, TRUE, 256, MD_FILENAME, NULL); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config_writer, 1, 3, FALSE, TRUE, TRUE, FALSE, TRUE, 256, NULL, 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); + if ((fapl_writer = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; - if (fapl_writer == H5I_INVALID_HID) + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl_writer, FALSE, FALSE, FS_PAGE_SIZE, config_writer) < 0) FAIL_STACK_ERROR; if ((fcpl = vfd_swmr_create_fcpl(H5F_FSPACE_STRATEGY_PAGE, FS_PAGE_SIZE)) < 0) { @@ -2275,7 +2406,7 @@ test_disable_enable_eot_concur(void) } /* Create an HDF5 file with VFD SWMR configured */ - if ((fid_writer = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl_writer)) < 0) + if ((fid_writer = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl_writer)) < 0) FAIL_STACK_ERROR; /* Close the file */ @@ -2339,26 +2470,29 @@ test_disable_enable_eot_concur(void) * 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); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config_reader, 1, 3, FALSE, FALSE, TRUE, FALSE, TRUE, 256, NULL, 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 = H5Pcopy(orig_fapl)) < 0) + HDexit(EXIT_FAILURE); - if (fapl_reader == H5I_INVALID_HID) - FAIL_STACK_ERROR; + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl_reader, FALSE, FALSE, FS_PAGE_SIZE, config_reader) < 0) + HDexit(EXIT_FAILURE); /* Open the test file as reader */ - if ((fid_reader = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl_reader)) < 0) + if ((fid_reader = H5Fopen(filename, H5F_ACC_RDONLY, fapl_reader)) < 0) HDexit(EXIT_FAILURE); /* Open the same test file as reader (a second time) */ - if ((fid_reader2 = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl_reader)) < 0) + if ((fid_reader2 = H5Fopen(filename, H5F_ACC_RDONLY, fapl_reader)) < 0) HDexit(EXIT_FAILURE); /* Open the same test file as reader (a third time) */ - if ((fid_reader3 = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl_reader)) < 0) + if ((fid_reader3 = H5Fopen(filename, H5F_ACC_RDONLY, fapl_reader)) < 0) HDexit(EXIT_FAILURE); /* Verify the # of files on the EOT queue is 3 */ @@ -2449,7 +2583,7 @@ test_disable_enable_eot_concur(void) */ /* Open as VFD SWMR writer */ - if ((fid_writer = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl_writer)) < 0) + if ((fid_writer = H5Fopen(filename, H5F_ACC_RDWR, fapl_writer)) < 0) FAIL_STACK_ERROR; /* Send notification 1 to reader to start verification */ @@ -2506,7 +2640,7 @@ error: H5E_END_TRY; return 1; -} /* test_disable_enable_eot_concur() */ +} /* test_enable_disable_eot_concur() */ /*------------------------------------------------------------------------- * Function: test_file_end_tick_concur() @@ -2523,8 +2657,9 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_file_end_tick_concur(void) +test_file_end_tick_concur(hid_t orig_fapl) { + char filename[FILE_NAME_LEN]; /* Filename to use */ hid_t fcpl = H5I_INVALID_HID; /* File creation property list */ hid_t fid_writer = H5I_INVALID_HID; /* File ID for writer */ hid_t fapl_writer = H5I_INVALID_HID; /* File access property list for writer */ @@ -2541,22 +2676,26 @@ test_file_end_tick_concur(void) TESTING("Verify concurrent H5Fvfd_swmr_end_tick()"); + h5_fixname(namebase, orig_fapl, filename, sizeof(filename)); + /* Allocate memory for the configuration structure */ if ((config_writer = HDmalloc(sizeof(*config_writer))) == NULL) FAIL_STACK_ERROR; /* - * Set up the VFD SWMR configuration + page buffering + * Set up VFD SWMR configuration as writer in fapl_writer */ - /* 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); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config_writer, 1, 3, FALSE, TRUE, TRUE, FALSE, TRUE, 256, NULL, 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); + if ((fapl_writer = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; - if (fapl_writer == H5I_INVALID_HID) + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl_writer, FALSE, FALSE, FS_PAGE_SIZE, config_writer) < 0) FAIL_STACK_ERROR; if ((fcpl = vfd_swmr_create_fcpl(H5F_FSPACE_STRATEGY_PAGE, FS_PAGE_SIZE)) < 0) { @@ -2565,7 +2704,7 @@ test_file_end_tick_concur(void) } /* Create an HDF5 file with VFD SWMR configured */ - if ((fid_writer = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl_writer)) < 0) + if ((fid_writer = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl_writer)) < 0) FAIL_STACK_ERROR; /* Close the file */ @@ -2625,26 +2764,29 @@ test_file_end_tick_concur(void) if ((config_reader = HDmalloc(sizeof(*config_reader))) == NULL) HDexit(EXIT_FAILURE); - /* 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); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config_reader, 1, 3, FALSE, FALSE, TRUE, FALSE, TRUE, 256, NULL, 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 = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; - if (fapl_reader == H5I_INVALID_HID) + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl_reader, FALSE, FALSE, FS_PAGE_SIZE, config_reader) < 0) FAIL_STACK_ERROR; /* Open the test file as reader */ - if ((fid_reader1 = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl_reader)) < 0) + if ((fid_reader1 = H5Fopen(filename, H5F_ACC_RDONLY, fapl_reader)) < 0) HDexit(EXIT_FAILURE); /* Open the same test file as reader (a second time) */ - if ((fid_reader2 = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl_reader)) < 0) + if ((fid_reader2 = H5Fopen(filename, H5F_ACC_RDONLY, fapl_reader)) < 0) HDexit(EXIT_FAILURE); /* Open the same test file as reader (a third time) */ - if ((fid_reader3 = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl_reader)) < 0) + if ((fid_reader3 = H5Fopen(filename, H5F_ACC_RDONLY, fapl_reader)) < 0) HDexit(EXIT_FAILURE); /* Get file pointer */ @@ -2721,7 +2863,7 @@ test_file_end_tick_concur(void) */ /* Open as VFD SWMR writer */ - if ((fid_writer = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl_writer)) < 0) + if ((fid_writer = H5Fopen(filename, H5F_ACC_RDWR, fapl_writer)) < 0) FAIL_STACK_ERROR; /* Send notification 1 to reader to start verification */ @@ -2780,6 +2922,274 @@ error: return 1; } /* test_file_end_tick_concur() */ +/*------------------------------------------------------------------------- + * Function: test_make_believe_multiple_file_opens_concur() + * + * Purpose: Verify the following: + * A) Open a file as VFD SWMR reader + * --there is no metadata file i.e. make-believe is enabled + * B) Open the file as VFD SWMR writer + * --metadata file is created + * C) Trigger end of tick processing for the reader in (A) + * --Verify make-believe is disabled + * + * Return: 0 if test is successful + * 1 if test fails + * + * Programmer: Vailin Choi; 4/25/2022 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_make_believe_multiple_file_opens_concur(hid_t orig_fapl) +{ + char filename[FILE_NAME_LEN]; /* Filename to use */ + hid_t fcpl = H5I_INVALID_HID; + pid_t tmppid; /* Child process ID returned by waitpid */ + pid_t childpid = 0; /* Child process ID */ + int child_status; /* Status passed to waitpid */ + int child_wait_option = 0; /* Options passed to waitpid */ + int child_exit_val; /* Exit status of the child */ + int parent_pfd[2]; /* Pipe for parent process as writer */ + int child_pfd[2]; /* Pipe for child process as reader */ + int notify = 0; /* Notification between parent and child */ + hid_t fid = H5I_INVALID_HID; + hid_t fapl = H5I_INVALID_HID; + H5F_vfd_swmr_config_t *config = NULL; /* VFD SWMR configuration */ + H5F_t * f; /* File pointer */ + + TESTING("Verify make-believe-data when opening files concurrently as VFD SWMR reader and then as VFD " + "SWMR writer"); + + h5_fixname(namebase, orig_fapl, filename, sizeof(filename)); + + 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 ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* Close the file */ + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR; + + /* Create 2 pipes */ + if (HDpipe(parent_pfd) < 0) + FAIL_STACK_ERROR; + + if (HDpipe(child_pfd) < 0) + FAIL_STACK_ERROR; + + /* Fork child process */ + if ((childpid = HDfork()) < 0) + FAIL_STACK_ERROR; + + /* + * Child process + */ + if (childpid == 0) { + int child_notify = 0; /* Notification between child and parent */ + hid_t fid_writer = H5I_INVALID_HID; /* File ID for writer */ + hid_t fapl_writer = H5I_INVALID_HID; /* File access property list for writer */ + H5F_vfd_swmr_config_t *config_writer = NULL; /* VFD SWMR configuration for reader */ + + /* Close unused write end for writer pipe */ + if (HDclose(parent_pfd[1]) < 0) + HDexit(EXIT_FAILURE); + + /* Close unused read end for reader pipe */ + if (HDclose(child_pfd[0]) < 0) + HDexit(EXIT_FAILURE); + + /* + * Set up and open file A as VFD SWMR writer + */ + + /* Wait for notification 1 from parent before opening file A */ + while (child_notify != 1) { + if (HDread(parent_pfd[0], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + } + + /* Allocate memory for VFD SMWR configuration */ + if ((config_writer = HDmalloc(sizeof(*config_writer))) == NULL) + HDexit(EXIT_FAILURE); + + /* Set up VFD SWMR configuration as writer in fapl_writer */ + + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config_writer, 1, 3, TRUE, TRUE, TRUE, FALSE, TRUE, 256, NULL, MD_FILENAME, + NULL); + + if ((fapl_writer = H5Pcopy(orig_fapl)) < 0) + HDexit(EXIT_FAILURE); + + /* use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl_writer, FALSE, FALSE, FS_PAGE_SIZE, config_writer) < 0) + HDexit(EXIT_FAILURE); + + /* Open file A as VFD SWMR writer */ + if ((fid_writer = H5Fopen(filename, H5F_ACC_RDWR, fapl_writer)) < 0) + HDexit(EXIT_FAILURE); + + /* Send notification 2 to parent that file A is open */ + child_notify = 2; + if (HDwrite(child_pfd[1], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + + /* Wait for notification 3 from parent before closing file A */ + while (child_notify != 3) { + if (HDread(parent_pfd[0], &child_notify, sizeof(int)) < 0) + HDexit(EXIT_FAILURE); + } + + HDfree(config_writer); + + /* Close the file */ + if (H5Fclose(fid_writer) < 0) + HDexit(EXIT_FAILURE); + if (H5Pclose(fapl_writer) < 0) + HDexit(EXIT_FAILURE); + + /* Close the pipes */ + if (HDclose(parent_pfd[0]) < 0) + HDexit(EXIT_FAILURE); + if (HDclose(child_pfd[1]) < 0) + HDexit(EXIT_FAILURE); + + HDexit(EXIT_SUCCESS); + } /* end child process */ + + /* + * Parent process + */ + + /* Close unused read end for writer pipe */ + if (HDclose(parent_pfd[0]) < 0) + FAIL_STACK_ERROR; + + /* Close unused write end for reader pipe */ + if (HDclose(child_pfd[1]) < 0) + FAIL_STACK_ERROR; + + /* + * Set up and open file A as VFD SWMR reader + */ + + /* Allocate memory for VFD SWMR configuration */ + if ((config = HDmalloc(sizeof(*config))) == NULL) + FAIL_STACK_ERROR; + + /* Set up VFD SWMR configuration as reader in fapl */ + + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config, 7, 10, TRUE, FALSE, TRUE, FALSE, TRUE, 256, NULL, MD_FILENAME, NULL); + + if ((fapl = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; + + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl, FALSE, FALSE, FS_PAGE_SIZE, config) < 0) + FAIL_STACK_ERROR; + + /* Open file A as VFD SWMR reader */ + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + FAIL_STACK_ERROR; + + /* Get a pointer to the internal file object */ + if (NULL == (f = H5VL_object(fid))) + FAIL_STACK_ERROR; + + /* Verify make-believe: should be true */ + if (!H5FD_vfd_swmr_get_make_believe(f->shared->lf)) { + printf("Make believe for initial open should be true\n"); + TEST_ERROR; + } + + /* Send notification 1 to child to open file A as VFD SWMR writer */ + notify = 1; + if (HDwrite(parent_pfd[1], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; + + /* Wait for notification 2 from child that file A is open */ + while (notify != 2) { + if (HDread(child_pfd[0], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; + } + + /* Trigger end of tick processing */ + if (H5Fvfd_swmr_end_tick(fid) < 0) + FAIL_STACK_ERROR; + + /* Verify make-believe: should be false */ + if (H5FD_vfd_swmr_get_make_believe(f->shared->lf)) { + printf("Make believe after end of tick processing should be false\n"); + TEST_ERROR; + } + + /* Send notification 3 to child to close file A */ + notify = 3; + if (HDwrite(parent_pfd[1], ¬ify, sizeof(int)) < 0) + FAIL_STACK_ERROR; + + /* + * Done + */ + + /* Close the pipes */ + if (HDclose(parent_pfd[1]) < 0) + FAIL_STACK_ERROR; + if (HDclose(child_pfd[0]) < 0) + FAIL_STACK_ERROR; + + /* Wait for child process to complete */ + if ((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) + FAIL_STACK_ERROR; + + /* Check exit status of child process */ + if (WIFEXITED(child_status)) { + if ((child_exit_val = WEXITSTATUS(child_status)) != 0) + TEST_ERROR; + } + else { /* child process terminated abnormally */ + TEST_ERROR; + } + + /* Closing */ + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(fapl) < 0) + FAIL_STACK_ERROR; + if (H5Pclose(fcpl) < 0) + FAIL_STACK_ERROR; + + /* Free resources */ + HDfree(config); + + PASSED(); + return 0; + +error: + HDfree(config); + + H5E_BEGIN_TRY + { + H5Pclose(fapl); + H5Fclose(fid); + H5Pclose(fcpl); + } + H5E_END_TRY; + + return 1; +} /* test_make_believe_multiple_file_opens_concur() */ + #endif /* H5_HAVE_UNISTD_H */ /*------------------------------------------------------------------------- @@ -2795,23 +3205,29 @@ error: * *------------------------------------------------------------------------- */ - static unsigned -test_multiple_file_opens(void) +test_multiple_file_opens(hid_t orig_fapl) { - hid_t fid1 = H5I_INVALID_HID; /* File ID */ - hid_t fid2 = H5I_INVALID_HID; /* File ID */ - hid_t fid = H5I_INVALID_HID; /* File ID */ - hid_t fcpl = H5I_INVALID_HID; /* File creation property list ID */ - hid_t fapl1 = H5I_INVALID_HID; /* File access property list ID */ - hid_t fapl2 = H5I_INVALID_HID; /* File access property list ID */ - H5F_t * f1, *f2, *f; /* File pointer */ - H5F_vfd_swmr_config_t *config1 = NULL; /* Configuration for VFD SWMR */ - H5F_vfd_swmr_config_t *config2 = NULL; /* Configuration for VFD SWMR */ + char filename[FILE_NAME_LEN]; /* Filename to use */ + char filename2[FILE_NAME_LEN]; /* Filename to use */ + char non_filename[FILE_NAME_LEN]; /* Filename to use */ + hid_t fid1 = H5I_INVALID_HID; /* File ID */ + hid_t fid2 = H5I_INVALID_HID; /* File ID */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t fcpl = H5I_INVALID_HID; /* File creation property list ID */ + hid_t fapl1 = H5I_INVALID_HID; /* File access property list ID */ + hid_t fapl2 = H5I_INVALID_HID; /* File access property list ID */ + H5F_t * f1, *f2, *f; /* File pointer */ + H5F_vfd_swmr_config_t *config1 = NULL; /* Configuration for VFD SWMR */ + H5F_vfd_swmr_config_t *config2 = NULL; /* Configuration for VFD SWMR */ eot_queue_entry_t * curr; TESTING("EOT queue entries when opening files with/without VFD SWMR"); + h5_fixname(namebase, orig_fapl, filename, sizeof(filename)); + h5_fixname(namebase2, orig_fapl, filename2, sizeof(filename2)); + h5_fixname(non_namebase, orig_fapl, non_filename, sizeof(non_filename)); + /* Allocate memory for the configuration structure */ if ((config1 = HDmalloc(sizeof(*config1))) == NULL) FAIL_STACK_ERROR; @@ -2822,23 +3238,28 @@ test_multiple_file_opens(void) * 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); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config1, 4, 6, FALSE, TRUE, TRUE, FALSE, TRUE, 2, NULL, 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) + if ((fapl1 = H5Pcopy(orig_fapl)) < 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(config2, 4, 6, TRUE, TRUE, FALSE, TRUE, 2, MD_FILENAME2, NULL); + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl1, FALSE, FALSE, 4096, config1) < 0) + FAIL_STACK_ERROR; + + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config2, 4, 6, FALSE, TRUE, TRUE, FALSE, TRUE, 2, NULL, 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 = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; - if (fapl2 == H5I_INVALID_HID) + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl2, FALSE, FALSE, 4096, config2) < 0) FAIL_STACK_ERROR; if ((fcpl = vfd_swmr_create_fcpl(H5F_FSPACE_STRATEGY_PAGE, 4096)) < 0) { @@ -2847,7 +3268,7 @@ test_multiple_file_opens(void) } /* Create a file without VFD SWMR */ - if ((fid = H5Fcreate(FNAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(non_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Get a pointer to the internal file object */ @@ -2862,7 +3283,7 @@ test_multiple_file_opens(void) TEST_ERROR; /* Create a file with VFD SWMR writer */ - if ((fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl1)) < 0) + if ((fid1 = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl1)) < 0) TEST_ERROR; /* Get a pointer to the internal file object */ @@ -2877,7 +3298,7 @@ test_multiple_file_opens(void) TEST_ERROR; /* Create another file with VFD SWMR writer */ - if ((fid2 = H5Fcreate(FILENAME2, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) TEST_ERROR; /* Get a pointer to the internal file object */ @@ -2960,6 +3381,8 @@ error: * * Purpose: Verify multiple opens of the same file as listed below: * + * When presume is false: + * * #1st open# * #2nd open# VW VR W R * ------------------ @@ -2969,6 +3392,17 @@ error: * R | f f s s | * ------------------ * + * When presume is true: (the only difference is column 2) + * + * #1st open# + * #2nd open# VW VR W R + * ------------------ + * VW | s f f f | + * VR | f s f f | + * W | f f s f | + * R | f f s s | + * ------------------ + * * Notations: * W: H5F_ACC_RDWR * R: H5F_ACC_RDONLY @@ -2986,8 +3420,9 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_same_file_opens(void) +test_same_file_opens(hid_t orig_fapl, hbool_t presume) { + char filename[FILE_NAME_LEN]; /* Filename to use */ hid_t fid = H5I_INVALID_HID; /* File ID */ hid_t fid2 = H5I_INVALID_HID; /* File ID */ hid_t fcpl = H5I_INVALID_HID; /* File creation property list ID */ @@ -2996,10 +3431,13 @@ test_same_file_opens(void) H5F_vfd_swmr_config_t *config1 = NULL; /* Configuration for VFD SWMR */ H5F_vfd_swmr_config_t *config2 = NULL; /* Configuration for VFD SWMR */ - TESTING("Multiple opens of the same file with VFD SWMR configuration"); + TESTING( + "Multiple opens of the same file with VFD SWMR configuration with/without presume_posix_semantics"); + + h5_fixname(namebase, orig_fapl, filename, sizeof(filename)); /* Should succeed without VFD SWMR configured */ - if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Close the file */ @@ -3022,7 +3460,7 @@ test_same_file_opens(void) */ /* Create the test file */ - if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) TEST_ERROR; /* Close the file */ @@ -3030,27 +3468,31 @@ test_same_file_opens(void) FAIL_STACK_ERROR; /* - * Set the VFD SWMR configuration in fapl1 + page buffering + * Set up VFD SWMR configuration as writer in fapl1 */ - /* 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); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config1, 4, 10, presume ? TRUE : FALSE, TRUE, TRUE, FALSE, TRUE, 2, NULL, + 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 = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; - if (fapl1 == H5I_INVALID_HID) + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl1, FALSE, FALSE, 4096, config1) < 0) FAIL_STACK_ERROR; /* Open the file as VFD SWMR writer */ - /* Keep the file open */ - if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl1)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl1)) < 0) TEST_ERROR; + /* Keep the file open */ + /* 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) + if ((fid2 = H5Fopen(filename, H5F_ACC_RDWR, fapl1)) < 0) TEST_ERROR; /* Close the second file open */ @@ -3058,24 +3500,27 @@ test_same_file_opens(void) FAIL_STACK_ERROR; /* - * Set the VFD SWMR configuration in fapl2 + page buffering + * Set up VFD SWMR configuration as reader in fapl2 */ - /* 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); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config2, 3, 8, presume ? TRUE : FALSE, FALSE, TRUE, FALSE, TRUE, 3, NULL, + 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 = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; - if (fapl2 == H5I_INVALID_HID) + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl2, FALSE, FALSE, 4096, config2) < 0) FAIL_STACK_ERROR; /* Open the same file again as VFD SWMR reader */ /* Should fail: 1st open--VFD SWMR writer, 2nd open--VFD SWMR reader */ H5E_BEGIN_TRY { - fid2 = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl2); + fid2 = H5Fopen(filename, H5F_ACC_RDONLY, fapl2); } H5E_END_TRY; if (fid2 >= 0) @@ -3088,7 +3533,7 @@ test_same_file_opens(void) /* Should fail: 1st open--VFD SWMR writer, 2nd open--regular writer */ H5E_BEGIN_TRY { - fid2 = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); + fid2 = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT); } H5E_END_TRY; if (fid2 >= 0) @@ -3098,7 +3543,7 @@ test_same_file_opens(void) /* Should fail: 1st open--VFD SWMR writer, 2nd open--regular reader */ H5E_BEGIN_TRY { - fid2 = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT); + fid2 = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT); } H5E_END_TRY; if (fid2 >= 0) @@ -3110,20 +3555,25 @@ test_same_file_opens(void) /* * Tests for second column + * + * For presume is false, only need to test for the 1st case */ /* - * Set up as VFD SWMR reader + page buffering + * Set up VFD SWMR configuration as reader in fapl1 */ - /* 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); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config1, 4, 10, presume ? TRUE : FALSE, FALSE, TRUE, FALSE, TRUE, 2, NULL, + 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 = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; - if (fapl1 == H5I_INVALID_HID) + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl1, FALSE, FALSE, 4096, config1) < 0) FAIL_STACK_ERROR; /* Open the file as VFD SWMR reader */ @@ -3131,11 +3581,81 @@ test_same_file_opens(void) /* Take a while to complete due to retries */ H5E_BEGIN_TRY { - fid = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl1); + fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl1); } H5E_END_TRY; - if (fid >= 0) - TEST_ERROR; + + if (!presume) { + /* Should fail because there is no metadata file */ + /* Take a while to complete due to retries */ + if (fid >= 0) + TEST_ERROR; + } + else { /* presume is true */ + /* Should succeed since presume_posix_semantics is true allowing make_believe data */ + if (fid < 0) + TEST_ERROR; + + /* Continue testing for the remaining 3 cases */ + /* Keep the file open */ + + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + /* presume_posix_semantics is TRUE */ + init_vfd_swmr_config(config2, 4, 10, TRUE, TRUE, TRUE, FALSE, TRUE, 2, NULL, MD_FILENAME, NULL); + + if ((fapl2 = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; + + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl2, FALSE, FALSE, 4096, config2) < 0) + FAIL_STACK_ERROR; + + /* Open the same file again as VFD SWMR writer */ + /* Should fail */ + H5E_BEGIN_TRY + { + fid2 = H5Fopen(filename, H5F_ACC_RDWR, fapl2); + } + H5E_END_TRY; + if (fid2 >= 0) + TEST_ERROR; + + /* Open the same file again as VFD SWMR reader */ + /* Should succeed */ + if ((fid2 = H5Fopen(filename, H5F_ACC_RDONLY, fapl1)) < 0) + TEST_ERROR; + + if (H5Fclose(fid2) < 0) + FAIL_STACK_ERROR; + + /* Open the same file again as regular writer */ + /* Should fail: 1st open--VFD SWMR reader, 2nd open--regular writer */ + H5E_BEGIN_TRY + { + fid2 = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT); + } + H5E_END_TRY; + if (fid2 >= 0) + TEST_ERROR; + + /* Open the same file again as regular reader */ + /* Should fail: 1st open--VFD SWMR reader, 2nd open--regular reader */ + H5E_BEGIN_TRY + { + fid2 = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT); + } + H5E_END_TRY; + if (fid2 >= 0) + TEST_ERROR; + + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR; + + if (H5Pclose(fapl2) < 0) + FAIL_STACK_ERROR; + } if (H5Pclose(fapl1) < 0) FAIL_STACK_ERROR; @@ -3145,29 +3665,33 @@ test_same_file_opens(void) */ /* Open the file as regular writer */ - /* Keep the file open */ - if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR; + /* Keep the file open */ + /* - * Set up as VFD SWMR writer + page buffering + * Set up as VFD SWMR configuration as writer in fapl1 */ - /* 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); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config1, 4, 10, presume ? TRUE : FALSE, TRUE, TRUE, FALSE, TRUE, 2, NULL, + 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 = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; - if (fapl1 == H5I_INVALID_HID) + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl1, FALSE, FALSE, 4096, config1) < 0) FAIL_STACK_ERROR; /* Open the same file again as VFD SWMR writer */ /* Should fail: 1st open--regular writer, 2nd open--VFD SWMR writer */ H5E_BEGIN_TRY { - fid2 = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl1); + fid2 = H5Fopen(filename, H5F_ACC_RDWR, fapl1); } H5E_END_TRY; if (fid2 >= 0) @@ -3178,15 +3702,15 @@ test_same_file_opens(void) /* Open the same file again as regular writer */ /* Should succeed: 1st open--regular writer, 2nd open--regular writer */ - if ((fid2 = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR; if (H5Fclose(fid2) < 0) FAIL_STACK_ERROR; /* Open the same file again as regular reader */ - /* Should succeed: 1st open is writer, 2nd open is the same file as reader */ - if ((fid2 = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + /* Should succeed: 1st open--regular writer, 2nd open--regular reader */ + if ((fid2 = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR; if (H5Fclose(fid2) < 0) @@ -3202,28 +3726,31 @@ test_same_file_opens(void) /* Open the file as regular reader */ /* keep the file open */ - if ((fid = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR; /* - * Set up as VFD SWMR writer + page buffering + * Set up VFD SWMR configuration as writer in fapl1 */ - /* 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); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config1, 4, 10, presume ? TRUE : FALSE, TRUE, TRUE, FALSE, TRUE, 2, NULL, + 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 = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; - if (fapl1 == H5I_INVALID_HID) + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl1, FALSE, FALSE, 4096, config1) < 0) FAIL_STACK_ERROR; /* Open the same file again as VFD SMWR writer */ /* Should fail: 1st open--regular reader, 2nd open--VFD SWMR writer */ H5E_BEGIN_TRY { - fid2 = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl1); + fid2 = H5Fopen(filename, H5F_ACC_RDWR, fapl1); } H5E_END_TRY; if (fid2 >= 0) @@ -3234,7 +3761,7 @@ test_same_file_opens(void) /* Open the same file again as regular reader */ /* Should succeed: 1st open--regular reader, 2nd open--regular reader */ - if ((fid2 = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if ((fid2 = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR; if (H5Fclose(fid2) < 0) @@ -3244,7 +3771,7 @@ test_same_file_opens(void) /* Should fail: 1st open--regular reader, 2nd open--regular writer */ H5E_BEGIN_TRY { - fid2 = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); + fid2 = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT); } H5E_END_TRY; if (fid2 >= 0) @@ -3386,26 +3913,35 @@ out: *------------------------------------------------------------------------- */ static unsigned -test_enable_disable_eot(void) +test_enable_disable_eot(hid_t orig_fapl) { - hid_t fid = H5I_INVALID_HID; /* File ID */ - hid_t fid1 = H5I_INVALID_HID; /* File ID */ - hid_t fid2 = H5I_INVALID_HID; /* File ID */ - hid_t fid3 = H5I_INVALID_HID; /* File ID */ - hid_t fcpl = H5I_INVALID_HID; /* File creation property list ID */ - hid_t fapl1 = H5I_INVALID_HID; /* File access property list ID */ - hid_t fapl2 = H5I_INVALID_HID; /* File access property list ID */ - hid_t fapl3 = H5I_INVALID_HID; /* File access property list ID */ - H5F_t * f1, *f2, *f3; /* File pointer */ - H5F_vfd_swmr_config_t *config1 = NULL; /* Configuration for VFD SWMR */ - H5F_vfd_swmr_config_t *config2 = NULL; /* Configuration for VFD SWMR */ - H5F_vfd_swmr_config_t *config3 = NULL; /* Configuration for VFD SWMR */ - eot_queue_entry_t * curr; /* Pointer to an entry on the EOT queue */ - unsigned count = 0; /* Counter */ - herr_t ret; /* Return value */ + char filename[FILE_NAME_LEN]; /* Filename to use */ + char filename2[FILE_NAME_LEN]; /* Filename to use */ + char filename3[FILE_NAME_LEN]; /* Filename to use */ + char non_filename[FILE_NAME_LEN]; /* Filename to use */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t fid1 = H5I_INVALID_HID; /* File ID */ + hid_t fid2 = H5I_INVALID_HID; /* File ID */ + hid_t fid3 = H5I_INVALID_HID; /* File ID */ + hid_t fcpl = H5I_INVALID_HID; /* File creation property list ID */ + hid_t fapl1 = H5I_INVALID_HID; /* File access property list ID */ + hid_t fapl2 = H5I_INVALID_HID; /* File access property list ID */ + hid_t fapl3 = H5I_INVALID_HID; /* File access property list ID */ + H5F_t * f1, *f2, *f3; /* File pointer */ + H5F_vfd_swmr_config_t *config1 = NULL; /* Configuration for VFD SWMR */ + H5F_vfd_swmr_config_t *config2 = NULL; /* Configuration for VFD SWMR */ + H5F_vfd_swmr_config_t *config3 = NULL; /* Configuration for VFD SWMR */ + eot_queue_entry_t * curr; /* Pointer to an entry on the EOT queue */ + unsigned count = 0; /* Counter */ + herr_t ret; /* Return value */ TESTING("H5Fvfd_swmr_enable/disable_end_of_tick()"); + h5_fixname(namebase, orig_fapl, filename, sizeof(filename)); + h5_fixname(namebase2, orig_fapl, filename2, sizeof(filename)); + h5_fixname(namebase3, orig_fapl, filename3, sizeof(filename)); + h5_fixname(non_namebase, orig_fapl, non_filename, sizeof(non_filename)); + /* Allocate memory for the configuration structure */ if ((config1 = HDmalloc(sizeof(*config1))) == NULL) FAIL_STACK_ERROR; @@ -3418,42 +3954,48 @@ test_enable_disable_eot(void) * 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); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config1, 4, 6, FALSE, TRUE, TRUE, FALSE, TRUE, 2, NULL, 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 = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; - if (fapl1 == H5I_INVALID_HID) + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl1, FALSE, FALSE, 4096, config1) < 0) FAIL_STACK_ERROR; /* * 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); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config2, 4, 6, FALSE, TRUE, TRUE, FALSE, TRUE, 2, NULL, 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 = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; - if (fapl2 == H5I_INVALID_HID) + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl2, FALSE, FALSE, 4096, config2) < 0) FAIL_STACK_ERROR; /* * 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); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config3, 4, 6, FALSE, TRUE, TRUE, FALSE, TRUE, 2, NULL, 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 = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; - if (fapl3 == H5I_INVALID_HID) + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl3, FALSE, FALSE, 4096, config3) < 0) FAIL_STACK_ERROR; if ((fcpl = vfd_swmr_create_fcpl(H5F_FSPACE_STRATEGY_PAGE, 4096)) < 0) { @@ -3462,7 +4004,7 @@ test_enable_disable_eot(void) } /* Create a file without VFD SWMR */ - if ((fid = H5Fcreate(FNAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(non_filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Should fail to disable the file because VFD SWMR is not configured */ @@ -3478,15 +4020,15 @@ test_enable_disable_eot(void) TEST_ERROR; /* Create file 1 with VFD SWMR writer */ - if ((fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl1)) < 0) + if ((fid1 = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl1)) < 0) TEST_ERROR; /* Create file 2 with VFD SWMR writer */ - if ((fid2 = H5Fcreate(FILENAME2, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) + if ((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, fcpl, fapl2)) < 0) TEST_ERROR; /* Create file 3 with VFD SWMR writer */ - if ((fid3 = H5Fcreate(FILENAME3, H5F_ACC_TRUNC, fcpl, fapl3)) < 0) + if ((fid3 = H5Fcreate(filename3, H5F_ACC_TRUNC, fcpl, fapl3)) < 0) TEST_ERROR; /* Should have 3 files on the EOT queue */ @@ -3555,7 +4097,7 @@ test_enable_disable_eot(void) TEST_ERROR; /* Open file 3 again without VFD SWMR writer */ - if ((fid3 = H5Fopen(FILENAME3, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if ((fid3 = H5Fopen(filename3, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR; /* Get a pointer to the internal file object for file 3 */ @@ -3698,8 +4240,9 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_updater_flags(void) +test_updater_flags(hid_t orig_fapl) { + char filename[FILE_NAME_LEN]; /* Filename to use */ hid_t fid = H5I_INVALID_HID; /* File ID */ hid_t fcpl = H5I_INVALID_HID; /* File creation property list ID */ hid_t fapl = H5I_INVALID_HID; /* File access property list ID */ @@ -3713,8 +4256,10 @@ test_updater_flags(void) TESTING("VFD SWMR updater file flags"); + h5_fixname(namebase, orig_fapl, filename, sizeof(filename)); + /* Should succeed without VFD SWMR configured */ - if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Close the file */ @@ -3731,22 +4276,24 @@ test_updater_flags(void) * 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); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config, 4, 7, FALSE, TRUE, TRUE, TRUE, TRUE, 2, NULL, 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 = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; - if (fapl == H5I_INVALID_HID) - TEST_ERROR; + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl, FALSE, FALSE, 4096, config) < 0) + FAIL_STACK_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) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) TEST_ERROR; /* Get the file's file access property list */ @@ -3769,7 +4316,7 @@ test_updater_flags(void) TEST_ERROR; /* Check updater file size */ - if (HDstat(namebuf, &sb) == 0 && sb.st_size != H5F_UD_HEADER_SIZE) + if (HDstat(namebuf, &sb) == 0 && sb.st_size < H5F_UD_HEADER_SIZE) TEST_ERROR; /* Closing */ @@ -3838,8 +4385,9 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_updater_flags_same_file_opens(void) +test_updater_flags_same_file_opens(hid_t orig_fapl) { + char filename[FILE_NAME_LEN]; /* Filename to use */ hid_t fid = H5I_INVALID_HID; /* File ID */ hid_t fid2 = H5I_INVALID_HID; /* File ID */ hid_t fcpl = H5I_INVALID_HID; /* File creation property list ID */ @@ -3851,8 +4399,10 @@ test_updater_flags_same_file_opens(void) TESTING("VFD SWMR updater file flags for multiple opens of the same file"); + h5_fixname(namebase, orig_fapl, filename, sizeof(filename)); + /* Should succeed without VFD SWMR configured */ - if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Close the file */ @@ -3869,7 +4419,7 @@ test_updater_flags_same_file_opens(void) } /* Create the test file */ - if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) TEST_ERROR; /* Close the file */ @@ -3880,24 +4430,26 @@ test_updater_flags_same_file_opens(void) * 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); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config1, 4, 10, FALSE, TRUE, TRUE, TRUE, TRUE, 2, NULL, 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 = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; - if (fapl1 == H5I_INVALID_HID) + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl1, FALSE, FALSE, 4096, config1) < 0) FAIL_STACK_ERROR; /* Open the file as VFD SWMR writer */ /* Keep the file open */ - if ((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl1)) < 0) + 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) + if ((fid2 = H5Fopen(filename, H5F_ACC_RDWR, fapl1)) < 0) TEST_ERROR; /* Close the second file open */ @@ -4246,13 +4798,16 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_updater_generate_md_checksums(hbool_t file_create) +test_updater_generate_md_checksums(hid_t orig_fapl, hbool_t file_create) { - hid_t fid = H5I_INVALID_HID; /* File ID */ - hid_t fcpl = H5I_INVALID_HID; /* File creation property list ID */ - hid_t fapl = H5I_INVALID_HID; /* File access property list ID */ - H5F_vfd_swmr_config_t config; /* Configuration for VFD SWMR */ - H5F_generate_md_ck_cb_t cb_info; /* Callback */ + char filename[FILE_NAME_LEN]; /* Filename to use */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t fcpl = H5I_INVALID_HID; /* File creation property list ID */ + hid_t fapl = H5I_INVALID_HID; /* File access property list ID */ + H5F_vfd_swmr_config_t config; /* Configuration for VFD SWMR */ + H5F_generate_md_ck_cb_t cb_info; /* Callback */ + H5F_t * f = NULL; /* Internal file object pointer */ + char * md_file_path_name; if (file_create) { TESTING("VFD SWMR updater generate checksums for metadata file with H5Fcreate"); @@ -4261,15 +4816,19 @@ test_updater_generate_md_checksums(hbool_t file_create) 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); + h5_fixname(namebase4, orig_fapl, filename, sizeof(filename)); - /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ - fapl = vfd_swmr_create_fapl(TRUE, TRUE, FALSE, 4096, &config); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(&config, 4, 7, FALSE, TRUE, TRUE, TRUE, TRUE, 2, NULL, MD_FILE, UD_FILE); - if (fapl == H5I_INVALID_HID) - TEST_ERROR; + if ((fapl = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; + + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl, TRUE, FALSE, 4096, &config) < 0) + FAIL_STACK_ERROR; if ((fcpl = vfd_swmr_create_fcpl(H5F_FSPACE_STRATEGY_PAGE, 4096)) < 0) { HDprintf("vfd_swmr_create_fcpl() failed"); @@ -4285,19 +4844,26 @@ test_updater_generate_md_checksums(hbool_t file_create) /* Use file creation or file open for testing */ if (file_create) { - if ((fid = H5Fcreate(FILENAME4, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) FAIL_STACK_ERROR; } else { - if ((fid = H5Fcreate(FILENAME4, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; - if ((fid = H5Fopen(FILENAME4, H5F_ACC_RDWR, fapl)) < 0) + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR; } + /* Get a pointer to the internal file object */ + if (NULL == (f = (H5F_t *)H5VL_object(fid))) + TEST_ERROR + + /* Get the full metadata file pathname */ + md_file_path_name = HDstrdup(f->shared->md_file_path_name); + /* Close the file */ if (H5Fclose(fid) < 0) FAIL_STACK_ERROR; @@ -4308,11 +4874,11 @@ test_updater_generate_md_checksums(hbool_t file_create) FAIL_STACK_ERROR; /* Verify contents of checksum file and updater files */ - if (verify_ud_chk(config.md_file_path, config.updater_file_path) < 0) + if (verify_ud_chk(md_file_path_name, config.updater_file_path) < 0) TEST_ERROR; /* It's important to clean up the checksum and updater files. */ - clean_chk_ud_files(config.md_file_path, config.updater_file_path); + clean_chk_ud_files(md_file_path_name, config.updater_file_path); PASSED(); @@ -4328,13 +4894,295 @@ error: 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); + clean_chk_ud_files(md_file_path_name, config.updater_file_path); return 1; } /* test_updater_generate_md_checksums() */ /*------------------------------------------------------------------------- + * Function: test_auto_generate_md() + * + * Purpose: Verify the automatic generation of metadata filename + * when md_file_name is NULL. + * + * Return: 0 if test is successful + * 1 if test fails + * + * Programmer: Vailin Choi; May 2022 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_auto_generate_md(hid_t orig_fapl, const char *md_path) +{ + char filename[FILE_NAME_LEN]; /* Filename to use */ + char newfilename[FILE_NAME_LEN]; /* Filename to use */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t fcpl = H5I_INVALID_HID; /* File creation property list ID */ + hid_t fapl = H5I_INVALID_HID; /* File access property list ID associated with the file */ + H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */ + H5F_t * f; /* File pointer */ + + TESTING("Automatic generation of metadata file name with/without md_path"); + + h5_fixname(namebase, orig_fapl, filename, sizeof(filename)); + + /* Allocate memory for the configuration structure */ + if ((config = (H5F_vfd_swmr_config_t *)HDmalloc(sizeof(H5F_vfd_swmr_config_t))) == NULL) + FAIL_STACK_ERROR; + + /* + * Configured as VFD SWMR writer + */ + + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config, 4, 7, FALSE, TRUE, TRUE, FALSE, TRUE, 2, md_path, NULL, NULL); + + if ((fapl = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; + + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl, FALSE, FALSE, 4096, config) < 0) + 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 HDF5 file with VFD SWMR enabled */ + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) + TEST_ERROR; + + /* Get internal file pointer */ + f = H5VL_object(fid); + + /* Zero out newfilename */ + HDmemset(newfilename, 0, sizeof(newfilename)); + + if (md_path != NULL) { + HDstrcat(newfilename, md_path); + HDstrcat(newfilename, "/"); + } + + HDstrcat(newfilename, filename); + HDstrcat(newfilename, ".md"); + + /* Compare the automatic generation of metadata filename is as expected */ + if (HDstrcmp(f->shared->md_file_path_name, newfilename)) + TEST_ERROR; + + /* Closing */ + if (H5Fclose(fid) < 0) + FAIL_STACK_ERROR; + + if (H5Pclose(fcpl) < 0) + FAIL_STACK_ERROR; + + /* Free buffers */ + HDfree(config); + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY + { + H5Pclose(fcpl); + H5Pclose(fapl); + H5Fclose(fid); + } + H5E_END_TRY; + + HDfree(config); + + return 1; +} /* test_auto_generate_md() */ + +/*------------------------------------------------------------------------- + * Function: test_long_md_path_name() + * + * Purpose: Verify failure when metadata pathname + filename + * that exceeds H5F__MAX_VFD_SWMR_FILE_NAME_LEN (1024) + * + * Return: 0 if test is successful + * 1 if test fails + * + * Programmer: Vailin Choi; May 2022 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_long_md_path_name(hid_t orig_fapl) +{ + char filename[FILE_NAME_LEN + 10]; /* Filename to use */ + char long_md_name[FILE_NAME_LEN + 10]; /* Filename to use */ + char long_md_path[FILE_NAME_LEN + 10]; /* Filename to use */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t fapl = H5I_INVALID_HID; /* File access property list ID associated with the file */ + H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */ + unsigned i, times; + int ret; + + TESTING("Generation of metadata pathname + filename exceeding H5F__MAX_VFD_SWMR_FILE_NAME_LEN"); + + h5_fixname(namebase, orig_fapl, filename, sizeof(filename)); + + /* Create long metadata pathname + filename that exceed H5F__MAX_VFD_SWMR_FILE_NAME_LEN */ + + times = (FILE_NAME_LEN / 2) / HDstrlen("long_md_name") + 1; + + HDmemset(long_md_path, 0, sizeof(long_md_path)); + HDmemset(long_md_name, 0, sizeof(long_md_name)); + + for (i = 0; i < times; i++) { + HDstrcat(long_md_path, "long_md_path"); + HDstrcat(long_md_name, "long_md_name"); + } + + /* Allocate memory for the configuration structure */ + if ((config = (H5F_vfd_swmr_config_t *)HDmalloc(sizeof(H5F_vfd_swmr_config_t))) == NULL) + FAIL_STACK_ERROR; + + /* + * Configured as VFD SWMR writer + */ + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config, 4, 7, FALSE, TRUE, TRUE, FALSE, TRUE, 2, long_md_path, long_md_name, NULL); + + if ((fapl = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; + + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + /* Should fail when calling H5Pset_vfd_swmr_config */ + H5E_BEGIN_TRY + ret = vfd_swmr_fapl_augment(fapl, FALSE, FALSE, 4096, config); + H5E_END_TRY; + + if (ret >= 0) + TEST_ERROR; + + /* Free buffers */ + HDfree(config); + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY + { + H5Pclose(fapl); + H5Fclose(fid); + } + H5E_END_TRY; + + HDfree(config); + + return 1; +} /* test_long_md_path_name() */ + +/*------------------------------------------------------------------------- + * Function: test_auto_long_md_path_name() + * + * Purpose: Verify failure in automatic generation of metadata filename + * that exceeds H5F__MAX_VFD_SWMR_FILE_NAME_LEN (1024) + * + * Return: 0 if test is successful + * 1 if test fails + * + * Programmer: Vailin Choi; May 2022 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_auto_long_md_path_name(hid_t orig_fapl) +{ + char filename[FILE_NAME_LEN + 10]; /* Filename to use */ + char long_namebase[FILE_NAME_LEN + 10]; /* Filename to use */ + hid_t fid = H5I_INVALID_HID; /* File ID */ + hid_t fcpl = H5I_INVALID_HID; /* File creation property list ID */ + hid_t fapl = H5I_INVALID_HID; /* File access property list ID associated with the file */ + H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */ + unsigned i, times; + + TESTING("Automatic generation of metadata file name exceeding H5F__MAX_VFD_SWMR_FILE_NAME_LEN"); + + /* Create long hdf5 filename to trigger automatic generation of long metadata filename */ + + times = FILE_NAME_LEN / HDstrlen(namebase) + 1; + + HDmemset(long_namebase, 0, sizeof(long_namebase)); + + /* Generate a long hdf5 filename that exceeds 1024 */ + for (i = 0; i < times; i++) + HDstrcat(long_namebase, namebase); + + h5_fixname(long_namebase, orig_fapl, filename, sizeof(filename)); + + /* + * Configured as VFD SWMR writer + NULL md_file_name + */ + + /* Allocate memory for the configuration structure */ + if ((config = (H5F_vfd_swmr_config_t *)HDmalloc(sizeof(H5F_vfd_swmr_config_t))) == NULL) + FAIL_STACK_ERROR; + + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config, 4, 7, FALSE, TRUE, TRUE, FALSE, TRUE, 2, NULL, NULL, NULL); + + if ((fapl = H5Pcopy(orig_fapl)) < 0) + FAIL_STACK_ERROR; + + /* fapl, use_latest_format, only_meta_page, page_buf_size, config */ + if (vfd_swmr_fapl_augment(fapl, FALSE, FALSE, 4096, config) < 0) + 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 HDF5 file with VFD SWMR enabled */ + /* Should fail when doing automatic generation of metadata filename + because of the long hdf5 filename */ + H5E_BEGIN_TRY + fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl); + H5E_END_TRY; + + if (fid >= 0) + TEST_ERROR; + + if (H5Pclose(fcpl) < 0) + FAIL_STACK_ERROR; + + /* Free buffers */ + HDfree(config); + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY + { + H5Pclose(fcpl); + H5Pclose(fapl); + H5Fclose(fid); + } + H5E_END_TRY; + + HDfree(config); + + return 1; +} /* test_auto_long_md_path_name() */ + +/*------------------------------------------------------------------------- * Function: main() * * Purpose: Main function for VFD SWMR tests. @@ -4347,12 +5195,14 @@ error: int main(void) { - hid_t fapl = H5I_INVALID_HID; /* File access property list for */ - /* data files */ - unsigned nerrors = 0; /* Cumulative error count */ - char * lock_env_var = NULL; /* File locking env var pointer */ - const char *env_h5_drvr = NULL; /* File Driver value from environment */ - hbool_t use_file_locking; /* Read from env var */ + hid_t fapl = H5I_INVALID_HID; /* File access property list for */ + /* data files */ + unsigned nerrors = 0; /* Cumulative error count */ + char * lock_env_var = NULL; /* File locking env var pointer */ + const char * env_h5_drvr = NULL; /* File Driver value from environment */ + hbool_t use_file_locking; /* Read from env var */ + hid_t driver_id = -1; /* ID for this VFD */ + unsigned long driver_flags = 0; /* VFD feature flags */ /* Check the environment variable that determines if we care * about file locking. File locking should be used unless explicitly @@ -4369,14 +5219,17 @@ main(void) if (env_h5_drvr == NULL) env_h5_drvr = "nomatch"; +#if 0 /* Temporary skip testing with multi/split drivers: * Page buffering depends on paged aggregation which is * currently disabled for multi/split drivers. */ if ((0 == HDstrcmp(env_h5_drvr, "multi")) || (0 == HDstrcmp(env_h5_drvr, "split"))) { HDputs("Skip VFD SWMR test because paged aggregation is disabled for multi/split drivers"); + HDprintf("The %s does not support VFD SWMR feature\n", env_h5_drvr); HDexit(EXIT_SUCCESS); } +#endif #ifdef H5_HAVE_PARALLEL HDputs("Skip VFD SWMR test because paged aggregation is disabled in parallel HDF5"); @@ -4391,41 +5244,66 @@ main(void) PUTS_ERROR("Can't get VFD-dependent fapl") } - /* Add nfs/updater testing in this routine */ - nerrors += test_fapl(); + /* Get the VFD feature flags for this VFD */ + if ((driver_id = H5Pget_driver(fapl)) < 0) + PUTS_ERROR("Can't get driver set in fapl") + if (H5FDdriver_query(driver_id, &driver_flags) < 0) + PUTS_ERROR("Can't query driver flags") + + /* Check whether the VFD feature flag supports VFD SWMR */ + if (!(driver_flags & H5FD_FEAT_SUPPORTS_VFD_SWMR)) { + SKIPPED(); + HDprintf("The %s driver does not support VFD SWMR feature.\n", env_h5_drvr); + HDexit(EXIT_SUCCESS); + } if (use_file_locking) { - nerrors += test_updater_flags(); - nerrors += test_updater_flags_same_file_opens(); -#ifndef H5_HAVE_WIN32_API - /* VFD SWMR: Fails on windows due to error from generate_md_ck_cb(). */ - nerrors += test_updater_generate_md_checksums(TRUE); - nerrors += test_updater_generate_md_checksums(FALSE); -#endif + + nerrors += test_fapl(fapl); + nerrors += test_file_fapl(fapl); nerrors += test_shadow_index_lookup(); - nerrors += test_file_fapl(); #ifndef H5_HAVE_WIN32_API /* XXX: VFD SWMR: Fails on Win32 due to problems unlinking the metadata file. * The OS claims another process is using the file. */ - nerrors += test_writer_create_open_flush(); - nerrors += test_writer_md(); + nerrors += test_writer_create_open_flush(fapl); + nerrors += test_writer_md(fapl); #endif - nerrors += test_reader_md_concur(); + nerrors += test_reader_md_concur(fapl); - nerrors += test_multiple_file_opens(); - nerrors += test_multiple_file_opens_concur(); - nerrors += test_same_file_opens(); + nerrors += test_multiple_file_opens(fapl); + nerrors += test_multiple_file_opens_concur(fapl); - nerrors += test_enable_disable_eot(); - nerrors += test_disable_enable_eot_concur(); + nerrors += test_enable_disable_eot(fapl); + nerrors += test_enable_disable_eot_concur(fapl); - nerrors += test_file_end_tick(); - nerrors += test_file_end_tick_concur(); + nerrors += test_file_end_tick(fapl); + nerrors += test_file_end_tick_concur(fapl); + + nerrors += test_updater_flags(fapl); + nerrors += test_updater_flags_same_file_opens(fapl); + +#ifndef H5_HAVE_WIN32_API + /* VFD SWMR: Fails on windows due to error from generate_md_ck_cb(). */ + nerrors += test_updater_generate_md_checksums(fapl, TRUE); + nerrors += test_updater_generate_md_checksums(fapl, FALSE); +#endif + nerrors += test_same_file_opens(fapl, FALSE); + nerrors += test_same_file_opens(fapl, TRUE); + + nerrors += test_make_believe_multiple_file_opens_concur(fapl); + + nerrors += test_auto_generate_md(fapl, NULL); + nerrors += test_auto_generate_md(fapl, "."); + nerrors += test_auto_generate_md(fapl, "./"); + nerrors += test_auto_long_md_path_name(fapl); + nerrors += test_long_md_path_name(fapl); } + h5_clean_files(namebases, fapl); + if (nerrors) goto error; @@ -4441,6 +5319,4 @@ error: H5Pclose(fapl); } H5E_END_TRY; - - HDexit(EXIT_FAILURE); } diff --git a/test/vfd_swmr_addrem_writer.c b/test/vfd_swmr_addrem_writer.c index 0cd1713..ea395f6 100644 --- a/test/vfd_swmr_addrem_writer.c +++ b/test/vfd_swmr_addrem_writer.c @@ -94,9 +94,10 @@ open_skeleton(const char *filename, unsigned verbose) if ((config = HDcalloc(1, sizeof(*config))) == NULL) goto 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, 4, 5, TRUE, TRUE, FALSE, TRUE, 128, "rw-shadow", NULL); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config, 4, 5, FALSE, TRUE, TRUE, FALSE, TRUE, 128, NULL, "rw-shadow", NULL); /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ if ((fapl = vfd_swmr_create_fapl(TRUE, TRUE, FALSE, 4096, config)) < 0) diff --git a/test/vfd_swmr_attrdset_writer.c b/test/vfd_swmr_attrdset_writer.c index 37c4c72..85ceb01 100644 --- a/test/vfd_swmr_attrdset_writer.c +++ b/test/vfd_swmr_attrdset_writer.c @@ -130,40 +130,40 @@ typedef struct { .fd_reader_to_writer = -1, .notify = 0, .verify = 0 \ } -static herr_t state_init(state_t *s, int argc, const char *const *argv); - -static herr_t np_init(np_state_t *np, hbool_t writer); -static herr_t np_close(np_state_t *np, hbool_t writer); -static herr_t np_writer(hbool_t result, unsigned step, const state_t *s, np_state_t *np, - H5F_vfd_swmr_config_t *config); -static herr_t np_reader(hbool_t result, unsigned step, const state_t *s, np_state_t *np); -static herr_t np_confirm_verify_notify(int fd, unsigned step, const state_t *s, np_state_t *np); -static herr_t np_reader_no_verification(const state_t *s, np_state_t *np, H5F_vfd_swmr_config_t *config); - -static herr_t create_dsets(const state_t *s, dsets_state_t *ds); -static herr_t open_dsets(const state_t *s, dsets_state_t *ds); -static herr_t open_dset_real(hid_t fid, hid_t *did, const char *name, unsigned *max_compact, - unsigned *min_dense); -static herr_t close_dsets(const dsets_state_t *ds); - -static herr_t perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, +static hbool_t state_init(state_t *s, int argc, const char *const *argv); + +static hbool_t np_init(np_state_t *np, hbool_t writer); +static hbool_t np_close(np_state_t *np, hbool_t writer); +static hbool_t np_writer(hbool_t result, unsigned step, const state_t *s, np_state_t *np, + H5F_vfd_swmr_config_t *config); +static hbool_t np_reader(hbool_t result, unsigned step, const state_t *s, np_state_t *np); +static hbool_t np_confirm_verify_notify(int fd, unsigned step, const state_t *s, np_state_t *np); +static hbool_t np_reader_no_verification(const state_t *s, np_state_t *np, H5F_vfd_swmr_config_t *config); + +static hbool_t create_dsets(const state_t *s, dsets_state_t *ds); +static hbool_t open_dsets(const state_t *s, dsets_state_t *ds); +static hbool_t open_dset_real(hid_t fid, hid_t *did, const char *name, unsigned *max_compact, + unsigned *min_dense); +static hbool_t close_dsets(const dsets_state_t *ds); + +static hbool_t perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, + np_state_t *np); +static hbool_t attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which); +static hbool_t attr_action(unsigned action, const state_t *s, hid_t did, unsigned which); +static hbool_t add_attr(const state_t *s, hid_t did, unsigned int which); +static hbool_t modify_attr(const state_t *s, hid_t did, unsigned int which); +static hbool_t delete_attr(hid_t did, unsigned int which); + +static hbool_t verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np); -static herr_t attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which); -static herr_t attr_action(unsigned action, const state_t *s, hid_t did, unsigned which); -static herr_t add_attr(const state_t *s, hid_t did, unsigned int which); -static herr_t modify_attr(const state_t *s, hid_t did, unsigned int which); -static herr_t delete_attr(hid_t did, unsigned int which); - -static herr_t verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, - np_state_t *np); -static herr_t verify_attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, - unsigned which); -static herr_t verify_attr_action(unsigned action, hid_t did, unsigned which); -static herr_t verify_add_or_modify_attr(unsigned action, hid_t did, char *attr_name, unsigned int which); -static herr_t verify_delete_attr(hid_t did, char *attr_name); -static herr_t verify_storage_cont(unsigned action, hid_t did, unsigned int which, unsigned max_compact, - unsigned min_dense, unsigned asteps); -static herr_t verify_storage_cont_real(hid_t did, unsigned int which, unsigned cut_point); +static hbool_t verify_attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, + unsigned which); +static hbool_t verify_attr_action(unsigned action, hid_t did, unsigned which); +static hbool_t verify_add_or_modify_attr(unsigned action, hid_t did, char *attr_name, unsigned int which); +static hbool_t verify_delete_attr(hid_t did, char *attr_name); +static hbool_t verify_storage_cont(unsigned action, hid_t did, unsigned int which, unsigned max_compact, + unsigned min_dense, unsigned asteps); +static hbool_t verify_storage_cont_real(hid_t did, unsigned int which, unsigned cut_point); /* Names for datasets */ #define DSET_COMPACT_NAME "compact_dset" @@ -215,7 +215,7 @@ usage(const char *progname) /* * Initialize option info in state_t */ -static herr_t +static hbool_t state_init(state_t *s, int argc, const char *const *argv) { unsigned long tmp; @@ -347,20 +347,20 @@ state_init(state_t *s, int argc, const char *const *argv) /* The test file name */ esnprintf(s->filename, sizeof(s->filename), "vfd_swmr_attrdset.h5"); - return SUCCEED; + return true; error: if (tfile) HDfree(tfile); - return FAIL; + return false; } /* state_init() */ /* * Create the datasets as specified on the command line. */ -static herr_t +static hbool_t create_dsets(const state_t *s, dsets_state_t *ds) { hid_t dcpl = H5I_INVALID_HID; @@ -719,7 +719,7 @@ create_dsets(const state_t *s, dsets_state_t *ds) } } - return SUCCEED; + return true; error: H5E_BEGIN_TRY @@ -741,14 +741,14 @@ error: } H5E_END_TRY; - return FAIL; + return false; } /* create_dsets() */ /* * Open the datasets as specified. */ -static herr_t +static hbool_t open_dsets(const state_t *s, dsets_state_t *ds) { *ds = DSETS_INITIALIZER; @@ -796,10 +796,10 @@ open_dsets(const state_t *s, dsets_state_t *ds) } } - return SUCCEED; + return true; error: - return FAIL; + return false; } /* open_dsets() */ @@ -807,7 +807,7 @@ error: * Do the real work of opening the dataset. * Retrieve the max_compact and min_dense values for the dataset. */ -static herr_t +static hbool_t open_dset_real(hid_t fid, hid_t *did, const char *name, unsigned *max_compact, unsigned *min_dense) { hid_t dcpl = H5I_INVALID_HID; @@ -832,7 +832,7 @@ open_dset_real(hid_t fid, hid_t *did, const char *name, unsigned *max_compact, u TEST_ERROR; } - return SUCCEED; + return true; error: H5E_BEGIN_TRY @@ -842,13 +842,13 @@ error: } H5E_END_TRY; - return FAIL; + return false; } /* open_dset_real() */ /* * Close all the datasets as specified. */ -static herr_t +static hbool_t close_dsets(const dsets_state_t *ds) { if (ds->compact_did != H5I_INVALID_HID && H5Dclose(ds->compact_did) < 0) { @@ -886,7 +886,7 @@ close_dsets(const dsets_state_t *ds) TEST_ERROR; } - return SUCCEED; + return true; error: H5E_BEGIN_TRY @@ -901,7 +901,7 @@ error: } H5E_END_TRY; - return FAIL; + return false; } /* close_dsets() */ /* @@ -914,7 +914,7 @@ error: * MODIFY_ATTR : -m option * DELETE_ATTR : -d <dattrs> option */ -static herr_t +static hbool_t perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np) { unsigned step; @@ -974,10 +974,10 @@ perform_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *c } } - return SUCCEED; + return true; error: - return FAIL; + return false; } /* perform_dsets_operations() */ @@ -987,7 +987,7 @@ error: * -g: contiguous dataset * -k: 5 chunked datasets with 5 indexing types */ -static herr_t +static hbool_t attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which) { int nerrors = 0; @@ -1035,7 +1035,7 @@ attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, un } if (nerrors) - ret = FALSE; + ret = false; return (ret); @@ -1047,7 +1047,7 @@ attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, un * MODIFY_ATTR : modify `which` attribute * DELETE_ATTR : delete `which` attribute */ -static herr_t +static hbool_t attr_action(unsigned action, const state_t *s, hid_t did, unsigned which) { hbool_t ret; @@ -1080,7 +1080,7 @@ attr_action(unsigned action, const state_t *s, hid_t did, unsigned which) * H5T_NATIVE_UINT32 (-b) or * H5T_NATIVE_UINT32 (default) */ -static herr_t +static hbool_t add_attr(const state_t *s, hid_t did, unsigned int which) { hid_t aid = H5I_INVALID_HID; @@ -1140,7 +1140,7 @@ add_attr(const state_t *s, hid_t did, unsigned int which) if (val) HDfree(val); - return SUCCEED; + return true; error: H5E_BEGIN_TRY @@ -1153,14 +1153,14 @@ error: if (val) HDfree(val); - return FAIL; + return false; } /* add_attr() */ /* * Modify the attribute data. */ -static herr_t +static hbool_t modify_attr(const state_t *s, hid_t did, unsigned int which) { hid_t aid = H5I_INVALID_HID; @@ -1224,7 +1224,7 @@ modify_attr(const state_t *s, hid_t did, unsigned int which) if (val) HDfree(val); - return SUCCEED; + return true; error: H5E_BEGIN_TRY { @@ -1236,13 +1236,13 @@ error: if (val) HDfree(val); - return FAIL; + return false; } /* modify_attr() */ /* * Delete the attribute */ -static herr_t +static hbool_t delete_attr(hid_t did, unsigned int which) { char name[sizeof("attr-9999999999")]; @@ -1255,10 +1255,10 @@ delete_attr(hid_t did, unsigned int which) TEST_ERROR; } - return SUCCEED; + return true; error: - return FAIL; + return false; } /* delete_attr() */ @@ -1276,7 +1276,7 @@ error: * --[-c <csteps>] is 1 * --not applicable for -m option */ -static herr_t +static hbool_t verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *config, np_state_t *np) { unsigned step; @@ -1360,11 +1360,11 @@ verify_dsets_operations(state_t *s, dsets_state_t *ds, H5F_vfd_swmr_config_t *co } } - return SUCCEED; + return true; error: - return FAIL; + return false; } /* verify_dsets_operations() */ /* @@ -1373,7 +1373,7 @@ error: * -g: contiguous dataset * -k: 5 chunked datasets with 5 indexing types */ -static herr_t +static hbool_t verify_attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t *ds, unsigned which) { int nerrors = 0; @@ -1465,7 +1465,7 @@ verify_attr_dsets_action(unsigned action, const state_t *s, const dsets_state_t /* * Verify the attribute action on the specified dataset. */ -static herr_t +static hbool_t verify_attr_action(unsigned action, hid_t did, unsigned which) { char name[sizeof("attr-9999999999")]; @@ -1496,7 +1496,7 @@ verify_attr_action(unsigned action, hid_t did, unsigned which) /* * Verify the attribute is added or modified */ -static herr_t +static hbool_t verify_add_or_modify_attr(unsigned action, hid_t did, char *attr_name, unsigned int which) { unsigned int read_which; @@ -1575,14 +1575,14 @@ error: if (is_vl) H5free_memory(read_vl_which); - return FAIL; + return false; } /* verify_add_or_modify_attr() */ /* * Verify the attribute does not exist. */ -static herr_t +static hbool_t verify_delete_attr(hid_t did, char *attr_name) { int ret; @@ -1592,14 +1592,14 @@ verify_delete_attr(hid_t did, char *attr_name) TEST_ERROR; } else if (!ret) /* attribute does not exist */ - ret = TRUE; + ret = true; else /* attribute exist */ - ret = FALSE; + ret = false; return ret; error: - return FAIL; + return false; } /* verify_delete_attr() */ @@ -1617,11 +1617,11 @@ error: * --`which` is at min_dense: dense storage, no continuation block * --`which` is at (min_dense - 1): compact storage, continuation block exists */ -static herr_t +static hbool_t verify_storage_cont(unsigned action, hid_t did, unsigned int which, unsigned max_compact, unsigned min_dense, unsigned asteps) { - hbool_t ret = TRUE; + hbool_t ret = true; HDassert(action == ADD_ATTR || action == DELETE_ATTR); @@ -1660,7 +1660,7 @@ verify_storage_cont(unsigned action, hid_t did, unsigned int which, unsigned max /* * Verify the storage condition at the specific checkpoint */ -static herr_t +static hbool_t verify_storage_cont_real(hid_t did, unsigned int which, unsigned cut_point) { H5O_native_info_t ninfo; @@ -1687,7 +1687,7 @@ verify_storage_cont_real(hid_t did, unsigned int which, unsigned cut_point) } error: - return FAIL; + return false; } /* verify_storage_cont_real() */ @@ -1698,7 +1698,7 @@ error: /* * Initialize the named pipes for test synchronization. */ -static herr_t +static hbool_t np_init(np_state_t *np, hbool_t writer) { *np = NP_INITIALIZER; @@ -1746,17 +1746,17 @@ np_init(np_state_t *np, hbool_t writer) TEST_ERROR; } - return SUCCEED; + return true; error: - return FAIL; + return false; } /* np_init() */ /* * Close the named pipes. */ -static herr_t +static hbool_t np_close(np_state_t *np, hbool_t writer) { /* Both the writer and reader close the named pipes */ @@ -1782,16 +1782,16 @@ np_close(np_state_t *np, hbool_t writer) TEST_ERROR; } } - return SUCCEED; + return true; error: - return FAIL; + return false; } /* np_close() */ /* * Writer synchronization depending on the result from the attribute action performed. */ -static herr_t +static hbool_t np_writer(hbool_t result, unsigned step, const state_t *s, np_state_t *np, H5F_vfd_swmr_config_t *config) { unsigned int i; @@ -1841,10 +1841,10 @@ np_writer(hbool_t result, unsigned step, const state_t *s, np_state_t *np, H5F_v } } } - return SUCCEED; + return true; error: - return FAIL; + return false; } /* np_writer() */ @@ -1852,7 +1852,7 @@ error: * * Reader synchronization depending on the result from the verification. */ -static herr_t +static hbool_t np_reader(hbool_t result, unsigned step, const state_t *s, np_state_t *np) { /* The verification fails */ @@ -1882,10 +1882,10 @@ np_reader(hbool_t result, unsigned step, const state_t *s, np_state_t *np) } } } - return SUCCEED; + return true; error: - return FAIL; + return false; } /* np_reader() */ @@ -1893,7 +1893,7 @@ error: * Handshake between writer and reader: * Confirm `verify` is same as `notify`. */ -static herr_t +static hbool_t np_confirm_verify_notify(int fd, unsigned step, const state_t *s, np_state_t *np) { if (step % s->csteps == 0) { @@ -1914,17 +1914,17 @@ np_confirm_verify_notify(int fd, unsigned step, const state_t *s, np_state_t *np } } - return SUCCEED; + return true; error: - return FAIL; + return false; } /* confirm_verify_notify() */ /* * Synchronization done by the reader before moving onto the * next verification phase. */ -static herr_t +static hbool_t np_reader_no_verification(const state_t *s, np_state_t *np, H5F_vfd_swmr_config_t *config) { if (s->use_np) { @@ -1946,10 +1946,10 @@ np_reader_no_verification(const state_t *s, np_state_t *np, H5F_vfd_swmr_config_ } } - return SUCCEED; + return true; error: - return FAIL; + return false; } /* np_reader_no_verification() */ @@ -1981,10 +1981,10 @@ main(int argc, char **argv) TEST_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, 4, 7, writer, TRUE, FALSE, TRUE, 128, "./attrdset-shadow", NULL); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(&config, 4, 7, FALSE, writer, TRUE, FALSE, TRUE, 128, "./", "attrdset-shadow", NULL); /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ if ((fapl = vfd_swmr_create_fapl(TRUE, s.use_vfd_swmr, TRUE, 4096, &config)) < 0) { diff --git a/test/vfd_swmr_bigset_writer.c b/test/vfd_swmr_bigset_writer.c index 71bd730..6ff5d03 100644 --- a/test/vfd_swmr_bigset_writer.c +++ b/test/vfd_swmr_bigset_writer.c @@ -2580,22 +2580,33 @@ main(int argc, char **argv) continue; } - /* config, tick_len, max_lag, writer, maintain_metadata_file, generate_updater_files, - * flush_raw_data, md_pages_reserved, md_file_path, updater_file_path */ + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + #ifdef H5_HAVE_AUX_PROCESS + /* If using the auxiliary process, the writer creates the updater files. * The reader uses the metadata file generated by the auxiliary process. */ if (s.writer) { - init_vfd_swmr_config(&config, s.tick_len, s.max_lag, s.writer, FALSE, TRUE, s.flush_raw_data, 128, - "./bigset-shadow-%zu", "bigset_updater", i); + init_vfd_swmr_config(&config, s.tick_len, s.max_lag, FALSE, s.writer, FALSE, TRUE, + s.flush_raw_data, 128, "./", "bigset-shadow-%zu", "bigset_updater", i); } else { - init_vfd_swmr_config(&config, s.tick_len, s.max_lag, s.writer, TRUE, FALSE, s.flush_raw_data, 128, - "./mdfile", NULL); + init_vfd_swmr_config(&config, s.tick_len, s.max_lag, FALSE, s.writer, TRUE, FALSE, + s.flush_raw_data, 128, "./", "mdfile", NULL); } #else - init_vfd_swmr_config(&config, s.tick_len, s.max_lag, s.writer, TRUE, FALSE, s.flush_raw_data, 128, - "./bigset-shadow-%zu", NULL, i); + + if (s.vds == vds_multi || s.vds == vds_single) { + init_vfd_swmr_config(&config, s.tick_len, s.max_lag, TRUE, s.writer, TRUE, FALSE, + s.flush_raw_data, 128, "", "", NULL); + } + else { + init_vfd_swmr_config(&config, s.tick_len, s.max_lag, FALSE, s.writer, TRUE, FALSE, + s.flush_raw_data, 128, "./", "bigset-shadow-%zu", NULL, i); + } + #endif /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ diff --git a/test/vfd_swmr_common.c b/test/vfd_swmr_common.c index 931b49b..1652ee5 100644 --- a/test/vfd_swmr_common.c +++ b/test/vfd_swmr_common.c @@ -326,14 +326,14 @@ await_signal(hid_t fid) #endif /* H5_HAVE_WIN32_API */ -/* Revised support routines that can be used for all VFD SWMR integration tests - * NOTE: For tests that call this common routine, md_file_path needs to be set - * regardless of whether maintain_metadata_file is true or false. +/* + * Revised support routines that can be used for all VFD SWMR integration tests */ void -init_vfd_swmr_config(H5F_vfd_swmr_config_t *config, uint32_t tick_len, uint32_t max_lag, hbool_t writer, - hbool_t maintain_metadata_file, hbool_t generate_updater_files, hbool_t flush_raw_data, - uint32_t md_pages_reserved, const char *md_file_fmtstr, const char *updater_file_path, +init_vfd_swmr_config(H5F_vfd_swmr_config_t *config, uint32_t tick_len, uint32_t max_lag, + hbool_t presume_posix_semantics, hbool_t writer, hbool_t maintain_metadata_file, + hbool_t generate_updater_files, hbool_t flush_raw_data, uint32_t md_pages_reserved, + const char *md_path_fmtstr, const char *md_file_fmtstr, const char *updater_path_fmtstr, ...) { va_list ap; @@ -343,22 +343,36 @@ init_vfd_swmr_config(H5F_vfd_swmr_config_t *config, uint32_t tick_len, uint32_t config->version = H5F__CURR_VFD_SWMR_CONFIG_VERSION; config->pb_expansion_threshold = 0; - config->tick_len = tick_len; - config->max_lag = max_lag; - config->writer = writer; - config->maintain_metadata_file = maintain_metadata_file; - config->generate_updater_files = generate_updater_files; - config->flush_raw_data = flush_raw_data; - config->md_pages_reserved = md_pages_reserved; - - HDva_start(ap, updater_file_path); - - evsnprintf(config->md_file_path, sizeof(config->md_file_path), md_file_fmtstr, ap); + config->tick_len = tick_len; + config->max_lag = max_lag; + config->presume_posix_semantics = presume_posix_semantics; + config->writer = writer; + config->maintain_metadata_file = maintain_metadata_file; + config->generate_updater_files = generate_updater_files; + config->flush_raw_data = flush_raw_data; + config->md_pages_reserved = md_pages_reserved; + + if (md_path_fmtstr == NULL) + config->md_file_path[0] = '\0'; + else { + HDva_start(ap, updater_path_fmtstr); + evsnprintf(config->md_file_path, sizeof(config->md_file_path), md_path_fmtstr, ap); + HDva_end(ap); + } - HDva_end(ap); + if (md_file_fmtstr == NULL) + config->md_file_name[0] = '\0'; + else { + HDva_start(ap, updater_path_fmtstr); + evsnprintf(config->md_file_name, sizeof(config->md_file_name), md_file_fmtstr, ap); + HDva_end(ap); + } - if (config->generate_updater_files && updater_file_path != NULL) - HDstrcpy(config->updater_file_path, updater_file_path); + if (config->generate_updater_files && updater_path_fmtstr != NULL) { + HDva_start(ap, updater_path_fmtstr); + evsnprintf(config->updater_file_path, sizeof(config->updater_file_path), updater_path_fmtstr, ap); + HDva_end(ap); + } } /* init_vfd_swmr_config() */ diff --git a/test/vfd_swmr_common.h b/test/vfd_swmr_common.h index 4fd45b4..8d6f2d5 100644 --- a/test/vfd_swmr_common.h +++ b/test/vfd_swmr_common.h @@ -74,10 +74,11 @@ H5TEST_DLL hid_t vfd_swmr_create_fapl(bool use_latest_format, bool use_vfd_swmr, size_t page_buf_size, H5F_vfd_swmr_config_t *config); H5TEST_DLL void init_vfd_swmr_config(H5F_vfd_swmr_config_t *config, uint32_t tick_len, uint32_t max_lag, - hbool_t writer, hbool_t maintain_metadata_file, - hbool_t generate_updater_files, hbool_t flush_raw_data, - uint32_t md_pages_reserved, const char *md_file_fmtstr, - const char *updater_file_path, ...) H5_ATTR_FORMAT(printf, 9, 11); + hbool_t presume_posix_semantics, hbool_t writer, + hbool_t maintain_metadata_file, hbool_t generate_updater_files, + hbool_t flush_raw_data, uint32_t md_pages_reserved, + const char *md_file_path, const char *md_file_fmtstr, + const char *updater_file_path, ...) H5_ATTR_FORMAT(printf, 11, 13); H5TEST_DLL void init_vfd_swmr_log(H5F_vfd_swmr_config_t *config, const char *log_file_fmtstr, ...) H5_ATTR_FORMAT(printf, 2, 3); diff --git a/test/vfd_swmr_dsetchks_writer.c b/test/vfd_swmr_dsetchks_writer.c index caaad1b..1e4de5a 100644 --- a/test/vfd_swmr_dsetchks_writer.c +++ b/test/vfd_swmr_dsetchks_writer.c @@ -2308,10 +2308,11 @@ main(int argc, char **argv) TEST_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, 4, 7, writer, TRUE, FALSE, s.flush_raw_data, 128, "./dsetchks-shadow", - NULL); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(&config, 4, 7, FALSE, writer, TRUE, FALSE, s.flush_raw_data, 128, "./", + "dsetchks-shadow", NULL); /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ if ((fapl = vfd_swmr_create_fapl(true, s.use_vfd_swmr, true, 4096, &config)) < 0) { diff --git a/test/vfd_swmr_dsetops_writer.c b/test/vfd_swmr_dsetops_writer.c index 8ef0962..cdb84b2 100644 --- a/test/vfd_swmr_dsetops_writer.c +++ b/test/vfd_swmr_dsetops_writer.c @@ -2228,9 +2228,11 @@ main(int argc, char **argv) TEST_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, 4, 7, writer, TRUE, FALSE, s.flush_raw_data, 128, "./dsetops-shadow", NULL); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(&config, 4, 7, FALSE, writer, TRUE, FALSE, s.flush_raw_data, 128, "./", + "dsetops-shadow", NULL); /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ if ((fapl = vfd_swmr_create_fapl(true, s.use_vfd_swmr, true, 4096, &config)) < 0) { diff --git a/test/vfd_swmr_generator.c b/test/vfd_swmr_generator.c index a78abbc..1392293 100644 --- a/test/vfd_swmr_generator.c +++ b/test/vfd_swmr_generator.c @@ -125,9 +125,11 @@ gen_skeleton(const char *filename, hbool_t verbose, hbool_t vfd_swmr_write, int if ((config = HDcalloc(1, sizeof(*config))) == NULL) return -1; - /* 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, 10, vfd_swmr_write, TRUE, FALSE, TRUE, 128, "generator-shadow", NULL); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config, 4, 10, FALSE, vfd_swmr_write, TRUE, FALSE, TRUE, 128, NULL, + "generator-shadow", NULL); } /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ diff --git a/test/vfd_swmr_gfail_writer.c b/test/vfd_swmr_gfail_writer.c index 27d6c31..10370cc 100644 --- a/test/vfd_swmr_gfail_writer.c +++ b/test/vfd_swmr_gfail_writer.c @@ -544,10 +544,11 @@ main(int argc, char **argv) TEST_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, s.tick_len, s.max_lag, writer, TRUE, FALSE, TRUE, 128, "./group-shadow", - NULL); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(&config, s.tick_len, s.max_lag, FALSE, writer, TRUE, FALSE, TRUE, 128, "./", + "group-shadow", NULL); /* If old-style option is chosen, use the earliest file format(H5F_LIBVER_EARLIEST) * as the second parameter of H5Pset_libver_bound() that is called by diff --git a/test/vfd_swmr_gperf_writer.c b/test/vfd_swmr_gperf_writer.c index 66fd22f..c376b51 100644 --- a/test/vfd_swmr_gperf_writer.c +++ b/test/vfd_swmr_gperf_writer.c @@ -2804,10 +2804,11 @@ main(int argc, char **argv) return EXIT_SUCCESS; } - /* 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, s.tick_len, s.max_lag, writer, TRUE, FALSE, FALSE, 128, "./group-shadow", - NULL); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(&config, s.tick_len, s.max_lag, FALSE, writer, TRUE, FALSE, FALSE, 128, "./", + "group-shadow", NULL); /* If the log flag is on, create the log file log-test under the current directory. */ if (s.glog == true) diff --git a/test/vfd_swmr_group_writer.c b/test/vfd_swmr_group_writer.c index 53c9cec..dd387b2 100644 --- a/test/vfd_swmr_group_writer.c +++ b/test/vfd_swmr_group_writer.c @@ -5003,10 +5003,11 @@ main(int argc, char **argv) TEST_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, s.tick_len, s.max_lag, writer, TRUE, FALSE, TRUE, 128, "./group-shadow", - NULL); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(&config, s.tick_len, s.max_lag, FALSE, writer, TRUE, FALSE, TRUE, 128, "./", + "group-shadow", NULL); /* If old-style option is chosen, use the earliest file format(H5F_LIBVER_EARLIEST) * as the second parameter of H5Pset_libver_bound() that is called by diff --git a/test/vfd_swmr_indep_rw_writer.c b/test/vfd_swmr_indep_rw_writer.c index fae4d82..77eee74 100644 --- a/test/vfd_swmr_indep_rw_writer.c +++ b/test/vfd_swmr_indep_rw_writer.c @@ -359,14 +359,16 @@ error: * for the VFD SMWR independence of the reader/writer test. */ static hbool_t -indep_init_vfd_swmr_config_plist(state_t *s, hbool_t writer, const char *mdf_path) +indep_init_vfd_swmr_config_plist(state_t *s, hbool_t writer, const char *mdf_name) { H5F_vfd_swmr_config_t config; - /* 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, s->tick_len, s->max_lag, writer, TRUE, FALSE, TRUE, 128, mdf_path, NULL); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(&config, s->tick_len, s->max_lag, FALSE, writer, TRUE, FALSE, TRUE, 128, "./", + mdf_name, NULL); /* Pass the use_vfd_swmr, only_meta_page, page buffer size, config to vfd_swmr_create_fapl().*/ if ((s->fapl = vfd_swmr_create_fapl(TRUE, s->use_vfd_swmr, TRUE, s->pbs, &config)) < 0) { @@ -645,7 +647,7 @@ main(int argc, char **argv) if (s.first_proc) { writer = TRUE; - if (FALSE == indep_init_vfd_swmr_config_plist(&s, writer, "./file1-shadow")) { + if (FALSE == indep_init_vfd_swmr_config_plist(&s, writer, "file1-shadow")) { HDfprintf(stderr, "Writer: Cannot initialize file property lists for file %s\n", s.filename[0]); TEST_ERROR; } @@ -678,7 +680,7 @@ main(int argc, char **argv) } writer = FALSE; - if (FALSE == indep_init_vfd_swmr_config_plist(&s, writer, "./file2-shadow")) { + if (FALSE == indep_init_vfd_swmr_config_plist(&s, writer, "file2-shadow")) { HDfprintf(stderr, "Reader: Cannot initialize file property lists for file %s\n", s.filename[1]); TEST_ERROR; } @@ -715,7 +717,7 @@ main(int argc, char **argv) * then writes a dataset in the second file for the first process to read. */ writer = FALSE; - if (FALSE == indep_init_vfd_swmr_config_plist(&s, writer, "./file1-shadow")) { + if (FALSE == indep_init_vfd_swmr_config_plist(&s, writer, "file1-shadow")) { HDfprintf(stderr, "Reader: Cannot initialize file property lists for file %s\n", s.filename[0]); TEST_ERROR; } @@ -737,7 +739,7 @@ main(int argc, char **argv) } writer = TRUE; - if (FALSE == indep_init_vfd_swmr_config_plist(&s, writer, "./file2-shadow")) { + if (FALSE == indep_init_vfd_swmr_config_plist(&s, writer, "file2-shadow")) { HDfprintf(stderr, "writer: Cannot initialize file property lists for file %s\n", s.filename[1]); TEST_ERROR; } diff --git a/test/vfd_swmr_reader.c b/test/vfd_swmr_reader.c index 153048c..2e918b0 100644 --- a/test/vfd_swmr_reader.c +++ b/test/vfd_swmr_reader.c @@ -319,9 +319,10 @@ read_records(const char *filename, hbool_t verbose, FILE *verbose_file, unsigned goto 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, 4, 5, FALSE, TRUE, FALSE, TRUE, 128, "rw-shadow", NULL); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config, 4, 5, FALSE, FALSE, TRUE, FALSE, TRUE, 128, NULL, "rw-shadow", NULL); /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ if ((fapl = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, 4096, config)) < 0) { diff --git a/test/vfd_swmr_remove_reader.c b/test/vfd_swmr_remove_reader.c index 9c684f5..775eb76 100644 --- a/test/vfd_swmr_remove_reader.c +++ b/test/vfd_swmr_remove_reader.c @@ -303,9 +303,10 @@ read_records(const char *filename, unsigned verbose, unsigned long nseconds, uns if ((config = HDcalloc(1, sizeof(*config))) == NULL) goto 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, 4, 5, FALSE, TRUE, FALSE, TRUE, 128, "rw-shadow", NULL); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config, 4, 5, FALSE, FALSE, TRUE, FALSE, TRUE, 128, NULL, "rw-shadow", NULL); /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ if ((fapl = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, 4096, config)) < 0) { diff --git a/test/vfd_swmr_remove_writer.c b/test/vfd_swmr_remove_writer.c index 1e40a18..72209f8 100644 --- a/test/vfd_swmr_remove_writer.c +++ b/test/vfd_swmr_remove_writer.c @@ -86,9 +86,10 @@ open_skeleton(const char *filename, unsigned verbose, unsigned old H5_ATTR_UNUSE if ((config = (H5F_vfd_swmr_config_t *)HDcalloc(1, sizeof(H5F_vfd_swmr_config_t))) == NULL) goto 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, 4, 5, TRUE, TRUE, FALSE, TRUE, 128, "rw-shadow", NULL); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config, 4, 5, FALSE, TRUE, TRUE, FALSE, TRUE, 128, NULL, "rw-shadow", NULL); /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ if ((fapl = vfd_swmr_create_fapl(TRUE, TRUE, FALSE, 4096, config)) < 0) diff --git a/test/vfd_swmr_sparse_reader.c b/test/vfd_swmr_sparse_reader.c index 1d9557c..2f7856c 100644 --- a/test/vfd_swmr_sparse_reader.c +++ b/test/vfd_swmr_sparse_reader.c @@ -207,9 +207,10 @@ read_records(const char *filename, unsigned verbose, unsigned long nrecords, uns if ((config = HDcalloc(1, sizeof(H5F_vfd_swmr_config_t))) == NULL) goto 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, 4, 5, FALSE, TRUE, FALSE, TRUE, 128, "rw-shadow", NULL); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config, 4, 5, FALSE, FALSE, TRUE, FALSE, TRUE, 128, NULL, "rw-shadow", NULL); /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ if ((fapl = vfd_swmr_create_fapl(FALSE, TRUE, FALSE, 4096, config)) < 0) { diff --git a/test/vfd_swmr_sparse_writer.c b/test/vfd_swmr_sparse_writer.c index 0d521b7..a233bb3 100644 --- a/test/vfd_swmr_sparse_writer.c +++ b/test/vfd_swmr_sparse_writer.c @@ -86,9 +86,10 @@ open_skeleton(const char *filename, unsigned verbose) if ((config = (H5F_vfd_swmr_config_t *)HDcalloc(1, sizeof(H5F_vfd_swmr_config_t))) == NULL) goto 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, 4, 5, TRUE, TRUE, FALSE, TRUE, 128, "rw-shadow", NULL); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config, 4, 5, FALSE, TRUE, TRUE, FALSE, TRUE, 128, NULL, "rw-shadow", NULL); /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ if ((fapl = vfd_swmr_create_fapl(TRUE, TRUE, FALSE, 4096, config)) < 0) diff --git a/test/vfd_swmr_vlstr_reader.c b/test/vfd_swmr_vlstr_reader.c index cbcc6c0..dc403cf 100644 --- a/test/vfd_swmr_vlstr_reader.c +++ b/test/vfd_swmr_vlstr_reader.c @@ -115,9 +115,10 @@ main(int argc, char **argv) if (argc > 0) errx(EXIT_FAILURE, "unexpected command-line arguments"); - /* 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, FALSE, TRUE, FALSE, TRUE, 128, "./vlstr-shadow", NULL); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(&config, 4, 7, FALSE, false, TRUE, FALSE, TRUE, 128, "./", "vlstr-shadow", NULL); /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ fapl = vfd_swmr_create_fapl(TRUE, use_vfd_swmr, sel == TEST_OOB, 4096, &config); diff --git a/test/vfd_swmr_vlstr_writer.c b/test/vfd_swmr_vlstr_writer.c index 682e86a..6a747a2 100644 --- a/test/vfd_swmr_vlstr_writer.c +++ b/test/vfd_swmr_vlstr_writer.c @@ -152,10 +152,10 @@ main(int argc, char **argv) if (argc > 0) errx(EXIT_FAILURE, "unexpected command-line arguments"); - /* 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, FALSE, TRUE, 128, "./vlstr-shadow", NULL); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(&config, 4, 7, FALSE, true, TRUE, FALSE, TRUE, 128, "./", "vlstr-shadow", NULL); /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ fapl = vfd_swmr_create_fapl(TRUE, use_vfd_swmr, sel == TEST_OOB, 4096, &config); diff --git a/test/vfd_swmr_writer.c b/test/vfd_swmr_writer.c index eeceb49..ba9938f 100644 --- a/test/vfd_swmr_writer.c +++ b/test/vfd_swmr_writer.c @@ -87,9 +87,10 @@ open_skeleton(const char *filename, hbool_t verbose, FILE *verbose_file, unsigne if ((config = (H5F_vfd_swmr_config_t *)HDcalloc(1, sizeof(H5F_vfd_swmr_config_t))) == NULL) return -1; - /* 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, 5, TRUE, TRUE, FALSE, TRUE, 128, "rw-shadow", NULL); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(config, 4, 5, FALSE, TRUE, TRUE, FALSE, TRUE, 128, NULL, "rw-shadow", NULL); /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ if ((fapl = vfd_swmr_create_fapl(TRUE, TRUE, FALSE, 4096, config)) < 0) diff --git a/test/vfd_swmr_zoo_writer.c b/test/vfd_swmr_zoo_writer.c index 32726f7..4a6e61c 100644 --- a/test/vfd_swmr_zoo_writer.c +++ b/test/vfd_swmr_zoo_writer.c @@ -475,9 +475,11 @@ main(int argc, char **argv) parse_command_line_options(argc, argv); - /* 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(&vfd_swmr_config, TICK_LEN, 7, writer, TRUE, FALSE, TRUE, 128, "./zoo-shadow", NULL); + /* config, tick_len, max_lag, presume_posix_semantics, writer, + * maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved, + * md_file_path, md_file_name, updater_file_path */ + init_vfd_swmr_config(&vfd_swmr_config, TICK_LEN, 7, FALSE, writer, TRUE, FALSE, TRUE, 128, "./", + "zoo-shadow", NULL); /* ? turn off use latest format argument via 1st argument? since later on it reset to early format */ /* use_latest_format, use_vfd_swmr, only_meta_page, page_buf_size, config */ diff --git a/utils/test/CMakeLists.txt b/utils/test/CMakeLists.txt index 921fbd0..001fbea 100644 --- a/utils/test/CMakeLists.txt +++ b/utils/test/CMakeLists.txt @@ -20,12 +20,12 @@ macro (ADD_H5_EXE file) endmacro () ############################################################################## -### S W I M M E R T E S T U T I L S ### +### S W M R T E S T U T I L S ### ############################################################################## set (H5_UTIL_TESTS) if (HDF5_TEST_SWMR) - set (H5_UTIL_TESTS ${H5_UTIL_TESTS} swmr_check_compat_vfd) + set (H5_UTIL_TESTS ${H5_UTIL_TESTS} swmr_check_compat_vfd vfd_swmr_check_compat_vfd) endif () if (H5_UTIL_TESTS) diff --git a/utils/test/Makefile.am b/utils/test/Makefile.am index 164562f..ee0a1e2 100644 --- a/utils/test/Makefile.am +++ b/utils/test/Makefile.am @@ -23,7 +23,7 @@ AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/test -I$(top_srcdir)/tools/lib # These are our main targets, the tools -noinst_PROGRAMS=swmr_check_compat_vfd +noinst_PROGRAMS=swmr_check_compat_vfd vfd_swmr_check_compat_vfd # Programs all depend on the hdf5 library, the tools library, and the HL # library. diff --git a/utils/test/vfd_swmr_check_compat_vfd.c b/utils/test/vfd_swmr_check_compat_vfd.c new file mode 100644 index 0000000..daecaad --- /dev/null +++ b/utils/test/vfd_swmr_check_compat_vfd.c @@ -0,0 +1,66 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* Purpose: This is a small program that checks if the HDF5_DRIVER + * environment variable is set to a value that supports SWMR. + * It also checks for parallel HDF5, where page buffering + * is disabled and thus can't be used for VFD SWMR. + * + * It is intended for use in shell scripts. + */ + +#include "h5test.h" + +/* This file needs to access the file driver testing code */ +#define H5FD_FRIEND /*suppress error about including H5FDpkg */ +#define H5FD_TESTING +#include "H5FDpkg.h" /* File drivers */ + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Inspects the HDF5_DRIVER environment variable, which + * determines the VFD that the test harness will use with + * the majority of the tests. + * + * Also checks for parallel HDF5, which does not support + * VFD SWMR. + * + * Return: VFD supports SWMR: EXIT_SUCCESS + * + * VFD does not support SWMR + * or failure: EXIT_FAILURE + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ +#ifdef H5_HAVE_PARALLEL + + return EXIT_FAILURE; + +#else + + char *driver = NULL; + + driver = HDgetenv(HDF5_DRIVER); + + if (H5FD__supports_swmr_test(driver)) + return EXIT_SUCCESS; + else + return EXIT_FAILURE; + +#endif + +} /* end main() */ |