Commit eda407a6 authored by Ziv Hirsch's avatar Ziv Hirsch Committed by Tomasz Zawadzki
Browse files

nvme: add support for verify command



Signed-off-by: default avatarZiv Hirsch <zivhirsch13@gmail.com>
Change-Id: Ic9859d5078d9568bb28eefcf8fb70a7fc222ee15
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13928


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
parent 5c3360ce
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -51,6 +51,8 @@ an engine.
Added SPDK_NVME_TRANSPORT_CUSTOM_FABRICS to enum spdk_nvme_transport_type to support custom
fabric transport. SPDK_NVME_TRANSPORT_CUSTOM was intended to be non-fabric custom transport.

Added a new function `spdk_nvme_ns_cmd_verify` to submit a Verify Command to a Namespace.

## v22.05

### sock
+26 −0
Original line number Diff line number Diff line
@@ -3123,6 +3123,32 @@ int spdk_nvme_ns_cmd_write_zeroes(struct spdk_nvme_ns *ns, struct spdk_nvme_qpai
				  spdk_nvme_cmd_cb cb_fn, void *cb_arg,
				  uint32_t io_flags);

/**
 * Submit a verify I/O to the specified NVMe namespace.
 *
 * The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
 * The user must ensure that only one thread submits I/O on a given qpair at any
 * given time.
 *
 * \param ns NVMe namespace to submit the verify I/O.
 * \param qpair I/O queue pair to submit the request.
 * \param lba Starting LBA to verify the data.
 * \param lba_count Length (in sectors) for the verify operation.
 * \param cb_fn Callback function to invoke when the I/O is completed.
 * \param cb_arg Argument to pass to the callback function.
 * \param io_flags Set flags, defined by the SPDK_NVME_IO_FLAGS_* entries in
 * spdk/nvme_spec.h, for this I/O.
 *
 * \return 0 if successfully submitted, negated errnos on the following error conditions:
 * -EINVAL: The request is malformed.
 * -ENOMEM: The request cannot be allocated.
 * -ENXIO: The qpair is failed at the transport level.
 */
int spdk_nvme_ns_cmd_verify(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
			    uint64_t lba, uint32_t lba_count,
			    spdk_nvme_cmd_cb cb_fn, void *cb_arg,
			    uint32_t io_flags);

/**
 * Submit a write uncorrectable I/O to the specified NVMe namespace.
 *
+1 −0
Original line number Diff line number Diff line
@@ -1540,6 +1540,7 @@ enum spdk_nvme_nvm_opcode {
	SPDK_NVME_OPC_WRITE_ZEROES			= 0x08,
	SPDK_NVME_OPC_DATASET_MANAGEMENT		= 0x09,

	SPDK_NVME_OPC_VERIFY				= 0x0c,
	SPDK_NVME_OPC_RESERVATION_REGISTER		= 0x0d,
	SPDK_NVME_OPC_RESERVATION_REPORT		= 0x0e,

+34 −0
Original line number Diff line number Diff line
@@ -1087,6 +1087,40 @@ spdk_nvme_ns_cmd_write_zeroes(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *q
	return nvme_qpair_submit_request(qpair, req);
}

int
spdk_nvme_ns_cmd_verify(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
			uint64_t lba, uint32_t lba_count,
			spdk_nvme_cmd_cb cb_fn, void *cb_arg,
			uint32_t io_flags)
{
	struct nvme_request	*req;
	struct spdk_nvme_cmd	*cmd;

	if (!_is_io_flags_valid(io_flags)) {
		return -EINVAL;
	}

	if (lba_count == 0 || lba_count > UINT16_MAX + 1) {
		return -EINVAL;
	}

	req = nvme_allocate_request_null(qpair, cb_fn, cb_arg);
	if (req == NULL) {
		return -ENOMEM;
	}

	cmd = &req->cmd;
	cmd->opc = SPDK_NVME_OPC_VERIFY;
	cmd->nsid = ns->id;

	*(uint64_t *)&cmd->cdw10 = lba;
	cmd->cdw12 = lba_count - 1;
	cmd->fuse = (io_flags & SPDK_NVME_IO_FLAGS_FUSE_MASK);
	cmd->cdw12 |= (io_flags & SPDK_NVME_IO_FLAGS_CDW12_MASK);

	return nvme_qpair_submit_request(qpair, req);
}

int
spdk_nvme_ns_cmd_write_uncorrectable(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
				     uint64_t lba, uint32_t lba_count,
+1 −0
Original line number Diff line number Diff line
@@ -167,6 +167,7 @@
	spdk_nvme_ns_cmd_compare_with_md;
	spdk_nvme_ns_cmd_writev_ext;
	spdk_nvme_ns_cmd_readv_ext;
	spdk_nvme_ns_cmd_verify;

	spdk_nvme_qpair_get_optimal_poll_group;
	spdk_nvme_qpair_process_completions;
Loading