summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/VFD_SWMR_Punch_List.md5
-rw-r--r--src/H5Fint.c68
-rw-r--r--test/vfd_swmr.c40
3 files changed, 65 insertions, 48 deletions
diff --git a/doc/VFD_SWMR_Punch_List.md b/doc/VFD_SWMR_Punch_List.md
index 94c8edd..851094a 100644
--- a/doc/VFD_SWMR_Punch_List.md
+++ b/doc/VFD_SWMR_Punch_List.md
@@ -127,3 +127,8 @@ This document lives at [https://bitbucket.hdfgroup.org/users/dyoung/repos/vchoi_
27. **Vailin, complete** Change the field name "vfd_swmr_writer" to "writer" in
"struct H5F_vfd_swmr_config_t" and all references to it. See page 11 in the RFC.
+
+28. **Vailin, complete** Fix bug as stated on page 9 in the RFC section 3.1.1:
+ Given that the VFD SWMR configuration FAPL property is set, the writer field must
+ be consistent with the flags passed in the H5Fopen() (either H5F_ACC_RDWR for the
+ VFD SWMR writer, or H5F_ACC_RDONLY for the VFD SWMR readers).
diff --git a/src/H5Fint.c b/src/H5Fint.c
index 5321698..db1b7de 100644
--- a/src/H5Fint.c
+++ b/src/H5Fint.c
@@ -44,42 +44,6 @@
/* Local Macros */
/****************/
-/* VFD SWMR */
-
-/* Prepend entry to the delayed free spaced release linked list */
-#define H5F_DC_PREPEND(entry_ptr, head_ptr, tail_ptr, len) \
-{ \
- if((head_ptr) == NULL) { \
- (head_ptr) = (entry_ptr); \
- (tail_ptr) = (entry_ptr); \
- } else { \
- (head_ptr)->prev = (entry_ptr); \
- (entry_ptr)->next = (head_ptr); \
- (head_ptr) = (entry_ptr); \
- } \
- (len)++; \
-} /* H5F_DC_PREPEND() */
-
-/* Remove entry from delayed free spaced release linked list */
-#define H5F_DC_REMOVE(entry_ptr, head_ptr, tail_ptr, len) \
-{ \
- if((head_ptr) == (entry_ptr)) { \
- (head_ptr) = (entry_ptr)->next; \
- if((head_ptr) != NULL ) \
- (head_ptr)->prev = NULL; \
- } else \
- (entry_ptr)->prev->next = (entry_ptr)->next; \
- if((tail_ptr) == (entry_ptr)) { \
- (tail_ptr) = (entry_ptr)->prev; \
- if((tail_ptr) != NULL) \
- (tail_ptr)->next = NULL; \
- } else \
- (entry_ptr)->next->prev = (entry_ptr)->prev; \
- entry_ptr->next = NULL; \
- entry_ptr->prev = NULL; \
- (len)--; \
-} /* H5F_DC_REMOVE() */
-
/******************/
/* Local Typedefs */
/******************/
@@ -1515,6 +1479,27 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id)
FUNC_ENTER_NOAPI(NULL)
+ /* 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")
+
+ /* Allocate space for VFD SWMR configuration info */
+ if(NULL == (vfd_swmr_config_ptr = (H5F_vfd_swmr_config_t *)H5MM_calloc(sizeof(H5F_vfd_swmr_config_t))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't allocate memory for mdc log file name")
+
+ /* Get VFD SWMR configuration */
+ if(H5P_get(a_plist, H5F_ACS_VFD_SWMR_CONFIG_NAME, vfd_swmr_config_ptr) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get VFD SWMR config info")
+
+ /* When configured with VFD SWMR */
+ if(vfd_swmr_config_ptr->version) {
+ /* Verify that file access flags are consistent with VFD SWMR configuartion */
+ if((flags & H5F_ACC_RDWR) && !vfd_swmr_config_ptr->writer)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "file access is writer but VFD SWMR config is reader")
+ if((flags & H5F_ACC_RDWR) == 0 && vfd_swmr_config_ptr->writer)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "file access is reader but VFD SWMR config is writer")
+ }
+
/*
* 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
@@ -1664,10 +1649,6 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id)
shared = file->shared;
lf = shared->lf;
- /* 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 page buffering is enabled */
if(H5P_get(a_plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, &page_buf_size) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get page buffer size")
@@ -1745,6 +1726,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id)
if(H5F_vfd_swmr_init(file, file_create) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTSET, NULL, "file open fail with initialization for VFD SWMR")
}
+
/* Insert the entry that corresponds to file onto the EOT queue */
if(H5F_vfd_swmr_insert_entry_eot(file) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTSET, NULL, "unable to insert entry into the EOT queue")
@@ -1752,12 +1734,6 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id)
/* For multiple opens of the same file, verify that the VFD SWMR setting is consistent */
if(shared->nrefs > 1) {
- if(NULL == (vfd_swmr_config_ptr = (H5F_vfd_swmr_config_t *)H5MM_calloc(sizeof(H5F_vfd_swmr_config_t))))
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't allocate memory for mdc log file name")
-
- if(H5P_get(a_plist, H5F_ACS_VFD_SWMR_CONFIG_NAME, vfd_swmr_config_ptr) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get VFD SWMR config info")
-
if(HDmemcmp(vfd_swmr_config_ptr, &shared->vfd_swmr_config, sizeof(H5F_vfd_swmr_config_t)))
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "inconsistent VFD SWMR config info")
}
diff --git a/test/vfd_swmr.c b/test/vfd_swmr.c
index c4085b3..6e5c82a 100644
--- a/test/vfd_swmr.c
+++ b/test/vfd_swmr.c
@@ -190,7 +190,10 @@ error:
* Purpose: A) Verify that page buffering and paged aggregation
* have to be enabled for a file to be configured
* with VFD SWMR.
- * B) Verify the VFD SWMR configuration set in fapl
+ * B) Verify that the "writer" setting in the fapl's VFD
+ * SWMR configuration should be consistent with the
+ * file access flags.
+ * C) Verify the VFD SWMR configuration set in fapl
* used to create/open the file is the same as the
* configuration retrieved from the file's fapl.
*
@@ -239,6 +242,32 @@ test_file_fapl(void)
if((fapl1 = H5Pcreate(H5P_FILE_ACCESS)) < 0)
TEST_ERROR;
+ /* Configured as VFD SWMR reader */
+ config1->version = H5F__CURR_VFD_SWMR_CONFIG_VERSION;
+ config1->tick_len = 4;
+ config1->max_lag = 6;
+ config1->writer = FALSE;
+ config1->md_pages_reserved = 2;
+ HDstrcpy(config1->md_file_path, MD_FILENAME);
+
+ /* Should succeed in setting the VFD SWMR configuration */
+ if(H5Pset_vfd_swmr_config(fapl1, config1) < 0)
+ TEST_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);
+ } H5E_END_TRY;
+ if(fid >= 0)
+ TEST_ERROR;
+
+ if(H5Pclose(fapl1) < 0)
+ FAIL_STACK_ERROR
+
+ /* Create a copy of the file access property list */
+ if((fapl1 = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ TEST_ERROR;
+
/* Configured as VFD SWMR writer */
config1->version = H5F__CURR_VFD_SWMR_CONFIG_VERSION;
config1->tick_len = 4;
@@ -258,6 +287,7 @@ test_file_fapl(void)
if(fid >= 0)
TEST_ERROR;
+
/* Create a copy of the file creation property list */
if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
FAIL_STACK_ERROR
@@ -299,8 +329,14 @@ test_file_fapl(void)
if(H5Pclose(file_fapl) < 0)
FAIL_STACK_ERROR;
+ /* Should fail to open: file access is reader but VFD SWMR config is writer */
+ H5E_BEGIN_TRY {
+ fid = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl1);
+ } H5E_END_TRY;
+ if(fid >= 0)
+ TEST_ERROR;
- /* Should succeed to open the file as VFD SWMR writer */
+ /* Should succeed to open: file access and VFD SWMR config are consistent */
if((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl1)) < 0)
TEST_ERROR;