Changeset 3132
- Timestamp:
- 08/17/10 20:27:19 (3 years ago)
- Location:
- trunk/smartmontools
- Files:
-
- 5 modified
-
CHANGELOG (modified) (1 diff)
-
atacmds.cpp (modified) (3 diffs)
-
atacmds.h (modified) (2 diffs)
-
ataprint.cpp (modified) (4 diffs)
-
smartd.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/smartmontools/CHANGELOG
r3131 r3132 43 43 <DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE> 44 44 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 45 49 [CF] smartctl: Add option '-t vendor,N' to issue ATA 46 50 command SMART EXECUTE OFF-LINE IMMEDIATE with -
trunk/smartmontools/atacmds.cpp
r3131 r3132 1742 1742 // Get attribute state 1743 1743 ata_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 */) 1746 1748 { 1747 1749 if (!attr.id) … … 1754 1756 return ATTRSTATE_NO_NORMVAL; 1755 1757 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; 1763 1773 1764 1774 // Don't report a failed attribute if its threshold is 0. … … 1766 1776 // threshold (Later ATA versions declare all thresholds as "obsolete"). 1767 1777 // In practice, threshold value 0 is often used for usage attributes. 1768 if (!thre .threshold)1778 if (!threshold) 1769 1779 return ATTRSTATE_OK; 1770 1780 1771 1781 // Failed now if current value is below threshold 1772 if (attr.current <= thre .threshold)1782 if (attr.current <= threshold) 1773 1783 return ATTRSTATE_FAILED_NOW; 1774 1784 1775 1785 // 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) 1777 1787 return ATTRSTATE_FAILED_PAST; 1778 1788 -
trunk/smartmontools/atacmds.h
r3065 r3132 827 827 ATTRSTATE_NON_EXISTING, // No such Attribute 828 828 ATTRSTATE_NO_NORMVAL, // Normalized value not valid 829 ATTRSTATE_BAD_THRESHOLD, // Threshold not valid830 829 ATTRSTATE_NO_THRESHOLD, // Unknown or no threshold 831 830 ATTRSTATE_OK, // Never failed … … 836 835 // Get attribute state 837 836 ata_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); 840 841 841 842 // Get attribute raw value. -
trunk/smartmontools/ataprint.cpp
r3131 r3132 787 787 const ata_smart_attribute & attr = data->vendor_attributes[i]; 788 788 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); 791 790 792 791 if (!onlyfailed) { … … 815 814 for (int i = 0; i < NUMBER_ATA_SMART_ATTRIBUTES; i++) { 816 815 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]; 818 817 819 818 // 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); 821 821 if (state == ATTRSTATE_NON_EXISTING) 822 822 continue; … … 850 850 worstr = "---"; 851 851 if (state > ATTRSTATE_NO_THRESHOLD) 852 threstr = strprintf("%.3d", thre .threshold);852 threstr = strprintf("%.3d", threshold); 853 853 else 854 854 threstr = "---"; … … 865 865 " -" ), 866 866 ata_format_attr_raw_value(attr, defs).c_str()); 867 868 // Print a warning if there is inconsistency here869 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 }875 867 } 876 868 if (!needheader) pout("\n"); -
trunk/smartmontools/smartd.cpp
r3101 r3132 2540 2540 const ata_smart_attribute & attr, 2541 2541 const ata_smart_attribute & prev, 2542 const ata_smart_threshold_entry & thre) 2542 int attridx, 2543 const ata_smart_threshold_entry * thresholds) 2543 2544 { 2544 2545 // 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); 2546 2547 if (attrstate == ATTRSTATE_NON_EXISTING) 2547 2548 return; … … 2567 2568 2568 2569 // 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); 2572 2573 return; 2573 2574 } … … 2774 2775 curval.vendor_attributes[i], 2775 2776 state.smartval.vendor_attributes[i], 2776 state.smartthres.thres_entries[i]);2777 i, state.smartthres.thres_entries); 2777 2778 } 2778 2779