From patchwork Tue Mar 5 05:24:45 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: 10839039 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 613BB1390 for ; Tue, 5 Mar 2019 05:24:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E2832BBBB for ; Tue, 5 Mar 2019 05:24:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41AE52BE0E; Tue, 5 Mar 2019 05:24: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 A168B2BBBB for ; Tue, 5 Mar 2019 05:24:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726300AbfCEFYv (ORCPT ); Tue, 5 Mar 2019 00:24:51 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:55132 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725835AbfCEFYu (ORCPT ); Tue, 5 Mar 2019 00:24: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=1551763490; x=1583299490; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=p0OzuGjmy4M/BE9rqf4rRfbTao6WJTH/dhiea2ZR5yo=; b=LP6tPRWHjDoYKF7TxD29jwJ8yc7ChJubNWJwL+EENGHS4YkdFf70dLVK OVBk54N+hdPtUuyKfQT2qTdClxvQ6rqUPTduP+Xc+DpvKG6sJVljbZZA3 ai4Kfr90pQ/MDKxU8+SrI/12Xy08eUHyHWPWFGdCYdhotKET/ZMMPaQt8 fr68kx5p5x7e8kz0aew9457CmLXxcDfqhywkfjEGhglyntSUEvOk26Yzj 8y9s72pcsIgQw8RrsHaXt0bGs4/NFBAarcFDkBNO1iFRYB5VVUrKk6VuI ukqwWXftAT/61OSueNp+G+Gui1F/Wq7PPfQHUogYHzS643iebx4junMrK w==; X-IronPort-AV: E=Sophos;i="5.58,442,1544457600"; d="scan'208";a="107735604" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 05 Mar 2019 13:24:50 +0800 IronPort-SDR: yEj+nNpwmD5LbuKQmMwGTArZXnOShSPbJn10frzNWfg9wCJxhAinvDjt2Kg4y4f7UyRQy+egPn DvnYxbRRzdxFX9lNpjab0SinOaxJFk7Uk3W7KY74/UIn90WcqjCzd4ebXnLI7BAv01hdV/VbZ4 w3P3UVbruFeGl68MO2z6qmTzM72ZtBbBSngmD4CCoqAOly3Y6gyKor3hmGPmDPz7ke4ClL4GVw ueXrjPVMOxitTBW8f2Wx5Gi1sRcuxbvaV+3MdcpPA9HaP1Pt37FXt47t1V50fOR6r6pDD0ss2K MHksDqi90ZgGrhEfV3jgng+g Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP; 04 Mar 2019 21:04:54 -0800 IronPort-SDR: +nVMYLJalwuHScyHdkc7Yc3t3QWgJC9Sb4ER6JirN4CCY6mNkDDv79ctXuzK+DWnEGZ/Hukh1A /+OO/A7s/BrNie0jKH7Qkx2/SUNELHA/NwFpokcEqDoYMYbDB0h+lzsYufuDrBR+WtqvLLFPTg PKjNxieQdvPuriUxD5dgu0Tk8HpdT4F0iukK/KjQSwUXiDeftpWw0Ij0NUqADQP6nqTRFw8dFJ Je5730vtYsNvu4Cq45Qfkds/CX10hNtUoiHYY55J8wUxNKsgvPZ3duwyTfZqVUHtgTkih5bfRQ GAE= Received: from shin_dev.dhcp.fujisawa.hgst.com (HELO shin_dev.fujisawa.hgst.com) ([10.149.52.166]) by uls-op-cesaip01.wdc.com with ESMTP; 04 Mar 2019 21:24:49 -0800 From: Shin'ichiro Kawasaki To: linux-block@vger.kernel.org, Omar Sandoval , Shinichiro Kawasaki Cc: Masato Suzuki , Omar Sandoval , Chaitanya Kulkarni Subject: [PATCH blktests 1/3] check: Add TEST_DEV_PART_SYSFS variable Date: Tue, 5 Mar 2019 14:24:45 +0900 Message-Id: <20190305052447.24291-2-shinichiro.kawasaki@wdc.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190305052447.24291-1-shinichiro.kawasaki@wdc.com> References: <20190305052447.24291-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 When partition devices are specified in TEST_DEV, TEST_DEV_SYSFS variable points to the sysfs paths of holder devices of the partition devices (e.g., /sys/block/sda). This sysfs path is different from the sysfs path of the partition devices (e.g., /sys/block/sda/sda1). For example, size parameters exist in both the holder device sysfs and the partition device sysfs with different values. To allow test cases to access sysfs path of the partition devices, add TEST_DEV_PART_SYSFS variable. TEST_DEV_SYSFS is set as is to refer the sysfs path of the holder devices. If the TEST_DEV is not a partition device, an empty string is set to the TEST_DEV_PART_SYSFS variable. Rename _find_sysfs_dir() function to _find_sysfs_dirs() and make it find holder device sysfs as well as the partition device sysfs. The function obtains the canonical sysfs path, and if the device is a partition device, the function cuts the last device name in the canonical sysfs path to obtain the holder device sysfs path. Signed-off-by: Shin'ichiro Kawasaki --- check | 46 +++++++++++++++++++++++++--------------------- new | 16 ++++++++++++++-- 2 files changed, 39 insertions(+), 23 deletions(-) diff --git a/check b/check index 819d8f3..6d44bfb 100755 --- a/check +++ b/check @@ -443,13 +443,13 @@ _run_test() { _warning "$TEST_NAME: fallback_device call failure" return 0 fi - if ! sysfs_dir="$(_find_sysfs_dir "$test_dev")"; then + + if ! _find_sysfs_dirs "$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 @@ -465,6 +465,7 @@ _run_test() { local ret=0 for TEST_DEV in "${TEST_DEVS[@]}"; do TEST_DEV_SYSFS="${TEST_DEV_SYSFS_DIRS["$TEST_DEV"]}" + TEST_DEV_PART_SYSFS="${TEST_DEV_PART_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")" @@ -484,6 +485,7 @@ _run_test() { if (( FALLBACK_DEVICE )); then cleanup_fallback_device unset TEST_DEV_SYSFS_DIRS["${TEST_DEVS[0]}"] + unset TEST_DEV_PART_SYSFS_DIRS["${TEST_DEVS[0]}"] TEST_DEVS=() fi @@ -508,6 +510,8 @@ _run_group() { for i in "${!TEST_DEVS[@]}"; do TEST_DEV="${TEST_DEVS[$i]}" TEST_DEV_SYSFS="${TEST_DEV_SYSFS_DIRS["$TEST_DEV"]}" + # shellcheck disable=SC2034 + TEST_DEV_PART_SYSFS="${TEST_DEV_PART_SYSFS_DIRS["$TEST_DEV"]}" if ! group_device_requires; then _output_notrun "${group}/*** => $(basename "$TEST_DEV")" unset TEST_DEVS["$i"] @@ -528,30 +532,32 @@ _run_group() { return $ret } -_find_sysfs_dir() { +_find_sysfs_dirs() { local test_dev="$1" + local sysfs_path local major=$((0x$(stat -L -c '%t' "$test_dev"))) local minor=$((0x$(stat -L -c '%T' "$test_dev"))) - local dev="$major:$minor" - local block_dir part_dir - for block_dir in /sys/block/*; do - if [[ $(cat "${block_dir}/dev") = "$dev" ]]; then - echo "$block_dir" - return - fi - for part_dir in "$block_dir"/*; do - if [[ -r ${part_dir}/dev && $(cat "${part_dir}/dev") = "$dev" ]]; then - echo "$block_dir" - return - fi - done - done + # Get the canonical sysfs path + if ! sysfs_path="$(realpath "/sys/dev/block/${major}:${minor}")"; then + return 1 + fi - return 1 + if [[ -r "${sysfs_path}"/partition ]]; then + # If the device is a partition device, cut the last device name + # of the canonical sysfs path to access to the sysfs of its + # holder device. + # e.g. .../block/sda/sda1 -> ...block/sda + TEST_DEV_SYSFS_DIRS["$test_dev"]="${sysfs_path%/*}" + TEST_DEV_PART_SYSFS_DIRS["$test_dev"]="${sysfs_path}" + else + TEST_DEV_SYSFS_DIRS["$test_dev"]="${sysfs_path}" + TEST_DEV_PART_SYSFS_DIRS["$test_dev"]="" + fi } declare -A TEST_DEV_SYSFS_DIRS +declare -A TEST_DEV_PART_SYSFS_DIRS _check() { # shellcheck disable=SC2034 SRCDIR="$(realpath src)" @@ -564,11 +570,9 @@ _check() { _error "${test_dev} is not a block device" fi - local sysfs_dir - if ! sysfs_dir="$(_find_sysfs_dir "$test_dev")"; then + if ! _find_sysfs_dirs "$test_dev"; then _error "could not find sysfs directory for ${test_dev}" fi - TEST_DEV_SYSFS_DIRS["$test_dev"]="$sysfs_dir" done local test_name group prev_group diff --git a/new b/new index d7d5f7c..24c066d 100755 --- a/new +++ b/new @@ -80,7 +80,10 @@ group_requires() { # should return non-zero and set the \$SKIP_REASON variable. \$TEST_DEV is the # full path of the block device (e.g., /dev/nvme0n1 or /dev/sda1), and # \$TEST_DEV_SYSFS is the sysfs path of the disk (not the partition, e.g., -# /sys/block/nvme0n1 or /sys/block/sda). +# /sys/block/nvme0n1 or /sys/block/sda). If the target device is a partition +# device, \$TEST_DEV_PART_SYSFS is the sysfs path of the partition device +# (e.g., /sys/block/nvme0n1/nvme0n1p1 or /sys/block/sda/sda1). Otherwise, +# \$TEST_DEV_PART_SYSFS is an empty string. # # Usually, group_device_requires() just needs to check that the test device is # the right type of hardware or supports any necessary features using the @@ -165,7 +168,10 @@ DESCRIPTION="" # set the \$SKIP_REASON variable. \$TEST_DEV is the full path of the block # device (e.g., /dev/nvme0n1 or /dev/sda1), and \$TEST_DEV_SYSFS is the sysfs # path of the disk (not the partition, e.g., /sys/block/nvme0n1 or -# /sys/block/sda). +# /sys/block/sda). If the target device is a partition device, +# \$TEST_DEV_PART_SYSFS is the sysfs path of the partition device (e.g., +# /sys/block/nvme0n1/nvme0n1p1 or /sys/block/sda/sda1). Otherwise, +# \$TEST_DEV_PART_SYSFS is an empty string. # # Usually, device_requires() just needs to check that the test device is the # right type of hardware or supports any necessary features using the @@ -207,6 +213,12 @@ DESCRIPTION="" # - \$TEST_DEV_SYSFS -- the sysfs directory of the device (e.g., # /sys/block/sda). In general, you should use the # _test_dev_queue_{get,set} helpers. +# If the device is a partition device, the sysfs +# directory of its holder device is set. +# - \$TEST_DEV_PART_SYSFS -- the sysfs directory of the device if the device +# is a partition device (e.g., +# /sys/block/sda/sda1). Empty string is set if +# the device is not a partition device. test() { echo "Running \${TEST_NAME}" From patchwork Tue Mar 5 05:24:46 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: 10839041 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 98A75922 for ; Tue, 5 Mar 2019 05:25:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83BB92BBBB for ; Tue, 5 Mar 2019 05:25:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 739FE2BE0E; Tue, 5 Mar 2019 05:25: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 1AB8E2BBBB for ; Tue, 5 Mar 2019 05:25:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726045AbfCEFZI (ORCPT ); Tue, 5 Mar 2019 00:25:08 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:29725 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725835AbfCEFZI (ORCPT ); Tue, 5 Mar 2019 00:25: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=1551763508; x=1583299508; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MiZZeTqu+1kJzRl7EGsiCbJmhOI0dS6PQbZ9+5e6sPs=; b=SVYfuIflS8fTRbBL57+2TNquD5ozgYowMmkpKCyFs5qzjY1wiIAmFQkI qQYYSOfKn/kG5he6W9qmhGPNKgeSKfzd2RqkFLqYXc4oFgr3UxnxkkHth IAqY04N2mualWvQvLuvQG6Wg0R18+1I3eXtNsZyqIPoYLUzbaogymxnd2 lrnPI7qNHFF8/fK089Wibjz6dlNG+VzhRH8sT0CCooFEvF2t/rBOjbD+q Bs7uqXiVeX3kHHCI2mHXM0qABGD+5CMZvUd7SJdfxGieG0p5fpB6mvNYT p0VzdnuCk97ROPr8j8ewToPHPePUWwgmBMLV0pSA1JzbSkEOPsMi49w6s w==; X-IronPort-AV: E=Sophos;i="5.58,442,1544457600"; d="scan'208";a="104040565" 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; 05 Mar 2019 13:25:08 +0800 IronPort-SDR: PyEfEix1mlHtV5Wmi8CjKUTn2xekBr2d8NcaN7NOu66Hf2H9JdRya7SOavhY/il79vvUcXe9u/ whH4lpY4lGqBOL9uMg9HpDZbSZYIxVArVpgpWMNqAi6Rwrjm2PQ9fOAWetK+KO/ZJC2TDUbrGE VhMTDw7VyaQddWTkgXBzLdsiNKKT+xniXdn8PgplPYouvjsVfja2vM6p2dOe3N3pugVakMKdmc UVdXMeWM/JitF3W3ZALzh8y/AuMkXh80NpP2kthgZhbJmorC6ozENGQdZY0AWDGp1Bk5UDJqV7 DCLkloPA06jgX2nnBF6879li Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP; 04 Mar 2019 21:05:11 -0800 IronPort-SDR: Zom28rTANRXTDxVaTFHhMzyCHsWiv6/JqNVBGCoMhUlJZUsAmqc01FLh1eVTEjXVyqRH7KgBLQ XphV9JpgZKduVPxNiryzqLPKIGiL+9MlxrXM0wDb4izz5Qs55GHB8Cj4kmwEm9hB/J3RQENuAM MvlDSZV6HxVcox0zBZ1aPZnyvH7alry23SLmxVXDXwk/P5zL3xpXczzpubjoQbnc0Eoadpou2X TZGBZNt2ZO+nX/vQ6BLIuLLLO2kLx6JfE9071CyyQ5dd4jkmAngnh3y7Z6H3Yyzey+m563dFLh Orw= Received: from shin_dev.dhcp.fujisawa.hgst.com (HELO shin_dev.fujisawa.hgst.com) ([10.149.52.166]) by uls-op-cesaip01.wdc.com with ESMTP; 04 Mar 2019 21:25:07 -0800 From: Shin'ichiro Kawasaki To: linux-block@vger.kernel.org, Omar Sandoval , Shinichiro Kawasaki Cc: Masato Suzuki , Omar Sandoval , Chaitanya Kulkarni Subject: [PATCH blktests 2/3] common: Add _test_dev_is_partition() helper function Date: Tue, 5 Mar 2019 14:24:46 +0900 Message-Id: <20190305052447.24291-3-shinichiro.kawasaki@wdc.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190305052447.24291-1-shinichiro.kawasaki@wdc.com> References: <20190305052447.24291-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 control test conditions unique for partition devices, introduce the _test_dev_is_partition() helper function. Refer TEST_DEV_PART_SYSFS variable to tell if the TEST_DEV is a partition device or not. Signed-off-by: Shin'ichiro Kawasaki Reviewed-by: Omar Sandoval --- common/rc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/rc b/common/rc index 153a323..0c354a2 100644 --- a/common/rc +++ b/common/rc @@ -208,6 +208,14 @@ _test_dev_in_hotplug_slot() { return 0 } +_test_dev_is_partition() { + if [[ -z ${TEST_DEV_PART_SYSFS} ]]; then + SKIP_REASON="${TEST_DEV} is not a partition device" + return 1 + fi + return 0 +} + # Older versions of xfs_io use pwrite64 and such, so the error messages won't # match current versions of xfs_io. See c52086226bc6 ("filter: xfs_io output # has dropped "64" from error messages") in xfstests. From patchwork Tue Mar 5 05:24:47 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: 10839043 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 7C19F922 for ; Tue, 5 Mar 2019 05:25:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6AB612BBBB for ; Tue, 5 Mar 2019 05:25:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E0AE2BE0E; Tue, 5 Mar 2019 05:25:11 +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 4EE852BBBB for ; Tue, 5 Mar 2019 05:25:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725835AbfCEFZJ (ORCPT ); Tue, 5 Mar 2019 00:25:09 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:29725 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727043AbfCEFZJ (ORCPT ); Tue, 5 Mar 2019 00:25:09 -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=1551763509; x=1583299509; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NLJDoKqNeFjkCpr7fNdtTafJP8i4aDf71RpsRFmb0uI=; b=RIq+drCxCzUBbYP+nV/T3PBfhn4Hvdw03xZaOMsnOMfhYeRioKpSs7rm I4yPErRnquLocKgPRi1s+ntJ6EAetttBNKBLcPWdkJKweZCW49uAOrDMZ IH1gCB4DcqJJP0AaBbNIfAoyLIhyd3h5eN51jv/pfN8R20GfT1VZDxM43 BaC0vz4rJ4J5sjJX3tZ3lhmMFspE3lCEf60d1ve12Io/98IWtuuKfLeks nEJnSOCYBfCezTvJ6VNkz54+1Crgz9akgVj+vAHxlmBNjqP95JmzGQUlo fF8Ghx1HmVZA4GigMEY7LHF+57cu53npKZpGu7tVOl7po9GSaaX+YHm3Y w==; X-IronPort-AV: E=Sophos;i="5.58,442,1544457600"; d="scan'208";a="104040566" 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; 05 Mar 2019 13:25:09 +0800 IronPort-SDR: qBqdgGiiAvlQQJOppG8xEP4+nDG9orG9QqdHjpMPY5CZm7+4VSbbxzNNiUAsAXUukobL4JIwvi U3i8YfJMRNYJBPVGSMDRhNrO0H525gxs40LW7cBrVEE6zLOVXRRHjObqcYZRnZjUGCz++yScRG Hckpjaug2SVSttNE4jYptqjbOUyNCqJCA+3XZjLr7FCAQs6OOQXDHZ/dRTlda4qpJOHUPzBJ9H VbFaW/VcJ+Oe8QKf6EX1EGnKaqeFOPSQWC8SHy9Db7qSnTlHPI2L773mcgIC6ihsPPXDvLJRVW w3CFIri/LZhbd6jVc0caChRM Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP; 04 Mar 2019 21:05:12 -0800 IronPort-SDR: ER19VKxzZB7My61R0qozBwU3+3t2mxXo7xyXAKeYUtpsdtmQeE+wQWnppT+66KLbH8HC86Dmfo kcVW/RopYNsQavHJZ+ORFP7MO1mmfRH/aFLZW2lgZ5/quEqwmn1ghgBvGJTSRR+AJURkY4HMah 6ftFuvGfN9roKeimCRyyDG5ROXUbvSAArJZb6VMiAb+i8NWwX3TsWO6ht4i1Sa/5kjxXimJ2hh dYjODJn8NdiW2uzdcb9im+9jQupwAL83g4s2CxDLbDfBgPw+DCCmfLdF+NjJF8Kma+bHUCa9tv RdU= Received: from shin_dev.dhcp.fujisawa.hgst.com (HELO shin_dev.fujisawa.hgst.com) ([10.149.52.166]) by uls-op-cesaip01.wdc.com with ESMTP; 04 Mar 2019 21:25:08 -0800 From: Shin'ichiro Kawasaki To: linux-block@vger.kernel.org, Omar Sandoval , Shinichiro Kawasaki Cc: Masato Suzuki , Omar Sandoval , Chaitanya Kulkarni Subject: [PATCH blktests 3/3] zbd: Change sysfs path for partition devices Date: Tue, 5 Mar 2019 14:24:47 +0900 Message-Id: <20190305052447.24291-4-shinichiro.kawasaki@wdc.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190305052447.24291-1-shinichiro.kawasaki@wdc.com> References: <20190305052447.24291-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 zbd/001 and zbd/002 test cases fail for partition devices because of sysfs path difference between partition devices and their holder devices. The size parameter in sysfs path is different between the partition devices and their holder devices. The holder devices have nr_zones parameter in sysfs but the partition devices do not. Utilize _test_dev_is_partition() helper function and TEST_DEV_PART_SYSFS variable to refer correct sysfs size parameter for the partition devices. Do not refer sysfs nr_zones parameter for the partition devices. Instead, calculate the expected nr_zones from device capacity and zone size. Signed-off-by: Shin'ichiro Kawasaki Reviewed-by: Omar Sandoval --- tests/zbd/rc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/zbd/rc b/tests/zbd/rc index c32bf31..88538d0 100644 --- a/tests/zbd/rc +++ b/tests/zbd/rc @@ -75,7 +75,11 @@ export SV_NR_ZONES=4 _get_sysfs_variable() { unset SYSFS_VARS local _dir=${TEST_DEV_SYSFS} - SYSFS_VARS[$SV_CAPACITY]=$(<"${_dir}"/size) + if _test_dev_is_partition; then + SYSFS_VARS[$SV_CAPACITY]=$(<"${TEST_DEV_PART_SYSFS}"/size) + else + SYSFS_VARS[$SV_CAPACITY]=$(<"${_dir}"/size) + fi 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)) @@ -83,7 +87,7 @@ _get_sysfs_variable() { # 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 + if [[ -e "${_dir}"/queue/nr_zones ]] && ! _test_dev_is_partition; then SYSFS_VARS[$SV_NR_ZONES]=$(<"${_dir}"/queue/nr_zones) else SYSFS_VARS[$SV_NR_ZONES]=$(( (SYSFS_VARS[SV_CAPACITY] - 1) \