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

The lbaf_index attriute is needed for the format NVM command.
This is to reduce the identify commands to get the information.

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

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index ca9959a8fb9e..2cc9876322e6 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1909,7 +1909,7 @@ static void nvme_configure_metadata(struct nvme_ctrl *ctrl,
 	head->features &= ~(NVME_NS_METADATA_SUPPORTED | NVME_NS_EXT_LBAS);
 	head->pi_type = 0;
 	head->pi_size = 0;
-	head->ms = le16_to_cpu(id->lbaf[nvme_lbaf_index(id->flbas)].ms);
+	head->ms = le16_to_cpu(id->lbaf[head->lbaf_index].ms);
 	if (!head->ms || !(ctrl->ops->flags & NVME_F_METADATA_SUPPORTED))
 		return;
 
@@ -2151,7 +2151,8 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
 	}
 
 	blk_mq_freeze_queue(ns->disk->queue);
-	ns->head->lba_shift = id->lbaf[lbaf].ds;
+	ns->head->lbaf_index = lbaf;
+	ns->head->lba_shift = id->lbaf[ns->head->lbaf_index].ds;
 	ns->head->nuse = le64_to_cpu(id->nuse);
 	capacity = nvme_lba_to_sect(ns->head, le64_to_cpu(id->nsze));
 
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 313a4f978a2c..fb1d7c812135 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -483,6 +483,7 @@ struct nvme_ns_head {
 	u64			zsze;
 #endif
 	unsigned long		features;
+	u8			lbaf_index;
 
 	struct ratelimit_state	rs_nuse;
 
diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c
index eb345551d6fe..108b6eda07dc 100644
--- a/drivers/nvme/host/sysfs.c
+++ b/drivers/nvme/host/sysfs.c
@@ -246,6 +246,12 @@ static ssize_t nuse_show(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR_RO(nuse);
 
+static ssize_t lbaf_index_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	return sysfs_emit(buf, "%u\n", dev_to_ns_head(dev)->lbaf_index);
+}
+static DEVICE_ATTR_RO(lbaf_index);
+
 static struct attribute *nvme_ns_attrs[] = {
 	&dev_attr_wwid.attr,
 	&dev_attr_uuid.attr,
@@ -255,6 +261,7 @@ static struct attribute *nvme_ns_attrs[] = {
 	&dev_attr_nsid.attr,
 	&dev_attr_metadata_bytes.attr,
 	&dev_attr_nuse.attr,
+	&dev_attr_lbaf_index.attr,
 #ifdef CONFIG_NVME_MULTIPATH
 	&dev_attr_ana_grpid.attr,
 	&dev_attr_ana_state.attr,
-- 
2.43.0



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

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

On Sun, Sep 22, 2024 at 02:38:18PM +0900, Tokunori Ikegami wrote:
> The lbaf_index attriute is needed for the format NVM command.
> This is to reduce the identify commands to get the information.

I'm not sure how knowing this is particularly useful. You'd have to run
the identify namespace command anyway to understand the significance of
what the index tells you.


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

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

The format command only uses the LBAF index so the attribute can be used 
by the command. About the LBAFs list I will do consider to add into the 
ns attribute, etc. if needed later. Thank you.

On 2024/09/23 0:29, Keith Busch wrote:
> On Sun, Sep 22, 2024 at 02:38:18PM +0900, Tokunori Ikegami wrote:
>> The lbaf_index attriute is needed for the format NVM command.
>> This is to reduce the identify commands to get the information.
> I'm not sure how knowing this is particularly useful. You'd have to run
> the identify namespace command anyway to understand the significance of
> what the index tells you.


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

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

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-22  5:38 [PATCH] nvme-sysfs: add 'lbaf_index' ns attribute Tokunori Ikegami
2024-09-22 15:29 ` Keith Busch
2024-09-22 18:44   ` Tokunori Ikegami

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