Commit 82c61e06 authored by Ankit Kumar's avatar Ankit Kumar Committed by Tomasz Zawadzki
Browse files

lib/nvme: 0 based numd for reservation report



Fix for number of dwords which is 0 based as per spec.
Use bitwise operators instead of division and modulus.

Change-Id: Ib315bf9394ef599317f41429742e7b8054069549
Signed-off-by: default avatarAnkit Kumar <ankit.kumar@samsung.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16814


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent a67da4e6
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1338,10 +1338,9 @@ spdk_nvme_ns_cmd_reservation_report(struct spdk_nvme_ns *ns,
	struct nvme_request	*req;
	struct spdk_nvme_cmd	*cmd;

	if (len % 4) {
	if (len & 0x3) {
		return -EINVAL;
	}
	num_dwords = len / 4;

	req = nvme_allocate_request_user_copy(qpair, payload, len, cb_fn, cb_arg, false);
	if (req == NULL) {
@@ -1352,7 +1351,8 @@ spdk_nvme_ns_cmd_reservation_report(struct spdk_nvme_ns *ns,
	cmd->opc = SPDK_NVME_OPC_RESERVATION_REPORT;
	cmd->nsid = ns->id;

	cmd->cdw10 = num_dwords;
	num_dwords = (len >> 2);
	cmd->cdw10 = num_dwords - 1; /* 0-based */

	return nvme_qpair_submit_request(qpair, req);
}
+1 −1
Original line number Diff line number Diff line
@@ -1310,7 +1310,7 @@ test_nvme_ns_cmd_reservation_report(void)
	CU_ASSERT(g_request->cmd.opc == SPDK_NVME_OPC_RESERVATION_REPORT);
	CU_ASSERT(g_request->cmd.nsid == ns.id);

	CU_ASSERT(g_request->cmd.cdw10 == (size / 4));
	CU_ASSERT(g_request->cmd.cdw10 == (size >> 2) - 1);

	spdk_free(g_request->payload.contig_or_cb_arg);
	nvme_free_request(g_request);