From patchwork Mon Dec 23 22:55:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Asleson X-Patchwork-Id: 11308815 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 A9816184C for ; Mon, 23 Dec 2019 22:56:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 87C5721569 for ; Mon, 23 Dec 2019 22:56:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="W55TwLRV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727033AbfLWW4G (ORCPT ); Mon, 23 Dec 2019 17:56:06 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:54043 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726943AbfLWW4F (ORCPT ); Mon, 23 Dec 2019 17:56:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577141764; 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=Ti74zgLwc9xdwukIMd+N9Ca9W+CO/0vNVJxfQlPd5OY=; b=W55TwLRVxXdSlIuqNsjAL4iDpU1YYUXLLAJtb2gWMsA5lOMrFSDuechr0dIzYWrZ8DMrBo bzVt2fYtrndu8286F11XzHaR+YcbJ0r/1qyKrb+pEQpINZLDKaCRl4k0PvwNFPBbaoRDWf xP4Xbdmh48x43VIpyQLJ/IycrwnansY= 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-116--SyhMrKbN4Kn6hs4rcI6dA-1; Mon, 23 Dec 2019 17:56:03 -0500 X-MC-Unique: -SyhMrKbN4Kn6hs4rcI6dA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2BBF510054E3; Mon, 23 Dec 2019 22:56:02 +0000 (UTC) Received: from sulaco.redhat.com (ovpn-112-13.rdu2.redhat.com [10.10.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E50160BE2; Mon, 23 Dec 2019 22:56:01 +0000 (UTC) From: Tony Asleson To: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [RFC 1/9] lib/string: Add function to trim duplicate WS Date: Mon, 23 Dec 2019 16:55:50 -0600 Message-Id: <20191223225558.19242-2-tasleson@redhat.com> In-Reply-To: <20191223225558.19242-1-tasleson@redhat.com> References: <20191223225558.19242-1-tasleson@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Adds function strim_dupe which trims leading & trailing whitespace and duplicate adjacent. Initial use case is to shorten T10 storage IDs. Signed-off-by: Tony Asleson --- include/linux/string.h | 2 ++ lib/string.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/include/linux/string.h b/include/linux/string.h index b6ccdc2c7f02..bcca6bfab6ab 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -72,6 +72,8 @@ extern char * __must_check skip_spaces(const char *); extern char *strim(char *); +extern size_t strim_dupe(char *s); + static inline __must_check char *strstrip(char *str) { return strim(str); diff --git a/lib/string.c b/lib/string.c index 08ec58cc673b..1186cce1f66b 100644 --- a/lib/string.c +++ b/lib/string.c @@ -515,6 +515,41 @@ char *strim(char *s) } EXPORT_SYMBOL(strim); +/** + * Removes leading and trailing whitespace and removes duplicate + * adjacent whitespace in a string, modifies string in place. + * @s The %NUL-terminated string to have spaces removed + * Returns the new length + */ +size_t strim_dupe(char *s) +{ + size_t ret = 0; + char *w = s; + char *p; + + /* + * This will remove all leading and duplicate adjacent, but leave + * 1 space at the end if one or more are present. + */ + for (p = s; *p != '\0'; ++p) { + if (!isspace(*p) || (p != s && !isspace(*(p - 1)))) { + *w = *p; + ++w; + ret += 1; + } + } + + *w = '\0'; + + /* Take off the last character if it's a space too */ + if (ret && isspace(*(w - 1))) { + ret--; + *(w - 1) = '\0'; + } + return ret; +} +EXPORT_SYMBOL(strim_dupe); + #ifndef __HAVE_ARCH_STRLEN /** * strlen - Find the length of a string From patchwork Mon Dec 23 22:55:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Asleson X-Patchwork-Id: 11308847 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 2384D17EE for ; Mon, 23 Dec 2019 22:56:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ED45520715 for ; Mon, 23 Dec 2019 22:56:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JLnzsNjs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727102AbfLWW4Q (ORCPT ); Mon, 23 Dec 2019 17:56:16 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:39995 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727028AbfLWW4G (ORCPT ); Mon, 23 Dec 2019 17:56:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577141765; 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=+eqUlR7O5ItJZvt5VamFpVvKNarH3yz0ic7VAKiE8+I=; b=JLnzsNjs0aWFdcso0z6uApF2lHCXlamjAoTTv/kdGS+czQImLAxGdqXDGFadV0ZuCmOD6i B1+owuYH6H/OJlVe11oZC5+jenHEPoi01uOtXhYf+mcWe41trELVi2k+BIFQdH0dHtJWTA Qpuxln0mZ5FBEOdTzfW5gap01ny6TKM= 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-134-XZvnH7IvNFCASfr2LpmdQg-1; Mon, 23 Dec 2019 17:56:04 -0500 X-MC-Unique: XZvnH7IvNFCASfr2LpmdQg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 69FD9DB60; Mon, 23 Dec 2019 22:56:03 +0000 (UTC) Received: from sulaco.redhat.com (ovpn-112-13.rdu2.redhat.com [10.10.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C87160BE2; Mon, 23 Dec 2019 22:56:02 +0000 (UTC) From: Tony Asleson To: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [RFC 2/9] printk: Bring back printk_emit Date: Mon, 23 Dec 2019 16:55:51 -0600 Message-Id: <20191223225558.19242-3-tasleson@redhat.com> In-Reply-To: <20191223225558.19242-1-tasleson@redhat.com> References: <20191223225558.19242-1-tasleson@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Needed for adding structured logging in a number of different areas. Signed-off-by: Tony Asleson --- include/linux/printk.h | 5 +++++ kernel/printk/printk.c | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/linux/printk.h b/include/linux/printk.h index c09d67edda3a..06c3ba5b695e 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -167,6 +167,11 @@ int vprintk_emit(int facility, int level, asmlinkage __printf(1, 0) int vprintk(const char *fmt, va_list args); +asmlinkage __printf(5, 6) __cold +int printk_emit(int facility, int level, + const char *dict, size_t dictlen, + const char *fmt, ...); + asmlinkage __printf(1, 2) __cold int printk(const char *fmt, ...); diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index ca65327a6de8..8d7be8c9bb08 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2009,6 +2009,21 @@ asmlinkage int vprintk(const char *fmt, va_list args) } EXPORT_SYMBOL(vprintk); +asmlinkage int printk_emit(int facility, int level, + const char *dict, size_t dictlen, + const char *fmt, ...) +{ + va_list args; + int r; + + va_start(args, fmt); + r = vprintk_emit(facility, level, dict, dictlen, fmt, args); + va_end(args); + + return r; +} +EXPORT_SYMBOL(printk_emit); + int vprintk_default(const char *fmt, va_list args) { int r; From patchwork Mon Dec 23 22:55:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Asleson X-Patchwork-Id: 11308825 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 BDE4B109A for ; Mon, 23 Dec 2019 22:56:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 93D132073A for ; Mon, 23 Dec 2019 22:56:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="FH0O6pEP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727070AbfLWW4J (ORCPT ); Mon, 23 Dec 2019 17:56:09 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:38543 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726995AbfLWW4J (ORCPT ); Mon, 23 Dec 2019 17:56:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577141768; 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=jYMogOorzB+CGid5/i1zzD3nNlcrIJfVcdr7IEB6sKc=; b=FH0O6pEP7CwBg7x4Kj1lLzoiwrTSp44Zi+xhSPtwi8m4SqdKEPz6N8Jc4OnxnY9vOPZisL QtYicxbl4lbvIDL+pQMGXGOqxuRD7n0Yd26AUEMIbrCFotm6nl4Mm7X18/BDmXLtvF/PQ+ 0Yw/ON7aa0l5qVaP8dcyRQdrtmQshsI= 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-3-vGrG4TV6PNC4y9lmWKyn5Q-1; Mon, 23 Dec 2019 17:56:05 -0500 X-MC-Unique: vGrG4TV6PNC4y9lmWKyn5Q-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 981E0800053; Mon, 23 Dec 2019 22:56:04 +0000 (UTC) Received: from sulaco.redhat.com (ovpn-112-13.rdu2.redhat.com [10.10.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id B784C60BE2; Mon, 23 Dec 2019 22:56:03 +0000 (UTC) From: Tony Asleson To: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [RFC 3/9] printk: Add printk_emit_ratelimited macro Date: Mon, 23 Dec 2019 16:55:52 -0600 Message-Id: <20191223225558.19242-4-tasleson@redhat.com> In-Reply-To: <20191223225558.19242-1-tasleson@redhat.com> References: <20191223225558.19242-1-tasleson@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Needed so we can add structured data to the block layer logging. Signed-off-by: Tony Asleson --- include/linux/printk.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/printk.h b/include/linux/printk.h index 06c3ba5b695e..dd41b79e6f06 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -172,6 +172,18 @@ int printk_emit(int facility, int level, const char *dict, size_t dictlen, const char *fmt, ...); +#define printk_emit_ratelimited(facility, level, \ + dict, dict_len, fmt, ...) \ +({ \ + static DEFINE_RATELIMIT_STATE(_ers, \ + DEFAULT_RATELIMIT_INTERVAL, \ + DEFAULT_RATELIMIT_BURST); \ + \ + if (__ratelimit(&_ers)) \ + printk_emit(facility, level, \ + dict, dict_len, fmt, ##__VA_ARGS__); \ +}) + asmlinkage __printf(1, 2) __cold int printk(const char *fmt, ...); From patchwork Mon Dec 23 22:55:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Asleson X-Patchwork-Id: 11308829 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 05E4217EE for ; Mon, 23 Dec 2019 22:56:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CE5D620715 for ; Mon, 23 Dec 2019 22:56:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="TKfhoDpt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727066AbfLWW4J (ORCPT ); Mon, 23 Dec 2019 17:56:09 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:48889 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726833AbfLWW4I (ORCPT ); Mon, 23 Dec 2019 17:56:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577141768; 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=0qGtQMo2+Ggjf6Vv8mYhur7z1U69z+rZqXUk93Xvkto=; b=TKfhoDptR0vMJIyDPJLlVpxCddeTmR8dS4hOBQgX2MpczfrmM9x7OTu1aXZOukoLzODmoK rVLc+Waj5Gn6jd070F2WVYpR2NoKIRWn1UQs5r1i0mfAH9tKEg3uo1x65fUPIvquine8mj nxYNIUMCtfQbTjDMSaC621zanCyqXwI= 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-174-pffGjjZTM4-uEkKFB64OVQ-1; Mon, 23 Dec 2019 17:56:06 -0500 X-MC-Unique: pffGjjZTM4-uEkKFB64OVQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DAF5D184B44F; Mon, 23 Dec 2019 22:56:05 +0000 (UTC) Received: from sulaco.redhat.com (ovpn-112-13.rdu2.redhat.com [10.10.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id F2FDB60BE2; Mon, 23 Dec 2019 22:56:04 +0000 (UTC) From: Tony Asleson To: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [RFC 4/9] struct device_type: Add function callback durable_name Date: Mon, 23 Dec 2019 16:55:53 -0600 Message-Id: <20191223225558.19242-5-tasleson@redhat.com> In-Reply-To: <20191223225558.19242-1-tasleson@redhat.com> References: <20191223225558.19242-1-tasleson@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Function callback to be used in logging functions to write a persistent durable name to the supplied character buffer. This will be used to add structured key-value data to log messages. Signed-off-by: Tony Asleson --- include/linux/device.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/device.h b/include/linux/device.h index 297239a08bb7..dd4ac8db5f57 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -799,6 +799,8 @@ struct device_type { void (*release)(struct device *dev); const struct dev_pm_ops *pm; + + int (*durable_name)(const struct device *dev, char *buff, size_t len); }; /* interface for exporting device attributes */ From patchwork Mon Dec 23 22:55:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Asleson X-Patchwork-Id: 11308839 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 1AF7D184C for ; Mon, 23 Dec 2019 22:56:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EE5B32073A for ; Mon, 23 Dec 2019 22:56:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CPI3uT0U" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726997AbfLWW4N (ORCPT ); Mon, 23 Dec 2019 17:56:13 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:49739 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727072AbfLWW4K (ORCPT ); Mon, 23 Dec 2019 17:56:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577141769; 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=Jqpmf7hQ+PQiGEtZK47/PMHEWUmQlrFIk294J3iPG3M=; b=CPI3uT0U9f/yLJ8Gtst+kFcjYOAP7xaF4n178JtRgZQRqnbysO4FBW0XDwNsKmpWG8Tsgq u30oTay5PoxfmOx5icBCiK6vtVnBjmC8DqOpP4v/SEu/PBDgzeJG6GjlT3mKycS7MPc2zA qIp9k3lka3fx19+6fakgjrny39vwtyM= 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-6-7wSF-REIMnyRq5dNXy_yRg-1; Mon, 23 Dec 2019 17:56:08 -0500 X-MC-Unique: 7wSF-REIMnyRq5dNXy_yRg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1EC64801E74; Mon, 23 Dec 2019 22:56:07 +0000 (UTC) Received: from sulaco.redhat.com (ovpn-112-13.rdu2.redhat.com [10.10.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B16C60BE2; Mon, 23 Dec 2019 22:56:06 +0000 (UTC) From: Tony Asleson To: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [RFC 5/9] block: Add support functions for persistent durable name Date: Mon, 23 Dec 2019 16:55:54 -0600 Message-Id: <20191223225558.19242-6-tasleson@redhat.com> In-Reply-To: <20191223225558.19242-1-tasleson@redhat.com> References: <20191223225558.19242-1-tasleson@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Add functions to retrieve and build durable name string into supplied buffer for functions that log using struct device and struct scsi_device. Signed-off-by: Tony Asleson --- drivers/base/core.c | 24 ++++++++++++++++++++++++ drivers/scsi/scsi_lib.c | 20 ++++++++++++++++++++ drivers/scsi/scsi_sysfs.c | 1 + include/linux/device.h | 2 ++ include/scsi/scsi_device.h | 3 +++ 5 files changed, 50 insertions(+) diff --git a/drivers/base/core.c b/drivers/base/core.c index 7bd9cd366d41..93cc1c45e9d3 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -2009,6 +2009,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->type && dev->type->durable_name) { + tmp = snprintf(buffer, len, "DURABLE_NAME="); + if (tmp < len) { + dlen = dev->type->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/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 91c007d26c1e..f22e59253d9d 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -3120,3 +3120,23 @@ int scsi_vpd_tpg_id(struct scsi_device *sdev, int *rel_id) return group_id; } EXPORT_SYMBOL(scsi_vpd_tpg_id); + +int dev_to_scsi_durable_name(const struct device *dev, char *buf, size_t len) +{ + return scsi_durable_name(to_scsi_device(dev), buf, len); +} +EXPORT_SYMBOL(dev_to_scsi_durable_name); + +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 = strim_dupe(buf) + 1; + 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 6d7362e7367e..ee5b8197916f 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -1560,6 +1560,7 @@ static struct device_type scsi_dev_type = { .name = "scsi_device", .release = scsi_device_dev_release, .groups = scsi_sdev_attr_groups, + .durable_name = dev_to_scsi_durable_name, }; void scsi_sysfs_device_initialize(struct scsi_device *sdev) diff --git a/include/linux/device.h b/include/linux/device.h index dd4ac8db5f57..566f6be6ee0d 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -1350,6 +1350,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) { diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 202f4d6a4342..1cb35e10f54a 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -455,6 +455,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 Mon Dec 23 22:55:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Asleson X-Patchwork-Id: 11308837 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 92D94138D for ; Mon, 23 Dec 2019 22:56:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 71E522073A for ; Mon, 23 Dec 2019 22:56:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GbT0KhZ7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727101AbfLWW4N (ORCPT ); Mon, 23 Dec 2019 17:56:13 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:26815 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726995AbfLWW4L (ORCPT ); Mon, 23 Dec 2019 17:56:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577141771; 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=Gq1+GAMa0C3Il9jYW93UwC35MCssNnsKhwATazBP0NA=; b=GbT0KhZ7yQ322/DIfsUT0mmGit5d/ILuOJpZmVlntx0IIGX9E9KJOgld1+guFdxioIBE8q 5H37cHfr0UfN/NX8rkBYQxrgHumntj7qyHttARbuLsmj3x6LqbN+UsExzXjBHrVnT3E8Jw +zksJvqDaPD/2M5kd1GLPWUSRKIZpuU= 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-350-nuwm2qyyNIOwZBtnPLUHxA-1; Mon, 23 Dec 2019 17:56:09 -0500 X-MC-Unique: nuwm2qyyNIOwZBtnPLUHxA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4BD6D800D41; Mon, 23 Dec 2019 22:56:08 +0000 (UTC) Received: from sulaco.redhat.com (ovpn-112-13.rdu2.redhat.com [10.10.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C12360BE2; Mon, 23 Dec 2019 22:56:07 +0000 (UTC) From: Tony Asleson To: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [RFC 6/9] create_syslog_header: Add durable name Date: Mon, 23 Dec 2019 16:55:55 -0600 Message-Id: <20191223225558.19242-7-tasleson@redhat.com> In-Reply-To: <20191223225558.19242-1-tasleson@redhat.com> References: <20191223225558.19242-1-tasleson@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/base/core.c b/drivers/base/core.c index 93cc1c45e9d3..57b5f5cd29fc 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -3318,6 +3318,15 @@ create_syslog_header(const struct device *dev, char *hdr, size_t hdrlen) "DEVICE=+%s:%s", subsys, dev_name(dev)); } + if (dev->type && dev->type->durable_name) { + int dlen; + + dlen = dev_durable_name(dev, hdr + (pos + 1), + hdrlen - (pos + 1)); + if (dlen) + pos += dlen + 1; + } + if (pos >= hdrlen) goto overflow; From patchwork Mon Dec 23 22:55:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Asleson X-Patchwork-Id: 11308861 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 4DA8E109A for ; Mon, 23 Dec 2019 22:56:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2337E2073A for ; Mon, 23 Dec 2019 22:56:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AxipSpEW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727114AbfLWW4S (ORCPT ); Mon, 23 Dec 2019 17:56:18 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:38506 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727076AbfLWW4M (ORCPT ); Mon, 23 Dec 2019 17:56:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577141771; 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=UXBplLcKGcpkDyS8yQgGXGNohbofkhElCmjtU2legM0=; b=AxipSpEWjGsg4Co0daYo62g8wTNVUa1+BrZB11S4KpD2MtpGbEOSvSbIbxcqIqBzfOXpyO LWVFNkCKyDoX97Oqggs9XTt6gV84jWIWCsjtq6fScLFqXqH1qRDyLeNcmDfjFLs1IWqdEp +jY40lRd5uJuYkPTmtAJHkqo7VHPMv0= 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-101-cH2QAAxSOymhWEqg6-2E2A-1; Mon, 23 Dec 2019 17:56:10 -0500 X-MC-Unique: cH2QAAxSOymhWEqg6-2E2A-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8678E10054E3; Mon, 23 Dec 2019 22:56:09 +0000 (UTC) Received: from sulaco.redhat.com (ovpn-112-13.rdu2.redhat.com [10.10.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id A373960BE2; Mon, 23 Dec 2019 22:56:08 +0000 (UTC) From: Tony Asleson To: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [RFC 7/9] print_req_error: Add persistent durable name Date: Mon, 23 Dec 2019 16:55:56 -0600 Message-Id: <20191223225558.19242-8-tasleson@redhat.com> In-Reply-To: <20191223225558.19242-1-tasleson@redhat.com> References: <20191223225558.19242-1-tasleson@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Add persistent durable name to errors that occur in block mid layer. Signed-off-by: Tony Asleson --- block/blk-core.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/block/blk-core.c b/block/blk-core.c index d5e668ec751b..a0171a7c6535 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -211,11 +211,20 @@ static void print_req_error(struct request *req, blk_status_t status, const char *caller) { int idx = (__force int)status; + char dict[128]; + int dict_len = 0; if (WARN_ON_ONCE(idx >= ARRAY_SIZE(blk_errors))) return; - printk_ratelimited(KERN_ERR + if (req->rq_disk) { + dict_len = dev_durable_name( + disk_to_dev(req->rq_disk)->parent, + dict, + sizeof(dict)); + } + + printk_emit_ratelimited(0, LOGLEVEL_ERR, dict, dict_len, "%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 Mon Dec 23 22:55:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Asleson X-Patchwork-Id: 11308855 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 079D117EE for ; Mon, 23 Dec 2019 22:56:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DAB372075B for ; Mon, 23 Dec 2019 22:56:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="jPiGQ5oJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727076AbfLWW4T (ORCPT ); Mon, 23 Dec 2019 17:56:19 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:52789 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727012AbfLWW4S (ORCPT ); Mon, 23 Dec 2019 17:56:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577141777; 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=s2/47G9XeaWMpZM1zDOYKyC4Wpdu3yTfLbrqo+TK1DM=; b=jPiGQ5oJSREDmvWHYdKSIY//btorumGEhSfY2clFEdRNTC2NH7RYHc0h/mLR/O/etVzPrc eiHf7/SDoSz4J0eLe+yiTBSDjPq/QuyE/8HhoWy/cxSh0/3PnXAoIK9auIQV70HOJfotjC SsAG82XFP9tYmwVTDsUuX0IvJf94gxE= 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-332-pFJS9mGJPZ-zNFs_M12gbA-1; Mon, 23 Dec 2019 17:56:11 -0500 X-MC-Unique: pFJS9mGJPZ-zNFs_M12gbA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CAE26184B456; Mon, 23 Dec 2019 22:56:10 +0000 (UTC) Received: from sulaco.redhat.com (ovpn-112-13.rdu2.redhat.com [10.10.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEC8560BE2; Mon, 23 Dec 2019 22:56:09 +0000 (UTC) From: Tony Asleson To: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [RFC 8/9] ata_dev_printk: Add durable name to output Date: Mon, 23 Dec 2019 16:55:57 -0600 Message-Id: <20191223225558.19242-9-tasleson@redhat.com> In-Reply-To: <20191223225558.19242-1-tasleson@redhat.com> References: <20191223225558.19242-1-tasleson@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org If we have a durable name we will add to output, else we will default to existing message output format. Signed-off-by: Tony Asleson --- drivers/ata/libata-core.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 28c492be0a57..b57a74cfb529 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -7249,6 +7249,9 @@ EXPORT_SYMBOL(ata_link_printk); void ata_dev_printk(const struct ata_device *dev, const char *level, const char *fmt, ...) { + char dict[128]; + int dict_len = 0; + struct va_format vaf; va_list args; @@ -7257,9 +7260,26 @@ 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); + if (dev->sdev) { + dict_len = dev_durable_name( + &dev->sdev->sdev_gendev, + dict, + sizeof(dict)); + } + + if (dict_len > 0) { + printk_emit(0, level[1] - '0', dict, dict_len, + "sata%u.%02u: %pV", + dev->link->ap->print_id, + dev->link->pmp + dev->devno, + &vaf); + } else { + printk("%sata%u.%02u: %pV", + level, + dev->link->ap->print_id, + dev->link->pmp + dev->devno, + &vaf); + } va_end(args); } From patchwork Mon Dec 23 22:55:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Asleson X-Patchwork-Id: 11308857 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 7ECD1138D for ; Mon, 23 Dec 2019 22:56:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5E0622075B for ; Mon, 23 Dec 2019 22:56:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="c7WYowDY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727083AbfLWW4T (ORCPT ); Mon, 23 Dec 2019 17:56:19 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:42950 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727009AbfLWW4Q (ORCPT ); Mon, 23 Dec 2019 17:56:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577141775; 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=vefL+wod3IF0bm304mueY4QtPGsIHZR1kZjIDWRhJoA=; b=c7WYowDYqA1tyoIeLTtg9mflc6bqdbtHR7OorQH4wGmEnSLCJ+0FEMLmn50TC/FFRAjnCO 2v6mMgVSY2/o+wKZ5V2+IL+1ymQ9ie7o07z1I16WklCRIreJvLA7J2xu+A/+RZi1a2AuLo 8hNC2Z/4af35PTif/Gk7lcrgSIZ5+Co= 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-423-GdshT3QoN1GGMMTcbOwoxA-1; Mon, 23 Dec 2019 17:56:13 -0500 X-MC-Unique: GdshT3QoN1GGMMTcbOwoxA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 15643801E74; Mon, 23 Dec 2019 22:56:12 +0000 (UTC) Received: from sulaco.redhat.com (ovpn-112-13.rdu2.redhat.com [10.10.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2558260BE2; Mon, 23 Dec 2019 22:56:10 +0000 (UTC) From: Tony Asleson To: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [RFC 9/9] __xfs_printk: Add durable name to output Date: Mon, 23 Dec 2019 16:55:58 -0600 Message-Id: <20191223225558.19242-10-tasleson@redhat.com> In-Reply-To: <20191223225558.19242-1-tasleson@redhat.com> References: <20191223225558.19242-1-tasleson@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Add persistent durable name to xfs messages so we can correlate them with other messages for the same block device. Signed-off-by: Tony Asleson --- fs/xfs/xfs_message.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/fs/xfs/xfs_message.c b/fs/xfs/xfs_message.c index 9804efe525a9..8447cdd985b4 100644 --- a/fs/xfs/xfs_message.c +++ b/fs/xfs/xfs_message.c @@ -20,6 +20,23 @@ __xfs_printk( const struct xfs_mount *mp, struct va_format *vaf) { + char dict[128]; + int dict_len = 0; + + if (mp && mp->m_super && mp->m_super->s_bdev && + mp->m_super->s_bdev->bd_disk) { + dict_len = dev_durable_name( + disk_to_dev(mp->m_super->s_bdev->bd_disk)->parent, + dict, + sizeof(dict)); + if (dict_len) { + printk_emit( + 0, level[1] - '0', dict, dict_len, + "XFS (%s): %pV\n", mp->m_fsname, vaf); + return; + } + } + if (mp && mp->m_fsname) { printk("%sXFS (%s): %pV\n", level, mp->m_fsname, vaf); return;