Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#1467 closed defect (fixed)

Autodetection under OpenBSD assumes full SCSI for sd-Devices

Reported by: Martin Ziemer Owned by:
Priority: minor Milestone: Release 7.3
Component: all Version:
Keywords: openbsd Cc:

Description

Under OpenBSD not only SCSI devices, but also sata devices have names like /dev/sd0.

When autodetectiong such a device, smartmontools uses the full scsi commandset instead of only sat commands.

One way to fix this would be to change line 592 in os_openbsd.cpp to something like this:
return new openbsd_scsi_device(this, name, "", true /*scanning*/);

Change History (10)

comment:1 by Christian Franke, 4 years ago

Keywords: openbsd added; OpenBSD removed
Milestone: undecided

When autodetectiong such a device, smartmontools uses the full scsi commandset instead of only sat commands.

Which smartctl command is used?
Which SCSI commands are erroneously issued?
Is SAT detected later or not?

One way to fix this would be to change line 592 in os_openbsd.cpp to something like this:
return new openbsd_scsi_device(this, name, "", true /*scanning*/);

The scanning flag should only set during smartctl --scan or smartd.conf DEVICESCAN. The autodetect code in os_openbsd.cpp may need some rework.

comment:2 by Martin Ziemer, 4 years ago

The command was just smartctl -a /dev/sd0c.

I dont know, how to see the scsi-command, which was issued.

I found the solution by reproducing the behaviour of smartmontools 7.1, where the sat-flag was given.

In the daemon-process it is detected correctly. Also there are no Problems, if i add "-d sat" to the commandline.

comment:3 by Martin Ziemer, 4 years ago

To complete the Bug-Desription Command and output as copy/pasta:

(126) horrad@dozer:/usr/ports/sysutils/smartmontools $ doas /usr/obj/ports/smartmontools-7.2/build-amd64/smartctl -a /dev/sd0c        
smartctl 7.2 2020-12-30 r5155 [OpenBSD 6.9 amd64] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

User Capacity:        2,000,398,934,016 bytes [2.00 TB]
Logical block size:   512 bytes
Physical block size:  4096 bytes
LB provisioning type: not reported [LBPME=1, LBPRZ=0]
Form Factor:          2.5 inches
>> Terminate command early due to bad response to IEC mode page
A mandatory SMART command failed: exiting. To continue, add one or more '-T permissive' options.

comment:4 by Christian Franke, 4 years ago

Needs to be further investigated by an OpenBSD expert. Leaving open as undecided for now.

comment:5 by Alex Samorukov, 4 years ago

I can try to take a look. Which OpenBSD version do you use?

comment:6 by Alex Samorukov, 4 years ago

Ok, was able to reproduce it in vbox, using virtual ahci controller and OpenBSD 6.8.

Please try this patch:

  • os_openbsd.cpp

     
    588588      // XXX get USB vendor ID, product ID and version from sd(4)/umass(4).
    589589      // XXX check sat device via get_usb_dev_type_by_id().
    590590
    591       // No USB bridge found, assume regular SCSI device
    592       return get_scsi_device(name, "scsi");
     591      // No USB bridge found, assume regular SCSI or SAT device
     592      return get_scsi_device(name, "");
    593593    }
    594594    if (!strncmp(net_dev_scsi_tape, test_name, strlen(net_dev_scsi_tape)))
    595595      return get_scsi_device(name, "scsi");

And let me know if it works for you.

TODO: check if same apply to netbsd which is based on the same code logic.

comment:7 by Alex Samorukov, 4 years ago

P.S. had a quick look on the kernel to see if its easy/possible to get usb device detection attached to scsi and seems that this information is not exported to userland. I would recommend to request that from OpenBSD folks if you want to have this in the smartmontools. Specifically ioctl needs to return bus type or driver (e.g. usb or umass) and get easy way to get usb vid/pid using it.

Last edited 4 years ago by Alex Samorukov (previous) (diff)

in reply to:  6 comment:8 by Martin Ziemer, 4 years ago

Replying to Alex Samorukov:

Ok, was able to reproduce it in vbox, using virtual ahci controller and OpenBSD 6.8.

Please try this patch:

  • os_openbsd.cpp

     
    588588      // XXX get USB vendor ID, product ID and version from sd(4)/umass(4).
    589589      // XXX check sat device via get_usb_dev_type_by_id().
    590590
    591       // No USB bridge found, assume regular SCSI device
    592       return get_scsi_device(name, "scsi");
     591      // No USB bridge found, assume regular SCSI or SAT device
     592      return get_scsi_device(name, "");
    593593    }
    594594    if (!strncmp(net_dev_scsi_tape, test_name, strlen(net_dev_scsi_tape)))
    595595      return get_scsi_device(name, "scsi");

And let me know if it works for you.

TODO: check if same apply to netbsd which is based on the same code logic.

This patch works for me.
BUT i have only sata and USB disks to test at hand. -- So i dont know, of it breaks real scsi disks!

comment:9 by Alex Samorukov, 4 years ago

Thank you for testing. It should not break real scsi. There is a way to be even more strict and do SAT check ONLY when sc_bus != SCSI, but i think it is overkill + device is not yet open when we doing return get_scsi_device. Also checked with netbsd - it should not be relevant as NetBSD always adds AHCI devices as wd* and not sd*. We also doing sat check by default on Linux/FreeBSD, so that should not harm.

Last edited 4 years ago by Alex Samorukov (previous) (diff)

comment:10 by Alex Samorukov, 4 years ago

Milestone: undecidedRelease 7.3
Resolution: fixed
Status: newclosed

Should be fixed in r5215

Note: See TracTickets for help on using tickets.