From 35d7ed9c8a10ec9a1713672ce732edfce372d123 Mon Sep 17 00:00:00 2001 From: Johnny Silverman Date: Fri, 7 Nov 2025 18:47:49 +0200 Subject: [PATCH] Add workaround for drives which report `LBAs` read/written but instead report in 32MiB blocks. --- src/mainwindow.cpp | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 9f81f36..d2dac04 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -607,10 +607,6 @@ void MainWindow::populateWindow(const QJsonObject &localObj, const QString &heal } else if (attrObj["name"] == "Host_Writes_32MiB") { double megabytes = (attrObj["raw"].toObject()["value"].toInt() * 32 * 1024.0 * 1024.0) / 1e6; totalMbWritesI64 = static_cast(megabytes); - } else if (attrObj["name"] == "Total_LBAs_Written") { - qlonglong lbaWritten = attrObj["raw"].toObject()["value"].toVariant().toLongLong(); - double megabytes = double(lbaWritten * logicalBlockSize) / 1e6; - totalMbWritesI64 = static_cast(megabytes); } else if (attrObj["name"] == "Host_Writes_GiB" || attrObj["name"] == "Lifetime_Writes_GiB") { double gibibytes = attrObj["raw"].toObject()["value"].toDouble(); double bytesPerGiB = static_cast(1ULL << 30); @@ -618,6 +614,17 @@ void MainWindow::populateWindow(const QJsonObject &localObj, const QString &heal double conversionFactor = bytesPerGiB / bytesPerMB; double megabytes = gibibytes * conversionFactor; totalMbWritesI64 = static_cast(megabytes); + } else if (attrObj["name"] == "Total_LBAs_Written") { + qlonglong lbaWritten = attrObj["raw"].toObject()["value"].toVariant().toLongLong(); + double megabytes = double(logicalBlockSize * lbaWritten) / 1e6; + totalMbWritesI64 = static_cast(megabytes); + // workaround: for drives that report different value with bad attribute name + // Check if total MB writes are less than power on hours + if (totalMbWritesI64 / powerOnTimeInt == 0) { + // Assume it's 32MiB chunks reported as LBAs + megabytes = (double(lbaWritten * 32) * 1024.0 * 1024.0) / 1e6; + totalMbWritesI64 = static_cast(megabytes); + } } } else if (attrObj["id"] == 242) { if (attrObj["name"] == "Total_Reads_GB") { @@ -626,10 +633,6 @@ void MainWindow::populateWindow(const QJsonObject &localObj, const QString &heal } else if (attrObj["name"] == "Host_Reads_32MiB") { double megabytes = (attrObj["raw"].toObject()["value"].toInt() * 32 * 1024 * 1024) / 1e6; totalMbReadsI64 = static_cast(megabytes); - } else if (attrObj["name"] == "Total_LBAs_Read") { - qlonglong lbaRead = attrObj["raw"].toObject()["value"].toVariant().toLongLong(); - double megabytes = double(lbaRead * logicalBlockSize) / 1e6; - totalMbReadsI64 = static_cast(megabytes); } else if (attrObj["name"] == "Host_Reads_GiB" || attrObj["name"] == "Lifetime_Reads_GiB") { double gibibytes = attrObj["raw"].toObject()["value"].toDouble(); double bytesPerGiB = static_cast(1ULL << 30); @@ -637,6 +640,17 @@ void MainWindow::populateWindow(const QJsonObject &localObj, const QString &heal double conversionFactor = bytesPerGiB / bytesPerMB; double megabytes = gibibytes * conversionFactor; totalMbReadsI64 = static_cast(megabytes); + } else if (attrObj["name"] == "Total_LBAs_Read") { + qlonglong lbaRead = attrObj["raw"].toObject()["value"].toVariant().toLongLong(); + double megabytes = double(logicalBlockSize * lbaRead) / 1e6; + totalMbReadsI64 = static_cast(megabytes); + // workaround for drives that report different value with bad attribute name + // Check if total MB reads are less than power on hours + if (totalMbReadsI64 / powerOnTimeInt == 0) { + // Assume it's 32MiB chunks reported as LBAs + megabytes = (double(lbaRead * 32) * 1024.0 * 1024.0) / 1e6; + totalMbReadsI64 = static_cast(megabytes); + } } } else if (attrObj["id"] == 246) { // MX500 if (attrObj["name"] == "Total_LBAs_Written") {