From owner-freebsd-scsi@FreeBSD.ORG Fri Aug 31 05:02:36 2012 Return-Path: Delivered-To: freebsd-scsi@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5C498106566C; Fri, 31 Aug 2012 05:02:36 +0000 (UTC) (envelope-from ken@kdm.org) Received: from nargothrond.kdm.org (nargothrond.kdm.org [70.56.43.81]) by mx1.freebsd.org (Postfix) with ESMTP id 010C18FC14; Fri, 31 Aug 2012 05:02:35 +0000 (UTC) Received: from nargothrond.kdm.org (localhost [127.0.0.1]) by nargothrond.kdm.org (8.14.2/8.14.2) with ESMTP id q7V4g43a040723; Thu, 30 Aug 2012 22:42:04 -0600 (MDT) (envelope-from ken@nargothrond.kdm.org) Received: (from ken@localhost) by nargothrond.kdm.org (8.14.2/8.14.2/Submit) id q7V4g4Fe040722; Thu, 30 Aug 2012 22:42:04 -0600 (MDT) (envelope-from ken) Date: Thu, 30 Aug 2012 22:42:04 -0600 From: "Kenneth D. Merry" To: John Message-ID: <20120831044204.GA39391@nargothrond.kdm.org> References: <20120831003106.GA70561@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120831003106.GA70561@FreeBSD.org> User-Agent: Mutt/1.4.2i Cc: FreeBSD SCSI Subject: Re: camcontrol devlist device name ordering X-BeenThere: freebsd-scsi@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SCSI subsystem List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Aug 2012 05:02:36 -0000 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: > > at scbus7 target 165 lun 0 (pass24,da21) > at scbus7 target 166 lun 0 (pass25,da22) > at scbus7 target 167 lun 0 (pass26,da23) > at scbus7 target 168 lun 0 (pass27,da24) > at scbus7 target 169 lun 0 (ses0,pass28) <--- > at scbus7 target 170 lun 0 (pass29,da25) > at scbus7 target 171 lun 0 (pass30,da26) > 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