From patchwork Wed Aug 5 02:50:58 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: 11701643 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 354F8913 for ; Wed, 5 Aug 2020 09:45:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1832F22B40 for ; Wed, 5 Aug 2020 09:45:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Q6dck2lX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728170AbgHEJpk (ORCPT ); Wed, 5 Aug 2020 05:45:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727941AbgHEJpR (ORCPT ); Wed, 5 Aug 2020 05:45:17 -0400 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 F3099C061757 for ; Wed, 5 Aug 2020 02:45:16 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id p1so24940419pls.4 for ; Wed, 05 Aug 2020 02:45:16 -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=BX+qEUXJP3Gj5JCJCCKYSqHBd/iu1VMbpZI+qGsbNeg=; b=Q6dck2lXg83kERKGtkvDYtYOO9kv77oIxHdGHK5RnJU+0tT0f0FJa1q9b6G6W1S2hE mJvzYeIKWoVcHwZEG7tgxquw4SmnhVIJFyowkSL1JTznV6gLHbBiIR1aF2vO8jdoCYvn ikhf9srKFtL6LbKAKI+zBKosaE2RdJD/eK0gU= 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=BX+qEUXJP3Gj5JCJCCKYSqHBd/iu1VMbpZI+qGsbNeg=; b=aglsAV+FVFK8Y72yHuiqPYg4ofLTYE/Lyl2JQ6pElHhqvSJ9YjQvZLzppAmfNMVR1z prhlNnRh+Mw6Cc4VCg2Xjr/Rqshv7oPOfHMkbfUZgsufspN5y6j2YhfCEHVzf5kH6ut2 MkxBAARKIcG82KTu4KpcH0KRVKqZ/+SGuEw6Sfhiq2VdZOV8NJeZRVn7zx9Zj/eMikmn dN6Fr6zW5y4RLUCz/+VqlPZmYtuM9Sjp34SnlxsxLd7c6lJ8AwQW6CJiNEwsw3eHr09Z saphjdB5uJMkBDnFus7Uq/6pR/13MxbuNMOGfucmjdB1lxxyjYeQYGgoU25svGjpPJ4f s0Jg== X-Gm-Message-State: AOAM533BUk3iPtspm9L+PBMOPg86XxwoqJTHie0w8uem5ehHs7MMETSI re6KgeNdW5/fmazVpiWVoZ+64mxEPI9a19cCv/orcCaLCqWfJTCThPZIqBiIsRIpd/I4mty1Nl4 CFj1IyTHOkJ3mR1CYNuMb/tsBtmE8sG9cKLjN4X+3AzM3lAop+cxIEpQ0M2EDHIvPHbuJOYMrYr O+KT03+A== X-Google-Smtp-Source: ABdhPJy1YYB/NanEAFnu/oludmnmc8za/DQS+H6Hm8wea9AUctKGszhukbl5Ojb+DvZUYnkINeQS6g== X-Received: by 2002:a17:90b:3907:: with SMTP id ob7mr2507314pjb.124.1596620715718; Wed, 05 Aug 2020 02:45:15 -0700 (PDT) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id e9sm2632346pfh.151.2020.08.05.02.45.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Aug 2020 02:45:15 -0700 (PDT) From: Muneendra To: linux-scsi@vger.kernel.org Cc: hare@suse.de, jsmart2021@gmail.com, emilne@redhat.com, mkumar@redhat.com, Muneendra Subject: [PATCH 1/5] scsi: Added a new macro in scsi_cmnd.h Date: Wed, 5 Aug 2020 08:20:58 +0530 Message-Id: <1596595862-11075-2-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596595862-11075-1-git-send-email-muneendra.kumar@broadcom.com> References: <1596595862-11075-1-git-send-email-muneendra.kumar@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Added a new macro SCMD_NORETRIES_ABORT in scsi_cmnd.h The SCMD_NORETRIES_ABORT macro defines the third bit postion in scmd->state Signed-off-by: Muneendra Reviewed-by: Hannes Reinecke --- 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 e76bac4..e1883fe 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 Wed Aug 5 02:50:59 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: 11701645 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 C0E2314DD for ; Wed, 5 Aug 2020 09:45:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AB5BF22B48 for ; Wed, 5 Aug 2020 09:45:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="iAtIDBuB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727972AbgHEJpu (ORCPT ); Wed, 5 Aug 2020 05:45:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727982AbgHEJpT (ORCPT ); Wed, 5 Aug 2020 05:45:19 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6BA4C06174A for ; Wed, 5 Aug 2020 02:45:19 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id p8so8019409pgn.13 for ; Wed, 05 Aug 2020 02:45:19 -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=jZ7zBAmaLTbB7ZI7UK6uP32mQ4MxQ7D03hfaE9GRXSs=; b=iAtIDBuB4LCaHZkty6Oo33MbxRRjP/d6KzD3Yu5QX4NjwpY53HaAaQM2zmswmk4Pdi WdBtF7U/AwSmQ23pUbASK7E8LCVI1m0hED7uJocwj78mi4AG+10utBFovxyeSrSEah0n J+qjeaJ3x0rBIExnJbwxKZPBP5HuMDpO/q6co= 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=jZ7zBAmaLTbB7ZI7UK6uP32mQ4MxQ7D03hfaE9GRXSs=; b=NS/gNfFHBcpEnTFglBCFElcbg4JykUr9A+3A3pDaxRwOUrpXmy3JlHMWm71RukNdRI bLCNYuxCt6qlPpbrJkBQQqu0OTjf0DbZbGzIOVIVRajmA1OlmVqzAn0KRtpjcUY3tmF3 vhImNPg9AHzBkG8LxFWL0LYzUdqR6ltmM+BXOaG7zI8f9je840RtTJ9dRBgZ/Uo3ECbV wt3kgPPO3SyVsN6hwDQ69+7ntaxVSnUJEfovr9kk617SgdBVFQlYO8qKjUfSbrE6f0Ok BqJxywvuU6r/C1fmeeBHS3oCt9UzchOlGD5qezKkpCl7rnAxarF2y4iVamV/QN+QcMxn a3IQ== X-Gm-Message-State: AOAM531fIgM1431gBPWegFciB1ozGadAkAQr0G+J6rQ8tKoqxaxZ5nL+ cl96bY1wGXUScQz57+BuGhjVBkyWTNGTWxR6IV+wqgBNUcQ0ArQCKyLHy68vXeHn5gr3qf80FvH Vxwe++V0YurseurDzvitfECm0C5AAvezn9bC8dOfByCP8+R8cqMgN0JXRp7DF/+s7Pa0BvdMEww c7Tr4DfQ== X-Google-Smtp-Source: ABdhPJxnM4Oq4U58Z/1FpDbdrc1HB69X3JD9kba2w3o6Vr0YuvAMgBo9WzrU25Czdl8E/TPGH1QPRQ== X-Received: by 2002:aa7:9314:: with SMTP id 20mr2415977pfj.65.1596620718358; Wed, 05 Aug 2020 02:45:18 -0700 (PDT) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id e9sm2632346pfh.151.2020.08.05.02.45.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Aug 2020 02:45:17 -0700 (PDT) From: Muneendra To: linux-scsi@vger.kernel.org Cc: hare@suse.de, jsmart2021@gmail.com, emilne@redhat.com, mkumar@redhat.com, Muneendra Subject: [PATCH 2/5] scsi: Clear state bit SCMD_NORETRIES_ABORT of scsi_cmd before start request Date: Wed, 5 Aug 2020 08:20:59 +0530 Message-Id: <1596595862-11075-3-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596595862-11075-1-git-send-email-muneendra.kumar@broadcom.com> References: <1596595862-11075-1-git-send-email-muneendra.kumar@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Clearing the SCMD_NORETRIES_ABORT bit in state flag of scsi_cmd if the block layer didn't complete the request due to a timeout injection so that the timeout handler will see it needs to escalate its own error recovery. Also clearing the SCMD_NORETRIES_ABORT bit in state flag before blk_mq_start_request. Signed-off-by: Muneendra Reviewed-by: Hannes Reinecke --- drivers/scsi/scsi_lib.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 27b52fc..3da6402 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1594,12 +1594,15 @@ static void scsi_mq_done(struct scsi_cmnd *cmd) /* * If the block layer didn't complete the request due to a timeout - * injection, scsi must clear its internal completed state so that the + * injection, scsi must clear its internal completed state and + * SCMD_NORETRIES_ABORT bit in state field so that the * timeout handler will see it needs to escalate its own error * recovery. */ - if (unlikely(!blk_mq_complete_request(cmd->request))) + if (unlikely(!blk_mq_complete_request(cmd->request))) { clear_bit(SCMD_STATE_COMPLETE, &cmd->state); + clear_bit(SCMD_NORETRIES_ABORT, &cmd->state); + } } static void scsi_mq_put_budget(struct blk_mq_hw_ctx *hctx) @@ -1652,6 +1655,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); blk_mq_start_request(req); } From patchwork Wed Aug 5 02:51:00 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: 11701647 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 3EF04913 for ; Wed, 5 Aug 2020 09:46:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 29F5322CAD for ; Wed, 5 Aug 2020 09:46:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="GJo6qLO2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728182AbgHEJp5 (ORCPT ); Wed, 5 Aug 2020 05:45:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728030AbgHEJpX (ORCPT ); Wed, 5 Aug 2020 05:45:23 -0400 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 C1E37C06179F for ; Wed, 5 Aug 2020 02:45:22 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id d19so566666pgl.10 for ; Wed, 05 Aug 2020 02:45:22 -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=frtssFZl2k+0RW8Ck7DYyWzCIdpJFd7XWZU4HUn8FDM=; b=GJo6qLO2DueEWHf/94R5+/cCa4AVCNBDq3GR5hJT13yWVC9MBQLlIqfjLwdIX1IJMg vPGqfSBI6DrK9+a/rCxMrwgCEb+gL9DVOA/zArSFaDK9TVI6o3agt24tkYZeLA3eE9M2 xgv1sy4S2L5TpkbOO87OaVIeLidoXEA3B+r3o= 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=frtssFZl2k+0RW8Ck7DYyWzCIdpJFd7XWZU4HUn8FDM=; b=TgnOg8xYezR6qyO8Ory19wtQ+dXnc28q/sjyqWR/xQLiSnPmFPkVAS+goBkHxeNUEN kPjyn9BXttLYroDKIjnJhr/3F4uqsBbQFof0zeIP0n02yRez8wdoGN2Y1Pkf7ZXcPvkv VbycE73JSIjLaByuz3k3c7SekUAPWLztE/7OkKhyhu0jlOpD9hdIMHS8vjagDYcBIfJg jIZKwF3jTgIrLgBn28N3Ivyeda7Td2qXCLX3wifEpyxXFvpxizF7nNEdeUbSf6U1rfIR TrqsyJhGz73PyDge2d98c8ckyFhzBWwjRMtI3zQ/c+4n7KtSYuQSPOpUXk3tUBh9R436 3bTg== X-Gm-Message-State: AOAM532UgU82kEx11M4FNrrpVt3po1fhcNP2RjY9QiNn2+fdwy0O9SNu Kw3JV1TG1UfSc0R3HhtJ5GxurKfWh29ya3SUqbpdsV7xH8uHGU2h2TUa4/nHbHNd4vp5mv+k0Um fXg+8wXb7Dny8zPBJiVCtTQ1rn6QM1Iu+3Il2LzutqRcEYlTurdABHgy2glr75Q9QgGfHXqPmhx QMAr4/Jg== X-Google-Smtp-Source: ABdhPJzuziSQVUqzqGRsjKsr59dJcNgZ+r23cQ3ozntBCTV3D3tCEHSMtWjyqh2aNgnUVyDlRywEjw== X-Received: by 2002:aa7:96e5:: with SMTP id i5mr2512780pfq.108.1596620721137; Wed, 05 Aug 2020 02:45:21 -0700 (PDT) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id e9sm2632346pfh.151.2020.08.05.02.45.18 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Aug 2020 02:45:20 -0700 (PDT) From: Muneendra To: linux-scsi@vger.kernel.org Cc: hare@suse.de, jsmart2021@gmail.com, emilne@redhat.com, mkumar@redhat.com, Muneendra Subject: [PATCH 3/5] scsi: No retries on abort success Date: Wed, 5 Aug 2020 08:21:00 +0530 Message-Id: <1596595862-11075-4-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596595862-11075-1-git-send-email-muneendra.kumar@broadcom.com> References: <1596595862-11075-1-git-send-email-muneendra.kumar@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org 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(issued on scsi timeouts) 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_FAILFAST so that the error can be propogated as recoverable transport error to the blk layers. Signed-off-by: Muneendra Reviewed-by: Hannes Reinecke --- drivers/scsi/scsi_error.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 927b1e6..3222496 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -1749,6 +1749,16 @@ int scsi_noretry_cmd(struct scsi_cmnd *scmd) check_type: /* + * Check whether caller has decided not to do retries on + * abort success by setting 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_FAILFAST); + return 1; + } + + /* * assume caller has checked sense and determined * the check condition was retryable. */ From patchwork Wed Aug 5 02:51:01 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: 11701649 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 8F4A214DD for ; Wed, 5 Aug 2020 09:46:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7AD0022CAE for ; Wed, 5 Aug 2020 09:46:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="chwC3CUu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728250AbgHEJqT (ORCPT ); Wed, 5 Aug 2020 05:46:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728045AbgHEJp1 (ORCPT ); Wed, 5 Aug 2020 05:45:27 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D52B2C0617A0 for ; Wed, 5 Aug 2020 02:45:24 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id o1so24958591plk.1 for ; Wed, 05 Aug 2020 02:45:24 -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=Vs4ohT5ml+/RHTL8m+5tUUhTKflTPiKuw9gqdGTRkSA=; b=chwC3CUuzjhRvovtpePtnn+xxLaZBEBhwsyhRx9UDtch5OYSH5QUjY6R1+njKn8k6H Gx9be3a+QS3ovtfK5gvPfysTfpwkXEpqaSLAdXSAOC8QvD4khIJd+rl15CfC2crQjTar OnI2bIaYy7eFtNBlqECTWDXWri4eN1nQm50bo= 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=Vs4ohT5ml+/RHTL8m+5tUUhTKflTPiKuw9gqdGTRkSA=; b=UxMKCsMgIKUrjkwJZCZTk6X8UG8YF8J5ZReAANdHa8po1dEMJVeNJudPZyNfmp7kfj reyw4rfknQi/W9MZn1tWakrzyU8PrWr5ge65+ck3U2DWYsJZUVJTX79vz3Ouk+P7dUDM t8ktvIKMJ50OsoOvjh+r8lWvA8e/GMoeZUh7f35QS8RgG1YL4iFMWOsTtWEcnR9GdXvk 6ZZVzvP658HMsjLDTCMPiOQin/VqeXeFfQvSFyR5qZeyqtpPYGpyA5amOKZ7oqs30FVO W5/OEy67c5eq/oxvMKHdEHOXBS7h7Oz8lLpllS+gtEyozYa4hR2nCoaZVw+DmPmWQ745 iDig== X-Gm-Message-State: AOAM531kG+wbeema0G2Yxs3z324ZEjhe2BptUv49Z5UPv54PHqauowx6 E+96ECjM8OVWmtIPAFagwCALu1JGULR1Rwm1oG63Vws19j5W0DEWPmtsl8XXtX9iojkQ/mVel23 s94YK2Ru2Wj8eTad3quUvSLTX+04JGY5uH1zUJD2jt0/HSGjFZxuB3/zijQMlll8QJbT0oof0za fnXJdS9w== X-Google-Smtp-Source: ABdhPJypzbVp8Jew6AoGp0c+0W5f3t7Tbw3uOgAwFhsnMAXuwS2XLSynTsvLo3gNd4Pi1X009XSAKg== X-Received: by 2002:a17:902:7b82:: with SMTP id w2mr2340875pll.39.1596620723799; Wed, 05 Aug 2020 02:45:23 -0700 (PDT) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id e9sm2632346pfh.151.2020.08.05.02.45.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Aug 2020 02:45:23 -0700 (PDT) From: Muneendra To: linux-scsi@vger.kernel.org Cc: hare@suse.de, jsmart2021@gmail.com, emilne@redhat.com, mkumar@redhat.com, Muneendra Subject: [PATCH 4/5] scsi: Added routine to set SCMD_NORETRIES_ABORT bit for outstanding io on scsi_dev Date: Wed, 5 Aug 2020 08:21:01 +0530 Message-Id: <1596595862-11075-5-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596595862-11075-1-git-send-email-muneendra.kumar@broadcom.com> References: <1596595862-11075-1-git-send-email-muneendra.kumar@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Added a new routine scsi_set_noretries_abort_io_device()to set SCMD_NORETRIES_ABORT for all the inflight/pending IO's on a particular scsi device at that particular instant. Export the symbol so the routine can be called by scsi_transport_fc.c Added new function declaration scsi_set_noretries_abort_io_device in scsi_priv.h Signed-off-by: Muneendra Reviewed-by: Hannes Reinecke --- drivers/scsi/scsi_error.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/scsi/scsi_priv.h | 1 + 2 files changed, 54 insertions(+) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 3222496..938d770 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -271,6 +271,59 @@ void scsi_eh_scmd_add(struct scsi_cmnd *scmd) call_rcu(&scmd->rcu, scsi_eh_inc_host_failed); } +static bool +scsi_set_noretries_abort_io(struct request *rq, void *priv, bool reserved) +{ + struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(rq); + struct scsi_device *sdev = scmd->device; + + /* only set SCMD_NORETRIES_ABORT on ios on a specific sdev */ + if (sdev != priv) + return true; + /* we don't want this command reissued on abort success + * so set SCMD_NORETRIES_ABORT bit to ensure it + * won't get reissued + */ + if (READ_ONCE(rq->state) == MQ_RQ_IN_FLIGHT) + set_bit(SCMD_NORETRIES_ABORT, &scmd->state); + return true; +} + +static int +__scsi_set_noretries_abort_io_device(struct scsi_device *sdev) +{ + + if (sdev->sdev_state != SDEV_RUNNING) + return -EINVAL; + + if (blk_queue_init_done(sdev->request_queue)) { + + blk_mq_quiesce_queue(sdev->request_queue); + blk_mq_tagset_busy_iter(&sdev->host->tag_set, + scsi_set_noretries_abort_io, sdev); + blk_mq_unquiesce_queue(sdev->request_queue); + } + return 0; +} + +/* + * scsi_set_noretries_abort_io_device - set the SCMD_NORETRIES_ABORT + * bit for all the pending io's on a device + * @sdev: scsi_device + */ +int +scsi_set_noretries_abort_io_device(struct scsi_device *sdev) +{ + struct Scsi_Host *shost = sdev->host; + int ret = -EINVAL; + + mutex_lock(&shost->scan_mutex); + ret = __scsi_set_noretries_abort_io_device(sdev); + mutex_unlock(&shost->scan_mutex); + return ret; +} +EXPORT_SYMBOL(scsi_set_noretries_abort_io_device); + /** * scsi_times_out - Timeout function for normal scsi commands. * @req: request that is timing out. diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h index d12ada0..1bbffd3 100644 --- a/drivers/scsi/scsi_priv.h +++ b/drivers/scsi/scsi_priv.h @@ -81,6 +81,7 @@ void scsi_eh_ready_devs(struct Scsi_Host *shost, int scsi_eh_get_sense(struct list_head *work_q, struct list_head *done_q); int scsi_noretry_cmd(struct scsi_cmnd *scmd); +extern int scsi_set_noretries_abort_io_device(struct scsi_device *sdev); /* scsi_lib.c */ extern int scsi_maybe_unblock_host(struct scsi_device *sdev); From patchwork Wed Aug 5 02:51:02 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: 11701651 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 206B014E3 for ; Wed, 5 Aug 2020 09:46:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0DEC822CF8 for ; Wed, 5 Aug 2020 09:46:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="B1yB7RI4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727801AbgHEJqs (ORCPT ); Wed, 5 Aug 2020 05:46:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727808AbgHEJph (ORCPT ); Wed, 5 Aug 2020 05:45:37 -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 BBB5BC0617A2 for ; Wed, 5 Aug 2020 02:45:27 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id d22so4053226pfn.5 for ; Wed, 05 Aug 2020 02:45:27 -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=gRhgCN7oJwispLAOBWNZIvR9k9He6AcoHnospPRglyo=; b=B1yB7RI4hpz8UXSJTNF1naCRYZ21hN2Q/+WPSQGscWfZui9wC7/eELi2n+eTD09pTL Uk4LiatAC97zMmGiTsoUGi168DdvGPSIdtcAdXX1f1+7iD3iqKaFwE1rpKXNwkv2LC3K GTUNLNcW5EaPbFRj5iLhEptcEZdLQQlbR3Pj8= 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=gRhgCN7oJwispLAOBWNZIvR9k9He6AcoHnospPRglyo=; b=P+JB3Wqcg7sLY7heNVjMVHZJt74Pi0YlyUqk8Z9OobUtUI3hYbfiAe5BhVKWhA5a0F oaikrCsW9MpXkMnrqixOTPhmuD5ni2letg1jjuTf0/5YJZVNx6pbnSmdoSAb5CqcIcPP x1XgOj8iequ8gC21pMvPgnxmYZSR9K1tgHp7v2jiznoaZQEKhLbDJ/ioVf8e8DdjrDX9 MFZ9zk6YinG4eNNtP2Si017m7XoktNz/amLLpBOfH6wvR5gmkMjvniQdhCuMgruTBsvm LEWVzCnhgUBBnuUJnVNJboD/PCccNK3ZwnZYGCwsK92FJeNPwSx5jM4tB5JX15BR7gF8 aKsA== X-Gm-Message-State: AOAM532c+zwRd6qz/YF5Dqqa2ZCIHEYjTuPaJ7ucKKqE7rd3L1smcoMn VgynCzPiKl2NRzrzXmccxxHr10EeSiTu/oslTv+PC8lvk3+XmO1wzxyUcTzUdDB97yFTQsxVYzT SRRIrFoYOqD6KykofbxNKf7nSyCRpl4p70oa9kiLbVWuBmh7SeCqwyY2Sx+CL2/01NcZcQ20VD4 uclqKaUQ== X-Google-Smtp-Source: ABdhPJxLOGEmGlQWi0grAn0sJc0i1qICzdsSHDHsSmH3S3aykKZPGZUJ4WUR7C/E76cYVIowmrFsxQ== X-Received: by 2002:aa7:9e5d:: with SMTP id z29mr2571367pfq.122.1596620726664; Wed, 05 Aug 2020 02:45:26 -0700 (PDT) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id e9sm2632346pfh.151.2020.08.05.02.45.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Aug 2020 02:45:25 -0700 (PDT) From: Muneendra To: linux-scsi@vger.kernel.org Cc: hare@suse.de, jsmart2021@gmail.com, emilne@redhat.com, mkumar@redhat.com, Muneendra Subject: [PATCH 5/5] scsi_transport_fc: Added a new sysfs attribute noretries_abort Date: Wed, 5 Aug 2020 08:21:02 +0530 Message-Id: <1596595862-11075-6-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1596595862-11075-1-git-send-email-muneendra.kumar@broadcom.com> References: <1596595862-11075-1-git-send-email-muneendra.kumar@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Added a new sysfs attribute noretries_abort under fc_transport/target*/ 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. Below is the interface provided to abort the io echo 1 >> /sys/class/fc_transport/targetX\:Y\:Z/noretries_abort Signed-off-by: Muneendra --- drivers/scsi/scsi_transport_fc.c | 49 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c index 2732fa6..f7b00ae 100644 --- a/drivers/scsi/scsi_transport_fc.c +++ b/drivers/scsi/scsi_transport_fc.c @@ -305,7 +305,7 @@ struct device_attribute device_attr_##_prefix##_##_name = \ * Attribute counts pre object type... * Increase these values if you add attributes */ -#define FC_STARGET_NUM_ATTRS 3 +#define FC_STARGET_NUM_ATTRS 4 #define FC_RPORT_NUM_ATTRS 10 #define FC_VPORT_NUM_ATTRS 9 #define FC_HOST_NUM_ATTRS 29 @@ -994,6 +994,44 @@ static FC_DEVICE_ATTR(rport, fast_io_fail_tmo, S_IRUGO | S_IWUSR, /* * FC SCSI Target Attribute Management */ +static void scsi_target_set_noretries_abort(struct scsi_target *starget) +{ + struct scsi_device *sdev, *tmp; + struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); + unsigned long flags; + + spin_lock_irqsave(shost->host_lock, flags); + list_for_each_entry_safe(sdev, tmp, &starget->devices, same_target_siblings) { + if (sdev->sdev_state == SDEV_DEL) + continue; + if (scsi_device_get(sdev)) + continue; + + spin_unlock_irqrestore(shost->host_lock, flags); + scsi_set_noretries_abort_io_device(sdev); + spin_lock_irqsave(shost->host_lock, flags); + scsi_device_put(sdev); + } + spin_unlock_irqrestore(shost->host_lock, flags); +} + +/* + * Sets no retries on abort in scmd->state for all + * outstanding io of all the scsi_devs + * write 1 to set the bit for all outstanding io's + */ +static ssize_t fc_target_set_noretries_abort(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct scsi_target *starget = transport_class_to_starget(dev); + + scsi_target_set_noretries_abort(starget); + return count; +} + +static FC_DEVICE_ATTR(starget, noretries_abort, 0200, + NULL, fc_target_set_noretries_abort); /* * Note: in the target show function we recognize when the remote @@ -1036,6 +1074,13 @@ static FC_DEVICE_ATTR(starget, field, S_IRUGO, \ if (i->f->show_starget_##field) \ count++ +#define SETUP_PRIVATE_STARGET_ATTRIBUTE_RW(field) \ +do { \ + i->private_starget_attrs[count] = device_attr_starget_##field; \ + i->starget_attrs[count] = &i->private_starget_attrs[count]; \ + count++; \ +} while (0) + #define SETUP_STARGET_ATTRIBUTE_RW(field) \ i->private_starget_attrs[count] = device_attr_starget_##field; \ if (!i->f->set_starget_##field) { \ @@ -2197,7 +2242,7 @@ struct scsi_transport_template * SETUP_STARGET_ATTRIBUTE_RD(node_name); SETUP_STARGET_ATTRIBUTE_RD(port_name); SETUP_STARGET_ATTRIBUTE_RD(port_id); - + SETUP_PRIVATE_STARGET_ATTRIBUTE_RW(noretries_abort); BUG_ON(count > FC_STARGET_NUM_ATTRS); i->starget_attrs[count] = NULL;