All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
To: Eryu Guan <guan@eryu.me>
Cc: fstests@vger.kernel.org, linux-btrfs@vger.kernel.org,
	Naohiro Aota <naohiro.aota@wdc.com>
Subject: [PATCH 3/4] common/rc: introduce zone check commands
Date: Fri, 23 Apr 2021 20:26:33 +0900	[thread overview]
Message-ID: <20210423112634.6067-4-johannes.thumshirn@wdc.com> (raw)
In-Reply-To: <20210423112634.6067-1-johannes.thumshirn@wdc.com>

From: Naohiro Aota <naohiro.aota@wdc.com>

Introduce some zone related helper functions: _zone_type(),
_require_zoned_device(), and _require_non_zoned_device(). They all take a
device path as an argument.

_zone_type() return the zone type of the device according to the value
returned from "/sys/block/<disk>/queue/zoned". See
Documentation/ABI/testing/sysfs-block for a detail.

_require_zoned_device() checks if the device is zoned. If not, it skips the
current test. _require_non_zoned_device() does the opposite.

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
 common/rc | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/common/rc b/common/rc
index 76a7265e23ba..18436e33dcf3 100644
--- a/common/rc
+++ b/common/rc
@@ -1931,6 +1931,50 @@ _require_dm_target()
 	fi
 }
 
+_zone_type()
+{
+	local target=$1
+	if [ -z $target ]; then
+		echo "Usage: _zone_type <device>"
+		exit 1
+	fi
+	local sdev=`_short_dev $target`
+
+	if [ -e /sys/block/${sdev}/queue/zoned ]; then
+		cat /sys/block/${sdev}/queue/zoned
+	else
+		echo none
+	fi
+}
+
+_require_zoned_device()
+{
+	local target=$1
+	if [ -z $target ]; then
+		echo "Usage: _require_zoned_device <device>"
+		exit 1
+	fi
+
+	local type=`_zone_type ${target}`
+	if [ "${type}" = "none" ]; then
+		_notrun "this test require zoned block device"
+	fi
+}
+
+_require_non_zoned_device()
+{
+	local target=$1
+	if [ -z $target ]; then
+		echo "Usage: _require_non_zoned_device <device>"
+		exit 1
+	fi
+
+	local type=`_zone_type ${target}`
+	if [ "${type}" != "none" ]; then
+		_notrun "this test require non-zoned block device"
+	fi
+}
+
 # this test requires the ext4 kernel support crc feature on scratch device
 #
 _require_scratch_ext4_crc()
-- 
2.30.0


  parent reply	other threads:[~2021-04-23 11:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-23 11:26 [PATCH 0/4] fstests: first few support patches for zoned btrfs Johannes Thumshirn
2021-04-23 11:26 ` [PATCH 1/4] fstests: add missing checks of fallocate feature Johannes Thumshirn
2021-04-23 11:26 ` [PATCH 2/4] btrfs: require discard functionality from scratch device Johannes Thumshirn
2021-04-25  8:26   ` Eryu Guan
2021-04-23 11:26 ` Johannes Thumshirn [this message]
2021-04-23 11:26 ` [PATCH 4/4] btrfs: add test for zone auto reclaim Johannes Thumshirn
2021-04-25  8:33   ` Eryu Guan
2021-04-26  6:08     ` Johannes Thumshirn

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=20210423112634.6067-4-johannes.thumshirn@wdc.com \
    --to=johannes.thumshirn@wdc.com \
    --cc=fstests@vger.kernel.org \
    --cc=guan@eryu.me \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=naohiro.aota@wdc.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.