From patchwork Thu May 18 19:31:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 685874 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 8A48CC77B7A for ; Thu, 18 May 2023 19:32:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229773AbjERTcI (ORCPT ); Thu, 18 May 2023 15:32:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229461AbjERTcH (ORCPT ); Thu, 18 May 2023 15:32:07 -0400 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AB13B5 for ; Thu, 18 May 2023 12:32:06 -0700 (PDT) Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-643465067d1so1923127b3a.0 for ; Thu, 18 May 2023 12:32:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684438326; x=1687030326; h=content-transfer-encoding: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=E4BivBkDVwb9wkvJmHlC3sRkvVJuZrmosM6xqXvfVxc=; b=lobsCq1nQ6o/lRsZm3yjwwYn1XhRuJkFgoqDmGjBjLtnEPjij86QM3kAqpMYjYJDHR m3XOLR/Hqc54kmj7GOWSOhs8gFEAWvpCk0HZGqlV0dzERHeQ4Zcteo8wAHbLIWoQdz2e kJNzZThKIt902c340RcEpdKTk1IxFFsB6R2wmZGfbYz3pS6wBrlv0ztFTIT5xRVouzmy Md9XwEOSNs3hK52EcDmwqjOxWY79Oj3KZqsLpcjzNSOsucOO1G8GF72COsNPGp5XC6sx osc2BPfI/oRNzasltmdRxVseTjUawFr6QSrd3sGZQ/f7QWWgLipvoblIW2EoEU5Ddus6 LtFg== X-Gm-Message-State: AC+VfDzOwLfspmoEoG1R/kjLFTc0bDX3FUox1GnsAbm4uizcrUnRskvA DGP2aiDDHAC282ioAcKDibY= X-Google-Smtp-Source: ACHHUZ4iW3Dx0wm4G+kXRYcb0qLz+w9cJ0JfeprKV+HaB5Qy7HNBeYMENPDZlk4HzlH2QJFDXm4sHg== X-Received: by 2002:a05:6a20:244d:b0:ff:a017:2b07 with SMTP id t13-20020a056a20244d00b000ffa0172b07mr1032299pzc.20.1684438325440; Thu, 18 May 2023 12:32:05 -0700 (PDT) Received: from bvanassche-glaptop2.roam.corp.google.com ([98.51.102.78]) by smtp.gmail.com with ESMTPSA id 11-20020a63050b000000b0051afa49e07asm1619047pgf.50.2023.05.18.12.32.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 12:32:05 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" Cc: Christoph Hellwig , linux-scsi@vger.kernel.org, Bart Van Assche , Benjamin Block , Douglas Gilbert Subject: [PATCH v4 1/3] scsi: core: Use min() instead of open-coding it Date: Thu, 18 May 2023 12:31:57 -0700 Message-ID: <20230518193159.1166304-2-bvanassche@acm.org> X-Mailer: git-send-email 2.40.1.698.g37aff9b760-goog In-Reply-To: <20230518193159.1166304-1-bvanassche@acm.org> References: <20230518193159.1166304-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use min() instead of open-coding it in scsi_normalize_sense(). Reviewed-by: Christoph Hellwig Reviewed-by: Benjamin Block Cc: Douglas Gilbert Signed-off-by: Bart Van Assche --- drivers/scsi/scsi_common.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/scsi_common.c b/drivers/scsi/scsi_common.c index 6e50e81a8216..24dec80a6253 100644 --- a/drivers/scsi/scsi_common.c +++ b/drivers/scsi/scsi_common.c @@ -176,8 +176,7 @@ bool scsi_normalize_sense(const u8 *sense_buffer, int sb_len, if (sb_len > 2) sshdr->sense_key = (sense_buffer[2] & 0xf); if (sb_len > 7) { - sb_len = (sb_len < (sense_buffer[7] + 8)) ? - sb_len : (sense_buffer[7] + 8); + sb_len = min(sb_len, sense_buffer[7] + 8); if (sb_len > 12) sshdr->asc = sense_buffer[12]; if (sb_len > 13) From patchwork Thu May 18 19:31:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 683835 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 1F819C77B7A for ; Thu, 18 May 2023 19:32:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229756AbjERTcQ (ORCPT ); Thu, 18 May 2023 15:32:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229749AbjERTcI (ORCPT ); Thu, 18 May 2023 15:32:08 -0400 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DDADE5E for ; Thu, 18 May 2023 12:32:07 -0700 (PDT) Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-64384274895so1777476b3a.2 for ; Thu, 18 May 2023 12:32:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684438326; x=1687030326; h=content-transfer-encoding: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=xAVBJxxiddqpj3OThYrLZRemgGSYW1XJjXqIMtpmojc=; b=Wi91UpMYyQHr9dxS0BDYgSJruWIoefSRp1XptBsO42FyHClbHQkT/v7OR2WXSk+x94 pGXdggHS/lA20Z5UK4PEH2jN1IwyH4JGmVyfgrQfEyGhAFdrxkobhhVl3SYxD2PN/hQn Am6Iyf4Q7Qn5V+ZFLHJdMZN/DWJRM6iJIJjh8YHMu1zKx+8vxmwSXpen21IkbEbWNdF4 ks0w4ygebYFnhqUbnK37sA+wrtUE8coKJpYA23YIE/1qoY3HXEiSUBp0TMD2JSfX2/d0 2RS1L37bfrGGkewpEmDhzi6YaToykco+f6IKoDsKCRhjr+2nyARP4rkTodMO0MDutY/0 GsZg== X-Gm-Message-State: AC+VfDxznGuIjocZsvl+fSZEOsy2aZBUWIXLuCHgbik+/99RZqnXeV83 oFjyKHsuR9Ojx18XioZyuJw= X-Google-Smtp-Source: ACHHUZ4rY0Bcw87/WMp1tyqEmO/VpgtmZnXHG2H5df1zwzYW0Pzcw9xthYmNOkm0i03uKd7tQNe9gA== X-Received: by 2002:a05:6a21:918b:b0:106:1f7b:27bf with SMTP id tp11-20020a056a21918b00b001061f7b27bfmr1045649pzb.18.1684438326471; Thu, 18 May 2023 12:32:06 -0700 (PDT) Received: from bvanassche-glaptop2.roam.corp.google.com ([98.51.102.78]) by smtp.gmail.com with ESMTPSA id 11-20020a63050b000000b0051afa49e07asm1619047pgf.50.2023.05.18.12.32.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 12:32:06 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" Cc: Christoph Hellwig , linux-scsi@vger.kernel.org, Bart Van Assche , Niklas Cassel , Ming Lei , Hannes Reinecke , John Garry , Mike Christie Subject: [PATCH v4 2/3] scsi: core: Trace SCSI sense data Date: Thu, 18 May 2023 12:31:58 -0700 Message-ID: <20230518193159.1166304-3-bvanassche@acm.org> X-Mailer: git-send-email 2.40.1.698.g37aff9b760-goog In-Reply-To: <20230518193159.1166304-1-bvanassche@acm.org> References: <20230518193159.1166304-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org If a command fails, SCSI sense data is essential to determine why it failed. Hence make the sense key, ASC and ASCQ codes available in the ftrace output. Cc: Niklas Cassel Cc: Christoph Hellwig Cc: Ming Lei Cc: Hannes Reinecke Cc: John Garry Cc: Mike Christie Signed-off-by: Bart Van Assche Reviewed-by: Ming Lei Reviewed-by: Niklas Cassel --- include/trace/events/scsi.h | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/include/trace/events/scsi.h b/include/trace/events/scsi.h index a2c7befd451a..8e2d9b1b0e77 100644 --- a/include/trace/events/scsi.h +++ b/include/trace/events/scsi.h @@ -269,9 +269,14 @@ DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template, __field( unsigned int, prot_sglen ) __field( unsigned char, prot_op ) __dynamic_array(unsigned char, cmnd, cmd->cmd_len) + __field( u8, sense_key ) + __field( u8, asc ) + __field( u8, ascq ) ), TP_fast_assign( + struct scsi_sense_hdr sshdr; + __entry->host_no = cmd->device->host->host_no; __entry->channel = cmd->device->channel; __entry->id = cmd->device->id; @@ -285,11 +290,22 @@ DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template, __entry->prot_sglen = scsi_prot_sg_count(cmd); __entry->prot_op = scsi_get_prot_op(cmd); memcpy(__get_dynamic_array(cmnd), cmd->cmnd, cmd->cmd_len); + if (cmd->sense_buffer && SCSI_SENSE_VALID(cmd) && + scsi_command_normalize_sense(cmd, &sshdr)) { + __entry->sense_key = sshdr.sense_key; + __entry->asc = sshdr.asc; + __entry->ascq = sshdr.ascq; + } else { + __entry->sense_key = 0; + __entry->asc = 0; + __entry->ascq = 0; + } ), TP_printk("host_no=%u channel=%u id=%u lun=%u data_sgl=%u prot_sgl=%u " \ "prot_op=%s driver_tag=%d scheduler_tag=%d cmnd=(%s %s raw=%s) " \ - "result=(driver=%s host=%s message=%s status=%s)", + "result=(driver=%s host=%s message=%s status=%s) " + "sense=(key=%#x asc=%#x ascq=%#x)", __entry->host_no, __entry->channel, __entry->id, __entry->lun, __entry->data_sglen, __entry->prot_sglen, show_prot_op_name(__entry->prot_op), __entry->driver_tag, @@ -299,7 +315,8 @@ DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template, "DRIVER_OK", show_hostbyte_name(((__entry->result) >> 16) & 0xff), "COMMAND_COMPLETE", - show_statusbyte_name(__entry->result & 0xff)) + show_statusbyte_name(__entry->result & 0xff), + __entry->sense_key, __entry->asc, __entry->ascq) ); DEFINE_EVENT(scsi_cmd_done_timeout_template, scsi_dispatch_cmd_done, From patchwork Thu May 18 19:31:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 685873 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 3871BC77B7D for ; Thu, 18 May 2023 19:32:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229669AbjERTcR (ORCPT ); Thu, 18 May 2023 15:32:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229461AbjERTcJ (ORCPT ); Thu, 18 May 2023 15:32:09 -0400 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BBF6B5 for ; Thu, 18 May 2023 12:32:08 -0700 (PDT) Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-64d2a87b9daso400590b3a.0 for ; Thu, 18 May 2023 12:32:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684438328; x=1687030328; h=content-transfer-encoding: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=8SXLTFsp+gjzSgG9JqJUM2xgRcPzYQQmb2LNC2tO1KA=; b=g+zu+JtrAPJ9GJrZgnbWCzNQyeyA3+I3ggzdBt5U/rBD7g2wDZci8+M7Ky33s7J/BL M/bY5FLsyTkw5zgF6optYRX9as0gT7CVmEwqdfDMuupBoRkLY1nvtbSFdfpC4vlIvkfN a7e+q27VPpkoN4OGl/9rzHQ8PU8NXIlmosPy6Wqd1n50ePxso9q1YCsir3wn1Qa2cZqq 5qOXawxjJUwDFkuoDihR65TH7MD9OAkpVe8i15YIQ9fqhF7hNBuDBDmbbsmrMLvVulDD OH723bUul+dqOXqml+TyOcw/zvVyK7qL8w8y3NXgK2LCi0oTmp9nS9z3wT1LpOszp8Jt HxTQ== X-Gm-Message-State: AC+VfDxhJsipePptWS5JLi7rZbkN4pqRJvxfWWaqqVqrISwKjm7A4Dqw TjnruTxsQeE41La4tMsTYQzJtQgZWjo= X-Google-Smtp-Source: ACHHUZ4lfTNzgX1HWcDy86+WvM1ydQV1I8kPvNz1nbxg9djMiBThWFf1WG5NJnUj8+WEczY13Kg7fw== X-Received: by 2002:a05:6a20:1602:b0:102:2de7:ee36 with SMTP id l2-20020a056a20160200b001022de7ee36mr1090100pzj.36.1684438327556; Thu, 18 May 2023 12:32:07 -0700 (PDT) Received: from bvanassche-glaptop2.roam.corp.google.com ([98.51.102.78]) by smtp.gmail.com with ESMTPSA id 11-20020a63050b000000b0051afa49e07asm1619047pgf.50.2023.05.18.12.32.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 12:32:07 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" Cc: Christoph Hellwig , linux-scsi@vger.kernel.org, Bart Van Assche , Ming Lei , Hannes Reinecke , John Garry , Mike Christie Subject: [PATCH v4 3/3] scsi: core: Only kick the requeue list if necessary Date: Thu, 18 May 2023 12:31:59 -0700 Message-ID: <20230518193159.1166304-4-bvanassche@acm.org> X-Mailer: git-send-email 2.40.1.698.g37aff9b760-goog In-Reply-To: <20230518193159.1166304-1-bvanassche@acm.org> References: <20230518193159.1166304-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Instead of running the request queue of each device associated with a host every 3 ms (BLK_MQ_RESOURCE_DELAY) while host error handling is in progress, run the request queue after error handling has finished. Cc: Christoph Hellwig Cc: Ming Lei Cc: Hannes Reinecke Cc: John Garry Cc: Mike Christie Signed-off-by: Bart Van Assche --- drivers/scsi/scsi_lib.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index e59eb0cbfc83..e4f34217b879 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -122,11 +122,9 @@ static void scsi_mq_requeue_cmd(struct scsi_cmnd *cmd, unsigned long msecs) WARN_ON_ONCE(true); } - if (msecs) { - blk_mq_requeue_request(rq, false); + blk_mq_requeue_request(rq, false); + if (!scsi_host_in_recovery(cmd->device->host)) blk_mq_delay_kick_requeue_list(rq->q, msecs); - } else - blk_mq_requeue_request(rq, true); } /** @@ -165,7 +163,8 @@ static void __scsi_queue_insert(struct scsi_cmnd *cmd, int reason, bool unbusy) */ cmd->result = 0; - blk_mq_requeue_request(scsi_cmd_to_rq(cmd), true); + blk_mq_requeue_request(scsi_cmd_to_rq(cmd), + !scsi_host_in_recovery(cmd->device->host)); } /** @@ -449,6 +448,7 @@ static void scsi_run_queue(struct request_queue *q) if (!list_empty(&sdev->host->starved_list)) scsi_starved_list_run(sdev->host); + blk_mq_kick_requeue_list(q); blk_mq_run_hw_queues(q, false); } @@ -499,6 +499,9 @@ static void scsi_mq_uninit_cmd(struct scsi_cmnd *cmd) static void scsi_run_queue_async(struct scsi_device *sdev) { + if (scsi_host_in_recovery(sdev->host)) + return; + if (scsi_target(sdev)->single_lun || !list_empty(&sdev->host->starved_list)) { kblockd_schedule_work(&sdev->requeue_work);