lib/nvme_tcp: get the max_sges from the nvme ctrlr.

Add the error print if there is still remaining_size in
order to provide more meaningful debug info.

Signed-off-by: Ziye Yang <ziye.yang@intel.com>
Change-Id: I7b15c9c9a630ea7ecb2d3191b73c9c99f7febf31
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1189
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Ziye Yang 2020-03-09 23:26:21 +08:00 committed by Changpeng Liu
parent 5feebd8528
commit 9ba4bb22fe
2 changed files with 8 additions and 2 deletions

View File

@ -379,7 +379,7 @@ static int
nvme_tcp_build_sgl_request(struct nvme_tcp_qpair *tqpair, struct nvme_tcp_req *tcp_req)
{
int rc;
uint32_t length, remaining_size, iovcnt = 0;
uint32_t length, remaining_size, iovcnt = 0, max_num_sgl;
struct nvme_request *req = tcp_req->req;
SPDK_DEBUGLOG(SPDK_LOG_NVME, "enter\n");
@ -390,6 +390,7 @@ nvme_tcp_build_sgl_request(struct nvme_tcp_qpair *tqpair, struct nvme_tcp_req *t
assert(req->payload.next_sge_fn != NULL);
req->payload.reset_sgl_fn(req->payload.contig_or_cb_arg, req->payload_offset);
max_num_sgl = spdk_min(req->qpair->ctrlr->max_sges, NVME_TCP_MAX_SGL_DESCRIPTORS);
remaining_size = req->payload_size;
do {
@ -403,11 +404,13 @@ nvme_tcp_build_sgl_request(struct nvme_tcp_qpair *tqpair, struct nvme_tcp_req *t
tcp_req->iov[iovcnt].iov_len = length;
remaining_size -= length;
iovcnt++;
} while (remaining_size > 0 && iovcnt < NVME_TCP_MAX_SGL_DESCRIPTORS);
} while (remaining_size > 0 && iovcnt < max_num_sgl);
/* Should be impossible if we did our sgl checks properly up the stack, but do a sanity check here. */
if (remaining_size > 0) {
SPDK_ERRLOG("Failed to construct tcp_req=%p, and the iovcnt=%u, remaining_size=%u\n",
tcp_req, iovcnt, remaining_size);
return -1;
}

View File

@ -220,12 +220,15 @@ static void
test_nvme_tcp_build_sgl_request(void)
{
struct nvme_tcp_qpair tqpair;
struct spdk_nvme_ctrlr ctrlr = {0};
struct nvme_tcp_req tcp_req = {0};
struct nvme_request req = {{0}};
struct nvme_tcp_ut_bdev_io bio;
uint64_t i;
int rc;
ctrlr.max_sges = NVME_TCP_MAX_SGL_DESCRIPTORS;
tqpair.qpair.ctrlr = &ctrlr;
tcp_req.req = &req;
req.payload.reset_sgl_fn = nvme_tcp_ut_reset_sgl;