From patchwork Thu Oct 22 12:34:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muneendra Kumar M X-Patchwork-Id: 11851853 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8977892C for ; Thu, 22 Oct 2020 19:28:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 473C02466D for ; Thu, 22 Oct 2020 19:28:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="NbDiTG86" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2895887AbgJVT2Y (ORCPT ); Thu, 22 Oct 2020 15:28:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2508349AbgJVT2X (ORCPT ); Thu, 22 Oct 2020 15:28:23 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DCE1C0613CE for ; Thu, 22 Oct 2020 12:28:23 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id e10so1815311pfj.1 for ; Thu, 22 Oct 2020 12:28:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WPjHEdnxhvpJLKnX52AO9fh8LWhqZ0MvewT18vMQDic=; b=NbDiTG86eCwnO8aZbR+4i9Ie+Y8JNDmorvtEI2bbrZkjpkyN4fT5o4g+rWH66w8svC cNJcV5yA9pPGs/BOX4IciHP3oBmNz91ThAPdsOrRtpYwdPPCCCNn2Io+Nl4MtX/1dcO/ 5PzDx5xvbYwH19PZWr8m89refnplKGMQTGU2I= 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=WPjHEdnxhvpJLKnX52AO9fh8LWhqZ0MvewT18vMQDic=; b=kcEw8VCCy6oahvyaVuLyqmkgpVEY4TS0R30TEOv5HhUN4YirajQgsawaxOh6E1/EF1 Pcvra4D4hQIE5/WARHaZUNLslEEZOx4qWn+vVVt4EGIuDFRxCitCrq9HV3ZTfQgSGmDp JInPkejOIn+zjPYPrCntgGuLK6hb79KhOvRMoyMF5Awtdnlqq+MKwJgBcCaCx8bUwCuo nPqlNcxC5/shjy6+dt0OhLsVR51gS/TOVKu2dBo+59s3BSooFzxJe/KKQmGKBAv6asrg elq5G4DNohelegyRJjpfm2IRDWtkYGL0OsOd6ecXATW0Z1WpW7D3XJfNzJdMosMW12Rd pmPg== X-Gm-Message-State: AOAM533RZYk+H9lnb7azKcOaO7mvGBeYFjBGrCfzn1BhkFuStmMBfusk NrsTx9TRk7494bRvCsxNAQ9hXsvZT06yeVw6n2lo07Uh0rN6CBnePF7n/he4xj6v8BxhVj4In/V 2SrEPlB6ziQJy52EBPMqJ8+Dl+1bEQCWODqbHbGaghvcVEnjQv9202Ocl1nanSHSDULSIF5xUWo cQfZ7197BaJWQ= X-Google-Smtp-Source: ABdhPJzfnch0q8dPa5/CUaNBtsESWkq8jzRLy11dRKC92H7T8IqHYx1AM060AVFgYOCSWmebBRBckA== X-Received: by 2002:a17:90a:1b6e:: with SMTP id q101mr3547396pjq.79.1603394902689; Thu, 22 Oct 2020 12:28:22 -0700 (PDT) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id s10sm2846759pji.7.2020.10.22.12.28.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Oct 2020 12:28:22 -0700 (PDT) From: Muneendra To: linux-scsi@vger.kernel.org, michael.christie@oracle.com, hare@suse.de Cc: jsmart2021@gmail.com, emilne@redhat.com, mkumar@redhat.com, Muneendra Subject: [patch v4 1/5] scsi: Added a new definition in scsi_cmnd.h Date: Thu, 22 Oct 2020 18:04:47 +0530 Message-Id: <1603370091-9337-2-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1603370091-9337-1-git-send-email-muneendra.kumar@broadcom.com> References: <1603370091-9337-1-git-send-email-muneendra.kumar@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Added a new definition SCMD_NORETRIES_ABORT in scsi_cmnd.h The SCMD_NORETRIES_ABORT defines the third bit postion in scmd->state Signed-off-by: Muneendra --- v4: No Change v3: No change v2: Modified the commit log --- include/scsi/scsi_cmnd.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index 69ade4fb71aa..8dec4ec6bd5f 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -64,6 +64,9 @@ struct scsi_pointer { /* for scmd->state */ #define SCMD_STATE_COMPLETE 0 #define SCMD_STATE_INFLIGHT 1 +#define SCMD_NORETRIES_ABORT 2 /* If this bit is set then there won't be any + * retries of scmd on abort success + */ struct scsi_cmnd { struct scsi_request req; From patchwork Thu Oct 22 12:34:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muneendra Kumar M X-Patchwork-Id: 11851855 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 26AAB14B2 for ; Thu, 22 Oct 2020 19:28:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F2FEE2466D for ; Thu, 22 Oct 2020 19:28:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="JAWR8rcV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S370064AbgJVT20 (ORCPT ); Thu, 22 Oct 2020 15:28:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2508349AbgJVT20 (ORCPT ); Thu, 22 Oct 2020 15:28:26 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56ECDC0613CE for ; Thu, 22 Oct 2020 12:28:26 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id r10so1547530pgb.10 for ; Thu, 22 Oct 2020 12:28:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4DhPbRIuMnpkQuYR/Y1ctrU5a4R5h1aMaCkzf8cF8UA=; b=JAWR8rcVH4VRQV764m33XPIuiEQmi4aSLJGiwvVFukXHE1z2jKux4KZaar86Rdm67f 6MOflLQpGaZO1GqlPyOokOxDB753qbzvdJrdGPca7KDmSg0HNWGDORiInswjKe8XbTiU XI9rk24iaCoxRUY0/5peCNYSGBN9CaXnZx81Y= 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=4DhPbRIuMnpkQuYR/Y1ctrU5a4R5h1aMaCkzf8cF8UA=; b=gb0ykw/xZLSkleTxn8hjq4+FG5JXBHOw3RsxuHPRw3zetG6LTo4X7sVXexCYLkM1Ca 69Vj6dpzX454VUz1kj0UCSaVRCSD1xqvi734thiaSNZEWbB6Rq4XLapjBbXrshX9n4q/ hj46xhiFEt12C59uk2SzFYOO2ZMGnp02Xeq1BAWbgnwssd0Y2nkrfBWXBGdMIZdAQW4z PA0BXOZSlhB5YEDA0+wm9d0noaMRMNrQxeI7+Nu+02oGVQUc0i0LIfEHMIobUeNsNA36 iPjJv/Jqj9rVMBd9YrBIghtxOiFhNQnfKv13SrhHdtSJp0a0u1zdfyNrhfiA5PUcqnYA uDvw== X-Gm-Message-State: AOAM533OVB35LVOYTiz9Am3V6cPC+OK7KiFMPNcUM08ENoPsZTea0h1B 65+cNzu6FqK3kKqzEiJO0Q2hz95EcgPL2Op7GyDbDH7Y8dao12DHYhephD3S9arqXpD5MiDqdu6 +sbNptBDAn3iPF6MAsmKKN5AroaFB7dbMqwg2VtTqjXVQA2w62ZP7yOCR+O1g82RbNkujXlknTG Hrcy3sejXSwq0= X-Google-Smtp-Source: ABdhPJypv7q1BK9Ap1e/Go0WFudduccnh1biBLntgpbh9Yd7UIHkmyYW3oeopQ5EoHa3WWJ5lBFBww== X-Received: by 2002:a17:90b:1085:: with SMTP id gj5mr3721706pjb.30.1603394905486; Thu, 22 Oct 2020 12:28:25 -0700 (PDT) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id s10sm2846759pji.7.2020.10.22.12.28.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Oct 2020 12:28:24 -0700 (PDT) From: Muneendra To: linux-scsi@vger.kernel.org, michael.christie@oracle.com, hare@suse.de Cc: jsmart2021@gmail.com, emilne@redhat.com, mkumar@redhat.com, Muneendra Subject: [patch v4 2/5] scsi: Added a new error code in scsi.h Date: Thu, 22 Oct 2020 18:04:48 +0530 Message-Id: <1603370091-9337-3-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1603370091-9337-1-git-send-email-muneendra.kumar@broadcom.com> References: <1603370091-9337-1-git-send-email-muneendra.kumar@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Added a new error code DID_TRANSPORT_MARGINAL to handle marginal errors in scsi.h Clearing the SCMD_NORETRIES_ABORT bit in state flag before blk_mq_start_request Signed-off-by: Muneendra --- v4: No change v3: Rearranged the patch by merging second hunk of the previous(v2) patch3 to this patch v2: Newpatch --- drivers/scsi/scsi_lib.c | 1 + include/scsi/scsi.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 1a2e9bab42ef..2b5dea07498e 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1660,6 +1660,7 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx, req->rq_flags |= RQF_DONTPREP; } else { clear_bit(SCMD_STATE_COMPLETE, &cmd->state); + clear_bit(SCMD_NORETRIES_ABORT, &cmd->state); } cmd->flags &= SCMD_PRESERVED_FLAGS; diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h index 5339baadc082..5b287ad8b727 100644 --- a/include/scsi/scsi.h +++ b/include/scsi/scsi.h @@ -159,6 +159,7 @@ static inline int scsi_is_wlun(u64 lun) * paths might yield different results */ #define DID_ALLOC_FAILURE 0x12 /* Space allocation on the device failed */ #define DID_MEDIUM_ERROR 0x13 /* Medium error */ +#define DID_TRANSPORT_MARGINAL 0x14 /* Transport marginal errors */ #define DRIVER_OK 0x00 /* Driver status */ /* From patchwork Thu Oct 22 12:34:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muneendra Kumar M X-Patchwork-Id: 11851857 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 03A4914B2 for ; Thu, 22 Oct 2020 19:28:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CD42E2466D for ; Thu, 22 Oct 2020 19:28:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Ao+N+zTM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S370203AbgJVT23 (ORCPT ); Thu, 22 Oct 2020 15:28:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2508349AbgJVT23 (ORCPT ); Thu, 22 Oct 2020 15:28:29 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CF9DC0613CE for ; Thu, 22 Oct 2020 12:28:29 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id t4so1476423plq.13 for ; Thu, 22 Oct 2020 12:28:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3zq35Fg2X25UHROfLAAKqHg+C070OElbqopYZARNkMc=; b=Ao+N+zTMfSTBmw79QvQjDipObSomlDpb33GG9ZHX6tvs8O/TeYehnx45t2dgXPxVNb IOdEFe283IZVUYBIo/nU9aVjRtV1fnp+KsiRIIKe2dvtGWcc06XwH3dmwT0IFpHdjX1D A5HCGXLTlRrfS97YZD9UC+jif+E4lB5Am8wNo= 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=3zq35Fg2X25UHROfLAAKqHg+C070OElbqopYZARNkMc=; b=DpC3eI7pFqzJJy2uAsN1TH8XXTYHSEb5re4JaCoUZU9ZyfCQdwSdCtNY3B6Qp65pp4 u/18YDN3XH+BEZna3+XhWcLwcF521PdqTAUHUfp5e3y85kzG6ojb6wTQuIx29GhJzhid PjYx/zBBdrcCTgdw4eO/Z5kszo29UEFt2TOSIWm/NxAvliPl5N0jhvMkqylaiAJ6l6nR 4Qu6958tDFmqiQSTxX3bMzi7OStZQTrfF+gnhFlQtkJTGVrxD3XFsfa0oYp0qrJDEOTd LjAOpAB2FMjnd9gMcXvmBh8QQnibIloRyeVDklkxmcO9uWeJ4Ndk+h+WD1KQ1CNf4Wg/ aDAw== X-Gm-Message-State: AOAM533Dfe2Q0A2ll10BGg/kJ+cwVUKJw8TEO2T6k2M5PukV8RbdKm6q B7ZLPHX5Iy6aDXHZ1dz5EZbLFcgPc3bObodx7+PTz29Di5dMKMHM5UrYGOQBouJwTw+QfDoObVr 0Btl6DgF+2FAenQWQfRrlMCw46jbkDcJT86zzGeYnugcCNRxj3AyOVwlZzFcsdNATMkgYCRvnQ8 g7U0/Osjy9ugg= X-Google-Smtp-Source: ABdhPJw7+L1dMA1EBD8PazsggJaz43CgpsswULuta6QdEltoFNHjYEue14W9OleN8FWUI5HVPHY0xA== X-Received: by 2002:a17:902:369:b029:d6:1d46:21dc with SMTP id 96-20020a1709020369b02900d61d4621dcmr941853pld.56.1603394908164; Thu, 22 Oct 2020 12:28:28 -0700 (PDT) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id s10sm2846759pji.7.2020.10.22.12.28.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Oct 2020 12:28:27 -0700 (PDT) From: Muneendra To: linux-scsi@vger.kernel.org, michael.christie@oracle.com, hare@suse.de Cc: jsmart2021@gmail.com, emilne@redhat.com, mkumar@redhat.com, Muneendra Subject: [patch v4 3/5] scsi: No retries on abort success Date: Thu, 22 Oct 2020 18:04:49 +0530 Message-Id: <1603370091-9337-4-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1603370091-9337-1-git-send-email-muneendra.kumar@broadcom.com> References: <1603370091-9337-1-git-send-email-muneendra.kumar@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Made an additional check in scsi_noretry_cmd to verify whether user has decided not to do retries on abort success by setting the SCMD_NORETRIES_ABORT bit If SCMD_NORETRIES_ABORT bit is set we are making sure there won't be any retries done on the same path and also setting the host byte as DID_TRANSPORT_MARGINAL so that the error can be propogated as recoverable transport error to the blk layers. Added a code in scsi_result_to_blk_status to translate a new error DID_TRANSPORT_MARGINAL to the corresponding blk_status_t i.e BLK_STS_TRANSPORT Signed-off-by: Muneendra --- v4: Modified the comments in the code appropriately v3: Merged first part of the previous patch(v2 patch3) with this patch. v2: set the hostbyte as DID_TRANSPORT_MARGINAL instead of DID_TRANSPORT_FAILFAST. --- drivers/scsi/scsi_error.c | 10 ++++++++++ drivers/scsi/scsi_lib.c | 1 + 2 files changed, 11 insertions(+) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index ae80daa5d831..5c016270bda2 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -1763,6 +1763,16 @@ int scsi_noretry_cmd(struct scsi_cmnd *scmd) return 0; check_type: + /* + * Check whether caller has decided not to do retries on + * abort success by checking the SCMD_NORETRIES_ABORT bit + */ + if ((test_bit(SCMD_NORETRIES_ABORT, &scmd->state)) && + (scmd->request->cmd_flags & REQ_FAILFAST_TRANSPORT)) { + set_host_byte(scmd, DID_TRANSPORT_MARGINAL); + return 1; + } + /* * assume caller has checked sense and determined * the check condition was retryable. diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 2b5dea07498e..9606bad1542f 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -629,6 +629,7 @@ static blk_status_t scsi_result_to_blk_status(struct scsi_cmnd *cmd, int result) return BLK_STS_OK; return BLK_STS_IOERR; case DID_TRANSPORT_FAILFAST: + case DID_TRANSPORT_MARGINAL: return BLK_STS_TRANSPORT; case DID_TARGET_FAILURE: set_host_byte(cmd, DID_OK); From patchwork Thu Oct 22 12:34:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muneendra Kumar M X-Patchwork-Id: 11851859 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CD2E592C for ; Thu, 22 Oct 2020 19:28:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9AB3D2465E for ; Thu, 22 Oct 2020 19:28:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="QtgRpjLq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S370226AbgJVT2c (ORCPT ); Thu, 22 Oct 2020 15:28:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2508349AbgJVT2c (ORCPT ); Thu, 22 Oct 2020 15:28:32 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E00D3C0613CE for ; Thu, 22 Oct 2020 12:28:31 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id e10so1815575pfj.1 for ; Thu, 22 Oct 2020 12:28:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0OSsIa87ZqpEJWxUE5TTVaDzYe5VSY+iPSNHGI/uGdU=; b=QtgRpjLqEGcMLOmJBwBqnLTpBEGGC8lk6AjTxXaYEDMczVo52ZRSdyd80EOeOXBRLh ush1Kn+mx+4gRN4OisIMWeNyvHcPKx2ZNK+60mp/JzD74ctH19LuSGrfylki0H6KkhFk fR4aSkrcZshN3Js8JJdUur5bsGRe4QxFYKjIk= 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=0OSsIa87ZqpEJWxUE5TTVaDzYe5VSY+iPSNHGI/uGdU=; b=tFZmTdwxSnQvrYXCAvqO87Bx24CywMp4BASyNTpzO+Z0dBG1rXoRXBhAboLTwNcxt2 3hjBE0y2w9Vk3K+4fwv14xbR0ejYBYhjeU6/mCXfzF7ULjSAAd1BkuSoaqV2B6Ey1Ft1 SE8K+pfzaNkJnLiJQtRzr0GeYyK936OkeBIdDM4IQlMKEobqWFO64nQnY7MNgEAwM0N9 G/1fryw78GZtAPSyOvjkFN6LFklL+zIJFisfc7HpaQV+vE4n5SLo8gjUo6gfyTfQ9F+H vWFPgp3INKiiEFwRp7uGg0yf0e+zvrDBwuq1JDEu1xjhoD1tCqd8wniSkLQfw5UHdYjk pDrA== X-Gm-Message-State: AOAM5325DXgoxefsUcY7BFs8lpqRiSL2OB8u6V4JEtQs+fKYwatfIXWA LXbtIMNeIdZX2awFccAu3+j5B6VPFb6V78EMdM0MUiFgF15HucMW0WWed+q9xLH5rCpF2p6jhJM n5CICP3owppDZeUNBSMPtxAWfO/t6Jh5qGgp74Ssiqypjpql9qyD/X+qwhdKImib7a/Pb50s49n IB9G08+OH4hvA= X-Google-Smtp-Source: ABdhPJx8FSq5G/66NrLt2TZ0dmQ2Oje0F6qA9d7na+4R9JY27X9iIkWQjCHtXWGyWyp8+s+PrJZ9cg== X-Received: by 2002:a05:6a00:814:b029:15c:d506:27b9 with SMTP id m20-20020a056a000814b029015cd50627b9mr3841463pfk.81.1603394910919; Thu, 22 Oct 2020 12:28:30 -0700 (PDT) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id s10sm2846759pji.7.2020.10.22.12.28.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Oct 2020 12:28:30 -0700 (PDT) From: Muneendra To: linux-scsi@vger.kernel.org, michael.christie@oracle.com, hare@suse.de Cc: jsmart2021@gmail.com, emilne@redhat.com, mkumar@redhat.com, Muneendra Subject: [patch v4 4/5] scsi_transport_fc: Added a new rport state FC_PORTSTATE_MARGINAL Date: Thu, 22 Oct 2020 18:04:50 +0530 Message-Id: <1603370091-9337-5-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1603370091-9337-1-git-send-email-muneendra.kumar@broadcom.com> References: <1603370091-9337-1-git-send-email-muneendra.kumar@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Added a new rport state FC_PORTSTATE_MARGINAL. Added a new inline function fc_rport_chkmarginal_set_noretries which will set the SCMD_NORETRIES_ABORT bit in cmd->state if rport state is marginal. Made changes in fc_eh_timed_out to call fc_rport_chkmarginal_set_noretries Also made changes in fc_remote_port_delete,fc_user_scan_tgt, fc_timeout_deleted_rport functions to handle the new rport state FC_PORTSTATE_MARGINAL. Signed-off-by: Muneendra --- v4: Made changes in fc_eh_timed_out to call fc_rport_chkmarginal_set_noretries so that SCMD_NORETRIES_ABORT bit in cmd->state is set if rport state is marginal. Removed the newly added scsi_cmd argument to fc_remote_port_chkready as the current patch handles only SCSI EH timeout/abort case. v3: Rearranged the patch so that all the changes with respect to new rport state is part of this patch. Added a new argument to scsi_cmd to fc_remote_port_chkready v2: New patch --- drivers/scsi/scsi_transport_fc.c | 41 +++++++++++++++++++------------- include/scsi/scsi_transport_fc.h | 19 +++++++++++++++ 2 files changed, 44 insertions(+), 16 deletions(-) diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c index 2ff7f06203da..fcb38068e2a4 100644 --- a/drivers/scsi/scsi_transport_fc.c +++ b/drivers/scsi/scsi_transport_fc.c @@ -142,20 +142,23 @@ fc_enum_name_search(host_event_code, fc_host_event_code, static struct { enum fc_port_state value; char *name; + int matchlen; } fc_port_state_names[] = { - { FC_PORTSTATE_UNKNOWN, "Unknown" }, - { FC_PORTSTATE_NOTPRESENT, "Not Present" }, - { FC_PORTSTATE_ONLINE, "Online" }, - { FC_PORTSTATE_OFFLINE, "Offline" }, - { FC_PORTSTATE_BLOCKED, "Blocked" }, - { FC_PORTSTATE_BYPASSED, "Bypassed" }, - { FC_PORTSTATE_DIAGNOSTICS, "Diagnostics" }, - { FC_PORTSTATE_LINKDOWN, "Linkdown" }, - { FC_PORTSTATE_ERROR, "Error" }, - { FC_PORTSTATE_LOOPBACK, "Loopback" }, - { FC_PORTSTATE_DELETED, "Deleted" }, + { FC_PORTSTATE_UNKNOWN, "Unknown", 7}, + { FC_PORTSTATE_NOTPRESENT, "Not Present", 11 }, + { FC_PORTSTATE_ONLINE, "Online", 6 }, + { FC_PORTSTATE_OFFLINE, "Offline", 7 }, + { FC_PORTSTATE_BLOCKED, "Blocked", 7 }, + { FC_PORTSTATE_BYPASSED, "Bypassed", 8 }, + { FC_PORTSTATE_DIAGNOSTICS, "Diagnostics", 11 }, + { FC_PORTSTATE_LINKDOWN, "Linkdown", 8 }, + { FC_PORTSTATE_ERROR, "Error", 5 }, + { FC_PORTSTATE_LOOPBACK, "Loopback", 8 }, + { FC_PORTSTATE_DELETED, "Deleted", 7 }, + { FC_PORTSTATE_MARGINAL, "Marginal", 8 }, }; fc_enum_name_search(port_state, fc_port_state, fc_port_state_names) +fc_enum_name_match(port_state, fc_port_state, fc_port_state_names) #define FC_PORTSTATE_MAX_NAMELEN 20 @@ -2071,6 +2074,7 @@ fc_eh_timed_out(struct scsi_cmnd *scmd) { struct fc_rport *rport = starget_to_rport(scsi_target(scmd->device)); + fc_rport_chkmarginal_set_noretries(rport, scmd); if (rport->port_state == FC_PORTSTATE_BLOCKED) return BLK_EH_RESET_TIMER; @@ -2095,7 +2099,8 @@ fc_user_scan_tgt(struct Scsi_Host *shost, uint channel, uint id, u64 lun) if (rport->scsi_target_id == -1) continue; - if (rport->port_state != FC_PORTSTATE_ONLINE) + if ((rport->port_state != FC_PORTSTATE_ONLINE) && + (rport->port_state != FC_PORTSTATE_MARGINAL)) continue; if ((channel == rport->channel) && @@ -2958,7 +2963,8 @@ fc_remote_port_delete(struct fc_rport *rport) spin_lock_irqsave(shost->host_lock, flags); - if (rport->port_state != FC_PORTSTATE_ONLINE) { + if ((rport->port_state != FC_PORTSTATE_ONLINE) && + (rport->port_state != FC_PORTSTATE_MARGINAL)) { spin_unlock_irqrestore(shost->host_lock, flags); return; } @@ -3100,7 +3106,8 @@ fc_timeout_deleted_rport(struct work_struct *work) * target, validate it still is. If not, tear down the * scsi_target on it. */ - if ((rport->port_state == FC_PORTSTATE_ONLINE) && + if (((rport->port_state == FC_PORTSTATE_ONLINE) || + (rport->port_state == FC_PORTSTATE_MARGINAL)) && (rport->scsi_target_id != -1) && !(rport->roles & FC_PORT_ROLE_FCP_TARGET)) { dev_printk(KERN_ERR, &rport->dev, @@ -3243,7 +3250,8 @@ fc_scsi_scan_rport(struct work_struct *work) struct fc_internal *i = to_fc_internal(shost->transportt); unsigned long flags; - if ((rport->port_state == FC_PORTSTATE_ONLINE) && + if (((rport->port_state == FC_PORTSTATE_ONLINE) || + (rport->port_state == FC_PORTSTATE_ONLINE)) && (rport->roles & FC_PORT_ROLE_FCP_TARGET) && !(i->f->disable_target_scan)) { scsi_scan_target(&rport->dev, rport->channel, @@ -3747,7 +3755,8 @@ static blk_status_t fc_bsg_rport_prep(struct fc_rport *rport) !(rport->flags & FC_RPORT_FAST_FAIL_TIMEDOUT)) return BLK_STS_RESOURCE; - if (rport->port_state != FC_PORTSTATE_ONLINE) + if ((rport->port_state != FC_PORTSTATE_ONLINE) && + (rport->port_state != FC_PORTSTATE_MARGINAL)) return BLK_STS_IOERR; return BLK_STS_OK; diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h index 1c7dd35cb7a0..829bade13b89 100644 --- a/include/scsi/scsi_transport_fc.h +++ b/include/scsi/scsi_transport_fc.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -67,6 +68,7 @@ enum fc_port_state { FC_PORTSTATE_ERROR, FC_PORTSTATE_LOOPBACK, FC_PORTSTATE_DELETED, + FC_PORTSTATE_MARGINAL, }; @@ -707,6 +709,22 @@ struct fc_function_template { unsigned long disable_target_scan:1; }; +/** + * fc_rport_chkmarginal_set_noretries - Set the SCMD_NORETRIES_ABORT bit + * in cmd->state if port state is marginal + * @rport: remote port to be checked + * @scmd: scsi_cmd to set/clear the SCMD_NORETRIES_ABORT bit on Marginal state + **/ +static inline void +fc_rport_chkmarginal_set_noretries(struct fc_rport *rport, struct scsi_cmnd *cmd) +{ + if ((rport->port_state == FC_PORTSTATE_MARGINAL) && + (cmd->request->cmd_flags & REQ_FAILFAST_TRANSPORT)) + set_bit(SCMD_NORETRIES_ABORT, &cmd->state); + else + clear_bit(SCMD_NORETRIES_ABORT, &cmd->state); + +} /** * fc_remote_port_chkready - called to validate the remote port state @@ -723,6 +741,7 @@ fc_remote_port_chkready(struct fc_rport *rport) switch (rport->port_state) { case FC_PORTSTATE_ONLINE: + case FC_PORTSTATE_MARGINAL: if (rport->roles & FC_PORT_ROLE_FCP_TARGET) result = 0; else if (rport->flags & FC_RPORT_DEVLOSS_PENDING) From patchwork Thu Oct 22 12:34:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muneendra Kumar M X-Patchwork-Id: 11851861 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 68C6514B2 for ; Thu, 22 Oct 2020 19:28:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 39A182465D for ; Thu, 22 Oct 2020 19:28:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Rj8blCs3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S370229AbgJVT2f (ORCPT ); Thu, 22 Oct 2020 15:28:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S370227AbgJVT2e (ORCPT ); Thu, 22 Oct 2020 15:28:34 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89440C0613CE for ; Thu, 22 Oct 2020 12:28:34 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id e10so1815640pfj.1 for ; Thu, 22 Oct 2020 12:28:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Hffbf+plhDD5Arm8/qnGwKp+WUWqsiObkp0/QTkKypI=; b=Rj8blCs3AqHIfwW6+lS1CByk9NO/tm1iWfj1aelq88iehQX6mkxfeKmBSZxaghCbDQ +xVz1LXDMnVTGbt35Hxh9j3ktJ5ysSkxgEaaQ83Kv4ifPZTKsqctbUoAt6W1slzPQI54 1dtbA5Ih6ornZAJ5w+Kg84O0sIUvLlTf1jmAE= 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=Hffbf+plhDD5Arm8/qnGwKp+WUWqsiObkp0/QTkKypI=; b=SECbH7M+LlCmUfvqC1mf9aJkpWgBu2iio4zjWrydMN0MNagx0ennUbEvgn4fR4swlj +s3F6n3Jw5Dngkmr3tjWH1TjNZqW+mqD6e03yWzQAU/oz/vy3qb6PPj1kMzruSd9enhR wboRpBANL3MlROeIZvbCnFv5r2Tx8ThQaKHiUOH0EvF2V1BZrNLqO4LiCoCmJu2qrvxv JPAqu5ayDx3jnGth8YBKkjIaXHH6XpGRo1Z/Evx79G8gzyrMP1Uc3vFLAaqHZIdt3ndd Kb2cDI8255v8/9dhcdFS7RppIzIBbiEGe9WlN6GrF8EEiQLLVyga5apCHECRbNifm40l 9tzQ== X-Gm-Message-State: AOAM531/Xggm9gr3TQc2bkoTMP4KIY2r4mVkzbMMU8Axv1G0XBIKSN4v RX4SAvAH40aoA16reZ3b1fAkL9HaZ1/iXoxvkuc65szZ+2ll/5Wm7A5x0J05pCeFTN3emv2Iaxk ey4b8s1SyF9lsdTo6cZOyzcu0PdnK60PEk4XEvrAFRufSV4TV6d5lX1wSJWN5AUaeeTGEKsC+3U 5zU2F/zOXO9JE= X-Google-Smtp-Source: ABdhPJzE2OJIHsO313ChDHufWPWKmWY+O7GQCxPZdCcY6lBYeFQIvKTMUpb9JICPzzoabJovseCwBQ== X-Received: by 2002:a17:90a:f211:: with SMTP id bs17mr3715747pjb.153.1603394913605; Thu, 22 Oct 2020 12:28:33 -0700 (PDT) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id s10sm2846759pji.7.2020.10.22.12.28.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Oct 2020 12:28:33 -0700 (PDT) From: Muneendra To: linux-scsi@vger.kernel.org, michael.christie@oracle.com, hare@suse.de Cc: jsmart2021@gmail.com, emilne@redhat.com, mkumar@redhat.com, Muneendra Subject: [patch v4 5/5] scsi_transport_fc: Added store fucntionality to set the rport port_state using sysfs Date: Thu, 22 Oct 2020 18:04:51 +0530 Message-Id: <1603370091-9337-6-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1603370091-9337-1-git-send-email-muneendra.kumar@broadcom.com> References: <1603370091-9337-1-git-send-email-muneendra.kumar@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Added a store functionality to set rport port_state using sysfs under fc_remote_ports/rport-*/port_state With this functionality the user can move the port_state from Marginal -> Online and Online->Marginal. On Marginal :This interface will set SCMD_NORETRIES_ABORT bit in scmd->state for all the pending io's on the scsi device associated with target port. On Online :This interface will clear SCMD_NORETRIES_ABORT bit in scmd->state for all the pending io's on the scsi device associated with target port. Below is the interface provided to set the port state to Marginal and Online. echo "Marginal" >> /sys/class/fc_remote_ports/rport-X\:Y-Z/port_state echo "Online" >> /sys/class/fc_remote_ports/rport-X\:Y-Z/port_state Reported-by: kernel test robot Signed-off-by: Muneendra --- v4: Addressed the error reported by kernel test robot Removed the code needed to traverse all the devices under rport to set/clear SCMD_NORETRIES_ABORT Removed unncessary comments. Return the error values on failure while setting the port_state v3: Removed the port_state from starget attributes. Enabled the store functionality for port_state under remote port. used the starget_for_each_device to traverse around all the devices under rport v2: Changed from a noretries_abort attribute under fc_transport/target*/ to port_state for changing the port_state to a marginal state --- drivers/scsi/scsi_transport_fc.c | 56 ++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c index fcb38068e2a4..41587b1a49fb 100644 --- a/drivers/scsi/scsi_transport_fc.c +++ b/drivers/scsi/scsi_transport_fc.c @@ -943,7 +943,59 @@ show_fc_rport_roles (struct device *dev, struct device_attribute *attr, static FC_DEVICE_ATTR(rport, roles, S_IRUGO, show_fc_rport_roles, NULL); -fc_private_rport_rd_enum_attr(port_state, FC_PORTSTATE_MAX_NAMELEN); +static ssize_t fc_rport_set_marginal_state(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct fc_rport *rport = transport_class_to_rport(dev); + enum fc_port_state port_state; + int ret = 0; + + ret = get_fc_port_state_match(buf, &port_state); + if (ret) + return -EINVAL; + if (port_state == FC_PORTSTATE_MARGINAL) { + /* + * Change the state to marginal only if the + * current rport state is Online + * Allow only Online->marginal + */ + if (rport->port_state == FC_PORTSTATE_ONLINE) + rport->port_state = port_state; + else + return -EINVAL; + } else if (port_state == FC_PORTSTATE_ONLINE) { + /* + * Change the state to Online only if the + * current rport state is Marginal + * Allow only MArginal->Online + */ + if (rport->port_state == FC_PORTSTATE_MARGINAL) + rport->port_state = port_state; + else + return -EINVAL; + } else + return -EINVAL; + return count; +} + +static ssize_t +show_fc_rport_port_state(struct device *dev, + struct device_attribute *attr, char *buf) +{ + const char *name; + struct fc_rport *rport = transport_class_to_rport(dev); + + name = get_fc_port_state_name(rport->port_state); + if (!name) + return -EINVAL; + + return snprintf(buf, 20, "%s\n", name); +} + +static FC_DEVICE_ATTR(rport, port_state, 0444 | 0200, + show_fc_rport_port_state, fc_rport_set_marginal_state); + fc_private_rport_rd_attr(scsi_target_id, "%d\n", 20); /* @@ -2267,7 +2319,7 @@ fc_attach_transport(struct fc_function_template *ft) SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(port_name); SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(port_id); SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(roles); - SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(port_state); + SETUP_PRIVATE_RPORT_ATTRIBUTE_RW(port_state); SETUP_PRIVATE_RPORT_ATTRIBUTE_RD(scsi_target_id); SETUP_PRIVATE_RPORT_ATTRIBUTE_RW(fast_io_fail_tmo);