1. Summary
  2. Files
  3. Support
  4. Report Spam
  5. Create account
  6. Log in

Changeset 3132

Show
Ignore:
Timestamp:
08/17/10 20:27:19 (3 years ago)
Author:
chrfranke
Message:

Allow SMART threshold entries at positions different from attribute table.

Location:
trunk/smartmontools
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/smartmontools/CHANGELOG

    r3131 r3132  
    4343<DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE> 
    4444 
     45  [CF] Allow SMART threshold entries at positions different from 
     46       attribute table. This fixes attribute output for recent 
     47       SSDs with SandForce controller. 
     48 
    4549  [CF] smartctl: Add option '-t vendor,N' to issue ATA 
    4650       command SMART EXECUTE OFF-LINE IMMEDIATE with 
  • trunk/smartmontools/atacmds.cpp

    r3131 r3132  
    17421742// Get attribute state 
    17431743ata_attr_state ata_get_attr_state(const ata_smart_attribute & attr, 
    1744                                   const ata_smart_threshold_entry & thre, 
    1745                                   const ata_vendor_attr_defs & defs) 
     1744                                  int attridx, 
     1745                                  const ata_smart_threshold_entry * thresholds, 
     1746                                  const ata_vendor_attr_defs & defs, 
     1747                                  unsigned char * threshval /* = 0 */) 
    17461748{ 
    17471749  if (!attr.id) 
     
    17541756    return ATTRSTATE_NO_NORMVAL; 
    17551757 
    1756   // No threshold if thresholds cannot be read. 
    1757   if (!thre.id && !thre.threshold) 
    1758     return ATTRSTATE_NO_THRESHOLD; 
    1759  
    1760   // Bad threshold if id's don't match 
    1761   if (attr.id != thre.id) 
    1762     return ATTRSTATE_BAD_THRESHOLD; 
     1758  // Normally threshold is at same index as attribute 
     1759  int i = attridx; 
     1760  if (thresholds[i].id != attr.id) { 
     1761    // Find threshold id in table 
     1762    for (i = 0; thresholds[i].id != attr.id; ) { 
     1763      if (++i >= NUMBER_ATA_SMART_ATTRIBUTES) 
     1764        // Threshold id missing or thresholds cannot be read 
     1765        return ATTRSTATE_NO_THRESHOLD; 
     1766    } 
     1767  } 
     1768  unsigned char threshold = thresholds[i].threshold; 
     1769 
     1770  // Return threshold if requested 
     1771  if (threshval) 
     1772    *threshval = threshold; 
    17631773 
    17641774  // Don't report a failed attribute if its threshold is 0. 
     
    17661776  // threshold (Later ATA versions declare all thresholds as "obsolete"). 
    17671777  // In practice, threshold value 0 is often used for usage attributes. 
    1768   if (!thre.threshold) 
     1778  if (!threshold) 
    17691779    return ATTRSTATE_OK; 
    17701780 
    17711781  // Failed now if current value is below threshold 
    1772   if (attr.current <= thre.threshold) 
     1782  if (attr.current <= threshold) 
    17731783    return ATTRSTATE_FAILED_NOW; 
    17741784 
    17751785  // Failed in the past if worst value is below threshold 
    1776   if (!(defs[attr.id].flags & ATTRFLAG_NO_WORSTVAL) && attr.worst <= thre.threshold) 
     1786  if (!(defs[attr.id].flags & ATTRFLAG_NO_WORSTVAL) && attr.worst <= threshold) 
    17771787    return ATTRSTATE_FAILED_PAST; 
    17781788 
  • trunk/smartmontools/atacmds.h

    r3065 r3132  
    827827  ATTRSTATE_NON_EXISTING,   // No such Attribute 
    828828  ATTRSTATE_NO_NORMVAL,     // Normalized value not valid 
    829   ATTRSTATE_BAD_THRESHOLD,  // Threshold not valid 
    830829  ATTRSTATE_NO_THRESHOLD,   // Unknown or no threshold 
    831830  ATTRSTATE_OK,             // Never failed 
     
    836835// Get attribute state 
    837836ata_attr_state ata_get_attr_state(const ata_smart_attribute & attr, 
    838                                   const ata_smart_threshold_entry & thre, 
    839                                   const ata_vendor_attr_defs & defs); 
     837                                  int attridx, 
     838                                  const ata_smart_threshold_entry * thresholds, 
     839                                  const ata_vendor_attr_defs & defs, 
     840                                  unsigned char * threshval = 0); 
    840841 
    841842// Get attribute raw value. 
  • trunk/smartmontools/ataprint.cpp

    r3131 r3132  
    787787    const ata_smart_attribute & attr = data->vendor_attributes[i]; 
    788788 
    789     ata_attr_state state = ata_get_attr_state(attr, 
    790                              thresholds->thres_entries[i], defs); 
     789    ata_attr_state state = ata_get_attr_state(attr, i, thresholds->thres_entries, defs); 
    791790 
    792791    if (!onlyfailed) { 
     
    815814  for (int i = 0; i < NUMBER_ATA_SMART_ATTRIBUTES; i++) { 
    816815    const ata_smart_attribute & attr = data->vendor_attributes[i]; 
    817     const ata_smart_threshold_entry & thre = thresholds->thres_entries[i]; 
     816    //const ata_smart_threshold_entry & thre = thresholds->thres_entries[i]; 
    818817 
    819818    // Check attribute and threshold 
    820     ata_attr_state state = ata_get_attr_state(attr, thre, defs); 
     819    unsigned char threshold = 0; 
     820    ata_attr_state state = ata_get_attr_state(attr, i, thresholds->thres_entries, defs, &threshold); 
    821821    if (state == ATTRSTATE_NON_EXISTING) 
    822822      continue; 
     
    850850      worstr = "---"; 
    851851    if (state > ATTRSTATE_NO_THRESHOLD) 
    852       threstr = strprintf("%.3d", thre.threshold); 
     852      threstr = strprintf("%.3d", threshold); 
    853853    else 
    854854      threstr = "---"; 
     
    865865                                           "    -"        ), 
    866866         ata_format_attr_raw_value(attr, defs).c_str()); 
    867  
    868     // Print a warning if there is inconsistency here 
    869     if (state == ATTRSTATE_BAD_THRESHOLD) { 
    870       pout("%3d %-24s<== Data Page      |  WARNING: PREVIOUS ATTRIBUTE HAS TWO\n", 
    871            attr.id, attrname.c_str()); 
    872       pout("%3d %-24s<== Threshold Page |  INCONSISTENT IDENTITIES IN THE DATA\n", 
    873            thre.id, ata_get_smart_attr_name(thre.id, defs).c_str()); 
    874     } 
    875867  } 
    876868  if (!needheader) pout("\n"); 
  • trunk/smartmontools/smartd.cpp

    r3101 r3132  
    25402540                            const ata_smart_attribute & attr, 
    25412541                            const ata_smart_attribute & prev, 
    2542                             const ata_smart_threshold_entry & thre) 
     2542                            int attridx, 
     2543                            const ata_smart_threshold_entry * thresholds) 
    25432544{ 
    25442545  // Check attribute and threshold 
    2545   ata_attr_state attrstate = ata_get_attr_state(attr, thre, cfg.attribute_defs); 
     2546  ata_attr_state attrstate = ata_get_attr_state(attr, attridx, thresholds, cfg.attribute_defs); 
    25462547  if (attrstate == ATTRSTATE_NON_EXISTING) 
    25472548    return; 
     
    25672568 
    25682569  // Issue warning if they don't have the same ID in all structures. 
    2569   if (attr.id != prev.id || attrstate == ATTRSTATE_BAD_THRESHOLD) { 
    2570     PrintOut(LOG_INFO,"Device: %s, same Attribute has different ID numbers: %d = %d = %d\n", 
    2571              cfg.name.c_str(), attr.id, prev.id, thre.id); 
     2570  if (attr.id != prev.id) { 
     2571    PrintOut(LOG_INFO,"Device: %s, same Attribute has different ID numbers: %d = %d\n", 
     2572             cfg.name.c_str(), attr.id, prev.id); 
    25722573    return; 
    25732574  } 
     
    27742775                          curval.vendor_attributes[i], 
    27752776                          state.smartval.vendor_attributes[i], 
    2776                           state.smartthres.thres_entries[i]); 
     2777                          i, state.smartthres.thres_entries); 
    27772778        } 
    27782779