]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
common/dmlogwrites: Extend _log_writes_init() to accept the specified length
authorXiao Yang <yangx.jy@fujitsu.com>
Mon, 14 Nov 2022 08:35:02 +0000 (08:35 +0000)
committerZorro Lang <zlang@kernel.org>
Wed, 23 Nov 2022 03:55:03 +0000 (11:55 +0800)
It is unnecssary to always create a dm-log-writes device
based on the entire size of the target/underlying device.

Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/dmlogwrites

index 9fa1c9775ba005264ad10e03131c81c0916aad88..c1c85de9dd43ac68deb71360e89746ac109af39d 100644 (file)
@@ -59,14 +59,28 @@ _require_log_writes_dax_mountopt()
        fi
 }
 
+# Set up a dm-log-writes device
+#
+# blkdev: the specified target device
+# length(optional): the mapped length in bytes
+# Note that the entire size of the target device will be used
+# if length is not specified.
 _log_writes_init()
 {
-       blkdev=$1
+       local blkdev=$1
+       local length=$2
+       local BLK_DEV_SIZE
 
        [ -z "$blkdev" ] && _fail \
        "block dev must be specified for _log_writes_init"
 
-       local BLK_DEV_SIZE=`blockdev --getsz $blkdev`
+       if [ -z "$length" ]; then
+               BLK_DEV_SIZE=`blockdev --getsz $blkdev`
+       else
+               local blksz=`blockdev --getss $blkdev`
+               BLK_DEV_SIZE=$((length / blksz))
+       fi
+
        LOGWRITES_NAME=logwrites-test
        LOGWRITES_DMDEV=/dev/mapper/$LOGWRITES_NAME
        LOGWRITES_TABLE="0 $BLK_DEV_SIZE log-writes $blkdev $LOGWRITES_DEV"