Message ID | 20200724171706.1550403-6-tasleson@redhat.com |
---|---|
State | Not Applicable |
Delegated to: | David Miller |
Headers | show |
Series | Add persistent durable identifier to storage log messages | expand |
Hello! On 24.07.2020 20:17, 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(+) > > 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 */ serial_len-- instead? > + 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_sub [...] MBR, Sergei
On Fri, Jul 24, 2020 at 8:19 PM Tony Asleson <tasleson@redhat.com> wrote: > > Corrections from Keith Busch review comments. Good! And where is the commit message? > +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; > +} Sorry, but this is ugly. Can we rather get some common code from wwid_show() and reuse it there and here w/o above dances with \n?
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);
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(+)