[RFC,v3,7/8] nvme: Add durable name for dev_printk
diff mbox series

Message ID 20200623191749.115200-8-tasleson@redhat.com
State New
Headers show
Series
  • Add persistent durable identifier to storage log messages
Related show

Commit Message

Tony Asleson June 23, 2020, 7:17 p.m. UTC
Corrections from Keith Busch review comments.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
---
 drivers/nvme/host/core.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Chaitanya Kulkarni June 23, 2020, 8:04 p.m. UTC | #1
On 6/23/20 12:18 PM, Tony Asleson wrote:
> Corrections from Keith Busch review comments.
> 
> Signed-off-by: Tony Asleson<tasleson@redhat.com>
> ---
>   drivers/nvme/host/core.c | 18 ++++++++++++++++++
>   1 file changed, 18 insertions(+)
This looks useful me, but why you still have an RFC fag ?
Tony Asleson June 23, 2020, 8:32 p.m. UTC | #2
On 6/23/20 3:04 PM, Chaitanya Kulkarni wrote:
> On 6/23/20 12:18 PM, Tony Asleson wrote:
>> Corrections from Keith Busch review comments.
>>
>> Signed-off-by: Tony Asleson<tasleson@redhat.com>
>> ---
>>   drivers/nvme/host/core.c | 18 ++++++++++++++++++
>>   1 file changed, 18 insertions(+)
> This looks useful me, but why you still have an RFC fag ?

I have some questions in the cover letter that I was thinking should be
discussed before removing RFC, but maybe I'm going about this the wrong
way and should remove that?

Patch
diff mbox series

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);