Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1913400rwl; Fri, 24 Mar 2023 18:19:22 -0700 (PDT) X-Google-Smtp-Source: AKy350ZnjEPjBQO2PwK/HHxxbenOv8OV6Ifi7mJAm5swRtkGVyqap6pU5sMu84awhCzM2RI2nQDy X-Received: by 2002:a17:90a:185:b0:237:161d:f5ac with SMTP id 5-20020a17090a018500b00237161df5acmr4583875pjc.36.1679707161979; Fri, 24 Mar 2023 18:19:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679707161; cv=none; d=google.com; s=arc-20160816; b=fX+kkp3O6qMdwUm6GyA/QvRo10V+HJEAKvMgvjddR3b9o1MTkdeLplGqvsPGiwO6SU 9HR7ZqeooxNsA0ZspudAIT94nmWymaT1nqIL7GYDSDTwG2QCGRc6oOxqrGQwCbLrnY8t B/ZizgFiDGK2zPYwMLTcC5ReFkxPIkwjtPh1PPlmydifqx4TLRt7fIUJc5LtqEiSr5Rq zn0XXeyqePPkjaBTyczO15nF3LjsKZ/xQfTsO6Qb2B4IeIxQbQGykYupn8UJkTYzm0K9 EVFYHLJCHWKUc/qox9VBtnDR5X37arCmtc22gkRBgde0/CHqCzBSwc77qKuOwgU47qEt EgaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=m+YK0TkKG5igifNQPgrzatLosHOh2aGtA/QuowwtVgA=; b=nYO59Gf+TMSKDp532hoqpFRT29KeCv5OZy8OvoQb2cFI8tWobuZ8pOk7SMiBx+0WVW LHz6kmBBpkQa0OyQdpdw483njmbpkyxGrltYPV1oihWFCSoeDJMv4AFo31KW/iuhE7bA W3I8NjXF280U4cBSWJIXRvA+FnOorBrAB2lL6hTFor+3Vz3j1oEltFOygaoyM8Y7gTSr Cqb4oVCzCRpJGlk2qMSZ+T0JytFPJC6NnCCR0PZSEd/Ejzp6yKBIk1Y/2/cmIlbXOCc/ GUAl0THcKsZd4tSbsffQQ7deoZHXg3am4LWAqJCcKsJLjHBskT+RGdYl/VJaytlwoZBq lw3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g20-20020a170902e39400b0019cec50618csi20519521ple.159.2023.03.24.18.19.10; Fri, 24 Mar 2023 18:19:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232105AbjCYBTA (ORCPT + 99 others); Fri, 24 Mar 2023 21:19:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231950AbjCYBSl (ORCPT ); Fri, 24 Mar 2023 21:18:41 -0400 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A93321A95D; Fri, 24 Mar 2023 18:18:39 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.169]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Pk1Rt6wlZz4f3lXK; Sat, 25 Mar 2023 09:18:34 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP3 (Coremail) with SMTP id _Ch0CgCnUiDpSx5kmy0NFg--.49234S8; Sat, 25 Mar 2023 09:18:36 +0800 (CST) From: Ye Bin To: jejb@linux.ibm.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ye Bin Subject: [PATCH 4/5] scsi: blocking IO when host is blocked Date: Sat, 25 Mar 2023 09:17:33 +0800 Message-Id: <20230325011734.507453-5-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230325011734.507453-1-yebin@huaweicloud.com> References: <20230325011734.507453-1-yebin@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: _Ch0CgCnUiDpSx5kmy0NFg--.49234S8 X-Coremail-Antispam: 1UD129KBjvJXoW7urWrXr48tr4kCr13Cw4Uurg_yoW8Gr48pF Z0qa42kr48GFW09a98WF15XrySgayDGryUJa4fWwn8JF98t34jqan8GFyUXFy8GF4Fkrsr XFsrtFyYkF1UXr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvEb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUAV Cq3wA2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0 rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267 AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E 14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7 xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Y z7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7 v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF 1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIx AIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI 42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWI evJa73UjIFyTuYvjxU2CJmUUUUU X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ye Bin Unlike recovery state may block other process, blocking IO only when host is blocked. Signed-off-by: Ye Bin --- drivers/scsi/scsi_lib.c | 4 ++++ include/scsi/scsi_host.h | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index b7c569a42aa4..492487717f41 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1731,6 +1731,10 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx, ret = BLK_STS_OFFLINE; goto out_dec_target_busy; } + + if (unlikely(scsi_host_blocked(shost))) + goto out_dec_target_busy; + if (!scsi_host_queue_ready(q, shost, sdev, cmd)) goto out_dec_target_busy; diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 9e99317b11fa..571321bbb706 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -745,6 +745,11 @@ static inline int scsi_host_in_recovery(struct Scsi_Host *shost) shost->tmf_in_progress; } +static inline int scsi_host_blocked(struct Scsi_Host *shost) +{ + return shost->shost_state == SHOST_BLOCKED; +} + extern int scsi_queue_work(struct Scsi_Host *, struct work_struct *); extern void scsi_flush_work(struct Scsi_Host *); -- 2.31.1