From patchwork Fri Jan 18 09:44:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinichiro Kawasaki X-Patchwork-Id: 10769615 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 B415214E5 for ; Fri, 18 Jan 2019 09:45:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A29482A2D0 for ; Fri, 18 Jan 2019 09:45:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 96C002A560; Fri, 18 Jan 2019 09:45:04 +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 EC05F2A2D0 for ; Fri, 18 Jan 2019 09:45:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725784AbfARJpC (ORCPT ); Fri, 18 Jan 2019 04:45:02 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:34681 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726288AbfARJpC (ORCPT ); Fri, 18 Jan 2019 04:45:02 -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=1547804703; x=1579340703; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rJtgDZkkRZf0LQYp77VMpsZko8wlDUStddWAOBwzLgI=; b=KYAVVqOWafX2acwbUa3gzXXhSKDmCKMrwHYC/+LrI5eTeifQfv2GPx2H DZWwV3X1JcquFFpvBPeWY5dvSRL8xwLdzXaMW1ZTwn6ztisyimer1nKUL OfenqwWpTpDAbfaHipDnxJZpZtUyHTcw03AaAud+hIRuB0rGFAJpby2O/ QCflwDVg4Ua1RZgzeqGYg+5f9BR9QCBsraRBBGgKybvjq9RdoSedHWBoQ Ioj0yb6zaLx+LCIwaVSb1LGo5wGKNOaeingPxWMa6jkDJQMuM4FvtQF64 ZKklgXza1aghfkaS+cIcSZc6dXoHg6Ar1pJAEKQS5OYuUZPmq8YdRZBMJ A==; X-IronPort-AV: E=Sophos;i="5.56,489,1539619200"; d="scan'208";a="100920228" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Jan 2019 17:45:03 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 18 Jan 2019 01:26:20 -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; 18 Jan 2019 01:44:58 -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" , Chaitanya Kulkarni Subject: [PATCH blktests v3 01/13] config: Introduce RUN_ZONED_TESTS variable and CAN_BE_ZONED flag Date: Fri, 18 Jan 2019 18:44:41 +0900 Message-Id: <20190118094453.13773-2-shinichiro.kawasaki@wdc.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190118094453.13773-1-shinichiro.kawasaki@wdc.com> References: <20190118094453.13773-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 To allow running tests using a null_blk device with the zoned mode disabled (current setup) as well as enabled, introduce the config the RUN_ZONED_TESTS config variable and the per-test flag CAN_BE_ZONED. RUN_ZONED_TESTS=1 indicates that tests run against null_blk will be executed twice, first with null_blk as a regular block device (RUN_FOR_ZONED=0) and a second time with null_blk set as a zoned block device (RUN_FOR_ZONED=1). This applies only to tests cases that have the variable CAN_BE_ZONED set to 1, indicating that the test case applies to zoned block devices. If CAN_BE_ZONED is not defined by a test case, the test is executed only with the regular null_blk device. _init_null_blk is modified to prepare null_blk as a zoned blocked device if RUN_FOR_ZONED is set and as a regular block device otherwise. To avoid "modprobe -r null_blk" failures, rmdir calls on all sysfs nullbX directories is added. When a zoned block device is specified in TEST_DEVS, failures of test cases that do not set CAN_BE_ZONED are avoided by automatically skipping the test. The new helper function _test_dev_is_zoned() is introduced to implement this. The use of the RUN_ZONED_TESTS variable requires that the kernel be compiled with CONFIG_BLK_DEV_ZONED enabled. Signed-off-by: Shin'ichiro Kawasaki --- Documentation/running-tests.md | 13 +++++++++++++ check | 29 ++++++++++++++++++++++++++--- common/null_blk | 23 ++++++++++++++++++++++- common/shellcheck | 2 +- new | 4 ++++ 5 files changed, 66 insertions(+), 5 deletions(-) diff --git a/Documentation/running-tests.md b/Documentation/running-tests.md index 8f32af3..459c96b 100644 --- a/Documentation/running-tests.md +++ b/Documentation/running-tests.md @@ -82,6 +82,19 @@ passing the `-d` command line option or setting the `DEVICE_ONLY` variable. DEVICE_ONLY=1 ``` +### Zoned Block Device + +To run test cases for zoned block devices, set `RUN_ZONED_TESTS` variable. +When this variable is set and a test case can prepare a virtual devices such +as null_blk with zoned mode, the test case is executed twice: first with +non-zoned mode and second with zoned mode. The use of the RUN_ZONED_TESTS +variable requires that the kernel be compiled with CONFIG_BLK_DEV_ZONED +enabled. + +```sh +RUN_ZONED_TESTS=1 +``` + ### Custom Setup The `config` file is really just a bash file that is sourced at the beginning diff --git a/check b/check index 6c6d9f5..4563d62 100755 --- a/check +++ b/check @@ -17,7 +17,7 @@ _found_test() { local test_name="$1" local explicit="$2" - unset DESCRIPTION QUICK TIMED requires device_requires test test_device + unset DESCRIPTION QUICK TIMED CAN_BE_ZONED requires device_requires test test_device # shellcheck disable=SC1090 if ! . "tests/${test_name}"; then @@ -182,11 +182,14 @@ _write_test_run() { _output_status() { local test="$1" local status="$2" + local zoned=" " + + if (( RUN_FOR_ZONED )); then zoned=" (zoned) "; fi if [[ -v DESCRIPTION ]]; then - printf '%-60s' "$test ($DESCRIPTION)" + printf '%-60s' "${test}${zoned}($DESCRIPTION)" else - printf '%-60s' "$test" + printf '%-60s' "${test}${zoned}" fi if [[ -z $status ]]; then echo @@ -391,10 +394,19 @@ _call_test() { fi } +_test_dev_is_zoned() { + if grep -qe "none" "${TEST_DEV_SYSFS}/queue/zoned" ; then + SKIP_REASON="${TEST_DEV} is not a zoned block device" + return 1 + fi + return 0 +} + _run_test() { TEST_NAME="$1" CHECK_DMESG=1 DMESG_FILTER="cat" + RUN_FOR_ZONED=0 # shellcheck disable=SC1090 . "tests/${TEST_NAME}" @@ -407,6 +419,11 @@ _run_test() { RESULTS_DIR="$OUTPUT/nodev" _call_test test + if (( RUN_ZONED_TESTS && CAN_BE_ZONED )); then + RESULTS_DIR="$OUTPUT/nodev_zoned" + RUN_FOR_ZONED=1 + _call_test test + fi else if [[ ${#TEST_DEVS[@]} -eq 0 ]]; then return 0 @@ -420,6 +437,11 @@ _run_test() { local ret=0 for TEST_DEV in "${TEST_DEVS[@]}"; do TEST_DEV_SYSFS="${TEST_DEV_SYSFS_DIRS["$TEST_DEV"]}" + if (( !CAN_BE_ZONED )) && _test_dev_is_zoned; then + SKIP_REASON="${TEST_DEV} is a zoned block device" + _output_notrun "$TEST_NAME => $(basename "$TEST_DEV")" + continue + fi if declare -fF device_requires >/dev/null && ! device_requires; then _output_notrun "$TEST_NAME => $(basename "$TEST_DEV")" continue @@ -591,6 +613,7 @@ fi # Default configuration. : "${DEVICE_ONLY:=0}" : "${QUICK_RUN:=0}" +: "${RUN_ZONED_TESTS:=0}" : "${OUTPUT:=results}" if [[ -v EXCLUDE ]] && ! declare -p EXCLUDE | grep -q '^declare -a'; then # If EXCLUDE was not defined as an array, convert it to one. diff --git a/common/null_blk b/common/null_blk index 937ece0..fd035b7 100644 --- a/common/null_blk +++ b/common/null_blk @@ -8,8 +8,29 @@ _have_null_blk() { _have_modules null_blk } +_null_blk_not_zoned() { + if [[ "${ZONED}" != "0" ]]; then + # shellcheck disable=SC2034 + SKIP_REASON="null_blk zoned mode not supported" + return 1 + fi + return 0 +} + _init_null_blk() { - if ! modprobe -r null_blk || ! modprobe null_blk "$@"; then + for d in /sys/kernel/config/nullb/*; + do [[ -d "$d" ]] && rmdir "$d"; done + + local _zoned="" + if [[ ${RUN_FOR_ZONED} -ne 0 ]] ; then + if ! _have_kernel_option BLK_DEV_ZONED ; then + echo -n "ZONED specified for kernel with " + echo "CONFIG_BLK_DEV_ZONED disabled" + return 1 + fi + _zoned="zoned=1" + fi + if ! modprobe -r null_blk || ! modprobe null_blk "$@" "${_zoned}" ; then return 1 fi diff --git a/common/shellcheck b/common/shellcheck index 5f46c00..b9be7d2 100644 --- a/common/shellcheck +++ b/common/shellcheck @@ -6,5 +6,5 @@ # Suppress unused global variable warnings. _silence_sc2034() { - echo "$CGROUP2_DIR $CHECK_DMESG $DESCRIPTION $DMESG_FILTER $FIO_PERF_FIELDS $FIO_PERF_PREFIX $QUICK $SKIP_REASON ${TEST_RUN[*]} $TIMED" > /dev/null + echo "$CGROUP2_DIR $CHECK_DMESG $DESCRIPTION $DMESG_FILTER $FIO_PERF_FIELDS $FIO_PERF_PREFIX $QUICK $SKIP_REASON ${TEST_RUN[*]} $TIMED $CAN_BE_ZONED" > /dev/null } diff --git a/new b/new index 63e36cd..d7d5f7c 100755 --- a/new +++ b/new @@ -145,6 +145,10 @@ DESCRIPTION="" # Alternatively, you can filter out any unimportant messages in dmesg like so: # DMESG_FILTER="grep -v sysfs" +# TODO: if this test can be run for both regular block devices and zoned block +# devices, uncomment the line below. +# CAN_BE_ZONED=1 + # TODO: if this test has any extra requirements, it should define a requires() # function. If the test can be run, requires() should return 0. Otherwise, it # should return non-zero and set the \$SKIP_REASON variable. Usually, From patchwork Fri Jan 18 09:44:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinichiro Kawasaki X-Patchwork-Id: 10769617 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 689C613BF for ; Fri, 18 Jan 2019 09:45:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57DEA2A1B1 for ; Fri, 18 Jan 2019 09:45:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 491992A4AB; Fri, 18 Jan 2019 09:45:09 +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 D9FFA2A1B1 for ; Fri, 18 Jan 2019 09:45:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726873AbfARJpI (ORCPT ); Fri, 18 Jan 2019 04:45:08 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:34681 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726288AbfARJpI (ORCPT ); Fri, 18 Jan 2019 04:45:08 -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=1547804709; x=1579340709; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xr1OyQaLlTmPYAsiFIzba9jjn+m6h3teH3K/mzCBlhc=; b=aiSmtoax9lxFeRFCNEZlOiQxQkY4RMLOhLweEhuujjBRjx16q8pvHnqc VtBI0iBSIyFqqBZoVO5oEZxQKEExaqacJe+HmjKn8G1VN47l0UmfqDH7Y rnXHsuT0g5/dAvbcTgzCEPvNxVzQYBOEeKdQ+by9pWgxr+4oT6VLTgHlO RJBS62mmW3UQdEI/t0Y9Z2jbHnR2pIzfYgIPhHip3KAmbatI4EpsXkZRT u/mW1co88uKn+lkz52XQo6eej8y6OA/ESchQjvaLAW2IC5idf9OWxPf8k mkY2XOxslgKfO0LF3C5rt+XIdQTzaYDbs8Gtf4nuOnQze3x8JzfwnAw1w g==; X-IronPort-AV: E=Sophos;i="5.56,489,1539619200"; d="scan'208";a="100920244" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Jan 2019 17:45:07 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 18 Jan 2019 01:26:24 -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; 18 Jan 2019 01:45:02 -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" , Chaitanya Kulkarni Subject: [PATCH blktests v3 02/13] common: Introduce _have_fio_zbd_zonemode() helper function Date: Fri, 18 Jan 2019 18:44:42 +0900 Message-Id: <20190118094453.13773-3-shinichiro.kawasaki@wdc.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190118094453.13773-1-shinichiro.kawasaki@wdc.com> References: <20190118094453.13773-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 Fio zbd zone mode is necessary for zoned block devices. Introduce the helper function _have_fio_zbd_zonemode() to check that the installed fio version supports the option --zonemode=zbd. Signed-off-by: Shin'ichiro Kawasaki --- common/fio | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/common/fio b/common/fio index e407088..4c771fc 100644 --- a/common/fio +++ b/common/fio @@ -17,6 +17,15 @@ _have_fio() { return 0 } +_have_fio_zbd_zonemode() { + _have_fio || return $? + if ! fio --cmdhelp=zonemode 2>&1 | grep -q zbd ; then + SKIP_REASON="Fio version too old (does not support --zonemode=zbd)" + return 1 + fi + return 0 +} + declare -A FIO_TERSE_FIELDS FIO_TERSE_FIELDS=( # Read status From patchwork Fri Jan 18 09:44:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinichiro Kawasaki X-Patchwork-Id: 10769619 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 25F426C2 for ; Fri, 18 Jan 2019 09:45:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 154442A1B1 for ; Fri, 18 Jan 2019 09:45:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 098D82A4AB; Fri, 18 Jan 2019 09:45:13 +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 ABDF92A1B1 for ; Fri, 18 Jan 2019 09:45:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726896AbfARJpM (ORCPT ); Fri, 18 Jan 2019 04:45:12 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:34681 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726818AbfARJpM (ORCPT ); Fri, 18 Jan 2019 04:45:12 -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=1547804713; x=1579340713; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6YTkS4nlP5Xyy3NO2sMAr7LrBiJv+t0RuuBnTmmOSPY=; b=Ake8uZMv3hbRfMfv4Nh9WlumNHt4HXKFy6hn1ZLnDVE37Cf9erlEYeCO PjxRKD3SALyzv6akKbU5+CTZwNTVacG3i+m7/ZEeSGxPWUYuwNiZlcqri cLGv5H5As/eO+itC56iZAf5j6y1W1FGYjytQSXtE1GFSb7rhkuizMyMLO EoQsbKysverMybT9x7BlDp0KhZRR2eafWtmwWzuugt626h57EdRFRGXul VptGSLCAD+QRZ3CokIZn1xUqWMTJhzFmKzE9g9S04rDsbyf+TP1hhzE1u ecSPd/OXAUudrV+8ojj6yYWeAdslV+CDUnB+bHS0WxrK+/iALjphzUmqp g==; X-IronPort-AV: E=Sophos;i="5.56,489,1539619200"; d="scan'208";a="100920267" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Jan 2019 17:45:11 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 18 Jan 2019 01:26:28 -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; 18 Jan 2019 01:45:06 -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" , Chaitanya Kulkarni Subject: [PATCH blktests v3 03/13] block/004: Adjust fio conditions for zoned block devices Date: Fri, 18 Jan 2019 18:44:43 +0900 Message-Id: <20190118094453.13773-4-shinichiro.kawasaki@wdc.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190118094453.13773-1-shinichiro.kawasaki@wdc.com> References: <20190118094453.13773-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 For a random write pattern to a zoned block device, fio requires --direct=1 and --zonemode=zbd options as well as deadline I/O scheduler to be specified. Specify these options and set the I/O scheduler if the target device is a zoned block device. Before doing that, also make sure that the deadline scheduler is available and that fio supports the zbd zone mode. Set CAN_BE_ZONED flag to run this test case for zoned block devices. Signed-off-by: Shin'ichiro Kawasaki --- tests/block/004 | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/block/004 b/tests/block/004 index 4c14c4b..7340d33 100755 --- a/tests/block/004 +++ b/tests/block/004 @@ -8,6 +8,7 @@ DESCRIPTION="run lots of flushes" TIMED=1 +CAN_BE_ZONED=1 requires() { _have_fio @@ -16,10 +17,25 @@ requires() { test_device() { echo "Running ${TEST_NAME}" + local directio="" + local zbdmode="" + + if _test_dev_is_zoned; then + if ! _have_fio_zbd_zonemode; then + echo "${SKIP_REASON}" + return 1 + fi + + _test_dev_queue_set scheduler deadline + + directio="--direct=1" + zbdmode="--zonemode=zbd" + fi + FIO_PERF_FIELDS=("write iops") _fio_perf --bs=4k --rw=randwrite --norandommap --fsync=1 \ --number_ios=256 --numjobs=64 --name=flushes \ - --filename="$TEST_DEV" + ${directio} ${zbdmode} --filename="$TEST_DEV" echo "Test complete" } From patchwork Fri Jan 18 09:44:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinichiro Kawasaki X-Patchwork-Id: 10769621 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 F28756C2 for ; Fri, 18 Jan 2019 09:45:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E11CC2A1B1 for ; Fri, 18 Jan 2019 09:45:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D569C2A4AB; Fri, 18 Jan 2019 09:45:15 +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 6CA552A1B1 for ; Fri, 18 Jan 2019 09:45:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726204AbfARJpP (ORCPT ); Fri, 18 Jan 2019 04:45:15 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:34681 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726818AbfARJpO (ORCPT ); Fri, 18 Jan 2019 04:45:14 -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=1547804715; x=1579340715; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IzZu3HYUWRKzTUWViQ/t9rs1bLmUlw8NNEuIXkqUbeM=; b=l83bDM7NVF/zLbe+4s8aL1wLGPsCUEoWO03NXgH2b96z2HUVLWzzGBsn zxsNWVO6I/MKbX4gzukBPbNvcHrYcewxmZJrIxm/VwfyKAZi/cFbtBStP X3Pa6Gph9oyMAHqqLinIGU9PWDDVOvIZx8sum+X5nIwgBBLSBdrCPzo6s s3wzIRwkZ+DYHFSmEFFGP4+NfMQSXPz0rcyK3KCx5mHK2SqohAXzjJFRy d+qxyXbbzKW/HlfTxsEg3bvyYr/IAZf35HBW4gz/z6lrUTR2jWcYHrFvV sAN0i9RbU1gbwiLZosqro3yyr+Md3YOyVkr6lOVnsmagkm37IoVq/DONw Q==; X-IronPort-AV: E=Sophos;i="5.56,489,1539619200"; d="scan'208";a="100920274" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Jan 2019 17:45:15 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 18 Jan 2019 01:26:32 -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; 18 Jan 2019 01:45:11 -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" , Chaitanya Kulkarni Subject: [PATCH blktests v3 04/13] block: Whitelist tests supporting zoned block devices Date: Fri, 18 Jan 2019 18:44:44 +0900 Message-Id: <20190118094453.13773-5-shinichiro.kawasaki@wdc.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190118094453.13773-1-shinichiro.kawasaki@wdc.com> References: <20190118094453.13773-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 Define CAN_BE_ZONED=1 in block/005, block/006, block/010, block/011, block/016, block/017, block/020, block/021 and block/023 as all these tests should execute without any problem against null_blk with zoned mode enabled or zoned block devices specified in TEST_DEVS. Signed-off-by: Shin'ichiro Kawasaki --- tests/block/005 | 1 + tests/block/006 | 1 + tests/block/010 | 1 + tests/block/011 | 1 + tests/block/016 | 1 + tests/block/017 | 1 + tests/block/020 | 1 + tests/block/021 | 1 + tests/block/023 | 1 + 9 files changed, 9 insertions(+) diff --git a/tests/block/005 b/tests/block/005 index 65eba22..8ab6791 100755 --- a/tests/block/005 +++ b/tests/block/005 @@ -8,6 +8,7 @@ DESCRIPTION="switch schedulers while doing IO" TIMED=1 +CAN_BE_ZONED=1 requires() { _have_fio diff --git a/tests/block/006 b/tests/block/006 index 630d478..0b8a3c0 100755 --- a/tests/block/006 +++ b/tests/block/006 @@ -12,6 +12,7 @@ DESCRIPTION="run null-blk in blocking mode" TIMED=1 +CAN_BE_ZONED=1 requires() { _have_null_blk && _have_module_param null_blk blocking && _have_fio diff --git a/tests/block/010 b/tests/block/010 index 76b301f..b81208e 100644 --- a/tests/block/010 +++ b/tests/block/010 @@ -12,6 +12,7 @@ DESCRIPTION="run I/O on null_blk with shared and non-shared tags" TIMED=1 +CAN_BE_ZONED=1 requires() { _have_null_blk && _have_module_param null_blk shared_tags && _have_fio diff --git a/tests/block/011 b/tests/block/011 index 8e10900..c3432a6 100755 --- a/tests/block/011 +++ b/tests/block/011 @@ -8,6 +8,7 @@ DESCRIPTION="disable PCI device while doing I/O" TIMED=1 +CAN_BE_ZONED=1 requires() { _have_fio && _have_program setpci diff --git a/tests/block/016 b/tests/block/016 index 10ec4ba..c70b7d0 100755 --- a/tests/block/016 +++ b/tests/block/016 @@ -11,6 +11,7 @@ DESCRIPTION="send a signal to a process waiting on a frozen queue" QUICK=1 +CAN_BE_ZONED=1 requires() { _have_null_blk diff --git a/tests/block/017 b/tests/block/017 index cea29be..e4a9259 100755 --- a/tests/block/017 +++ b/tests/block/017 @@ -11,6 +11,7 @@ DESCRIPTION="do I/O and check the inflight counter" QUICK=1 +CAN_BE_ZONED=1 requires() { _have_null_blk diff --git a/tests/block/020 b/tests/block/020 index a377ea2..39dde66 100755 --- a/tests/block/020 +++ b/tests/block/020 @@ -11,6 +11,7 @@ DESCRIPTION="run null-blk on different schedulers with only one hardware tag" QUICK=1 +CAN_BE_ZONED=1 requires() { _have_null_blk && _have_fio diff --git a/tests/block/021 b/tests/block/021 index 0ca5a17..a1bbf45 100755 --- a/tests/block/021 +++ b/tests/block/021 @@ -11,6 +11,7 @@ DESCRIPTION="read/write nr_requests on null-blk with different schedulers" QUICK=1 +CAN_BE_ZONED=1 requires() { _have_null_blk diff --git a/tests/block/023 b/tests/block/023 index b0739f7..0f20f4a 100755 --- a/tests/block/023 +++ b/tests/block/023 @@ -10,6 +10,7 @@ DESCRIPTION="do I/O on all null_blk queue modes" QUICK=1 +CAN_BE_ZONED=1 requires() { _have_null_blk From patchwork Fri Jan 18 09:44:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinichiro Kawasaki X-Patchwork-Id: 10769623 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 F0F026C2 for ; Fri, 18 Jan 2019 09:45:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFE772A2D0 for ; Fri, 18 Jan 2019 09:45:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D46672C209; Fri, 18 Jan 2019 09:45:20 +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 7EF412A2D0 for ; Fri, 18 Jan 2019 09:45:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726309AbfARJpT (ORCPT ); Fri, 18 Jan 2019 04:45:19 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:34681 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726288AbfARJpS (ORCPT ); Fri, 18 Jan 2019 04:45:18 -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=1547804719; x=1579340719; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=J5dITalF8Q+eHuhjO0iTOWrN0bjgfPaGbX8tVYk/w1k=; b=V+NgIUfW88Xfy/aYYOvbw3kqdh/EoMI6tD+vwxoyoM+QF1dWYsDBN7S9 Suamdzh95tlNABVmhgq419ZXmODz0YGnTPovO/XwOnq397tWJeitvbgKY F/xQlG0TOve7ow89L5pU1W5HRC0UQPGVz+7iXHX4OGHwdhELPPZ5/byss i21taIR9FGfZ1bxSqJf2TDoKhEsrn/8YcilaEEhxpqC8e2MljpCcgJLyx Pm3rbOQxpJzyaXFxMJuq2AWWM4Cn8EM401+vq1VI6aHfyZAXjjqnR31oh XtYxyzU7DuTFQhCJVHlDTZSacyNmKd5mPB8SehZKct7Qo1X0NLWoZEOkK Q==; X-IronPort-AV: E=Sophos;i="5.56,489,1539619200"; d="scan'208";a="100920279" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Jan 2019 17:45:19 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 18 Jan 2019 01:26: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; 18 Jan 2019 01:45:15 -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" , Chaitanya Kulkarni Subject: [PATCH blktests v3 05/13] check: Introduce fallback_device() and cleanup_fallback_device() Date: Fri, 18 Jan 2019 18:44:45 +0900 Message-Id: <20190118094453.13773-6-shinichiro.kawasaki@wdc.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190118094453.13773-1-shinichiro.kawasaki@wdc.com> References: <20190118094453.13773-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 These optional functions can be defined by a test case script. When defined and TEST_DEVS is empty, the fallback_device() is executed before runing the test case. The fallback_device() function intializes a virtual device to run the test case and return the device to be set in TEST_DEVS. After running the test case, cleanup_fallback_device() is executed to clean up the device. This feature allows to run test cases with test_device() function even if TEST_DEVS is not set in the config, using virtaul devices such as null_blk. Signed-off-by: Shin'ichiro Kawasaki --- check | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/check b/check index 4563d62..4b66995 100755 --- a/check +++ b/check @@ -407,6 +407,7 @@ _run_test() { CHECK_DMESG=1 DMESG_FILTER="cat" RUN_FOR_ZONED=0 + FALLBACK_DEVICE=0 # shellcheck disable=SC1090 . "tests/${TEST_NAME}" @@ -425,6 +426,23 @@ _run_test() { _call_test test fi else + if [[ ${#TEST_DEVS[@]} -eq 0 ]] && \ + declare -fF fallback_device >/dev/null && \ + declare -fF cleanup_fallback_device >/dev/null; then + if ! test_dev=$(fallback_device); then + _warning "$TEST_NAME: fallback_device call failure" + return 0 + fi + if ! sysfs_dir="$(_find_sysfs_dir "$test_dev")"; then + _warning "$TEST_NAME: could not find sysfs directory for ${test_dev}" + cleanup_fallback_device + return 0 + fi + TEST_DEVS=( "${test_dev}" ) + TEST_DEV_SYSFS_DIRS["$test_dev"]="$sysfs_dir" + FALLBACK_DEVICE=1 + fi + if [[ ${#TEST_DEVS[@]} -eq 0 ]]; then return 0 fi @@ -451,6 +469,13 @@ _run_test() { ret=1 fi done + + if (( FALLBACK_DEVICE )); then + cleanup_fallback_device + unset TEST_DEV_SYSFS_DIRS["${TEST_DEVS[0]}"] + TEST_DEVS=() + fi + return $ret fi } From patchwork Fri Jan 18 09:44:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinichiro Kawasaki X-Patchwork-Id: 10769625 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 DC78413BF for ; Fri, 18 Jan 2019 09:45:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7C2E2A1B1 for ; Fri, 18 Jan 2019 09:45:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B94002C209; Fri, 18 Jan 2019 09:45:44 +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 55CA82A1B1 for ; Fri, 18 Jan 2019 09:45:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726334AbfARJpn (ORCPT ); Fri, 18 Jan 2019 04:45:43 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:8856 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726288AbfARJpn (ORCPT ); Fri, 18 Jan 2019 04:45:43 -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=1547804744; x=1579340744; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wONpaa8KC9keYspWe5/MYQFaOwEXehto04D3/Q6+B3w=; b=GIRwV1YddwvkEDdz5Q9zUEfKuSDaCgraGWzhbg2CaxHE7MiZiAOKQZiD tC8AMRv9zWgnhU9blSVQXNFSs6r6M6IGLI7rjk1fkO07qezhW6liop4FQ fijzlaI5IadrNLA3sPLAwJEzTrpfc1bhfgcE7+D3SJ1OHVqmN0s1gKSWZ 8bZqrJfBFQD1GqcsD0V9Oet08DoripPtHS2ZpBI/Dm+67tfhejwD4uVJ+ 28zKN2ledMyTrJV4tSEhLZY0pHP/A253Dj9FsZgWYr0B06ErhzoFeQW1b MyYRd1GRAb8xnm6cHCNOKmqmhsOwK65mDI+7RMrNezvE3yUfUNDMwd/SV Q==; X-IronPort-AV: E=Sophos;i="5.56,489,1539619200"; d="scan'208";a="99182284" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Jan 2019 17:45:25 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 18 Jan 2019 01:26:43 -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; 18 Jan 2019 01:45:21 -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" , Chaitanya Kulkarni Subject: [PATCH blktests v3 06/13] common: Introduce _dd() helper function Date: Fri, 18 Jan 2019 18:44:46 +0900 Message-Id: <20190118094453.13773-7-shinichiro.kawasaki@wdc.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190118094453.13773-1-shinichiro.kawasaki@wdc.com> References: <20190118094453.13773-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 To analyze dd command failures found by blktests, need to confirm dd command options. Introduce the helper function which executes dd and records dd command options in FULL file for quick analysis. Reviewed-by: Chaitanya Kulkarni Signed-off-by: Shin'ichiro Kawasaki --- common/rc | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/common/rc b/common/rc index 153a323..fe0e5d8 100644 --- a/common/rc +++ b/common/rc @@ -214,3 +214,34 @@ _test_dev_in_hotplug_slot() { _filter_xfs_io_error() { sed -e 's/^\(.*\)64\(: .*$\)/\1\2/' } + +# Issue dd command with five arguments and record command line in FULL file. +# args: target device, r/w, start sector, sector len, block size in bytes +_dd() { + local target_dev=${1} + local rw=${2} + local -i start_sector=${3} + local -i start_byte=$(( start_sector * 512 )) + local -i sector_count=${4} + local -i bs=${5} + local -i block_count=$(( sector_count * 512 / bs )) + + local _cmd="dd bs=${bs} count=${block_count}" + + if [[ ${rw} = "read" ]]; then + _cmd="${_cmd} if=${target_dev} of=/dev/null" + _cmd="${_cmd} iflag=skip_bytes skip=${start_byte}" + elif [[ ${rw} = "write" ]]; then + _cmd="${_cmd} if=/dev/zero of=${target_dev}" + _cmd="${_cmd} oflag=seek_bytes,direct seek=${start_byte}" + fi + + echo "${_cmd}" >> "$FULL" 2>&1 + + if ! eval "${_cmd}" >> "$FULL" 2>&1 ; then + echo "dd command failed" + return 1 + fi + + sync +} From patchwork Fri Jan 18 09:44:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinichiro Kawasaki X-Patchwork-Id: 10769627 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 33DD714E5 for ; Fri, 18 Jan 2019 09:45:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 227322A1B1 for ; Fri, 18 Jan 2019 09:45:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 168172A9CB; Fri, 18 Jan 2019 09:45:45 +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 9DC1C2A2D0 for ; Fri, 18 Jan 2019 09:45:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726288AbfARJpo (ORCPT ); Fri, 18 Jan 2019 04:45:44 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:8856 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725898AbfARJpn (ORCPT ); Fri, 18 Jan 2019 04:45:43 -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=1547804744; x=1579340744; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=abHhg2wcbdF25eLMhxDmHJ2SklmyEaucqIIwjuf8MIk=; b=GqPdo8Weze7wYpem/2izQAcZEJ1ln+IkN/Z61ZF9ZUQyVbDfTZzIya6u s5Ux6vvD5gim+n2R9HYWpQMHA/T6+brfRTNRZhkqxDKQpw6zR5CTKwYGM 9FY2orTQSuI/uYPGQRStFpbDp7c0QnmuBG1kandtxggZBCD08f507ue8K dNlb0O655RB9Xyo6fj9OuGNAemm8MgP2BobFN+segtrwy2CCoQNKloPIc qNJWrbhy2bkWtUaFJEJJIfRxurlEMs9nB7ZXJqBzM86GLUmI+cMyKUgd9 bcvPszqXnWnt4U7dhHn3K7cl4CAN+3bIDObT/zJdnIU2Ugf1HbEUVXeJC g==; X-IronPort-AV: E=Sophos;i="5.56,489,1539619200"; d="scan'208";a="99182297" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Jan 2019 17:45:29 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 18 Jan 2019 01:26:47 -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; 18 Jan 2019 01:45:26 -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" , Chaitanya Kulkarni Subject: [PATCH blktests v3 07/13] src: Introduce zbdioctl program Date: Fri, 18 Jan 2019 18:44:47 +0900 Message-Id: <20190118094453.13773-8-shinichiro.kawasaki@wdc.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190118094453.13773-1-shinichiro.kawasaki@wdc.com> References: <20190118094453.13773-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 zbdioctl implements calls to zoned block devices ioctls that are not supported currently by sys-utils blkzone utility, namely BLKGETZONESZ and BLKGETNRZONES. Reviewed-by: Chaitanya Kulkarni Signed-off-by: Shin'ichiro Kawasaki --- src/.gitignore | 1 + src/Makefile | 3 +- src/zbdioctl.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 src/zbdioctl.c diff --git a/src/.gitignore b/src/.gitignore index 8c95785..2108f56 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -6,3 +6,4 @@ /nbdsetsize /sg/dxfer-from-dev /sg/syzkaller1 +/zbdioctl diff --git a/src/Makefile b/src/Makefile index c4094b4..5a0556f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -5,7 +5,8 @@ C_TARGETS := \ sg/dxfer-from-dev \ sg/syzkaller1 \ nbdsetsize \ - loop_change_fd + loop_change_fd \ + zbdioctl CXX_TARGETS := \ discontiguous-io diff --git a/src/zbdioctl.c b/src/zbdioctl.c new file mode 100644 index 0000000..1ea72e8 --- /dev/null +++ b/src/zbdioctl.c @@ -0,0 +1,83 @@ +// SPDX-License-Identifier: GPL-3.0+ +// Copyright (C) 2018 Western Digital Corporation or its affiliates. +#include +#include +#include +#include +#include +#include +#include +#include + +#if !defined(BLKGETZONESZ) || !defined(BLKGETNRZONES) + +int main(int argc, char **argv) +{ + return EXIT_FAILURE; +} + +#else + +struct request { + const char *name; + unsigned long code; +} requests[] = { + { "-s", BLKGETZONESZ}, + { "-n", BLKGETNRZONES}, + { NULL, 0}, +}; + +void usage(const char *progname) +{ + int i = 0; + + fprintf(stderr, "usage: %s \n", progname); + fprintf(stderr, " can be:\n"); + while (requests[i].name) { + fprintf(stderr, "\t%s\n", requests[i].name); + i++; + } + exit(EXIT_FAILURE); +} + +int main(int argc, char **argv) +{ + int i = 0, fd, ret; + unsigned int val; + unsigned long code = 0; + + if (argc != 3) + usage(argv[0]); + + while (requests[i].name) { + if (strcmp(argv[1], requests[i].name) == 0) { + code = requests[i].code; + break; + } + i++; + } + if (code == 0) + usage(argv[0]); + + fd = open(argv[2], O_RDWR); + if (fd < 0) { + perror("open"); + return EXIT_FAILURE; + } + + ret = ioctl(fd, code, &val); + if (ret < 0) { + perror("ioctl"); + close(fd); + return EXIT_FAILURE; + } + + printf("%u\n", val); + + close(fd); + + return EXIT_SUCCESS; +} + +#endif + From patchwork Fri Jan 18 09:44:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinichiro Kawasaki X-Patchwork-Id: 10769629 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 AF78E13BF for ; Fri, 18 Jan 2019 09:45:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B43F2A1B1 for ; Fri, 18 Jan 2019 09:45:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F2FA2A9CB; Fri, 18 Jan 2019 09:45:46 +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 EC4322A2D0 for ; Fri, 18 Jan 2019 09:45:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727001AbfARJpp (ORCPT ); Fri, 18 Jan 2019 04:45:45 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:8856 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726782AbfARJpo (ORCPT ); Fri, 18 Jan 2019 04:45:44 -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=1547804744; x=1579340744; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lXVjGmULqipA7ROs8cuvjZ8HifiIlveKYNJgKpS3KdE=; b=WuBo9ysxj4IUvqhO3K+W9JJZ1bMcbDeYcEEyPjgG8NefpJgao8YQRCad Dgqu0bXdpAx4Z1vuLkRmGHVf1L5S7cXhD+jn+LhrkleoHj2NZUswfhtvU QW4UXoeps4bYt/zaM8A6fTm8zpkNRO4e0a5zXB0CAFIbiFdm6NmU6o1Ep wPCvraApkAFixBGi5cj1R5prXnIN+PugZJmUjBYF2WYpAahYr7uEqja2z TwHGiGxvirB+gn3evDtg7dbf6087maVUQd7zL05LeIiPKVP8qsa11yl5u LkZuhJuTftY7rGePYlfqLDX2C2ikyw6xSSuptl9wZs/NxUeo0z21GFIHn w==; X-IronPort-AV: E=Sophos;i="5.56,489,1539619200"; d="scan'208";a="99182311" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Jan 2019 17:45:34 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 18 Jan 2019 01:26:51 -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; 18 Jan 2019 01:45:30 -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" , Chaitanya Kulkarni Subject: [PATCH blktests v3 08/13] tests: Introduce zbd test group Date: Fri, 18 Jan 2019 18:44:48 +0900 Message-Id: <20190118094453.13773-9-shinichiro.kawasaki@wdc.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190118094453.13773-1-shinichiro.kawasaki@wdc.com> References: <20190118094453.13773-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 The zoned block device (zbd) test group is used to gather all tests specific to zoned block devices (null_blk device with zoned mode enabled, SMR disks, dm-linear on top of zoned devices, etc). Execution of this group requires that the kernel be compiled with the block layer CONFIG_BLK_DEV_ZONED option enabled and also requires the null_blk driver to have zoned mode support (added in kernel 4.19). This group rc script implements _fallback_null_blk_zoned() helper function which initailize a null_blk device with zoned mode. Each of the zbd group test cases calls it in fallback_device() function. This allows the zbd group test cases fallback to the null_blk device even if the TEST_DEVS is empty. With this, all tests scripts can be written by only defining the test_device() function while allowing operation on both null_blk and user specified devices. Signed-off-by: Shin'ichiro Kawasaki Signed-off-by: Masato Suzuki --- tests/zbd/rc | 195 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+) create mode 100644 tests/zbd/rc diff --git a/tests/zbd/rc b/tests/zbd/rc new file mode 100644 index 0000000..a6c7696 --- /dev/null +++ b/tests/zbd/rc @@ -0,0 +1,195 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2018 Western Digital Corporation or its affiliates. +# +# Tests for Zone Block Device. + +. common/rc +. common/null_blk + +# +# Test requirement check functions +# + +group_requires() { + _have_root || return $? + _have_program blkzone || return $? + _have_program dd || return $? + _have_kernel_option BLK_DEV_ZONED || return $? + _have_modules null_blk && _have_module_param null_blk zoned +} + +group_device_requires() { + _test_dev_is_zoned +} + +_fallback_null_blk_zoned() { + if ! _init_null_blk zone_size=4 gb=1 zoned=1 ; then + return 1 + fi + echo /dev/nullb0 +} + +# +# Zone types and conditions +# +export ZONE_TYPE_CONVENTIONAL=1 +export ZONE_TYPE_SEQ_WRITE_REQUIRED=2 +export ZONE_TYPE_SEQ_WRITE_PREFERRED=3 + +export ZONE_COND_EMPTY=1 +export ZONE_COND_IMPLICIT_OPEN=2 +export ZONE_COND_FULL=14 + +export ZONE_TYPE_ARRAY=( + [1]="CONVENTIONAL" + [2]="SEQ_WRITE_REQUIRED" + [3]="SEQ_WRITE_PREFERRED" +) + +export ZONE_COND_ARRAY=( + [0]="NOT_WP" + [1]="EMPTY" + [2]="IMPLICIT_OPEN" + [3]="EXPLICIT_OPEN" + [4]="CLOSE" + [13]="READ_ONLY" + [14]="FULL" + [15]="OFFLINE" +) + +# sysfs variable array indices +export SV_CAPACITY=0 +export SV_CHUNK_SECTORS=1 +export SV_PHYS_BLK_SIZE=2 +export SV_PHYS_BLK_SECTORS=3 +export SV_NR_ZONES=4 + +# +# Helper functions +# + +# Obtain zone related sysfs variables and keep in a global array until put +# function call. +_get_sysfs_variable() { + unset SYSFS_VARS + local _dir=${TEST_DEV_SYSFS} + SYSFS_VARS[$SV_CAPACITY]=$(<"${_dir}"/size) + SYSFS_VARS[$SV_CHUNK_SECTORS]=$(<"${_dir}"/queue/chunk_sectors) + SYSFS_VARS[$SV_PHYS_BLK_SIZE]=$(<"${_dir}"/queue/physical_block_size) + SYSFS_VARS[$SV_PHYS_BLK_SECTORS]=$((SYSFS_VARS[SV_PHYS_BLK_SIZE] / 512)) + + # If the nr_zones sysfs attribute exists, get its value. Otherwise, + # calculate its value based on the total capacity and zone size, taking + # into account that the last zone can be smaller than other zones. + if [[ -e ${TEST_DEV_SYSFS}/queue/nr_zones ]]; then + SYSFS_VARS[$SV_NR_ZONES]=$(<"${_dir}"/queue/nr_zones) + else + SYSFS_VARS[$SV_NR_ZONES]=$(( (SYSFS_VARS[SV_CAPACITY] - 1) \ + / SYSFS_VARS[SV_CHUNK_SECTORS] + 1 )) + fi +} + +_put_sysfs_variable() { + unset SYSFS_VARS +} + +# Issue zone report command and keep reported information in global arrays +# until put function call. +_get_blkzone_report() { + local target_dev=${1} + + # Initialize arrays to store parsed blkzone reports. + # Number of reported zones is set in REPORTED_COUNT. + # The arrays have REPORTED_COUNT+1 elements with additional one at tail + # to simplify loop operation. + ZONE_STARTS=() + ZONE_LENGTHS=() + ZONE_WPTRS=() + ZONE_CONDS=() + ZONE_TYPES=() + NR_CONV_ZONES=0 + REPORTED_COUNT=0 + + TMP_REPORT_FILE=${TMPDIR}/blkzone_report + if ! blkzone report "${target_dev}" > "${TMP_REPORT_FILE}"; then + echo "blkzone command failed" + return $? + fi + + local _IFS=$IFS + local -i loop=0 + IFS=$' ,:' + while read -r -a _tokens + do + ZONE_STARTS+=($((_tokens[1]))) + ZONE_LENGTHS+=($((_tokens[3]))) + ZONE_WPTRS+=($((_tokens[5]))) + ZONE_CONDS+=($((${_tokens[11]%\(*}))) + ZONE_TYPES+=($((${_tokens[13]%\(*}))) + if [[ ${ZONE_TYPES[-1]} -eq ${ZONE_TYPE_CONVENTIONAL} ]]; then + (( NR_CONV_ZONES++ )) + fi + (( loop++ )) + done < "${TMP_REPORT_FILE}" + IFS="$_IFS" + REPORTED_COUNT=${loop} + + if [[ ${REPORTED_COUNT} -eq 0 ]] ; then + echo "blkzone report returned no zone" + return 1 + fi + + # Set value to allow additioanl element access at array end + local -i max_idx=$((REPORTED_COUNT - 1)) + ZONE_STARTS+=( $((ZONE_STARTS[max_idx] + ZONE_LENGTHS[max_idx])) ) + ZONE_LENGTHS+=( "${ZONE_LENGTHS[max_idx]}" ) + ZONE_WPTRS+=( "${ZONE_WPTRS[max_idx]}" ) + ZONE_CONDS+=( "${ZONE_CONDS[max_idx]}" ) + ZONE_TYPES+=( "${ZONE_TYPES[max_idx]}" ) + + rm -f "${TMP_REPORT_FILE}" +} + +_put_blkzone_report() { + unset ZONE_STARTS + unset ZONE_LENGTHS + unset ZONE_WPTRS + unset ZONE_CONDS + unset ZONE_TYPES + unset REPORTED_COUNT + unset NR_CONV_ZONES +} + +# Issue reset zone command with zone count option. +# Call _get_blkzone_report() beforehand. +_reset_zones() { + local target_dev=${1} + local -i idx=${2} + local -i count=${3} + + if ! blkzone reset -o "${ZONE_STARTS[idx]}" -c "${count}" \ + "${target_dev}" >> "$FULL" 2>&1 ; then + echo "blkzone reset command failed" + return 1 + fi +} + +# Search zones and find two contiguous sequential required zones. +# Return index of the first zone of the found two zones. +# Call _get_blkzone_report() beforehand. +_find_two_contiguous_seq_zones() { + local -i type_seq=${ZONE_TYPE_SEQ_WRITE_REQUIRED} + + for ((idx = NR_CONV_ZONES; idx < REPORTED_COUNT; idx++)); do + if [[ ${ZONE_TYPES[idx]} -eq ${type_seq} && + ${ZONE_TYPES[idx+1]} -eq ${type_seq} ]]; then + echo "${idx}" + return 0 + fi + done + + echo "Contiguous sequential write required zones not found" + return 1 +} + From patchwork Fri Jan 18 09:44:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinichiro Kawasaki X-Patchwork-Id: 10769637 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 259D013BF for ; Fri, 18 Jan 2019 09:45:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 120022A1B1 for ; Fri, 18 Jan 2019 09:45:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 065532A9CB; Fri, 18 Jan 2019 09:45:54 +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 96BE42A1B1 for ; Fri, 18 Jan 2019 09:45:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727186AbfARJpw (ORCPT ); Fri, 18 Jan 2019 04:45:52 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:8861 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726956AbfARJpp (ORCPT ); Fri, 18 Jan 2019 04:45:45 -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=1547804745; x=1579340745; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZuAoGLlnQKEbYDiO6jPdNjX8klQL9nBbv/TjzQXA7Ec=; b=EEg+RK7M6GeTl3nXn5SR2oPy7BP5FX++VJx+Hf1ut5Lfrs6dQa4ktrMf 5IjR8kuUb4FQz/DELEl1CjVGGgAiDcZ+gRC/ZUTAzYbWkuE/R8oaTPRwn Svk6EJRGjRmYCKkXrWF4hsQUYGMbYnvNDAnLizGRemJ5QwpaPB4i+mCSf juNtf8e8mPXfVr7ouycKj7iQY/UpRkonTv1rxhgcTJ/fXbNh5mWBmfd/T ronT+6DYwCronZoRHMrsIh2uVGE244xQjZOtZMZzTIcDp/QLuQggFfoAi iEvGZJf2srHLx5/ZxT9jftHYhgGulBgD7xdJ/QBARtjoXeIpBCyO2kjdf g==; X-IronPort-AV: E=Sophos;i="5.56,489,1539619200"; d="scan'208";a="99182327" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Jan 2019 17:45:38 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 18 Jan 2019 01:26:55 -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; 18 Jan 2019 01:45:34 -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" , Chaitanya Kulkarni Subject: [PATCH blktests v3 09/13] zbd/001: sysfs and ioctl consistency test Date: Fri, 18 Jan 2019 18:44:49 +0900 Message-Id: <20190118094453.13773-10-shinichiro.kawasaki@wdc.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190118094453.13773-1-shinichiro.kawasaki@wdc.com> References: <20190118094453.13773-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 From patchwork Fri Jan 18 09:44:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinichiro Kawasaki X-Patchwork-Id: 10769631 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 244396C2 for ; Fri, 18 Jan 2019 09:45:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1216C2A1B1 for ; Fri, 18 Jan 2019 09:45:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 063362A9CB; Fri, 18 Jan 2019 09:45:50 +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 8F5A02A1B1 for ; Fri, 18 Jan 2019 09:45:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727371AbfARJps (ORCPT ); Fri, 18 Jan 2019 04:45:48 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:8872 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726818AbfARJpr (ORCPT ); Fri, 18 Jan 2019 04:45:47 -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=1547804747; x=1579340747; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dh8QPHi3FD6QXaxoS9Vqy3f5Q2frQEsXR0qi8u8XpP0=; b=kqAV3EuYMxIk+5SBoEKZC1eZJOKKGaHoZTlgKnDyKGw1OJ8tWTTSVwAm +S8fCZcqITqQNu1P2wD67+2Sv+070T96kbjFy+0lILYx62S0HJ0fEJBhJ hRIQkn3c0tJOew/x0XS4dzGBrVZ2pHy+zxosJ0+v4rXDaVHrybHeUipSs 5BenT4tjHVfKCVhhNvS3UuoXsXXb0Urm3yHcTrCJtrk6322dIzOxc9LVn vtuC2BxTaj4qxT14MlJkPu9dyHwGS/UWoERrnnojZQj0qzVvgTOkr1u+E JeZwNX5GL4gVq1vdSsEXcrwCr/K1G1azeYl+14tzdx3nE/iOPk8U8Z9JB A==; X-IronPort-AV: E=Sophos;i="5.56,489,1539619200"; d="scan'208";a="99182351" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Jan 2019 17:45:42 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 18 Jan 2019 01:26:59 -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; 18 Jan 2019 01:45:38 -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" , Chaitanya Kulkarni Subject: [PATCH blktests v3 10/13] zbd/002: report zone test Date: Fri, 18 Jan 2019 18:44:50 +0900 Message-Id: <20190118094453.13773-11-shinichiro.kawasaki@wdc.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190118094453.13773-1-shinichiro.kawasaki@wdc.com> References: <20190118094453.13773-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 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 --- 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 From patchwork Fri Jan 18 09:44:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinichiro Kawasaki X-Patchwork-Id: 10769633 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 CD15D13BF for ; Fri, 18 Jan 2019 09:45:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB01F2A1B1 for ; Fri, 18 Jan 2019 09:45:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF9ED2A9CB; Fri, 18 Jan 2019 09:45:50 +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 47DBB2A1B1 for ; Fri, 18 Jan 2019 09:45:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726818AbfARJps (ORCPT ); Fri, 18 Jan 2019 04:45:48 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:8872 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727364AbfARJpr (ORCPT ); Fri, 18 Jan 2019 04:45:47 -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=1547804748; x=1579340748; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ya2NYClFb4ZqlWBd2VeHxA0zaynp4IhePTtWV6F79lM=; b=nF2gvdiE07j+hVcUEiBB0AGaPSfugWSCSufBYIH8xjuom7+HhSdoY3tB fkyBSeUw0r7C2+rXDyqx+82Vt7NwASkU0jQszq4c2QiGWKfDviaijipGi Ot/ZdDJObOPTke/j1azAJRVP4IMkr0DmSlNIxSEmYUgmRUYO+RTyW+jz4 Hl8yGKQ5lwnoWnEDagoOkwyANLZzfbJvQApTUax/BmKQpPSAZd5fq4dSh uctN9iuCvvnF3Ypv7b0Qxe/XRZMhAQ/TPrdNUkZg+88ZgsWjl4k7JEnXK 1eSE9PHJq8fCYeshsU/oN054xpZD9HYmN1Pr/dKWgFbyBgRkdy71KrXoJ g==; X-IronPort-AV: E=Sophos;i="5.56,489,1539619200"; d="scan'208";a="99182368" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Jan 2019 17:45:46 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 18 Jan 2019 01:27:03 -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; 18 Jan 2019 01:45:42 -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" , Chaitanya Kulkarni Subject: [PATCH blktests v3 11/13] zbd/003: Test sequential zones reset Date: Fri, 18 Jan 2019 18:44:51 +0900 Message-Id: <20190118094453.13773-12-shinichiro.kawasaki@wdc.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190118094453.13773-1-shinichiro.kawasaki@wdc.com> References: <20190118094453.13773-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 Test zone reset operation to make sure that the BLKRESETZONE ioctl call works as expected but also that the zone sector remapping that may be done for logical devices (partitions or dm-linear devices) is correct. Signed-off-by: Shin'ichiro Kawasaki Signed-off-by: Masato Suzuki --- tests/zbd/003 | 78 +++++++++++++++++++++++++++++++++++++++++++++++ tests/zbd/003.out | 2 ++ 2 files changed, 80 insertions(+) create mode 100755 tests/zbd/003 create mode 100644 tests/zbd/003.out diff --git a/tests/zbd/003 b/tests/zbd/003 new file mode 100755 index 0000000..b51f713 --- /dev/null +++ b/tests/zbd/003 @@ -0,0 +1,78 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2018 Western Digital Corporation or its affiliates. +# +# Confirm that reset zone command for 2 contiguous sequential write +# requried zones works as expected. + +. tests/zbd/rc + +DESCRIPTION="reset sequential required zones" +QUICK=1 +CAN_BE_ZONED=1 + +requires() { + _have_program blkzone +} + +fallback_device() { + _fallback_null_blk_zoned +} + +cleanup_fallback_device() { + _exit_null_blk +} + +test_device() { + local -i zone_idx + local -a target_zones + local -i phys_blk_size + + echo "Running ${TEST_NAME}" + + # Get physical block size for dd + _get_sysfs_variable "${TEST_DEV}" || return $? + phys_blk_size=${SYSFS_VARS[$SV_PHYS_BLK_SIZE]} + _put_sysfs_variable + + # Select 2 target zones so that reset zone range also get tested + _get_blkzone_report "${TEST_DEV}" || return $? + zone_idx=$(_find_two_contiguous_seq_zones) || return $? + target_zones=( "${zone_idx}" "$((zone_idx + 1))" ) + + # Reset the 2 target zones and write 4KB in each zone to increment + # their write pointer positions + _reset_zones "${TEST_DEV}" "${zone_idx}" "2" + for i in "${target_zones[@]}"; do + _dd "${TEST_DEV}" "write" "${ZONE_STARTS[$i]}" \ + "8" "${phys_blk_size}" + done + _put_blkzone_report + + # Check that the write pointers have moved by 8x512 B sectors + _get_blkzone_report "${TEST_DEV}" || return $? + for i in "${target_zones[@]}"; do + if [[ ${ZONE_WPTRS[$i]} -ne 8 ]]; then + echo -n "Unexpected write poiter position in zone ${i} " + echo "wp: ${ZONE_WPTRS[i]}" + return 1 + fi + done + + # Reset the 2 target zones + _reset_zones "${TEST_DEV}" "${zone_idx}" "2" + _put_blkzone_report + + # Check that the write pointers have moved back to position 0 + _get_blkzone_report "${TEST_DEV}" || return $? + for i in "${target_zones[@]}"; do + if [[ ${ZONE_WPTRS[i]} -ne 0 ]]; then + echo -n "Unexpected non-zero write poiter in zone ${i} " + echo "wp: ${ZONE_WPTRS[i]}" + return 1 + fi + done + _put_blkzone_report + + echo "Test complete" +} diff --git a/tests/zbd/003.out b/tests/zbd/003.out new file mode 100644 index 0000000..7326ae4 --- /dev/null +++ b/tests/zbd/003.out @@ -0,0 +1,2 @@ +Running zbd/003 +Test complete From patchwork Fri Jan 18 09:44:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinichiro Kawasaki X-Patchwork-Id: 10769635 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 20B5913BF for ; Fri, 18 Jan 2019 09:45:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B3772A1B1 for ; Fri, 18 Jan 2019 09:45:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F26E52A9CB; Fri, 18 Jan 2019 09:45:52 +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 859202A1B1 for ; Fri, 18 Jan 2019 09:45:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726062AbfARJpv (ORCPT ); Fri, 18 Jan 2019 04:45:51 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:8872 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727364AbfARJpu (ORCPT ); Fri, 18 Jan 2019 04:45:50 -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=1547804750; x=1579340750; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lbo007G+ae48GozuMUNyozvlZw+duVvqZXjtgNBvxMw=; b=rxhGfIgKrn5rRA797MODvEb8bmyjIMTTPAoPZrCb3lSOsj9o0uVdHkCg nFDWfiKlw5X301zbet3Dk0lr9yU1CHIAcxCe+UrzhmEn0kRQBfPSBdGAO uYeJHetnigjwro9t4De8s/hCnBlC6omTkOW0fyQIawuV7laADM6vWYJof XvmeAi2xcbiXB1NZlXqRj3xnPuGXiqJP0z1cUrQFNTcwcmp+/GvuCTblR UrxTANhUc52UusWwHZNjZD3QulBJcFzdYuWGsPfpPP7KY6nu8dSBSOa6h TNsQ3B0489dnjRLQnm2olV0pg0onvX/RVgkY+gjKJAqQ+vsX14Y7s/AT1 w==; X-IronPort-AV: E=Sophos;i="5.56,489,1539619200"; d="scan'208";a="99182379" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Jan 2019 17:45:50 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 18 Jan 2019 01:27:08 -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; 18 Jan 2019 01:45:46 -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" , Chaitanya Kulkarni Subject: [PATCH blktests v3 12/13] zbd/004: Check write split accross sequential zones Date: Fri, 18 Jan 2019 18:44:52 +0900 Message-Id: <20190118094453.13773-13-shinichiro.kawasaki@wdc.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190118094453.13773-1-shinichiro.kawasaki@wdc.com> References: <20190118094453.13773-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 Check that write operations spanning a zone boundary are correctly processed as 2 different write operations each fully within a single zone. Signed-off-by: Masato Suzuki --- tests/zbd/004 | 90 +++++++++++++++++++++++++++++++++++++++++++++++ tests/zbd/004.out | 2 ++ 2 files changed, 92 insertions(+) create mode 100755 tests/zbd/004 create mode 100644 tests/zbd/004.out diff --git a/tests/zbd/004 b/tests/zbd/004 new file mode 100755 index 0000000..d8defa9 --- /dev/null +++ b/tests/zbd/004 @@ -0,0 +1,90 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2018 Western Digital Corporation or its affiliates. +# +# Check kernel splits write operations across a zone border. Select two +# contiguous sequential write required zones and confirm write oprations +# across the two zones succeed. + +. tests/zbd/rc + +DESCRIPTION="write split across sequential zones" +QUICK=1 +CAN_BE_ZONED=1 + +fallback_device() { + _fallback_null_blk_zoned +} + +cleanup_fallback_device() { + _exit_null_blk +} + +_check_zone_cond() { + local -i idx=${1} + local -i cond=${2} + + if [[ ${ZONE_CONDS[idx]} -ne ${cond} ]]; then + echo -n "Zone ${idx} condition is not ${ZONE_COND_ARRAY[cond]} " + echo "cond: ${ZONE_COND_ARRAY[ZONE_CONDS[idx]]}" + return 1 + fi +} + +test_device() { + local -i idx + local -i phys_blk_size + local -i phys_blk_sectors + + echo "Running ${TEST_NAME}" + + # Get physical block size and sectors for dd. + _get_sysfs_variable "${TEST_DEV}" || return $? + phys_blk_size=${SYSFS_VARS[SV_PHYS_BLK_SIZE]} + phys_blk_sectors=${SYSFS_VARS[SV_PHYS_BLK_SECTORS]} + _put_sysfs_variable + + # Find target sequential required zones and reset write pointers + _get_blkzone_report "${TEST_DEV}" || return $? + idx=$(_find_two_contiguous_seq_zones) || return $? + _reset_zones "${TEST_DEV}" "${idx}" "2" + + # Confirm the zones are initialized + _put_blkzone_report + _get_blkzone_report "${TEST_DEV}" || return $? + _check_zone_cond "${idx}" "${ZONE_COND_EMPTY}" || return $? + _check_zone_cond "$((idx+1))" "${ZONE_COND_EMPTY}" || return $? + + # Fill first target zone, remaining a physical block to write + if ! _dd "${TEST_DEV}" "write" "${ZONE_STARTS[idx]}" \ + $((ZONE_LENGTHS[idx] - phys_blk_sectors)) ${phys_blk_size} ; then + echo "Fill zone failed" + return 1 + fi + + # Write across the zone border as a single block write + local -i start_sector=$((ZONE_STARTS[idx+1] - phys_blk_sectors)) + if ! _dd "${TEST_DEV}" "write" ${start_sector} \ + $((phys_blk_sectors * 2)) $((phys_blk_size * 2)) ; then + echo "Write across zone border failed" + return 1 + fi + + # Confirm the zone conditions are as expected + _put_blkzone_report + _get_blkzone_report "${TEST_DEV}" || return $? + _check_zone_cond "${idx}" "${ZONE_COND_FULL}" || return $? + _check_zone_cond "$((idx+1))" "${ZONE_COND_IMPLICIT_OPEN}" || return $? + if [[ ${ZONE_WPTRS[idx+1]} -ne ${phys_blk_sectors} ]]; then + echo -n "Unexpected write pointer for zone $((idx+1)) " + echo "wp: ${ZONE_WPTRS[idx+1]}" + return 1 + fi + + # Clean up + _reset_zones "${TEST_DEV}" "${idx}" "2" + _put_blkzone_report + + echo "Test complete" +} + diff --git a/tests/zbd/004.out b/tests/zbd/004.out new file mode 100644 index 0000000..dd4ea94 --- /dev/null +++ b/tests/zbd/004.out @@ -0,0 +1,2 @@ +Running zbd/004 +Test complete From patchwork Fri Jan 18 09:44:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinichiro Kawasaki X-Patchwork-Id: 10769639 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 DDCAE6C2 for ; Fri, 18 Jan 2019 09:46:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C92772A2D0 for ; Fri, 18 Jan 2019 09:46:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD5F22C209; Fri, 18 Jan 2019 09:46:02 +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 BACF02A2D0 for ; Fri, 18 Jan 2019 09:45:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727364AbfARJpz (ORCPT ); Fri, 18 Jan 2019 04:45:55 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:8872 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726956AbfARJpy (ORCPT ); Fri, 18 Jan 2019 04:45:54 -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=1547804754; x=1579340754; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HhLivrf1ZOQNPDV2UpJ0kdP7WmFbE6YMCJKyYi+AggQ=; b=aYizh53U0FFv/FdxWNXSiujKhLHsqLNWfOESIcPphQ9NL/mhBI1HndCD 8XXars++MQS76I6m747l2MOg2QoA83jsxW9eBvDnZuN00vLWXlE5lKsT0 9d8hPrSEd0h7fEtBN5n7QVcFlz++pEFox3SDpxvU0IGClb5Yu1BqitVFl t9n0aTp6K57XbZwBXmM+Bwxrgf4BP8kMro62nCpjAcMCnc1pvOmYmtGJ3 nHhX8264qsZhKcmrtH9HoeGRsBpmzfMLf64+oOF9qhMSJ9Wh1x3d3rc9+ 53Xa23qx68go8YR+PUb7b8Ngda6Tmr8Bv0XI9P1tmAVQY86WEi8dU18PT A==; X-IronPort-AV: E=Sophos;i="5.56,489,1539619200"; d="scan'208";a="99182391" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Jan 2019 17:45:54 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 18 Jan 2019 01:27:12 -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; 18 Jan 2019 01:45:50 -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" , Chaitanya Kulkarni Subject: [PATCH blktests v3 13/13] zbd/005: Test write ordering Date: Fri, 18 Jan 2019 18:44:53 +0900 Message-Id: <20190118094453.13773-14-shinichiro.kawasaki@wdc.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190118094453.13773-1-shinichiro.kawasaki@wdc.com> References: <20190118094453.13773-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 Run a high queue depth direct sequential write fio job to check that write requests are not being reordered when the deadline scheduler is used. This test allowed to catch a bug fixed with commit 80e02039721 "block: mq-deadline: Fix write completion handling". Signed-off-by: Masato Suzuki --- tests/zbd/005 | 67 +++++++++++++++++++++++++++++++++++++++++++++++ tests/zbd/005.out | 2 ++ 2 files changed, 69 insertions(+) create mode 100755 tests/zbd/005 create mode 100644 tests/zbd/005.out diff --git a/tests/zbd/005 b/tests/zbd/005 new file mode 100755 index 0000000..bc9cad5 --- /dev/null +++ b/tests/zbd/005 @@ -0,0 +1,67 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2018 Western Digital Corporation or its affiliates. +# +# Run a high queue depth direct sequential write fio job to check that +# write requests are not being reordered when the deadline scheduler is +# used. This test allowed to catch a bug fixed with commit 80e02039721 +# "block: mq-deadline: Fix write completion handling". + +. tests/zbd/rc + +DESCRIPTION="write command ordering" +TIMED=1 +CAN_BE_ZONED=1 + +requires() { + _have_fio_zbd_zonemode +} + +fallback_device() { + _fallback_null_blk_zoned +} + +cleanup_fallback_device() { + _exit_null_blk +} + +_find_first_sequential_zone() { + for ((idx = NR_CONV_ZONES; idx < REPORTED_COUNT; idx++)); do + if [[ ${ZONE_TYPES[idx]} -eq ${ZONE_TYPE_SEQ_WRITE_REQUIRED} ]]; + then + echo "${idx}" + return 0 + fi + done + echo "Sequential write required zone not found" + + return 1 +} + +test_device() { + local -i zone_idx + local -i offset + + echo "Running ${TEST_NAME}" + + _get_sysfs_variable "${TEST_DEV}" || return $? + _get_blkzone_report "${TEST_DEV}" || return $? + + zone_idx=$(_find_first_sequential_zone) || return $? + offset=$((ZONE_STARTS[zone_idx] * 512)) + + blkzone reset -o "${ZONE_STARTS[zone_idx]}" "${TEST_DEV}" + + _test_dev_queue_set scheduler deadline + + : "${TIMEOUT:=30}" + FIO_PERF_FIELDS=("write io" "write iops") + _fio_perf --filename="${TEST_DEV}" --name zbdwo --rw=write --direct=1 \ + --ioengine=libaio --iodepth=128 --bs=256k \ + --offset="${offset}" + + _put_blkzone_report + _put_sysfs_variable + + echo "Test complete" +} diff --git a/tests/zbd/005.out b/tests/zbd/005.out new file mode 100644 index 0000000..3ff78c6 --- /dev/null +++ b/tests/zbd/005.out @@ -0,0 +1,2 @@ +Running zbd/005 +Test complete