From: Dmitry Monakhov <dmonakhov@openvz.org>
To: fstests@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org,
Dmitry Monakhov <dmonakhov@openvz.org>
Subject: [PATCH 1/6] add lio-target helpers
Date: Thu, 6 Apr 2017 17:19:05 +0400 [thread overview]
Message-ID: <1491484750-9164-2-git-send-email-dmonakhov@openvz.org> (raw)
In-Reply-To: <1491484750-9164-1-git-send-email-dmonakhov@openvz.org>
Linux-IO Target is very good framework for testing block backend.
It is more flexible than scsi_debug.
http://linux-iscsi.org/wiki/LIO
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
common/config | 2 +
common/liotarget | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 113 insertions(+)
create mode 100644 common/liotarget
diff --git a/common/config b/common/config
index 59041a3..cfe7913 100644
--- a/common/config
+++ b/common/config
@@ -212,6 +212,8 @@ export XZ_PROG="`set_prog_path xz`"
export FLOCK_PROG="`set_prog_path flock`"
export LDD_PROG="`set_prog_path ldd`"
export TIMEOUT_PROG="`set_prog_path timeout`"
+export TARGETCLI_PROG="`set_prog_path targetcli`"
+export TARGETCTL_PROG="`set_prog_path targetctl`"
# use 'udevadm settle' or 'udevsettle' to wait for lv to be settled.
# newer systems have udevadm command but older systems like RHEL5 don't.
diff --git a/common/liotarget b/common/liotarget
new file mode 100644
index 0000000..f821692
--- /dev/null
+++ b/common/liotarget
@@ -0,0 +1,111 @@
+#!/bin/bash
+#
+# Copyright (c) 2017 Virtuozzo Inc
+# All Rights Reserved.
+#
+# Written by Dmitry Monakhov <dmonakhov@openvz.org>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+#
+# Functions for Linux-IO Target manipulation
+#
+
+_require_liotarget()
+{
+ which $TARGETCLI_PROG >>$seqres.full 2>&1 || \
+ _notrun "this test requires 'targetcli' tool"
+ which $TARGETCLI_PROG >>$seqres.full 2>&1 || \
+ _notrun "this test requires 'targetcli' tool"
+
+ $TARGETCLI_PROG ls /backstores/ramdisk >>$seqres.full 2>&1 ||\
+ _notrun "kernel compiled w/o CONFIG_TARGET_CORE"
+ $TARGETCLI_PROG ls /backstores/fileio >>$seqres.full 2>&1 ||\
+ _notrun "kernel compiled w/o CONFIG_TCM_FILEIO"
+ $TARGETCLI_PROG ls /loopback >>$seqres.full 2>&1 ||\
+ _notrun "kernel compiled w/o CONFIG_LOOPBACK_TARGET"
+}
+
+_liotgt_create_fileio()
+{
+ local name=$1
+ local img=$2
+ local sz=$3
+
+ $TARGETCLI_PROG /backstores/fileio create \
+ name=$name file_or_dev=$img size=$sz >>$seqres.full ||\
+ _fail "Can not create /backstores/fileio/$name"
+
+ local cfg_path=`ls -d /sys/kernel/config/target/core/fileio_*/$name`
+ [ -d "$cfg_path" ] || _fail "Bad config path"
+ echo $cfg_path
+}
+
+_liotgt_set_attribute()
+{
+ local path=$1
+ local attr_name=$2
+ local attr_val=$3
+
+ [ -f $path/attrib/$attr_name ] || _fail "Bad attribute $attr_name"
+ echo "echo $attr_val > $path/attrib/$attr_name " >>$seqres.full
+ echo $attr_val > $path/attrib/$attr_name
+}
+
+_liotgt_create_loopback()
+{
+ local out=`$TARGETCLI_PROG /loopback/ create 2>&1`
+ [ $? -eq 0 ] || _fail "Can not create loopback target"
+ echo $out >>$seqres.full
+
+ local naa=`echo $out | gawk '{ print $3 }'`
+ echo ${naa:0:20} >>$seqres.full
+
+ echo ${naa:0:20}
+}
+
+_liotgt_find_dev()
+{
+ local found=""
+ local name=$1
+ local drives=`find /sys/devices -type f -name model`
+ for d in $drives;do
+ local dir=`dirname $d`
+ local vendor=`cat $dir/vendor`
+ local model=`cat $dir/model`
+ if [ "${vendor//[[:space:]]/}" == "LIO-ORG" ] && \
+ [ "${model//[[:space:]]/}" == "$name" ]; then
+ found=/dev/$(ls $dir/block)
+ break
+ fi
+ done
+ [ -z "$found" ] && _fail "Can not find device with backend $name"
+ echo "$found"
+}
+
+_liotgt_attach_target()
+{
+ local path=$1
+ local name=`basename $path`
+ local naa=$(_liotgt_create_loopback)
+
+ $TARGETCLI_PROG /loopback/$naa/luns create $path >>$seqres.full 2>&1 ||\
+ _fail "Can not attach $path to tcm_loop"
+ _liotgt_find_dev $name
+}
+
+_liotgt_cleanup()
+{
+ $TARGETCTL_PROG clear
+}
--
2.9.3
next prev parent reply other threads:[~2017-04-06 13:19 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-06 13:19 [PATCH 0/6] RFC add blkdev tests v2 Dmitry Monakhov
2017-04-06 13:19 ` Dmitry Monakhov [this message]
2017-04-06 13:19 ` [PATCH 2/6] add: blockdev/001 check page-cache coherency after BLKDISCARD Dmitry Monakhov
2017-04-06 13:19 ` [PATCH 3/6] new: blockdev/002 check information leak for lio-fileio Dmitry Monakhov
2017-04-06 13:19 ` [PATCH 4/6] new: blockdev/003 basic blockdev T10-DIF-TYPE1 integrity checks Dmitry Monakhov
2017-04-06 13:19 ` [PATCH 5/6] new: blockdev/004 Check that live fs survives blkdev page truncation Dmitry Monakhov
2017-04-06 13:19 ` [PATCH 6/6] new: blockdev/005 Check that busy " Dmitry Monakhov
2017-04-06 13:55 ` [PATCH 0/6] RFC add blkdev tests v2 Christoph Hellwig
2017-04-06 14:33 ` Jens Axboe
2017-04-06 14:47 ` Christoph Hellwig
2017-04-06 14:51 ` Jens Axboe
2017-04-06 15:20 ` Johannes Thumshirn
2017-04-06 15:32 ` Eric Sandeen
2017-04-06 18:15 ` Johannes Thumshirn
2017-04-06 18:19 ` Jens Axboe
2017-04-06 18:22 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1491484750-9164-2-git-send-email-dmonakhov@openvz.org \
--to=dmonakhov@openvz.org \
--cc=fstests@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).