Re: How to figure out which block device has been created by tcm_loop?

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

 



On Sat, Sep 26, 2015 at 5:18 PM, Nicholas A. Bellinger
<nab@xxxxxxxxxxxxxxx> wrote:
> On Sat, 2015-09-26 at 00:24 -0700, Ming Lin wrote:
>> On Fri, 2015-09-25 at 20:00 -0700, Sheng Yang wrote:
>> > Hi,
>> >
>> > I got hard time to determine which block device was created when I was
>> > using tcm_loop.
>> >
>> > Normally I would just take a look at dmesg, see sda or sdb got
>> > attached etc, but that's not a reliable way of doing it I guess.
>> >
>> > I also found the device showed up in "udevadm monitor", but unable to
>> > find a way to associate with the original device I created from TCM
>> > either.
>> >
>> > Here is the commands I've used to create the device(with tcmu-runner
>> > running with file_handler demo code). I guess it's possible associate
>> > with iscsi name somehow:
>> >
>> > mkdir -p /sys/kernel/config/target/core/user_1/test
>> > echo dev_size=1024000000 > /sys/kernel/config/target/core/user_1/test/control
>> > echo dev_config=file//root/test >
>> > /sys/kernel/config/target/core/user_1/test/control
>> > echo 1 > /sys/kernel/config/target/core/user_1/test/enable
>> >
>> > mkdir -p /sys/kernel/config/target/loopback/naa.60014059436855c1/tpgt_1
>> > echo "naa.60014051153c198a" >
>> > /sys/kernel/config/target/loopback/naa.60014059436855c1/tpgt_1/nexus
>> > mkdir -p /sys/kernel/config/target/loopback/naa.60014059436855c1/tpgt_1/lun/lun_0
>> > ln -s /sys/kernel/config/target/core/user_1/test
>> > /sys/kernel/config/target/loopback/naa.60014059436855c1/tpgt_1/lun/lun_0/c68d79910b
>>
>> You can get scsi port/lun from the configfs.
>>
>> Try below script.
>> The only missing part is I don't how to map wwn to SCSI host number.
>> So you need to modify the hard-coded map_wwn_to_host().
>
> That is found in /sys/bus/tcm_loop_bus/devices/tcm_loop_adapter_*/$HOST/
>
> Note the formatting of vpd_pg83 sysfs attribute is funky, but the same
> evpd=0x83 can be obtained via sg_inq + sg_vpd:
>
> root@scsi-mq:~# targetcli ls /loopback
> o- loopback ...................................................................... [1 Target]
>   o- naa.6001405cc85b892d .................................. [nexus WWN naa.60014050da04a3a9]
>     o- luns ......................................................................... [1 LUN]
>       o- lun0 ............................................... [fileio/tmpfile (/root/fileio)]
> root@scsi-mq:~# lsscsi
> [1:0:1:0]    disk    LIO-ORG  FILEIO           4.0   /dev/sda
> root@scsi-mq:~# cat /sys/bus/tcm_loop_bus/devices/tcm_loop_adapter_0/host1/target1\:0\:1/1\:0\:1\:0/vpd_pg83
> ��   ` @Rt  K� ���0��  4LIO-ORGFILEIO:2741b034-b8a0-4f7a-a833-0fefcfe15f6da�  a�    c� naa.6001405cc85b892d,t,0x0001c� naa.6001405cc85b892d
> root@scsi-mq:~# sg_vpd -i /dev/sda
> Device Identification VPD page:
>   Addressed logical unit:
>     designator type: NAA,  code set: Binary
>       0x60014052741b034b8a04f7aa8330fefc
>     designator type: T10 vendor identification,  code set: ASCII
>       vendor id: LIO-ORG
>       vendor specific: FILEIO:2741b034-b8a0-4f7a-a833-0fefcfe15f6d
>     designator type: Logical unit group,  code set: Binary
>       Logical unit group: 0x0
>   Target port:
>     designator type: Relative target port,  code set: Binary
>      transport: Serial Attached SCSI Protocol (SPL-3)
>       Relative target port: 0x2
>     designator type: Target port group,  code set: Binary
>      transport: Serial Attached SCSI Protocol (SPL-3)
>       Target port group: 0x0
>     designator type: SCSI name string,  code set: UTF-8
>      transport: Serial Attached SCSI Protocol (SPL-3)
>       SCSI name string:
>       naa.6001405cc85b892d,t,0x0001
>   Target device that contains addressed lu:
>     designator type: SCSI name string,  code set: UTF-8
>      transport: Serial Attached SCSI Protocol (SPL-3)
>       SCSI name string:
>       naa.6001405cc85b892d
>

Thank you Nicholas.

But seems probably due to the TCMU I am using, I cannot get the VPD
page of the device. Is it the VPD page implemented per backstore, or
it should be there but I setup something wrong?

root@kernel-dev:~# sg_inq /dev/sda
standard INQUIRY:
  PQual=0  Device_type=0  RMB=0  version=0x05  [SPC-3]
  [AERC=0]  [TrmTsk=0]  NormACA=0  HiSUP=0  Resp_data_format=2
  SCCS=0  ACC=0  TPGS=0  3PC=0  Protect=0  [BQue=0]
  EncServ=0  MultiP=0  [MChngr=0]  [ACKREQQ=0]  Addr16=0
  [RelAdr=0]  WBus16=0  Sync=0  Linked=0  [TranDis=0]  CmdQue=1
    length=36 (0x24)   Peripheral device type: disk
 Vendor identification: LIO-ORG
 Product identification: TCMU device
 Product revision level: 0002
root@kernel-dev:~# sg_inq --vpd /dev/sda
VPD INQUIRY, page code=0x00:
   [PQual=0  Peripheral device type: disk]
   Supported VPD pages:
root@kernel-dev:~# sg_vpd -i /dev/sda
Device Identification VPD page:
invalid VPD response; probably a STANDARD INQUIRY response
fetching VPD page failed

--Sheng
--
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