OpenBSD Journal

Developer blog: dlg: hotplug scsibus

Contributed by dlg on from the rebooting-is-for-chumps dept.

This morning I committed some bits to the SCSI midlayer that will enable drivers for scsi controllers to attach and detach devices at runtime. I also committed some code to mpi(4) to demonstrate it.

Unfortunately the functionality is limited to the SAS versions of mpi, not all of them. The messages that the hardware generates for the other controllers is different, so I'll have to add other code separately for them to do hotplug.

So this is what it looks like in dmesg with the boring bits removed:

ami0 at pci5 dev 0 function 0 "AMI MegaRAID" rev 0x20: irq 11
ami0: Dell PERC3/DC, 64b/lhc, FW 198U, BIOS v3.35, 128MB RAM
ami0: 2 channels, 0 FC loops, 2 logical drives
scsibus0 at ami0: 40 targets
sd0 at scsibus0 targ 0 lun 0: <AMI, Host drive #00, > SCSI2 0/direct fixed
sd0: 17280MB, 17280 cyl, 64 head, 32 sec, 512 bytes/sec, 35389440 sec total
sd1 at scsibus0 targ 1 lun 0: <AMI, Host drive #01, > SCSI2 0/direct fixed
sd1: 17280MB, 17280 cyl, 64 head, 32 sec, 512 bytes/sec, 35389440 sec total
scsibus1 at ami0: 16 targets
safte0 at scsibus1 targ 6 lun 0: <DELL, 1x6 U2W SCSI BP, 1.32> SCSI2 3/processor fixed
scsibus2 at ami0: 16 targets
"QLogic ISP12160" rev 0x06 at pci4 dev 1 function 0 not configured
mpi0 at pci3 dev 8 function 0 "Symbios Logic SAS1068" rev 0x00: irq 11
scsibus3 at mpi0: 126 targets
sd2 at scsibus3 targ 10 lun 0: <ATA, ST3320620AS, D> SCSI3 0/direct fixed
sd2: 305245MB, 305246 cyl, 16 head, 127 sec, 512 bytes/sec, 625142448 sec total
sd3 at scsibus3 targ 11 lun 0: <ATA, ST3320620AS, D> SCSI3 0/direct fixed
sd3: 305245MB, 305246 cyl, 16 head, 127 sec, 512 bytes/sec, 625142448 sec total
[snip]
dkcsum: sd0 matches BIOS drive 0x81
dkcsum: sd1 matches BIOS drive 0x80
root on sd0a
rootdev=0x400 rrootdev=0xd00 rawdev=0xd02
sd2 detached
sd3 detached
sd2 at scsibus3 targ 10 lun 0: <ATA, ST3320620AS, D> SCSI3 0/direct fixed
sd2: 305245MB, 305246 cyl, 16 head, 127 sec, 512 bytes/sec, 625142448 sec total
sd3 at scsibus3 targ 11 lun 0: <ATA, ST3320620AS, D> SCSI3 0/direct fixed
sd3: 305245MB, 305246 cyl, 16 head, 127 sec, 512 bytes/sec, 625142448 sec total
sd3 detached
sd3 at scsibus3 targ 11 lun 0: <ATA, ST3320620AS, D> SCSI3 0/direct fixed
sd3: 305245MB, 305246 cyl, 16 head, 127 sec, 512 bytes/sec, 625142448 sec total
sd4 at scsibus3 targ 12 lun 0: <ATA, ST3320620AS, C> SCSI3 0/direct fixed
sd4: 305245MB, 305246 cyl, 16 head, 127 sec, 512 bytes/sec, 625142448 sec total
sd4 detached

That's me unplugging and plugging disks on mpi. Riveting isn't it?

Because I haven't handled the appropriate messages in non SAS mpi controllers, this is currently disabled in the driver. If there are any brave souls out there who want to try it out, look for #ifdef notyet in src/sys/dev/ic/mpi.c and take the preprocessor bits out to enable the initialisation of event notifications.

