[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v12 09/10] hw/nvme: add reservation protocal command
From: |
Stefan Hajnoczi |
Subject: |
Re: [PATCH v12 09/10] hw/nvme: add reservation protocal command |
Date: |
Fri, 13 Sep 2024 16:49:25 -0400 |
On Thu, Sep 12, 2024 at 07:19:16PM +0800, Changqi Lu wrote:
> +static int nvme_read_reservation_cb(NvmeReadReservation *reservation)
> +{
> + int rc;
> + NvmeReservationStatus *nvme_status;
> + NvmeRequest *req = reservation->req;
> + NvmeCtrl *n = req->sq->ctrl;
> + NvmeResvKeys *keys_info = reservation->keys_info;
> + int len = sizeof(NvmeReservationStatusHeader) +
> + sizeof(NvmeRegisteredCtrl) * keys_info->num_keys;
> +
> + nvme_status = g_malloc(len);
> + nvme_status->header.gen = reservation->generation;
> + nvme_status->header.rtype = block_pr_type_to_nvme(reservation->type);
> + nvme_status->header.regctl = keys_info->num_keys;
> + for (int i = 0; i < keys_info->num_keys; i++) {
> + nvme_status->regctl_ds[i].cntlid = nvme_ctrl(req)->cntlid;
> + nvme_status->regctl_ds[i].rkey = keys_info->keys[i];
> + nvme_status->regctl_ds[i].rcsts = keys_info->keys[i] ==
> + reservation->key ? 1 : 0;
Missing byte swaps? I see byte swaps in nvme_read_reservation_ext_cb().
> + /* hostid is not supported currently */
> + memset(&nvme_status->regctl_ds[i].hostid, 0, 8);
> + }
> +
> + rc = nvme_c2h(n, (uint8_t *)nvme_status, len, req);
> + g_free(nvme_status);
> + return rc;
> +}
> +
> +static int nvme_read_reservation_ext_cb(NvmeReadReservation *reservation)
> +{
> + int rc;
> + NvmeReservationStatusExt *nvme_status_ext;
> + NvmeRequest *req = reservation->req;
> + NvmeCtrl *n = req->sq->ctrl;
> + NvmeResvKeys *keys_info = reservation->keys_info;
> + int len = sizeof(NvmeReservationStatusHeader) +
> + sizeof(uint8_t) * 40 +
> + sizeof(NvmeRegisteredCtrlExt) * keys_info->num_keys;
> +
> + nvme_status_ext = g_malloc(len);
> + nvme_status_ext->header.gen = cpu_to_be32(reservation->generation);
> + nvme_status_ext->header.rtype = block_pr_type_to_nvme(reservation->type);
> + nvme_status_ext->header.regctl = cpu_to_be16(keys_info->num_keys);
> +
> + for (int i = 0; i < keys_info->num_keys; i++) {
> + uint16_t ctnlid = nvme_ctrl(req)->cntlid;
> + nvme_status_ext->regctl_eds[i].cntlid = cpu_to_be16(ctnlid);
> + nvme_status_ext->regctl_eds[i].rkey =
> cpu_to_be64(keys_info->keys[i]);
> + nvme_status_ext->regctl_eds[i].rcsts = keys_info->keys[i] ==
> + reservation->key ? 1 : 0;
> + /* hostid is not supported currently */
> + memset(&nvme_status_ext->regctl_eds[i].hostid, 0, 16);
> + }
> +
> + rc = nvme_c2h(n, (uint8_t *)nvme_status_ext, len, req);
> + g_free(nvme_status_ext);
> + return rc;
> +}
signature.asc
Description: PGP signature
- [PATCH v12 01/10] block: add persistent reservation in/out api, (continued)
- [PATCH v12 01/10] block: add persistent reservation in/out api, Changqi Lu, 2024/09/12
- [PATCH v12 02/10] block/raw: add persistent reservation in/out driver, Changqi Lu, 2024/09/12
- [PATCH v12 03/10] scsi/constant: add persistent reservation in/out protocol constants, Changqi Lu, 2024/09/12
- [PATCH v12 04/10] scsi/util: add helper functions for persistent reservation types conversion, Changqi Lu, 2024/09/12
- [PATCH v12 05/10] hw/scsi: add persistent reservation in/out api for scsi device, Changqi Lu, 2024/09/12
- [PATCH v12 06/10] block/nvme: add reservation command protocol constants, Changqi Lu, 2024/09/12
- [PATCH v12 07/10] hw/nvme: add helper functions for converting reservation types, Changqi Lu, 2024/09/12
- [PATCH v12 08/10] hw/nvme: enable ONCS and rescap function, Changqi Lu, 2024/09/12
- [PATCH v12 10/10] block/iscsi: add persistent reservation in/out driver, Changqi Lu, 2024/09/12
- [PATCH v12 09/10] hw/nvme: add reservation protocal command, Changqi Lu, 2024/09/12
- Re: [PATCH v12 09/10] hw/nvme: add reservation protocal command,
Stefan Hajnoczi <=