From patchwork Fri Jul 24 17:17:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Asleson X-Patchwork-Id: 1335884 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-ide-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bz9Pd7oI; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4BCwqp4dYZz9sRK for ; Sat, 25 Jul 2020 03:17:26 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726953AbgGXRR0 (ORCPT ); Fri, 24 Jul 2020 13:17:26 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:55462 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726962AbgGXRRX (ORCPT ); Fri, 24 Jul 2020 13:17:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595611042; 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=mODc3efTkpI2zf5Pknz9bXgNLlzTp1vYCCFGuMMO6Cs=; b=bz9Pd7oIe0RNM4oOaPIwB/yxCT/PLlz1A7zzLxfAWYog4obJsPkFYFwZA380gANnzzOE58 2S8Chw3qSqu7Gr6cDpY2Mea4Cc6kuMV9s2RLMtfI33IYaBLsuc9UvEcdpxGHK9S37kl2am rTr9PpR+4qRiNiZU48u6Cpnk9E+mKpE= 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-281-AFtHj5L7PQmK2wkqzuSOOA-1; Fri, 24 Jul 2020 13:17:18 -0400 X-MC-Unique: AFtHj5L7PQmK2wkqzuSOOA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7099318FF662; Fri, 24 Jul 2020 17:17:17 +0000 (UTC) Received: from sulaco.redhat.com (unknown [10.3.128.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 33D8474F64; Fri, 24 Jul 2020 17:17:16 +0000 (UTC) From: Tony Asleson To: linux-block@vger.kernel.org, linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org, b.zolnierkie@samsung.com, axboe@kernel.dk Subject: [v4 05/11] nvme: Add durable name for dev_printk Date: Fri, 24 Jul 2020 12:17:00 -0500 Message-Id: <20200724171706.1550403-6-tasleson@redhat.com> In-Reply-To: <20200724171706.1550403-1-tasleson@redhat.com> References: <20200724171706.1550403-1-tasleson@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@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);