From patchwork Thu Oct 15 03:27:29 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: 11838847 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 4658E1744 for ; Thu, 15 Oct 2020 10:21:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 14E7D2224A for ; Thu, 15 Oct 2020 10:21:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="KRJVGlNa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731061AbgJOKVU (ORCPT ); Thu, 15 Oct 2020 06:21:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726709AbgJOKVT (ORCPT ); Thu, 15 Oct 2020 06:21:19 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A322C061755 for ; Thu, 15 Oct 2020 03:21:19 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id a1so1738371pjd.1 for ; Thu, 15 Oct 2020 03:21: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=z1FC3pUFkwS9yzzl3wibbLMwFNi6rUktgCaXt92PeRA=; b=KRJVGlNaCznBBMx6cZNUCH1fui1SQhSBi+T3CPCYBfbPONRyntJc45PkAuOJbZ2Fx1 gBqViUKuc+jPH999YkGoQGy+BpWdPjaaVtBvmBPR/qoM1eYtDyYh4PslsTqxIXhhW+hY 0c4UlsHxzO7Lna3K/z59Uxf39TFUPJOfY3o3w= 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=z1FC3pUFkwS9yzzl3wibbLMwFNi6rUktgCaXt92PeRA=; b=eAOAJtHfLOIks7XHwckMHpxcC0XpP6QMEQMrPTQSRVKJ38QMK8uASSRM+8gYBoMSUD tDRB0Y+YZnPLdqgewTUWeyWUyr7VmGSf2qqmukC5RZ/6eAMGA8rIbz4QHyOgAawNsNWq KduIFH3JieuInYdBkSuDPu7vDgB9pZeEeBQXKWP4TVsgvpUj/Bgfydt8Q578ElBNDAMe Qn1pL3+VAmIKo9iV5Wv2S7w2HCmxAz0PTB6nHAHd6KsTkBBcvtIBN66BPajvnNbNwQ2W 9ZDLjKZmNVO4qXYA+AxXG4DPKwLs3KSm+jw7nqp1/GDnml4PEIqHymd1c9q9ckyPyNXw Sutw== X-Gm-Message-State: AOAM532zj9nKnRkkY7GHhvZSrVN0b7N5iLOm3gLR8JuAM6LWvCTAg3yZ igPNfPVAcWviIiR3IsXh4wWfTP6VQu7u+4hl7eGckV0/CCcHbljqjFtid/ziz2RWEdEaSONrzcc +BKtWE4ffAXzRgl6yWaaEYYKqTWH/yqdvSOC7ZQ91326isBPueeFhVxFtQZsW+SeV0PZpsAMNlz fpE8NgPFtH8rQ= X-Google-Smtp-Source: ABdhPJwFnbUL5A8euW9x20KOuKqWZLBb4ddsRrgPFUuol7GM4wP6OJdzDbaZqJNDNlD67/zHBvFEtw== X-Received: by 2002:a17:902:ff14:b029:d3:f1e5:c992 with SMTP id f20-20020a170902ff14b02900d3f1e5c992mr3493743plj.72.1602757278043; Thu, 15 Oct 2020 03:21:18 -0700 (PDT) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 194sm2802258pfz.182.2020.10.15.03.21.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Oct 2020 03:21:17 -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 v3 04/17] scsi: Added routine to set/clear SCMD_NORETRIES_ABORT bit for outstanding io on scsi_dev Date: Thu, 15 Oct 2020 08:57:29 +0530 Message-Id: <1602732462-10443-5-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1602732462-10443-1-git-send-email-muneendra.kumar@broadcom.com> References: <1602732462-10443-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 a bool(set). When set is passed as 1 this routine will set SCMD_NORETRIES_ABORT bit in scmd->state for all the io's on the scsi device associated with remote port. When set is passed as 0 This routine will clear SCMD_NORETRIES_ABORT bit in scmd->state for all the io's on the scsi device associated with remote 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 --- v3: Used the existing scsi command iterators scsi_host_busy_iter. Set the SCMD_NORETRIES_ABORT to every command instead of only the inflight ios. Modified the scsi_chg_noretries_abort_io_device argument type from int to bool 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 | 65 +++++++++++++++++++++++++++++++++++++++ drivers/scsi/scsi_priv.h | 2 ++ 2 files changed, 67 insertions(+) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index aa30c1c9e9db..70e70fdfb00c 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -279,6 +279,71 @@ 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 scsi_cmnd *scmd, void *priv, bool reserved) +{ + 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*/ + clear_bit(SCMD_NORETRIES_ABORT, &scmd->state); + return true; +} + +static bool +scsi_set_noretries_abort_io(struct scsi_cmnd *scmd, void *priv, bool reserved) +{ + 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 + */ + set_bit(SCMD_NORETRIES_ABORT, &scmd->state); + return true; +} + +static int +__scsi_chg_noretries_abort_io_device(struct scsi_device *sdev, bool set) +{ + + if (sdev->sdev_state != SDEV_RUNNING) + return -EINVAL; + + blk_mq_quiesce_queue(sdev->request_queue); + if (set) + scsi_host_busy_iter(sdev->host, scsi_set_noretries_abort_io, sdev); + else + scsi_host_busy_iter(sdev->host, 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 + */ +int +scsi_chg_noretries_abort_io_device(struct scsi_device *sdev, bool 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 180636d54982..9ccd3b716cf9 100644 --- a/drivers/scsi/scsi_priv.h +++ b/drivers/scsi/scsi_priv.h @@ -82,6 +82,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, + bool set); /* scsi_lib.c */ extern int scsi_maybe_unblock_host(struct scsi_device *sdev);