fstests.vger.kernel.org archive mirror
 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>,
	Johannes Thumshirn <johannes.thumshirn@wdc.com>
Subject: [PATCH 2/4] btrfs: require discard functionality from scratch device
Date: Fri, 23 Apr 2021 20:26:32 +0900	[thread overview]
Message-ID: <20210423112634.6067-3-johannes.thumshirn@wdc.com> (raw)
In-Reply-To: <20210423112634.6067-1-johannes.thumshirn@wdc.com>

Some test cases for btrfs require the scratch device to support discard.
Check if the scratch device does support discard before trying to execute
the test.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 common/rc       | 8 ++++++++
 tests/btrfs/116 | 1 +
 tests/btrfs/156 | 1 +
 3 files changed, 10 insertions(+)

diff --git a/common/rc b/common/rc
index 11ff7635700b..76a7265e23ba 100644
--- a/common/rc
+++ b/common/rc
@@ -3587,6 +3587,14 @@ _require_batched_discard()
 	$FSTRIM_PROG $1 > /dev/null 2>&1 || _notrun "FITRIM not supported on $1"
 }
 
+_require_scratch_discard()
+{
+	local sdev="$(_short_dev $SCRATCH_DEV)"
+	local discard=$(cat /sys/block/$sdev/queue/discard_granularity)
+
+	[ $discard -gt 0 ] || _notrun "discard not supported"
+}
+
 _require_dumpe2fs()
 {
 	if [ -z "$DUMPE2FS_PROG" ]; then
diff --git a/tests/btrfs/116 b/tests/btrfs/116
index 3ed097eccf03..f4db439caef8 100755
--- a/tests/btrfs/116
+++ b/tests/btrfs/116
@@ -29,6 +29,7 @@ _cleanup()
 # real QA test starts here
 _supported_fs btrfs
 _require_scratch
+_require_scratch_discard
 
 rm -f $seqres.full
 
diff --git a/tests/btrfs/156 b/tests/btrfs/156
index 89c80e7161e2..56206d99c801 100755
--- a/tests/btrfs/156
+++ b/tests/btrfs/156
@@ -42,6 +42,7 @@ rm -f $seqres.full
 _supported_fs btrfs
 _require_scratch
 _require_fstrim
+_require_scratch_discard
 
 # 1024fs size
 fs_size=$((1024 * 1024 * 1024))
-- 
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 ` Johannes Thumshirn [this message]
2021-04-25  8:26   ` [PATCH 2/4] btrfs: require discard functionality from scratch device Eryu Guan
2021-04-23 11:26 ` [PATCH 3/4] common/rc: introduce zone check commands Johannes Thumshirn
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-3-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 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).