From patchwork Mon Sep 28 04:50:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muneendra Kumar X-Patchwork-Id: 257509 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.9 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 45F8EC2D0A8 for ; Mon, 28 Sep 2020 11:44:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D170221D95 for ; Mon, 28 Sep 2020 11:44:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="da6z3gnC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726558AbgI1Loo (ORCPT ); Mon, 28 Sep 2020 07:44:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726608AbgI1Loo (ORCPT ); Mon, 28 Sep 2020 07:44:44 -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 3BE9EC061755 for ; Mon, 28 Sep 2020 04:44:44 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id l126so762722pfd.5 for ; Mon, 28 Sep 2020 04:44:44 -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=W+8t/wFNwhBkBbVsyEDmQ227b7g8+rNL8kbsStypFEg=; b=da6z3gnC/H2ozMdd3Ri58LpjKlz5X4ohVlxne6if68PKybnerEQyd4D/mKgZcGwwXZ Lz262nBy2j9ogfyFnrQhVnAQG4ESf5oF72q5XKlFYzQ9JxFUXcqT2G3YUJlj0qfQ/cXb nQ5jNoxAOHuNkRWYZKJYs262slujj+Z1omCcA= 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=W+8t/wFNwhBkBbVsyEDmQ227b7g8+rNL8kbsStypFEg=; b=QeYfV2/poS8yBw6m6CmKfwZGGN+y08MzNK44VJZ4lUs8710PPH/UK8FTf/bhEHf82s hTKEY5U9J+8BEnb1RJKL9IoQtY6GhoWLoDAtW5Nk4DcXz2fkOFRseNB/L6gSfWYvpxdg iRCQwXK12Gw7e8YWfvnJo/gB1e9sFNr24z1vKMSXAE9RhhILqAM75qGPDWveR8GkLlbw Ug/G03A6PxGOLBsZGCvaZoj/FUMF5/eBrseCiwPCadQ0J1W+EDT71OUqf1oXlUEtT7Q7 PwgNknPcGENl6ao08dLbXK1nia7GWYlmJ0C63zVqkuN8yYdJhNNp874j8j1clixCc60t vcew== X-Gm-Message-State: AOAM531iUzbkDzFxFt6uQZyCZiAXiaSXjxcJbKegAIt4U02Mj+CGV+O8 iTIpv+Ke9oq1wv43ngRt/LgaVfapoCa1J+iFR35h6+nj8EHzvbk8/D/jIIMOfd0hJ+IVMX5bU4d wTK3RtSR/HpcpmZlCfNtjq0uM0jmxWXBFyWp5NyU+CA2WddK/yEGtnaIeJdKaPfS2zgANuljBnJ 86rHaxP3X0 X-Google-Smtp-Source: ABdhPJxGxuoXq3UJyI4dntalbHM6ZlRvEv6wAfQlHvY/X8Sa+wZpX4GWi9zSIIE7wUjxin6y5xzXyw== X-Received: by 2002:a17:902:c281:b029:d2:2988:4906 with SMTP id i1-20020a170902c281b02900d229884906mr1238338pld.82.1601293483275; Mon, 28 Sep 2020 04:44:43 -0700 (PDT) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id w19sm1468866pfq.60.2020.09.28.04.44.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Sep 2020 04:44:42 -0700 (PDT) From: Muneendra To: linux-scsi@vger.kernel.org, hare@suse.de Cc: jsmart2021@gmail.com, emilne@redhat.com, mkumar@redhat.com, Muneendra Subject: [PATCH v2 5/8] scsi: Added routine to set/clear SCMD_NORETRIES_ABORT bit for outstanding io on scsi_dev Date: Mon, 28 Sep 2020 10:20:54 +0530 Message-Id: <1601268657-940-6-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1601268657-940-1-git-send-email-muneendra.kumar@broadcom.com> References: <1601268657-940-1-git-send-email-muneendra.kumar@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Added a new routine scsi_chg_noretries_abort_io_device(). This functions accepts two arguments Scsi_device and an integer(set). When set is passed as 1 this routine will set SCMD_NORETRIES_ABORT bit in scmd->state for all the pending io's on the scsi device associated with target port. When set is passed as 0 This routine will clear SCMD_NORETRIES_ABORT bit in scmd->state for all the pending io's on the scsi device associated with target port. Export the symbol so the routine can be called by scsi_transport_fc.c Added new function declaration scsi_chg_noretries_abort_io_device in scsi_priv.h Signed-off-by: Muneendra --- v2: Renamed the below functions as scsi_set_noretries_abort_io_device ->scsi_chg_noretries_abort_io_device __scsi_set_noretries_abort_io_device->__scsi_set_noretries_abort_io_device which accepts the value as an arg to set/clear the SCMD_NORETRIES_ABORT bit --- drivers/scsi/scsi_error.c | 76 +++++++++++++++++++++++++++++++++++++++ drivers/scsi/scsi_priv.h | 2 ++ 2 files changed, 78 insertions(+) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 3f14ea10d5da..c0943f08b469 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -271,6 +271,82 @@ void scsi_eh_scmd_add(struct scsi_cmnd *scmd) call_rcu(&scmd->rcu, scsi_eh_inc_host_failed); } +static bool +scsi_clear_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 clear SCMD_NORETRIES_ABORT on ios on a specific sdev */ + if (sdev != priv) + return true; + + /*Clear the SCMD_NORETRIES_ABORT bit*/ + if (READ_ONCE(rq->state) == MQ_RQ_IN_FLIGHT) + clear_bit(SCMD_NORETRIES_ABORT, &scmd->state); + return true; +} + +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_chg_noretries_abort_io_device(struct scsi_device *sdev, int set) +{ + + if (sdev->sdev_state != SDEV_RUNNING) + return -EINVAL; + + if (blk_queue_init_done(sdev->request_queue)) { + + blk_mq_quiesce_queue(sdev->request_queue); + + if (set) + blk_mq_tagset_busy_iter(&sdev->host->tag_set, + scsi_set_noretries_abort_io, sdev); + else + blk_mq_tagset_busy_iter(&sdev->host->tag_set, + scsi_clear_noretries_abort_io, sdev); + + blk_mq_unquiesce_queue(sdev->request_queue); + } + return 0; +} + +/* + * scsi_chg_noretries_abort_io_device - set/clear the SCMD_NORETRIES_ABORT + * bit for all the pending io's on a device + * @sdev: scsi_device + * @set: indicates to clear (0) or set (1) the SCMD_NORETRIES_ABORT flag + */ +int +scsi_chg_noretries_abort_io_device(struct scsi_device *sdev, int set) +{ + struct Scsi_Host *shost = sdev->host; + int ret = -EINVAL; + + mutex_lock(&shost->scan_mutex); + ret = __scsi_chg_noretries_abort_io_device(sdev, set); + mutex_unlock(&shost->scan_mutex); + return ret; +} +EXPORT_SYMBOL(scsi_chg_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 d12ada035961..aba98a3294ce 100644 --- a/drivers/scsi/scsi_priv.h +++ b/drivers/scsi/scsi_priv.h @@ -81,6 +81,8 @@ 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_chg_noretries_abort_io_device(struct scsi_device *sdev, + int set); /* scsi_lib.c */ extern int scsi_maybe_unblock_host(struct scsi_device *sdev);