From 5449685e23c795f8d690ba71edf72315b3157328 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Wed, 21 Dec 2011 14:48:13 +0100
Subject: [PATCH] Switch blockdev_getmirrorstatus_multi to per-node bodies

Even for a small 4-node node-group, this reduces the payload of this
RPC call by half for each node; for a big node group, previous testing
(using a different patch) showed a general reduction in traffic over
the entire cluster verify from 9MB to ~2MB.

We only need to change the RPC call, not its return value, since that
was already in an "optimised" form.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 lib/rpc_defs.py     | 14 +++++++++++++-
 lib/server/noded.py |  5 +----
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/lib/rpc_defs.py b/lib/rpc_defs.py
index 13cb0948d..f4b0c46a4 100644
--- a/lib/rpc_defs.py
+++ b/lib/rpc_defs.py
@@ -105,6 +105,17 @@ def _BlockdevGetMirrorStatusPostProc(result):
   return result
 
 
+def _BlockdevGetMirrorStatusMultiPreProc(node, args):
+  """Prepares the appropriate node values for blockdev_getmirrorstatus_multi.
+
+  """
+  # there should be only one argument to this RPC, already holding a
+  # node->disks dictionary, we just need to extract the value for the
+  # current node
+  assert len(args) == 1
+  return [args[0][node]]
+
+
 def _BlockdevGetMirrorStatusMultiPostProc(result):
   """Post-processor for L{rpc.RpcRunner.call_blockdev_getmirrorstatus_multi}.
 
@@ -396,7 +407,8 @@ _BLOCKDEV_CALLS = [
     "Request status of a (mirroring) device"),
   ("blockdev_getmirrorstatus_multi", MULTI, TMO_NORMAL, [
     ("node_disks", ED_NODE_TO_DISK_DICT, None),
-    ], None, _BlockdevGetMirrorStatusMultiPostProc,
+    ], _BlockdevGetMirrorStatusMultiPreProc,
+   _BlockdevGetMirrorStatusMultiPostProc,
     "Request status of (mirroring) devices from multiple nodes"),
   ]
 
diff --git a/lib/server/noded.py b/lib/server/noded.py
index b8f848cba..22091d7c1 100644
--- a/lib/server/noded.py
+++ b/lib/server/noded.py
@@ -288,10 +288,7 @@ class NodeHttpServer(http.server.HttpServer):
     """
     (node_disks, ) = params
 
-    node_name = netutils.Hostname.GetSysName()
-
-    disks = [objects.Disk.FromDict(dsk_s)
-             for dsk_s in node_disks.get(node_name, [])]
+    disks = [objects.Disk.FromDict(dsk_s) for dsk_s in node_disks]
 
     result = []
 
-- 
GitLab