The "force_close" sysfs attribute remains to exist for some time
after q2t_close_session() finished. Avoid that q2t_close_session()
invokes q2t_sess_put() more than once by removing a session from
the session list before returning. Avoid that that disabling a
target after q2t_close_session() has been invoked triggers a call
of q2t_sess_put(). Avoid that triggering the "force_close" sysfs
attribute after a target has been disabled triggers an additional
call of q2t_sess_put().
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4944 d57e44dd-8a1f-0410-8b47-8ef2f437770f
HARDWARE ERROR sense is very strong considered be "internal failure", so
might lead to serios initiator side issues up to disconnect from device. In
many cases WRITE or READ ERROR sense can be used instead. All remaining
usages must be logged.
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4911 d57e44dd-8a1f-0410-8b47-8ef2f437770f
That patch contains the following changes:
* Move the code for creating a "close_sess" sysfs attribute from iscsi-scst to
the SCST core such that it becomes available for other target drivers. This
does not change the functionality of iscsi-scst.
* Add code in ib_srpt and qla2x00t to allow a session to be forcibly closed from
user space.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4852 d57e44dd-8a1f-0410-8b47-8ef2f437770f
Currently the install location of SCST is pretty much hard coded into
the Makefiles to be /usr/local.
I am custom building a system for ZFS & SCST and I want to install in
/usr instead of /usr/local.
Currently I am doing a “find . -name Makefile -exec sed -i 's:/usr/local:/usr:g'
{} \;” to accommodate this.
This patch fixes it.
From Sietse van Zanen <sietse@wizdom.nu>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4791 d57e44dd-8a1f-0410-8b47-8ef2f437770f
The expression "sg_dma_address(prm->sg)" occurs several times in several
pieces of code that compute a DMA address. Make these pieces of code
somewhat easier to read by storing the DMA address in a temporary variable
called "dma_addr".
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4778 d57e44dd-8a1f-0410-8b47-8ef2f437770f
It is cumbersome to change SCST_INC_DIR and SCST_DIR in each Makefile
before and after a release. Hence modify the Makefiles such that these
paths are detected automatically.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4740 d57e44dd-8a1f-0410-8b47-8ef2f437770f
Smatch reports two warnings on the qla2x00t code:
* sess->local being tested while sess can be NULL.
* The code after the out_unreg_target2x label is only necessary in the procfs build.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4486 d57e44dd-8a1f-0410-8b47-8ef2f437770f
The symptom of the crash is that one finds the system deadlocked
spinning on scsi_qla_host_t.hardware_lock in qla2x00_enable_tgt_mode
with a stack something like this:
crash> bt
PID: 6155 TASK: ffff88006e4bc3c0 CPU: 1 COMMAND: "scst_uid"
#0 [ffff88007b915b28] machine_kexec at ffffffff8103163b
#1 [ffff88007b915b88] crash_kexec at ffffffff810b8e52
#2 [ffff88007b915c58] panic at ffffffff814ed0ab
#3 [ffff88007b915cd8] spin_bug at ffffffff8127cd46
#4 [ffff88007b915d18] _raw_spin_lock at ffffffff8127d015
#5 [ffff88007b915d68] _spin_lock_irqsave at ffffffff814f02e4
#6 [ffff88007b915d88] qla2x00_enable_tgt_mode at ffffffffa047b672 [qla2xxx]
#7 [ffff88007b915db8] q2t_host_action at ffffffffa06db6a6 [qla2x00tgt]
#8 [ffff88007b915df8] q2t_enable_tgt at ffffffffa06db6ea [qla2x00tgt]
#9 [ffff88007b915e18] scst_process_tgt_enable_store at ffffffffa04f102e [scst]
#10 [ffff88007b915e48] scst_tgt_enable_store_work_fn at ffffffffa04f1176 [scst]
#11 [ffff88007b915e58] scst_process_sysfs_works at ffffffffa04e8bbe [scst]
#12 [ffff88007b915e78] sysfs_work_thread_fn at ffffffffa04e8db5 [scst]
#13 [ffff88007b915ed8] kthread at ffffffff8108f976
#14 [ffff88007b915f48] kernel_thread at ffffffff8100c20a
I was pulling my hair out on this one, because with the spinlock
debugging (enhanced to capture the PID along with the task pointer), I
figured out that the task (and process) that originally locked the lock
was gone! It got really confusing when I added more spinlock debug code
to the kernel to detect locks held in the task switching and
task/process termination paths -- and didn't catch anything terminating
with locks held!
I finally tracked the problem down to two things:
1. When qla24xx_create_vhost creates a new virtual scsi_qla_host_t it
does it by copying the physical (aka parent) scsi_qla_host_t. Under the
right unlucky conditions, this can happen with the hardware_lock held
(the spinlock is embedded in the structure).
2. The code should only be locking the hardware_lock of the physical
scsi_qla_host_t, because the lock is associated with the hardware.
Unfortunately, quite a few places are not using to_qla_parent to make
sure they lock the correct lock. One of those places is
qla2x00_enable_tgt_mode. Along with the deadlock, this has the
potential to leave the hardware and driver structures in unpredictable
states, because the lock isn't always providing serialization.
The fix entails two things:
1. Zeroing the lock after copying the scsi_qla_host_t structure: This
won't stop the deadlock, but will enable the spinlock debug code to
easily catch anything that misbehaves and locks the wrong lock. I also
initialized the other locks because they could have the same problem. I
also initialized the list heads, because they could end up holding
dangling references. I did not initialize all pointers, because there
are quite a few that point to read only data and are OK (and I didn't
have time to research all of them).
2. Using to_qla_parent everywhere when locking and the scsi_qla_host_t
structure might be virtual. This is a lot of changes, but they are the
same thing over and over again.
I did not make an effort to look for scalar or pointer fields that are
being picked from the wrong structure. That's getting to be as much
pain as merging up to the latest QLogic driver (which would have gotten
rid of this problem).
From "Robinson, Herbie" <Herbie.Robinson@stratus.com>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4420 d57e44dd-8a1f-0410-8b47-8ef2f437770f
The attached patch fixes compilation warnings for the qla2x00t driver
when compiled by RHEL 6.1, kernel version 2.6.32-131.0.15.el6. I
believe this is the second kernel version for RHEL 6.1.
From "Robinson, Herbie" <Herbie.Robinson@stratus.com>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4419 d57e44dd-8a1f-0410-8b47-8ef2f437770f
The fix for the locking bug I found in q2t_pre_xmit_response has already
been added, but I had some comments in my copy that couldn't hurt.
From "Robinson, Herbie" <Herbie.Robinson@stratus.com>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4418 d57e44dd-8a1f-0410-8b47-8ef2f437770f