diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-05-23 19:31:37 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-07-11 19:28:35 -0400 |
commit | ecf4230e175eaa2c4ed4a71799fbe1d9ab58f9bf (patch) | |
tree | 6286c48da8c0e1c660e591310ebd4bec17c8ea2d | |
parent | cac4cc8009094608bbfc09966aa7ecfb220d91eb (diff) |
generic/{455,457,482}: make dmlogwrites tests work on bcachefs
bcachefs has log structured btree nodes, in addition to a regular
journal, which means that unless we replay to markers in the log in the
same order that they happened and are careful to avoid writing in
between replaying to different events - we need to wipe and start fresh
each time.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rwxr-xr-x | tests/generic/455 | 14 | ||||
-rwxr-xr-x | tests/generic/457 | 14 | ||||
-rwxr-xr-x | tests/generic/482 | 27 |
3 files changed, 48 insertions, 7 deletions
diff --git a/tests/generic/455 b/tests/generic/455 index da803de0..a9020c63 100755 --- a/tests/generic/455 +++ b/tests/generic/455 @@ -29,6 +29,17 @@ _require_no_logdev _require_log_writes _require_dm_target thin-pool +_reset_dmthin() +{ + # With bcachefs, we need to wipe and start fresh every time we replay to a + # different point in time - if we see metadata from a future point in time, + # or an unrelated mount, bcachefs will get confused: + if [ "$FSTYP" = "bcachefs" ]; then + _dmthin_cleanup + _dmthin_init $devsize $devsize $csize $lowspace + fi +} + check_files() { local name=$1 @@ -38,6 +49,7 @@ check_files() local filename=$(basename $i) local mark="${filename##*.}" echo "checking $filename" >> $seqres.full + _reset_dmthin _log_writes_replay_log $filename $DMTHIN_VOL_DEV _dmthin_mount local expected_md5=$(_md5_checksum $i) @@ -96,6 +108,7 @@ _dmthin_check_fs # check pre umount echo "checking pre umount" >> $seqres.full +_reset_dmthin _log_writes_replay_log last $DMTHIN_VOL_DEV _dmthin_mount _dmthin_check_fs @@ -106,6 +119,7 @@ done # Check the end echo "checking post umount" >> $seqres.full +_reset_dmthin _log_writes_replay_log end $DMTHIN_VOL_DEV _dmthin_mount for j in `seq 0 $((NUM_FILES-1))`; do diff --git a/tests/generic/457 b/tests/generic/457 index 03aeb814..03977eea 100755 --- a/tests/generic/457 +++ b/tests/generic/457 @@ -33,6 +33,17 @@ _require_dm_target thin-pool # $SCRATCH_DEV won't be directly created filesystem on, so fsck isn't required rm -f "${RESULT_DIR}/require_scratch" +_reset_dmthin() +{ + # With bcachefs, we need to wipe and start fresh every time we replay to a + # different point in time - if we see metadata from a future point in time, + # or an unrelated mount, bcachefs will get confused: + if [ "$FSTYP" = "bcachefs" ]; then + _dmthin_cleanup + _dmthin_init $devsize $devsize $csize $lowspace + fi +} + check_files() { local name=$1 @@ -42,6 +53,7 @@ check_files() local filename=$(basename $i) local mark="${filename##*.}" echo "checking $filename" >> $seqres.full + _reset_dmthin _log_writes_replay_log $filename $DMTHIN_VOL_DEV _dmthin_mount local expected_md5=$(_md5_checksum $i) @@ -102,6 +114,7 @@ _dmthin_check_fs # check pre umount echo "checking pre umount" >> $seqres.full +_reset_dmthin _log_writes_replay_log last $DMTHIN_VOL_DEV _dmthin_mount _dmthin_check_fs @@ -112,6 +125,7 @@ done # Check the end echo "checking post umount" >> $seqres.full +_reset_dmthin _log_writes_replay_log end $DMTHIN_VOL_DEV _dmthin_mount for j in `seq 0 $((NUM_FILES-1))`; do diff --git a/tests/generic/482 b/tests/generic/482 index c647d24c..21ea66ce 100755 --- a/tests/generic/482 +++ b/tests/generic/482 @@ -88,16 +88,29 @@ prev=$(_log_writes_mark_to_entry_number mkfs) cur=$(_log_writes_find_next_fua $prev) [ -z "$cur" ] && _fail "failed to locate next FUA write" +if [ "$FSTYP" = "bcachefs" ]; then + _dmthin_cleanup + _dmthin_init $devsize $devsize $csize $lowspace +fi + while [ ! -z "$cur" ]; do _log_writes_replay_log_range $cur $DMTHIN_VOL_DEV >> $seqres.full - # Here we need extra mount to replay the log, mainly for journal based - # fs, as their fsck will report dirty log as error. - # We don't care to preserve any data on the replay dev, as we can replay - # back to the point we need, and in fact sometimes creating/deleting - # snapshots repeatedly can be slower than replaying the log. - _dmthin_mount - _dmthin_check_fs + if [ "$FSTYP" = "bcachefs" ]; then + # bcachefs will get confused if fsck does writes to replay the log, + # but then we replay writes from an earlier point in time on the + # same fs - but fsck in -n mode won't do any writes: + _check_generic_filesystem -n $DMTHIN_VOL_DEV + else + # Here we need extra mount to replay the log, mainly for journal based + # fs, as their fsck will report dirty log as error. + # We don't care to preserve any data on the replay dev, as we can replay + # back to the point we need, and in fact sometimes creating/deleting + # snapshots repeatedly can be slower than replaying the log. + + _dmthin_mount + _dmthin_check_fs + fi prev=$cur cur=$(_log_writes_find_next_fua $(($cur + 1))) |