nvmet: Fix discover log page when offsets are used
Subsystems (2)
PATCH v3 1/1 nvmet: Fix discover log page when offsets are used
The nvme target hadn't been taking the Get Log Page offset parameter into consideration, and so has been returning corrupted log pages when offsets are used. Since many tools, including nvme-cli, split the log request to 4k, we've been breaking discovery log responses when more than 3 subsystems exist.
Fix the returned data by internally generating the entire discovery log page and copying only the requested bytes into the user buffer. The command log page offset type has been modified to a native __le64 to make it easier to extract the value from a command.
---
v2 -> v3:
Make entry counting return the consistent type (Chaitanya)
Comment on dword aligned offset (Chaitanya)
Simplified obtaining the offset by using a native le64 type (Christoph, Bart)
Updated change log
drivers/nvme/target/admin-cmd.c | 5 +++ drivers/nvme/target/discovery.c | 68 +++++++++++++++++++++++++++-------------- drivers/nvme/target/nvmet.h | 1 + include/linux/nvme.h | 9 ++++-- 4 files changed, 58 insertions(+), 25 deletions(-)
drivers/nvme/target/admin-cmd.c +5 -0
@@ -24,6 +24,11 @@ u32 nvmet_get_log_page_len(struct nvme_command *cmd)return len; } +u64 nvmet_get_log_page_offset (struct nvme_command *cmd) +{ +return le64_to_cpu (cmd->get_log_page.lpo); +} +static void nvmet_execute_get_log_page_noop (struct nvmet_req *req) {nvmet_req_complete (req,nvmet_zero_sgl (req,0 , req->data_len));
drivers/nvme/target/discovery.c +45 -23
107 lines not on this page · raw message
drivers/nvme/target/nvmet.h +1 -0
@@ -428,6 +428,7 @@ u16 nvmet_copy_from_sgl(struct nvmet_req *req, off_t off, void *buf,u16 nvmet_zero_sgl (struct nvmet_req *req,off_t off,size_t len);u32 nvmet_get_log_page_len (struct nvme_command *cmd); +u64 nvmet_get_log_page_offset (struct nvme_command *cmd);extern struct list_head *nvmet_ports; void nvmet_port_disc_changed(struct nvmet_port *port,
include/linux/nvme.h +7 -2
@@ -967,8 +967,13 @@ struct nvme_get_log_page_command {__le16 numdl;__le16 numdu;__u16 rsvd11; -__le32 lpol; -__le32 lpou; +union { +struct { +__le32 lpol; +__le32 lpou; + }; +__le64 lpo; + };__u32 rsvd14[2 ]; };
Signature · 1 line
2.14.4
PATCH v3 1/1 nvmet: Fix discover log page when offsets are used
I have tested this patch based on nvme-5.1 branch with over the 6 entries of Discovery Log entries.
Thanks,
PATCH v3 1/1 nvmet: Fix discover log page when offsets are used
In reply to Keith BuschQuoted 24 lines · Keith Busch
The nvme target hadn't been taking the Get Log Page offset parameter into consideration, and so has been returning corrupted log pages when offsets are used. Since many tools, including nvme-cli, split the log request to 4k, we've been breaking discovery log responses when more than 3 subsystems exist.
Fix the returned data by internally generating the entire discovery log page and copying only the requested bytes into the user buffer. The command log page offset type has been modified to a native
__le64to make it easier to extract the value from a command.Cc Hannes Reinecke <hare at suse.de>Reviewed-by James Smart <james.smart at broadcom.com>Signed-off-by Keith Busch <keith.busch at intel.com>---
v2 -> v3:Make entry counting return the consistent type (Chaitanya)
Comment on dword aligned offset (Chaitanya)
Simplified obtaining the offset by using a native le64 type (Christoph, Bart)
Quoted 8 lines
Updated change log
drivers/nvme/target/admin-cmd.c | 5 +++ drivers/nvme/target/discovery.c | 68 +++++++++++++++++++++++++++-------------- drivers/nvme/target/nvmet.h | 1 + include/linux/nvme.h | 9 ++++-- 4 files changed, 58 insertions(+), 25 deletions(-)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking hare at suse.de +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg GF: Felix Imend?rffer, Mary Higgins, Sri Rasiah HRB 21284 (AG N?rnberg)
PATCH v3 1/1 nvmet: Fix discover log page when offsets are used
In reply to Keith BuschThanks,
applied to nvme-5.1.