From patchwork Thu Mar 23 09:45:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13185377 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8045C6FD1C for ; Thu, 23 Mar 2023 09:46:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230499AbjCWJq4 (ORCPT ); Thu, 23 Mar 2023 05:46:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229990AbjCWJqq (ORCPT ); Thu, 23 Mar 2023 05:46:46 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39B142472C; Thu, 23 Mar 2023 02:46:46 -0700 (PDT) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32N5hvKp010849; Thu, 23 Mar 2023 09:46:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=ugvdMQOQLiTnuCTeYWIm73lmLo4cygfDQ9cF0NAB9Sk=; b=KzBWyWKavel+5JNTmkkahULrlgp/mK0yuwPtfYpPJYRbpScsMnFz2tyn0c94tPI3MRlJ 3eLpKmsbkFViEb7o1HkyINkJhwCZn2+txGUa/S2n0BdLnUqb6Kie953toPMlaa/F7nck JSteXiDz7JrIjuEDVA5zIM/Vd+pBxTv9gxQEenbE/ApEyPFGIcPUaiZ5pVAukA+GLPlZ MrOeUojVaxkGmWGZsSk1EOSVaN8liSAU9g3Nu8PzcAEzoOyL59UtGHY089suWYwXClUX loz1u4KRl1xMk1zEjDPV6flVSWM8qSQw1boslIEjFbFRCrYoUyE6nDSYmyMk2I4lJ42k 1g== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3pd433u9ht-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Mar 2023 09:46:42 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 32N9cdiG006987; Thu, 23 Mar 2023 09:46:41 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2042.outbound.protection.outlook.com [104.47.66.42]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3pgmamg7ry-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 23 Mar 2023 09:46:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V5yVcB0xwbTcsuVK7nhXPq1e7iJOArWGuUmYqOysYEE2RxdLNDAGoz6CYn+KEIqhrlLmpi/tSrEBsk632vsuiOQY3Hcvb6T+yFX9NWpkoxeOzQUpYPNBASk3DtUQ+sLyE9VKZDQj9bHdL/FkVj2H2ixLzkABPQzt6JdXBxCokgopV9NuN5OrVBjZMGDPKYvCHnCrmV+kJkLnYJoFRe+Pumcp94yuL7vrzsJ80PLIM2Gr5akOYytP06b68E7H8A552hluxcuj+TuUAh9yz7L803Ni+JV9Lq6+OMw4S/x+DRtVSw3Ovfv0c98UomrHD7Tte8u5m2bCAZJ0zNuZRy0ZHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ugvdMQOQLiTnuCTeYWIm73lmLo4cygfDQ9cF0NAB9Sk=; b=FU9Q38aIbNx8otxTpCQRXQ2HTjk+1FzTof0wKHIGz8bXJG2tlYIh2xfkYlOOl0dYWu31DJl1aIKcDGxmIgcWSICbmR+HaOx1DUtGAQTBe0bd80W2YIWAg5VwzIT7yd5pqGakIK9X6aQQyFgF9BxuLEcbQIzormNMKHIDygqOfMzIvALBR+OOl8CrWzCht+M8PS3a5sPl7YE7m2Rkzkgcgp/VUx2DXBLxL9ucIiqus8LQ0eUPrkgTOFZEkBVRrhSUg7CGoiJ2tnEWUnDgER0scDtUx8CU0deusMpIELGBGcj5vsiLafn0mjEK4FZLqZnrlny9EuikZwagHd6gHc8diQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ugvdMQOQLiTnuCTeYWIm73lmLo4cygfDQ9cF0NAB9Sk=; b=PkF1tSek4PuE1A7XlTYzJN8TWHdUoqLjGHU0734bBp6Sd8ogGeXHjN5rbZYhvhpOiLAxikB022Qiy0SbkNa5awdgBxaL7FGSKtj6IXwHC1M3c8P7X+HZ304Z/ep5zQKbKW1g3iumL5N0QlGMxOmyWuG8pxO4A45JNSR3ll2BEww= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH0PR10MB5273.namprd10.prod.outlook.com (2603:10b6:610:db::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.38; Thu, 23 Mar 2023 09:46:36 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::7276:bc4c:17a0:7267]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::7276:bc4c:17a0:7267%5]) with mapi id 15.20.6178.038; Thu, 23 Mar 2023 09:46:36 +0000 From: John Garry To: jejb@linux.ibm.com, martin.petersen@oracle.com, dgilbert@interlog.com Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, bvanassche@acm.org, John Garry Subject: [PATCH v2 08/11] scsi: scsi_debug: Use blk_mq_tagset_busy_iter() in stop_all_queued() Date: Thu, 23 Mar 2023 09:45:52 +0000 Message-Id: <20230323094555.584624-9-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230323094555.584624-1-john.g.garry@oracle.com> References: <20230323094555.584624-1-john.g.garry@oracle.com> X-ClientProxiedBy: DM6PR06CA0012.namprd06.prod.outlook.com (2603:10b6:5:120::25) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CH0PR10MB5273:EE_ X-MS-Office365-Filtering-Correlation-Id: 18544636-0b46-4338-1e40-08db2b837e26 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mxSkf8gVT87ZhdEoE1Xzod4ggwlftgN075EppOBnhcOTgk5yFDQKIo7ZyplV5zkNsAT0EO3W8rcECMTNWOTG5ftBjzoQnxBdwWGK1KrghaIgREmZDpEiRw2C9avH5DffWrYV503YT7dMUMusbfynS5/Fva2HHMYpVez+YKMaKvIRIGRQL8D8TI/jBF5ithvBxNp1n2ySlevP/sdBl2lLhSWYpH/LiHOGHrRfvQ2opKI2v2ZmzSY7CJCDUDAGmfKgweIzcY7WmMEEbi0lAQk87At4X488NCYUeJO5nhd5Kcb6UbURk6KJaHy5QuiIHuTkFMAJGkIi3oAk8DTeegACDlF8G6tNhnQgk3etCwW7OESewDZydtFWqjDnH57BJQDjDq5j436ibcdAmDLbWmHiVe26xOdAOhX5MTKr+BciJiuQlBHTEUlh22ntUmzYoavjojNfkv8VmUOYU1DwAe9TI9u44IDjkCLeZfK1BnFK9WCjC+y3P3/t9PlXLYMh+sR5PpQ9oKojStZ0xjzfn86xLpiuR9mvNAQXUpgzawHxPZ+krW5fosyTH+5tsakTHivfp+om3yRJYib3jH6WzTrOcHnfz6K9OaVzuFmvlHmwql6CgUEfVwlBhdIPxLlSbA/YDpXBVS1IuqhE5zuTxV0rBQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(136003)(366004)(346002)(39860400002)(376002)(451199018)(6486002)(316002)(5660300002)(2616005)(8936002)(83380400001)(26005)(103116003)(41300700001)(478600001)(86362001)(38100700002)(2906002)(36756003)(4326008)(6506007)(66476007)(186003)(66556008)(6666004)(107886003)(66946007)(1076003)(6512007)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: c6rTrpOCNUu/7Ojdl/D+2kWk0SId6EmU8QStv781p56JuhrXo9+PUAkOhGvmWE6MA57VFekQp0f7EdDu6hbXZdLsGwSAyiKnW0kSlqBrSr0dNrgXhokqy06kcszO8gnVBsccj+/r0dEzKvcHyzskulT6UDhMtCuzAblwL8+dctj/n7L06RSY5OlOxIIh/0pSTs+1oQ0SgQJOYT8V8qXjgwssdbg13AVOxKIiC1XbFfl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DbYqVTpbOCwQ2CPbJTdqAEfwaLujSkJSXt1v8Ux7qGMBSOIq9pI6hPE9P81eqCHXdun+TTzsVno/HUSwGMAwVhKc97q0i4ECTgrbBQP9NLB7DQF5OeVIcsspG6G7AI5ZoheeypxVMXEs09SyW8Lzi1B5RvYnlWmzqS/cF5Kn8AHKc2lfokgU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 18544636-0b46-4338-1e40-08db2b837e26 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2023 09:46:36.1288 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: P8oq5wko6nUjGsWD/ppKmIyMtpP1566hu45ysR/B7ILGIYDp6VT7y5C49cV8kSrSJ0GAZkcsPmwYIxFol91GEA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5273 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-22_21,2023-03-22_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 phishscore=0 bulkscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303150002 definitions=main-2303230073 X-Proofpoint-ORIG-GUID: weJh2WUcXe0kzmckx5UR0YjuHPw4yFvQ X-Proofpoint-GUID: weJh2WUcXe0kzmckx5UR0YjuHPw4yFvQ Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Instead of iterating all deferred commands in the submission queue structures, use blk_mq_tagset_busy_iter(), which is a standard API for this. Signed-off-by: John Garry --- drivers/scsi/scsi_debug.c | 45 +++++++++++++++------------------------ 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 627bc98c18ae..3e2e7f24d90d 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -5326,40 +5326,29 @@ static bool scsi_debug_abort_cmnd(struct scsi_cmnd *cmnd) return res; } +/* + * All we can do is set the cmnd as internally aborted and wait for it to + * finish. We cannot call scsi_done() as normal completion path may do that. + */ +static bool sdebug_stop_cmnd(struct request *rq, void *data) +{ + scsi_debug_abort_cmnd(blk_mq_rq_to_pdu(rq)); + + return true; +} + /* Deletes (stops) timers or work queues of all queued commands */ static void stop_all_queued(void) { - unsigned long iflags, flags; - int j, k; - struct sdebug_queue *sqp; + struct sdebug_host_info *sdhp; - for (j = 0, sqp = sdebug_q_arr; j < submit_queues; ++j, ++sqp) { - spin_lock_irqsave(&sqp->qc_lock, iflags); - for (k = 0; k < SDEBUG_CANQUEUE; ++k) { - if (test_bit(k, sqp->in_use_bm)) { - struct sdebug_queued_cmd *sqcp = sqp->qc_arr[k]; - struct sdebug_scsi_cmd *sdsc; - struct scsi_cmnd *scmd; + mutex_lock(&sdebug_host_list_mutex); + list_for_each_entry(sdhp, &sdebug_host_list, host_list) { + struct Scsi_Host *shost = sdhp->shost; - if (!sqcp) - continue; - scmd = sqcp->scmd; - if (!scmd) - continue; - sdsc = scsi_cmd_priv(scmd); - spin_lock_irqsave(&sdsc->lock, flags); - if (TO_QEUEUED_CMD(scmd) != sqcp) { - spin_unlock_irqrestore(&sdsc->lock, flags); - continue; - } - scsi_debug_stop_cmnd(scmd, NULL); - spin_unlock_irqrestore(&sdsc->lock, flags); - sqp->qc_arr[k] = NULL; - clear_bit(k, sqp->in_use_bm); - } - } - spin_unlock_irqrestore(&sqp->qc_lock, iflags); + blk_mq_tagset_busy_iter(&shost->tag_set, sdebug_stop_cmnd, NULL); } + mutex_unlock(&sdebug_host_list_mutex); } static int scsi_debug_abort(struct scsi_cmnd *SCpnt)