]> www.infradead.org Git - users/hch/blktests.git/commitdiff
common/xfs: Create common helper to verify block device with xfs
authorLogan Gunthorpe <logang@deltatee.com>
Thu, 8 Oct 2020 16:40:16 +0000 (10:40 -0600)
committerOmar Sandoval <osandov@fb.com>
Thu, 22 Oct 2020 21:44:12 +0000 (14:44 -0700)
Make a common helper from the code in tests nvme/012 and nvme/013
to run an fio verify on a XFS file system backed by the
specified block device.

While we are at it, all the output is redirected to $FULL instead of
/dev/null.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
common/xfs
tests/nvme/012
tests/nvme/013

index d1a603b8c7b5dbccb6fe3a7a125b0a60257d91a1..210c924cdd410d6e6d84439ec43889f8a97e1ce9 100644 (file)
@@ -9,3 +9,25 @@
 _have_xfs() {
        _have_fs xfs && _have_program mkfs.xfs
 }
+
+_xfs_mkfs_and_mount() {
+       local bdev=$1
+       local mount_dir=$2
+
+       mkdir -p "${mount_dir}"
+       umount "${mount_dir}"
+       mkfs.xfs -l size=32m -f "${bdev}"
+       mount "${bdev}" "${mount_dir}"
+}
+
+_xfs_run_fio_verify_io() {
+       local mount_dir="/mnt/blktests"
+       local bdev=$1
+
+       _xfs_mkfs_and_mount "${bdev}" "${mount_dir}" >> "${FULL}" 2>&1
+
+       _run_fio_verify_io --size=950m --directory="${mount_dir}/"
+
+       umount "${mount_dir}" >> "${FULL}" 2>&1
+       rm -fr "${mount_dir}"
+}
index 1d8d8e3cc271e3ea21de76951e4e668b647a20f7..a13cd08ce6bf33c70b51f843d79680c5b3886e0e 100755 (executable)
@@ -26,12 +26,9 @@ test() {
        local port
        local nvmedev
        local loop_dev
-       local mount_dir="/mnt/blktests"
        local file_path="${TMPDIR}/img"
        local subsys_name="blktests-subsystem-1"
 
-       mkdir -p "${mount_dir}" > /dev/null 2>&1
-
        truncate -s 1G "${file_path}"
 
        loop_dev="$(losetup -f --show "${file_path}")"
@@ -47,15 +44,7 @@ test() {
        cat "/sys/block/${nvmedev}n1/uuid"
        cat "/sys/block/${nvmedev}n1/wwid"
 
-       umount ${mount_dir} > /dev/null 2>&1
-
-       mkfs.xfs -l size=32m -f /dev/"${nvmedev}n1" > /dev/null 2>&1
-
-       mount /dev/"${nvmedev}n1" "${mount_dir}"
-
-       _run_fio_verify_io --size=950m --directory="${mount_dir}/"
-
-       umount "${mount_dir}" > /dev/null 2>&1
+       _xfs_run_fio_verify_io "/dev/${nvmedev}n1"
 
        _nvme_disconnect_subsys "${subsys_name}"
 
@@ -66,7 +55,6 @@ test() {
        losetup -d "${loop_dev}"
 
        rm "${file_path}"
-       rm -fr "${mount_dir}"
 
        echo "Test complete"
 }
index 3819a2730d9b885a9c401a00a7ba3110bd0f3b93..1ac725ea83f28ff3899772c7707f10da3c42cbee 100755 (executable)
@@ -24,13 +24,10 @@ test() {
 
        local port
        local nvmedev
-       local mount_dir="/mnt/blktests/"
        local file_path="${TMPDIR}/img"
 
        local subsys_name="blktests-subsystem-1"
 
-       mkdir -p "${mount_dir}" > /dev/null 2>&1
-
        truncate -s 1G "${file_path}"
 
        _create_nvmet_subsystem "${subsys_name}" "${file_path}" \
@@ -44,15 +41,7 @@ test() {
        cat "/sys/block/${nvmedev}n1/uuid"
        cat "/sys/block/${nvmedev}n1/wwid"
 
-       umount ${mount_dir} > /dev/null 2>&1
-
-       mkfs.xfs -l size=32m -f /dev/"${nvmedev}n1" > /dev/null 2>&1
-
-       mount /dev/"${nvmedev}n1" "${mount_dir}"
-
-       _run_fio_verify_io --size=800m --directory="${mount_dir}/"
-
-       umount "${mount_dir}" > /dev/null 2>&1
+       _xfs_run_fio_verify_io "/dev/${nvmedev}n1"
 
        _nvme_disconnect_subsys "${subsys_name}"
 
@@ -61,7 +50,6 @@ test() {
        _remove_nvmet_port "${port}"
 
        rm "${file_path}"
-       rm -fr "${mount_dir}"
 
        echo "Test complete"
 }