diff --git a/debian/changelog b/debian/changelog index 3cf6763..ef9da0b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,8 @@ libatasmart (0.18-1) UNRELEASED; urgency=low * New upstream release. + * Remove 0001-Speed-up-get_overall-and-get_bad.patch, merged upstream. + * Refresh 0002-Drop-our-own-many-bad-sectors-heuristic.patch. -- Michael Biebl Wed, 12 Oct 2011 00:57:44 +0200 diff --git a/debian/patches/0001-Speed-up-get_overall-and-get_bad.patch b/debian/patches/0001-Speed-up-get_overall-and-get_bad.patch deleted file mode 100644 index 0cde046..0000000 --- a/debian/patches/0001-Speed-up-get_overall-and-get_bad.patch +++ /dev/null @@ -1,179 +0,0 @@ -From 2b24de1dc2314c28bce6e89050f16aa0dcac8031 Mon Sep 17 00:00:00 2001 -From: Martin Pitt -Date: Tue, 2 Mar 2010 09:58:59 +0100 -Subject: [PATCH 1/2] Speed up get_overall() and get_bad() - -Instead of iterating through all attributes four times for an -sk_disk_smart_get_overall() call, just do it once and store the results in -SkDisk. This considerably speeds up libatasmart for common operations like -smart_get_overall() and smart_get_bad(). - -https://bugs.freedesktop.org/show_bug.cgi?id=26834 ---- - atasmart.c | 97 +++++++++++++++++++++++++++-------------------------------- - 1 files changed, 44 insertions(+), 53 deletions(-) - -diff --git a/atasmart.c b/atasmart.c -index a4b60c0..13d55ff 100644 ---- a/atasmart.c -+++ b/atasmart.c -@@ -122,6 +122,15 @@ struct SkDisk { - SkIdentifyParsedData identify_parsed_data; - SkSmartParsedData smart_parsed_data; - -+ /* cache for commonly used attributes */ -+ SkBool attribute_cache_valid:1; -+ SkBool bad_attribute_now:1; -+ SkBool bad_attribute_in_the_past:1; -+ SkBool reallocated_sector_count_found:1; -+ SkBool current_pending_sector_found:1; -+ uint64_t reallocated_sector_count; -+ uint64_t current_pending_sector; -+ - void *blob; - }; - -@@ -2015,64 +2024,61 @@ int sk_disk_smart_get_power_cycle(SkDisk *d, uint64_t *count) { - return 0; - } - --static void reallocated_cb(SkDisk *d, const SkSmartAttributeParsedData *a, struct attr_helper *ah) { -- -- if (a->pretty_unit != SK_SMART_ATTRIBUTE_UNIT_SECTORS) -- return; -- -- if (!strcmp(a->name, "reallocated-sector-count")) { -+static void fill_cache_cb(SkDisk *d, const SkSmartAttributeParsedData *a, void* userdata) { - -- if (!ah->found || a->pretty_value > *ah->value) -- *ah->value = a->pretty_value; -+ if (a->prefailure) { -+ if (a->good_now_valid && !a->good_now) -+ d->bad_attribute_now = TRUE; - -- ah->found = TRUE; -+ if (a->good_in_the_past_valid && !a->good_in_the_past) -+ d->bad_attribute_in_the_past = TRUE; - } --} -- --static void pending_cb(SkDisk *d, const SkSmartAttributeParsedData *a, struct attr_helper *ah) { - - if (a->pretty_unit != SK_SMART_ATTRIBUTE_UNIT_SECTORS) - return; - -+ if (!strcmp(a->name, "reallocated-sector-count")) { -+ if (a->pretty_value > d->reallocated_sector_count) -+ d->reallocated_sector_count = a->pretty_value; -+ d->reallocated_sector_count_found = TRUE; -+ } -+ - if (!strcmp(a->name, "current-pending-sector")) { -+ if (a->pretty_value > d->current_pending_sector) -+ d->current_pending_sector = a->pretty_value; -+ d->current_pending_sector_found = TRUE; -+ } -+} - -- if (!ah->found || a->pretty_value > *ah->value) -- *ah->value = a->pretty_value; -+static int fill_cache(SkDisk *d) { -+ if (d->attribute_cache_valid) -+ return 0; - -- ah->found = TRUE; -- } -+ if (sk_disk_smart_parse_attributes(d, (SkSmartAttributeParseCallback) fill_cache_cb, NULL) >= 0) { -+ d->attribute_cache_valid = TRUE; -+ return 0; -+ } else -+ return -1; - } - - int sk_disk_smart_get_bad(SkDisk *d, uint64_t *sectors) { -- struct attr_helper ah1, ah2; -- uint64_t sectors1, sectors2; -- - assert(d); - assert(sectors); - -- ah1.found = FALSE; -- ah1.value = §ors1; -- -- if (sk_disk_smart_parse_attributes(d, (SkSmartAttributeParseCallback) reallocated_cb, &ah1) < 0) -+ if (fill_cache (d) < 0) - return -1; - -- ah2.found = FALSE; -- ah2.value = §ors2; -- -- if (sk_disk_smart_parse_attributes(d, (SkSmartAttributeParseCallback) pending_cb, &ah2) < 0) -- return -1; -- -- if (!ah1.found && !ah2.found) { -+ if (!d->reallocated_sector_count_found && !d->current_pending_sector_found) { - errno = ENOENT; - return -1; - } - -- if (ah1.found && ah2.found) -- *sectors = sectors1 + sectors2; -- else if (ah1.found) -- *sectors = sectors1; -+ if (d->reallocated_sector_count_found && d->current_pending_sector_found) -+ *sectors = d->reallocated_sector_count + d->current_pending_sector; -+ else if (d->reallocated_sector_count_found) -+ *sectors = d->reallocated_sector_count; - else -- *sectors = sectors2; -+ *sectors = d->current_pending_sector; - - return 0; - } -@@ -2096,16 +2102,6 @@ const char* sk_smart_overall_to_string(SkSmartOverall overall) { - return _P(map[overall]); - } - --static void bad_attribute_now_cb(SkDisk *d, const SkSmartAttributeParsedData *a, SkBool *good) { -- if (a->prefailure && a->good_now_valid && !a->good_now) -- *good = FALSE; --} -- --static void bad_attribute_in_the_past_cb(SkDisk *d, const SkSmartAttributeParsedData *a, SkBool *good) { -- if (a->prefailure && a->good_in_the_past_valid && !a->good_in_the_past) -- *good = FALSE; --} -- - static uint64_t u64log2(uint64_t n) { - unsigned r; - -@@ -2156,11 +2152,10 @@ int sk_disk_smart_get_overall(SkDisk *d, SkSmartOverall *overall) { - } - - /* Third, check if any of the SMART attributes is bad */ -- good = TRUE; -- if (sk_disk_smart_parse_attributes(d, (SkSmartAttributeParseCallback) bad_attribute_now_cb, &good) < 0) -+ if (fill_cache (d) < 0) - return -1; - -- if (!good) { -+ if (d->bad_attribute_now) { - *overall = SK_SMART_OVERALL_BAD_ATTRIBUTE_NOW; - return 0; - } -@@ -2172,11 +2167,7 @@ int sk_disk_smart_get_overall(SkDisk *d, SkSmartOverall *overall) { - } - - /* Fifth, check if any of the SMART attributes ever was bad */ -- good = TRUE; -- if (sk_disk_smart_parse_attributes(d, (SkSmartAttributeParseCallback) bad_attribute_in_the_past_cb, &good) < 0) -- return -1; -- -- if (!good) { -+ if (d->bad_attribute_in_the_past) { - *overall = SK_SMART_OVERALL_BAD_ATTRIBUTE_IN_THE_PAST; - return 0; - } --- -1.7.0 - diff --git a/debian/patches/0002-Drop-our-own-many-bad-sectors-heuristic.patch b/debian/patches/0002-Drop-our-own-many-bad-sectors-heuristic.patch index fc55cb2..ad35662 100644 --- a/debian/patches/0002-Drop-our-own-many-bad-sectors-heuristic.patch +++ b/debian/patches/0002-Drop-our-own-many-bad-sectors-heuristic.patch @@ -13,11 +13,11 @@ atasmart.c | 33 +++++++++++---------------------- 1 files changed, 11 insertions(+), 22 deletions(-) -diff --git a/atasmart.c b/atasmart.c -index 13d55ff..beb57b2 100644 ---- a/atasmart.c -+++ b/atasmart.c -@@ -130,6 +130,8 @@ struct SkDisk { +Index: libatasmart/atasmart.c +=================================================================== +--- libatasmart.orig/atasmart.c 2011-10-12 00:52:15.000000000 +0200 ++++ libatasmart/atasmart.c 2011-10-12 00:56:23.726017536 +0200 +@@ -130,6 +130,8 @@ SkBool current_pending_sector_found:1; uint64_t reallocated_sector_count; uint64_t current_pending_sector; @@ -26,7 +26,7 @@ void *blob; }; -@@ -2037,16 +2039,23 @@ static void fill_cache_cb(SkDisk *d, const SkSmartAttributeParsedData *a, void* +@@ -2181,16 +2183,23 @@ if (a->pretty_unit != SK_SMART_ATTRIBUTE_UNIT_SECTORS) return; @@ -50,7 +50,7 @@ } } -@@ -2102,24 +2111,9 @@ const char* sk_smart_overall_to_string(SkSmartOverall overall) { +@@ -2246,24 +2255,9 @@ return _P(map[overall]); } @@ -76,20 +76,18 @@ assert(d); assert(overall); -@@ -2140,12 +2134,7 @@ int sk_disk_smart_get_overall(SkDisk *d, SkSmartOverall *overall) { +@@ -2284,13 +2278,7 @@ return -1; sectors = 0; } else { - -- /* We use log2(n_sectors) as a threshold here. We had to pick -- * something, and this makes a bit of sense, or doesn't it? */ -- sector_threshold = u64log2(d->size/512); +- /* We use log2(n_sectors)*1024 as a threshold here. We +- * had to pick something, and this makes a bit of +- * sense, or doesn't it? */ +- sector_threshold = u64log2(d->size/512) * 1024; - - if (sectors >= sector_threshold) { + if (d->reallocated_sector_count_bad || d->current_pending_sector_bad) { *overall = SK_SMART_OVERALL_BAD_SECTOR_MANY; return 0; } --- -1.7.0 - diff --git a/debian/patches/series b/debian/patches/series index b39474e..8605cc9 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,3 +1,2 @@ # Debian patches for libatasmart -0001-Speed-up-get_overall-and-get_bad.patch 0002-Drop-our-own-many-bad-sectors-heuristic.patch