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

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