Blame SOURCES/0014-Move-block_in_bytes-entirely-to-the-presentation-lay.patch

985088
From 431dbd98bad6e3635b4d0885bf33dd3e759ca35d Mon Sep 17 00:00:00 2001
985088
From: "Richard W.M. Jones" <rjones@redhat.com>
985088
Date: Mon, 27 Mar 2017 21:22:52 +0100
985088
Subject: [PATCH 14/17] Move block_in_bytes entirely to the presentation layer.
985088
985088
Simplifies and updates commit dbef8dd3bf00417e75a12c851b053e49c9e1a79e.
985088
---
985088
 src/collect.ml       | 19 +++----------------
985088
 src/collect.mli      |  6 +-----
985088
 src/csv_output.ml    | 14 ++++++++++----
985088
 src/csv_output.mli   |  2 +-
985088
 src/redraw.ml        | 10 +++++++---
985088
 src/stream_output.ml | 14 ++++++++++----
985088
 src/top.ml           |  4 ++--
985088
 7 files changed, 34 insertions(+), 35 deletions(-)
985088
985088
diff --git a/src/collect.ml b/src/collect.ml
985088
index f856067..448ce8c 100644
985088
--- a/src/collect.ml
985088
+++ b/src/collect.ml
985088
@@ -57,12 +57,8 @@ and rd_active = {
985088
   (* The following are since the last slice, or None if cannot be calc'd: *)
985088
   rd_block_rd_reqs : int64 option;      (* Number of block device read rqs. *)
985088
   rd_block_wr_reqs : int64 option;      (* Number of block device write rqs. *)
985088
-  rd_block_rd_bytes : int64 option;   (* Number of bytes block device read *)
985088
-  rd_block_wr_bytes : int64 option;   (* Number of bytes block device write *)
985088
-  (* _info fields includes the number considering --block_in_bytes option *)
985088
-  rd_block_rd_info : int64 option;    (* Block device read info for user *)
985088
-  rd_block_wr_info : int64 option;    (* Block device read info for user *)
985088
-
985088
+  rd_block_rd_bytes : int64 option;     (* Number of bytes block device read *)
985088
+  rd_block_wr_bytes : int64 option;     (* Number of bytes block device write *)
985088
   rd_net_rx_bytes : int64 option;	(* Number of bytes received. *)
985088
   rd_net_tx_bytes : int64 option;	(* Number of bytes transmitted. *)
985088
 }
985088
@@ -114,7 +110,7 @@ let last_pcpu_usages = Hashtbl.create 13
985088
 let clear_pcpu_display_data () =
985088
   Hashtbl.clear last_pcpu_usages
985088
 
985088
-let collect (conn, _, _, _, _, node_info, _, _) block_in_bytes =
985088
+let collect (conn, _, _, _, _, node_info, _, _) =
985088
   (* Number of physical CPUs (some may be disabled). *)
985088
   let nr_pcpus = C.maxcpus_of_node_info node_info in
985088
 
985088
@@ -178,7 +174,6 @@ let collect (conn, _, _, _, _, node_info, _, _) block_in_bytes =
985088
                       rd_mem_bytes = 0L; rd_mem_percent = 0L;
985088
 		      rd_block_rd_reqs = None; rd_block_wr_reqs = None;
985088
                       rd_block_rd_bytes = None; rd_block_wr_bytes = None;
985088
-                      rd_block_rd_info = None; rd_block_wr_info = None;
985088
 		      rd_net_rx_bytes = None; rd_net_tx_bytes = None;
985088
 		    })
985088
 	  with
985088
@@ -256,14 +251,6 @@ let collect (conn, _, _, _, _, node_info, _, _) block_in_bytes =
985088
                     rd_block_rd_bytes = Some read_bytes;
985088
                     rd_block_wr_bytes = Some write_bytes;
985088
          } in
985088
-         let rd = { rd with
985088
-                    rd_block_rd_info =
985088
-                      if block_in_bytes then
985088
-                        rd.rd_block_rd_bytes else rd.rd_block_rd_reqs;
985088
-                    rd_block_wr_info =
985088
-                      if block_in_bytes then
985088
-                        rd.rd_block_wr_bytes else rd.rd_block_wr_reqs;
985088
-         } in
985088
 	 name, Active rd
