From patchwork Fri Feb 24 14:43:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ranjan Kumar X-Patchwork-Id: 656743 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 C8E35C61DA3 for ; Fri, 24 Feb 2023 14:44:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230022AbjBXOoN (ORCPT ); Fri, 24 Feb 2023 09:44:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230011AbjBXOoF (ORCPT ); Fri, 24 Feb 2023 09:44:05 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C3011689A for ; Fri, 24 Feb 2023 06:44:03 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id x20-20020a17090a8a9400b00233ba727724so6365705pjn.1 for ; Fri, 24 Feb 2023 06:44:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=pCSVyte/o5B+z6Oc0FZZkMKAqKb8UhZ5biDRytHoip8=; b=cZYI0BKJ0JnZIze7cj6BbfFLTK6lMG0Ysg0+UN/Wn8qk9Gu+89kfebL/p/m8gLTYzn b3aQ3HNsRwTqBQoMzTfv6aJuNdePtu/vfuzeWL9JDm8BgIiL+SAGaZqxSVrk/ui15Kk3 aiqZhBl+/N4tsmkJ1TkpkJTjRUbVgQnSgjeSA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=pCSVyte/o5B+z6Oc0FZZkMKAqKb8UhZ5biDRytHoip8=; b=4CV/3+dmCU48lU0fLdBdv0C5P8ah8YXwTe3PLs9aZyI2fR/G3YT8FjrowAkvrodlor 5qf5B18PGZjL/jkPXNwCMl4kIHE8+tM07UOABGw6Itb8S20do6oRl4jvq1ceHIgNUx42 Wtrg+TC2WA/MZ1G/CI1pIsHYfWPB3tRCIlqeSg18TgKrqKTwDjr4rt54lvdI/3VTw27E +Go6QHyH+17dirWcYczXtjfGLXYAyxbTInx9rwZiYiwtslSvgCtFI0YC4v3h4KUgeX3t C0Oh8Oflj7W06eFvT9QcikDNik/q+YBjW47p1y+l/f2by2FVkc3o7FpbpxyV7VvRXIYc vqIA== X-Gm-Message-State: AO0yUKWnhG/woomnCXSNbXLFzbX+yscHDWuE66ajRHXDBR4n8PxKX5yD bkcc0Yw6hXu0NwLkCf6PrbWZaaIbA3V0n5TmcBQxw7SCx3BAxxO789WaJaWHiwQENj2GHpsPHeK HRkGEy68EwiuiKQ6zxeXvO75S4bHlfzwj7M0nPBIThdwGChc2UnUivzwMjmMrK1/n5fGnad1JYD hGR0Mu6dw= X-Google-Smtp-Source: AK7set8vHjC1YXkrmj5AnVVjpATdwd+0tK9Qi8OwX2EvDmrSv8lT2R4/9WZvbuUGeYUobqG6GtBd9w== X-Received: by 2002:a17:902:e547:b0:19a:abb0:1e with SMTP id n7-20020a170902e54700b0019aabb0001emr19749210plf.38.1677249842356; Fri, 24 Feb 2023 06:44:02 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id b5-20020a170902a9c500b00186748fe6ccsm8911549plr.214.2023.02.24.06.44.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Feb 2023 06:44:02 -0800 (PST) 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 03/15] mpi3mr: Avoid escalating to higher level reset when target is removed Date: Fri, 24 Feb 2023 06:43:08 -0800 Message-Id: <20230224144320.10601-4-ranjan.kumar@broadcom.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230224144320.10601-1-ranjan.kumar@broadcom.com> References: <20230224144320.10601-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 dd3a84f73e1b..3677473a0211 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -3994,10 +3994,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, @@ -4062,10 +4066,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, @@ -4623,13 +4631,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; @@ -4640,7 +4659,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);