SCSI device/adapter/bus address correlation?
Subsystems (3)
PATCH 1/1 SCSI device/adapter/bus address correlation?
Not being a real SCSI person, I'm sure there's some clever way I'm supposed to figure out which disk is /dev/sda. But sometimes it's not clear from the kernel boot messages, particularly for drivers that don't print the PCI address of the adapter.
Is there any interest in a patch like the attached, which makes things look like this:
Attached scsi disk sda at 0000:20:01.0: scsi0, channel 0, id 0, lun 0
Attached scsi disk sdb at 0000:20:01.0: scsi0, channel 0, id 1, lun 0===== drivers/scsi/osst.c 1.58 vs edited =====
drivers/scsi/osst.c +3 -2
@@ -5564,8 +5564,9 @@ drive->number =devfs_register_tape (SDp->devfs_name);printk (KERN_INFO -"osst :I: Attached OnStream %.5s tape at scsi%d, channel %d, id %d, lun %d as %s\n" , - SDp->model, SDp->host->host_no, SDp->channel, SDp->id, SDp->lun,tape_name (tpnt)); +"osst :I: Attached OnStream %.5s tape at %s: scsi%d, channel %d, id %d, lun %d as %s\n" , + SDp->model,scsi_get_device (SDp->host)->bus_id, + SDp->host->host_no, SDp->channel, SDp->id, SDp->lun,tape_name (tpnt));return 0 ;
===== drivers/scsi/sd.c 1.156 vs edited =====
drivers/scsi/sd.c +3 -3
@@ -1489,10 +1489,10 @@dev_set_drvdata (dev, sdkp);add_disk (gd); -printk (KERN_NOTICE "Attached scsi %sdisk %s at scsi%d, channel %d, " +printk (KERN_NOTICE "Attached scsi %sdisk %s at %s: scsi%d, channel %d, " "id %d, lun %d\n" , sdp->removable ?"removable " :"" , - gd->disk_name, sdp->host->host_no, sdp->channel, - sdp->id, sdp->lun); + gd->disk_name,scsi_get_device (sdp->host)->bus_id, + sdp->host->host_no, sdp->channel, sdp->id, sdp->lun);return 0 ;
===== drivers/scsi/sg.c 1.95 vs edited =====
drivers/scsi/sg.c +2 -1
@@ -1468,8 +1468,9 @@printk (KERN_WARNING "sg_add: sg_sys INvalid\n" );printk (KERN_NOTICE -"Attached scsi generic sg%d at scsi%d, channel" +"Attached scsi generic sg%d at %s: scsi%d, channel" " %d, id %d, lun %d, type %d\n" , k, +scsi_get_device (scsidp->host)->bus_id, scsidp->host->host_no, scsidp->channel, scsidp->id, scsidp->lun, scsidp->type);
===== drivers/scsi/sr.c 1.114 vs edited =====
drivers/scsi/sr.c +3 -2
@@ -637,8 +637,9 @@add_disk (disk);printk (KERN_DEBUG -"Attached scsi CD-ROM %s at scsi%d, channel %d, id %d, lun %d\n" , - cd->cdi.name, sdev->host->host_no, sdev->channel, +"Attached scsi CD-ROM %s at %s: scsi%d, channel %d, id %d, lun %d\n" , + cd->cdi.name,scsi_get_device (sdev->host)->bus_id, + sdev->host->host_no, sdev->channel, sdev->id, sdev->lun);return 0 ;
===== drivers/scsi/st.c 1.93 vs edited =====
drivers/scsi/st.c +3 -2
@@ -3919,8 +3919,9 @@ disk->number =devfs_register_tape (SDp->devfs_name);printk (KERN_WARNING -"Attached scsi tape %s at scsi%d, channel %d, id %d, lun %d\n" , -tape_name (tpnt), SDp->host->host_no, SDp->channel, SDp->id, SDp->lun); +"Attached scsi tape %s at %s: scsi%d, channel %d, id %d, lun %d\n" , +tape_name (tpnt),scsi_get_device (SDp->host)->bus_id, + SDp->host->host_no, SDp->channel, SDp->id, SDp->lun);printk (KERN_WARNING "%s: try direct i/o: %s (alignment %d B), max page reachable by HBA %lu\n" ,tape_name (tpnt), tpnt->try_dio ?"yes" :"no" ,queue_dma_alignment (SDp->request_queue) +1 , tpnt->max_pfn);
Quoted 4 lines · Bjorn Helgaas
Not being a real SCSI person, I'm sure there's some clever way I'm supposed to figure out which disk is
/dev/sda. But sometimes it's not clear from the kernel boot messages, particularly for drivers that don't print the PCI address of the adapter.
You do it like this:
jejb@gsyprf11> ls -l /sys/block/sda/device
lrwxrwxrwx 1 root root 0 Aug 22 10:57 /sys/block/sda/device -> ../../devices/parisc0/parisc0:0/pci0000:00/0000:00:01.1/host1/1:0:15:0/
There you see the full attachment tree of the pci device.
Quoted 2 lines
Is there any interest in a patch like the attached, which makes things look like this:
Not really, unless it's part of a conversion to dev_printk().
James
Quoted 4 lines · James Bottomley
Quoted 2 lines
Is there any interest in a patch like the attached, which makes things look like this:
Not really, unless it's part of a conversion to
dev_printk().
In addition the patch will crash the box for all the legacy drivers that don't set the device field in struct Scsi_Host
Quoted 11 lines · James Bottomley
Quoted 4 lines · Bjorn Helgaas
Not being a real SCSI person, I'm sure there's some clever way I'm supposed to figure out which disk is
/dev/sda. But sometimes it's not clear from the kernel boot messages, particularly for drivers that don't print the PCI address of the adapter.You do it like this:
jejb@gsyprf11> ls -l
/sys/block/sda/device
lrwxrwxrwx 1 root root 0 Aug 22 10:57/sys/block/sda/device-> ../../devices/parisc0/parisc0:0/pci0000:00/0000:00:01.1/host1/1:0:15:0/
Thanks, I knew there must be a cool way. That doesn't help if you're trying to figure out the correct "root=" to boot your box, of course... -
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
Quoted 6 lines · Bjorn Helgaas
Quoted 3 lines
jejb@gsyprf11> ls -l
/sys/block/sda/device
lrwxrwxrwx 1 root root 0 Aug 22 10:57/sys/block/sda/device-> ../../devices/parisc0/parisc0:0/pci0000:00/0000:00:01.1/host1/1:0:15:0/Thanks, I knew there must be a cool way. That doesn't help if you're trying to figure out the correct "root=" to boot your box, of course...
initrd, udev, done.
Signature · 7 lines
USB is for mice, FireWire is for men! sUse lINUX ag, nÜRNBERG - 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
Quoted 7 lines · Bjorn Helgaas
Quoted 6 lines · James Bottomley
Quoted 4 lines · Bjorn Helgaas
Not being a real SCSI person, I'm sure there's some clever way I'm supposed to figure out which disk is
/dev/sda. But sometimes it's not clear from the kernel boot messages, particularly for drivers that don't print the PCI address of the adapter.
Quoted 8 lines
Quoted 5 lines
You do it like this:
jejb@gsyprf11> ls -l
/sys/block/sda/device
lrwxrwxrwx 1 root root 0 Aug 22 10:57/sys/block/sda/device-> ../../devices/parisc0/parisc0:0/pci0000:00/0000:00:01.1/host1/1:0:15:0/Thanks, I knew there must be a cool way. That doesn't help if you're trying to figure out the correct "root=" to boot your box, of course...
What exactly is the "root=" problem? You mean device names changing?
Also lsscsi gives simple easy to read output.
http://www.torque.net/scsi/lsscsi.html
[elm3a211 patman]$ lsscsi
[0:0:0:0] enclosu IBM EXP700 9319 - [0:0:1:0] disk IBM-ESXS ST318453FC F B953 /dev/sda [0:0:2:0] disk IBM-ESXS ST318453FC F B953 /dev/sdb [0:0:3:0] enclosu IBM EXP700 9319 - [0:0:4:0] disk IBM-ESXS ST318453FC F B953 /dev/sdc [0:0:5:0] disk IBM-ESXS ST318453FC F B953 /dev/sdd
I[elm3a211 patman]$ lsscsi -g
[0:0:0:0] enclosu IBM EXP700 9319 - /dev/sg0 [0:0:1:0] disk IBM-ESXS ST318453FC F B953 /dev/sda /dev/sg1 [0:0:2:0] disk IBM-ESXS ST318453FC F B953 /dev/sdb /dev/sg2 [0:0:3:0] enclosu IBM EXP700 9319 - /dev/sg3 [0:0:4:0] disk IBM-ESXS ST318453FC F B953 /dev/sdc /dev/sg4 [0:0:5:0] disk IBM-ESXS ST318453FC F B953 /dev/sdd /dev/sg5
I don't know if it works right with udev (i.e. I think it only prints default kernel names, just those found under sysfs, so if you don't user default kernels names with udev it might not show the correct /dev name).
-- Patrick Mansfield
-
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
Quoted 4 lines · Patrick Mansfield
Quoted 2 lines
Thanks, I knew there must be a cool way. That doesn't help if you're trying to figure out the correct "root=" to boot your box, of course...
What exactly is the "root=" problem? You mean device names changing?
Walk up to a box with a number of data disks already attached. Plug in a new disk with a root filesystem on it. Now try to boot the box, using the new root filesystem. What do you specify? It's difficult in general to figure it out.
Quoted 4 lines
Also lsscsi gives simple easy to read output.
...[0:0:0:0] enclosu IBM EXP700 9319 - [0:0:1:0] disk IBM-ESXS ST318453FC F B953 /dev/sda
That looks like it gives you the scsi unit, channel, id, lun, which is already available in dmesg. It doesn't tell you the PCI bus address, which you might need if you have more than one SCSI adapter.
My question has more to do with the situation where your box doesn't boot because you don't know which sd<x> device has your root filesystem. If the PCI bus number gets printed somewhere before the "can't mount root" panic, you at least have a clue to solve the problem.
Olaf pointed out what sounds like a reasonable way do to this, but of course that requires the hassle of an initrd.
Quoted 10 lines · Bjorn Helgaas
Quoted 4 lines · Patrick Mansfield
Quoted 2 lines
Thanks, I knew there must be a cool way. That doesn't help if you're trying to figure out the correct "root=" to boot your box, of course...
What exactly is the "root=" problem? You mean device names changing?
Walk up to a box with a number of data disks already attached. Plug in a new disk with a root filesystem on it. Now try to boot the box, using the new root filesystem. What do you specify? It's difficult in general to figure it out.
In this case the filesystem UUID or a string returned by an external udev helper like scsi_id will help. udev will create a /dev/foo and your initrd will mount that. We have predefined names (symlink to the kernel device node) like /dev/disk/by-id/SIBM_ST336753LC_3HX1AJJX00007407HDF3p1 in initramfs.
You can use them, or specify your own in udev.rules. Since the disk content will not change and there will (hopefully) not another one with the same VPD, everything will work as expected.
Signature · 7 lines
USB is for mice, FireWire is for men! sUse lINUX ag, nÜRNBERG - 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