From patchwork Mon Sep 23 06:01:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Milan P. Gandhi" X-Patchwork-Id: 11156071 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 0CE1414E5 for ; Mon, 23 Sep 2019 06:02:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D30362087C for ; Mon, 23 Sep 2019 06:02:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Tf3LoB5A" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392277AbfIWGBc (ORCPT ); Mon, 23 Sep 2019 02:01:32 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:40467 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391243AbfIWGBa (ORCPT ); Mon, 23 Sep 2019 02:01:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1569218489; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vdX8tdsz8p0cI70eNyOOHHqPsOCERsGcj5XIq8ZYihI=; b=Tf3LoB5AcFjrp+t5TCu0UdTg+rCsupYY81c8Vdy7a/NPbVegtjfVI3XuqSaXxLa4VXqfFE em+cqeoRE2kwETVEUYLbqqefs85Qbw4IQf3kWpkN5U1PSj8LiB2CnOA1tUlJ5WCOCeWijA euzjhkaEl+WHHU9RMj43U2UAtJo64tw= Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-16-tEGhy6SpPS6wk-ZiaBOReg-1; Mon, 23 Sep 2019 02:01:28 -0400 Received: by mail-pg1-f200.google.com with SMTP id w13so8715377pge.15 for ; Sun, 22 Sep 2019 23:01:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=6whaabGHABPeYQY1Y8LH/wuL+jQ1IMXfQogkhGaUTG4=; b=JySCmIm3X5oL8dhbI2fjJfzcR+ombDzqz8qIDlxYkf7eqmZYCB/sHoS4SyXsNNmK3l zAZ5AMsWvzZovHxFg9Qlhxkve/BxjkvGS/QmEES59qvCAPPO1U9p6FcD9jIIK7EQHgWi aEoQekUBPItJzfl8Jj3P8r88MnLVZR+kaWspogzmEz7vFkMlB+vYrWZ0vKlSatQRQQCv 3bv43H/DrjWSCDv8l5mBDFcMiKF8szmK6oDgvt87wS1eqvsOSTRP9F9nVrdhd08mkwOg 8rbeT9HEiB2VaKGNCPopuJWiDAGD/JllnZsaOF3G7XCOCc+EymSXzR/wtKW5ZA6mNoAF UFQQ== X-Gm-Message-State: APjAAAVBHPspLLGAFUMxxUegjlYJCvmrUnU9+XiiF0WrzzkMoGdbwoiu S2hqLsGbsJBJ2wSIKM04B9iCAfacUTGsd3APB6SMVrqbhRFt3O2lO3aw5vO3wrSEP2EdGn1P5Zo YIlrl0iljpVQjd16TH+5OnQ== X-Received: by 2002:a65:4286:: with SMTP id j6mr28025369pgp.218.1569218487154; Sun, 22 Sep 2019 23:01:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqyvR4MEfVgME/VvqMT+nE4Yv61JPtHdtmXLPt2MgBFKd99JPBW+AmK8Ul3rDdKdprEPdJMtSw== X-Received: by 2002:a65:4286:: with SMTP id j6mr28025339pgp.218.1569218486738; Sun, 22 Sep 2019 23:01:26 -0700 (PDT) Received: from machine1 ([125.16.200.50]) by smtp.gmail.com with ESMTPSA id l72sm14191309pjb.7.2019.09.22.23.01.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Sep 2019 23:01:26 -0700 (PDT) Date: Mon, 23 Sep 2019 11:31:22 +0530 From: "Milan P. Gandhi" To: linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org Cc: jejb@linux.ibm.com, martin.petersen@oracle.com Subject: [PATCH] scsi: core: Log SCSI command age with errors Message-ID: <20190923060122.GA9603@machine1> MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-MC-Unique: tEGhy6SpPS6wk-ZiaBOReg-1 X-Mimecast-Spam-Score: 0 Content-Disposition: inline Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Couple of users had requested to print the SCSI command age along with command failure errors. This is a small change, but allows users to get more important information about the command that was failed, it would help the users in debugging the command failures: Signed-off-by: Milan P. Gandhi Reviewed-by: Laurence Oberman diff --git a/drivers/scsi/scsi_logging.c b/drivers/scsi/scsi_logging.c index ecc5918e372a..ca2182bc53c6 100644 --- a/drivers/scsi/scsi_logging.c +++ b/drivers/scsi/scsi_logging.c @@ -437,6 +437,7 @@ void scsi_print_result(const struct scsi_cmnd *cmd, const char *msg, const char *mlret_string = scsi_mlreturn_string(disposition); const char *hb_string = scsi_hostbyte_string(cmd->result); const char *db_string = scsi_driverbyte_string(cmd->result); + unsigned long cmd_age = (jiffies - cmd->jiffies_at_alloc) / HZ; logbuf = scsi_log_reserve_buffer(&logbuf_len); if (!logbuf) @@ -478,10 +479,15 @@ void scsi_print_result(const struct scsi_cmnd *cmd, const char *msg, if (db_string) off += scnprintf(logbuf + off, logbuf_len - off, - "driverbyte=%s", db_string); + "driverbyte=%s ", db_string); else off += scnprintf(logbuf + off, logbuf_len - off, - "driverbyte=0x%02x", driver_byte(cmd->result)); + "driverbyte=0x%02x ", + driver_byte(cmd->result)); + + off += scnprintf(logbuf + off, logbuf_len - off, + "cmd-age=%lus", cmd_age); + out_printk: dev_printk(KERN_INFO, &cmd->device->sdev_gendev, "%s", logbuf); scsi_log_release_buffer(logbuf);