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

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