All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Robinson <john.robinson@anonymous.org.uk>
To: Phil Turmel <philip@turmel.org>
Cc: linux-raid@vger.kernel.org
Subject: Re: Determining which spindle is out of order
Date: Sun, 07 Nov 2010 15:19:08 +0000	[thread overview]
Message-ID: <4CD6C36C.1080200@anonymous.org.uk> (raw)
In-Reply-To: <4CD6BB2D.5020202@turmel.org>

[-- Attachment #1: Type: text/plain, Size: 8611 bytes --]

On 07/11/2010 14:43, Phil Turmel wrote:
> On 11/07/2010 08:43 AM, John Robinson wrote:
[...]
>> Please don't feel you have to turn this into a project, though.
>
> Too late.  Here's a version that doesn't use udevadm at all...

OK, it's an improvement because after I've changed the find command to 
find '*scsi_host*', it lists my controllers, but finds them all empty. I 
noted that the script was looking for subdirectories called block but 
mine have names like block:sda so I changed the script again to refer to 
'block*' both in the loop in check_host and in the substitution at the 
top of describe_device. There's still something not quite right with 
trying to read CentOS/RHEL 5 / kernel 2.6.18 sysfs, because this was the 
output I got:

[root@beast ~]# ~john/projects/describe_scsi/describe_scsi_2
Controller device @ pci0000:00/0000:00:1f.2 [ahci]
   SATA controller: Intel Corporation 82801JI (ICH10 Family) SATA AHCI 
Controller    host7: [Empty]
     host6: [Empty]
     host5: [Empty]
     host4: Unknown /sys/block/sdc/dev
sginfo(open): No such file or directory
file=/dev/4:0:0:0, or no corresponding sg device found
Is sg driver loaded?
     host4: /dev/4:0:0:0 ATA ST31000528AS
sginfo(open): No such file or directory
file=/dev/holders, or no corresponding sg device found
Is sg driver loaded?
     host4: /dev/holders ATA ST31000528AS
sginfo(open): No such file or directory
file=/dev/queue, or no corresponding sg device found
Is sg driver loaded?
     host4: /dev/queue ATA ST31000528AS
     host4: Unknown /sys/block/sdc/range
     host4: Unknown /sys/block/sdc/removable
     host4: /dev/sdc1 ATA ST31000528AS {SN: 9VP4XCQP}
     host4: /dev/sdc2 ATA ST31000528AS {SN: 9VP4XCQP}
     host4: Unknown /sys/block/sdc/size
sginfo(open): No such file or directory
file=/dev/slaves, or no corresponding sg device found
Is sg driver loaded?
     host4: /dev/slaves ATA ST31000528AS
     host4: Unknown /sys/block/sdc/stat
sginfo(open): No such file or directory
file=/dev/block, or no corresponding sg device found
Is sg driver loaded?
     host4: /dev/block ATA ST31000528AS
     host4: Unknown /sys/block/sdc/uevent
     host3: Unknown /sys/block/sdb/dev
sginfo(open): No such file or directory
file=/dev/3:0:0:0, or no corresponding sg device found
Is sg driver loaded?
     host3: /dev/3:0:0:0 ATA SAMSUNG HD103UJ
sginfo(open): No such file or directory
file=/dev/holders, or no corresponding sg device found
Is sg driver loaded?
     host3: /dev/holders ATA SAMSUNG HD103UJ
sginfo(open): No such file or directory
file=/dev/queue, or no corresponding sg device found
Is sg driver loaded?
     host3: /dev/queue ATA SAMSUNG HD103UJ
     host3: Unknown /sys/block/sdb/range
     host3: Unknown /sys/block/sdb/removable
     host3: /dev/sdb1 ATA SAMSUNG HD103UJ {SN: S1PVJ1CQ602162 }
     host3: /dev/sdb2 ATA SAMSUNG HD103UJ {SN: S1PVJ1CQ602162 }
     host3: Unknown /sys/block/sdb/size
sginfo(open): No such file or directory
file=/dev/slaves, or no corresponding sg device found
Is sg driver loaded?
     host3: /dev/slaves ATA SAMSUNG HD103UJ
     host3: Unknown /sys/block/sdb/stat
sginfo(open): No such file or directory
file=/dev/block, or no corresponding sg device found
Is sg driver loaded?
     host3: /dev/block ATA SAMSUNG HD103UJ
     host3: Unknown /sys/block/sdb/uevent
     host2: Unknown /sys/block/sda/dev
sginfo(open): No such file or directory
file=/dev/2:0:0:0, or no corresponding sg device found
Is sg driver loaded?
     host2: /dev/2:0:0:0 ATA Hitachi HDS72101
sginfo(open): No such file or directory
file=/dev/holders, or no corresponding sg device found
Is sg driver loaded?
     host2: /dev/holders ATA Hitachi HDS72101
sginfo(open): No such file or directory
file=/dev/queue, or no corresponding sg device found
Is sg driver loaded?
     host2: /dev/queue ATA Hitachi HDS72101
     host2: Unknown /sys/block/sda/range
     host2: Unknown /sys/block/sda/removable
     host2: /dev/sda1 ATA Hitachi HDS72101 {SN: JP2921HQ0J0PZA}
     host2: /dev/sda2 ATA Hitachi HDS72101 {SN: JP2921HQ0J0PZA}
     host2: Unknown /sys/block/sda/size
sginfo(open): No such file or directory
file=/dev/slaves, or no corresponding sg device found
Is sg driver loaded?
     host2: /dev/slaves ATA Hitachi HDS72101
     host2: Unknown /sys/block/sda/stat
sginfo(open): No such file or directory
file=/dev/block, or no corresponding sg device found
Is sg driver loaded?
     host2: /dev/block ATA Hitachi HDS72101
     host2: Unknown /sys/block/sda/uevent
Controller device @ pci0000:00/0000:00:1e.0/0000:05:01.1 [aic7xxx]
   SCSI storage controller: Adaptec AHA-3960D / AIC-7899A U160/m (rev 
01)    host9: [Empty]
Controller device @ pci0000:00/0000:00:1e.0/0000:05:01.0 [aic7xxx]
   SCSI storage controller: Adaptec AHA-3960D / AIC-7899A U160/m (rev 
01)    host8: [Empty]
Controller device @ pci0000:00/0000:00:1c.4/0000:03:00.0 [pata_marvell]
   IDE interface: Marvell Technology Group Ltd. 88SE6121 SATA II 
Controller (rev b2)    host1: [Empty]
     host0: Unknown /sys/block/sr0/dev
sginfo(open): No such file or directory
file=/dev/0:0:0:0, or no corresponding sg device found
Is sg driver loaded?
     host0: /dev/0:0:0:0 HL-DT-ST DVD-RAM GH22NP20
sginfo(open): No such file or directory
file=/dev/holders, or no corresponding sg device found
Is sg driver loaded?
     host0: /dev/holders HL-DT-ST DVD-RAM GH22NP20
sginfo(open): No such file or directory
file=/dev/queue, or no corresponding sg device found
Is sg driver loaded?
     host0: /dev/queue HL-DT-ST DVD-RAM GH22NP20
     host0: Unknown /sys/block/sr0/range
     host0: Unknown /sys/block/sr0/removable
     host0: Unknown /sys/block/sr0/size
sginfo(open): No such file or directory
file=/dev/slaves, or no corresponding sg device found
Is sg driver loaded?
     host0: /dev/slaves HL-DT-ST DVD-RAM GH22NP20
     host0: Unknown /sys/block/sr0/stat
sginfo(open): No such file or directory
file=/dev/block, or no corresponding sg device found
Is sg driver loaded?
     host0: /dev/block HL-DT-ST DVD-RAM GH22NP20
     host0: Unknown /sys/block/sr0/uevent
[root@beast ~]#

So it's finding my drives but also trying to describe_device lots of 
wrong things - maybe need a different expansion for the loop in check_host?

Hopefully the below will give you a better idea of what the sysfs layout 
is like on CentOS/RHEL 5:

[root@beast 0000:00:1f.2]# pwd
/sys/devices/pci0000:00/0000:00:1f.2
[root@beast 0000:00:1f.2]# ls -F
broken_parity_status  enable  host7/      resource0  subsystem@
bus@                  host2/  irq         resource1  subsystem_device
class                 host3/  local_cpus  resource2  subsystem_vendor
config                host4/  modalias    resource3  uevent
device                host5/  power/      resource4  vendor
driver@               host6/  resource    resource5
[root@beast 0000:00:1f.2]# ls -FR host2
host2:
power/  scsi_host:host2@  target2:0:0/  uevent

host2/power:
state  wakeup

host2/target2:0:0:
2:0:0:0/  power/  uevent

host2/target2:0:0/2:0:0:0:
block:sda@      iocounterbits  queue_type            state
bus@            iodone_cnt     rescan                subsystem@
delete          ioerr_cnt      rev                   sw_activity
device_blocked  iorequest_cnt  scsi_device:2:0:0:0@  timeout
dh_state        model          scsi_disk:2:0:0:0@    type
driver@         power/         scsi_generic:sg1@     uevent
generic@        queue_depth    scsi_level            vendor

host2/target2:0:0/2:0:0:0/power:
state  wakeup

host2/target2:0:0/power:
state  wakeup
[root@beast 0000:00:1f.2]# ls -FR host2/target2\:0\:0/2\:0\:0\:0/block\:sda/
host2/target2:0:0/2:0:0:0/block:sda/:
dev      holders/  range      sda1/  size     stat        uevent
device@  queue/    removable  sda2/  slaves/  subsystem@

host2/target2:0:0/2:0:0:0/block:sda/holders:

host2/target2:0:0/2:0:0:0/block:sda/queue:
iosched/  max_hw_sectors_kb  nr_requests    scheduler
iostats   max_sectors_kb     read_ahead_kb

host2/target2:0:0/2:0:0:0/block:sda/queue/iosched:
back_seek_max      fifo_expire_sync  slice_async     slice_sync
back_seek_penalty  quantum           slice_async_rq
fifo_expire_async  queued            slice_idle

host2/target2:0:0/2:0:0:0/block:sda/sda1:
dev  holders/  size  start  stat  subsystem@  uevent

host2/target2:0:0/2:0:0:0/block:sda/sda1/holders:
md0@

host2/target2:0:0/2:0:0:0/block:sda/sda2:
dev  holders/  size  start  stat  subsystem@  uevent

host2/target2:0:0/2:0:0:0/block:sda/sda2/holders:
md1@

host2/target2:0:0/2:0:0:0/block:sda/slaves:
[root@beast 0000:00:1f.2]#


Hope this helps. I've also attached my edited version of the script.

Many thanks,

John.

[-- Attachment #2: describe_scsi_2 --]
[-- Type: text/plain, Size: 1835 bytes --]

#! /bin/bash
#
# Examine specific system host devices to identify the drives attached
#

function describe_controller () {
	local device driver modprefix serial slotname
	driver="`readlink -f \"$1/driver\"`"
	driver="`basename $driver`"
	modprefix="`cut -d: -f1 <\"$1/modalias\"`"
	echo "Controller device @ ${1##/sys/devices/} [$driver]"
	if [[ "$modprefix" == "pci" ]] ; then
		slotname="`basename \"$1\"`"
		echo -n "  `lspci -s $slotname |cut -d\  -f2-`"
		return
	fi
	if [[ "$modprefix" == "usb" ]] ; then
		if [[ -f "$1/busnum" ]] ; then
			device="`cat \"$1/busnum\"`:`cat \"$1/devnum\"`"
			serial="`cat \"$1/serial\"`"
		else
			device="`cat \"$1/../busnum\"`:`cat \"$1/../devnum\"`"
			serial="`cat \"$1/../serial\"`"
		fi
		echo "  `lsusb -s $device` {SN: $serial}"
		return
	fi
	echo -e "  `cat \"$1/modalias\"`"
}

function describe_device () {
	targ=${1%/block*/*}
	vnd="`cat $targ/vendor`"
	mdl=`cat $targ/model`
	rdev=`readlink -f "$1"`
	if [[ -d $rdev ]] ; then
		bdev="`basename $rdev`"
		sn="`sginfo -s /dev/$bdev | \
			sed -rn -e \"/Serial Number/{s%^.+' *(.+) *'.*\\\$%\\\\1%;p;q}\"`" &>/dev/null
		if [[ -n "$sn" ]] ; then
			echo -e "    $bhost: `echo /dev/$bdev $vnd $mdl {SN: $sn}`"
		else
			echo -e "    $bhost: `echo /dev/$bdev $vnd $mdl`"
		fi
	else
		echo -e "    $bhost: Unknown $rdev"
	fi
}

function check_host () {
	local found=0
	local pController=
	while read shost ; do
		host=`dirname "$shost"`
		controller=`dirname "$host"`
		bhost=`basename "$host"`
		if [[ "$controller" != "$pController" ]] ; then
			pController="$controller"
			describe_controller "$controller"
		fi
		for dev in $host/target*/*/block*/* ; do
			if [[ "${dev: -1}" == '*' ]] ; then
				echo -e "    $bhost: [Empty]"
			else
				describe_device "$dev"
			fi
		done
	done
}

find /sys/devices/ -name *scsi_host* |check_host

  parent reply	other threads:[~2010-11-07 15:19 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-03 14:13 Determining which spindle is out of order Nat Makarevitch
2010-11-03 14:38 ` Roman Mamedov
2010-11-03 15:17   ` Graham Mitchell
2010-11-03 16:05     ` Roman Mamedov
2010-11-03 19:00       ` Jon Hardcastle
2010-11-03 14:43 ` John Robinson
2010-11-03 14:45 ` Tim Small
2010-11-03 15:59   ` Jon Hardcastle
2010-11-03 17:17     ` Bill Davidsen
2010-11-03 20:03       ` Tim Small
2010-11-03 15:29 ` Mikael Abrahamsson
2010-11-03 21:54 ` Phil Turmel
2010-11-03 22:26   ` Roman Mamedov
2010-11-04  9:29   ` Tom Carlson
2010-11-06 10:22   ` Leslie Rhorer
2010-11-06 15:12     ` Phil Turmel
     [not found]       ` <4CD57867.4010207@anonymous.org.uk>
2010-11-06 16:02         ` Phil Turmel
2010-11-06 16:11           ` Mathias Burén
2010-11-06 16:45           ` Jan Ceuleers
2010-11-06 19:39             ` Phil Turmel
2010-11-06 20:16               ` Leslie Rhorer
2010-11-06 20:23               ` Mr. James W. Laferriere
2010-11-07  7:51               ` Jan Ceuleers
2010-11-07 12:53           ` John Robinson
2010-11-07 13:21             ` Phil Turmel
2010-11-07 13:43               ` John Robinson
2010-11-07 14:43                 ` Phil Turmel
2010-11-07 15:04                   ` Mathias Burén
2010-11-07 15:19                   ` John Robinson [this message]
2010-11-07 18:39                     ` Phil Turmel
2010-11-07 20:46                       ` Leslie Rhorer
2010-11-07 21:22                         ` John Robinson
2010-11-08 18:59                           ` John Robinson
2010-11-07 21:24                       ` Andreas Dröscher
2010-11-08 21:05                   ` Mr. James W. Laferriere
2010-11-07 20:52                 ` Roman Mamedov
2010-11-09 14:40                   ` Phil Turmel
2010-11-06 19:58       ` Leslie Rhorer
2010-11-06 21:17       ` John Robinson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4CD6C36C.1080200@anonymous.org.uk \
    --to=john.robinson@anonymous.org.uk \
    --cc=linux-raid@vger.kernel.org \
    --cc=philip@turmel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.