985088
       (* For all other domains we can't calculate it, so leave as None. *)
985088
       | rd -> rd
985088
diff --git a/src/collect.mli b/src/collect.mli
985088
index 440859b..9ad3dcb 100644
985088
--- a/src/collect.mli
985088
+++ b/src/collect.mli
985088
@@ -48,10 +48,6 @@ and rd_active = {
985088
   rd_block_wr_reqs : int64 option;      (* Number of block device write rqs. *)
985088
   rd_block_rd_bytes : int64 option;     (* Number of bytes block device read *)
985088
   rd_block_wr_bytes : int64 option;     (* Number of bytes block device write *)
985088
-  (* _info fields includes the number considering --block_in_bytes option *)
985088
-  rd_block_rd_info : int64 option;      (* Block device read info for user *)
985088
-  rd_block_wr_info : int64 option;      (* Block device read info for user *)
985088
-
985088
   rd_net_rx_bytes : int64 option;	(* Number of bytes received. *)
985088
   rd_net_tx_bytes : int64 option;	(* Number of bytes transmitted. *)
985088
 }
985088
@@ -75,7 +71,7 @@ type pcpu_stats = {
985088
   rd_pcpu_pcpus_cpu_time : float array
985088
 }
985088
 
985088
-val collect : Types.setup -> bool -> stats
985088
+val collect : Types.setup -> stats
985088
 (** Collect statistics. *)
985088
 
985088
 val collect_pcpu : stats -> pcpu_stats
985088
diff --git a/src/csv_output.ml b/src/csv_output.ml
985088
index 9496ca8..f23d673 100644
985088
--- a/src/csv_output.ml
985088
+++ b/src/csv_output.ml
985088
@@ -56,6 +56,7 @@ let write_csv_header (csv_cpu, csv_mem, csv_block, csv_net) block_in_bytes =
985088
 (* Write summary data to CSV file. *)
985088
 let append_csv (_, _, _, _, _, node_info, hostname, _) (* setup *)
985088
                (csv_cpu, csv_mem, csv_block, csv_net)
985088
+               block_in_bytes
985088
                { rd_doms = doms;
985088
                  rd_printable_time = printable_time;
985088
                  rd_nr_pcpus = nr_pcpus; rd_total_cpu = total_cpu;
985088
@@ -104,10 +105,15 @@ let append_csv (_, _, _, _, _, node_info, hostname, _) (* setup *)
985088
         (if csv_mem then [
985088
             Int64.to_string rd.rd_mem_bytes; Int64.to_string rd.rd_mem_percent
985088
          ] else []) @
985088
-	(if csv_block then [
985088
-	   string_of_int64_option rd.rd_block_rd_info;
985088
-	   string_of_int64_option rd.rd_block_wr_info;
985088
-	 ] else []) @
985088
+	(if csv_block then
985088
+           if block_in_bytes then [
985088
+	     string_of_int64_option rd.rd_block_rd_bytes;
985088
+	     string_of_int64_option rd.rd_block_wr_bytes;
985088
+	   ] else [
985088
+	     string_of_int64_option rd.rd_block_rd_reqs;
985088
+	     string_of_int64_option rd.rd_block_wr_reqs;
985088
+           ]
985088
+         else []) @
985088
 	(if csv_net then [
985088
 	   string_of_int64_option rd.rd_net_rx_bytes;
985088
 	   string_of_int64_option rd.rd_net_tx_bytes;
985088
diff --git a/src/csv_output.mli b/src/csv_output.mli
985088
index d5eab0f..4064be5 100644
985088
--- a/src/csv_output.mli
985088
+++ b/src/csv_output.mli
985088
@@ -24,4 +24,4 @@ val csv_write : (string list -> unit) ref
985088
 
985088
 val write_csv_header : bool * bool * bool * bool -> bool -> unit
985088
 
985088
-val append_csv : Types.setup -> bool * bool * bool * bool -> Collect.stats -> unit
985088
+val append_csv : Types.setup -> bool * bool * bool * bool -> bool -> Collect.stats -> unit
985088
diff --git a/src/redraw.ml b/src/redraw.ml
985088
index 9ce889b..0403158 100644
985088
--- a/src/redraw.ml
985088
+++ b/src/redraw.ml
985088
@@ -155,8 +155,12 @@ let redraw display_mode sort_order
985088
 	| (name, Active rd) :: doms ->
985088
 	   if lineno < lines then (
985088
 	     let state = show_state rd.rd_info.D.state in
985088
-	     let rd_req = Show.int64_option rd.rd_block_rd_info in
985088
-	     let wr_req = Show.int64_option rd.rd_block_wr_info in
985088
+	     let rd_info =
985088
+               if block_in_bytes then Show.int64_option rd.rd_block_rd_bytes
985088
+               else Show.int64_option rd.rd_block_rd_reqs in
985088
+	     let wr_info =
985088
+               if block_in_bytes then Show.int64_option rd.rd_block_wr_bytes
985088
+               else Show.int64_option rd.rd_block_wr_reqs in
985088
 	     let rx_bytes = Show.int64_option rd.rd_net_rx_bytes in
985088
 	     let tx_bytes = Show.int64_option rd.rd_net_tx_bytes in
985088
 	     let percent_cpu = Show.percent rd.rd_percent_cpu in
985088
@@ -166,7 +170,7 @@ let redraw display_mode sort_order
985088
 
985088
 	     let line =
985088
                sprintf "%5d %c %s %s %s %s %s %s %s %s"
985088
-		       rd.rd_domid state rd_req wr_req rx_bytes tx_bytes
985088
+		       rd.rd_domid state rd_info wr_info rx_bytes tx_bytes
985088
 		       percent_cpu percent_mem time name in
985088
 	     let line = pad cols line in
985088
 	     mvaddstr lineno 0 line;
985088
diff --git a/src/stream_output.ml b/src/stream_output.ml
985088
index bf7b114..c3af99b 100644
985088
--- a/src/stream_output.ml
985088
+++ b/src/stream_output.ml
985088
@@ -59,10 +59,16 @@ let append_stream (_, _, _, _, _, node_info, hostname, _) (* setup *)
985088
   let dump_domain = fun name rd
985088
   -> begin
985088
     let state = Screen.show_state rd.rd_info.D.state in
985088
-         let rd_req = if rd.rd_block_rd_info = None then "   0"
985088
-                      else Show.int64_option rd.rd_block_rd_info in
985088
-         let wr_req = if rd.rd_block_wr_info = None then "   0"
985088
-                      else Show.int64_option rd.rd_block_wr_info in
985088
+         let rd_req =
985088
+           if rd.rd_block_rd_reqs = None then "   0"
985088
+           else
985088
+             if block_in_bytes then Show.int64_option rd.rd_block_rd_bytes
985088
+             else Show.int64_option rd.rd_block_rd_reqs in
985088
+         let wr_req =
985088
+           if rd.rd_block_wr_reqs = None then "   0"
985088
+           else
985088
+             if block_in_bytes then Show.int64_option rd.rd_block_wr_bytes
985088
+             else Show.int64_option rd.rd_block_wr_reqs in
985088
     let rx_bytes = if rd.rd_net_rx_bytes = None then "   0"
985088
     else Show.int64_option rd.rd_net_rx_bytes in
985088
     let tx_bytes = if rd.rd_net_tx_bytes = None then "   0"
985088
diff --git a/src/top.ml b/src/top.ml
985088
index 204f3b6..e2a93d6 100644
985088
--- a/src/top.ml
985088
+++ b/src/top.ml
985088
@@ -319,7 +319,7 @@ let rec main_loop ((_, batch_mode, script_mode, csv_enabled, stream_mode, _, _,
985088
 
985088
   while not !quit do
985088
     (* Collect stats. *)
985088
-    let state = collect setup !block_in_bytes in
985088
+    let state = collect setup in
985088
     let pcpu_display =
985088
       if !display_mode = PCPUDisplay then Some (collect_pcpu state)
985088
       else None in
985088
@@ -331,7 +331,7 @@ let rec main_loop ((_, batch_mode, script_mode, csv_enabled, stream_mode, _, _,
985088
 
985088
     (* Update CSV file. *)
985088
     if csv_enabled then
985088
-      Csv_output.append_csv setup csv_flags state;
985088
+      Csv_output.append_csv setup csv_flags !block_in_bytes state;
985088
 
985088
     (* Append to stream output file. *)
985088
     if stream_mode then
985088
-- 
985088
2.9.3
985088