Re: [PATCH 8/19]: SCST SYSFS interface implementation

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Vladislav Bolkhovitin
Date: Monday, November 15, 2010 - 1:36 pm

Greg KH, on 11/14/2010 02:59 AM wrote:

Hmm, I thought we had the approvement in the "[RFC]: SCST sysfs layout"
thread (http://osdir.com/ml/linux-kernel/2009-04/msg07822.html). Particularly,
in the message http://osdir.com/ml/linux-kernel/2009-04/msg08557.html.

But, looks like it isn't so and I should have asked you, the SYSFS maintainer.
Sorry.

Could you consider it, please?

You can find detail description why SCST needs such layout below.
 

I'll try to explain. It's a bit long story involving deep SCSI target specific
knowledge, but I'll try to make it as simple and short as possible.

SCST is a SCSI _target_ side subsystem, i.e. it is a _server_ side sybsystem.
It exports SCSI-speaking devices, not using them. You can consider it as an NFS
server. What usually meant by "SCSI subsystem" is SCSI _initiator_ subsystem,
i.e. client side subsystem (like NFS client), which is using SCSI-speaking
devices by sending SCSI commands to them.

Any SCSI-speaking protocol can be used with SCST: parallel (wide) SCSI, Fibre Channel,
iSCSI, SAS, SRP, iSER, etc. (Also, non-SCSI speaking protocols, like AoE and
NBD can be used, but that's another story.)

Strictly as required by SCSI Architecture Model (SAM [1]), SCST doesn't deal with
hardware devices. The closest to hardware things SCST deals with are SCSI target
ports and SCSI target devices.

SCSI target port is an abstract concept reflecting path through which SCST
exports devices. You can consider it as an IP network (network, not interface!)
through which an NFS server's exports can be used. For instance, for iSCSI
such ports are iSCSI targets. For Fibre Channel - virtual or hardware Fibre
Channel ports.

SCSI target device is an abstract concept, which provides a way to reach real storage
(files, block devices, etc.) and contains internal state information (reservations,
configuration parameters, etc.). You can consider it as an NFS export. Please don't
confuse it with SCSI _initiator_ device, which is a place to generate SCSI commands
and send them via one or more SCSI initiator ports (MPIO). On the target side
they will be accepted via one or more SCSI target ports, then sent by the
corresponding SCSI target device to back storage device (file, block device, etc.).

So, there is no place in SCST to make Linux devices and use struct device. It's up to
SCST target drivers to create Linux devices for target hardware, if they need it,
which is rare. For instance, scst_local driver make SCST's SCSI target devices be
available as SCSI initiator, i.e. regular, devices by creating all the necessary
devices and SYSFS infrastructure for them:

Load SCST modules:

[root@tgt ~]# modprobe scst
[root@tgt ~]# modprobe scst_vdisk

Create SCSI target device "blockio" with /dev/sda5 as backstorage:

[root@tgt ~]# echo "add_device blockio filename=/dev/sda5" >/sys/kernel/scst_tgt/handlers/vdisk_blockio/mgmt

Check current SCSI devices:

[root@tgt ~]# lsscsi
[1:0:0:0]    disk    SEAGATE  ST373455LW       0003  /dev/sda
[2:0:0:0]    disk    Linux    scsi_debug       0004  /dev/sdb

Check that host3 doesn't exist:

[root@tgt ~]# cd /sys/class/scsi_host/host3
bash: cd: /sys/class/scsi_host/host3: No such file or directory

Load scst_local target driver:

[root@tgt ~]# modprobe scst_local

Create SCSI target port "scst_local_tgt" with SCSI host "scst_local_host" (host3):

[root@tgt ~]# echo "add_target scst_local_tgt session_name=scst_local_host" >/sys/kernel/scst_tgt/targets/scst_local/mgmt

Add "blockio" as LUN 0:

[root@tgt ~]# echo "add blockio 0" >/sys/kernel/scst_tgt/targets/scst_local/scst_local_tgt/luns/mgmt

See new local SCSI device 3:0:0:0 (/dev/sdc):

[root@tgt ~]# lsscsi
[1:0:0:0]    disk    SEAGATE  ST373455LW       0003  /dev/sda
[2:0:0:0]    disk    Linux    scsi_debug       0004  /dev/sdb
[3:0:0:0]    disk    SCST_BIO blockio           210  /dev/sdc

[root@tgt ~]# cd /sys/class/scsi_host/host3
[root@tgt host3]# ll
total 0
-rw-r--r-- 1 root root 4096 Nov 16 00:22 active_mode
-r--r--r-- 1 root root 4096 Nov 16 00:22 can_queue
-r--r--r-- 1 root root 4096 Nov 16 00:22 cmd_per_lun
lrwxrwxrwx 1 root root    0 Nov 16 00:07 device -> ../../../devices/scst_local/scst_local_host/host3
-r--r--r-- 1 root root 4096 Nov 16 00:22 host_busy
drwxr-xr-x 2 root root    0 Nov 16 00:22 power
-r--r--r-- 1 root root 4096 Nov 16 00:22 proc_name
-r--r--r-- 1 root root 4096 Nov 16 00:22 prot_capabilities
-r--r--r-- 1 root root 4096 Nov 16 00:22 prot_guard_type
--w------- 1 root root 4096 Nov 16 00:22 scan
-r--r--r-- 1 root root 4096 Nov 16 00:22 sg_tablesize
-rw-r--r-- 1 root root 4096 Nov 16 00:22 state
lrwxrwxrwx 1 root root    0 Nov 16 00:22 subsystem -> ../../scsi_host
-rw-r--r-- 1 root root 4096 Nov 16 00:22 supported_mode
-rw-r--r-- 1 root root 4096 Nov 16 00:22 uevent
-r--r--r-- 1 root root 4096 Nov 16 00:22 unchecked_isa_dma
-r--r--r-- 1 root root 4096 Nov 16 00:22 unique_id

Hopefully, it will make a bit clearer, why SCST can't use struct device, but uses
struct kobject, and why it needs a special place in the SYSFS tree to attach to.

Thanks,
Vlad

[1] You can download a copy of SAM from http://www.t10.org/drafts.htm. Exact version doesn't matter.
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCHv4 0/19]: New SCSI target framework (SCST) with dev ..., Vladislav Bolkhovitin, (Fri Oct 1, 2:34 pm)
[PATCH 1/19]: Integration of SCST into the Linux kernel tree, Vladislav Bolkhovitin, (Fri Oct 1, 2:36 pm)
[PATCH 2/19]: SCST core's Makefile and Kconfig, Vladislav Bolkhovitin, (Fri Oct 1, 2:36 pm)
[PATCH 3/19]: SCST public headers, Vladislav Bolkhovitin, (Fri Oct 1, 2:38 pm)
[PATCH 4/19]: SCST main management files and private headers, Vladislav Bolkhovitin, (Fri Oct 1, 2:39 pm)
[PATCH 5/19]: SCST implementation of the SCSI target state ..., Vladislav Bolkhovitin, (Fri Oct 1, 2:42 pm)
[PATCH 6/19]: SCST internal library functions, Vladislav Bolkhovitin, (Fri Oct 1, 2:43 pm)
[PATCH 7/19]: SCST Persistent Reservations implementation, Vladislav Bolkhovitin, (Fri Oct 1, 2:44 pm)
[PATCH 8/19]: SCST SYSFS interface implementation, Vladislav Bolkhovitin, (Fri Oct 1, 2:46 pm)
[PATCH 9/19]: SCST debugging support routines, Vladislav Bolkhovitin, (Fri Oct 1, 2:46 pm)
[PATCH 10/19]: SCST SGV cache, Vladislav Bolkhovitin, (Fri Oct 1, 2:48 pm)
[PATCH 11/19]: SCST core's docs, Vladislav Bolkhovitin, (Fri Oct 1, 2:48 pm)
[PATCH 12/19]: SCST dev handlers' Makefile, Vladislav Bolkhovitin, (Fri Oct 1, 2:49 pm)
[PATCH 13/19]: SCST vdisk dev handler, Vladislav Bolkhovitin, (Fri Oct 1, 2:50 pm)
[PATCH 14/19]: SCST pass-through dev handlers, Vladislav Bolkhovitin, (Fri Oct 1, 2:51 pm)
[PATCH 15/19]: Implementation of blk_rq_map_kern_sg(), Vladislav Bolkhovitin, (Fri Oct 1, 2:53 pm)
[PATCH 16/19]: scst_local target driver, Vladislav Bolkhovitin, (Fri Oct 1, 2:57 pm)
[PATCH 17/19]: SCST InfiniBand SRP target driver, Vladislav Bolkhovitin, (Fri Oct 1, 2:58 pm)
[PATCH 18/19]: ibmvstgt: Port from tgt to SCST, Vladislav Bolkhovitin, (Fri Oct 1, 3:04 pm)
[PATCH 19/19]: tgt: Removal, Vladislav Bolkhovitin, (Fri Oct 1, 3:05 pm)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Vladislav Bolkhovitin, (Mon Oct 11, 12:29 pm)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Vladislav Bolkhovitin, (Tue Oct 12, 11:53 am)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Vladislav Bolkhovitin, (Thu Oct 14, 12:48 pm)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Vladislav Bolkhovitin, (Fri Oct 22, 10:30 am)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Vladislav Bolkhovitin, (Fri Oct 22, 11:40 am)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Vladislav Bolkhovitin, (Mon Nov 8, 12:58 pm)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Vladislav Bolkhovitin, (Tue Nov 9, 1:06 pm)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Boaz Harrosh, (Wed Nov 10, 2:58 am)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Vladislav Bolkhovitin, (Wed Nov 10, 1:19 pm)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Joe Eykholt, (Wed Nov 10, 1:29 pm)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Vladislav Bolkhovitin, (Wed Nov 10, 1:38 pm)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Joe Eykholt, (Wed Nov 10, 1:42 pm)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Boaz Harrosh, (Thu Nov 11, 2:59 am)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Boaz Harrosh, (Thu Nov 11, 7:05 am)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Boaz Harrosh, (Thu Nov 11, 7:19 am)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Vladislav Bolkhovitin, (Thu Nov 11, 1:50 pm)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Dmitry Torokhov, (Thu Nov 11, 6:23 pm)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Bart Van Assche, (Fri Nov 12, 5:09 am)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Dmitry Torokhov, (Fri Nov 12, 11:44 am)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Bart Van Assche, (Sat Nov 13, 3:52 am)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Vladislav Bolkhovitin, (Sat Nov 13, 10:20 am)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Dmitry Torokhov, (Sun Nov 14, 11:59 pm)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Dmitry Torokhov, (Mon Nov 15, 12:04 am)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Boaz Harrosh, (Mon Nov 15, 2:46 am)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Boaz Harrosh, (Mon Nov 15, 10:19 am)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Bart Van Assche, (Mon Nov 15, 10:45 am)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Bart Van Assche, (Mon Nov 15, 10:49 am)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Bart Van Assche, (Mon Nov 15, 10:53 am)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Nicholas A. Bellinger, (Mon Nov 15, 1:19 pm)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Vladislav Bolkhovitin, (Mon Nov 15, 1:36 pm)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Vladislav Bolkhovitin, (Mon Nov 15, 1:36 pm)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Vladislav Bolkhovitin, (Mon Nov 15, 1:37 pm)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Vladislav Bolkhovitin, (Mon Nov 15, 1:39 pm)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Vladislav Bolkhovitin, (Mon Nov 15, 1:39 pm)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Vladislav Bolkhovitin, (Mon Nov 15, 1:39 pm)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Dmitry Torokhov, (Mon Nov 15, 2:14 pm)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Joe Eykholt, (Mon Nov 15, 10:04 pm)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Nicholas A. Bellinger, (Mon Nov 15, 11:03 pm)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Bart Van Assche, (Tue Nov 16, 12:15 am)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Florian Mickler, (Tue Nov 16, 1:49 am)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Vladislav Bolkhovitin, (Tue Nov 16, 6:12 am)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Vladislav Bolkhovitin, (Tue Nov 16, 6:13 am)
Re: [Scst-devel] [PATCH 8/19]: SCST SYSFS interface implem ..., Vladislav Bolkhovitin, (Tue Nov 16, 6:17 am)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Vladislav Bolkhovitin, (Tue Nov 16, 6:18 am)
Re: [PATCH 8/19]: SCST SYSFS interface implementation, Vladislav Bolkhovitin, (Tue Nov 16, 6:19 am)
Re: [Scst-devel] [PATCH 8/19]: SCST SYSFS interface implem ..., Vladislav Bolkhovitin, (Thu Nov 18, 2:02 pm)
Re: [Scst-devel] [PATCH 8/19]: SCST SYSFS interface implem ..., Vladislav Bolkhovitin, (Fri Nov 19, 11:00 am)
Re: [Scst-devel] [PATCH 8/19]: SCST SYSFS interface implem ..., Vladislav Bolkhovitin, (Fri Nov 19, 1:50 pm)
Re: [Scst-devel] [PATCH 8/19]: SCST SYSFS interface implem ..., Vladislav Bolkhovitin, (Wed Nov 24, 1:35 pm)