Commit c24f5069 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Changpeng Liu
Browse files

iscsi: Increase the size of write buffers to store DIF



Increase the size of write (data out) buffers and immediate
data buffers in the iSCSI library to store DIF. Increase is the
amount necessary to store 16 byte metadata block to the block
formatted iwth 512 + 16. 512 + 16 is the current maximum ratio
of metadata per block.

Use the macro SPDK_BDEV_BUF_SIZE_WITH_MD defined in
include/spdk/bdev.h for this purpose.

Besides, change the name of a helper function from
spdk_get_immediate_data_buffer_size() to
spdk_get_max_immediate_data_size() to differentiate the maximum
data size and the buffer size, and then to use the macro.

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


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>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent a18c0acd
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -374,7 +374,7 @@ spdk_iscsi_check_data_segment_length(struct spdk_iscsi_conn *conn,
		   pdu->bhs.opcode == ISCSI_OP_NOPOUT) {
		max_segment_len = SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH;
	} else {
		max_segment_len = spdk_get_immediate_data_buffer_size();
		max_segment_len = spdk_get_max_immediate_data_size();
	}
	if (data_len <= max_segment_len) {
		return true;
@@ -466,12 +466,12 @@ spdk_iscsi_read_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu **_pdu)
	/* copy the actual data into local buffer */
	if (pdu->data_valid_bytes < data_len) {
		if (pdu->data_buf == NULL) {
			if (data_len <= spdk_get_immediate_data_buffer_size()) {
			if (data_len <= spdk_get_max_immediate_data_size()) {
				pool = g_spdk_iscsi.pdu_immediate_data_pool;
				pdu->data_buf_len = spdk_get_immediate_data_buffer_size();
				pdu->data_buf_len = SPDK_BDEV_BUF_SIZE_WITH_MD(spdk_get_max_immediate_data_size());
			} else if (data_len <= SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH) {
				pool = g_spdk_iscsi.pdu_data_out_pool;
				pdu->data_buf_len = SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH;
				pdu->data_buf_len = SPDK_BDEV_BUF_SIZE_WITH_MD(SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH);
			} else {
				SPDK_ERRLOG("Data(%d) > MaxSegment(%d)\n",
					    data_len, SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH);
+1 −1
Original line number Diff line number Diff line
@@ -441,7 +441,7 @@ void spdk_iscsi_op_abort_task_set(struct spdk_iscsi_task *task,
				  uint8_t function);

static inline int
spdk_get_immediate_data_buffer_size(void)
spdk_get_max_immediate_data_size(void)
{
	/*
	 * Specify enough extra space in addition to FirstBurstLength to
+3 −3
Original line number Diff line number Diff line
@@ -145,9 +145,9 @@ spdk_mobj_ctor(struct spdk_mempool *mp, __attribute__((unused)) void *arg,
static int spdk_iscsi_initialize_pdu_pool(void)
{
	struct spdk_iscsi_globals *iscsi = &g_spdk_iscsi;
	int imm_mobj_size = spdk_get_immediate_data_buffer_size() +
	int imm_mobj_size = SPDK_BDEV_BUF_SIZE_WITH_MD(spdk_get_max_immediate_data_size()) +
			    sizeof(struct spdk_mobj) + ISCSI_DATA_BUFFER_ALIGNMENT;
	int dout_mobj_size = SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH +
	int dout_mobj_size = SPDK_BDEV_BUF_SIZE_WITH_MD(SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH) +
			     sizeof(struct spdk_mobj) + ISCSI_DATA_BUFFER_ALIGNMENT;

	/* create PDU pool */