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
Speeds up reading from a RAM disk via ib_srpt by about 30%.
Tested with iSCSI-SCST, ib_srpt and scst_local.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
In it:
- Fixed NULLIO, which the original patch breaks
- Changed on all fast paths sBUG_ON() on EXTRACHECKS_BUG_ON()
- Fixed errors path in non_fileio_exec() and fileio_alloc_data_buf().
- Renamed zero_copy_read to just zero_copy.
- Docs and change log updated
- Some cleanups
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4213 d57e44dd-8a1f-0410-8b47-8ef2f437770f
Clarify the qla2x00t how-to where necessary:
- Add instructions to unload the upstream qla2xxx kernel module
before starting to build the SCST qla2xxx kernel modules.
- Change the name qla2xxx into qla2xxx_scst in the step for
loading kernel modules.
- Replace the instructions for removing the distro-provided qla2xxx kernel
module by instructions for blacklisting that module and rebuilding the
initial RAM disk.
- Prepend all commands that have to be executed by the user by a prompt.
- Add instructions for RHEL / SUSE next to Debian.
- Shortened Debian kernel development package list.
Markup changes:
- Use a CSS style attribute to specify the distance between steps instead of
using <br><br><br>.
- Add a missing </li> tag.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4209 d57e44dd-8a1f-0410-8b47-8ef2f437770f
Fix three occurrences of the following warnings reported by the checkpatch
script included with Linux kernel version 3.3:
WARNING: min() should probably be min_t()
WARNING: max() should probably be max_t()
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4172 d57e44dd-8a1f-0410-8b47-8ef2f437770f
QLE2560 and QLE2562, the OS is RHEL6.0 with kernel linux-2.6.32,
scst code version from svn is 3952.
As T2 (SPARC64) is big-endian, which may not be tested sufficently,
we had to fix some endian swap to make qla2x00t work good on it.
The first fix is in q24_build_ctio_pkt(), loop_id from prm->cmd, which
was generated by CPU, should be converted to little-endian when wrapped
in pkt, which will be used by HBA ASIC.
The second fix in qla2x_tgt_def.h, reorder the bit-order of structs'
member, is an attempt in despair, cannot explain why, but it just works!
Besides the programming skills, we cannot get QLogic FC HBA databook,
and have little acknowledge about the driver, the fixes may need to
be refined, so don't hold the comments :)
Signed-off-by: Linwen Deng <linwendeng@gmail.com>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@3958 d57e44dd-8a1f-0410-8b47-8ef2f437770f
__attribute__((aligned(x))) into __aligned(x) in kernel code since
checkpatch complains about the former.
BSD-signed-off-by: Bart Van Assche <bvanassche@acm.org>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@3952 d57e44dd-8a1f-0410-8b47-8ef2f437770f
As Mikko Kortelainen <kordex@gmail.com> explained on the SCST IRC
channel, it's not necessary to replace the qla2xxx directory in the
kernel source tree in order to build the SCST qla2x00t target driver.
Also, if neither SCSI pass-through nor iSCSI will be used rebuilding
the kernel tree can be skipped entirely. The patch below updates the
qla2x00t howto accordingly, and also implements the following changes:
- Fix everything the W3C HTML validator complains about:
- Add DOCTYPE declaration.
- Add charset declaration.
- Change </br> into <br> since </br> is invalid.
- Change one occurrence of & into &.
- Use proper HTML constructs for numbered and unnumbered enumerations.
- Use a fixed-sized font and the brown color for all computer output
text (via inline CSS).
- Use hyperlinks to refer to other steps.
- Fix spelling errors.
- Merge the Debian and non-Debian howto's because the differences are
so small that it's not justified to maintain two different documents.
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@3936 d57e44dd-8a1f-0410-8b47-8ef2f437770f