dm-log-writes: only replay log to marks that exist
authorRoss Zwisler <ross.zwisler@linux.intel.com>
Wed, 6 Dec 2017 00:37:43 +0000 (17:37 -0700)
committerEryu Guan <eguan@redhat.com>
Fri, 8 Dec 2017 04:25:53 +0000 (12:25 +0800)
The 'replay-log' executable will replay the dm-log-writes log until
the given mark, or until the end of the log if the mark isn't found.

This means that if the mark you're looking for was never inserted in
the log or if you give garbage to _log_writes_replay_log() the
entire log will be replayed.  This can cause unexpected test
results.

Fix this by making sure that the mark we're given actually exists in
the log before we allow the replay.

Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
common/dmlogwrites

index 247c744238c6fea88fc2f4faa2aef666bb4739d0..05829dbc0a03093e49b0a2eb7703ded63b2d1d17 100644 (file)
@@ -72,6 +72,10 @@ _log_writes_replay_log()
 {
        _mark=$1
 
+       $here/src/log-writes/replay-log --log $LOGWRITES_DEV --find \
+               --end-mark $_mark >> $seqres.full 2>&1
+       [ $? -ne 0 ] && _fail "mark '$_mark' does not exist"
+
        $here/src/log-writes/replay-log --log $LOGWRITES_DEV --replay $SCRATCH_DEV \
                --end-mark $_mark >> $seqres.full 2>&1
        [ $? -ne 0 ] && _fail "replay failed"