From patchwork Thu Dec 20 18:18:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dennis Zhou X-Patchwork-Id: 10739275 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 1D27513AD for ; Thu, 20 Dec 2018 18:18:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E28328DA5 for ; Thu, 20 Dec 2018 18:18:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F395B28DE2; Thu, 20 Dec 2018 18:18:32 +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.9 required=2.0 tests=BAYES_00,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 A36E028DA5 for ; Thu, 20 Dec 2018 18:18:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732063AbeLTSSc (ORCPT ); Thu, 20 Dec 2018 13:18:32 -0500 Received: from mail-yw1-f65.google.com ([209.85.161.65]:43261 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730897AbeLTSSc (ORCPT ); Thu, 20 Dec 2018 13:18:32 -0500 Received: by mail-yw1-f65.google.com with SMTP id n21so1046769ywd.10 for ; Thu, 20 Dec 2018 10:18:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DjzoohP8ri7b1Fvpz3Cnv3WgJh5EJUJ6dAteQ8S5u2E=; b=j1z6jHCmy7VnMtaD3x9054tHI3510vU0C41qaePl0Z4sGtXjORr0y0mIBSqcz1g2UE 8OJQy8j2MVy1c+pioNshSZFcteNiuJRGbXy5iglq4orh1CoZ6dFHqnMyvrsq9cQcIkzk LyHjz0YwJuhfRxuGK+6RV3xu1OwDOrF57IkBc8oy/c57lIP+/vkr9mQnYGnb0fNjEWj2 y+HFhS4fhRCdvHyvY/JuNJ0WPhiH58TZG10SUbjjn+k3vauqeG9MeqUVkohHoDO6jEhC VBpctSX1kOvutHfMUR6Oqbq444cb8bFN+BBk2B3H6O6/ehFyNYQR1rTGxM31TOMsE4WX YIMA== X-Gm-Message-State: AA+aEWYjR6clo8GjpXNibUdrNQKzgTlrGKXXZMYum2iCythjGQMijGdp 953KMPAMEB5ZJUY8rGAQa7Q= X-Google-Smtp-Source: AFSGD/W+UTIk4F29XEAzXqhA8I9IzzPlMRxNgv1BPQ1tmR+DKQ7o/aslSIl+z34mzhcyvGU00l2Now== X-Received: by 2002:a81:c44d:: with SMTP id s13mr28473829ywj.411.1545329911278; Thu, 20 Dec 2018 10:18:31 -0800 (PST) Received: from dennisz-mbp.thefacebook.com ([199.201.65.2]) by smtp.gmail.com with ESMTPSA id q185sm7115113ywe.87.2018.12.20.10.18.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Dec 2018 10:18:30 -0800 (PST) From: Dennis Zhou To: Omar Sandoval , Ming Lei Cc: kernel-team@fb.com, linux-block@vger.kernel.org, Dennis Zhou Subject: [PATCH blktests 1/2] blktests: split out cgroup2 controller and file check Date: Thu, 20 Dec 2018 12:18:25 -0600 Message-Id: <20181220181826.55481-2-dennis@kernel.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20181220181826.55481-1-dennis@kernel.org> References: <20181220181826.55481-1-dennis@kernel.org> 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 This is a prep patch for a new test that will race blkg association and request_queue cleanup. As blkg association is a underlying cgroup io controller feature, we need the ability to check if the controller is available. Signed-off-by: Dennis Zhou --- v2: - fixed minor typo. common/cgroup | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/common/cgroup b/common/cgroup index d445093..48e546f 100644 --- a/common/cgroup +++ b/common/cgroup @@ -37,19 +37,27 @@ _have_cgroup2() return 0 } -_have_cgroup2_controller_file() +_have_cgroup2_controller() { - _have_cgroup2 || return 1 - local controller="$1" - local file="$2" - local dir + + _have_cgroup2 || return 1 dir="$(_cgroup2_base_dir)" + if ! grep -q "$controller" "$dir/cgroup.controllers"; then SKIP_REASON="no support for $controller cgroup controller; if it is enabled, you may need to boot with cgroup_no_v1=$controller" return 1 fi +} + +_have_cgroup2_controller_file() +{ + local controller="$1" + local file="$2" + local dir + + _have_cgroup2_controller "$controller" || return 1 mkdir "$dir/blktests" echo "+$controller" > "$dir/cgroup.subtree_control" From patchwork Thu Dec 20 18:18:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dennis Zhou X-Patchwork-Id: 10739277 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 BBDF013AD for ; Thu, 20 Dec 2018 18:18:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC68228DA5 for ; Thu, 20 Dec 2018 18:18:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A037828DE2; Thu, 20 Dec 2018 18:18:35 +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.9 required=2.0 tests=BAYES_00,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 569FA28DA5 for ; Thu, 20 Dec 2018 18:18:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388703AbeLTSSe (ORCPT ); Thu, 20 Dec 2018 13:18:34 -0500 Received: from mail-yw1-f68.google.com ([209.85.161.68]:34470 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730897AbeLTSSe (ORCPT ); Thu, 20 Dec 2018 13:18:34 -0500 Received: by mail-yw1-f68.google.com with SMTP id g75so1058981ywb.1 for ; Thu, 20 Dec 2018 10:18:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EWY3OuL6JZdXdY2O0STsZO7NtlrRHK8oR23qfHiwJTY=; b=rUzGQ4jarBpP6TVtb5dDghXkPLAmqWgNVD56sE5P/CFCRDX2KX4vA+bcSZcwHdq0n8 EPxV3ZGtsvbNmaPAjpw01YIA6Car4sUAFDyqh//exbwgKMgAbKCCG1ljWwPY+jOBLDN/ 7vfdTdc5GG2kbiQbB0FxVvIK9uA16h3x9K2qcfJzM0IOd6fCjgSL5YowtbgJJWIJ8j2Y xFcxyvCN1aqK309nKl6+jKQQeuXZBA+3ucvWT2jqy2t9ihWChYF1Lo72ah8/m0U0FAf7 GINLTYgC0C5RFVHWEamSyH5V1LTTsZE3sAhBT7ew7IPptO0yy/Pfmej1lzNkw/hY809g OL8Q== X-Gm-Message-State: AA+aEWaLJXYMLc12HvqX3LZtkV0R7q+sRY09dFkzBEbv1AulN20iB+tc n2z9SfCE4IDUdY4D31dgqwynhIruiLo= X-Google-Smtp-Source: AFSGD/V55KtKqncpIrCbScVR2+3ypLHquo9yVp3FFndd3J0rJs/VUj2VjYucRoL8JQ0K+RfLkh6NAg== X-Received: by 2002:a0d:ec45:: with SMTP id v66mr26980939ywe.419.1545329912582; Thu, 20 Dec 2018 10:18:32 -0800 (PST) Received: from dennisz-mbp.thefacebook.com ([199.201.65.2]) by smtp.gmail.com with ESMTPSA id q185sm7115113ywe.87.2018.12.20.10.18.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Dec 2018 10:18:31 -0800 (PST) From: Dennis Zhou To: Omar Sandoval , Ming Lei Cc: kernel-team@fb.com, linux-block@vger.kernel.org, Dennis Zhou Subject: [PATCH blktests 2/2] blktests: add Ming Lei's scsi-stress-remove Date: Thu, 20 Dec 2018 12:18:26 -0600 Message-Id: <20181220181826.55481-3-dennis@kernel.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20181220181826.55481-1-dennis@kernel.org> References: <20181220181826.55481-1-dennis@kernel.org> 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 This test exposed a race condiiton when shutting down a request_queue with active IO against it and blkg association for the IOs [1]. The issue ended up being that while the request_queue will just start failing requests, blkg destruction sets the q->root_blkg to %NULL. This caused a NPE. This was fixed in [2]. So to help prevent this from happening again, integrate Ming's test into blktests so that it can more easily be ran. Here I've ported it to fit better into the blktests framework. [1] https://lore.kernel.org/lkml/20181205171039.73066-1-dennis@kernel.org/ [2] https://lore.kernel.org/lkml/20181211230308.66276-1-dennis@kernel.org/ Signed-off-by: Dennis Zhou Cc: Ming Lei --- v2: - Used helpers in common/scsi_debug per Omar's suggestion. tests/block/027 | 73 +++++++++++++++++++++++++++++++++++++++++++++ tests/block/027.out | 2 ++ 2 files changed, 75 insertions(+) create mode 100755 tests/block/027 create mode 100644 tests/block/027.out diff --git a/tests/block/027 b/tests/block/027 new file mode 100755 index 0000000..d5e1463 --- /dev/null +++ b/tests/block/027 @@ -0,0 +1,73 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2018 Ming Lei +# +# Regression test for commit 0273ac349f08 ("blkcg: handle dying request_queue +# when associating a blkg") +# +# This tries to expose the race condition between blkg association and +# request_queue shutdown. When a request_queue is shutdown, the corresponding +# blkgs are destroyed. Any further associations should fail gracefully and not +# cause a kernel panic. + +. tests/block/rc +. common/scsi_debug +. common/cgroup + +DESCRIPTION="test graceful shutdown of scsi_debug devices with running fio jobs" +QUICK=1 + +requires() { + _have_cgroup2_controller io && _have_scsi_debug && _have_fio +} + +scsi_debug_stress_remove() { + if ! _init_scsi_debug "$@"; then + return + fi + + # set higher aio limit + echo 524288 > /proc/sys/fs/aio-max-nr + + local dev fio_jobs scheds + local cnt=1 + for dev in "${SCSI_DEBUG_DEVICES[@]}"; do + # create fio job + fio_jobs=$fio_jobs" --name=job1 --filename=/dev/$dev " + + # set queue scheduler and queue_depth + queue_path=/sys/block/$dev/queue + scheds=($(sed 's/[][]//g' "$queue_path/scheduler")) + sched_idx=$((cnt % ${#scheds[@]})) + echo "${scheds[$sched_idx]}" > "$queue_path/scheduler" + echo $cnt > "$queue_path/../device/queue_depth" + cnt=$((cnt+1)) + done + + local num_jobs=4 runtime=21 + fio --rw=randread --size=128G --direct=1 --ioengine=libaio \ + --iodepth=2048 --numjobs=$num_jobs --bs=4k \ + --group_reporting=1 --group_reporting=1 --runtime=$runtime \ + --loops=10000 "$fio_jobs" > "$FULL" 2>&1 & + + sleep 7 + local device_path + for dev in "${SCSI_DEBUG_DEVICES[@]}"; do + # shutdown devices in progress + device_path=/sys/block/$dev/device + [ -f "$device_path/delete" ] && echo 1 > "$device_path/delete" + done + + wait + + _exit_scsi_debug +} + +test() { + echo "Running ${TEST_NAME}" + + scsi_debug_stress_remove virtual_gb=128 max_luns=21 ndelay=10000 \ + max_queue=110 + + echo "Test complete" +} diff --git a/tests/block/027.out b/tests/block/027.out new file mode 100644 index 0000000..b03498f --- /dev/null +++ b/tests/block/027.out @@ -0,0 +1,2 @@ +Running block/027 +Test complete