Skip to content

Commit

Permalink
Merge pull request #36 from HDFGroup/feature/vfd_swmr
Browse files Browse the repository at this point in the history
Feature/vfd swmr
  • Loading branch information
vchoi-hdfgroup authored Aug 12, 2021
2 parents 704dc8e + b5a5be4 commit 0a4ee89
Show file tree
Hide file tree
Showing 18 changed files with 1,124 additions and 711 deletions.
45 changes: 14 additions & 31 deletions src/H5Fvfd_swmr.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,26 +768,26 @@ H5F_vfd_swmr_writer_end_of_tick(H5F_t *f, hbool_t wait_for_reader)

/* 1) If requested, flush all raw data to the HDF5 file.
*
* (Not for first cut.)
*/
HDassert(!shared->vfd_swmr_config.flush_raw_data);

#if 1
/* Test to see if b-tree corruption seen in VFD SWMR tests
* is caused by client hiding data from the metadata cache. Do
* this by calling H5D_flush_all(), which flushes any cached
* dataset storage. Eventually, we will do this regardless
* when the above flush_raw_data flag is set.
*/
if (shared->vfd_swmr_config.flush_raw_data) {

/* Test to see if b-tree corruption seen in VFD SWMR tests
* is caused by client hiding data from the metadata cache. Do
* this by calling H5D_flush_all(), which flushes any cached
* dataset storage. Eventually, we will do this regardless
* when the above flush_raw_data flag is set.
*/

if (H5D_flush_all(f) < 0)
if (H5D_flush_all(f) < 0)

HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush dataset cache")
HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush dataset cache")

if (H5MF_free_aggrs(f) < 0)
if (H5MF_free_aggrs(f) < 0)

HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release file space")
HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release file space")
}

/* 2) If it exists, flush the metadata cache to the page buffer. */
if (shared->cache) {

if (H5AC_prep_for_file_flush(f) < 0)
Expand All @@ -806,23 +806,6 @@ H5F_vfd_swmr_writer_end_of_tick(H5F_t *f, hbool_t wait_for_reader)
if (H5FD_truncate(shared->lf, FALSE) < 0)

HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "low level truncate failed")
#endif

/* 2) If it exists, flush the metadata cache to the page buffer. */
if (shared->cache) {

if (H5AC_prep_for_file_flush(f) < 0)

HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "prep for MDC flush failed")

if (H5AC_flush(f) < 0)

HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush metadata cache to the page buffer")

if (H5AC_secure_from_file_flush(f) < 0)

HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "secure from MDC flush failed")
}

