Skip to contentSkip to conversation

Hot plugging a disk in runtime

DISCUSSION Rabeeh Khoury 7 participants 9 messages May 20, 2002 – May 21, 2002 1 message not in the archive SCSI

lore
Share & tools
lore
#0 lore raw

Hi list,

I have few questions withregards to hot-plugging disk into a running system -

1.. How is it possible to signal SCSI mid-layer (or other layers) of a presence of a newly hot-plugged disk ?

2.. Can an adapter's device driver trigger SCSI subsystem to scan channels for new LUNs / Targets ?

3.. Is this can be handled in a kernel level ? is there a user space application that can be triggered to start scanning adapters (obviously through SCSI subsystem) and registering new LUNs / Targets etc... ?

4.. How does SCSI API allow insertion of a new disk ?

5.. Is there a generic way of hot-plugging disks ?

Thank you alot,
Rabeeh

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

I use this script:

# cat `which sdon`
#!/bin/sh

dev=/dev/sdc
num=4

case $0 in
*off)

        umount ${dev}1
        scsi-spin --down $dev
        echo "scsi remove-single-device 0 0 $num 0" > /proc/scsi/scsi
        ;;
*on)
        echo scsi add-single-device 0 0 $num 0 > /proc/scsi/scsi
        mount ${dev}1
        ;;

esac

for a disk which happens to have scsi-id 4 and shows up as /dev/sdc.
Used like, sdoff, remove disk; insert disk, let it spin up, sdon.

Regards,
/Karl

-----------------------------------------------------------------------
Karl Hammar Aspö Data [email protected]
Lilla Aspö 2340 +46 173 140 57 Networks
S-742 94 Östhammar +46 10 270 26 67 Computers
Sweden Consulting
-----------------------------------------------------------------------

-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
In reply to Rabeeh Khoury
Quoted 2 lines

1.. How is it possible to signal SCSI mid-layer (or other layers) of a presence of a newly hot-plugged disk ?

aacraid is one example that does this, but via its config tools.

Quoted 2 lines

2.. Can an adapter's device driver trigger SCSI subsystem to scan channels for new LUNs / Targets ?

It is designed so user space can do so - so yes

Quoted 3 lines

3.. Is this can be handled in a kernel level ? is there a user space application that can be triggered to start scanning adapters (obviously through SCSI subsystem) and registering new LUNs / Targets etc... ?

echo "scsi-add-single-device a b c d" /proc/scsi/scsi

if I remember it right

Alan

#4 lore raw

A small cut'n paste from man proc !

scsi This is a listing of all SCSI devices known to the kernel. The
listing is similar to the one seen during bootup. scsi currently supports only the add-single-device command which allows root to add a hotplugged device to the list of known devices.

An echo 'scsi add-single-device 1 0 5 0' > /proc/scsi/scsi will cause host scsi1 to scan on SCSI channel 0 for a device on ID 5 LUN
0. If there is already a device known on this address or the address is invalid an error will be returned.

Quoted 8 lines · Alan Cox
Quoted 2 lines

1.. How is it possible to signal SCSI mid-layer (or other layers) of a presence of a newly hot-plugged disk ?

aacraid is one example that does this, but via its config tools.

Quoted 2 lines

2.. Can an adapter's device driver trigger SCSI subsystem to scan channels for new LUNs / Targets ?

Quoted 8 lines

It is designed so user space can do so - so yes

Quoted 3 lines

3.. Is this can be handled in a kernel level ? is there a user space application that can be triggered to start scanning adapters (obviously through SCSI subsystem) and registering new LUNs / Targets etc... ?

echo "scsi-add-single-device a b c d" /proc/scsi/scsi

To be precise :

echo 'scsi add-single-device a b c d ' > /proc/scsi/scsi

Thanks,
Kaushik

Quoted 8 lines

if I remember it right

Alan
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
In reply to Alan Cox
Quoted 3 lines · Alan Cox

echo "scsi-add-single-device a b c d" /proc/scsi/scsi

from drivers/scsi/scsi.c : (kernel 2.4.18)

/*
* Usage: echo "scsi add-single-device 0 1 2 3" >/proc/scsi/scsi
* with "0 1 2 3" replaced by your "Host Channel Id Lun".
* Consider this feature BETA.
* CAUTION: This is not for hotplugging your peripherals. As
* SCSI was not designed for this you could damage your
* hardware !
* However perhaps it is legal to switch on an
* already connected device. It is perhaps not
* guaranteed this device doesn't corrupt an ongoing data transfer. */

