From 14c286d51a13658ea26673efa3f197af06757cee Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Fri, 19 May 2017 14:58:34 -0700 Subject: Fixed HDFFV-10214: * Updated comments in the library to accurately reflect the semantics of the H5FD_FEAT_POSIX_COMPAT_HANDLE flag. * Removed the check for the POSIX compatible handle feature flag when determining if a VFD supports SWMR. Partial work for HDFFV-10197: * Added a new H5FD_FEAT_DEFAULT_VFD_COMPATIBLE feature flag that is set when a VFD creates output that is compatible with the default VFD. Will be used in the testing but might also be generally useful to users. --- src/H5FDcore.c | 8 +++++--- src/H5FDdirect.c | 1 + src/H5FDlog.c | 3 ++- src/H5FDmpio.c | 9 +++++---- src/H5FDpublic.h | 8 ++++++++ src/H5FDsec2.c | 3 ++- src/H5FDstdio.c | 9 +++++---- src/H5Fint.c | 4 ---- 8 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/H5FDcore.c b/src/H5FDcore.c index d100a8b..b980b7e 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -982,9 +982,11 @@ 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 */ - /* If the backing store is open, a POSIX file handle is available */ - if(file && file->fd >= 0 && file->backing_store) - *flags |= H5FD_FEAT_POSIX_COMPAT_HANDLE; /* VFD handle is POSIX I/O call compatible */ + /* 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 */ + *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default VFD */ + } } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c index 1487cda..7a4c99c 100644 --- a/src/H5FDdirect.c +++ b/src/H5FDdirect.c @@ -698,6 +698,7 @@ H5FD_direct_query(const H5FD_t H5_ATTR_UNUSED * _f, unsigned long *flags /* out *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ *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 */ } FUNC_LEAVE_NOAPI(SUCCEED) diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 75333c2..7c6bbd4 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -895,8 +895,9 @@ H5FD_log_query(const H5FD_t *_file, unsigned long *flags /* out */) *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ - *flags |= H5FD_FEAT_POSIX_COMPAT_HANDLE; /* VFD handle is POSIX I/O call compatible */ + *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_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default VFD */ /* Check for flags that are set by h5repart */ if(file && file->fam_to_sec2) diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c index ace91f8..f594d8e 100644 --- a/src/H5FDmpio.c +++ b/src/H5FDmpio.c @@ -1150,10 +1150,11 @@ H5FD_mpio_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags /* out /* Set the VFL feature flags that this driver supports */ if(flags) { *flags=0; - *flags|=H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ - *flags|=H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ - *flags|=H5FD_FEAT_HAS_MPI; /* This driver uses MPI */ - *flags|=H5FD_FEAT_ALLOCATE_EARLY; /* Allocate space early instead of late */ + *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ + *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ + *flags |= H5FD_FEAT_HAS_MPI; /* This driver uses MPI */ + *flags |= H5FD_FEAT_ALLOCATE_EARLY; /* Allocate space early instead of late */ + *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default VFD */ } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) diff --git a/src/H5FDpublic.h b/src/H5FDpublic.h index 3032e8a..45b1237 100644 --- a/src/H5FDpublic.h +++ b/src/H5FDpublic.h @@ -250,6 +250,14 @@ typedef enum H5F_mem_t H5FD_mem_t; * This is specifically used for the multi/split driver. */ #define H5FD_FEAT_PAGED_AGGR 0x00004000 + /* + * Defining H5FD_FEAT_DEFAULT_VFD_COMPATIBLE for a VFL driver + * that creates a file which is compatible with the default VFD. + * Generally, this means that the VFD creates a single file that follows + * the canonical HDF5 file format. + */ +#define H5FD_FEAT_DEFAULT_VFD_COMPATIBLE 0x00008000 + /* Forward declaration */ typedef struct H5FD_t H5FD_t; diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index 26913e2..b6385fb 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -527,8 +527,9 @@ H5FD_sec2_query(const H5FD_t *_file, unsigned long *flags /* out */) *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ - *flags |= H5FD_FEAT_POSIX_COMPAT_HANDLE; /* VFD handle is POSIX I/O call compatible */ + *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_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default VFD */ /* Check for flags that are set by h5repart */ if(file && file->fam_to_sec2) diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index 5023af3..861c6a6 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -555,10 +555,11 @@ H5FD_stdio_query(const H5FD_t *_f, unsigned long /*OUT*/ *flags) */ if(flags) { *flags = 0; - *flags|=H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ - *flags|=H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ - *flags|=H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ - *flags|=H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ + *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ + *flags |= H5FD_FEAT_ACCUMULATE_METADATA; /* OK to accumulate metadata for faster writes */ + *flags |= H5FD_FEAT_DATA_SIEVE; /* OK to perform data sieving for faster raw data reads & writes */ + *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 */ } return 0; diff --git a/src/H5Fint.c b/src/H5Fint.c index fe532b2..e52d539 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -715,10 +715,6 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t if(!H5F_HAS_FEATURE(f, H5FD_FEAT_SUPPORTS_SWMR_IO) && (H5F_INTENT(f) & (H5F_ACC_SWMR_WRITE | H5F_ACC_SWMR_READ))) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "must use a SWMR-compatible VFD when SWMR is specified") - /* Require a POSIX compatible VFD to use SWMR feature */ - /* (It's reasonable to try to expand this to other VFDs eventually -QAK) */ - if(!H5F_HAS_FEATURE(f, H5FD_FEAT_POSIX_COMPAT_HANDLE) && (H5F_INTENT(f) & (H5F_ACC_SWMR_WRITE | H5F_ACC_SWMR_READ))) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "must use POSIX compatible VFD with SWMR write access") if(H5FD_get_fs_type_map(lf, f->shared->fs_type_map) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get free space type mapping from VFD") if(H5MF_init_merge_flags(f) < 0) -- cgit v0.12 From e3b22b8fa45697d6f73330b33cd201c37e0335d6 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 24 May 2017 06:51:45 -0400 Subject: Initialized IDs to -1 and minor code tidy. --- test/swmr.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/swmr.c b/test/swmr.c index 399a9ec..5b50d63 100644 --- a/test/swmr.c +++ b/test/swmr.c @@ -116,12 +116,12 @@ static int test_multiple_same(hid_t in_fapl, hbool_t new_format); static int test_metadata_read_attempts(hid_t in_fapl) { - hid_t fapl; /* File access property list */ - hid_t file_fapl; /* The file's access property list */ - hid_t fid, fid1, fid2; /* File IDs */ - unsigned attempts; /* The # of read attempts */ - char filename[NAME_BUF_SIZE]; /* File name */ - herr_t ret; /* Generic return value */ + hid_t fapl = -1; /* File access property list */ + hid_t file_fapl = -1; /* The file's access property list */ + hid_t fid = -1, fid1 = -1, fid2 = -1; /* File IDs */ + unsigned attempts; /* The # of read attempts */ + char filename[NAME_BUF_SIZE]; /* File name */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ TESTING("H5Pget/set_metadata_read_attempts()"); -- cgit v0.12 From e5a57c97aa43d6c76d1bb1fe64d24aaa0bbbb7d3 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 24 May 2017 07:44:18 -0400 Subject: * Made H5FD_driver_query() a private function instead of static. * Moved H5FD_driver_query() to H5FDint.c. * Minor typo fixes in H5I.c. * Updated swmr.c to check the VFD feature flags and skip the retries test when the VFD is not compatible with H5P_DEFAULT. --- src/H5FD.c | 37 ------------------------------------- src/H5FDint.c | 37 +++++++++++++++++++++++++++++++++++++ src/H5FDprivate.h | 1 + src/H5I.c | 4 ++-- test/swmr.c | 36 ++++++++++++++++++++++++++++++------ 5 files changed, 70 insertions(+), 45 deletions(-) diff --git a/src/H5FD.c b/src/H5FD.c index dcfaa6d..d3cb77c 100644 --- a/src/H5FD.c +++ b/src/H5FD.c @@ -62,7 +62,6 @@ /********************/ static herr_t H5FD_free_cls(H5FD_class_t *cls); static int H5FD_query(const H5FD_t *f, unsigned long *flags/*out*/); -static int H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags/*out*/); /*********************/ /* Package Variables */ @@ -1085,42 +1084,6 @@ H5FD_query(const H5FD_t *f, unsigned long *flags/*out*/) /*------------------------------------------------------------------------- -* Function: H5FD_driver_query -* -* Purpose: Similar to H5FD_query(), but intended for cases when we don't -* have a file available (e.g. before one is opened). Since we -* can't use the file to get the driver, the driver is passed in -* as a parameter. -* -* Return: Success: non-negative -* Failure: negative -* -* Programmer: Jacob Gruber -* Wednesday, August 17, 2011 -* -*------------------------------------------------------------------------- -*/ -static int -H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags/*out*/) -{ - int ret_value = 0; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - HDassert(driver); - HDassert(flags); - - /* Check for the driver to query and then query it */ - if(driver->query) - ret_value = (driver->query)(NULL, flags); - else - *flags = 0; - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_driver_query() */ - - -/*------------------------------------------------------------------------- * Function: H5FDalloc * * Purpose: Allocates SIZE bytes of memory from the FILE. The memory will diff --git a/src/H5FDint.c b/src/H5FDint.c index bc322d6..ccf0f2e 100644 --- a/src/H5FDint.c +++ b/src/H5FDint.c @@ -433,3 +433,40 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_get_eof() */ + +/*------------------------------------------------------------------------- +* Function: H5FD_driver_query +* +* Purpose: Similar to H5FD_query(), but intended for cases when we don't +* have a file available (e.g. before one is opened). Since we +* can't use the file to get the driver, the driver is passed in +* as a parameter. +* +* Return: Success: non-negative +* Failure: negative +* +* Programmer: Jacob Gruber +* Wednesday, August 17, 2011 +* +*------------------------------------------------------------------------- +*/ +int +H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags/*out*/) +{ + int ret_value = 0; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(driver); + HDassert(flags); + + /* Check for the driver to query and then query it */ + if(driver->query) + ret_value = (driver->query)(NULL, flags); + else + *flags = 0; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_driver_query() */ + + diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h index 0fc2135..589e391 100644 --- a/src/H5FDprivate.h +++ b/src/H5FDprivate.h @@ -153,6 +153,7 @@ H5_DLL H5FD_t *H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); H5_DLL herr_t H5FD_close(H5FD_t *file); H5_DLL int H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2); +H5_DLL int H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags/*out*/); H5_DLL haddr_t H5FD_alloc(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, struct H5F_t *f, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size); H5_DLL herr_t H5FD_free(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, struct H5F_t *f, diff --git a/src/H5I.c b/src/H5I.c index ce4ecdc..42edf58 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -888,7 +888,7 @@ H5I_subst(hid_t id, const void *new_object) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end if */ +} /* end H5I_subst() */ /*------------------------------------------------------------------------- @@ -920,7 +920,7 @@ H5I_object(hid_t id) } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end if */ +} /* end H5I_object() */ /*------------------------------------------------------------------------- diff --git a/test/swmr.c b/test/swmr.c index 5b50d63..9239ca2 100644 --- a/test/swmr.c +++ b/test/swmr.c @@ -116,16 +116,40 @@ static int test_multiple_same(hid_t in_fapl, hbool_t new_format); static int test_metadata_read_attempts(hid_t in_fapl) { - hid_t fapl = -1; /* File access property list */ - hid_t file_fapl = -1; /* The file's access property list */ - hid_t fid = -1, fid1 = -1, fid2 = -1; /* File IDs */ - unsigned attempts; /* The # of read attempts */ - char filename[NAME_BUF_SIZE]; /* File name */ - herr_t ret; /* Generic return value */ + hid_t fapl = -1; /* File access property list */ + hid_t file_fapl = -1; /* The file's access property list */ + hid_t fid = -1, fid1 = -1, fid2 = -1; /* File IDs */ + hid_t driver_id = -1; /* ID for this VFD */ + H5FD_class_t *driver = NULL; /* Pointer to VFD class struct */ + unsigned long driver_flags = 0; /* VFD feature flags */ + hbool_t compat_w_default_vfd; /* current VFD compat w/ H5P_DEFAULT? */ + unsigned attempts; /* The # of read attempts */ + char filename[NAME_BUF_SIZE]; /* File name */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ TESTING("H5Pget/set_metadata_read_attempts()"); + /* Check if the driver is compatible with the default VFD. + * Most of the tests will attempt to create and open files with both the + * VFD specified in the passed-in fapl and the default VFD. Since this + * will clearly not work with VFDs that are not compatible with the default + * fapl (e.g.: split/multi), we just skip this entire test. + */ + if ((driver_id = H5Pget_driver(in_fapl)) < 0) + FAIL_STACK_ERROR + if (NULL == (driver = (H5FD_class_t *)H5I_object_verify(driver_id, H5I_VFL))) + FAIL_STACK_ERROR + if (H5FD_driver_query(driver, &driver_flags) < 0) + FAIL_STACK_ERROR + compat_w_default_vfd = (driver_flags & H5FD_FEAT_DEFAULT_VFD_COMPATIBLE) ? TRUE : FALSE; + + if (!compat_w_default_vfd) { + SKIPPED() + HDputs(" The current VFD is not compatible with the default VFD."); + return 0; + } + /* Get a copy of the parameter fapl */ if((fapl = H5Pcopy(in_fapl)) < 0) FAIL_STACK_ERROR -- cgit v0.12 From 479f326a267ca5ffacc2012f33674c66cf2907d8 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 24 May 2017 09:41:26 -0400 Subject: * Added new public H5FDdriver_query() API call. * Changed return type of H5FD_driver_query() to herr_t. * Updated swmr.c to use H5FDdriver_query() instead of the private call. * Added some flags tests to vfd.c. --- src/H5FD.c | 42 +++++++++++++++++++++++++++++++++++++++++- src/H5FDint.c | 8 +++----- src/H5FDprivate.h | 2 +- src/H5FDpublic.h | 3 +++ test/swmr.c | 5 +---- test/vfd.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 97 insertions(+), 11 deletions(-) diff --git a/src/H5FD.c b/src/H5FD.c index d3cb77c..67cf963 100644 --- a/src/H5FD.c +++ b/src/H5FD.c @@ -789,7 +789,8 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, NULL, "file driver has no `open' method") /* Query driver flag */ - H5FD_driver_query(driver, &driver_flags); + if(H5FD_driver_query(driver, &driver_flags) < 0) + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, NULL, "can't query VFD flags") /* Get initial file image info */ if(H5P_peek(plist, H5F_ACS_FILE_IMAGE_INFO_NAME, &file_image_info) < 0) @@ -2039,3 +2040,42 @@ H5FD_set_paged_aggr(H5FD_t *file, hbool_t paged) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_set_paged_aggr() */ + + +/*------------------------------------------------------------------------- +* Function: H5FDdriver_query +* +* Purpose: Similar to H5FD_query(), but intended for cases when we don't +* have a file available (e.g. before one is opened). Since we +* can't use the file to get the driver, the driver ID is passed +* in as a parameter. +* +* Return: SUCCEED/FAIL +* +* Programmer: Jacob Gruber +* Wednesday, August 17, 2011 +* +*------------------------------------------------------------------------- +*/ +herr_t +H5FDdriver_query(hid_t driver_id, unsigned long *flags/*out*/) +{ + H5FD_class_t *driver = NULL; /* Pointer to VFD class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "ix", driver_id, flags); + + if(NULL == flags) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "flags parameter cannot be NULL") + + /* Check for the driver to query and then query it */ + if (NULL == (driver = (H5FD_class_t *)H5I_object_verify(driver_id, H5I_VFL))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a VFL ID") + if (H5FD_driver_query(driver, flags) < 0) + HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "driver flag query failed") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5FDdriver_query() */ + diff --git a/src/H5FDint.c b/src/H5FDint.c index ccf0f2e..52fbc23 100644 --- a/src/H5FDint.c +++ b/src/H5FDint.c @@ -442,18 +442,17 @@ done: * can't use the file to get the driver, the driver is passed in * as a parameter. * -* Return: Success: non-negative -* Failure: negative +* Return: SUCCEED/FAIL * * Programmer: Jacob Gruber * Wednesday, August 17, 2011 * *------------------------------------------------------------------------- */ -int +herr_t H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags/*out*/) { - int ret_value = 0; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -469,4 +468,3 @@ H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags/*out*/) FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_driver_query() */ - diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h index 589e391..e758951 100644 --- a/src/H5FDprivate.h +++ b/src/H5FDprivate.h @@ -153,7 +153,7 @@ H5_DLL H5FD_t *H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); H5_DLL herr_t H5FD_close(H5FD_t *file); H5_DLL int H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2); -H5_DLL int H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags/*out*/); +H5_DLL herr_t H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags/*out*/); H5_DLL haddr_t H5FD_alloc(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, struct H5F_t *f, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size); H5_DLL herr_t H5FD_free(H5FD_t *file, hid_t dxpl_id, H5FD_mem_t type, struct H5F_t *f, diff --git a/src/H5FDpublic.h b/src/H5FDpublic.h index 45b1237..514d1bf 100644 --- a/src/H5FDpublic.h +++ b/src/H5FDpublic.h @@ -384,6 +384,9 @@ H5_DLL herr_t H5FDtruncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing); H5_DLL herr_t H5FDlock(H5FD_t *file, hbool_t rw); H5_DLL herr_t H5FDunlock(H5FD_t *file); +/* Allows querying a VFD ID for features before the file is opened */ +H5_DLL herr_t H5FDdriver_query(hid_t driver_id, unsigned long *flags/*out*/); + #ifdef __cplusplus } #endif diff --git a/test/swmr.c b/test/swmr.c index 9239ca2..3b1bd09 100644 --- a/test/swmr.c +++ b/test/swmr.c @@ -120,7 +120,6 @@ test_metadata_read_attempts(hid_t in_fapl) hid_t file_fapl = -1; /* The file's access property list */ hid_t fid = -1, fid1 = -1, fid2 = -1; /* File IDs */ hid_t driver_id = -1; /* ID for this VFD */ - H5FD_class_t *driver = NULL; /* Pointer to VFD class struct */ unsigned long driver_flags = 0; /* VFD feature flags */ hbool_t compat_w_default_vfd; /* current VFD compat w/ H5P_DEFAULT? */ unsigned attempts; /* The # of read attempts */ @@ -138,9 +137,7 @@ test_metadata_read_attempts(hid_t in_fapl) */ if ((driver_id = H5Pget_driver(in_fapl)) < 0) FAIL_STACK_ERROR - if (NULL == (driver = (H5FD_class_t *)H5I_object_verify(driver_id, H5I_VFL))) - FAIL_STACK_ERROR - if (H5FD_driver_query(driver, &driver_flags) < 0) + if (H5FDdriver_query(driver_id, &driver_flags) < 0) FAIL_STACK_ERROR compat_w_default_vfd = (driver_flags & H5FD_FEAT_DEFAULT_VFD_COMPATIBLE) ? TRUE : FALSE; diff --git a/test/vfd.c b/test/vfd.c index 1932d2c..213cd9c 100644 --- a/test/vfd.c +++ b/test/vfd.c @@ -86,6 +86,8 @@ test_sec2(void) hid_t fid = -1; /* file ID */ hid_t fapl_id = -1; /* file access property list ID */ hid_t fapl_id_out = -1; /* from H5Fget_access_plist */ + hid_t driver_id = -1; /* ID for this VFD */ + unsigned long driver_flags = 0; /* VFD feature flags */ char filename[1024]; /* filename */ void *os_file_handle = NULL; /* OS file handle */ hsize_t file_size; /* file size */ @@ -102,6 +104,28 @@ test_sec2(void) if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) TEST_ERROR; + /* Check that the VFD feature flags are correct */ + if ((driver_id = H5Pget_driver(fapl_id)) < 0) + TEST_ERROR + if (H5FDdriver_query(driver_id, &driver_flags) < 0) + TEST_ERROR + if(!(driver_flags & H5FD_FEAT_AGGREGATE_METADATA)) TEST_ERROR + if(!(driver_flags & H5FD_FEAT_ACCUMULATE_METADATA)) TEST_ERROR + if(!(driver_flags & H5FD_FEAT_DATA_SIEVE)) TEST_ERROR + if(!(driver_flags & H5FD_FEAT_AGGREGATE_SMALLDATA)) TEST_ERROR + if(!(driver_flags & H5FD_FEAT_POSIX_COMPAT_HANDLE)) TEST_ERROR + if(!(driver_flags & H5FD_FEAT_SUPPORTS_SWMR_IO)) 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)) + TEST_ERROR + /* Retrieve the access property list... */ if((fapl_id_out = H5Fget_access_plist(fid)) < 0) TEST_ERROR; @@ -174,6 +198,8 @@ test_core(void) hid_t fid = -1; /* file ID */ hid_t fapl_id = -1; /* file access property list ID */ hid_t fapl_id_out = -1; /* from H5Fget_access_plist */ + hid_t driver_id = -1; /* ID for this VFD */ + unsigned long driver_flags = 0; /* VFD feature flags */ hid_t did = -1; /* dataset ID */ hid_t sid = -1; /* dataspace ID */ char filename[1024]; /* filename */ @@ -219,6 +245,28 @@ test_core(void) if(HDaccess(filename, F_OK) != -1) FAIL_PUTS_ERROR("file created when backing store set to FALSE"); + /* Check that the VFD feature flags are correct. + * Note that the H5FDdriver_query() API call does not require a file + * so backing-store related flags will not be returned here. + */ + if ((driver_id = H5Pget_driver(fapl_id)) < 0) + TEST_ERROR + if (H5FDdriver_query(driver_id, &driver_flags) < 0) + TEST_ERROR + if(!(driver_flags & H5FD_FEAT_AGGREGATE_METADATA)) TEST_ERROR + if(!(driver_flags & H5FD_FEAT_ACCUMULATE_METADATA)) TEST_ERROR + if(!(driver_flags & H5FD_FEAT_DATA_SIEVE)) TEST_ERROR + if(!(driver_flags & H5FD_FEAT_AGGREGATE_SMALLDATA)) TEST_ERROR + if(!(driver_flags & H5FD_FEAT_ALLOW_FILE_IMAGE)) 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)) + TEST_ERROR /************************************************************************ * Check basic core VFD operation and properties. This is done with the -- cgit v0.12 From 13d3d4bd0e0b799aa9c3a9b45e445d1f52294d47 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Fri, 26 May 2017 18:22:07 -0400 Subject: Added feature flag checks for a few other VFDs in test/vfd.c. --- test/vfd.c | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 116 insertions(+), 10 deletions(-) diff --git a/test/vfd.c b/test/vfd.c index 213cd9c..f8e5761 100644 --- a/test/vfd.c +++ b/test/vfd.c @@ -101,9 +101,6 @@ test_sec2(void) TEST_ERROR; h5_fixname(FILENAME[0], fapl_id, filename, sizeof(filename)); - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) - TEST_ERROR; - /* Check that the VFD feature flags are correct */ if ((driver_id = H5Pget_driver(fapl_id)) < 0) TEST_ERROR @@ -126,6 +123,9 @@ test_sec2(void) | H5FD_FEAT_DEFAULT_VFD_COMPATIBLE)) TEST_ERROR + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) + TEST_ERROR; + /* Retrieve the access property list... */ if((fapl_id_out = H5Fget_access_plist(fid)) < 0) TEST_ERROR; @@ -234,16 +234,10 @@ test_core(void) if(HDaccess(filename, F_OK) != -1) if(HDremove(filename) < 0) FAIL_PUTS_ERROR("unable to remove backing store file"); + /* Create and close file w/ backing store off */ if(H5Pset_fapl_core(fapl_id, (size_t)CORE_INCREMENT, FALSE) < 0) TEST_ERROR; - if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) - TEST_ERROR; - if(H5Fclose(fid) < 0) - TEST_ERROR; - /* Check for the backing store file */ - if(HDaccess(filename, F_OK) != -1) - FAIL_PUTS_ERROR("file created when backing store set to FALSE"); /* Check that the VFD feature flags are correct. * Note that the H5FDdriver_query() API call does not require a file @@ -268,6 +262,14 @@ test_core(void) | H5FD_FEAT_CAN_USE_FILE_IMAGE_CALLBACKS)) TEST_ERROR + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) + TEST_ERROR; + if(H5Fclose(fid) < 0) + TEST_ERROR; + /* Check for the backing store file */ + if(HDaccess(filename, F_OK) != -1) + FAIL_PUTS_ERROR("file created when backing store set to FALSE"); + /************************************************************************ * Check basic core VFD operation and properties. This is done with the * backing store on so a file will be created for later use. @@ -843,6 +845,8 @@ test_family(void) { hid_t file=-1, fapl=-1, fapl2=-1, space=-1, dset=-1; hid_t access_fapl = -1; + hid_t driver_id = -1; /* ID for this VFD */ + unsigned long driver_flags = 0; /* VFD feature flags */ char filename[1024]; char dname[]="dataset"; unsigned int i, j; @@ -860,6 +864,22 @@ test_family(void) TEST_ERROR; h5_fixname(FILENAME[2], fapl, filename, sizeof(filename)); + /* Check that the VFD feature flags are correct */ + if ((driver_id = H5Pget_driver(fapl)) < 0) + TEST_ERROR + if (H5FDdriver_query(driver_id, &driver_flags) < 0) + TEST_ERROR + if(!(driver_flags & H5FD_FEAT_AGGREGATE_METADATA)) TEST_ERROR + if(!(driver_flags & H5FD_FEAT_ACCUMULATE_METADATA)) TEST_ERROR + if(!(driver_flags & H5FD_FEAT_DATA_SIEVE)) TEST_ERROR + if(!(driver_flags & H5FD_FEAT_AGGREGATE_SMALLDATA)) 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)) + TEST_ERROR + if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; @@ -1144,6 +1164,8 @@ test_multi(void) hid_t file=-1, fapl=-1, fapl2=-1, dset=-1, space=-1; hid_t root=-1, attr=-1, aspace=-1, atype=-1; hid_t access_fapl = -1; + hid_t driver_id = -1; /* ID for this VFD */ + unsigned long driver_flags = 0; /* VFD feature flags */ char filename[1024]; int *fhandle2=NULL, *fhandle=NULL; hsize_t file_size; @@ -1200,6 +1222,22 @@ test_multi(void) TEST_ERROR; h5_fixname(FILENAME[4], fapl, filename, sizeof filename); + /* Check that the VFD feature flags are correct */ + if ((driver_id = H5Pget_driver(fapl)) < 0) + TEST_ERROR + if (H5FDdriver_query(driver_id, &driver_flags) < 0) + TEST_ERROR + if(!(driver_flags & H5FD_FEAT_DATA_SIEVE)) TEST_ERROR + if(!(driver_flags & H5FD_FEAT_AGGREGATE_SMALLDATA)) TEST_ERROR + if(!(driver_flags & H5FD_FEAT_USE_ALLOC_SIZE)) TEST_ERROR + if(!(driver_flags & H5FD_FEAT_PAGED_AGGR)) TEST_ERROR + /* Check for extra flags not accounted for above */ + if(driver_flags != (H5FD_FEAT_DATA_SIEVE + | H5FD_FEAT_AGGREGATE_SMALLDATA + | H5FD_FEAT_USE_ALLOC_SIZE + | H5FD_FEAT_PAGED_AGGR)) + TEST_ERROR + if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; @@ -1532,6 +1570,8 @@ test_log(void) hid_t file = -1; hid_t fapl = -1; hid_t access_fapl = -1; + hid_t driver_id = -1; /* ID for this VFD */ + unsigned long driver_flags = 0; /* VFD feature flags */ char filename[1024]; int *fhandle = NULL; hsize_t file_size = 0; @@ -1547,6 +1587,28 @@ test_log(void) TEST_ERROR; h5_fixname(FILENAME[6], fapl, filename, sizeof filename); + /* Check that the VFD feature flags are correct */ + if ((driver_id = H5Pget_driver(fapl)) < 0) + TEST_ERROR + if (H5FDdriver_query(driver_id, &driver_flags) < 0) + TEST_ERROR + if(!(driver_flags & H5FD_FEAT_AGGREGATE_METADATA)) TEST_ERROR + if(!(driver_flags & H5FD_FEAT_ACCUMULATE_METADATA)) TEST_ERROR + if(!(driver_flags & H5FD_FEAT_DATA_SIEVE)) TEST_ERROR + if(!(driver_flags & H5FD_FEAT_AGGREGATE_SMALLDATA)) TEST_ERROR + if(!(driver_flags & H5FD_FEAT_POSIX_COMPAT_HANDLE)) TEST_ERROR + if(!(driver_flags & H5FD_FEAT_SUPPORTS_SWMR_IO)) 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)) + TEST_ERROR + /* Create the test file */ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; @@ -1619,6 +1681,8 @@ test_stdio(void) hid_t file = -1; hid_t fapl = -1; hid_t access_fapl = -1; + hid_t driver_id = -1; /* ID for this VFD */ + unsigned long driver_flags = 0; /* VFD feature flags */ char filename[1024]; FILE *fhandle = NULL; hsize_t file_size = 0; @@ -1632,6 +1696,24 @@ test_stdio(void) TEST_ERROR; h5_fixname(FILENAME[7], fapl, filename, sizeof filename); + /* Check that the VFD feature flags are correct */ + if ((driver_id = H5Pget_driver(fapl)) < 0) + TEST_ERROR + if (H5FDdriver_query(driver_id, &driver_flags) < 0) + TEST_ERROR + if(!(driver_flags & H5FD_FEAT_AGGREGATE_METADATA)) TEST_ERROR + if(!(driver_flags & H5FD_FEAT_ACCUMULATE_METADATA)) TEST_ERROR + if(!(driver_flags & H5FD_FEAT_DATA_SIEVE)) 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)) + TEST_ERROR + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; @@ -1706,6 +1788,8 @@ test_windows(void) hid_t file = -1; hid_t fapl = -1; hid_t access_fapl = -1; + hid_t driver_id = -1; /* ID for this VFD */ + unsigned long driver_flags = 0; /* VFD feature flags */ char filename[1024]; int *fhandle = NULL; hsize_t file_size = 0; @@ -1728,6 +1812,28 @@ test_windows(void) TEST_ERROR; h5_fixname(FILENAME[8], fapl, filename, sizeof filename); + /* Check that the VFD feature flags are correct */ + if ((driver_id = H5Pget_driver(fapl_id)) < 0) + TEST_ERROR + if (H5FDdriver_query(driver_id, &driver_flags) < 0) + TEST_ERROR + if(!(driver_flags & H5FD_FEAT_AGGREGATE_METADATA)) TEST_ERROR + if(!(driver_flags & H5FD_FEAT_ACCUMULATE_METADATA)) TEST_ERROR + if(!(driver_flags & H5FD_FEAT_DATA_SIEVE)) TEST_ERROR + if(!(driver_flags & H5FD_FEAT_AGGREGATE_SMALLDATA)) TEST_ERROR + if(!(driver_flags & H5FD_FEAT_POSIX_COMPAT_HANDLE)) TEST_ERROR + if(!(driver_flags & H5FD_FEAT_SUPPORTS_SWMR_IO)) 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)) + TEST_ERROR + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; -- cgit v0.12