Commit e3e023cf authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Darek Stojaczyk
Browse files

nvmf/tcp: Increase in-capsule buffer size to fill DIF fields



When NVMe/TCP initiator transfers in-capsule data, NVMe/TCP has to
process it as in-capsule data. If DIF insert/strip is enabled,
in-capsule data size will be increased by NVMe/TCP target to insert
metadata. However size of in-capsule data buffer had not been
increased, and buffer overflow occurred when NVMe/TCP initiator
transfers in-capsule data to NVMe/TCP target with DIF insert/strip
being enabled.

This patch increases size of in-capsule data buffer size to store
metadata. 16 byte metadata per 512 byte data block is the current
maximum ratio of metadata per block.

Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I88b127efd7a945bde167a95df19a0b9175cb8cd0
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/461333


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
parent 9d4ee5f3
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -926,8 +926,12 @@ spdk_nvmf_tcp_qpair_init_mem_resource(struct spdk_nvmf_tcp_qpair *tqpair, uint16
	int i;
	struct spdk_nvmf_tcp_req *tcp_req;
	struct spdk_nvmf_transport *transport = tqpair->qpair.transport;
	struct spdk_nvmf_tcp_transport *ttransport;
	ttransport = SPDK_CONTAINEROF(transport, struct spdk_nvmf_tcp_transport, transport);
	uint32_t in_capsule_data_size;

	in_capsule_data_size = transport->opts.in_capsule_data_size;
	if (transport->opts.dif_insert_or_strip) {
		in_capsule_data_size = SPDK_BDEV_BUF_SIZE_WITH_MD(in_capsule_data_size);
	}

	if (!tqpair->qpair.sq_head_max) {
		tqpair->req = calloc(1, sizeof(*tqpair->req));
@@ -936,8 +940,8 @@ spdk_nvmf_tcp_qpair_init_mem_resource(struct spdk_nvmf_tcp_qpair *tqpair, uint16
			return -1;
		}

		if (transport->opts.in_capsule_data_size) {
			tqpair->buf = spdk_dma_zmalloc(ttransport->transport.opts.in_capsule_data_size, 0x1000, NULL);
		if (in_capsule_data_size) {
			tqpair->buf = spdk_dma_zmalloc(in_capsule_data_size, 0x1000, NULL);
			if (!tqpair->buf) {
				SPDK_ERRLOG("Unable to allocate buf on tqpair=%p.\n", tqpair);
				return -1;
@@ -978,9 +982,8 @@ spdk_nvmf_tcp_qpair_init_mem_resource(struct spdk_nvmf_tcp_qpair *tqpair, uint16
			return -1;
		}

		if (transport->opts.in_capsule_data_size) {
			tqpair->bufs = spdk_dma_zmalloc(size * transport->opts.in_capsule_data_size,
							0x1000, NULL);
		if (in_capsule_data_size) {
			tqpair->bufs = spdk_dma_zmalloc(size * in_capsule_data_size, 0x1000, NULL);
			if (!tqpair->bufs) {
				SPDK_ERRLOG("Unable to allocate bufs on tqpair=%p.\n", tqpair);
				return -1;
@@ -995,7 +998,7 @@ spdk_nvmf_tcp_qpair_init_mem_resource(struct spdk_nvmf_tcp_qpair *tqpair, uint16

			/* Set up memory to receive commands */
			if (tqpair->bufs) {
				tcp_req->buf = (void *)((uintptr_t)tqpair->bufs + (i * transport->opts.in_capsule_data_size));
				tcp_req->buf = (void *)((uintptr_t)tqpair->bufs + (i * in_capsule_data_size));
			}

			/* Set the cmdn and rsp */