summaryrefslogtreecommitdiffstats
path: root/src/H5FDvfd_swmr.c
diff options
context:
space:
mode:
authorDavid Young <dyoung@hdfgroup.org>2020-01-10 17:50:35 (GMT)
committerDavid Young <dyoung@hdfgroup.org>2020-01-10 18:00:22 (GMT)
commitf19b6c4d485bd34cba2c5825718c4330664ad54f (patch)
tree4b52e48d94437112acdfbf1bd129aec498fff517 /src/H5FDvfd_swmr.c
parentc4e19fa84bf3d9f0e621923b2b1fbf512c85b0b3 (diff)
downloadhdf5-f19b6c4d485bd34cba2c5825718c4330664ad54f.zip
hdf5-f19b6c4d485bd34cba2c5825718c4330664ad54f.tar.gz
hdf5-f19b6c4d485bd34cba2c5825718c4330664ad54f.tar.bz2
Make H5FD__vfd_swmr_load_hdr_and_idx() simpler and faster: copy a
pointer to the metadata index instead of copying the index itself. Use struct assignment instead of copying individual struct members. Lower a staircase.
Diffstat (limited to 'src/H5FDvfd_swmr.c')
-rw-r--r--src/H5FDvfd_swmr.c86
1 files changed, 30 insertions, 56 deletions
diff --git a/src/H5FDvfd_swmr.c b/src/H5FDvfd_swmr.c
index 3c01d68..ed7808c 100644
--- a/src/H5FDvfd_swmr.c
+++ b/src/H5FDvfd_swmr.c
@@ -1177,63 +1177,46 @@ H5FD__vfd_swmr_load_hdr_and_idx(H5FD_t *_file, hbool_t open)
HDassert(md_header.tick_num > file->md_header.tick_num || open);
/* Load and decode the index */
- if(H5FD__vfd_swmr_index_deserialize(_file, &md_index,
- &md_header) >= 0) {
-
- /* tick_num is the same in both header and index */
- if(md_header.tick_num == md_index.tick_num) {
-
- /* Copy header to VFD local copy */
- HDmemcpy(&file->md_header, &md_header,
- sizeof(H5FD_vfd_swmr_md_header));
-
- /* Free VFD local entries */
- if(file->md_index.entries) {
-
- HDassert(file->md_index.num_entries);
-
- file->md_index.entries = (H5FD_vfd_swmr_idx_entry_t *)
- H5FL_SEQ_FREE(H5FD_vfd_swmr_idx_entry_t,
- file->md_index.entries);
- }
+ if (H5FD__vfd_swmr_index_deserialize(_file, &md_index, &md_header) < 0)
+ continue;
- /* Copy index info to VFD local copy */
- file->md_index.tick_num = md_index.tick_num;
- file->md_index.num_entries = md_index.num_entries;
+ /* tick_num is the same in both header and index */
+ if(md_header.tick_num == md_index.tick_num) {
- /* Allocate and copy index entries */
- if(md_index.num_entries) {
+ /* Copy header to VFD local copy */
+ file->md_header = md_header;
- if(NULL == (file->md_index.entries =
- H5FL_SEQ_MALLOC(H5FD_vfd_swmr_idx_entry_t,
- md_index.num_entries)))
+ /* Free VFD local entries */
+ if (file->md_index.entries != NULL) {
- HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, \
- "memory allocation failed for index entries")
+ HDassert(file->md_index.num_entries);
- HDmemcpy(file->md_index.entries, md_index.entries,
- md_index.num_entries *
- sizeof(H5FD_vfd_swmr_idx_entry_t));
- }
- break;
+ file->md_index.entries = (H5FD_vfd_swmr_idx_entry_t *)
+ H5FL_SEQ_FREE(H5FD_vfd_swmr_idx_entry_t,
+ file->md_index.entries);
}
- /* Error when tick_num in header is more than one greater
- * that in the index
- */
- else if (md_header.tick_num > (md_index.tick_num + 1))
- HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, \
- "tick number mis-match in header and index")
+ /* Copy index info to VFD local copy */
+ file->md_index = md_index;
+ md_index.entries = NULL;
+ break;
+ }
- if(md_index.entries) {
+ if (md_index.entries != NULL) {
- HDassert(md_index.num_entries);
- md_index.entries = (H5FD_vfd_swmr_idx_entry_t *)
- H5FL_SEQ_FREE(H5FD_vfd_swmr_idx_entry_t,
- md_index.entries);
- }
+ HDassert(md_index.num_entries);
+ md_index.entries = (H5FD_vfd_swmr_idx_entry_t *)
+ H5FL_SEQ_FREE(H5FD_vfd_swmr_idx_entry_t,
+ md_index.entries);
+ }
- } /* end if index ok */
+ /* Error when tick_num in header is more than one greater
+ * than in the index
+ */
+ if (md_header.tick_num > (md_index.tick_num + 1)) {
+ HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL,
+ "tick number mis-match in header and index");
+ }
}
/* Exhaust all retries for loading and decoding the md file header
@@ -1246,15 +1229,6 @@ H5FD__vfd_swmr_load_hdr_and_idx(H5FD_t *_file, hbool_t open)
done:
- /* Free index entries obtained from H5FD__vfd_swmr_index_deserialize() */
- if(md_index.entries) {
-
- HDassert(md_index.num_entries);
- md_index.entries = (H5FD_vfd_swmr_idx_entry_t *)
- H5FL_SEQ_FREE(H5FD_vfd_swmr_idx_entry_t,
- md_index.entries);
- }
-
FUNC_LEAVE_NOAPI(ret_value)
} /* H5FD__vfd_swmr_load_hdr_and_idx() */