Re: Does sysfs really provides persistent hardware path to devices?

From: Greg KH
Date: Wed Sep 24 2003 - 16:52:38 EST


On Sun, Aug 31, 2003 at 02:54:06PM +0400, Andrey Borzenkov wrote:
> On Tuesday 19 August 2003 00:42, Greg KH wrote:
> > On Mon, Aug 18, 2003 at 10:21:22AM +0400, "Andrey Borzenkov" wrote:
> > > just to show what I expected from sysfs - here is entry from Solaris
> > > /devices:
> > >
> > > brw-r----- 1 root sys 32,240 Jan 24 2002
> > > /devices/pci@16,4000/scsi@5,1/sd@0,0:a
> > >
> > > this entry identifies disk partition 0 on drive with SCSI ID 0, LUN 0
> > > connected to bus 1 of controller in slot 5 of PCI bus identified
> > > by 16. Now you can use whatever policy you like to give human
> > > meaningful name to this entry. And if you have USB it will continue
> > > further giving you exact topology starting from the root of your
> > > device tree.
> > >
> > > and this path does not contain single logical id so it is not subject
> > > to change if I add the same controller somewhere else.
> > >
> > > hopefully it clarifies what I mean ...
> >
> > Hm, a bit. First, have you looked at what sysfs provides? Here's one
> > of my machines and tell me if it has all the info you are looking for:
> >
> > $ tree /sys/bus/scsi/
> > /sys/bus/scsi/
> >
> > |-- devices
> > | `-- 0:0:0:0 ->
> > | ../../../devices/pci0000:00/0000:00:1e.0/0000:02:05.0/host0/0:0:0:0
> ^ ^unstable

Heh, so are the pci ids in that link too :)

> Now I have to ask - do we discuss udev-0.2 (what I currently have) or
> udev-as-it-can-be-in-fututure?

Either is fine with me.

> In udev-0.2 I cannot do it. I can say I want
>
> TOPOLOGY, BUS="scsi", place="0.0.0.0", NAME="jaz"
>
> but the next time I plug in SCSI card the host number changes. Even after I
> unplug USB stick and plug it again it gets new host number.
>
> And the same applies to USB, PCI and whatever. Sysfs exports entity numbers as
> kernel enumerates them; while Solaris exports persistent device tree leaving
> enumeration to user-level tools. Which means that if hardware changes for
> whatever reason enumeration changes as well and your config becomes invalid.

I agree. That's why topology is only one part of the rules, and is so
low in the chain of hierarchy of what to match on. To recap, here is
the hierarchy:
1 - label or serial number
2 - bus device number
3 - topology on bus
4 - replace name
5 - kernel name

So, if you do not have something that matches for your device for rules
1 or 2, then use 3. But yes, it can change. So can any of these items,
that's why we have to be flexible.

And yes, we should add wild card matching for topology rules, it's on
the todo list, I haven't had much time to work on udev lately.

> > Hope this helps,
> >
>
> Well, we did not move a tiny bit since the beginning of this thread :) You
> still did not show me namedev configuration that implements persistent name
> for a device based on its physical location :)))

Ok, do you have any other ideas of how to do this?

And patches for udev are always welcome :)

thanks,

greg k-h
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/