From patchwork Tue Jun 23 19:17:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Asleson X-Patchwork-Id: 11621531 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 C931514F6 for ; Tue, 23 Jun 2020 19:17:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B0D1D2082F for ; Tue, 23 Jun 2020 19:17:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DcUaJKNQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387466AbgFWTR5 (ORCPT ); Tue, 23 Jun 2020 15:17:57 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:41103 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1733309AbgFWTR5 (ORCPT ); Tue, 23 Jun 2020 15:17:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592939875; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MVXzDZJGgBD4xUv6v9WDwHRdtXXOvQAzISrUuLR4fHM=; b=DcUaJKNQ+C06tR0om72J57qC9nPRjNDaGd+Bkn2v+Ms5PQqYr9jpZIcUpsF9dRoxst3nL8 p2BP0jrglanrChBF26lPmML1fIuhLBOSQSeFuv4h1LGYM/hkgiiqJ6otoK5GDL3lDXAK26 L6Dsl3oSKoOwuO85FGn0hbjwRDzyTsQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-433-l_94cfbbOquXuITPxu4PpA-1; Tue, 23 Jun 2020 15:17:54 -0400 X-MC-Unique: l_94cfbbOquXuITPxu4PpA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0D000801503; Tue, 23 Jun 2020 19:17:53 +0000 (UTC) Received: from sulaco.redhat.com (unknown [10.3.128.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3C59E7168D; Tue, 23 Jun 2020 19:17:52 +0000 (UTC) From: Tony Asleson To: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org Subject: [RFC PATCH v3 1/8] struct device: Add function callback durable_name Date: Tue, 23 Jun 2020 14:17:42 -0500 Message-Id: <20200623191749.115200-2-tasleson@redhat.com> In-Reply-To: <20200623191749.115200-1-tasleson@redhat.com> References: <20200623191749.115200-1-tasleson@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Function callback and function to be used to write a persistent durable name to the supplied character buffer. This will be used to add structured key-value data to log messages for hardware related errors which allows end users to correlate message and specific hardware. Signed-off-by: Tony Asleson --- drivers/base/core.c | 24 ++++++++++++++++++++++++ include/linux/device.h | 4 ++++ 2 files changed, 28 insertions(+) diff --git a/drivers/base/core.c b/drivers/base/core.c index 0cad34f1eede..511b7d2fc916 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -2304,6 +2304,30 @@ int dev_set_name(struct device *dev, const char *fmt, ...) } EXPORT_SYMBOL_GPL(dev_set_name); +/** + * dev_durable_name - Write "DURABLE_NAME"= in buffer + * @dev: device + * @buffer: character buffer to write results + * @len: length of buffer + * @return: Number of bytes written to buffer + */ +int dev_durable_name(const struct device *dev, char *buffer, size_t len) +{ + int tmp, dlen; + + if (dev && dev->durable_name) { + tmp = snprintf(buffer, len, "DURABLE_NAME="); + if (tmp < len) { + dlen = dev->durable_name(dev, buffer + tmp, + len - tmp); + if (dlen > 0 && ((dlen + tmp) < len)) + return dlen + tmp; + } + } + return 0; +} +EXPORT_SYMBOL_GPL(dev_durable_name); + /** * device_to_dev_kobj - select a /sys/dev/ directory for the device * @dev: device diff --git a/include/linux/device.h b/include/linux/device.h index ac8e37cd716a..281755404c21 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -613,6 +613,8 @@ struct device { struct iommu_group *iommu_group; struct dev_iommu *iommu; + int (*durable_name)(const struct device *dev, char *buff, size_t len); + bool offline_disabled:1; bool offline:1; bool of_node_reused:1; @@ -654,6 +656,8 @@ static inline const char *dev_name(const struct device *dev) extern __printf(2, 3) int dev_set_name(struct device *dev, const char *name, ...); +int dev_durable_name(const struct device *d, char *buffer, size_t len); + #ifdef CONFIG_NUMA static inline int dev_to_node(struct device *dev) { From patchwork Tue Jun 23 19:17:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Asleson X-Patchwork-Id: 11621539 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 B986F6C1 for ; Tue, 23 Jun 2020 19:17:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9FEC920888 for ; Tue, 23 Jun 2020 19:17:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BQtTdg6U" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387482AbgFWTR6 (ORCPT ); Tue, 23 Jun 2020 15:17:58 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:52460 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1733308AbgFWTR5 (ORCPT ); Tue, 23 Jun 2020 15:17:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592939876; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=teVdl2eFjdKcaYL+t6xs5Kr2mkipcHIOT1fEkc9mcw0=; b=BQtTdg6UWkRemRfGkVUbi+PGAE9WkSnx4cRzMEPoBV7wfqrqLyjDwOWbi1QOKf513IZ2Gh xDznNs/gO4rtxHY6v/Fnp/zVglx2jO1riKHnodG/rsq7UYJo6L+DBtbE7tImH0xqxayS69 mKSG1yAsUJqFPBIqSDYkr84NVO7bVz8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-431-lH1bMT6rNEuJaJaI1CGXjA-1; Tue, 23 Jun 2020 15:17:55 -0400 X-MC-Unique: lH1bMT6rNEuJaJaI1CGXjA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 27BE48031C2; Tue, 23 Jun 2020 19:17:54 +0000 (UTC) Received: from sulaco.redhat.com (unknown [10.3.128.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D7E671694; Tue, 23 Jun 2020 19:17:53 +0000 (UTC) From: Tony Asleson To: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org Subject: [RFC PATCH v3 2/8] create_syslog_header: Add durable name Date: Tue, 23 Jun 2020 14:17:43 -0500 Message-Id: <20200623191749.115200-3-tasleson@redhat.com> In-Reply-To: <20200623191749.115200-1-tasleson@redhat.com> References: <20200623191749.115200-1-tasleson@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This gets us a persistent durable name for code that logs messages in the block layer that have the appropriate callbacks setup for durable name. Signed-off-by: Tony Asleson --- drivers/base/core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/base/core.c b/drivers/base/core.c index 511b7d2fc916..964690572a89 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -3754,6 +3754,7 @@ create_syslog_header(const struct device *dev, char *hdr, size_t hdrlen) { const char *subsys; size_t pos = 0; + int dlen; if (dev->class) subsys = dev->class->name; @@ -3796,6 +3797,10 @@ create_syslog_header(const struct device *dev, char *hdr, size_t hdrlen) "DEVICE=+%s:%s", subsys, dev_name(dev)); } + dlen = dev_durable_name(dev, hdr + (pos + 1), hdrlen - (pos + 1)); + if (dlen) + pos += dlen + 1; + if (pos >= hdrlen) goto overflow; From patchwork Tue Jun 23 19:17:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Asleson X-Patchwork-Id: 11621545 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 AC98E14F6 for ; Tue, 23 Jun 2020 19:18:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9540F208C9 for ; Tue, 23 Jun 2020 19:18:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="J/BsOvDY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387489AbgFWTSC (ORCPT ); Tue, 23 Jun 2020 15:18:02 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:33490 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387492AbgFWTSB (ORCPT ); Tue, 23 Jun 2020 15:18:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592939879; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TDzzcWBWxyBrAXvr4d3HonY06ASz+B0m8SXpgWZP+74=; b=J/BsOvDYrVTHtLrv0ByVn9BMVYkOJ47iFCSyoQFpJ7qeHsl9og9ZcTUnlfp7f0+iLdylJ4 j7PYlp2LehjWHEVohUckiODzXY5WcA0vHaCh8zAstwoS9s39lQNksF4SIfglM5w0e5FNPu T/EcH3MqKM7GnWlTDB6dwa+Cq00SqNQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-394-PAiMjlmLPQe97U4JuIhF4w-1; Tue, 23 Jun 2020 15:17:56 -0400 X-MC-Unique: PAiMjlmLPQe97U4JuIhF4w-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6FC0C464; Tue, 23 Jun 2020 19:17:55 +0000 (UTC) Received: from sulaco.redhat.com (unknown [10.3.128.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 888827168D; Tue, 23 Jun 2020 19:17:54 +0000 (UTC) From: Tony Asleson To: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org Subject: [RFC PATCH v3 3/8] print_req_error: Use dev_printk Date: Tue, 23 Jun 2020 14:17:44 -0500 Message-Id: <20200623191749.115200-4-tasleson@redhat.com> In-Reply-To: <20200623191749.115200-1-tasleson@redhat.com> References: <20200623191749.115200-1-tasleson@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Signed-off-by: Tony Asleson --- block/blk-core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/block/blk-core.c b/block/blk-core.c index 9bfaee050c82..bd57278d7113 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -213,12 +213,15 @@ EXPORT_SYMBOL_GPL(blk_status_to_errno); static void print_req_error(struct request *req, blk_status_t status, const char *caller) { + struct device *dev; int idx = (__force int)status; if (WARN_ON_ONCE(idx >= ARRAY_SIZE(blk_errors))) return; - printk_ratelimited(KERN_ERR + dev = (req->rq_disk) ? disk_to_dev(req->rq_disk) : NULL; + + dev_err_ratelimited(dev, "%s: %s error, dev %s, sector %llu op 0x%x:(%s) flags 0x%x " "phys_seg %u prio class %u\n", caller, blk_errors[idx].name, From patchwork Tue Jun 23 19:17:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Asleson X-Patchwork-Id: 11621543 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 456E61392 for ; Tue, 23 Jun 2020 19:18:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2DC362082F for ; Tue, 23 Jun 2020 19:18:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JvmYPyeH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387510AbgFWTSB (ORCPT ); Tue, 23 Jun 2020 15:18:01 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:34992 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387478AbgFWTSA (ORCPT ); Tue, 23 Jun 2020 15:18:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592939879; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Mw38SrAOK4PZpvbcKWC3wVsl3jfKtIJjGqTKE+RHMHI=; b=JvmYPyeHwWoE0WzsFKt2BjyaXGtG8yxD4GWb3RPmjqnN6qaE16B0I9w6KMwXzCRflhER67 OB5xwJ50ORt6aZFPHyEVtZE7ssQhKGH6eQvXTtlgfBVM/1alJyIKILwMm1z2N+g2od21nK ELjijTJTpDcKzr+wtay6+lO1rARm9Io= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-37-h5LrkLiZO1yElnw2pIGn3w-1; Tue, 23 Jun 2020 15:17:58 -0400 X-MC-Unique: h5LrkLiZO1yElnw2pIGn3w-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 057E418585A1; Tue, 23 Jun 2020 19:17:57 +0000 (UTC) Received: from sulaco.redhat.com (unknown [10.3.128.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0B4A71694; Tue, 23 Jun 2020 19:17:55 +0000 (UTC) From: Tony Asleson To: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org Subject: [RFC PATCH v3 4/8] buffer_io_error: Use dev_printk Date: Tue, 23 Jun 2020 14:17:45 -0500 Message-Id: <20200623191749.115200-5-tasleson@redhat.com> In-Reply-To: <20200623191749.115200-1-tasleson@redhat.com> References: <20200623191749.115200-1-tasleson@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Signed-off-by: Tony Asleson --- fs/buffer.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index a60f60396cfa..97b8f455c031 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -133,10 +133,16 @@ __clear_page_buffers(struct page *page) static void buffer_io_error(struct buffer_head *bh, char *msg) { - if (!test_bit(BH_Quiet, &bh->b_state)) - printk_ratelimited(KERN_ERR + if (!test_bit(BH_Quiet, &bh->b_state)) { + struct device *gendev; + + gendev = (bh->b_bdev->bd_disk) ? + disk_to_dev(bh->b_bdev->bd_disk) : NULL; + + dev_err_ratelimited(gendev, "Buffer I/O error on dev %pg, logical block %llu%s\n", bh->b_bdev, (unsigned long long)bh->b_blocknr, msg); + } } /* From patchwork Tue Jun 23 19:17:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Asleson X-Patchwork-Id: 11621547 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 20CF56C1 for ; Tue, 23 Jun 2020 19:18:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF313208C9 for ; Tue, 23 Jun 2020 19:18:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="R6rlJ4GE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387492AbgFWTSC (ORCPT ); Tue, 23 Jun 2020 15:18:02 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:22925 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387502AbgFWTSB (ORCPT ); Tue, 23 Jun 2020 15:18:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592939880; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2pEwcRgLvtMw24J+haf2mTbN9rcYAaYqY5Ij/FN/Jf0=; b=R6rlJ4GEa/Zb4o3C+1+OY9OruU/Vq06n4eiFYzwD4pJtvaQELG7jmGMSPCZIXXVM2wFk7p ow6kxYfF1jEYD7o0D7r8dqdLGkD0Z8KeWZbOx7ENW0UT+l9B/+q8WmMdSQHhHuRPj9ngEG NPjFYkS5FrmFBy7NTFMsargoCVB6bZQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-46-HZBeNS4BOFK4k7JsVqXFwQ-1; Tue, 23 Jun 2020 15:17:59 -0400 X-MC-Unique: HZBeNS4BOFK4k7JsVqXFwQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8344410059A5; Tue, 23 Jun 2020 19:17:58 +0000 (UTC) Received: from sulaco.redhat.com (unknown [10.3.128.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 730E171699; Tue, 23 Jun 2020 19:17:57 +0000 (UTC) From: Tony Asleson To: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org Subject: [RFC PATCH v3 5/8] ata_dev_printk: Use dev_printk Date: Tue, 23 Jun 2020 14:17:46 -0500 Message-Id: <20200623191749.115200-6-tasleson@redhat.com> In-Reply-To: <20200623191749.115200-1-tasleson@redhat.com> References: <20200623191749.115200-1-tasleson@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Utilize the dev_printk function which will add structured data to the log message. Signed-off-by: Tony Asleson --- drivers/ata/libata-core.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index beca5f91bb4c..44c874367fe3 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -6475,6 +6475,7 @@ EXPORT_SYMBOL(ata_link_printk); void ata_dev_printk(const struct ata_device *dev, const char *level, const char *fmt, ...) { + const struct device *gendev; struct va_format vaf; va_list args; @@ -6483,9 +6484,12 @@ void ata_dev_printk(const struct ata_device *dev, const char *level, vaf.fmt = fmt; vaf.va = &args; - printk("%sata%u.%02u: %pV", - level, dev->link->ap->print_id, dev->link->pmp + dev->devno, - &vaf); + gendev = (dev->sdev) ? &dev->sdev->sdev_gendev : &dev->tdev; + + dev_printk(level, gendev, "ata%u.%02u: %pV", + dev->link->ap->print_id, + dev->link->pmp + dev->devno, + &vaf); va_end(args); } From patchwork Tue Jun 23 19:17:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Asleson X-Patchwork-Id: 11621555 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 405CC14F6 for ; Tue, 23 Jun 2020 19:18:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2978020CC7 for ; Tue, 23 Jun 2020 19:18:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="COjC0+Jw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387514AbgFWTSF (ORCPT ); Tue, 23 Jun 2020 15:18:05 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:34940 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387495AbgFWTSE (ORCPT ); Tue, 23 Jun 2020 15:18:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592939882; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6l0ewfp9uvlqiKQxv1YU6LOf7OLKlhLdh0XniwOzvC4=; b=COjC0+JwmAze0yTQQpKS3iaucp+KPBiFaDST+ZkHX+N24S6ZnT73/H70xTie2osz7cpNcr 7gEwCzO28YZ8R6clfJum2aSluL8y3OZAz86gR81WqIPEggcu+Q5GbhXgnxYF7rlKeEG6rT bLRsfZtqRYXT90bINO3KSE9Cby1QsTY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-73-DQf0LK7SPlyZTVa6r2L0gQ-1; Tue, 23 Jun 2020 15:18:01 -0400 X-MC-Unique: DQf0LK7SPlyZTVa6r2L0gQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ED57D10059A3; Tue, 23 Jun 2020 19:17:59 +0000 (UTC) Received: from sulaco.redhat.com (unknown [10.3.128.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id F1A2771699; Tue, 23 Jun 2020 19:17:58 +0000 (UTC) From: Tony Asleson To: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org Subject: [RFC PATCH v3 6/8] scsi: Add durable_name for dev_printk Date: Tue, 23 Jun 2020 14:17:47 -0500 Message-Id: <20200623191749.115200-7-tasleson@redhat.com> In-Reply-To: <20200623191749.115200-1-tasleson@redhat.com> References: <20200623191749.115200-1-tasleson@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Add the needed functions to fill out the durable_name function call back for scsi based storage devices. This allows calls into dev_printk for scsi devices to have a persistent id associated with them. Signed-off-by: Tony Asleson --- drivers/scsi/scsi_lib.c | 14 ++++++++++++++ drivers/scsi/scsi_sysfs.c | 23 +++++++++++++++++++++++ drivers/scsi/sd.c | 2 ++ include/scsi/scsi_device.h | 3 +++ 4 files changed, 42 insertions(+) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 06c260f6cdae..9f6c41162c55 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -3142,3 +3142,17 @@ int scsi_vpd_tpg_id(struct scsi_device *sdev, int *rel_id) return group_id; } EXPORT_SYMBOL(scsi_vpd_tpg_id); + +int scsi_durable_name(struct scsi_device *sdev, char *buf, size_t len) +{ + int vpd_len = 0; + + vpd_len = scsi_vpd_lun_id(sdev, buf, len); + if (vpd_len > 0 && vpd_len < len) + vpd_len++; + else + vpd_len = 0; + + return vpd_len; +} +EXPORT_SYMBOL(scsi_durable_name); diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index 163dbcb741c1..f719b63f4b63 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -1582,6 +1582,28 @@ static struct device_type scsi_dev_type = { .groups = scsi_sdev_attr_groups, }; + +int dev_to_scsi_durable_name(const struct device *dev, char *buf, size_t len) +{ + struct scsi_device *sd_dev = NULL; + + // When we go through dev_printk in the scsi layer, dev is embedded + // in a struct scsi_device. When we go through the block layer, + // dev is embedded in struct genhd, thus we need different paths to + // retrieve the struct scsi_device to call scsi_durable_name. + if (dev->type == &scsi_dev_type) { + sd_dev = to_scsi_device(dev); + } else if (dev->parent && dev->parent->type == &scsi_dev_type) { + sd_dev = to_scsi_device(dev->parent); + } else { + // We have a pointer to something else, bail + return 0; + } + + return scsi_durable_name(sd_dev, buf, len); +} +EXPORT_SYMBOL(dev_to_scsi_durable_name); + void scsi_sysfs_device_initialize(struct scsi_device *sdev) { unsigned long flags; @@ -1591,6 +1613,7 @@ void scsi_sysfs_device_initialize(struct scsi_device *sdev) device_initialize(&sdev->sdev_gendev); sdev->sdev_gendev.bus = &scsi_bus_type; sdev->sdev_gendev.type = &scsi_dev_type; + sdev->sdev_gendev.durable_name = dev_to_scsi_durable_name; dev_set_name(&sdev->sdev_gendev, "%d:%d:%d:%llu", sdev->host->host_no, sdev->channel, sdev->id, sdev->lun); diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index a793cb08d025..f40e4cb4a5f6 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3360,6 +3360,8 @@ static int sd_probe(struct device *dev) gd->private_data = &sdkp->driver; gd->queue = sdkp->device->request_queue; + disk_to_dev(gd)->durable_name = dev_to_scsi_durable_name; + /* defaults, until the device tells us otherwise */ sdp->sector_size = 512; sdkp->capacity = 0; diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index c3cba2aaf934..7be5861565f7 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -461,6 +461,9 @@ extern void sdev_disable_disk_events(struct scsi_device *sdev); extern void sdev_enable_disk_events(struct scsi_device *sdev); extern int scsi_vpd_lun_id(struct scsi_device *, char *, size_t); extern int scsi_vpd_tpg_id(struct scsi_device *, int *); +extern int dev_to_scsi_durable_name(const struct device *dev, char *buf, + size_t len); +extern int scsi_durable_name(struct scsi_device *sdev, char *buf, size_t len); #ifdef CONFIG_PM extern int scsi_autopm_get_device(struct scsi_device *); From patchwork Tue Jun 23 19:17:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Asleson X-Patchwork-Id: 11621559 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 82B0514F6 for ; Tue, 23 Jun 2020 19:18:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6194120888 for ; Tue, 23 Jun 2020 19:18:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SlH5olNw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387453AbgFWTSG (ORCPT ); Tue, 23 Jun 2020 15:18:06 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:49488 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1733308AbgFWTSF (ORCPT ); Tue, 23 Jun 2020 15:18:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592939883; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3FlvC4WnnfR6GPyXEm/QWq5hfr2bBZHvjMhaZjhHQsU=; b=SlH5olNwThH1X/Bn99pJBTHbUft2gTQno5e78SzYJthktJ0NAI9ZQjFFZgpt8pV4HIzi6E 6wjiGDBq8TRnRW/lctMMe4YRPJz3+cFlKjBPjQZBLGcr4xvkyIvbC3NTk6py5/zw/pPa6l yWkPW8wi+as2VICXISu59AnPnNgovLc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-59-js0mMmBcOn-ygKuTfAMeUg-1; Tue, 23 Jun 2020 15:18:02 -0400 X-MC-Unique: js0mMmBcOn-ygKuTfAMeUg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4C43B10059A4; Tue, 23 Jun 2020 19:18:01 +0000 (UTC) Received: from sulaco.redhat.com (unknown [10.3.128.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 671687169D; Tue, 23 Jun 2020 19:18:00 +0000 (UTC) From: Tony Asleson To: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org Subject: [RFC PATCH v3 7/8] nvme: Add durable name for dev_printk Date: Tue, 23 Jun 2020 14:17:48 -0500 Message-Id: <20200623191749.115200-8-tasleson@redhat.com> In-Reply-To: <20200623191749.115200-1-tasleson@redhat.com> References: <20200623191749.115200-1-tasleson@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Corrections from Keith Busch review comments. Signed-off-by: Tony Asleson --- drivers/nvme/host/core.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index f3c037f5a9ba..f2e5b91668a1 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2667,6 +2667,22 @@ static bool nvme_validate_cntlid(struct nvme_subsystem *subsys, return true; } +static ssize_t wwid_show(struct device *dev, struct device_attribute *attr, + char *buf); + +static int dev_to_nvme_durable_name(const struct device *dev, char *buf, size_t len) +{ + char serial[144]; /* Max 141 for wwid_show */ + ssize_t serial_len = wwid_show((struct device *)dev, NULL, serial); + + if (serial_len > 0 && serial_len < len) { + serial_len -= 1; /* Remove the '\n' from the string */ + strncpy(buf, serial, serial_len); + return serial_len; + } + return 0; +} + static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id) { struct nvme_subsystem *subsys, *found; @@ -3616,6 +3632,8 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid) disk->queue = ns->queue; disk->flags = flags; memcpy(disk->disk_name, disk_name, DISK_NAME_LEN); + disk_to_dev(disk)->durable_name = dev_to_nvme_durable_name; + ns->disk = disk; __nvme_revalidate_disk(disk, id); From patchwork Tue Jun 23 19:17:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Asleson X-Patchwork-Id: 11621563 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 841F214F6 for ; Tue, 23 Jun 2020 19:18:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 642F420888 for ; Tue, 23 Jun 2020 19:18:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hHsqE9Yz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387527AbgFWTSJ (ORCPT ); Tue, 23 Jun 2020 15:18:09 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:54878 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387518AbgFWTSJ (ORCPT ); Tue, 23 Jun 2020 15:18:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592939888; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H1ShwfQ/jwFEqVsmbSMX+mrCeDuorCzonQ7UJ1/zhw8=; b=hHsqE9YzLxeYW0RQ1+SMe+/AyWeh3v0Ar26XW2htfjWu/sTQi+HdfpxM6+MrrO9Vs79TdF 3V8Qi52iMg/dqyYmBEQV3+qTRwCyHuTBL2pHHeMUh4YcfLNsNsVtUcsWUfBU3LEodnziu5 9XV5T37nx+D6y9qPoIE6yZ5G65a7ImE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-251-146-zBuTM42psyn7Tn6OUw-1; Tue, 23 Jun 2020 15:18:03 -0400 X-MC-Unique: 146-zBuTM42psyn7Tn6OUw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D2AF0107ACCA; Tue, 23 Jun 2020 19:18:02 +0000 (UTC) Received: from sulaco.redhat.com (unknown [10.3.128.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id A5A577168D; Tue, 23 Jun 2020 19:18:01 +0000 (UTC) From: Tony Asleson To: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org Subject: [RFC PATCH v3 8/8] dev_vprintk_emit: Increase hdr size Date: Tue, 23 Jun 2020 14:17:49 -0500 Message-Id: <20200623191749.115200-9-tasleson@redhat.com> In-Reply-To: <20200623191749.115200-1-tasleson@redhat.com> References: <20200623191749.115200-1-tasleson@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org With the addition of the device persistent id we have the possibility of adding 154 more bytes to the hdr. Thus if we assume the previous size of 128 was sufficent we can simply add the 2 amounts and round up. Signed-off-by: Tony Asleson --- drivers/base/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 964690572a89..c2439d12608d 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -3814,7 +3814,7 @@ create_syslog_header(const struct device *dev, char *hdr, size_t hdrlen) int dev_vprintk_emit(int level, const struct device *dev, const char *fmt, va_list args) { - char hdr[128]; + char hdr[288]; size_t hdrlen; hdrlen = create_syslog_header(dev, hdr, sizeof(hdr));