From patchwork Wed Nov 11 04:58:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muneendra Kumar X-Patchwork-Id: 323440 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00, DATE_IN_PAST_06_12, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MIME_HEADER_CTYPE_ONLY,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, T_TVD_MIME_NO_HEADERS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4DBD8C5517A for ; Wed, 11 Nov 2020 11:51:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CE5D120709 for ; Wed, 11 Nov 2020 11:51:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="HrcJWx9J" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726499AbgKKLvb (ORCPT ); Wed, 11 Nov 2020 06:51:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726203AbgKKLva (ORCPT ); Wed, 11 Nov 2020 06:51:30 -0500 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9D74C0613D1 for ; Wed, 11 Nov 2020 03:51:29 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id 62so1274889pgg.12 for ; Wed, 11 Nov 2020 03:51:29 -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=8XKbWlR0P9nEOHQKylW8DIvraE/TYQZotEMJiMFSX04=; b=HrcJWx9JLc/qE3zIX2cwDH7+F+lHi+qCY7rtStE7JvKpPKT4mncQQIOiUTiBe+a4qD j8ho7O4r0FzZvrKzhdpX0Z63QnskatqJ8YEs1Suewm7+eOFEvgMmTiH0VWt9atvbZhEB Rqee5nDktdjdaZysi7aTxItqqyt7yck7wN5f8= 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=8XKbWlR0P9nEOHQKylW8DIvraE/TYQZotEMJiMFSX04=; b=n5udSIO4xwVUfPtllxA/Ic6ZJKxThRTgNTwyi7SWcQqf3VO9v1uwx0gUWX1SkCjqK8 +frJAMz9TDXr5lbGJJ3mZ5f7VpUgztbLA9UQ1QUn01zlAgngdk3ZuaWD/pgfW8Afs9Gj tu8bjl9ASUyWAZ4Hx/WnX7aBmpdCK88XNSE2O/9bXNN5FM8cFNuh7Ng3gG9I5dnGIzGP Rvgb5Fz1DJt7CWlIwjzC1pHhV5IqmUyOXtcLrfqVlriNceEWz2pbXAwHFhQuUMqaCJcG DsWp1UB269p4xW9xrQXaCCg7O9jBM37+5LZ4b08LDlZpaBC6kpES0DRhJdnaLklFdnWB hhbw== X-Gm-Message-State: AOAM533wRY5PCXRX6z14SaS4mWgRV6vCYkeSBI9vGuRZyWp8Z+S0/tOC G3BsRHlw90Bz31VJv7FobBRWLtwIAzqQxIm+Tf7EwPVvxJxS5b6IjNivAsKtsadNqxz0VVhANaT mbOIZe7s8lhMWEgbycRhCTtBWroLmeh53fjmg+0Kd7CyyHDeSholU3r4W16kWMd6xAVFePiAsr9 zLYqn60NHEPzw= X-Google-Smtp-Source: ABdhPJxHR4P51kPNXNFKFgiLjPjtDUI+E9o8d0a8eoFjbFO4TqTgrKCm87QqwgDdMBMduhF60ql7eQ== X-Received: by 2002:a62:1455:0:b029:18b:83a2:768b with SMTP id 82-20020a6214550000b029018b83a2768bmr22812725pfu.3.1605095488765; Wed, 11 Nov 2020 03:51:28 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id o1sm1160221pfk.67.2020.11.11.03.51.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Nov 2020 03:51: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 v7 2/5] scsi: No retries on abort success Date: Wed, 11 Nov 2020 10:28:02 +0530 Message-Id: <1605070685-20945-3-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1605070685-20945-1-git-send-email-muneendra.kumar@broadcom.com> References: <1605070685-20945-1-git-send-email-muneendra.kumar@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Added a new optional routine eh_should_retry_cmd in scsi_host_template that allows the transport to decide if a cmd is retryable.Return true if the transport is in a state the cmd should be retried on. Added a new interface scsi_eh_should_retry_cmd which checks and calls the new routine eh_should_retry_cmd. Made changes in scmd_eh_abort_handler and scsi_eh_flush_done_q which calls the scsi_eh_should_retry_cmd to check whether the command needs to be retried. The above changes were done based on a patch by Mike Christie. Signed-off-by: Muneendra Reviewed-by: Hannes Reinecke Reviewed-by: Ewan D. Milne Reviewed-by: Himanshu Madhani --- v7: Added New routine in scsi_host_template to decide if a cmd is retryable instead of checking the same using SCMD_NORETRIES_ABORT bit as the cmd retry part can be checked by validating the port state. Moved the DID_TRANSPORT_MARGINAL changes to previous patch for reordering 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 +++++++++++++++-- include/scsi/scsi_host.h | 6 ++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 28056ee498b3..1cdfa5a8ca09 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -124,6 +124,17 @@ static bool scsi_cmd_retry_allowed(struct scsi_cmnd *cmd) return ++cmd->retries <= cmd->allowed; } +static bool scsi_eh_should_retry_cmd(struct scsi_cmnd *cmd) +{ + struct scsi_device *sdev = cmd->device; + struct Scsi_Host *host = sdev->host; + + if (host->hostt->eh_should_retry_cmd) + return host->hostt->eh_should_retry_cmd(cmd); + + return true; +} + /** * scmd_eh_abort_handler - Handle command aborts * @work: command to be aborted. @@ -159,7 +170,8 @@ scmd_eh_abort_handler(struct work_struct *work) "eh timeout, not retrying " "aborted command\n")); } else if (!scsi_noretry_cmd(scmd) && - scsi_cmd_retry_allowed(scmd)) { + scsi_cmd_retry_allowed(scmd) && + scsi_eh_should_retry_cmd(scmd)) { SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_WARNING, scmd, "retry aborted command\n")); @@ -2111,7 +2123,8 @@ void scsi_eh_flush_done_q(struct list_head *done_q) list_for_each_entry_safe(scmd, next, done_q, eh_entry) { list_del_init(&scmd->eh_entry); if (scsi_device_online(scmd->device) && - !scsi_noretry_cmd(scmd) && scsi_cmd_retry_allowed(scmd)) { + !scsi_noretry_cmd(scmd) && scsi_cmd_retry_allowed(scmd) && + scsi_eh_should_retry_cmd(scmd)) { SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd, "%s: flush retry cmd\n", diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 701f178b20ae..e30fd963b97d 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -314,6 +314,12 @@ struct scsi_host_template { * Status: OPTIONAL */ enum blk_eh_timer_return (*eh_timed_out)(struct scsi_cmnd *); + /* + * Optional routine that allows the transport to decide if a cmd + * is retryable. Return true if the transport is in a state the + * cmd should be retried on. + */ + bool (*eh_should_retry_cmd)(struct scsi_cmnd *scmd); /* This is an optional routine that allows transport to initiate * LLD adapter or firmware reset using sysfs attribute. From patchwork Wed Nov 11 04:58:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muneendra Kumar X-Patchwork-Id: 323439 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00, DATE_IN_PAST_06_12, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MIME_HEADER_CTYPE_ONLY,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, T_TVD_MIME_NO_HEADERS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 811D4C5517A for ; Wed, 11 Nov 2020 11:51:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 135F220729 for ; Wed, 11 Nov 2020 11:51:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="d2vMF1Xn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726509AbgKKLvo (ORCPT ); Wed, 11 Nov 2020 06:51:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726504AbgKKLvg (ORCPT ); Wed, 11 Nov 2020 06:51:36 -0500 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 B2BA0C0613D4 for ; Wed, 11 Nov 2020 03:51:35 -0800 (PST) Received: by mail-pf1-x443.google.com with SMTP id w6so1500075pfu.1 for ; Wed, 11 Nov 2020 03:51:35 -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=rdrB8vUKcIobhhyLHE2CzkmnV7S1/aoHW9v0gzzXfP8=; b=d2vMF1Xne5cjPnaa/HXlWA6/9IspYZuQP71aB8YHZFMHTTlc/jW4jldwjSi5uDcSOV 01v23S8V0UESNCDuqLc3g+MbmbFeqMnKosqpDTCw7gSJ2R86BE3oHv0iO/ArZqtLCwOg 8Jsxxpeae5ckX8APevwD9RfIvUksOrvM644IY= 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=rdrB8vUKcIobhhyLHE2CzkmnV7S1/aoHW9v0gzzXfP8=; b=nFPvrhf1R8fXJCyH+SXA5x2TiizHH8ygV2Z4Vi9F0BB3+e8fndzMDpxTX2JFFJl4xB pcvPgsBUQ3trXwa33uWES8HY5OY8uxZFpywr4Nr5Z6VGnce8Um9BHOuDvG9mQMrV9+11 GNM1pGm2eJ3DElUqPkuSBe3BDfnoMQoA0T6Mq2/E8nvjXnrr79ovc8VMKuxg4Uw5mhHM Ss9E4ZctOI6RHyJun+6LhbWG0gkb9p8YxaBMyLw07LOnAdLa3iN1G0JLIIjS0W1uvnka c1csGeyqX+6wW9ycEbFIEa2IrRNUwDmV318HJjOZhdczLuNuGrrDvF2XWKcg60FVxpDk 5l9g== X-Gm-Message-State: AOAM531nv2xA1ogQn9yt4pLQSo3vYlgaj4lCkgehY9pmnO7gbnbPrfSB X0TI5t3zR+API0Zxj4X8AQpjmQc1JbQR4DGIyrBytnp05UEE0iG2jl5YHAq+if/u7mLA8wL5E5c /XwnZGT1ERnYB8DBPd9rKH00s47eI9AzzfZeWr6OGwEffL5mbjdYsZWQD5EsPzrYfJoYuq7G1Jd c3tgRFUs5jheU= X-Google-Smtp-Source: ABdhPJwgrZRc4+jB834Ww09Or3j6fj1OLZT8kG8BjqF1mnS0lPGPPkVJ0YtgSYlJtAnH9gefW7SLNA== X-Received: by 2002:a63:f74c:: with SMTP id f12mr21035426pgk.434.1605095494648; Wed, 11 Nov 2020 03:51:34 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id o1sm1160221pfk.67.2020.11.11.03.51.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Nov 2020 03:51:34 -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 v7 4/5] scsi_transport_fc: Added store fucntionality to set the rport port_state using sysfs Date: Wed, 11 Nov 2020 10:28:04 +0530 Message-Id: <1605070685-20945-5-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1605070685-20945-1-git-send-email-muneendra.kumar@broadcom.com> References: <1605070685-20945-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 Reviewed-by: Hannes Reinecke Reviewed-by: Ewan D. Milne Reviewed-by: Himanshu Madhani --- v7: No change 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 ffd25195ae62..d378ca4a60fe 100644 --- a/drivers/scsi/scsi_transport_fc.c +++ b/drivers/scsi/scsi_transport_fc.c @@ -1238,7 +1238,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); /* @@ -2681,7 +2733,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);