nvme: add metadata to spdk_nvme_ns_cmd_read/writev()
verified on QEMU NVMe for OCSSD 2.0 and RFC will be shared soon Change-Id: I01c513e30768ac1961a5c5af20de3a2490da7729 Signed-off-by: Young Tack Jin <youngtack.jin@circuitblvd.com> Reviewed-on: https://review.gerrithub.io/413854 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
8c45ed3822
commit
f52d800864
@ -1208,6 +1208,34 @@ int spdk_nvme_ns_cmd_writev(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpa
|
||||
spdk_nvme_req_reset_sgl_cb reset_sgl_fn,
|
||||
spdk_nvme_req_next_sge_cb next_sge_fn);
|
||||
|
||||
/**
|
||||
* \brief Submits a write I/O to the specified NVMe namespace.
|
||||
*
|
||||
* \param ns NVMe namespace to submit the write I/O
|
||||
* \param qpair I/O queue pair to submit the request
|
||||
* \param lba starting LBA to write the data
|
||||
* \param lba_count length (in sectors) for the write 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 in nvme_spec.h, for this I/O
|
||||
* \param reset_sgl_fn callback function to reset scattered payload
|
||||
* \param next_sge_fn callback function to iterate each scattered
|
||||
* payload memory segment
|
||||
* \param metadata virtual address pointer to the metadata payload, the length
|
||||
* of metadata is specified by spdk_nvme_ns_get_md_size()
|
||||
*
|
||||
* \return 0 if successfully submitted, ENOMEM if an nvme_request
|
||||
* structure cannot be allocated for the I/O request
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
int spdk_nvme_ns_cmd_writev_with_md(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,
|
||||
spdk_nvme_req_reset_sgl_cb reset_sgl_fn,
|
||||
spdk_nvme_req_next_sge_cb next_sge_fn, void *metadata);
|
||||
|
||||
/**
|
||||
* \brief Submits a write I/O to the specified NVMe namespace.
|
||||
*
|
||||
@ -1308,6 +1336,34 @@ int spdk_nvme_ns_cmd_readv(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpai
|
||||
spdk_nvme_req_reset_sgl_cb reset_sgl_fn,
|
||||
spdk_nvme_req_next_sge_cb next_sge_fn);
|
||||
|
||||
/**
|
||||
* \brief Submits a read I/O to the specified NVMe namespace.
|
||||
*
|
||||
* \param ns NVMe namespace to submit the read I/O
|
||||
* \param qpair I/O queue pair to submit the request
|
||||
* \param lba starting LBA to read the data
|
||||
* \param lba_count length (in sectors) for the read 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 in nvme_spec.h, for this I/O
|
||||
* \param reset_sgl_fn callback function to reset scattered payload
|
||||
* \param next_sge_fn callback function to iterate each scattered
|
||||
* payload memory segment
|
||||
* \param metadata virtual address pointer to the metadata payload, the length
|
||||
* of metadata is specified by spdk_nvme_ns_get_md_size()
|
||||
*
|
||||
* \return 0 if successfully submitted, ENOMEM if an nvme_request
|
||||
* structure cannot be allocated for the I/O request
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
int spdk_nvme_ns_cmd_readv_with_md(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,
|
||||
spdk_nvme_req_reset_sgl_cb reset_sgl_fn,
|
||||
spdk_nvme_req_next_sge_cb next_sge_fn, void *metadata);
|
||||
|
||||
/**
|
||||
* \brief Submits a read I/O to the specified NVMe namespace.
|
||||
*
|
||||
|
@ -669,6 +669,36 @@ spdk_nvme_ns_cmd_readv(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
spdk_nvme_ns_cmd_readv_with_md(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,
|
||||
spdk_nvme_req_reset_sgl_cb reset_sgl_fn,
|
||||
spdk_nvme_req_next_sge_cb next_sge_fn, void *metadata)
|
||||
{
|
||||
struct nvme_request *req;
|
||||
struct nvme_payload payload;
|
||||
|
||||
if (reset_sgl_fn == NULL || next_sge_fn == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
payload = NVME_PAYLOAD_SGL(reset_sgl_fn, next_sge_fn, cb_arg, metadata);
|
||||
|
||||
req = _nvme_ns_cmd_rw(ns, qpair, &payload, 0, 0, lba, lba_count, cb_fn, cb_arg, SPDK_NVME_OPC_READ,
|
||||
io_flags, 0, 0, true);
|
||||
if (req != NULL) {
|
||||
return nvme_qpair_submit_request(qpair, req);
|
||||
} else if (spdk_nvme_ns_check_request_length(lba_count,
|
||||
ns->sectors_per_max_io,
|
||||
ns->sectors_per_stripe,
|
||||
qpair->ctrlr->opts.io_queue_requests)) {
|
||||
return -EINVAL;
|
||||
} else {
|
||||
return -ENOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
spdk_nvme_ns_cmd_write(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
|
||||
void *buffer, uint64_t lba,
|
||||
@ -749,6 +779,36 @@ spdk_nvme_ns_cmd_writev(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
spdk_nvme_ns_cmd_writev_with_md(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,
|
||||
spdk_nvme_req_reset_sgl_cb reset_sgl_fn,
|
||||
spdk_nvme_req_next_sge_cb next_sge_fn, void *metadata)
|
||||
{
|
||||
struct nvme_request *req;
|
||||
struct nvme_payload payload;
|
||||
|
||||
if (reset_sgl_fn == NULL || next_sge_fn == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
payload = NVME_PAYLOAD_SGL(reset_sgl_fn, next_sge_fn, cb_arg, metadata);
|
||||
|
||||
req = _nvme_ns_cmd_rw(ns, qpair, &payload, 0, 0, lba, lba_count, cb_fn, cb_arg, SPDK_NVME_OPC_WRITE,
|
||||
io_flags, 0, 0, true);
|
||||
if (req != NULL) {
|
||||
return nvme_qpair_submit_request(qpair, req);
|
||||
} else if (spdk_nvme_ns_check_request_length(lba_count,
|
||||
ns->sectors_per_max_io,
|
||||
ns->sectors_per_stripe,
|
||||
qpair->ctrlr->opts.io_queue_requests)) {
|
||||
return -EINVAL;
|
||||
} else {
|
||||
return -ENOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
spdk_nvme_ns_cmd_write_zeroes(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
|
||||
uint64_t lba, uint32_t lba_count,
|
||||
|
Loading…
Reference in New Issue
Block a user