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 ��`@RtK����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 -- 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