vhost: fix the memory free in submit_inflight_desc

SPDK shouldn't use `free` to free the memory allocated by rte_zmalloc_socket.
Otherwises, the vhost-blk/scsi will continuously crash.

In this patch, SPDK don't free the dpdk allocated memory,
DPDK will free it finally. Add a flag to indice the resubmit handle.

Change-Id: I85fd84b7d27a091830006a0f84d541c48290cbb3
Signed-off-by: Li Feng <fengli@smartx.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10383
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
This commit is contained in:
Li Feng 2021-11-24 16:06:24 +08:00 committed by Tomasz Zawadzki
parent 869929a1ca
commit 73f61bcdc1
2 changed files with 23 additions and 18 deletions

View File

@ -785,19 +785,24 @@ static void
submit_inflight_desc(struct spdk_vhost_blk_session *bvsession,
struct spdk_vhost_virtqueue *vq)
{
struct spdk_vhost_session *vsession = &bvsession->vsession;
spdk_vhost_resubmit_info *resubmit = vq->vring_inflight.resubmit_inflight;
struct spdk_vhost_session *vsession;
spdk_vhost_resubmit_info *resubmit;
spdk_vhost_resubmit_desc *resubmit_list;
uint16_t req_idx;
int i;
if (spdk_likely(resubmit == NULL || resubmit->resubmit_list == NULL)) {
resubmit = vq->vring_inflight.resubmit_inflight;
if (spdk_likely(resubmit == NULL || resubmit->resubmit_list == NULL ||
resubmit->resubmit_num == 0)) {
return;
}
resubmit_list = resubmit->resubmit_list;
while (resubmit->resubmit_num-- > 0) {
req_idx = resubmit_list[resubmit->resubmit_num].index;
SPDK_DEBUGLOG(vhost_blk, "====== Start processing request idx %"PRIu16"======\n",
vsession = &bvsession->vsession;
for (i = resubmit->resubmit_num - 1; i >= 0; --i) {
req_idx = resubmit_list[i].index;
SPDK_DEBUGLOG(vhost_blk, "====== Start processing resubmit request idx %"PRIu16"======\n",
req_idx);
if (spdk_unlikely(req_idx >= vq->vring.size)) {
@ -813,9 +818,7 @@ submit_inflight_desc(struct spdk_vhost_blk_session *bvsession,
process_blk_task(vq, req_idx);
}
}
free(resubmit_list);
resubmit->resubmit_list = NULL;
resubmit->resubmit_num = 0;
}
static void

View File

@ -739,19 +739,24 @@ static void
submit_inflight_desc(struct spdk_vhost_scsi_session *svsession,
struct spdk_vhost_virtqueue *vq)
{
struct spdk_vhost_session *vsession = &svsession->vsession;
spdk_vhost_resubmit_info *resubmit = vq->vring_inflight.resubmit_inflight;
struct spdk_vhost_session *vsession;
spdk_vhost_resubmit_info *resubmit;
spdk_vhost_resubmit_desc *resubmit_list;
uint16_t req_idx;
int i;
if (spdk_likely(resubmit == NULL || resubmit->resubmit_list == NULL)) {
resubmit = vq->vring_inflight.resubmit_inflight;
if (spdk_likely(resubmit == NULL || resubmit->resubmit_list == NULL ||
resubmit->resubmit_num == 0)) {
return;
}
resubmit_list = resubmit->resubmit_list;
while (resubmit->resubmit_num-- > 0) {
vsession = &svsession->vsession;
for (i = resubmit->resubmit_num - 1; i >= 0; --i) {
req_idx = resubmit_list[resubmit->resubmit_num].index;
SPDK_DEBUGLOG(vhost_scsi, "====== Start processing request idx %"PRIu16"======\n",
SPDK_DEBUGLOG(vhost_scsi, "====== Start processing resubmit request idx %"PRIu16"======\n",
req_idx);
if (spdk_unlikely(req_idx >= vq->vring.size)) {
@ -763,11 +768,8 @@ submit_inflight_desc(struct spdk_vhost_scsi_session *svsession,
process_scsi_task(vsession, vq, req_idx);
}
/* reset the submit_num to 0 to avoid underflow. */
resubmit->resubmit_num = 0;
free(resubmit_list);
resubmit->resubmit_list = NULL;
resubmit->resubmit_num = 0;
}
static void