From: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
To: linux-block@vger.kernel.org, Omar Sandoval <osandov@fb.com>,
Masato Suzuki <masato.suzuki@wdc.com>,
Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Cc: Omar Sandoval <osandov@osandov.com>, Jens Axboe <axboe@kernel.dk>,
Matias Bjorling <matias.bjorling@wdc.com>,
Hannes Reinecke <hare@suse.de>, Mike Snitzer <snitzer@redhat.com>,
"Martin K . Petersen" <martin.petersen@oracle.com>,
Chaitanya Kulkarni <Chaitanya.Kulkarni@wdc.com>
Subject: [PATCH blktests v3 10/13] zbd/002: report zone test
Date: Fri, 18 Jan 2019 18:44:50 +0900 [thread overview]
Message-ID: <20190118094453.13773-11-shinichiro.kawasaki@wdc.com> (raw)
In-Reply-To: <20190118094453.13773-1-shinichiro.kawasaki@wdc.com>
From: Masato Suzuki <masato.suzuki@wdc.com>
Get a report for all zones and confirm that the reported values are
valid and consistent with regard to the device capacity and zone size.
Signed-off-by: Masato Suzuki <masato.suzuki@wdc.com>
---
tests/zbd/002 | 108 ++++++++++++++++++++++++++++++++++++++++++++++
tests/zbd/002.out | 2 +
2 files changed, 110 insertions(+)
create mode 100755 tests/zbd/002
create mode 100644 tests/zbd/002.out
diff --git a/tests/zbd/002 b/tests/zbd/002
new file mode 100755
index 0000000..e197827
--- /dev/null
+++ b/tests/zbd/002
@@ -0,0 +1,108 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2018 Western Digital Corporation or its affiliates.
+#
+# Issue report zone command and confirm consistency of reported values.
+
+. tests/zbd/rc
+
+DESCRIPTION="report zone"
+CAN_BE_ZONED=1
+
+fallback_device() {
+ _fallback_null_blk_zoned
+}
+
+cleanup_fallback_device() {
+ _exit_null_blk
+}
+
+_check_blkzone_report() {
+ # Utilize local variables as much as possible to speed up loop execution
+ local -i max_idx=$((REPORTED_COUNT - 1))
+ local -i chunk_sectors=${SYSFS_VARS[$SV_CHUNK_SECTORS]}
+ local -i cur_start=${ZONE_STARTS[0]}
+ local -i next_start=0
+ local -i len=0
+ local -i wptr=0
+ local -i cond=0
+ local -i zone_type=0
+
+ # Confirm number of reported zones
+ if [[ ${REPORTED_COUNT} -ne ${SYSFS_VARS[$SV_NR_ZONES]} ]]; then
+ echo "The number of zones reported differ from sysfs nr_zones"
+ echo -n "Reported zones count: ${REPORTED_COUNT} "
+ echo "sysfs nr_zones: ${SYSFS_VARS[$SV_NR_ZONES]}"
+ return 1
+ fi
+
+ # Check consistency between last zone size and capacity
+ local -i last_zone_end=$((ZONE_STARTS[max_idx] + ZONE_LENGTHS[max_idx]))
+ if [[ ${last_zone_end} -gt ${SYSFS_VARS[$SV_CAPACITY]} ]]; then
+ echo "Last zone start sector + length exceeds capacity"
+ echo -n "Capacity: ${SYSFS_VARS[$SV_CAPACITY]}, "
+ echo "last zone start sector + length: ${last_zone_end}"
+ return 1
+ fi
+
+ # Check each zone parameter validity and that all zones are contiguous
+ for ((idx = 0; idx <= max_idx; idx++)); do
+
+ next_start=${ZONE_STARTS[$((idx+1))]}
+ len=${ZONE_LENGTHS[$idx]}
+ wptr=${ZONE_WPTRS[$idx]}
+ cond=${ZONE_CONDS[$idx]}
+ zone_type=${ZONE_TYPES[$idx]}
+
+ # Check two zones are contiguous
+ if [[ $((cur_start+len)) -ne ${next_start} ]]; then
+ echo -n "Zones are not contiguous at zone ${idx}. "
+ echo "cur:${cur_start}+${len}, next:${next_start}"
+ return 1
+ fi
+
+ # Check zone size
+ if [[ ${len} -ne ${chunk_sectors} &&
+ ${idx} -ne ${max_idx} ]]; then
+ echo -n "Zone size is not same as chunk_sectors "
+ echo -n "at zone ${idx}. "
+ echo "size: ${len}, chunk_sectors: ${chunk_sectors}"
+ return 1
+ fi
+
+ # Check write pointer
+ if [[ ${wptr} -lt 0 || ${wptr} -gt ${len} ]]; then
+ echo -n "Write pointer is invalid at zone ${idx}. "
+ echo "wp:${wptr}"
+ return 1
+ fi
+
+ # Check zone condition
+ if [[ ! ${ZONE_COND_ARRAY[cond]} ]]; then
+ echo -n "Zone condition is incorrect at zone ${idx}. "
+ echo "condition: ${cond}"
+ return 1
+ fi
+
+ # Check zone type
+ if [[ ! ${ZONE_TYPE_ARRAY[zone_type]} ]]; then
+ echo -n "Zone type is incorrect at zone ${idx}. "
+ echo "type: ${zone_type}"
+ return 1
+ fi
+ cur_start=${next_start}
+ done
+ return 0
+}
+
+test_device() {
+ echo "Running ${TEST_NAME}"
+
+ _get_sysfs_variable "${TEST_DEV}" || return $?
+ _get_blkzone_report "${TEST_DEV}" || return $?
+ _check_blkzone_report || return $?
+ _put_blkzone_report
+ _put_sysfs_variable
+
+ echo "Test complete"
+}
diff --git a/tests/zbd/002.out b/tests/zbd/002.out
new file mode 100644
index 0000000..7317541
--- /dev/null
+++ b/tests/zbd/002.out
@@ -0,0 +1,2 @@
+Running zbd/002
+Test complete
--
2.20.1
next prev parent reply other threads:[~2019-01-18 9:45 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-18 9:44 [PATCH blktests v3 00/13] Implement zoned block device support Shin'ichiro Kawasaki
2019-01-18 9:44 ` [PATCH blktests v3 01/13] config: Introduce RUN_ZONED_TESTS variable and CAN_BE_ZONED flag Shin'ichiro Kawasaki
2019-01-25 20:59 ` Omar Sandoval
2019-01-28 10:07 ` Shinichiro Kawasaki
2019-01-18 9:44 ` [PATCH blktests v3 02/13] common: Introduce _have_fio_zbd_zonemode() helper function Shin'ichiro Kawasaki
2019-01-18 9:44 ` [PATCH blktests v3 03/13] block/004: Adjust fio conditions for zoned block devices Shin'ichiro Kawasaki
2019-01-25 21:09 ` Omar Sandoval
2019-01-28 10:13 ` Shinichiro Kawasaki
2019-01-18 9:44 ` [PATCH blktests v3 04/13] block: Whitelist tests supporting " Shin'ichiro Kawasaki
2019-01-25 21:11 ` Omar Sandoval
2019-01-28 10:37 ` Shinichiro Kawasaki
2019-01-18 9:44 ` [PATCH blktests v3 05/13] check: Introduce fallback_device() and cleanup_fallback_device() Shin'ichiro Kawasaki
2019-01-25 21:14 ` Omar Sandoval
2019-01-28 10:54 ` Shinichiro Kawasaki
2019-01-18 9:44 ` [PATCH blktests v3 06/13] common: Introduce _dd() helper function Shin'ichiro Kawasaki
2019-01-25 21:17 ` Omar Sandoval
2019-01-28 12:18 ` Shinichiro Kawasaki
2019-01-18 9:44 ` [PATCH blktests v3 07/13] src: Introduce zbdioctl program Shin'ichiro Kawasaki
2019-01-18 9:44 ` [PATCH blktests v3 08/13] tests: Introduce zbd test group Shin'ichiro Kawasaki
2019-01-18 9:44 ` [PATCH blktests v3 09/13] zbd/001: sysfs and ioctl consistency test Shin'ichiro Kawasaki
2019-01-18 9:44 ` Shin'ichiro Kawasaki [this message]
2019-01-18 9:44 ` [PATCH blktests v3 11/13] zbd/003: Test sequential zones reset Shin'ichiro Kawasaki
2019-01-18 9:44 ` [PATCH blktests v3 12/13] zbd/004: Check write split accross sequential zones Shin'ichiro Kawasaki
2019-01-18 9:44 ` [PATCH blktests v3 13/13] zbd/005: Test write ordering Shin'ichiro Kawasaki
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=20190118094453.13773-11-shinichiro.kawasaki@wdc.com \
--to=shinichiro.kawasaki@wdc.com \
--cc=Chaitanya.Kulkarni@wdc.com \
--cc=axboe@kernel.dk \
--cc=hare@suse.de \
--cc=linux-block@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=masato.suzuki@wdc.com \
--cc=matias.bjorling@wdc.com \
--cc=osandov@fb.com \
--cc=osandov@osandov.com \
--cc=snitzer@redhat.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).