module/compress: handle enqueue errors

A recent change to the compression API means that we can no longer
assume that rejection from the API means that it was busy. We need
to only queue operations that were from the busy condition and
fail others.

Signed-off-by: paul luse <paul.e.luse@intel.com>
Change-Id: I7fa5d27559eacdf1bdf6982bdc142939333076ae
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/472465
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
paul luse 2019-10-26 20:17:10 +00:00 committed by Tomasz Zawadzki
parent fede944d8c
commit 7c77c29268
2 changed files with 42 additions and 8 deletions

View File

@ -450,6 +450,7 @@ _compress_operation(struct spdk_reduce_backing_dev *backing_dev, struct iovec *s
int i;
int src_mbuf_total = src_iovcnt;
int dst_mbuf_total = dst_iovcnt;
bool device_error = false;
assert(src_iovcnt < MAX_MBUFS_PER_OP);
@ -601,11 +602,14 @@ _compress_operation(struct spdk_reduce_backing_dev *backing_dev, struct iovec *s
/* We always expect 1 got queued, if 0 then we need to queue it up. */
if (rc == 1) {
return 0;
} else {
} else if (comp_op->status == RTE_COMP_OP_STATUS_NOT_PROCESSED) {
/* we free mbufs differently depending on whether they were chained or not */
rte_pktmbuf_free(comp_op->m_src);
rte_pktmbuf_free(comp_op->m_dst);
goto error_enqueue;
} else {
device_error = true;
goto error_src_dst;
}
/* Error cleanup paths. */
@ -621,6 +625,15 @@ error_get_src:
error_enqueue:
rte_comp_op_free(comp_op);
error_get_op:
if (device_error == true) {
/* There was an error sending the op to the device, most
* likely with the parameters.
*/
SPDK_ERRLOG("Compression API returned 0x%x\n", comp_op->status);
return -EINVAL;
}
op_to_queue = calloc(1, sizeof(struct vbdev_comp_op));
if (op_to_queue == NULL) {
SPDK_ERRLOG("unable to allocate operation for queueing.\n");

View File

@ -435,7 +435,9 @@ _get_mbuf_array(struct rte_mbuf *mbuf_array[UT_MBUFS_PER_OP_BOUND_TEST],
}
#define FAKE_ENQUEUE_SUCCESS 255
static uint16_t ut_enqueue_value = 0;
#define FAKE_ENQUEUE_ERROR 128
#define FAKE_ENQUEUE_BUSY 64
static uint16_t ut_enqueue_value = FAKE_ENQUEUE_SUCCESS;
static struct rte_comp_op ut_expected_op;
uint16_t
rte_compressdev_enqueue_burst(uint8_t dev_id, uint16_t qp_id, struct rte_comp_op **ops,
@ -446,13 +448,23 @@ rte_compressdev_enqueue_burst(uint8_t dev_id, uint16_t qp_id, struct rte_comp_op
struct rte_mbuf *exp_mbuf[UT_MBUFS_PER_OP_BOUND_TEST];
int i, num_src_mbufs = UT_MBUFS_PER_OP;
if (ut_enqueue_value == 0) {
switch (ut_enqueue_value) {
case FAKE_ENQUEUE_BUSY:
op->status = RTE_COMP_OP_STATUS_NOT_PROCESSED;
return 0;
break;
case FAKE_ENQUEUE_SUCCESS:
op->status = RTE_COMP_OP_STATUS_SUCCESS;
return 1;
break;
case FAKE_ENQUEUE_ERROR:
op->status = RTE_COMP_OP_STATUS_ERROR;
return 0;
break;
default:
break;
}
if (ut_enqueue_value == FAKE_ENQUEUE_SUCCESS) {
return 1;
}
/* by design the compress module will never send more than 1 op at a time */
CU_ASSERT(op->private_xform == ut_expected_op.private_xform);
@ -656,8 +668,8 @@ test_compress_operation(void)
CU_ASSERT(rc == 0);
ut_rte_pktmbuf_alloc_bulk = 0;
/* test enqueue failure */
ut_enqueue_value = 0;
/* test enqueue failure busy */
ut_enqueue_value = FAKE_ENQUEUE_BUSY;
CU_ASSERT(TAILQ_EMPTY(&g_comp_bdev.queued_comp_ops) == true);
rc = _compress_operation(&g_comp_bdev.backing_dev, &src_iovs[0], src_iovcnt,
&dst_iovs[0], dst_iovcnt, true, &cb_arg);
@ -671,6 +683,15 @@ test_compress_operation(void)
CU_ASSERT(rc == 0);
ut_enqueue_value = 1;
/* test enqueue failure error */
ut_enqueue_value = FAKE_ENQUEUE_ERROR;
CU_ASSERT(TAILQ_EMPTY(&g_comp_bdev.queued_comp_ops) == true);
rc = _compress_operation(&g_comp_bdev.backing_dev, &src_iovs[0], src_iovcnt,
&dst_iovs[0], dst_iovcnt, true, &cb_arg);
CU_ASSERT(TAILQ_EMPTY(&g_comp_bdev.queued_comp_ops) == true);
CU_ASSERT(rc == -EINVAL);
ut_enqueue_value = FAKE_ENQUEUE_SUCCESS;
/* test success with 3 vector iovec */
ut_expected_op.private_xform = &g_decomp_xform;
ut_expected_op.src.offset = 0;