Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 Aug 2012 22:42:04 -0600
From:      "Kenneth D. Merry" <ken@freebsd.org>
To:        John <jwd@freebsd.org>
Cc:        FreeBSD SCSI <freebsd-scsi@freebsd.org>
Subject:   Re: camcontrol devlist device name ordering
Message-ID:  <20120831044204.GA39391@nargothrond.kdm.org>
In-Reply-To: <20120831003106.GA70561@FreeBSD.org>
References:  <20120831003106.GA70561@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help

On Fri, Aug 31, 2012 at 00:31:06 +0000, John wrote:
> Hi Folks,
> 
>    I've been working on a small utility to map devices and enclosures
> and generate a small report. Nothing special really.
> 
>    However, I've run into a small parsing issue I thought I'd ask
> about here.
> 
>    When running "camcontrol devlist", the device names are not always
> printed out the same. For instance:
> 
> <HP EG0600FBLSH HPD2>              at scbus7 target 165 lun 0 (pass24,da21)
> <HP EG0600FBLSH HPD2>              at scbus7 target 166 lun 0 (pass25,da22)
> <HP EG0600FBLSH HPD2>              at scbus7 target 167 lun 0 (pass26,da23)
> <HP EG0600FBLSH HPD2>              at scbus7 target 168 lun 0 (pass27,da24)
> <HP D2700 SAS AJ941A 0131>         at scbus7 target 169 lun 0 (ses0,pass28) <---
> <HP EG0600FBLSH HPD2>              at scbus7 target 170 lun 0 (pass29,da25)
> <HP EG0600FBLSH HPD2>              at scbus7 target 171 lun 0 (pass30,da26)
> <HP EG0600FBLSH HPD2>              at scbus7 target 172 lun 0 (pass31,da27)
> 
>    In the last column, the disk devices are pass device / disk device. For
> the enclosure, it's enclosure device / pass device.
> 
>    First I looked at camcontrol, but it is simply looping over the list
> as presented. It is not responsible for the ordering. I then started
> poking around in sys/cam/scsi/scsi_ses.c and I can see where the device
> is allocated, but I'm not sure how the insertion ordering is controlled
> for the pass & ses devices.
> 
>    Does someone with a bit more knowledge of this area have an idea
> where I should look?

It is done in the order that the peripherals attach, and so it is rather
random and timing dependent.

Specifically, see cam_periph_alloc() in sys/cam/cam_periph.c, and
xpt_add_periph() in sys/cam/cam_xpt.c.

You could also do a 'camcontrol periphlist' for the first peripheral or
bus/target/lun in the devlist output and grep for the type of peripheral
you're interested in.

Some day I suppose we should do an XML output version of the devlist code,
or make it more script friendly.

Ken
-- 
Kenneth Merry
ken@FreeBSD.ORG



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120831044204.GA39391>