From: Todd Deshane <tmdeshan@vnet.ibm.com>
To: linux-hotplug@vger.kernel.org
Subject: mapping device name to iscsi target
Date: Sun, 23 Jul 2006 04:49:33 +0000 [thread overview]
Message-ID: <1153630174.15463.45.camel@localhost> (raw)
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
next reply other threads:[~2006-07-23 4:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-23 4:49 Todd Deshane [this message]
2006-07-24 14:25 ` mapping device name to iscsi target Todd Deshane
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=1153630174.15463.45.camel@localhost \
--to=tmdeshan@vnet.ibm.com \
--cc=linux-hotplug@vger.kernel.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 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).