This ability is actually cool because it paves the way for us to do a lot more dynamic configuration of devices on SCSI buses, ranging from simple addition and removal of disks like SAS mpi does, to maybe being able to create and delete RAID volumes with bioctl. However, this is just talk at the moment. I'm not making any promises unless there is code in the tree.

I just thought it was cool that I could plug disks into my machine after it's booted and use them :)

(Comments are closed)


Comments
  1. By Anonymous Coward (194.245.32.131) on

    wow, this is really a nice feature. keep up the good work

  2. By Anonymous Coward (89.100.155.108) on

    Will it be possible to have hotplug cdrom drives with those bits in the future?

    Comments
    1. By Anonymous Coward (80.135.182.153) on

      > Will it be possible to have hotplug cdrom drives with those bits in the future?

      I would sell my soul for Hotplug SATA but this SCSI stuff is realy great work! :)

      Comments
      1. By Anonymous Coward (198.175.14.5) on

        Just buy the SAS controller and plug SATA II drivs into it

        Comments
        1. By Anonymous Coward (85.178.123.216) on

          > Just buy the SAS controller and plug SATA II drivs into it

          Well I ment more HotPlug-SATA provided by some Chipsetzs (like VIA). :)

          Comments
          1. By David Gwynne (203.173.42.48) loki@animata.net on

            > > Just buy the SAS controller and plug SATA II drivs into it
            >
            > Well I ment more HotPlug-SATA provided by some Chipsetzs (like VIA). :)

            I'm only interested in hotplug support on scsibus at the moment, though it would be kinda fun to have it on SATA controllers that are able to handle hotplug.

            Who know what might happen if I get bored enough.

  3. By Anonymous Coward (68.165.27.172) on

    A little off-topic, but which SATA hardware RAID card does OpenBSD support nicely? (not adaptec for sure) Which one is the best supported SATA RAID card? LSI maybe? If so, which model?

    Thanks!

    Comments
    1. By Anonymous Coward (68.165.27.172) on

      I'm asking because I simply can't afford SCSI or SAS really... And I don't want to do software RAID.

      Comments
      1. By Anonymous Coward (81.168.66.230) on

        > I'm asking because I simply can't afford SCSI or SAS really... And I don't want to do software RAID.

        Areca or LSI, both have PCIE SATA controllers if you don't have a motherboard with PCI-X. SAS controllers should work for SATA II drives too (for PCIE, the SAS MegaRAID is a similar price to the SATA version and may be easier to find).

    2. By djm@ (206.59.235.113) on

      > A little off-topic, but which SATA hardware RAID card does
      > OpenBSD support nicely? (not adaptec for sure) Which one is
      > the best supported SATA RAID card? LSI maybe? If so, which
      > model?

      I have a LSI MegaRAID SATA 150-4 and it works very well; bioctl produces useful results, etc.

      # dmesg | egrep '^(ami|sd)'
      ami0 at pci0 dev 13 function 0 "Symbios Logic MegaRAID" rev 0x01: irq 11
      ami0: LSI 523, 64b/lhc, FW 713N, BIOS vG119, 64MB RAM
      ami0: 1 channels, 0 FC loops, 2 logical drives
      sd0 at scsibus0 targ 0 lun 0:  SCSI2 0/direct fixed
      sd0: 152623MB, 152623 cyl, 64 head, 32 sec, 512 bytes/sec, 312571904 sec total
      sd1 at scsibus0 targ 1 lun 0:  SCSI2 0/direct fixed
      sd1: 152623MB, 152623 cyl, 64 head, 32 sec, 512 bytes/sec, 312571904 sec total
      # bioctl ami0
      Volume  Status               Size Device
       ami0 0 Online       160036814848 sd0     RAID1
            0 Online       160036814848 0:0.0   noencl <        ST3160827AS     3.42>
            1 Online       160036814848 0:1.0   noencl <        ST3160827AS     3.42>
       ami0 1 Online       160036814848 sd1     RAID1
            0 Online       160036814848 0:2.0   noencl <        ST3160812AS     3.AA>
            1 Online       160036814848 0:3.0   noencl <        ST3160827AS     3.42>
      

      Comments
      1. By Anonymous Coward (68.165.27.172) on

        >
        > A little off-topic, but which SATA hardware RAID card does
        > OpenBSD support nicely? (not adaptec for sure) Which one is
        > the best supported SATA RAID card? LSI maybe? If so, which
        > model?
        >
        >
        > I have a LSI MegaRAID SATA 150-4 and it works very well; bioctl produces useful results, etc.
        >
        >
        > # dmesg | egrep '^(ami|sd)'
        > ami0 at pci0 dev 13 function 0 "Symbios Logic MegaRAID" rev 0x01: irq 11
        > ami0: LSI 523, 64b/lhc, FW 713N, BIOS vG119, 64MB RAM
        > ami0: 1 channels, 0 FC loops, 2 logical drives
        > sd0 at scsibus0 targ 0 lun 0: SCSI2 0/direct fixed
        > sd0: 152623MB, 152623 cyl, 64 head, 32 sec, 512 bytes/sec, 312571904 sec total
        > sd1 at scsibus0 targ 1 lun 0: SCSI2 0/direct fixed
        > sd1: 152623MB, 152623 cyl, 64 head, 32 sec, 512 bytes/sec, 312571904 sec total
        > # bioctl ami0
        > Volume Status Size Device
        > ami0 0 Online 160036814848 sd0 RAID1
        > 0 Online 160036814848 0:0.0 noencl
        > 1 Online 160036814848 0:1.0 noencl
        > ami0 1 Online 160036814848 sd1 RAID1
        > 0 Online 160036814848 0:2.0 noencl
        > 1 Online 160036814848 0:3.0 noencl
        >

        Thank you I've head a lot of good things about LSI, thanks for the advice, also, if you lose a drive with an LSI, does openbsd (or LSI) provides the tools to automagically rebuild the array without having to reboot?

        Comments
        1. By David Gwynne (203.173.42.48) loki@animata.net on

          > Thank you I've head a lot of good things about LSI, thanks for the advice, also, if you lose a drive with an LSI, does openbsd (or LSI) provides the tools to automagically rebuild the array without having to reboot?

          On LSI controllers you can enable the automatic rebuilds in the controllers bios. bioctl does not have the functionality to trigger a rebuild on its own. However, it can be used to mark new disks as hotspares, which the controller will in turn use to auto rebuild onto.

    3. By jolan (71.82.175.104) on

      > A little off-topic, but which SATA hardware RAID card does OpenBSD support nicely? (not adaptec for sure) Which one is the best supported SATA RAID card? LSI maybe? If so, which model?
      >
      > Thanks!

      any areca make/model should work:

      arc0 at pci6 dev 14 function 0 "Areca ARC-1210" rev 0x00: irq 11
      arc0: 4 SATA Ports, 256MB SDRAM, FW Version: V1.41 2006-5-24

      $ sudo bioctl arc0
      Volume Status Size Device
      arc0 0 Online 249999917056 sd0 RAID1
      0 Online 250059350016 0:0.0 noencl <WDC WD2500KS-00MJB0 02.01C03>
      1 Online 250059350016 0:1.0 noencl <WDC WD2500KS-00MJB0 02.01C03>

      the arc(4) driver is half the size of the ami(4) one.

Credits

Copyright © - Daniel Hartmeier. All rights reserved. Articles and comments are copyright their respective authors, submission implies license to publish on this web site. Contents of the archive prior to as well as images and HTML templates were copied from the fabulous original deadly.org with Jose's and Jim's kind permission. This journal runs as CGI with httpd(8) on OpenBSD, the source code is BSD licensed. undeadly \Un*dead"ly\, a. Not subject to death; immortal. [Obs.]