Blame SOURCES/kvm-migration-update-index-field-when-delete-or-qsort-RD.patch

ae23c9
From 10aadee745539521945b4d6482717011eeb15fc2 Mon Sep 17 00:00:00 2001
ae23c9
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
ae23c9
Date: Wed, 1 Aug 2018 13:55:17 +0100
ae23c9
Subject: [PATCH 13/21] migration: update index field when delete or qsort
ae23c9
 RDMALocalBlock
ae23c9
ae23c9
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
ae23c9
Message-id: <20180801135522.11658-14-dgilbert@redhat.com>
ae23c9
Patchwork-id: 81574
ae23c9
O-Subject: [qemu-kvm RHEL8/virt212 PATCH 13/18] migration: update index field when delete or qsort RDMALocalBlock
ae23c9
Bugzilla: 1594384
ae23c9
RH-Acked-by: Peter Xu <peterx@redhat.com>
ae23c9
RH-Acked-by: John Snow <jsnow@redhat.com>
ae23c9
RH-Acked-by: Juan Quintela <quintela@redhat.com>
ae23c9
ae23c9
From: Lidong Chen <jemmy858585@gmail.com>
ae23c9
ae23c9
rdma_delete_block function deletes RDMALocalBlock base on index field,
ae23c9
but not update the index field. So when next time invoke rdma_delete_block,
ae23c9
it will not work correctly.
ae23c9
ae23c9
If start and cancel migration repeatedly, some RDMALocalBlock not invoke
ae23c9
ibv_dereg_mr to decrease kernel mm_struct vmpin. When vmpin is large than
ae23c9
max locked memory limitation, ibv_reg_mr will failed, and migration can not
ae23c9
start successfully again.
ae23c9
ae23c9
Signed-off-by: Lidong Chen <lidongchen@tencent.com>
ae23c9
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
ae23c9
Message-Id: <1525618499-1560-1-git-send-email-lidongchen@tencent.com>
ae23c9
Signed-off-by: Juan Quintela <quintela@redhat.com>
ae23c9
ae23c9
Signed-off-by: Lidong Chen <jemmy858585@gmail.com>
ae23c9
(cherry picked from commit 71cd73061c014d04bc6b54936e675347ebc8d964)
ae23c9
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ae23c9
---
ae23c9
 migration/rdma.c | 7 +++++++
ae23c9
 1 file changed, 7 insertions(+)
ae23c9
ae23c9
diff --git a/migration/rdma.c b/migration/rdma.c
ae23c9
index da474fc..7d233b0 100644
ae23c9
--- a/migration/rdma.c
ae23c9
+++ b/migration/rdma.c
ae23c9
@@ -708,6 +708,9 @@ static int rdma_delete_block(RDMAContext *rdma, RDMALocalBlock *block)
ae23c9
             memcpy(local->block + block->index, old + (block->index + 1),
ae23c9
                 sizeof(RDMALocalBlock) *
ae23c9
                     (local->nb_blocks - (block->index + 1)));
ae23c9
+            for (x = block->index; x < local->nb_blocks - 1; x++) {
ae23c9
+                local->block[x].index--;
ae23c9
+            }
ae23c9
         }
ae23c9
     } else {
ae23c9
         assert(block == local->block);
ae23c9
@@ -3246,6 +3249,10 @@ static int qemu_rdma_registration_handle(QEMUFile *f, void *opaque)
ae23c9
             qsort(rdma->local_ram_blocks.block,
ae23c9
                   rdma->local_ram_blocks.nb_blocks,
ae23c9
                   sizeof(RDMALocalBlock), dest_ram_sort_func);
ae23c9
+            for (i = 0; i < local->nb_blocks; i++) {
ae23c9
+                local->block[i].index = i;
ae23c9
+            }
ae23c9
+
ae23c9
             if (rdma->pin_all) {
ae23c9
                 ret = qemu_rdma_reg_whole_ram_blocks(rdma);
ae23c9
                 if (ret) {
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9