|
0 |
From 6846b7c2431dbeaddd9f931c609b522c04e55732 Mon Sep 17 00:00:00 2001
|
|
1 |
From: Martin Pitt <martin.pitt@ubuntu.com>
|
|
2 |
Date: Fri, 19 Mar 2010 14:56:06 +0100
|
|
3 |
Subject: [PATCH 2/2] Drop our own "many bad sectors" heuristic
|
|
4 |
|
|
5 |
This currently causes a lot of false positives, because in many cases our
|
|
6 |
treshold is either overly pessimistically low, or the raw value is implausibly
|
|
7 |
high. Just use the normalized values vs. treshold for now.
|
|
8 |
|
|
9 |
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=25772
|
|
10 |
Bug-Ubuntu: https://launchpad.net/bugs/438136
|
|
11 |
---
|
|
12 |
atasmart.c | 33 +++++++++++----------------------
|
|
13 |
1 files changed, 11 insertions(+), 22 deletions(-)
|
|
14 |
|
|
15 |
diff --git a/atasmart.c b/atasmart.c
|
|
16 |
index 13d55ff..beb57b2 100644
|
|
17 |
--- a/atasmart.c
|
|
18 |
+++ b/atasmart.c
|
|
19 |
@@ -130,6 +130,8 @@ struct SkDisk {
|
|
20 |
SkBool current_pending_sector_found:1;
|
|
21 |
uint64_t reallocated_sector_count;
|
|
22 |
uint64_t current_pending_sector;
|
|
23 |
+ SkBool reallocated_sector_count_bad:1;
|
|
24 |
+ SkBool current_pending_sector_bad:1;
|
|
25 |
|
|
26 |
void *blob;
|
|
27 |
};
|
|
28 |
@@ -2037,16 +2039,23 @@ static void fill_cache_cb(SkDisk *d, const SkSmartAttributeParsedData *a, void*
|
|
29 |
if (a->pretty_unit != SK_SMART_ATTRIBUTE_UNIT_SECTORS)
|
|
30 |
return;
|
|
31 |
|
|
32 |
+ if (!a->current_value_valid)
|
|
33 |
+ return;
|
|
34 |
+
|
|
35 |
if (!strcmp(a->name, "reallocated-sector-count")) {
|
|
36 |
if (a->pretty_value > d->reallocated_sector_count)
|
|
37 |
d->reallocated_sector_count = a->pretty_value;
|
|
38 |
d->reallocated_sector_count_found = TRUE;
|
|
39 |
+ if (a->good_now_valid && !a->good_now)
|
|
40 |
+ d->reallocated_sector_count_bad = TRUE;
|
|
41 |
}
|
|
42 |
|
|
43 |
if (!strcmp(a->name, "current-pending-sector")) {
|
|
44 |
if (a->pretty_value > d->current_pending_sector)
|
|
45 |
d->current_pending_sector = a->pretty_value;
|
|
46 |
d->current_pending_sector_found = TRUE;
|
|
47 |
+ if (a->good_now_valid && !a->good_now)
|
|
48 |
+ d->current_pending_sector_bad = TRUE;
|
|
49 |
}
|
|
50 |
}
|
|
51 |
|
|
52 |
@@ -2102,24 +2111,9 @@ const char* sk_smart_overall_to_string(SkSmartOverall overall) {
|
|
53 |
return _P(map[overall]);
|
|
54 |
}
|
|
55 |
|
|
56 |
-static uint64_t u64log2(uint64_t n) {
|
|
57 |
- unsigned r;
|
|
58 |
-
|
|
59 |
- if (n <= 1)
|
|
60 |
- return 0;
|
|
61 |
-
|
|
62 |
- r = 0;
|
|
63 |
- for (;;) {
|
|
64 |
- n = n >> 1;
|
|
65 |
- if (!n)
|
|
66 |
- return r;
|
|
67 |
- r++;
|
|
68 |
- }
|
|
69 |
-}
|
|
70 |
-
|
|
71 |
int sk_disk_smart_get_overall(SkDisk *d, SkSmartOverall *overall) {
|
|
72 |
SkBool good;
|
|
73 |
- uint64_t sectors, sector_threshold;
|
|
74 |
+ uint64_t sectors;
|
|
75 |
|
|
76 |
assert(d);
|
|
77 |
assert(overall);
|
|
78 |
@@ -2140,12 +2134,7 @@ int sk_disk_smart_get_overall(SkDisk *d, SkSmartOverall *overall) {
|
|
79 |
return -1;
|
|
80 |
sectors = 0;
|
|
81 |
} else {
|
|
82 |
-
|
|
83 |
- /* We use log2(n_sectors) as a threshold here. We had to pick
|
|
84 |
- * something, and this makes a bit of sense, or doesn't it? */
|
|
85 |
- sector_threshold = u64log2(d->size/512);
|
|
86 |
-
|
|
87 |
- if (sectors >= sector_threshold) {
|
|
88 |
+ if (d->reallocated_sector_count_bad || d->current_pending_sector_bad) {
|
|
89 |
*overall = SK_SMART_OVERALL_BAD_SECTOR_MANY;
|
|
90 |
return 0;
|
|
91 |
}
|
|
92 |
--
|
|
93 |
1.7.0
|
|
94 |
|