From patchwork Thu Mar 16 11:02:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ranjan Kumar X-Patchwork-Id: 664912 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45771C6FD19 for ; Thu, 16 Mar 2023 11:02:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229913AbjCPLCt (ORCPT ); Thu, 16 Mar 2023 07:02:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229886AbjCPLCr (ORCPT ); Thu, 16 Mar 2023 07:02:47 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D371942BD3 for ; Thu, 16 Mar 2023 04:02:46 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id l9-20020a17090a3f0900b0023d32684e7fso5498896pjc.1 for ; Thu, 16 Mar 2023 04:02:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1678964566; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=1e6sd+iqPYSj3saO2b3H259lVccRxjAWhdpUcWBve8w=; b=bcAEI6ZZ7PAunmATlFUORcbf103Ke1nVZ/7bMeQ0/c/hp3nGZM5Sig3NLr36UuNhQM KC7Du0Qm1ty428bb/OO68MJUZPHeIOMgoMSmW2jWlVugIrZ/cSR2dP4MzQVS4M8R0c8T JSj7LU72YMh9/TIfb7/RcbImmpx99gOa3fxYo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678964566; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1e6sd+iqPYSj3saO2b3H259lVccRxjAWhdpUcWBve8w=; b=JymLDBwr0yIswiCgdfGWwohm0GU2AuQ15YV8BTrKqMOnx68AQCRvwhzrV7YpoSeHQw 0S08L3p+rqdFgUUbz2nlhUIKw3orHXf31s7tkezx4ykr86VdiYNirJRoSHlx5VF8cKXb ZtQSIDGEMfQG5Ce0+jSSwr2JrqGnIk6qUcuLsMZhoEiujQN5dN2odQo+UdHuJCsim1qG AtYTfvUqRDQBs4yfWqI/y3zStnYSegd7lVpo9VT2+Nh+3lxR8fwIG4is6Y4uFGXsquAn jAfaWIULSMZUXkyC8jeW1S6vdWPG+VLzv69Nf3mwLaLn8RUhefPhy3IogVCn8fkQo3zF FlNg== X-Gm-Message-State: AO0yUKWpQ0aH0F/ldWLCa8e6ghAWpywocSZ7WXxwpp+D41dNeMS6mER3 424Rar/ZG1Hfj26mhOfuYN+F/QGyKvm+CRHlMgp6jfOaXn7rlofRseLdEcazmECtBDkxq2IlQCO anHrSZs9AbemOxVbj0age8j8L9JdqYwNXtQo3O8FhKaZeFrK/qAgoYEn9lUGPJjTf9+cKMXDJvw iyr8RClOfrEQ== X-Google-Smtp-Source: AK7set+ALayAwJdGzhM1IzAGjBdH1Tb7RQzH3rOmS3s6rfMRa631DlB3MHkFcOTg/ve7BXrFz3YHyQ== X-Received: by 2002:a17:902:f109:b0:19e:8bfe:7d68 with SMTP id e9-20020a170902f10900b0019e8bfe7d68mr2393360plb.11.1678964565999; Thu, 16 Mar 2023 04:02:45 -0700 (PDT) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id kb5-20020a170903338500b0019a6cce2060sm5343590plb.57.2023.03.16.04.02.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 04:02:45 -0700 (PDT) From: Ranjan Kumar To: linux-scsi@vger.kernel.org, martin.petersen@oracle.com Cc: rajsekhar.chundru@broadcom.com, sathya.prakash@broadcom.com, sumit.saxena@broadcom.com, Ranjan Kumar , Sreekanth Reddy Subject: [PATCH 4/8] mpi3mr: Avoid escalating to higher level reset when target is removed Date: Thu, 16 Mar 2023 16:32:05 +0530 Message-Id: <20230316110209.60145-5-ranjan.kumar@broadcom.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230316110209.60145-1-ranjan.kumar@broadcom.com> References: <20230316110209.60145-1-ranjan.kumar@broadcom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org SCSI error handling has taking place for timed out IOs on a drive and the corresponding drive is removed, then stop escalating to higher level of reset by returning the TUR with "I_T NEXUS LOSS OCCURRED" sense key. Signed-off-by: Ranjan Kumar Signed-off-by: Sreekanth Reddy --- drivers/scsi/mpi3mr/mpi3mr_os.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index 7ebd00dfd396..b5daa76e8628 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -4015,10 +4015,14 @@ static int mpi3mr_eh_target_reset(struct scsi_cmnd *scmd) stgt_priv_data = sdev_priv_data->tgt_priv_data; dev_handle = stgt_priv_data->dev_handle; if (stgt_priv_data->dev_removed) { + struct scmd_priv *cmd_priv = scsi_cmd_priv(scmd); sdev_printk(KERN_INFO, scmd->device, "%s:target(handle = 0x%04x) is removed, target reset is not issued\n", mrioc->name, dev_handle); - retval = FAILED; + if (!cmd_priv->in_lld_scope || cmd_priv->host_tag == MPI3MR_HOSTTAG_INVALID) + retval = SUCCESS; + else + retval = FAILED; goto out; } sdev_printk(KERN_INFO, scmd->device, @@ -4083,10 +4087,14 @@ static int mpi3mr_eh_dev_reset(struct scsi_cmnd *scmd) stgt_priv_data = sdev_priv_data->tgt_priv_data; dev_handle = stgt_priv_data->dev_handle; if (stgt_priv_data->dev_removed) { + struct scmd_priv *cmd_priv = scsi_cmd_priv(scmd); sdev_printk(KERN_INFO, scmd->device, "%s: device(handle = 0x%04x) is removed, device(LUN) reset is not issued\n", mrioc->name, dev_handle); - retval = FAILED; + if (!cmd_priv->in_lld_scope || cmd_priv->host_tag == MPI3MR_HOSTTAG_INVALID) + retval = SUCCESS; + else + retval = FAILED; goto out; } sdev_printk(KERN_INFO, scmd->device, @@ -4644,13 +4652,24 @@ static int mpi3mr_qcmd(struct Scsi_Host *shost, goto out; } + stgt_priv_data = sdev_priv_data->tgt_priv_data; + dev_handle = stgt_priv_data->dev_handle; + + /* Avoid error handling escalation when device is removed or blocked */ + + if (scmd->device->host->shost_state == SHOST_RECOVERY && + scmd->cmnd[0] == TEST_UNIT_READY && + (stgt_priv_data->dev_removed || (dev_handle == MPI3MR_INVALID_DEV_HANDLE))) { + scsi_build_sense(scmd, 0, UNIT_ATTENTION, 0x29, 0x07); + scsi_done(scmd); + goto out; + } + if (mrioc->reset_in_progress) { retval = SCSI_MLQUEUE_HOST_BUSY; goto out; } - stgt_priv_data = sdev_priv_data->tgt_priv_data; - if (atomic_read(&stgt_priv_data->block_io)) { if (mrioc->stop_drv_processing) { scmd->result = DID_NO_CONNECT << 16; @@ -4661,7 +4680,6 @@ static int mpi3mr_qcmd(struct Scsi_Host *shost, goto out; } - dev_handle = stgt_priv_data->dev_handle; if (dev_handle == MPI3MR_INVALID_DEV_HANDLE) { scmd->result = DID_NO_CONNECT << 16; scsi_done(scmd);