From: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
To: sreekuttan2156239@gmail.com
Cc: hare@suse.de, hch@lst.de, kch@nvidia.com,
linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org,
sagi@grimberg.me
Subject: [PATCH v2] nvmet: preserve ANA log page copy errors
Date: Sat, 31 Oct 2026 09:34:20 +0000 [thread overview]
Message-ID: <20261031093420.3017-1-sreekuttan2156239@gmail.com> (raw)
In-Reply-To: <20261031083505.4767-1-sreekuttan2156239@gmail.com>
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
next prev parent reply other threads:[~2026-10-31 9:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-31 8:35 [PATCH] " Sreeraj S Kurup
2026-10-31 9:34 ` Sreeraj S Kurup [this message]
2026-10-31 12:19 ` [PATCH v2] " Sreeraj S Kurup
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261031093420.3017-1-sreekuttan2156239@gmail.com \
--to=sreekuttan2156239@gmail.com \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=kch@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®