1 From 6846b7c2431dbeaddd9f931c609b522c04e55732 Mon Sep 17 00:00:00 2001
2 From: Martin Pitt <martin.pitt@ubuntu.com>
3 Date: Fri, 19 Mar 2010 14:56:06 +0100
4 Subject: [PATCH 2/2] Drop our own "many bad sectors" heuristic
6 This currently causes a lot of false positives, because in many cases our
7 threshold is either overly pessimistically low, or the raw value is implausibly
8 high. Just use the normalized values vs. threshold for now.
10 Bug: https://bugs.freedesktop.org/show_bug.cgi?id=25772
11 Bug-Ubuntu: https://launchpad.net/bugs/438136
13 atasmart.c | 33 +++++++++++----------------------
14 1 files changed, 11 insertions(+), 22 deletions(-)
16 Index: libatasmart/atasmart.c
17 ===================================================================
18 --- libatasmart.orig/atasmart.c 2012-05-23 08:34:14.007836753 +0200
19 +++ libatasmart/atasmart.c 2012-05-23 08:34:43.903835695 +0200
21 SkBool current_pending_sector_found:1;
22 uint64_t reallocated_sector_count;
23 uint64_t current_pending_sector;
24 + SkBool reallocated_sector_count_bad:1;
25 + SkBool current_pending_sector_bad:1;
29 @@ -2190,16 +2192,23 @@
30 if (a->pretty_unit != SK_SMART_ATTRIBUTE_UNIT_SECTORS)
33 + if (!a->current_value_valid)
36 if (!strcmp(a->name, "reallocated-sector-count")) {
37 if (a->pretty_value > d->reallocated_sector_count)
38 d->reallocated_sector_count = a->pretty_value;
39 d->reallocated_sector_count_found = TRUE;
40 + if (a->good_now_valid && !a->good_now)
41 + d->reallocated_sector_count_bad = TRUE;
44 if (!strcmp(a->name, "current-pending-sector")) {
45 if (a->pretty_value > d->current_pending_sector)
46 d->current_pending_sector = a->pretty_value;
47 d->current_pending_sector_found = TRUE;
48 + if (a->good_now_valid && !a->good_now)
49 + d->current_pending_sector_bad = TRUE;
53 @@ -2255,24 +2264,9 @@
54 return _P(map[overall]);
57 -static uint64_t u64log2(uint64_t n) {
72 int sk_disk_smart_get_overall(SkDisk *d, SkSmartOverall *overall) {
74 - uint64_t sectors, sector_threshold;
79 @@ -2293,13 +2287,7 @@
84 - /* We use log2(n_sectors)*1024 as a threshold here. We
85 - * had to pick something, and this makes a bit of
86 - * sense, or doesn't it? */
87 - sector_threshold = u64log2(d->size/512) * 1024;
89 - if (sectors >= sector_threshold) {
90 + if (d->reallocated_sector_count_bad || d->current_pending_sector_bad) {
91 *overall = SK_SMART_OVERALL_BAD_SECTOR_MANY;