* [PATCH 1/2] nvme: allow to force refresh of effects log
@ 2020-11-11 12:46 ` javier
0 siblings, 0 replies; 4+ messages in thread
From: javier @ 2020-11-11 12:46 UTC (permalink / raw)
To: linux-nvme
Cc: linux-block, hch, kbusch, sagi, axboe, joshi.k, k.jensen,
Niklas.Cassel, Javier González
From: Javier González <javier.gonz@samsung.com>
Allow the called of nvme_get_effects_log() to force re-reading the log
page from the device instead of getting the cached version when
available.
Signed-off-by: Javier González <javier.gonz@samsung.com>
---
drivers/nvme/host/core.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index fff90200497c..e4c79f1d2e96 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2951,18 +2951,20 @@ int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp, u8 csi,
return nvme_submit_sync_cmd(ctrl->admin_q, &c, log, size);
}
-static int nvme_get_effects_log(struct nvme_ctrl *ctrl, u8 csi,
- struct nvme_effects_log **log)
+static int nvme_get_effects_log(struct nvme_ctrl *ctrl, u8 csi, struct nvme_effects_log **log,
+ bool force)
{
struct nvme_cel *cel = xa_load(&ctrl->cels, csi);
int ret;
- if (cel)
+ if (cel && !force)
goto out;
- cel = kzalloc(sizeof(*cel), GFP_KERNEL);
- if (!cel)
- return -ENOMEM;
+ if (!cel) {
+ cel = kzalloc(sizeof(*cel), GFP_KERNEL);
+ if (!cel)
+ return -ENOMEM;
+ }
ret = nvme_get_log(ctrl, 0x00, NVME_LOG_CMD_EFFECTS, 0, csi,
&cel->log, sizeof(cel->log), 0);
@@ -3008,7 +3010,7 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
}
if (id->lpa & NVME_CTRL_LPA_CMD_EFFECTS_LOG) {
- ret = nvme_get_effects_log(ctrl, NVME_CSI_NVM, &ctrl->effects);
+ ret = nvme_get_effects_log(ctrl, NVME_CSI_NVM, &ctrl->effects, false);
if (ret < 0)
goto out_free;
}
@@ -3725,7 +3727,7 @@ static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ctrl *ctrl,
}
if (head->ids.csi) {
- ret = nvme_get_effects_log(ctrl, head->ids.csi, &head->effects);
+ ret = nvme_get_effects_log(ctrl, head->ids.csi, &head->effects, false);
if (ret)
goto out_cleanup_srcu;
} else
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 1/2] nvme: allow to force refresh of effects log
@ 2020-11-11 12:46 ` javier
0 siblings, 0 replies; 4+ messages in thread
From: javier @ 2020-11-11 12:46 UTC (permalink / raw)
To: linux-nvme
Cc: axboe, Niklas.Cassel, sagi, joshi.k, k.jensen, linux-block,
kbusch, Javier González, hch
From: Javier González <javier.gonz@samsung.com>
Allow the called of nvme_get_effects_log() to force re-reading the log
page from the device instead of getting the cached version when
available.
Signed-off-by: Javier González <javier.gonz@samsung.com>
---
drivers/nvme/host/core.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index fff90200497c..e4c79f1d2e96 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2951,18 +2951,20 @@ int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp, u8 csi,
return nvme_submit_sync_cmd(ctrl->admin_q, &c, log, size);
}
-static int nvme_get_effects_log(struct nvme_ctrl *ctrl, u8 csi,
- struct nvme_effects_log **log)
+static int nvme_get_effects_log(struct nvme_ctrl *ctrl, u8 csi, struct nvme_effects_log **log,
+ bool force)
{
struct nvme_cel *cel = xa_load(&ctrl->cels, csi);
int ret;
- if (cel)
+ if (cel && !force)
goto out;
- cel = kzalloc(sizeof(*cel), GFP_KERNEL);
- if (!cel)
- return -ENOMEM;
+ if (!cel) {
+ cel = kzalloc(sizeof(*cel), GFP_KERNEL);
+ if (!cel)
+ return -ENOMEM;
+ }
ret = nvme_get_log(ctrl, 0x00, NVME_LOG_CMD_EFFECTS, 0, csi,
&cel->log, sizeof(cel->log), 0);
@@ -3008,7 +3010,7 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
}
if (id->lpa & NVME_CTRL_LPA_CMD_EFFECTS_LOG) {
- ret = nvme_get_effects_log(ctrl, NVME_CSI_NVM, &ctrl->effects);
+ ret = nvme_get_effects_log(ctrl, NVME_CSI_NVM, &ctrl->effects, false);
if (ret < 0)
goto out_free;
}
@@ -3725,7 +3727,7 @@ static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ctrl *ctrl,
}
if (head->ids.csi) {
- ret = nvme_get_effects_log(ctrl, head->ids.csi, &head->effects);
+ ret = nvme_get_effects_log(ctrl, head->ids.csi, &head->effects, false);
if (ret)
goto out_cleanup_srcu;
} else
--
2.17.1
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] nvme: enable ro namespace for ZNS without append
2020-11-11 12:46 ` javier
@ 2020-11-11 12:46 ` javier
-1 siblings, 0 replies; 4+ messages in thread
From: javier @ 2020-11-11 12:46 UTC (permalink / raw)
To: linux-nvme
Cc: linux-block, hch, kbusch, sagi, axboe, joshi.k, k.jensen,
Niklas.Cassel, Javier González
From: Javier González <javier.gonz@samsung.com>
Allow ZNS NVMe SSDs to present a read-only namespace when append is not
supported, instead of rejecting the namespace directly.
This allows (i) the namespace to be used in read-only mode, which is not
a problem as the append command only affects the write path, and (ii) to
use standard management tools such as nvme-cli to choose a different
format or firmware slot that is compatible with the Linux zoned block
device.
This patch includes comments from Christoph, Niklas and Keith that
applied to a different approach setting capacity to 0
https://www.spinics.net/lists/linux-block/msg60747.html
The reminder of the original patch will be submitted separately.
Changes since V3:
- Force re-reading effects log page (from Keith)
- Pending proper refresh of RO flag - dependency on patch from Christoph
Changes since V2:
- Fix small conflict with a queued patch from Sagi (from Christoph)
- Fix indentation (from Niklas)
- Refresh effects log page to account for FW changes (from Keith)
Changes since V1:
- Change logic to use NVME_NS_ATTR_RO (from Christoph)
- Set max_zone_append egen in RO. This allows the device to be
properly revalidated and enables user-space tools such as blkzone to
be used when interacting with this zoned device.
Signed-off-by: Javier González <javier.gonz@samsung.com>
---
drivers/nvme/host/core.c | 5 ++---
drivers/nvme/host/nvme.h | 2 ++
drivers/nvme/host/zns.c | 19 ++++++++++++++-----
3 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index e4c79f1d2e96..170745d4a34b 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2083,7 +2083,7 @@ static void nvme_update_disk_info(struct gendisk *disk,
nvme_config_discard(disk, ns);
nvme_config_write_zeroes(disk, ns);
- if (id->nsattr & NVME_NS_ATTR_RO)
+ if (id->nsattr & NVME_NS_ATTR_RO || test_bit(NVME_NS_FORCE_RO, &ns->flags))
set_disk_ro(disk, true);
}
@@ -2951,8 +2951,7 @@ int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp, u8 csi,
return nvme_submit_sync_cmd(ctrl->admin_q, &c, log, size);
}
-static int nvme_get_effects_log(struct nvme_ctrl *ctrl, u8 csi, struct nvme_effects_log **log,
- bool force)
+int nvme_get_effects_log(struct nvme_ctrl *ctrl, u8 csi, struct nvme_effects_log **log, bool force)
{
struct nvme_cel *cel = xa_load(&ctrl->cels, csi);
int ret;
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 83fb30e317e0..cdfce7250da0 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -449,6 +449,7 @@ struct nvme_ns {
#define NVME_NS_REMOVING 0
#define NVME_NS_DEAD 1
#define NVME_NS_ANA_PENDING 2
+#define NVME_NS_FORCE_RO 3
struct nvme_fault_inject fault_inject;
@@ -638,6 +639,7 @@ int nvme_delete_ctrl(struct nvme_ctrl *ctrl);
int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp, u8 csi,
void *log, size_t size, u64 offset);
+int nvme_get_effects_log(struct nvme_ctrl *ctrl, u8 csi, struct nvme_effects_log **log, bool force);
struct nvme_ns *nvme_get_ns_from_disk(struct gendisk *disk,
struct nvme_ns_head **head, int *srcu_idx);
void nvme_put_ns_from_disk(struct nvme_ns_head *head, int idx);
diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c
index 67e87e9f306f..dfd1c38b95d4 100644
--- a/drivers/nvme/host/zns.c
+++ b/drivers/nvme/host/zns.c
@@ -54,13 +54,22 @@ int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf)
struct nvme_id_ns_zns *id;
int status;
+ /* Refresh effects log page to check for changes on append support */
+ status = nvme_get_effects_log(ns->ctrl, ns->head->ids.csi, &ns->head->effects, true);
+ if (status)
+ return status;
+
/* Driver requires zone append support */
- if (!(le32_to_cpu(log->iocs[nvme_cmd_zone_append]) &
- NVME_CMD_EFFECTS_CSUPP)) {
+ if ((le32_to_cpu(log->iocs[nvme_cmd_zone_append]) & NVME_CMD_EFFECTS_CSUPP)) {
+ if (test_and_clear_bit(NVME_NS_FORCE_RO, &ns->flags))
+ dev_warn(ns->ctrl->device,
+ "append supported for zoned namespace:%d. Remove read-only mode\n",
+ ns->head->ns_id);
+ } else {
+ set_bit(NVME_NS_FORCE_RO, &ns->flags);
dev_warn(ns->ctrl->device,
- "append not supported for zoned namespace:%d\n",
- ns->head->ns_id);
- return -EINVAL;
+ "append not supported for zoned namespace:%d. Forcing to read-only mode\n",
+ ns->head->ns_id);
}
/* Lazily query controller append limit for the first zoned namespace */
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] nvme: enable ro namespace for ZNS without append
@ 2020-11-11 12:46 ` javier
0 siblings, 0 replies; 4+ messages in thread
From: javier @ 2020-11-11 12:46 UTC (permalink / raw)
To: linux-nvme
Cc: axboe, Niklas.Cassel, sagi, joshi.k, k.jensen, linux-block,
kbusch, Javier González, hch
From: Javier González <javier.gonz@samsung.com>
Allow ZNS NVMe SSDs to present a read-only namespace when append is not
supported, instead of rejecting the namespace directly.
This allows (i) the namespace to be used in read-only mode, which is not
a problem as the append command only affects the write path, and (ii) to
use standard management tools such as nvme-cli to choose a different
format or firmware slot that is compatible with the Linux zoned block
device.
This patch includes comments from Christoph, Niklas and Keith that
applied to a different approach setting capacity to 0
https://www.spinics.net/lists/linux-block/msg60747.html
The reminder of the original patch will be submitted separately.
Changes since V3:
- Force re-reading effects log page (from Keith)
- Pending proper refresh of RO flag - dependency on patch from Christoph
Changes since V2:
- Fix small conflict with a queued patch from Sagi (from Christoph)
- Fix indentation (from Niklas)
- Refresh effects log page to account for FW changes (from Keith)
Changes since V1:
- Change logic to use NVME_NS_ATTR_RO (from Christoph)
- Set max_zone_append egen in RO. This allows the device to be
properly revalidated and enables user-space tools such as blkzone to
be used when interacting with this zoned device.
Signed-off-by: Javier González <javier.gonz@samsung.com>
---
drivers/nvme/host/core.c | 5 ++---
drivers/nvme/host/nvme.h | 2 ++
drivers/nvme/host/zns.c | 19 ++++++++++++++-----
3 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index e4c79f1d2e96..170745d4a34b 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2083,7 +2083,7 @@ static void nvme_update_disk_info(struct gendisk *disk,
nvme_config_discard(disk, ns);
nvme_config_write_zeroes(disk, ns);
- if (id->nsattr & NVME_NS_ATTR_RO)
+ if (id->nsattr & NVME_NS_ATTR_RO || test_bit(NVME_NS_FORCE_RO, &ns->flags))
set_disk_ro(disk, true);
}
@@ -2951,8 +2951,7 @@ int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp, u8 csi,
return nvme_submit_sync_cmd(ctrl->admin_q, &c, log, size);
}
-static int nvme_get_effects_log(struct nvme_ctrl *ctrl, u8 csi, struct nvme_effects_log **log,
- bool force)
+int nvme_get_effects_log(struct nvme_ctrl *ctrl, u8 csi, struct nvme_effects_log **log, bool force)
{
struct nvme_cel *cel = xa_load(&ctrl->cels, csi);
int ret;
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 83fb30e317e0..cdfce7250da0 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -449,6 +449,7 @@ struct nvme_ns {
#define NVME_NS_REMOVING 0
#define NVME_NS_DEAD 1
#define NVME_NS_ANA_PENDING 2
+#define NVME_NS_FORCE_RO 3
struct nvme_fault_inject fault_inject;
@@ -638,6 +639,7 @@ int nvme_delete_ctrl(struct nvme_ctrl *ctrl);
int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp, u8 csi,
void *log, size_t size, u64 offset);
+int nvme_get_effects_log(struct nvme_ctrl *ctrl, u8 csi, struct nvme_effects_log **log, bool force);
struct nvme_ns *nvme_get_ns_from_disk(struct gendisk *disk,
struct nvme_ns_head **head, int *srcu_idx);
void nvme_put_ns_from_disk(struct nvme_ns_head *head, int idx);
diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c
index 67e87e9f306f..dfd1c38b95d4 100644
--- a/drivers/nvme/host/zns.c
+++ b/drivers/nvme/host/zns.c
@@ -54,13 +54,22 @@ int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf)
struct nvme_id_ns_zns *id;
int status;
+ /* Refresh effects log page to check for changes on append support */
+ status = nvme_get_effects_log(ns->ctrl, ns->head->ids.csi, &ns->head->effects, true);
+ if (status)
+ return status;
+
/* Driver requires zone append support */
- if (!(le32_to_cpu(log->iocs[nvme_cmd_zone_append]) &
- NVME_CMD_EFFECTS_CSUPP)) {
+ if ((le32_to_cpu(log->iocs[nvme_cmd_zone_append]) & NVME_CMD_EFFECTS_CSUPP)) {
+ if (test_and_clear_bit(NVME_NS_FORCE_RO, &ns->flags))
+ dev_warn(ns->ctrl->device,
+ "append supported for zoned namespace:%d. Remove read-only mode\n",
+ ns->head->ns_id);
+ } else {
+ set_bit(NVME_NS_FORCE_RO, &ns->flags);
dev_warn(ns->ctrl->device,
- "append not supported for zoned namespace:%d\n",
- ns->head->ns_id);
- return -EINVAL;
+ "append not supported for zoned namespace:%d. Forcing to read-only mode\n",
+ ns->head->ns_id);
}
/* Lazily query controller append limit for the first zoned namespace */
--
2.17.1
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-11-11 12:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-11 12:46 [PATCH 1/2] nvme: allow to force refresh of effects log javier
2020-11-11 12:46 ` javier
2020-11-11 12:46 ` [PATCH 2/2] nvme: enable ro namespace for ZNS without append javier
2020-11-11 12:46 ` javier
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.