/* 3) If this is the first tick (i.e. tick == 1), create the
* in memory version of the metadata file index.
Expand Down
181 changes: 95 additions & 86 deletions test/testvfdswmr.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -1241,51 +1241,55 @@ done
###############################################################################
#
#
for options in "-p -e 20 -t -q" "-g -m 5 -n 2 -s 10 -w 7 -q" "-k -m 10 -n 5 -r 5 -l 10 -q"; do
#
#
if [ ${do_dsetops:-no} = no ]; then
continue
fi
# Clean up any existing fifo files from previous runs
if [ -e ./$DSETOPS_FIFO_WRITER_TO_READER ]; then # If writer fifo file is found
rm -f ./$DSETOPS_FIFO_WRITER_TO_READER
fi
if [ -e ./$DSETOPS_FIFO_READER_TO_WRITER ]; then # If reader fifo file is found
rm -f ./$DSETOPS_FIFO_READER_TO_WRITER
fi
#
echo launch vfd_swmr_dsetops_writer dsetops, options $options ......may take some time......
catch_out_err_and_rc vfd_swmr_dsetops_writer \
../vfd_swmr_dsetops_writer $options &
pid_writer=$!

catch_out_err_and_rc vfd_swmr_dsetops_reader \
../vfd_swmr_dsetops_reader $options &
pid_reader=$!

# Wait for the reader to finish before signaling the
# writer to quit: the writer holds the file open so that the
# reader will find the shadow file when it opens
# the .h5 file.
wait $pid_reader
wait $pid_writer
# Loop with flushing of raw data and then without
for flush in "" "-U"; do
# Loop with different operations
for options in "-p -e 20 -t -q" "-g -m 5 -n 2 -s 10 -w 7 -q" "-k -m 10 -n 5 -r 5 -l 10 -q"; do
#
#
if [ ${do_dsetops:-no} = no ]; then
continue
fi
# Clean up any existing fifo files from previous runs
if [ -e ./$DSETOPS_FIFO_WRITER_TO_READER ]; then # If writer fifo file is found
rm -f ./$DSETOPS_FIFO_WRITER_TO_READER
fi
if [ -e ./$DSETOPS_FIFO_READER_TO_WRITER ]; then # If reader fifo file is found
rm -f ./$DSETOPS_FIFO_READER_TO_WRITER
fi
#
echo launch vfd_swmr_dsetops_writer dsetops, options $options $flush......may take some time......
catch_out_err_and_rc vfd_swmr_dsetops_writer \
../vfd_swmr_dsetops_writer $options $flush &
pid_writer=$!

catch_out_err_and_rc vfd_swmr_dsetops_reader \
../vfd_swmr_dsetops_reader $options $flush &
pid_reader=$!

# Wait for the reader to finish before signaling the
# writer to quit: the writer holds the file open so that the
# reader will find the shadow file when it opens
# the .h5 file.
wait $pid_reader
wait $pid_writer

# Collect exit code of the reader
if [ $(cat vfd_swmr_dsetops_reader.rc) -ne 0 ]; then
echo reader had error
nerrors=$((nerrors + 1))
fi

# Collect exit code of the reader
if [ $(cat vfd_swmr_dsetops_reader.rc) -ne 0 ]; then
echo reader had error
nerrors=$((nerrors + 1))
fi
# Collect exit code of the writer
if [ $(cat vfd_swmr_dsetops_writer.rc) -ne 0 ]; then
echo writer had error
nerrors=$((nerrors + 1))
fi

# Collect exit code of the writer
if [ $(cat vfd_swmr_dsetops_writer.rc) -ne 0 ]; then
echo writer had error
nerrors=$((nerrors + 1))
fi

# Clean up output files
rm -f vfd_swmr_dsetops_writer.{out,rc}
rm -f vfd_swmr_dsetops_reader.*.{out,rc}
# Clean up output files
rm -f vfd_swmr_dsetops_writer.{out,rc}
rm -f vfd_swmr_dsetops_reader.*.{out,rc}
done
done

###############################################################################
Expand All @@ -1305,51 +1309,56 @@ dsetchks_list=(
"-r -m 11 -n 5 -l 7 -q"
"-f -x 5 -y 2 -q"
)
for options in "${dsetchks_list[@]}"; do
#
#
if [ ${do_dsetchks:-no} = no ]; then
continue
fi
# Clean up any existing fifo files from previous runs
if [ -e ./$DSETCHKS_FIFO_WRITER_TO_READER ]; then # If writer fifo file is found
rm -f ./$DSETCHKS_FIFO_WRITER_TO_READER
fi
if [ -e ./$DSETCHKS_FIFO_READER_TO_WRITER ]; then # If reader fifo file is found
rm -f ./$DSETCHKS_FIFO_READER_TO_WRITER
fi
#
echo launch vfd_swmr_dsetchks_writer dsetchks, options $options ......may take some time......
catch_out_err_and_rc vfd_swmr_dsetchks_writer \
../vfd_swmr_dsetchks_writer $options &
pid_writer=$!

catch_out_err_and_rc vfd_swmr_dsetchks_reader \
../vfd_swmr_dsetchks_reader $options &
pid_reader=$!

# Wait for the reader to finish before signaling the
# writer to quit: the writer holds the file open so that the
# reader will find the shadow file when it opens
# the .h5 file.
wait $pid_reader
wait $pid_writer

# Collect exit code of the reader
if [ $(cat vfd_swmr_dsetchks_reader.rc) -ne 0 ]; then
echo reader had error
nerrors=$((nerrors + 1))
fi
#
#
# Loop with flushing of raw data and then without
for flush in "" "-U"; do
for options in "${dsetchks_list[@]}"; do
#
#
if [ ${do_dsetchks:-no} = no ]; then
continue
fi
# Clean up any existing fifo files from previous runs
if [ -e ./$DSETCHKS_FIFO_WRITER_TO_READER ]; then # If writer fifo file is found
rm -f ./$DSETCHKS_FIFO_WRITER_TO_READER
fi
if [ -e ./$DSETCHKS_FIFO_READER_TO_WRITER ]; then # If reader fifo file is found
rm -f ./$DSETCHKS_FIFO_READER_TO_WRITER
fi
#
echo launch vfd_swmr_dsetchks_writer dsetchks, options $options $flush ......may take some time......
catch_out_err_and_rc vfd_swmr_dsetchks_writer \
../vfd_swmr_dsetchks_writer $options $flush &
pid_writer=$!

catch_out_err_and_rc vfd_swmr_dsetchks_reader \
../vfd_swmr_dsetchks_reader $options $flush &
pid_reader=$!

# Wait for the reader to finish before signaling the
# writer to quit: the writer holds the file open so that the
# reader will find the shadow file when it opens
# the .h5 file.
wait $pid_reader
wait $pid_writer

# Collect exit code of the reader
if [ $(cat vfd_swmr_dsetchks_reader.rc) -ne 0 ]; then
echo reader had error
nerrors=$((nerrors + 1))
fi

# Collect exit code of the writer
if [ $(cat vfd_swmr_dsetchks_writer.rc) -ne 0 ]; then
echo writer had error
nerrors=$((nerrors + 1))
fi
# Collect exit code of the writer
if [ $(cat vfd_swmr_dsetchks_writer.rc) -ne 0 ]; then
echo writer had error
nerrors=$((nerrors + 1))
fi

# Clean up output files
rm -f vfd_swmr_dsetchks_writer.{out,rc}
rm -f vfd_swmr_dsetchks_reader.*.{out,rc}
# Clean up output files
rm -f vfd_swmr_dsetchks_writer.{out,rc}
rm -f vfd_swmr_dsetchks_reader.*.{out,rc}
done
done

###############################################################################
Expand Down
2 changes: 1 addition & 1 deletion test/vfd_swmr_addrem_writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ open_skeleton(const char *filename, unsigned verbose)
goto error;

/* config, tick_len, max_lag, writer, flush_raw_data, md_pages_reserved, md_file_path */
init_vfd_swmr_config(config, 4, 5, TRUE, FALSE, 128, "./rw-shadow");
init_vfd_swmr_config(config, 4, 5, TRUE, TRUE, 128, "./rw-shadow");

/* 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)
Expand Down
Loading

0 comments on commit 0a4ee89

Please sign in to comment.