All of lore.kernel.org
 help / color / mirror / Atom feed
From: Todd Deshane <tmdeshan@vnet.ibm.com>
To: linux-hotplug@vger.kernel.org
Subject: Re: mapping device name to iscsi target
Date: Mon, 24 Jul 2006 14:25:59 +0000	[thread overview]
Message-ID: <1153751159.15463.100.camel@localhost> (raw)
In-Reply-To: <1153630174.15463.45.camel@localhost>

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

      reply	other threads:[~2006-07-24 14:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-23  4:49 mapping device name to iscsi target Todd Deshane
2006-07-24 14:25 ` Todd Deshane [this message]

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=1153751159.15463.100.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.