Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme-sysfs: add 'fna' attribute
@ 2024-09-21 15:45 Tokunori Ikegami
  2024-09-22 15:36 ` Keith Busch
  0 siblings, 1 reply; 3+ messages in thread
From: Tokunori Ikegami @ 2024-09-21 15:45 UTC (permalink / raw)
  To: linux-nvme; +Cc: Tokunori Ikegami

The fna attriute is needed for the format NVM command.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
---
 drivers/nvme/host/core.c  |  1 +
 drivers/nvme/host/nvme.h  |  1 +
 drivers/nvme/host/sysfs.c | 13 +++++++++++++
 3 files changed, 15 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index ca9959a8fb9e..0ecb7cbabbed 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3302,6 +3302,7 @@ static int nvme_init_identify(struct nvme_ctrl *ctrl)
 	ctrl->cctemp = le16_to_cpu(id->cctemp);
 
 	atomic_set(&ctrl->abort_limit, id->acl + 1);
+	ctrl->fna = id->fna;
 	ctrl->vwc = id->vwc;
 	if (id->mdts)
 		max_hw_sectors = nvme_mps_to_sectors(ctrl, id->mdts);
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 313a4f978a2c..3df0fbaadb04 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -328,6 +328,7 @@ struct nvme_ctrl {
 	u16 sqsize;
 	u32 max_namespaces;
 	atomic_t abort_limit;
+	u8 fna;
 	u8 vwc;
 	u32 vs;
 	u32 sgls;
diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c
index eb345551d6fe..816a869306df 100644
--- a/drivers/nvme/host/sysfs.c
+++ b/drivers/nvme/host/sysfs.c
@@ -546,6 +546,18 @@ static ssize_t dctype_show(struct device *dev,
 }
 static DEVICE_ATTR_RO(dctype);
 
+static ssize_t fna_show(struct device *dev, struct device_attribute *attr,
+			char *buf)
+{
+	struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
+
+	if (ctrl->fna)
+		return sysfs_emit(buf, "%02x\n", ctrl->fna);
+
+	return 0;
+}
+static DEVICE_ATTR_RO(fna);
+
 #ifdef CONFIG_NVME_HOST_AUTH
 static ssize_t nvme_ctrl_dhchap_secret_show(struct device *dev,
 		struct device_attribute *attr, char *buf)
@@ -687,6 +699,7 @@ static struct attribute *nvme_dev_attrs[] = {
 	&dev_attr_kato.attr,
 	&dev_attr_cntrltype.attr,
 	&dev_attr_dctype.attr,
+	&dev_attr_fna.attr,
 #ifdef CONFIG_NVME_HOST_AUTH
 	&dev_attr_dhchap_secret.attr,
 	&dev_attr_dhchap_ctrl_secret.attr,
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] nvme-sysfs: add 'fna' attribute
  2024-09-21 15:45 [PATCH] nvme-sysfs: add 'fna' attribute Tokunori Ikegami
@ 2024-09-22 15:36 ` Keith Busch
  2024-09-22 18:50   ` Tokunori Ikegami
  0 siblings, 1 reply; 3+ messages in thread
From: Keith Busch @ 2024-09-22 15:36 UTC (permalink / raw)
  To: Tokunori Ikegami; +Cc: linux-nvme

On Sun, Sep 22, 2024 at 12:45:53AM +0900, Tokunori Ikegami wrote:
> The fna attriute is needed for the format NVM command.

At least for multi-namespace subsystems, I would agree knowing this
value is important to understand the potentially undesired reprecussions
of running a format command, but that logic ought to just go in tooling.
And the meaning of the reported value here is not immediately obvious to
a typical user without the spec in front of you, so I'm a little
skeptical on exporting this attribute.

nvme-cli already checks this on a format request, at least. You probably
are not formatting very frequently anyway, so avoiding an identify
command for such a low frequency event seems a bit overkill to me.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] nvme-sysfs: add 'fna' attribute
  2024-09-22 15:36 ` Keith Busch
@ 2024-09-22 18:50   ` Tokunori Ikegami
  0 siblings, 0 replies; 3+ messages in thread
From: Tokunori Ikegami @ 2024-09-22 18:50 UTC (permalink / raw)
  To: Keith Busch; +Cc: linux-nvme

There are many identify commands fields so if the nvme driver can be 
kept the field values seems can be reduced to run many identify 
commands. Thank you.

On 2024/09/23 0:36, Keith Busch wrote:
> At least for multi-namespace subsystems, I would agree knowing this
> value is important to understand the potentially undesired reprecussions
> of running a format command, but that logic ought to just go in tooling.
> And the meaning of the reported value here is not immediately obvious to
> a typical user without the spec in front of you, so I'm a little
> skeptical on exporting this attribute.
>
> nvme-cli already checks this on a format request, at least. You probably
> are not formatting very frequently anyway, so avoiding an identify
> command for such a low frequency event seems a bit overkill to me.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-09-22 18:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-21 15:45 [PATCH] nvme-sysfs: add 'fna' attribute Tokunori Ikegami
2024-09-22 15:36 ` Keith Busch
2024-09-22 18:50   ` Tokunori Ikegami

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox