]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
common/dmlogwrites: genericize log writes target device
authorBrian Foster <bfoster@redhat.com>
Thu, 28 Feb 2019 14:41:27 +0000 (09:41 -0500)
committerEryu Guan <guaneryu@gmail.com>
Sat, 2 Mar 2019 11:39:00 +0000 (19:39 +0800)
The dm-log-writes infrastructure is currently implemented to use
SCRATCH_DEV as a hardcoded data device. In preparation to allow use
of specialized devices in certain circumstances, genericize the code
to allow an arbitrary data device. This requires passing the target
device as a parameter to several helper functions from various
tests. No functional changes.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
common/dmlogwrites
tests/generic/455
tests/generic/457
tests/generic/470
tests/generic/482

index b9cbae7a93de28e6c0d1572b0760680fe6bb61aa..ae2cbc6a34850d04dda2fc33876928ba4d8f4999 100644 (file)
@@ -32,7 +32,7 @@ _require_log_writes_dax()
        _require_test_program "log-writes/replay-log"
 
        local ret=0
-       _log_writes_init
+       _log_writes_init $SCRATCH_DEV
        _log_writes_mkfs > /dev/null 2>&1
        _log_writes_mount -o dax > /dev/null 2>&1
        # Check options to be sure. XFS ignores dax option
@@ -47,10 +47,15 @@ _require_log_writes_dax()
 
 _log_writes_init()
 {
-       local BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
+       blkdev=$1
+
+       [ -z "$blkdev" ] && _fail \
+       "block dev must be specified for _log_writes_init"
+
+       local BLK_DEV_SIZE=`blockdev --getsz $blkdev`
        LOGWRITES_NAME=logwrites-test
        LOGWRITES_DMDEV=/dev/mapper/$LOGWRITES_NAME
-       LOGWRITES_TABLE="0 $BLK_DEV_SIZE log-writes $SCRATCH_DEV $LOGWRITES_DEV"
+       LOGWRITES_TABLE="0 $BLK_DEV_SIZE log-writes $blkdev $LOGWRITES_DEV"
        _dmsetup_create $LOGWRITES_NAME --table "$LOGWRITES_TABLE" || \
                _fail "failed to create log-writes device"
 }
@@ -82,17 +87,21 @@ _log_writes_unmount()
 
 # _log_writes_replay_log <mark>
 #
-# This replays the log contained on $LOGWRITES_DEV onto $SCRATCH_DEV upto the
+# This replays the log contained on $LOGWRITES_DEV onto blkdev upto the
 # mark passed in.
 _log_writes_replay_log()
 {
        _mark=$1
+       _blkdev=$2
+
+       [ -z "$_blkdev" ] && _fail \
+       "block dev must be specified for _log_writes_replay_log"
 
        $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 \
+       $here/src/log-writes/replay-log --log $LOGWRITES_DEV --replay $_blkdev \
                --end-mark $_mark >> $seqres.full 2>&1
        [ $? -ne 0 ] && _fail "replay failed"
 }
@@ -150,16 +159,19 @@ _log_writes_find_next_fua()
 _log_writes_replay_log_range()
 {
        local end=$1
+       local blkdev=$2
 
        [ -z "$end" ] && _fail \
        "end entry must be specified for _log_writes_replay_log_range"
+       [ -z "$blkdev" ] && _fail \
+       "block dev must be specified for _log_writes_replay_log_range"
 
        # To ensure we replay the last entry,
        # we need to manually increase the end entry number to ensure
        # it's played
        echo "=== replay to $end ===" >> $seqres.full
        $here/src/log-writes/replay-log --log $LOGWRITES_DEV \
-               --replay $SCRATCH_DEV --limit $(($end + 1)) \
+               --replay $blkdev --limit $(($end + 1)) \
                >> $seqres.full 2>&1
        [ $? -ne 0 ] && _fail "replay failed"
 }
index 6a87b99b944b373dbdf932c9738c296f8117fbac..05621220edff89cb446c11c3042283086458a9e8 100755 (executable)
@@ -42,7 +42,7 @@ check_files()
                local filename=$(basename $i)
                local mark="${filename##*.}"
                echo "checking $filename" >> $seqres.full
-               _log_writes_replay_log $filename
+               _log_writes_replay_log $filename $SCRATCH_DEV
                _scratch_mount
                local expected_md5=$(_md5_checksum $i)
                local md5=$(_md5_checksum $SCRATCH_MNT/$name)
