From patchwork Thu Nov 5 06:09:53 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: 11884385 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 A4AFB921 for ; Thu, 5 Nov 2020 13:03:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5DE6420756 for ; Thu, 5 Nov 2020 13:03:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="O79wmu6w" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729992AbgKENDV (ORCPT ); Thu, 5 Nov 2020 08:03:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725468AbgKENDU (ORCPT ); Thu, 5 Nov 2020 08:03:20 -0500 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB57FC0613CF for ; Thu, 5 Nov 2020 05:03:20 -0800 (PST) Received: by mail-pl1-x643.google.com with SMTP id p4so762584plr.1 for ; Thu, 05 Nov 2020 05:03:20 -0800 (PST) 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=uDkQNsc6DsPsPKv2o21H94U+AHRU9KrNcFgTG8KcNPM=; b=O79wmu6wDX5n/8BwuAL9k2UOxXukdbjdxFvx/IolVP6mH16wn8eyN0UGjOGezS94om DaI8ibrqg/VmVIlbgfEThTAcTgK7wiR+Myi42carKNHdge8YGdLBQDmDBPzHgpQEDZ9+ 6kH9Q4/+ph97MwcEBzNs/rPK3koRYZDD/FyFc= 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=uDkQNsc6DsPsPKv2o21H94U+AHRU9KrNcFgTG8KcNPM=; b=TcX5COi9ndOhJM0PZ75yyS9t1oVeQVX7YrtFoo+pWucR89z4kIt63CXxrh3rNbHjcQ AntaTKxzfsBWCJJsT3w1ozlai1mQx/R+zBV+Mz8XzMePVDrw9YY8IZl7npnAjbNU0V/w uHQ/xsjEDoIf9hWD10XIiw+IqnzZ5rLii8pen/KmSpdVdjiNFub606crLtK1lQ8oMbHi 81PEH0XcKK6zBaHA2pk+utL60esqW6ADtgZMjM8+znV7AhXN1EwvRqmVPy+jsT2XDQhX pffLVQunTnaqebHuOzhjzr2SYpWTvEWUMoXAjKA+X54Kkjomk51wp2bZRGq+XiVy/ThH Pjrg== X-Gm-Message-State: AOAM532uozJiTiysKhfRH4TeAN28/BQBnPWQD0v0KVCflRYcbH4lbWz+ WfZ5O96UeNO/AORselGiY7NL0bLA2IwVxLPhP0bXsAgsoWiTUWW7Ardnscg/QQGttJUpv5Wl6TP Opsrf4EkqvBBE8Jeqy0JYAkraofEPPX6sHPnEPMhMt+udX4CUH79qO+kqhriSS8xl+ED5eNk/OP NyXYRUmmZ7qQ8= X-Google-Smtp-Source: ABdhPJwrnbDoIVOB1K0jspRhDaxYrDci6BJKYH3Lf0Exgh8pHACmV0gkjwpDsIH94l+ODUlzDz9cSg== X-Received: by 2002:a17:90b:3798:: with SMTP id mz24mr2302296pjb.46.1604581399763; Thu, 05 Nov 2020 05:03:19 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id y141sm2491319pfb.17.2020.11.05.05.03.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Nov 2020 05:03:19 -0800 (PST) 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 v6 1/4] scsi: Added a new definition in scsi_cmnd.h Date: Thu, 5 Nov 2020 11:39:53 +0530 Message-Id: <1604556596-27228-2-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1604556596-27228-1-git-send-email-muneendra.kumar@broadcom.com> References: <1604556596-27228-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 Clearing the SCMD_NORETRIES_ABORT bit in state flag before blk_mq_start_request Signed-off-by: Muneendra --- v6: Rearranged the patch by merging first hunk of the patch2 in v5 to this patch v5: No Change v4: No Change v3: No change v2: Modified the commit log --- drivers/scsi/scsi_lib.c | 1 + include/scsi/scsi_cmnd.h | 3 +++ 2 files changed, 4 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_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 Nov 5 06:09:54 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: 11884387 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 D4C071744 for ; Thu, 5 Nov 2020 13:03:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8AF662087D for ; Thu, 5 Nov 2020 13:03:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="LXzH5mEV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730594AbgKENDY (ORCPT ); Thu, 5 Nov 2020 08:03:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725468AbgKENDX (ORCPT ); Thu, 5 Nov 2020 08:03:23 -0500 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97C9CC0613CF for ; Thu, 5 Nov 2020 05:03:23 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id y7so390912pfq.11 for ; Thu, 05 Nov 2020 05:03:23 -0800 (PST) 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=Cu07e8/kT3mYvc0P5Yz/ZPTYuhP+CdMddVbnC1aSZ9Q=; b=LXzH5mEVcjRUu+AkGSW65W01UqMjRWdDmFyewIy1vISVq2djvMF7XEbE+Foc7dwRl6 1Q/AgZTnkTRCFzXJXKmV7Mj9JO5VDPDKFXNPBYnK64Vv+AYHOGir1t9RGDRIkP7/0fIB 0oNlBHMgm7sWmuulgoCWdsRduJiLslM+QYhk4= 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=Cu07e8/kT3mYvc0P5Yz/ZPTYuhP+CdMddVbnC1aSZ9Q=; b=Ayp3JLQSJDO4eNM2SFQNbjYJI14G7FwpW6NUey9ILA1bpFE231tvsXPif9CNHHiY2i C7RCUjPeTwTo6p4URrBDLDcDlcW1uAUpwB6H0ir6+/CEmBJuC4BZrSBC3TfRBLMRRHyj BNyhLwfwlPYRT3R8u5wmNXW1IHciuTDcgJyUnpvnyG4x2eWsG5jwd+czhscpow0z0B+F g3LIdRnZ6E99jViF5r/6lIwlIu0XxWBLH4+bROJKZazhhMFoqg/7zNz2wbya4kqEjBX5 ae27I6tLoFuv8urcA5OvW8hPoHFTpUlN63Kl+3UaMPNIddwpSoTCKYYitrISW6BoxvMy P8QA== X-Gm-Message-State: AOAM532Uf+Sw1ZTpSSE7s5TgiaZimgBhXX+Ydt5heTyvxXRvhUnVsdoV TLm7LuVm3K6fKZCUWr2VgWIFpJP99A/8C1AYHJxVWjv7/m0vVoaUUSXQRd/QTTU5WUyHs/E8pIc 7tsA3MbmngqAst5AEd95DGgqvThtrA7nmHvr8LVpfJWYufgIjOxquLe2vnrHdjwAJ7Lq3uLZFdC Kx6d/Z+28/X/U= X-Google-Smtp-Source: ABdhPJyQD4EIINIAM0eipa9q1q/nfMyxw9Mj2hPo/PPKwzkzIFLkAb0UTHbMyUUVpNaETMiFd+XgAQ== X-Received: by 2002:a62:f846:0:b029:15f:f897:7647 with SMTP id c6-20020a62f8460000b029015ff8977647mr2496415pfm.75.1604581402662; Thu, 05 Nov 2020 05:03:22 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id y141sm2491319pfb.17.2020.11.05.05.03.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Nov 2020 05:03:22 -0800 (PST) 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 v6 2/4] scsi: No retries on abort success Date: Thu, 5 Nov 2020 11:39:54 +0530 Message-Id: <1604556596-27228-3-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1604556596-27228-1-git-send-email-muneendra.kumar@broadcom.com> References: <1604556596-27228-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 checking 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 new error code DID_TRANSPORT_MARGINAL to handle marginal errors in scsi.h 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 Added DID_TRANSPORT_MARGINAL case to scsi_decide_disposition Signed-off-by: Muneendra --- v6: Rearranged the patch by merging second hunk of the patch2 in v5 to this patch v5: added the DID_TRANSPORT_MARGINAL case to scsi_decide_disposition 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 | 17 +++++++++++++++++ drivers/scsi/scsi_lib.c | 1 + include/scsi/scsi.h | 1 + 3 files changed, 19 insertions(+) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index ae80daa5d831..02dfd70219b2 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. @@ -1861,6 +1871,13 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd) * the fast io fail tmo fired), so send IO directly upwards. */ return SUCCESS; + + case DID_TRANSPORT_MARGINAL: + /* + * caller has decided not to do retries on + * abort success, so send IO directly upwards. + */ + return SUCCESS; case DID_ERROR: if (msg_byte(scmd->result) == COMMAND_COMPLETE && status_byte(scmd->result) == RESERVATION_CONFLICT) 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); 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 Nov 5 06:09:55 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: 11884389 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 317781744 for ; Thu, 5 Nov 2020 13:03:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E7DC020936 for ; Thu, 5 Nov 2020 13:03:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="LHAsEwwk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730660AbgKEND2 (ORCPT ); Thu, 5 Nov 2020 08:03:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730519AbgKEND1 (ORCPT ); Thu, 5 Nov 2020 08:03:27 -0500 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 7947DC0613CF for ; Thu, 5 Nov 2020 05:03:27 -0800 (PST) Received: by mail-pl1-x641.google.com with SMTP id z1so741366plo.12 for ; Thu, 05 Nov 2020 05:03:27 -0800 (PST) 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=VArABzytS7Zf++Ins7cjDwWoPXUTREZkEvsYK1v4Wu8=; b=LHAsEwwkx/gSexWolzkjKKZo9r0V3RSpb5oYe8jNuMnODbir+fULhS8WMfqInDW1U+ xCafqjAlQR2YJm6tbMlHHgZsZwmT+nNG0hgPmScJ2roeAmUNTZh1xP5AidBIfEIhAojZ ZA3mnm94Xha6EEHPHxORGQHPjKyVZCLdkSMxU= 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=VArABzytS7Zf++Ins7cjDwWoPXUTREZkEvsYK1v4Wu8=; b=oUtp6JC47x19xEHVagqSPnOVwBNqK+VjcLprwJila3bC3qyQUNSBP/Xv9n0o6dd+xQ qjnE5VGp5xXXy18KiW4KyRk00vG/P8IayGwXRBo76luRX7FUS9pkKorE7u3FC4/eFg1n FdYYqkAe50JrfrYGNF5h8wWI8gtzQmR1YCPHcErVHhSMbfk/gsw0wz16d6w4f0Hkra15 cvljCKGJLgwW+exKJZKKv08G3c9vzZcNxlV0nmxN/oyp0comjhBk+ghb2IpXznWhLqOe VZopPJsO5DkpG2iWYgw8TdxC7n5ZjvMTVqScBTQILFdA+YJJ0RYiKo91WCTEfMCQ3Dw3 o3qQ== X-Gm-Message-State: AOAM532iF+ilmU+pBpiNUuh5PRWhvLo549V1mLtl5Ztt09ue2DRl7ZqQ rGDmB5UjU6hx8RM1NkR1Ncky4i0zjZ+EGrjPhnMth562TnWeA337W8Msrv+QzNK2AYToXxfNvcz HhQJoo31SZSDApl4v1RCR6GmAkRncH7GSutJvP1WTx5vO3OkoHdh6c59utEab2Aw6SzrQkxIzQl CKrhDp4TsFHVg= X-Google-Smtp-Source: ABdhPJw/R54JvYQp3VBvFe1SsThkXrpIK34EXZ/aqJaes30YNtQrQnhS11RmoHeKlZlkdAeRqvGmpg== X-Received: by 2002:a17:90b:1413:: with SMTP id jo19mr2271582pjb.221.1604581405672; Thu, 05 Nov 2020 05:03:25 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id y141sm2491319pfb.17.2020.11.05.05.03.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Nov 2020 05:03:25 -0800 (PST) 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 v6 3/4] scsi_transport_fc: Added a new rport state FC_PORTSTATE_MARGINAL Date: Thu, 5 Nov 2020 11:39:55 +0530 Message-Id: <1604556596-27228-4-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1604556596-27228-1-git-send-email-muneendra.kumar@broadcom.com> References: <1604556596-27228-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. Made changes in fc_block_scsi_eh to clear the SCMD_NORETRIES_ABORT bit if the port_state is not marginal Signed-off-by: Muneendra --- v6: No change v5: Made changes to clear the SCMD_NORETRIES_ABORT bit if the port_state has changed from marginal to online due to port_delete and port_add as we need the normal cmd retry behaviour Made changes in fc_scsi_scan_rport as we are checking FC_PORTSTATE_ONLINE instead of FC_PORTSTATE_ONLINE and FC_PORTSTATE_MARGINAL 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 | 52 +++++++++++++++++++++----------- include/scsi/scsi_transport_fc.h | 19 ++++++++++++ 2 files changed, 54 insertions(+), 17 deletions(-) diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c index 2ff7f06203da..276826db0832 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 @@ -2074,6 +2077,7 @@ fc_eh_timed_out(struct scsi_cmnd *scmd) if (rport->port_state == FC_PORTSTATE_BLOCKED) return BLK_EH_RESET_TIMER; + fc_rport_chkmarginal_set_noretries(rport, scmd); return BLK_EH_DONE; } EXPORT_SYMBOL(fc_eh_timed_out); @@ -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_MARGINAL)) && (rport->roles & FC_PORT_ROLE_FCP_TARGET) && !(i->f->disable_target_scan)) { scsi_scan_target(&rport->dev, rport->channel, @@ -3308,11 +3316,20 @@ EXPORT_SYMBOL(fc_block_rport); int fc_block_scsi_eh(struct scsi_cmnd *cmnd) { struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device)); + int ret = 0; if (WARN_ON_ONCE(!rport)) return FAST_IO_FAIL; - return fc_block_rport(rport); + ret = fc_block_rport(rport); + /* + * Clear the SCMD_NORETRIES_ABORT bit if the Port state has + * changed from marginal to online due to + * fc_remote_port_delete and fc_remote_port_add + */ + if (rport->port_state != FC_PORTSTATE_MARGINAL) + clear_bit(SCMD_NORETRIES_ABORT, &cmnd->state); + return ret; } EXPORT_SYMBOL(fc_block_scsi_eh); @@ -3747,7 +3764,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 Nov 5 06:09:56 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: 11884391 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 9B399921 for ; Thu, 5 Nov 2020 13:03:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5EAE82073A for ; Thu, 5 Nov 2020 13:03:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Gc6EY/T5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730669AbgKENDd (ORCPT ); Thu, 5 Nov 2020 08:03:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725468AbgKENDb (ORCPT ); Thu, 5 Nov 2020 08:03:31 -0500 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B74B1C0613CF for ; Thu, 5 Nov 2020 05:03:31 -0800 (PST) Received: by mail-pj1-x1041.google.com with SMTP id b23so45963pju.5 for ; Thu, 05 Nov 2020 05:03:31 -0800 (PST) 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=nwJXdfa81GZUf6tOrWB3ofabgq/Xcim3w7/tL7ez6Pk=; b=Gc6EY/T5G4tml13g54s3u+8UmgNqtwcvKyLH19KmbrWhfkDfeP+hDHxi0xTVbpAUi7 bXN4MIyT/O7DXEveUbZo0A+giTb8ePHpTSZFwbCS4C5EhbKdHTpgN4LfpApDtahfzw2b axw2b8dOVzNq/t1tnwxdrAcp2NlRA4K+ZRY7Q= 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=nwJXdfa81GZUf6tOrWB3ofabgq/Xcim3w7/tL7ez6Pk=; b=PbsZa3mVLmEX/4s8E/wo91LCXYPeWYBZHz3kIzabeNn1BKSn3Dava2izqoo8ANL0mr UfXahaxpDBZ9Oti8zz7Svm3YZuo63kXr42PqJlXgdb/FMDRmsA5PBm9gD0ZtMOWj0BQ2 vF855WD6w0xBVaXshAg4iIldPJ+VP3hPEt7d+qFOQMKfXNWGTP/wmGmfaD2QKoUMm7Qr 8fNQRPySFfzSFSNmwco8EO0IDOBmvfWrljDwr4jgVDU9ZC1jeTL5cjELkzxt1Fdj6WuO 22I8ZLnAtkddIJJok3dUVkS6FPQcIK+r9gsVvXlt3kpisBryPu3Etb0L2POlVPKMAAwk 0H3A== X-Gm-Message-State: AOAM530V8v5YbTaZWRy77OvqmxrU5U+AXZAv2sS+Is8Mw9lpYGxP8Ka3 WpZ4TA9mUnuen+BYNJSsS8Ble+AqOoHZygplK0atCuu7J+l/sq1z5HdngbK5XGjtsN5vfCqvHk1 BsIKnJG+WlCbBVAb96azS4eE/zha/XcKwljKn81enRg9N5ryW4XBEZn35W2iO7HxWAkhkadbAbf aHVtRSywBa+KQ= X-Google-Smtp-Source: ABdhPJwkQbnpu7ojOU5mjaQXN+31L3kjkq5Zmf8G6LEuXtIrfcBjk/Vj8fkSa+l8TfmZfGJmVlgolA== X-Received: by 2002:a17:90a:8b93:: with SMTP id z19mr2337078pjn.123.1604581408571; Thu, 05 Nov 2020 05:03:28 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id y141sm2491319pfb.17.2020.11.05.05.03.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Nov 2020 05:03:28 -0800 (PST) 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 v6 4/4] scsi_transport_fc: Added store fucntionality to set the rport port_state using sysfs Date: Thu, 5 Nov 2020 11:39:56 +0530 Message-Id: <1604556596-27228-5-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1604556596-27228-1-git-send-email-muneendra.kumar@broadcom.com> References: <1604556596-27228-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 Signed-off-by: Muneendra --- v6: No change v5: No change 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 276826db0832..764bff609c5d 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);