Menu

#65 scsi status incorrectly handled

v1.0 (example)
open
nobody
None
3
2018-01-05
2015-08-25
Markus
No

When trying to read a sector on a dying harddisk with hdparm --read-sector (v. 9.48 freshly downloaded and compiled) I receive success but data probably from computer (kernel?) memory. Thus the data is invalid and not at all successfully read from disk.

Sample:
hdparm --verbose --read-sector 1001 /dev/sdb

/dev/sdb:
reading sector 1001: oflags.bits.lob_all=0xfc, flags={ nsect lbal lbam lbah dev command }
oflags.bits.hob_all=0x00, flags={ }
outgoing cdb: 85 08 0e 00 00 00 01 00 e9 00 03 00 00 e0 20 00
SG_IO: ATA_16 status=0x2, host_status=0x0, driver_status=0x8
SG_IO: sb[]: 70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
incoming_data: 0c 00 8c 16 39 2e 2b 1b 08 01 00 00 58 75 90 52 10 01 00 00 1e
....

In sgio.c of hdparm uses status directly which seems wrong from reading

Thus it seems as if the actual status was 0x1 = SG_CHECK_CONDITION.

Sense code seems to be:
sg_decode_sense 70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Fixed format, current; Sense key: Illegal Request
Additional sense: Invalid command operation code

Related

Bugs: #54

Discussion

  • Markus

    Markus - 2015-08-25

    PS: Might be related to bug 54.

     
  • Markus

    Markus - 2015-08-26

    I've changed io_hdr.status to io_hdr.masked_status in sgio.c in hdparm 9.48. Maybe that patch could help (I've also moved the dump_bytes part forward to get output even when now failing):

    278,283c278
    <       if (verbose) {
    <               dump_bytes("SG_IO: sb[]", sb, sizeof(sb));
    <               if (!rw && data)
    <                       dump_bytes("incoming_data", data, data_bytes);
    <       }
    <       if (io_hdr.masked_status && io_hdr.masked_status != SG_CHECK_CONDITION) {
    ---
    >       if (io_hdr.status && io_hdr.status != SG_CHECK_CONDITION) {
    293a289,293
    >       }
    >       if (verbose) {
    >               dump_bytes("SG_IO: sb[]", sb, sizeof(sb));
    >               if (!rw && data)
    >                       dump_bytes("incoming_data", data, data_bytes);
    
     

    Last edit: Markus 2015-08-26
  • Mark Lord

    Mark Lord - 2015-08-26

    What appears to have happened, is the kernel is now returning different information that it did previously. So at some point, something changed. hdparm has to work with all kernels, including way back to the 2.0 series.

    The trick is figuring out a fix that doesn't break it on older kernels.

     
  • Markus

    Markus - 2015-08-27

    I'm using openSUSE 13.1 with kernel 3.11.6.

    I've just come to realize 'SG_*' constants are different from the plain constants in scsi.h, thus my change above is wrong.

    It seems 'CHECK_CONDITION' is treated as success, right?
    The sense buffer starting with 0x70 is valid and contains sense key 0x5 '"ILLEGAL REQUEST"'. I am however somewhat at a loss regarding how the sense keys should be divided in success (like 0,1) and failure (particularly sense keys 6 and 9 seem unclear, see http://www.ibiblio.org/pub/historic-linux/distributions/redhat-3.0.3/i386/doc/HOWTO/SCSI-Programming-HOWTO).

     

    Last edit: Markus 2015-08-27
  • Kristýna Streitová

    Hello, are there any news regarding this bug? Thank you!

     
  • Mark Lord

    Mark Lord - 2018-01-05

    Nobody seems to have fixed it yet.

     

Log in to post a comment.

MongoDB Logo MongoDB