mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] nvmet: preserve ANA log page copy errors
@ 2026-10-31  8:35 Sreeraj S Kurup
  2026-10-31  9:34 ` [PATCH v2] " Sreeraj S Kurup
  2026-10-31 12:19 ` Sreeraj S Kurup
  0 siblings, 2 replies; 3+ messages in thread
From: Sreeraj S Kurup @ 2026-10-31  8:35 UTC (permalink / raw)
  To: hare, hch, sagi, kch; +Cc: linux-nvme, linux-kernel, Sreeraj S Kurup

Do not overwrite an error returned while copying ANA
group descriptors with the result of copying the ANA
log page header.

Initialize the status to success before processing
ANA groups and copy the header only if all group
descriptor copies succeed. This ensures that failures
during descriptor copying are correctly reported to
the host.

Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
---
 drivers/nvme/target/admin-cmd.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 26028be8fe4d..2bcb6d3de9ec 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -543,7 +543,7 @@ static void nvmet_execute_get_log_page_ana(struct nvmet_req *req)
 	u16 ngrps = 0;
 	u16 status;
 
-	status = NVME_SC_INTERNAL;
+	status = NVME_SC_SUCCESS;
 	desc = kmalloc_flex(*desc, nsids, NVMET_MAX_NAMESPACES);
 	if (!desc)
 		goto out;
@@ -572,7 +572,8 @@ static void nvmet_execute_get_log_page_ana(struct nvmet_req *req)
 	kfree(desc);
 
 	/* copy the header last once we know the number of groups */
-	status = nvmet_copy_to_sgl(req, 0, &hdr, sizeof(hdr));
+	if (!status)
+		status = nvmet_copy_to_sgl(req, 0, &hdr, sizeof(hdr));
 out:
 	nvmet_req_complete(req, status);
 }
-- 
2.55.0


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

* [PATCH v2] nvmet: preserve ANA log page copy errors
  2026-10-31  8:35 [PATCH] nvmet: preserve ANA log page copy errors Sreeraj S Kurup
@ 2026-10-31  9:34 ` Sreeraj S Kurup
  2026-10-31 12:19 ` Sreeraj S Kurup
  1 sibling, 0 replies; 3+ messages in thread
From: Sreeraj S Kurup @ 2026-10-31  9:34 UTC (permalink / raw)
  To: sreekuttan2156239; +Cc: hare, hch, kch, linux-kernel, linux-nvme, sagi

Preserve errors encountered while copying ANA group
descriptors instead of unconditionally overwriting
them with the result of copying the ANA log page
header.

Ensure that allocation failures are reported correctly
and that short ANA log page reads can still return the
header containing the change count and group count.
Preserve genuine descriptor-copy and header-copy
errors.

Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
---
v2:
 - Preserve the allocation failure status.
 - Handle short ANA log-page reads by checking
   descriptor length against the requested transfer
   length before copying.
 - Preserve genuine descriptor and header copy errors.

 drivers/nvme/target/admin-cmd.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 26028be8fe4d..b0bcfbc94b93 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -542,17 +542,23 @@ static void nvmet_execute_get_log_page_ana(struct nvmet_req *req)
 	u32 grpid;
 	u16 ngrps = 0;
 	u16 status;
+	u16 header_status;
 
 	status = NVME_SC_INTERNAL;
 	desc = kmalloc_flex(*desc, nsids, NVMET_MAX_NAMESPACES);
 	if (!desc)
 		goto out;
 
+	status = NVME_SC_SUCCESS;
+
 	down_read(&nvmet_ana_sem);
 	for (grpid = 1; grpid <= NVMET_MAX_ANAGRPS; grpid++) {
 		if (!nvmet_ana_group_enabled[grpid])
 			continue;
 		len = nvmet_format_ana_group(req, grpid, desc);
+		if (offset > req->transfer_len || len > req->transfer_len - offset)
+			break;
+
 		status = nvmet_copy_to_sgl(req, offset, desc, len);
 		if (status)
 			break;
@@ -572,7 +578,9 @@ static void nvmet_execute_get_log_page_ana(struct nvmet_req *req)
 	kfree(desc);
 
 	/* copy the header last once we know the number of groups */
-	status = nvmet_copy_to_sgl(req, 0, &hdr, sizeof(hdr));
+	header_status = nvmet_copy_to_sgl(req, 0, &hdr, sizeof(hdr));
+	if (!status)
+		status = header_status;
 out:
 	nvmet_req_complete(req, status);
 }
-- 
2.55.0


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

* Re: [PATCH v2] nvmet: preserve ANA log page copy errors
  2026-10-31  8:35 [PATCH] nvmet: preserve ANA log page copy errors Sreeraj S Kurup
  2026-10-31  9:34 ` [PATCH v2] " Sreeraj S Kurup
@ 2026-10-31 12:19 ` Sreeraj S Kurup
  1 sibling, 0 replies; 3+ messages in thread
From: Sreeraj S Kurup @ 2026-10-31 12:19 UTC (permalink / raw)
  To: sreekuttan2156239; +Cc: hare, hch, kch, linux-kernel, linux-nvme, sagi

Hi,

After further investigation, I found that the existing header-copy behavior is intentional for short ANA log-page reads. My proposed changes do not provide a functional fix.

I am withdrawing this patch. Please disregard both versions.

Sorry for the noise.

Thanks,
Sreeraj

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

end of thread, other threads:[~2026-10-31 12:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-31  8:35 [PATCH] nvmet: preserve ANA log page copy errors Sreeraj S Kurup
2026-10-31  9:34 ` [PATCH v2] " Sreeraj S Kurup
2026-10-31 12:19 ` Sreeraj S Kurup

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

all inboxes | Powered by JetHome®