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> Change-Id: I6f94b27dd7c64f756193ec3532de98b644b41d7e Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11212 Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
This commit is contained in:
parent
d5e63730ae
commit
21c84e363d
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user