krishnanadh / rpms / rasdaemon

Forked from rpms/rasdaemon a year ago
Clone

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

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