mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-17 10:41:26 +00:00
The sysfs attributes of a target can be accessed before scst_tgt.tgt_priv has been set. Avoid that such an access triggers a crash. Symptom: BUG: unable to handle kernel NULL pointer dereference at 000000000000004c IP: [<ffffffffa1345848>] iscsi_is_target_enabled+0x8/0x20 [iscsi_scst] PGD 150a4c067 PUD 13cacb067 PMD 0 Oops: 0000 [#1] SMP CPU 1 Modules linked in: zfs(P) iscsi_scst(O) scst_vdisk(O) scst(O) zcommon(P) znvpair(P) zavl(P) zunicode(P) spl(O) [last unloaded: zfs] Pid: 3974, comm: scst_uid1864 Tainted: P O 3.2.23-zfsiscsi-std-ipv6-64 #3 Supermicro X6DVA/X6DVA RIP: 0010:[<ffffffffa1345848>] [<ffffffffa1345848>] iscsi_is_target_enabled+0x8/0x20 [iscsi_scst] RSP: 0018:ffff88015071ddc0 EFLAGS: 00010282 RAX: 0000000000000000 RBX: ffff880181fdaa00 RCX: ffff88012d41f380 RDX: ffff88015071c010 RSI: 0000000000000000 RDI: ffff880181fdaa00 RBP: ffff88015071ddc0 R08: 0000000000000000 R09: 0000000000000001 R10: 0000000000000001 R11: 0000000000000001 R12: ffffffffa134a608 R13: 0000000000000000 R14: 0000000000000129 R15: ffffffffa134a4c0 FS: 0000000000000000(0000) GS:ffff88019fc80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b CR2: 000000000000004c CR3: 0000000151927000 CR4: 00000000000006e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 Process scst_uid1864 (pid: 3974, threadinfo ffff88015071c000, task ffff880194d57500) Stack: ffff88015071de10 ffffffffa12ee89a 00000000fffffffc 01ff88015071de98 ffff88015071de80 ffff8801932a48d8 00000000fffffffc ffff88015071de98 ffff88015071de80 ffff880194d57500 ffff88015071de30 ffffffffa12f582e Call Trace: [<ffffffffa12ee89a>] __scst_is_relative_target_port_id_unique+0x6a/0xc0 [scst] [<ffffffffa12f582e>] gen_relative_target_port_id+0x6e/0xd0 [scst] [<ffffffffa12fdb8a>] scst_tgt_enable_store_work_fn+0x3a/0xe0 [scst] [<ffffffffa12f9397>] sysfs_work_thread_fn+0xc7/0x2e0 [scst] [<ffffffffa12f92d0>] ? scst_tgtt_release+0x20/0x20 [scst] [<ffffffffa12f92d0>] ? scst_tgtt_release+0x20/0x20 [scst] [<ffffffff810b44f6>] kthread+0x96/0xa0 [<ffffffff81b8ed74>] kernel_thread_helper+0x4/0x10 [<ffffffff810b4460>] ? kthread_worker_fn+0x180/0x180 [<ffffffff81b8ed70>] ? gs_change+0xb/0xb Code: 42 c8 74 0f 39 78 48 75 ea c9 c3 0f 1f 84 00 00 00 00 00 31 c0 c9 c3 66 66 66 2e 0f 1f 84 00 00 00 00 00 48 8b 47 48 55 48 89 e5 <0f> b6 40 4c c9 83 e0 01 c3 66 66 66 66 66 66 2e 0f 1f 84 00 00 RIP [<ffffffffa1345848>] iscsi_is_target_enabled+0x8/0x20 [iscsi_scst] RSP <ffff88015071ddc0> CR2: 000000000000004c ---[ end trace 6311d4069703be07 ]--- Reported-by: Etienne Dechamps <e-t172@akegroup.org> Signed-off-by: Bart Van Assche <bvanassche@acm.org> with some modifications git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4515 d57e44dd-8a1f-0410-8b47-8ef2f437770f
About fcst
==========
The fcst kernel module implements an SCST target driver for the FCoE protocol.
FCoE or Fibre Channel over Ethernet is a protocol that allows to communicate
fibre channel frames over an Ethernet network. Since the FCoE protocol
requires a lossless Ethernet network, special network adapters and switches
are required. Ethernet network adapters that support FCoE are called
Converged Network Adapters (CNA). The standard that makes lossless Ethernet
communication possible is called DCB or Data Center Bridging.
Since FCoE frames are a kind of Ethernet frames, communication between FCoE
clients and servers is limited to a single Ethernet broadcast domain.
Building and Installing
=======================
FCST is a kernel module that depends on libfc and SCST to provide FC target
support.
To build for linux-2.6.34, do:
1. Get the kernel source:
KERNEL=linux-2.6.34
cd /usr/src/kernels
URL_DIR=http://www.kernel.org/pub/linux/kernel/v2.6
TARFILE=$KERNEL.tar.bz2
wget -o $TARFILE $URL_DIR/$TARFILE
tar xfj $TARFILE
cd $KERNEL
2. Apply patches needed for libfc target hooks and point-to-point fixes:
KDIR=/usr/src/kernels/$KERNEL
PDIR=/usr/src/scst/trunk/fcst/linux-patches # use your dir here
cd $PDIR
for patch in `grep -v '^#' series-2.6.34`
do
(cd $KDIR; patch -p1) < $patch
done
3. Apply SCST patches to the kernel
See trunk/scst/README
The readahead patches are not needed in 2.6.33 or later.
4. Configure, make, and install your kernel
5. Install SCST
See trunk/scst/README. Make sure you are building sysfs SCST build,
because FCST supports only it. You need to do
cd trunk/scst
make
make install
6. Make FCST
In the directory containing this README, just do
make
make install
7. Install the FCoE admin tools, including dcbd and fcoeadm.
Some distros may have these.
You should be able to use the source at
http://www.open-fcoe.org/openfc/downloads/2.6.34/open-fcoe-2.6.34.tar.gz
8. Bring up SCST and configure the devices.
9. Bring up an FCoE initiator (we'll enable target mode on it later):
modprobe fcoe
fcoeadm -c eth3
The other end can be an initiator as well, in point-to-point mode
over a full-duplex loss-less link (enable pause on both sides).
Alternatively, the other end can be an FCoE switch.
10. Use fcc (part of the open-fcoe contrib tools in step 7) to see the
initiator setup. To get the FCoE port name for eth3
# fcc
FC HBAs:
HBA Port Name Port ID State Device
host4 20:00:00:1b:21:06:58:21 01:01:02 Online eth3
host4 Remote Ports:
Path Port Name Port ID State Roles
4:0-0 10:00:50:41:4c:4f:3b:00 01:01:01 Online FCP Initiator
In the above example, there's one local host on eth3, and it's in
a point-to-point connection with the remote initiator with Port_id 010101.
11. Load fcst
modprobe fcst
12. Add any disks (configured in step 8) you want to export
Note that you must have a LUN 0.
LPORT=20:00:00:1b:21:06:58:21 # the local Port_Name
cd /sys/kernel/scst_tgt/targets/fcst/$LPORT
echo add disk-name 0 > luns/mgmt
echo add disk-name 1 > luns/mgmt
13. Enable the initiator:
echo 1 > $LPORT/enabled
14. As a temporary workaround, you may need to reset the interface
on the initiator side so it sees the SCST device as a target and
discovers LUNs. You can avoid this by bringing up the initiator last.