]> git.proxmox.com Git - zfsonlinux.git/blob - debian/patches/0010-arcstat-Fix-integer-division-with-python3.patch
086347f8bd55b3613e3a60b6892ad3ac29368fe7
[zfsonlinux.git] / debian / patches / 0010-arcstat-Fix-integer-division-with-python3.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Valmiky Arquissandas <kayvlim@gmail.com>
3 Date: Fri, 8 Oct 2021 16:32:27 +0100
4 Subject: [PATCH] arcstat: Fix integer division with python3
5
6 The arcstat script requests compatibility with python2 and python3, but
7 PEP 238 modified the / operator and results in erroneous output when
8 run under python3.
9
10 This commit replaces instances of / with //, yielding the expected
11 result in both versions of Python.
12
13 Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
14 Reviewed-by: John Kennedy <john.kennedy@delphix.com>
15 Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
16 Signed-off-by: Valmiky Arquissandas <foss@kayvlim.com>
17 Closes #12603
18 (cherry picked from commit 2d02bba23d83ae8fede8d281edc255f01ccd28e9)
19 Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
20 ---
21 cmd/arcstat/arcstat.in | 66 +++++++++++++++++++++---------------------
22 1 file changed, 33 insertions(+), 33 deletions(-)
23
24 diff --git a/cmd/arcstat/arcstat.in b/cmd/arcstat/arcstat.in
25 index 9e7c52a6c..cd9a803a2 100755
26 --- a/cmd/arcstat/arcstat.in
27 +++ b/cmd/arcstat/arcstat.in
28 @@ -441,73 +441,73 @@ def calculate():
29
30 v = dict()
31 v["time"] = time.strftime("%H:%M:%S", time.localtime())
32 - v["hits"] = d["hits"] / sint
33 - v["miss"] = d["misses"] / sint
34 + v["hits"] = d["hits"] // sint
35 + v["miss"] = d["misses"] // sint
36 v["read"] = v["hits"] + v["miss"]
37 - v["hit%"] = 100 * v["hits"] / v["read"] if v["read"] > 0 else 0
38 + v["hit%"] = 100 * v["hits"] // v["read"] if v["read"] > 0 else 0
39 v["miss%"] = 100 - v["hit%"] if v["read"] > 0 else 0
40
41 - v["dhit"] = (d["demand_data_hits"] + d["demand_metadata_hits"]) / sint
42 - v["dmis"] = (d["demand_data_misses"] + d["demand_metadata_misses"]) / sint
43 + v["dhit"] = (d["demand_data_hits"] + d["demand_metadata_hits"]) // sint
44 + v["dmis"] = (d["demand_data_misses"] + d["demand_metadata_misses"]) // sint
45
46 v["dread"] = v["dhit"] + v["dmis"]
47 - v["dh%"] = 100 * v["dhit"] / v["dread"] if v["dread"] > 0 else 0
48 + v["dh%"] = 100 * v["dhit"] // v["dread"] if v["dread"] > 0 else 0
49 v["dm%"] = 100 - v["dh%"] if v["dread"] > 0 else 0
50
51 - v["phit"] = (d["prefetch_data_hits"] + d["prefetch_metadata_hits"]) / sint
52 + v["phit"] = (d["prefetch_data_hits"] + d["prefetch_metadata_hits"]) // sint
53 v["pmis"] = (d["prefetch_data_misses"] +
54 - d["prefetch_metadata_misses"]) / sint
55 + d["prefetch_metadata_misses"]) // sint
56
57 v["pread"] = v["phit"] + v["pmis"]
58 - v["ph%"] = 100 * v["phit"] / v["pread"] if v["pread"] > 0 else 0
59 + v["ph%"] = 100 * v["phit"] // v["pread"] if v["pread"] > 0 else 0
60 v["pm%"] = 100 - v["ph%"] if v["pread"] > 0 else 0
61
62 v["mhit"] = (d["prefetch_metadata_hits"] +
63 - d["demand_metadata_hits"]) / sint
64 + d["demand_metadata_hits"]) // sint
65 v["mmis"] = (d["prefetch_metadata_misses"] +
66 - d["demand_metadata_misses"]) / sint
67 + d["demand_metadata_misses"]) // sint
68
69 v["mread"] = v["mhit"] + v["mmis"]
70 - v["mh%"] = 100 * v["mhit"] / v["mread"] if v["mread"] > 0 else 0
71 + v["mh%"] = 100 * v["mhit"] // v["mread"] if v["mread"] > 0 else 0
72 v["mm%"] = 100 - v["mh%"] if v["mread"] > 0 else 0
73
74 v["arcsz"] = cur["size"]
75 v["size"] = cur["size"]
76 v["c"] = cur["c"]
77 - v["mfu"] = d["mfu_hits"] / sint
78 - v["mru"] = d["mru_hits"] / sint
79 - v["mrug"] = d["mru_ghost_hits"] / sint
80 - v["mfug"] = d["mfu_ghost_hits"] / sint
81 - v["eskip"] = d["evict_skip"] / sint
82 - v["el2skip"] = d["evict_l2_skip"] / sint
83 - v["el2cach"] = d["evict_l2_cached"] / sint
84 - v["el2el"] = d["evict_l2_eligible"] / sint
85 - v["el2mfu"] = d["evict_l2_eligible_mfu"] / sint
86 - v["el2mru"] = d["evict_l2_eligible_mru"] / sint
87 - v["el2inel"] = d["evict_l2_ineligible"] / sint
88 - v["mtxmis"] = d["mutex_miss"] / sint
89 + v["mfu"] = d["mfu_hits"] // sint
90 + v["mru"] = d["mru_hits"] // sint
91 + v["mrug"] = d["mru_ghost_hits"] // sint
92 + v["mfug"] = d["mfu_ghost_hits"] // sint
93 + v["eskip"] = d["evict_skip"] // sint
94 + v["el2skip"] = d["evict_l2_skip"] // sint
95 + v["el2cach"] = d["evict_l2_cached"] // sint
96 + v["el2el"] = d["evict_l2_eligible"] // sint
97 + v["el2mfu"] = d["evict_l2_eligible_mfu"] // sint
98 + v["el2mru"] = d["evict_l2_eligible_mru"] // sint
99 + v["el2inel"] = d["evict_l2_ineligible"] // sint
100 + v["mtxmis"] = d["mutex_miss"] // sint
101
102 if l2exist:
103 - v["l2hits"] = d["l2_hits"] / sint
104 - v["l2miss"] = d["l2_misses"] / sint
105 + v["l2hits"] = d["l2_hits"] // sint
106 + v["l2miss"] = d["l2_misses"] // sint
107 v["l2read"] = v["l2hits"] + v["l2miss"]
108 - v["l2hit%"] = 100 * v["l2hits"] / v["l2read"] if v["l2read"] > 0 else 0
109 + v["l2hit%"] = 100 * v["l2hits"] // v["l2read"] if v["l2read"] > 0 else 0
110
111 v["l2miss%"] = 100 - v["l2hit%"] if v["l2read"] > 0 else 0
112 v["l2asize"] = cur["l2_asize"]
113 v["l2size"] = cur["l2_size"]
114 - v["l2bytes"] = d["l2_read_bytes"] / sint
115 + v["l2bytes"] = d["l2_read_bytes"] // sint
116
117 v["l2pref"] = cur["l2_prefetch_asize"]
118 v["l2mfu"] = cur["l2_mfu_asize"]
119 v["l2mru"] = cur["l2_mru_asize"]
120 v["l2data"] = cur["l2_bufc_data_asize"]
121 v["l2meta"] = cur["l2_bufc_metadata_asize"]
122 - v["l2pref%"] = 100 * v["l2pref"] / v["l2asize"]
123 - v["l2mfu%"] = 100 * v["l2mfu"] / v["l2asize"]
124 - v["l2mru%"] = 100 * v["l2mru"] / v["l2asize"]
125 - v["l2data%"] = 100 * v["l2data"] / v["l2asize"]
126 - v["l2meta%"] = 100 * v["l2meta"] / v["l2asize"]
127 + v["l2pref%"] = 100 * v["l2pref"] // v["l2asize"]
128 + v["l2mfu%"] = 100 * v["l2mfu"] // v["l2asize"]
129 + v["l2mru%"] = 100 * v["l2mru"] // v["l2asize"]
130 + v["l2data%"] = 100 * v["l2data"] // v["l2asize"]
131 + v["l2meta%"] = 100 * v["l2meta"] // v["l2asize"]
132
133 v["grow"] = 0 if cur["arc_no_grow"] else 1
134 v["need"] = cur["arc_need_free"]