From patchwork Mon Oct 2 15:43:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 13406395 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 3E751E784BF for ; Mon, 2 Oct 2023 15:44:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238194AbjJBPoK (ORCPT ); Mon, 2 Oct 2023 11:44:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238184AbjJBPnw (ORCPT ); Mon, 2 Oct 2023 11:43:52 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86536CE for ; Mon, 2 Oct 2023 08:43:49 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id D47C01F86C; Mon, 2 Oct 2023 15:43:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1696261423; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tVoh4ieT4DYECB0ceXYd5nVXDwZ/xXApA9j7xHxBpkQ=; b=VT7dsc0UxMyjabubytWDon3bU66BNYJTdpClGqEDOG7raD4lhXQrWulMZn9SPax27BH1Qd YvwbjTT/we8/4v4ySg0dt0LMYIu6Vt5ssC+9c1JmWZTSP/uWn2ZXpqPJOeGZevleWr2qno dy0JDpk5QsiuQJ19PTbCzAKeuU/Vm+A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1696261423; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tVoh4ieT4DYECB0ceXYd5nVXDwZ/xXApA9j7xHxBpkQ=; b=1pweGrKP/qMgn6I5ID2+hIU+/lfTbCiGA8fg0+y/69tUynCtlPmGOtPgNCqeC6rPwmaB/l sWY/Ixoyb1tNTEBw== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id B543E2C143; Mon, 2 Oct 2023 15:43:43 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id CD4FA51E7559; Mon, 2 Oct 2023 17:43:43 +0200 (CEST) From: Hannes Reinecke To: "Martin K. Petersen" Cc: James Bottomley , linux-scsi@vger.kernel.org, Christoph Hellwig , Hannes Reinecke Subject: [PATCH 17/18] pmcraid: select device in pmcraid_eh_target_reset_handler() Date: Mon, 2 Oct 2023 17:43:27 +0200 Message-Id: <20231002154328.43718-18-hare@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20231002154328.43718-1-hare@suse.de> References: <20231002154328.43718-1-hare@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The reset code requires a device to be selected, but we shouldn't rely on the command to provide a device for us. So select the first device on the target when sending down a target reset. Signed-off-by: Hannes Reinecke Reviewed-by: Christoph Hellwig --- drivers/scsi/pmcraid.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c index d7a331255e71..a831b34c08a4 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c @@ -3064,9 +3064,21 @@ static int pmcraid_eh_bus_reset_handler(struct scsi_cmnd *scmd) static int pmcraid_eh_target_reset_handler(struct scsi_cmnd *scmd) { - scmd_printk(KERN_INFO, scmd, + struct Scsi_Host *shost = scmd->device->host; + struct scsi_device *scsi_dev = NULL, *tmp; + + shost_for_each_device(tmp, shost) { + if ((tmp->channel == scmd->device->channel) && + (tmp->id == scmd->device->id)) { + scsi_dev = tmp; + break; + } + } + if (!scsi_dev) + return FAILED; + sdev_printk(KERN_INFO, scsi_dev, "Doing target reset due to an I/O command timeout.\n"); - return pmcraid_reset_device(scmd->device, + return pmcraid_reset_device(scsi_dev, PMCRAID_INTERNAL_TIMEOUT, RESET_DEVICE_TARGET); }