* mapping device name to iscsi target
@ 2006-07-23 4:49 Todd Deshane
2006-07-24 14:25 ` Todd Deshane
0 siblings, 1 reply; 2+ messages in thread
From: Todd Deshane @ 2006-07-23 4:49 UTC (permalink / raw)
To: linux-hotplug
Hi,
I know this topic has came up before on this list, but I still don't
have a reliable solution.
It was suggested to use the persistent device naming which comes with
udev:
http://www.kernel.org/git/?p=linux/hotplug/udev.git;a=blob;f=etc/udev/60-persistent-storage.rules
(see:
http://marc.theaimsgroup.com/?l=linux-hotplug-devel&m\x115036155509938&w=2
for details)
since it gives the /dev/disk entries such as by-id,by-label and by-uuid,
but i am not sure how to map the uuid back to the iscsi target.
Has anyone done this successful or have any ideas?
Also, the idea of using the bus id %b seems like a good idea, (see this
thread:
http://marc.theaimsgroup.com/?l=linux-hotplug-devel&m\x106928672620090&w=2
for details) but doesn't appear to be reliable enough: here is the code
if have for it so far for it:
I used the rule:
BUS="scsi", PROGRAM="/lib/udev/iscsidev %b" NAME="%c%n" SYMLINK="%k"
with the /lib/udev/iscsidev script as follows:
#!/usr/bin/python
import sys
import os
import re
arg = sys.argv[1]
(targname,bus,targ,lun) = arg.split(':')
for targets in os.popen('/sbin/iscsiadm -m session','r').readlines():
toMatch = re.compile('\[0*' + str(targname) + ':')
isMatch = toMatch.search(targets)
if(isMatch):
(head,addr,target_name) = targets.split();
sys.stdout.write(target_name)
script is based off of the perl version in:
http://groups.google.com/group/open-iscsi/browse_thread/thread/bc050f805c8f85c/fb0ff969e8da7629?q=udev&lnk=gst&rnum=2#fb0ff969e8da7629
In most cases this seems to work perfectly... it prints out the target
name and there is a nice mapping (targetname to actual device). However,
the problem seems to be that the bus id %b in the udev rule above can
get out of sync with targname in the script.
targname refers to the 'xx' in the output of the command iscsiadm -m
session
for example:
# iscsiadm -m session
[xx:<record id>] <host>:<port>,1 targetname
with a quick look at the source code the xx seems to refer to the
session id, which is not necessarily the same as the bus id, hence the
problem of out of sync.
So, what is the recommended way to get this mapping that
is reliable?
Any experience with this? ideas/suggestions?
Thanks in advance,
Todd
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CIDÞVDEV
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: mapping device name to iscsi target
2006-07-23 4:49 mapping device name to iscsi target Todd Deshane
@ 2006-07-24 14:25 ` Todd Deshane
0 siblings, 0 replies; 2+ messages in thread
From: Todd Deshane @ 2006-07-24 14:25 UTC (permalink / raw)
To: linux-hotplug
Hi All,
I have a working rule thanks to a response from Shawn Ferris.
here it is:
udev rule:
BUS="scsi", PROGRAM="/lib/udev/iscsidev.sh %b", SYMLINK+="iscsi/%c/part%
n"
iscsidev.sh script:
-------------------------------------------------------
#!/bin/sh
# Sample Path:
# /sys/class/scsi_host/host23/device/session19/iscsi_session:session19/targetname
BUS=${1}
HOST=${BUS%%:*}
file="/sys/class/scsi_host/host
${HOST}/device/session*/iscsi_session*/targetname"
# This is not an open-scsi drive
if [ -z "${file}" ]; then
exit 0
fi
target_name=$(cat ${file})
echo "${target_name}"
---------------------------------------------------------
Notice that you could use the following line of code to dynamically
detect the sysfs root (i.e. /sys), but with a read only
environment /etc/mtab is disabled so I just hardcoded /sys as the sysfs
root
---------------------------------------------------------
SYSFS=$(mount -t sysfs | awk '{print $3}' 2>/dev/null)
----------------------------------------------------------
Maybe this will help someone else in the future.
Todd
On Sun, 2006-07-23 at 00:49 -0400, Todd Deshane wrote:
> Hi,
>
> I know this topic has came up before on this list, but I still don't
> have a reliable solution.
>
> It was suggested to use the persistent device naming which comes with
> udev:
> http://www.kernel.org/git/?p=linux/hotplug/udev.git;a=blob;f=etc/udev/60-persistent-storage.rules
>
> (see:
> http://marc.theaimsgroup.com/?l=linux-hotplug-devel&m\x115036155509938&w=2
> for details)
>
> since it gives the /dev/disk entries such as by-id,by-label and by-uuid,
> but i am not sure how to map the uuid back to the iscsi target.
> Has anyone done this successful or have any ideas?
>
> Also, the idea of using the bus id %b seems like a good idea, (see this
> thread:
> http://marc.theaimsgroup.com/?l=linux-hotplug-devel&m\x106928672620090&w=2
> for details) but doesn't appear to be reliable enough: here is the code
> if have for it so far for it:
>
>
> I used the rule:
> BUS="scsi", PROGRAM="/lib/udev/iscsidev %b" NAME="%c%n" SYMLINK="%k"
>
> with the /lib/udev/iscsidev script as follows:
> #!/usr/bin/python
> import sys
> import os
> import re
>
> arg = sys.argv[1]
> (targname,bus,targ,lun) = arg.split(':')
> for targets in os.popen('/sbin/iscsiadm -m session','r').readlines():
> toMatch = re.compile('\[0*' + str(targname) + ':')
> isMatch = toMatch.search(targets)
> if(isMatch):
> (head,addr,target_name) = targets.split();
> sys.stdout.write(target_name)
>
> script is based off of the perl version in:
> http://groups.google.com/group/open-iscsi/browse_thread/thread/bc050f805c8f85c/fb0ff969e8da7629?q=udev&lnk=gst&rnum=2#fb0ff969e8da7629
>
> In most cases this seems to work perfectly... it prints out the target
> name and there is a nice mapping (targetname to actual device). However,
> the problem seems to be that the bus id %b in the udev rule above can
> get out of sync with targname in the script.
>
> targname refers to the 'xx' in the output of the command iscsiadm -m
> session
> for example:
> # iscsiadm -m session
> [xx:<record id>] <host>:<port>,1 targetname
>
> with a quick look at the source code the xx seems to refer to the
> session id, which is not necessarily the same as the bus id, hence the
> problem of out of sync.
>
> So, what is the recommended way to get this mapping that
> is reliable?
>
> Any experience with this? ideas/suggestions?
>
> Thanks in advance,
> Todd
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CIDÞVDEV
> _______________________________________________
> Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
> Linux-hotplug-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CIDÞVDEV
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-07-24 14:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-23 4:49 mapping device name to iscsi target Todd Deshane
2006-07-24 14:25 ` Todd Deshane
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).