@@ -57,7 +57,7 @@ rm -rf $SANITY_DIR
 mkdir $SANITY_DIR
 
 # Create the log
-_log_writes_init
+_log_writes_init $SCRATCH_DEV
 
 _log_writes_mkfs >> $seqres.full 2>&1
 
@@ -92,7 +92,7 @@ _check_scratch_fs
 
 # check pre umount
 echo "checking pre umount" >> $seqres.full
-_log_writes_replay_log last
+_log_writes_replay_log last $SCRATCH_DEV
 _scratch_mount
 _scratch_unmount
 _check_scratch_fs
@@ -103,7 +103,7 @@ done
 
 # Check the end
 echo "checking post umount" >> $seqres.full
-_log_writes_replay_log end
+_log_writes_replay_log end $SCRATCH_DEV
 _scratch_mount
 for j in `seq 0 $((NUM_FILES-1))`; do
        md5=$(_md5_checksum $SCRATCH_MNT/testfile$j)
index c4c0ca45f6619f0feb390e6ab98a27da024d8c0d..823673046f51d4d6ab9858822ec4704ba6bc5467 100755 (executable)
@@ -44,7 +44,7 @@ check_files()
                local filename=$(basename $i)
                local mark="${filename##*.}"
                echo "checking $filename" >> $seqres.full
-               _log_writes_replay_log $filename
+               _log_writes_replay_log $filename $SCRATCH_DEV
                _scratch_mount
                local expected_md5=$(_md5_checksum $i)
                local md5=$(_md5_checksum $SCRATCH_MNT/$name)
@@ -59,7 +59,7 @@ rm -rf $SANITY_DIR
 mkdir $SANITY_DIR
 
 # Create the log
-_log_writes_init
+_log_writes_init $SCRATCH_DEV
 
 _log_writes_mkfs >> $seqres.full 2>&1
 
@@ -96,7 +96,7 @@ _check_scratch_fs
 
 # check pre umount
 echo "checking pre umount" >> $seqres.full
-_log_writes_replay_log last
+_log_writes_replay_log last $SCRATCH_DEV
 _scratch_mount
 _scratch_unmount
 _check_scratch_fs
@@ -107,7 +107,7 @@ done
 
 # Check the end
 echo "checking post umount" >> $seqres.full
-_log_writes_replay_log end
+_log_writes_replay_log end $SCRATCH_DEV
 _scratch_mount
 for j in `seq 0 $((NUM_FILES-1))`; do
        md5=$(_md5_checksum $SCRATCH_MNT/testfile$j)
index a970aa80290868b12925e2291fdd27f6bf50a5be..93691f4ac6643ed07d4d9557735e55e3b059f542 100755 (executable)
@@ -39,7 +39,7 @@ _require_log_writes_dax
 _require_xfs_io_command "mmap" "-S"
 _require_xfs_io_command "log_writes"
 
-_log_writes_init
+_log_writes_init $SCRATCH_DEV
 _log_writes_mkfs >> $seqres.full 2>&1
 _log_writes_mount -o dax
 
@@ -58,7 +58,7 @@ _check_scratch_fs
 _scratch_mkfs >> $seqres.full 2>&1
 
 # check pre-unmap state
-_log_writes_replay_log preunmap
+_log_writes_replay_log preunmap $SCRATCH_DEV
 _scratch_mount
 
 # We should see $SCRATCH_MNT/test as having 1 MiB in block allocations
index 7595aa5950cb4a6b3e55557d588e63d14da6cc64..3c2199d7ecaee10bc42c37e022bd7c49476794a5 100755 (executable)
@@ -55,7 +55,7 @@ fsstress_args=$(_scale_fsstress_args -w -d $SCRATCH_MNT -n 512 -p $nr_cpus \
                $FSSTRESS_AVOID)
 
 _test_unmount
-_log_writes_init
+_log_writes_init $SCRATCH_DEV
 _log_writes_mkfs >> $seqres.full 2>&1
 _log_writes_mark mkfs
 
@@ -70,7 +70,7 @@ cur=$(_log_writes_find_next_fua $prev)
 [ -z "$cur" ] && _fail "failed to locate next FUA write"
 
 while [ ! -z "$cur" ]; do
-       _log_writes_replay_log_range $cur >> $seqres.full
+       _log_writes_replay_log_range $cur $SCRATCH_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.