From: Stefan Hajnoczi <stefanha@redhat.com>
To: Changqi Lu <luchangqi.123@bytedance.com>
Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, kwolf@redhat.com,
hreitz@redhat.com, fam@euphon.net, ronniesahlberg@gmail.com,
pbonzini@redhat.com, pl@dlhnet.de, kbusch@kernel.org,
its@irrelevant.dk, foss@defmacro.it, philmd@linaro.org,
pizhenwei@bytedance.com, Klaus Jensen <k.jensen@samsung.com>
Subject: Re: [PATCH v8 09/10] hw/nvme: add reservation protocal command
Date: Thu, 11 Jul 2024 15:24:06 +0200 [thread overview]
Message-ID: <20240711132406.GF16124@fedora.home> (raw)
In-Reply-To: <20240709024706.4108-10-luchangqi.123@bytedance.com>
[-- Attachment #1: Type: text/plain, Size: 3913 bytes --]
On Tue, Jul 09, 2024 at 10:47:05AM +0800, Changqi Lu wrote:
> Add reservation acquire, reservation register,
> reservation release and reservation report commands
> in the nvme device layer.
>
> By introducing these commands, this enables the nvme
> device to perform reservation-related tasks, including
> querying keys, querying reservation status, registering
> reservation keys, initiating and releasing reservations,
> as well as clearing and preempting reservations held by
> other keys.
>
> These commands are crucial for management and control of
> shared storage resources in a persistent manner.
> Signed-off-by: Changqi Lu <luchangqi.123@bytedance.com>
> Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
> Acked-by: Klaus Jensen <k.jensen@samsung.com>
> ---
> hw/nvme/ctrl.c | 323 ++++++++++++++++++++++++++++++++++++++++++-
> hw/nvme/nvme.h | 4 +
> include/block/nvme.h | 37 +++++
> 3 files changed, 363 insertions(+), 1 deletion(-)
>
> diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
> index ad212de723..a69a499078 100644
> --- a/hw/nvme/ctrl.c
> +++ b/hw/nvme/ctrl.c
> @@ -294,6 +294,10 @@ static const uint32_t nvme_cse_iocs_nvm[256] = {
> [NVME_CMD_COMPARE] = NVME_CMD_EFF_CSUPP,
> [NVME_CMD_IO_MGMT_RECV] = NVME_CMD_EFF_CSUPP,
> [NVME_CMD_IO_MGMT_SEND] = NVME_CMD_EFF_CSUPP | NVME_CMD_EFF_LBCC,
> + [NVME_CMD_RESV_REGISTER] = NVME_CMD_EFF_CSUPP,
> + [NVME_CMD_RESV_REPORT] = NVME_CMD_EFF_CSUPP,
> + [NVME_CMD_RESV_ACQUIRE] = NVME_CMD_EFF_CSUPP,
> + [NVME_CMD_RESV_RELEASE] = NVME_CMD_EFF_CSUPP,
> };
>
> static const uint32_t nvme_cse_iocs_zoned[256] = {
> @@ -308,6 +312,10 @@ static const uint32_t nvme_cse_iocs_zoned[256] = {
> [NVME_CMD_ZONE_APPEND] = NVME_CMD_EFF_CSUPP | NVME_CMD_EFF_LBCC,
> [NVME_CMD_ZONE_MGMT_SEND] = NVME_CMD_EFF_CSUPP | NVME_CMD_EFF_LBCC,
> [NVME_CMD_ZONE_MGMT_RECV] = NVME_CMD_EFF_CSUPP,
> + [NVME_CMD_RESV_REGISTER] = NVME_CMD_EFF_CSUPP,
> + [NVME_CMD_RESV_REPORT] = NVME_CMD_EFF_CSUPP,
> + [NVME_CMD_RESV_ACQUIRE] = NVME_CMD_EFF_CSUPP,
> + [NVME_CMD_RESV_RELEASE] = NVME_CMD_EFF_CSUPP,
> };
>
> static void nvme_process_sq(void *opaque);
> @@ -1745,6 +1753,7 @@ static void nvme_aio_err(NvmeRequest *req, int ret)
>
> switch (req->cmd.opcode) {
> case NVME_CMD_READ:
> + case NVME_CMD_RESV_REPORT:
> status = NVME_UNRECOVERED_READ;
> break;
> case NVME_CMD_FLUSH:
> @@ -1752,6 +1761,9 @@ static void nvme_aio_err(NvmeRequest *req, int ret)
> case NVME_CMD_WRITE_ZEROES:
> case NVME_CMD_ZONE_APPEND:
> case NVME_CMD_COPY:
> + case NVME_CMD_RESV_REGISTER:
> + case NVME_CMD_RESV_ACQUIRE:
> + case NVME_CMD_RESV_RELEASE:
> status = NVME_WRITE_FAULT;
> break;
> default:
> @@ -2127,7 +2139,10 @@ static inline bool nvme_is_write(NvmeRequest *req)
>
> return rw->opcode == NVME_CMD_WRITE ||
> rw->opcode == NVME_CMD_ZONE_APPEND ||
> - rw->opcode == NVME_CMD_WRITE_ZEROES;
> + rw->opcode == NVME_CMD_WRITE_ZEROES ||
> + rw->opcode == NVME_CMD_RESV_REGISTER ||
> + rw->opcode == NVME_CMD_RESV_ACQUIRE ||
> + rw->opcode == NVME_CMD_RESV_RELEASE;
> }
Why is this change necessary? The only nvme_is_write() caller I see is:
void nvme_rw_complete_cb(void *opaque, int ret)
{
...
if (ns->params.zoned && nvme_is_write(req)) {
nvme_finalize_zoned_write(ns, req);
}
nvme_finalize_zoned_write() must not be called on reservation requests
because they don't use NvmeRwCmd:
static void nvme_finalize_zoned_write(NvmeNamespace *ns, NvmeRequest *req)
{
NvmeRwCmd *rw = (NvmeRwCmd *)&req->cmd;
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2024-07-11 13:24 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-09 2:46 [PATCH v8 00/10] Support persistent reservation operations Changqi Lu
2024-07-09 2:46 ` [PATCH v8 01/10] block: add persistent reservation in/out api Changqi Lu
2024-07-09 2:46 ` [PATCH v8 02/10] block/raw: add persistent reservation in/out driver Changqi Lu
2024-07-09 2:46 ` [PATCH v8 03/10] scsi/constant: add persistent reservation in/out protocol constants Changqi Lu
2024-07-09 2:47 ` [PATCH v8 04/10] scsi/util: add helper functions for persistent reservation types conversion Changqi Lu
2024-07-09 2:47 ` [PATCH v8 05/10] hw/scsi: add persistent reservation in/out api for scsi device Changqi Lu
2024-07-11 13:01 ` Stefan Hajnoczi
2024-07-09 2:47 ` [PATCH v8 06/10] block/nvme: add reservation command protocol constants Changqi Lu
2024-07-09 2:47 ` [PATCH v8 07/10] hw/nvme: add helper functions for converting reservation types Changqi Lu
2024-07-09 2:47 ` [PATCH v8 08/10] hw/nvme: enable ONCS and rescap function Changqi Lu
2024-07-11 13:01 ` Stefan Hajnoczi
2024-07-09 2:47 ` [PATCH v8 09/10] hw/nvme: add reservation protocal command Changqi Lu
2024-07-11 13:24 ` Stefan Hajnoczi [this message]
2024-07-09 2:47 ` [PATCH v8 10/10] block/iscsi: add persistent reservation in/out driver Changqi Lu
2024-07-11 13:04 ` Stefan Hajnoczi
2024-07-11 13:05 ` Stefan Hajnoczi
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=20240711132406.GF16124@fedora.home \
--to=stefanha@redhat.com \
--cc=fam@euphon.net \
--cc=foss@defmacro.it \
--cc=hreitz@redhat.com \
--cc=its@irrelevant.dk \
--cc=k.jensen@samsung.com \
--cc=kbusch@kernel.org \
--cc=kwolf@redhat.com \
--cc=luchangqi.123@bytedance.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=pizhenwei@bytedance.com \
--cc=pl@dlhnet.de \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=ronniesahlberg@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).