krishnanadh / rpms / rasdaemon

Forked from rpms/rasdaemon a year ago
Clone

Blame SOURCES/0039-rasdaemon-do-not-assume-dimmX-directories-will-be-pr.patch

d9e469
From 7e79fa94dc6c294cd731c0c684b277dd4811c5db Mon Sep 17 00:00:00 2001
d9e469
From: Aristeu Rozanski <aris@redhat.com>
d9e469
Date: Fri, 15 Aug 2014 13:50:58 -0400
d9e469
Subject: [PATCH 3/4] rasdaemon: do not assume dimmX/ directories will be
d9e469
 present
d9e469
d9e469
While finding the labels, size and location, ras-mc-ctl will search /sys for
d9e469
the files and calculate the location. When it uses the location trying to map
d9e469
back to files to print labels or write labels, it'll just assume dimm*
d9e469
directories exist which is not correct while using drivers like amd64_edac.
d9e469
This patch adds two new hashes to store the location and the label file path
d9e469
so it can be used later.
d9e469
d9e469
Signed-off-by: Aristeu Rozanski <aris@redhat.com>
d9e469
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
d9e469
---
d9e469
 util/ras-mc-ctl.in | 21 +++++++++++++--------
d9e469
 1 file changed, 13 insertions(+), 8 deletions(-)
d9e469
d9e469
diff --git a/util/ras-mc-ctl.in b/util/ras-mc-ctl.in
d9e469
index 110262f..7b6d798 100755
d9e469
--- a/util/ras-mc-ctl.in
d9e469
+++ b/util/ras-mc-ctl.in
d9e469
@@ -45,6 +45,8 @@ my %conf        = ();
d9e469
 my %bus         = ();
d9e469
 my %dimm_size   = ();
d9e469
 my %dimm_node   = ();
d9e469
+my %dimm_label_file = ();
d9e469
+my %dimm_location = ();
d9e469
 my %csrow_size  = ();
d9e469
 my %rank_size   = ();
d9e469
 my %csrow_ranks = ();
d9e469
@@ -278,6 +280,9 @@ sub parse_dimm_nodes
d9e469
         my $str_loc = join(':', $mc, @pos);
d9e469
         $dimm_size{$str_loc} = $size;
d9e469
         $dimm_node{$str_loc} = $dimm;
d9e469
+        $file =~ s/size/dimm_label/;
d9e469
+        $dimm_label_file{$str_loc} = $file;
d9e469
+        $dimm_location{$str_loc} = $location;
d9e469
 
d9e469
         return;
d9e469
     }
d9e469
@@ -557,12 +562,14 @@ sub read_dimm_label
d9e469
 
d9e469
     my $dimm = $dimm_node{$pos};
d9e469
 
d9e469
-    my $file = "$sysfs/mc$mc/dimm$dimm/dimm_label";
d9e469
+    my $dimm_label_file = $dimm_label_file{$pos};
d9e469
 
d9e469
-    return ("$pos missing") unless -f $file;
d9e469
+    my $location = $dimm_location{$pos};
d9e469
 
d9e469
-    if (!open (LABEL, "$file")) {
d9e469
-        warn "Failed to open $file: $!\n";
d9e469
+    return ("label missing", "$pos missing") unless -f $dimm_label_file;
d9e469
+
d9e469
+    if (!open (LABEL, "$dimm_label_file")) {
d9e469
+        warn "Failed to open $dimm_label_file: $!\n";
d9e469
         return ("Error");
d9e469
     }
d9e469
 
d9e469
@@ -570,7 +577,7 @@ sub read_dimm_label
d9e469
 
d9e469
     close (LABEL);
d9e469
 
d9e469
-    $pos = "mc$mc " . qx(cat $sysfs/mc$mc/dimm$dimm/dimm_location);
d9e469
+    $pos = "mc$mc $location";
d9e469
 
d9e469
     return ($label, $pos);
d9e469
 }
d9e469
@@ -587,9 +594,7 @@ sub get_dimm_label_node
d9e469
 
d9e469
     return "" if (!defined($dimm_node{$pos}));
d9e469
 
d9e469
-    my $dimm = $dimm_node{$pos};
d9e469
-
d9e469
-    return "$sysfs/mc$mc/dimm$dimm/dimm_label";
d9e469
+    return "$dimm_label_file{$pos}";
d9e469
 }
d9e469
 
d9e469
 
d9e469
-- 
d9e469
1.8.3.1
d9e469