1.. What is meant by "SCSI was not designed for this ..." ?
2.. SCSI architecture model (SAM-2 at least) does not mention hot-plugging storage device into a running system ; but doing so is a very common task. So, are all the SCSI hot-plug systems in the world are based on proprietry methods of hot-plug ? 3.. What about the naming of /dev/sdxx naming of newly hot-plugged SCSI disk ? which name does it get ? (supposly I'm not using the dev filesystem)

#6 lore raw
Quoted 11 lines

* Usage: echo "scsi add-single-device 0 1 2 3" >/proc/scsi/scsi
* with "0 1 2 3" replaced by your "Host Channel Id Lun".
* Consider this feature BETA.
* CAUTION: This is not for hotplugging your peripherals. As
* SCSI was not designed for this you could damage your
* hardware !
* However perhaps it is legal to switch on an
* already connected device. It is perhaps not
* guaranteed this device doesn't corrupt an ongoing data transfer. */

Quoted 1 line

1.. What is meant by "SCSI was not designed for this ..." ?

SCSI itself is not. People had a habit of blowing up scsi kit trying to hot plug stuff that was not meant that way. Obviously thats different for hot plug certified SCA2 equipment

Quoted 1 line

3.. What about the naming of /dev/sdxx naming of newly hot-plugged SCSI disk ? which name does it get ? (supposly I'm not using the dev filesystem)

it gets the next free one

#7 lore raw
In reply to Rabeeh Khoury
Quoted 1 line · [email protected] said:

1.. What is meant by "SCSI was not designed for this ..." ?

That really refers to a very old daisy chained parallel SCSI model. Since the whole bus is a transmission line, breaking it to add another device can cause enormous disruption (sometimes this was bad enough to physically destroy other devices on the bus). However, these days, you can even get hotplug enclosures for parallel SCSI that don't need to break the bus to add new devices. And, of course, things like Fibre Channel we're designed to be alterable on the fly anyway.

Quoted 4 lines

2.. SCSI architecture model (SAM-2 at least) does not mention hot-plugging storage device into a running system ; but doing so is a very common task. So, are all the SCSI hot-plug systems in the world are based on proprietry methods of hot-plug ?

This is the province of something called the Scsi Enclosure Services (SES) standard:

ftp://ftp.t10.org/t10/drafts/ses/ses-r08b.pdf

However, like most standards it began life as a bunch of companies each inventing their own more or less proprietary way of doing things and then realising that standardisation might be a good thing, so there are quite a few not quite compatible implementations of this.

Like all good standards it's also due to be superceded (by SES-2) any day now.

There is an enclosure monitor, which I haven't looked at but which I presume could be used as part of a hotplug system for SCSI devices:

http://gort.metaparadigm.com/saftemon/

Quoted 3 lines

3.. What about the naming of /dev/sdxx naming of newly hot-plugged SCSI disk ? which name does it get ? (supposly I'm not using the dev filesystem)

The first available one.

James Bottomley

#8 lore raw

On 05/20/02 22:20, James Bottomley wrote:

[snip]

Quoted 4 lines

This is the province of something called the Scsi Enclosure Services (SES) standard:

ftp://ftp.t10.org/t10/drafts/ses/ses-r08b.pdf

Quoted 9 lines

However, like most standards it began life as a bunch of companies each inventing their own more or less proprietary way of doing things and then realising that standardisation might be a good thing, so there are quite a few not quite compatible implementations of this.

Like all good standards it's also due to be superceded (by SES-2) any day now.

There is an enclosure monitor, which I haven't looked at but which I presume could be used as part of a hotplug system for SCSI devices:

http://gort.metaparadigm.com/saftemon/

saftemon currently only does SAF-TE and not SES - but if you have a SAF-TE enclosure, it will give you an event when a disk has been inserted into an empty slot (or removed).

There is even some (currently not activated) code in there to map SAF-TE slots to the corresponding Linux SCSI device. This of course only works if you have physical disk devices on the SCSI bus as logical (RAID) devices can't be correllated easily to device slots (not unless you have an API to do get the mappings from your RAID controller).

It would be quite nice to get saftemon events to trigger Software RAID commands in a Software RAID set-up such as doing a device probe and maybe a raid hot add when a new disk is inserted.

~mc

#9 lore raw
In reply to Alan Cox
Quoted 10 lines · Alan Cox
Quoted 2 lines

1.. How is it possible to signal SCSI mid-layer (or other layers) of a presence of a newly hot-plugged disk ?

aacraid is one example that does this, but via its config tools.

Quoted 2 lines

2.. Can an adapter's device driver trigger SCSI subsystem to scan channels for new LUNs / Targets ?

It is designed so user space can do so - so yes

Quoted 7 lines
Quoted 3 lines

3.. Is this can be handled in a kernel level ? is there a user space application that can be triggered to start scanning adapters (obviously through SCSI subsystem) and registering new LUNs / Targets etc... ?

echo "scsi-add-single-device a b c d" /proc/scsi/scsi

if I remember it right

If I recall correctly, that code is more than a little bit racy. You're probably just fine adding a device here and there, but adding a couple dozen all at once makes things unhappy. Never finished debugging it though
- it seemed in need of a major rewrite.

Signature · 1 line
 "Love the dolphins," she advised him. "Write by W.A.S.T.E.."