RE: Exporting MHVTL devices via pscsi?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Sean,

On Sat, 2013-03-02 at 22:39 -0500, Sean Liu wrote:
> Hi Nicholas,
> 
> I tried to use tcm_node to add the tape device with the patched tcm_pscsi.py but it did not seem to work.
> root@vUbuntu:/usr/local/lib/python2.7/dist-packages# lsscsi -g
> [1:0:0:0]    cd/dvd  NECVMWar VMware IDE CDR10 1.00  /dev/sr0  /dev/sg0
> [2:0:0:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sda  /dev/sg1
> [3:0:0:0]    mediumx STK      L700             0104  /dev/sch0  /dev/sg10
> [3:0:1:0]    tape    IBM      ULT3580-TD5      0104  /dev/st0  /dev/sg2
> [3:0:2:0]    tape    IBM      ULT3580-TD5      0104  /dev/st1  /dev/sg3
> [3:0:3:0]    tape    IBM      ULT3580-TD4      0104  /dev/st2  /dev/sg4
> [3:0:4:0]    tape    IBM      ULT3580-TD4      0104  /dev/st3  /dev/sg5
> [3:0:8:0]    mediumx STK      L80              0104  /dev/sch1  /dev/sg11
> [3:0:9:0]    tape    STK      T10000B          0104  /dev/st4  /dev/sg6
> [3:0:10:0]   tape    STK      T10000B          0104  /dev/st5  /dev/sg7
> [3:0:11:0]   tape    STK      T10000B          0104  /dev/st6  /dev/sg8
> [3:0:12:0]   tape    STK      T10000B          0104  /dev/st7  /dev/sg9
> root@vUbuntu:/usr/local/lib/python2.7/dist-packages# python ./tcm_node.py --scsi=pscsi_3/st0 0:1:0
> Calling pscsi createvirtdev: path pscsi_3/st0
> Calling pscsi createvirtdev: params ['scsi_channel_id=0,scsi_target_id=1,scsi_lun_id=0']
> scsi_channel_id=0,scsi_target_id=1,scsi_lun_id=0
> Calling control_opt echo -n scsi_channel_id=0,scsi_target_id=1,scsi_lun_id=0 > /sys/kernel/config/target/core/pscsi_3/st0/control
> Calling enable_opt echo 1 > /sys/kernel/config/target/core/pscsi_3/st0/enable
> pSCSI: createvirtdev failed for enable_opt with scsi_channel_id=0,scsi_target_id=1,scsi_lun_id=0
> None
> 
> Following is the diff:
> root@vUbuntu:/usr/local/lib/python2.7/dist-packages# diff tcm_pscsi.py ~/lio-utils/lio-utils/tcm-py/tcm_pscsi.py.backup
> 46c46
> < 	print "Calling pscsi createvirtdev: path " + path
> ---
> > #	print "Calling pscsi createvirtdev: path " + path
> 49c49
> < 	print "Calling pscsi createvirtdev: params " + str(params)
> ---
> > #	print "Calling pscsi createvirtdev: params " + str(params)
> 51,53c51
> < 	print pscsi_params
> < 
> < 	udev_path="/dev/null"
> ---
> > #	print pscsi_params
> 107,108d104
> < 		pscsi_params = "scsi_host_id=" + scsi_host_id + ",scsi_channel_id=" + scsi_channel_id + ",scsi_target_id=" + scsi_target_id + ",scsi_lun_id=" + scsi_lun_id.rstrip()
> < 		
> 114a111,113
> > 		pscsi_params = "scsi_host_id=" + scsi_host_id + ",scsi_channel_id=" + scsi_channel_id + ",scsi_target_id=" + scsi_target_id + ",scsi_lun_id=" + scsi_lun_id.rstrip()
> > 
> > 		
> 116c115
> < 	print "Calling control_opt " + control_opt
> ---
> > #	print "Calling control_opt " + control_opt
> 123c122
> < 	print "Calling enable_opt " + enable_opt
> ---
> > #	print "Calling enable_opt " + enable_opt
> 
> I must have missed something? I plea newbie with LIO/TCM...
> 

This patch does not match the work-around below..

Namely, the 'set_udev_path_op' assignment part is missing, which is
required to set udev_path before enabling the pSCSI backend device.   

Without setting some value for udev_path, pSCSI will fail at enable time
as your encountering above.

Here's the patch again.

diff --git a/tcm-py/tcm_pscsi.py b/tcm-py/tcm_pscsi.py
index defe508..74d8c14 100755
--- a/tcm-py/tcm_pscsi.py
+++ b/tcm-py/tcm_pscsi.py
@@ -50,6 +50,8 @@ def createvirtdev(path, params):
        pscsi_params = params[0]
 #      print pscsi_params
 
+       udev_path = "/dev/null"
+
        # Exract HCTL from sysfs and set udev_path
        if re.search('/dev/', pscsi_params):
                udev_path = pscsi_params.rstrip()
@@ -102,14 +104,13 @@ def createvirtdev(path, params):
                scsi_lun_id = scsi_hctl[3]
                print "pSCSI: Referencing HCTL " + out[1].rstrip() + " for udev_path: " + udev_path
 
-               set_udev_path_op = "echo -n " + udev_path + " > " + cfs_path + "udev_path"
-               ret = os.system(set_udev_path_op)
-               if ret:
-                       print "pSCSI: Unable to set udev_path in " + cfs_path + " for: " + udev_path
-                       return -1
-
                pscsi_params = "scsi_host_id=" + scsi_host_id + ",scsi_channel_id=" + scsi_channel_id + ",scsi_targe
-
+               
+       set_udev_path_op = "echo -n " + udev_path + " > " + cfs_path + "udev_path"
+       ret = os.system(set_udev_path_op)
+       if ret:
+               print "pSCSI: Unable to set udev_path in " + cfs_path + " for: " + udev_path
+               return -1
                
        control_opt = "echo -n " + pscsi_params + " > " + cfs_path + "control"
 #      print "Calling control_opt " + control_opt


> Thanks,
> 
> Sean
> 
> -----Original Message-----
> From: Nicholas A. Bellinger [mailto:nab@xxxxxxxxxxxxxxx] 
> Sent: Thursday, February 28, 2013 5:38 PM
> To: Sean Liu
> Cc: target-devel@xxxxxxxxxxxxxxx
> Subject: Re: Exporting MHVTL devices via pscsi?
> 
> Hi Sean,
> 
> On Thu, 2013-02-28 at 12:19 -0500, Sean Liu wrote:
> > Hi there,
> > 
> > 
> > I am trying to make MHVTL (https://sites.google.com/site/linuxvtl2/) 
> > work under LIO.
> > 
> > MHVTL emulates virtual tape libraries and currently it can integrate 
> > with stgt framework.
> > 
> > Here's what has been emulated on my test machine (Ubuntu 12.04LTS):
> > 
> > root@vUbuntu:~# lsscsi -g
> > 
> > [1:0:0:0]    cd/dvd  NECVMWar VMware IDE CDR10 1.00  /dev/sr0  /dev/sg0
> > 
> > [2:0:0:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sda  /dev/sg1
> > 
> > [3:0:0:0]    mediumx STK      L700             0104  /dev/sch0  /dev/sg10
> > 
> > [3:0:1:0]    tape    IBM      ULT3580-TD5      0104  /dev/st0  /dev/sg2
> > 
> > [3:0:2:0]    tape    IBM      ULT3580-TD5      0104  /dev/st1  /dev/sg3
> > 
> > [3:0:3:0]    tape    IBM      ULT3580-TD4      0104  /dev/st2  /dev/sg4
> > 
> > [3:0:4:0]    tape    IBM      ULT3580-TD4      0104  /dev/st3  /dev/sg5
> > 
> > [3:0:8:0]    mediumx STK      L80              0104  /dev/sch1  /dev/sg11
> > 
> > [3:0:9:0]    tape    STK      T10000B          0104  /dev/st4  /dev/sg6
> > 
> > [3:0:10:0]   tape    STK      T10000B          0104  /dev/st5  /dev/sg7
> > 
> > [3:0:11:0]   tape    STK      T10000B          0104  /dev/st6  /dev/sg8
> > 
> > [3:0:12:0]   tape    STK      T10000B          0104  /dev/st7  /dev/sg9
> > 
> >  
> > 
> > With targetcli, I would imagine I'll have to use pscsi (iblock seems 
> > to only work with disk devices) to export the tape lib and drives. 
> > However when I try to add the backstores, I got following errors:
> > 
> > /backstores/pscsi> create name=tapelib1 dev=/dev/sg2
> > 
> > Cannot find SCSI device by path, and dev parameter not in H:C:T:L format:
> > /dev/sg2.
> > 
> > /backstores/pscsi> create name=tapelib1 dev=3:0:0:0
> > 
> > SCSI device does not exist.
> > 
> >  
> > 
> > As a matter of fact, even the disk could not be added:
> > 
> > /backstores/pscsi> create name=disk1 dev=/dev/sg1
> > 
> > Cannot find SCSI device by path, and dev parameter not in H:C:T:L format:
> > /dev/sg1.
> > 
> 
> Note that the pscsi dev= parameter in targetcli assumes a block device (/dev/sdX or /dev/sr), so this currently does not work with SCSI medium changers or tapes that use character devices..
> 
> >  
> > 
> > Am I missing anything? Or is pscsi not supported at all?
> > 
> 
> One work-around is to use tcm_node (from lio-utils.git) w/ a quick patch inline below to address changes in modern target_core_pscsi.ko code.
> 
> So with lsscsi output of mhvtl looking like:
> 
> [12:0:0:0]   mediumx STK      L700             0104  /dev/sch0
> [12:0:1:0]   tape    IBM      ULT3580-TD5      0104  /dev/st0
> [12:0:2:0]   tape    IBM      ULT3580-TD5      0104  /dev/st3
> [12:0:3:0]   tape    IBM      ULT3580-TD4      0104  /dev/st1
> [12:0:4:0]   tape    IBM      ULT3580-TD4      0104  /dev/st2
> [12:0:8:0]   mediumx STK      L80              0104  /dev/sch1
> [12:0:9:0]   tape    STK      T10000B          0104  /dev/st5
> [12:0:10:0]  tape    STK      T10000B          0104  /dev/st6
> [12:0:11:0]  tape    STK      T10000B          0104  /dev/st7
> [12:0:12:0]  tape    STK      T10000B          0104  /dev/st4
> 
> use tcm_node --scsi= with the following syntax.  Note that H:C:T:L needs to line up with pscsi_XX/foo X:X:X:
> 
> # tcm_node --scsi=pscsi_12/sch0 0:1:0
> dev_path: pscsi_12/sch0
> Status: DEACTIVATED  Execute/Left/Max Queue Depth: 0/32/32  SectorSize: 0  MaxSectors: 1024
>         SCSI Device Bus Location: Channel ID: 0 Target ID: 1 LUN: 0 Host ID: PHBA Mode
>         Vendor: IBM      Model: ULT3580-TD5      Rev: 0104
> 
> # tcm_node --scsi=pscsi_12/st0 0:2:0
> dev_path: pscsi_12/st0
> Status: DEACTIVATED  Execute/Left/Max Queue Depth: 0/32/32  SectorSize: 0  MaxSectors: 1024
>         SCSI Device Bus Location: Channel ID: 0 Target ID: 2 LUN: 0 Host ID: PHBA Mode
>         Vendor: IBM      Model: ULT3580-TD5      Rev: 0104
> 
> that will then show up under /backstores/pscsi/ and can be used normally in targetcli like other backstores:
> 
> /> ls /backstores/pscsi/
> o- pscsi ................................................... [2 Storage Objects]
>   o- sch0 ......................... [LEGACY: SHARED HBA (/dev/null deactivated)]
>   o- st0 ............................ [LEGACY: SHARED HBA (/dev/null activated)]
> 
> The patch to tcm_pscsi.py is below.  Note this currently does not support saving configuration state across restart with tcm_dump.py, which will need to be addressed separately.
> 
> However, it should be enough to get an initial configuration up and running.  Please let us know if you run into any other issues.
> 
> --nab
> 
> diff --git a/tcm-py/tcm_pscsi.py b/tcm-py/tcm_pscsi.py index defe508..74d8c14 100755
> --- a/tcm-py/tcm_pscsi.py
> +++ b/tcm-py/tcm_pscsi.py
> @@ -50,6 +50,8 @@ def createvirtdev(path, params):
>         pscsi_params = params[0]
>  #      print pscsi_params
>  
> +       udev_path = "/dev/null"
> +
>         # Exract HCTL from sysfs and set udev_path
>         if re.search('/dev/', pscsi_params):
>                 udev_path = pscsi_params.rstrip() @@ -102,14 +104,13 @@ def createvirtdev(path, params):
>                 scsi_lun_id = scsi_hctl[3]
>                 print "pSCSI: Referencing HCTL " + out[1].rstrip() + " for udev_path: " + udev_path
>  
> -               set_udev_path_op = "echo -n " + udev_path + " > " + cfs_path + "udev_path"
> -               ret = os.system(set_udev_path_op)
> -               if ret:
> -                       print "pSCSI: Unable to set udev_path in " + cfs_path + " for: " + udev_path
> -                       return -1
> -
>                 pscsi_params = "scsi_host_id=" + scsi_host_id + ",scsi_channel_id=" + scsi_channel_id + ",scsi_targe
> -
> +               
> +       set_udev_path_op = "echo -n " + udev_path + " > " + cfs_path + "udev_path"
> +       ret = os.system(set_udev_path_op)
> +       if ret:
> +               print "pSCSI: Unable to set udev_path in " + cfs_path + " for: " + udev_path
> +               return -1
>                 
>         control_opt = "echo -n " + pscsi_params + " > " + cfs_path + "control"
>  #      print "Calling control_opt " + control_opt
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe target-devel" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux