Commit 07689e94 authored by Darek Stojaczyk's avatar Darek Stojaczyk Committed by Jim Harris
Browse files

scsi: alloc temporary data buffer with regular calloc



spdk_dma_malloc() is not required here, as the buffer
is neither DMA-able nor shared between processes.

The buffer is used to store the scsi response as it's
prepared. At the end it's always memcopied to possibly
multiple DMA-able buffers in the scatter-gatter list
provided by the upper layer.

Change-Id: I92fcede67dc24c532b13399f6364b071b2aeeb56
Signed-off-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/451555


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarPaul Luse <paul.e.luse@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 1b6ddcc7
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -1584,7 +1584,7 @@ bdev_scsi_unmap(struct spdk_bdev *bdev, struct spdk_bdev_desc *bdev_desc,
		data = spdk_scsi_task_gather_data(task, &data_len);
		if (data) {
			desc_count = __copy_desc(ctx, data, data_len);
			spdk_dma_free(data);
			free(data);
		}
	}

@@ -1809,7 +1809,7 @@ bdev_scsi_process_primary(struct spdk_scsi_task *task)
	case SPDK_SPC_INQUIRY:
		alloc_len = from_be16(&cdb[3]);
		data_len = spdk_max(4096, alloc_len);
		data = spdk_dma_zmalloc(data_len, 0, NULL);
		data = calloc(1, data_len);
		assert(data != NULL);
		rc = bdev_scsi_inquiry(bdev, task, cdb, data, data_len);
		data_len = spdk_min(rc, data_len);
@@ -1833,7 +1833,7 @@ bdev_scsi_process_primary(struct spdk_scsi_task *task)
		}

		data_len = spdk_max(4096, alloc_len);
		data = spdk_dma_zmalloc(data_len, 0, NULL);
		data = calloc(1, data_len);
		assert(data != NULL);
		rc = bdev_scsi_report_luns(task->lun, sel, data, data_len);
		data_len = rc;
@@ -1941,7 +1941,7 @@ bdev_scsi_process_primary(struct spdk_scsi_task *task)
		}

		data_len = rc;
		data = spdk_dma_zmalloc(data_len, 0, NULL);
		data = calloc(1, data_len);
		assert(data != NULL);

		/* First call with no buffer to discover needed buffer size */
@@ -1983,7 +1983,7 @@ bdev_scsi_process_primary(struct spdk_scsi_task *task)
		spdk_scsi_task_build_sense_data(task, sk, asc, ascq);

		data_len = task->sense_data_len;
		data = spdk_dma_zmalloc(data_len, 0, NULL);
		data = calloc(1, data_len);
		assert(data != NULL);
		memcpy(data, task->sense_data, data_len);
		break;
@@ -2034,7 +2034,7 @@ bdev_scsi_process_primary(struct spdk_scsi_task *task)
	}

	if (data) {
		spdk_dma_free(data);
		free(data);
	}

	return SPDK_SCSI_TASK_COMPLETE;
+1 −1
Original line number Diff line number Diff line
@@ -169,7 +169,7 @@ spdk_scsi_task_gather_data(struct spdk_scsi_task *task, int *len)
		return NULL;
	}

	buf = spdk_dma_malloc(buf_len, 0, NULL);
	buf = calloc(1, buf_len);
	if (buf == NULL) {
		*len = -1;
		return NULL;