idxd: fix bug with cancelling a batch

The new batching code needs to call the cb_fn for each of the
elements of the batch when a batch that hasn't been submitted
yet needs to be cancelled (due to an error in building it).

Signed-off-by: paul luse <paul.e.luse@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11212 (master)

(cherry picked from commit 21c84e363d)
Change-Id: I6f94b27dd7c64f756193ec3532de98b644b41d7e
Signed-off-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11340
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
paul luse 2022-01-23 07:28:07 -07:00 committed by Tomasz Zawadzki
parent d0fded77d3
commit 4507521f91

View File

@ -249,7 +249,8 @@ err_chan:
return NULL;
}
static int idxd_batch_cancel(struct spdk_idxd_io_channel *chan, struct idxd_batch *batch);
static int idxd_batch_cancel(struct spdk_idxd_io_channel *chan, struct idxd_batch *batch,
int status);
void
spdk_idxd_put_channel(struct spdk_idxd_io_channel *chan)
@ -260,7 +261,7 @@ spdk_idxd_put_channel(struct spdk_idxd_io_channel *chan)
if (chan->batch) {
assert(chan->batch->transparent);
idxd_batch_cancel(chan, chan->batch);
idxd_batch_cancel(chan, chan->batch, -ECANCELED);
}
pthread_mutex_lock(&chan->idxd->num_channels_lock);
@ -455,8 +456,11 @@ _free_batch(struct idxd_batch *batch, struct spdk_idxd_io_channel *chan)
}
static int
idxd_batch_cancel(struct spdk_idxd_io_channel *chan, struct idxd_batch *batch)
idxd_batch_cancel(struct spdk_idxd_io_channel *chan, struct idxd_batch *batch, int status)
{
struct idxd_ops *op;
int i;
assert(chan != NULL);
assert(batch != NULL);
@ -474,6 +478,13 @@ idxd_batch_cancel(struct spdk_idxd_io_channel *chan, struct idxd_batch *batch)
chan->batch = NULL;
}
for (i = 0; i < batch->index; i++) {
op = &batch->user_ops[i];
if (op->cb_fn) {
op->cb_fn(op->cb_arg, status);
}
}
_free_batch(batch, chan);
return 0;
@ -496,7 +507,7 @@ idxd_batch_submit(struct spdk_idxd_io_channel *chan, struct idxd_batch *batch,
}
if (batch->index == 0) {
return idxd_batch_cancel(chan, batch);
return idxd_batch_cancel(chan, batch, 0);
}
/* Common prep. */
@ -516,7 +527,7 @@ idxd_batch_submit(struct spdk_idxd_io_channel *chan, struct idxd_batch *batch,
op->cb_arg = batch->user_ops[0].cb_arg;
op->crc_dst = batch->user_ops[0].crc_dst;
batch->index = 0;
idxd_batch_cancel(chan, batch);
idxd_batch_cancel(chan, batch, 0);
} else {
/* Command specific. */
desc->opcode = IDXD_OPCODE_BATCH;
@ -709,7 +720,7 @@ spdk_idxd_submit_copy(struct spdk_idxd_io_channel *chan,
return 0;
err:
idxd_batch_cancel(chan, batch);
idxd_batch_cancel(chan, batch, rc);
return rc;
}
@ -892,7 +903,7 @@ spdk_idxd_submit_compare(struct spdk_idxd_io_channel *chan,
return 0;
err:
idxd_batch_cancel(chan, batch);
idxd_batch_cancel(chan, batch, rc);
return rc;
}
@ -999,7 +1010,7 @@ spdk_idxd_submit_fill(struct spdk_idxd_io_channel *chan,
return 0;
err:
idxd_batch_cancel(chan, batch);
idxd_batch_cancel(chan, batch, rc);
return rc;
}
@ -1123,7 +1134,7 @@ spdk_idxd_submit_crc32c(struct spdk_idxd_io_channel *chan,
return 0;
err:
idxd_batch_cancel(chan, batch);
idxd_batch_cancel(chan, batch, rc);
return rc;
}
@ -1269,7 +1280,7 @@ spdk_idxd_submit_copy_crc32c(struct spdk_idxd_io_channel *chan,
return 0;
err:
idxd_batch_cancel(chan, batch);
idxd_batch_cancel(chan, batch, rc);
return rc;
}