diff mbox series

[blktests,2/5] zbd/002: Check validity of zone capacity

Message ID 20200728101452.19309-3-shinichiro.kawasaki@wdc.com (mailing list archive)
State New, archived
Headers show
Series Support zone capacity | expand

Commit Message

Shinichiro Kawasaki July 28, 2020, 10:14 a.m. UTC
Linux kernel 5.9 zone descriptor interface added the new zone capacity
field defining the range of sectors usable within a zone. Add a check to
ensure that the zone capacity is smaller than or equal to the zone size.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
 tests/zbd/002 | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Johannes Thumshirn July 28, 2020, 10:45 a.m. UTC | #1
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Klaus Jensen July 28, 2020, 7:19 p.m. UTC | #2
On Jul 28 19:14, Shin'ichiro Kawasaki wrote:
> Linux kernel 5.9 zone descriptor interface added the new zone capacity
> field defining the range of sectors usable within a zone. Add a check to
> ensure that the zone capacity is smaller than or equal to the zone size.
> 
> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>

LGTM.

Reviewed-by: Klaus Jensen <k.jensen@samsung.com>
diff mbox series

Patch

diff --git a/tests/zbd/002 b/tests/zbd/002
index e197827..a134434 100755
--- a/tests/zbd/002
+++ b/tests/zbd/002
@@ -24,6 +24,7 @@  _check_blkzone_report() {
 	local -i cur_start=${ZONE_STARTS[0]}
 	local -i next_start=0
 	local -i len=0
+	local -i cap=0
 	local -i wptr=0
 	local -i cond=0
 	local -i zone_type=0
@@ -50,6 +51,7 @@  _check_blkzone_report() {
 
 		next_start=${ZONE_STARTS[$((idx+1))]}
 		len=${ZONE_LENGTHS[$idx]}
+		cap=${ZONE_CAPS[$idx]}
 		wptr=${ZONE_WPTRS[$idx]}
 		cond=${ZONE_CONDS[$idx]}
 		zone_type=${ZONE_TYPES[$idx]}
@@ -70,6 +72,13 @@  _check_blkzone_report() {
 			return 1
 		fi
 
+		# Check zone capacity
+		if [[ ${cap} -gt ${len} ]]; then
+			echo -n "Zone capacity is invalid at zone ${idx}. "
+			echo "capacity: ${cap}, size: ${len}"
+			return 1
+		fi
+
 		# Check write pointer
 		if [[ ${wptr} -lt 0 || ${wptr} -gt ${len} ]]; then
 			echo -n "Write pointer is invalid at zone ${idx}. "