1
1

scsicmds.cpp,scsiprint.cpp: the 'Long (extended) Self-test duration' at the end of smartctl -a output comes from a 16 bit field holding seconds. On overflow consult Extended Inquiry VPD page

git-svn-id: http://svn.code.sf.net/p/smartmontools/code/trunk@5305 4ea69e1a-61f1-4043-bf83-b5c94c648137
Этот коммит содержится в:
dpgilbert 2022-01-29 03:27:45 +00:00
родитель c56e9b8311
Коммит cb069e935c
3 изменённых файлов: 38 добавлений и 7 удалений

Просмотреть файл

@ -1,5 +1,17 @@
$Id$
2022-01-28 Douglas Gilbert <dgilbert@interlog.com>
scsicmds.cpp,scsiprint.cpp: the "Long (extended)
Self-test duration" at the end of smartctl -a output
comes from a 16 bit field holding seconds. If the
value is 0xffff the spec now says to consult the
Extended Inquiry VPD page which has a similar field
but the unit is minutes. Tweak the output if the
duration exceeds 14400 seconds: calculate hours
in brackets [normally minutes]. Reason: my 20 TB
disk reports 38.7 hours to do a long self-test!
2022-01-16 Douglas Gilbert <dgilbert@interlog.com>
scsiprint.cpp: my tape drive gives a nuisance TapeAlert

Просмотреть файл

@ -1040,7 +1040,7 @@ scsiRequestSense(scsi_device * device, struct scsi_sense_disect * sense_info)
* Power condition command. Returns 0 if ok, anything else major problem.
* If power_cond is 0, treat as SSU(START) as that is better than
* SSU(STOP) which would be the case if byte 4 of the cdb was zero.
* Ref: SBC-4 revision 22, section 4.20 SSU and power conditions.
* Ref: SBC-4 revision 22, section 4.20 SSU and power conditions.
*
* SCSI_POW_COND_ACTIVE 0x1
* SCSI_POW_COND_IDLE 0x2
@ -2359,10 +2359,25 @@ scsiFetchExtendedSelfTestTime(scsi_device * device, int * durationSec,
return -EINVAL;
if (buff[offset + 1] >= 0xa) {
int res = sg_get_unaligned_be16(buff + offset + 10);
*durationSec = res;
return 0;
}
else
if (res < 0xffff) {
*durationSec = res;
return 0;
}
/* The value 0xffff (all bits set in 16 bit field) indicates that
* the Extended Inquiry VPD page should be consulted, it has a
* similarly named 16 bit field, but the unit is minutes. */
uint8_t b[64];
if ((0 == scsiInquiryVpd(device, SCSI_VPD_EXTENDED_INQUIRY_DATA,
b, sizeof(b))) &&
((sg_get_unaligned_be16(b + 2)) > 11)) {
res = sg_get_unaligned_be16(b + 10);
*durationSec = res * 60; /* VPD field is in minutes */
return 0;
} else
return -EINVAL;
} else
return -EINVAL;
}

Просмотреть файл

@ -1198,8 +1198,12 @@ scsiPrintSelfTest(scsi_device * device)
jout("No %ss have been logged\n", hname);
else if ((0 == scsiFetchExtendedSelfTestTime(device, &durationSec,
modese_len)) && (durationSec > 0)) {
jout("\nLong (extended) %s duration: %d seconds "
"[%.1f minutes]\n", hname, durationSec, durationSec / 60.0);
if (durationSec > 14400)
jout("\nLong (extended) %s duration: %d seconds "
"[%.1f hours]\n", hname, durationSec, durationSec / 3600.0);
else
jout("\nLong (extended) %s duration: %d seconds "
"[%.1f minutes]\n", hname, durationSec, durationSec / 60.0);
jglb["scsi_extended_self_test_seconds"] = durationSec;
}
jout("\n");