From patchwork Mon Jan 28 13:14:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shin'ichiro Kawasaki X-Patchwork-Id: 10783689 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DFB811390 for ; Mon, 28 Jan 2019 13:15:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF4A42A82A for ; Mon, 28 Jan 2019 13:15:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C321F2AA57; Mon, 28 Jan 2019 13:15:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 601282A82A for ; Mon, 28 Jan 2019 13:15:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726803AbfA1NPf (ORCPT ); Mon, 28 Jan 2019 08:15:35 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:60364 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726784AbfA1NPf (ORCPT ); Mon, 28 Jan 2019 08:15:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1548681335; x=1580217335; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZuAoGLlnQKEbYDiO6jPdNjX8klQL9nBbv/TjzQXA7Ec=; b=ZlMxAwzguLwHPqhm0U/u/SKikh4vzAYYe8+TF+0oHxM+GBeFIM1R6JB/ 7wyYeLoqCKX/9WDPxNCcGGwXgmUZXYn+thLLlaK2LDM3uxRf4f0K50aSz e6EyDWYd3VS8hxOKhRyCyevRes0FQTrirLf9ZJyuxNQiaBvWV8NKLNtUf msm/XBLbwChpsRWwGeK0yagjFyXZppnDa7xibWaavD4BD8p7i3G61yx8U WbbJGuPDxAGj+02gPWlmrjx01A+0WHv6stP9UZg8KgrZv2G6zygaWUww0 FEcKXlUaBhZjTEpgS6R/80odwQAqAobFagiLcGfY86m597jLJOVpffdFr w==; X-IronPort-AV: E=Sophos;i="5.56,534,1539619200"; d="scan'208";a="204977751" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 28 Jan 2019 21:15:35 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 28 Jan 2019 04:56:36 -0800 Received: from shin_dev.dhcp.fujisawa.hgst.com (HELO shin_dev.fujisawa.hgst.com) ([10.149.52.166]) by uls-op-cesaip02.wdc.com with ESMTP; 28 Jan 2019 05:15:32 -0800 From: Shin'ichiro Kawasaki To: linux-block@vger.kernel.org, Omar Sandoval , Masato Suzuki , Shinichiro Kawasaki Cc: Omar Sandoval , Jens Axboe , Matias Bjorling , Hannes Reinecke , Mike Snitzer , "Martin K . Petersen" , Damien Le Moal , Chaitanya Kulkarni Subject: [PATCH blktests v4 08/12] zbd/001: sysfs and ioctl consistency test Date: Mon, 28 Jan 2019 22:14:51 +0900 Message-Id: <20190128131455.31997-9-shinichiro.kawasaki@wdc.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190128131455.31997-1-shinichiro.kawasaki@wdc.com> References: <20190128131455.31997-1-shinichiro.kawasaki@wdc.com> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Masato Suzuki Obtain a zoned block device attributes from sysfs and using ioctl calls and confirm the consistency of the values. Signed-off-by: Shin'ichiro Kawasaki Signed-off-by: Masato Suzuki --- tests/zbd/001 | 75 +++++++++++++++++++++++++++++++++++++++++++++++ tests/zbd/001.out | 2 ++ 2 files changed, 77 insertions(+) create mode 100755 tests/zbd/001 create mode 100644 tests/zbd/001.out diff --git a/tests/zbd/001 b/tests/zbd/001 new file mode 100755 index 0000000..ccb6e6c --- /dev/null +++ b/tests/zbd/001 @@ -0,0 +1,75 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2018 Western Digital Corporation or its affiliates. +# +# Check zoned block device sysfs and ioctl parameter availability and +# confirm consistency among them. + +. tests/zbd/rc + +DESCRIPTION="sysfs and ioctl" +QUICK=1 +CAN_BE_ZONED=1 + +requires() { + _have_src_program zbdioctl +} + +fallback_device() { + _fallback_null_blk_zoned +} + +cleanup_fallback_device() { + _exit_null_blk +} + +test_device() { + echo "Running ${TEST_NAME}" + + # Get and keep sysfs variables + _get_sysfs_variable "${TEST_DEV}" || return $? + local -i capacity=${SYSFS_VARS[$SV_CAPACITY]} + local -i chunk_sectors=${SYSFS_VARS[$SV_CHUNK_SECTORS]} + + # Calculate expected number of zones based on the total capacity and + # zone size, taking into account that the last zone can be smaller + # than other zones. + local -i nr_zones=$(( (capacity - 1) / chunk_sectors + 1 )) + + # Compare sysfs values and ioctl values + if [[ -e "${TEST_DEV_SYSFS}"/queue/nr_zones ]]; then + local -i sysfs_nr_zones=${SYSFS_VARS[$SV_NR_ZONES]} + local -i ioctl_nr_zones + local -i ioctl_zonesize + + ioctl_zonesize=$(src/zbdioctl -s "${TEST_DEV}") + if [[ ${chunk_sectors} -ne ${ioctl_zonesize} ]]; then + echo -n "ioctl zone size:${ioctl_zonesize} != " + echo "sysfs chunk_sectors:${chunk_sectors}" + return 1 + fi + + ioctl_nr_zones=$(src/zbdioctl -n "${TEST_DEV}") + if [[ ${nr_zones} -ne ${ioctl_nr_zones} ]]; then + echo -n "ioctl nr_zones:${ioctl_nr_zones} != " + echo "nr_zones:${nr_zones}" + return 1 + fi + + if [[ ${nr_zones} -ne ${sysfs_nr_zones} ]]; then + echo -n "sysfs nr_zones:${sysfs_nr_zones} != " + echo "nr_zones:${nr_zones}" + return 1 + fi + fi + + _put_sysfs_variable + { + echo "Capacity: ${capacity} sectors" + echo "Zone: ${chunk_sectors} sectors" + echo "Number of zones: ${nr_zones} zones" + } >> "$FULL" 2>&1 + + echo "Test complete" +} + diff --git a/tests/zbd/001.out b/tests/zbd/001.out new file mode 100644 index 0000000..7d72a8f --- /dev/null +++ b/tests/zbd/001.out @@ -0,0 +1,2 @@ +Running zbd/001 +Test complete