Changeset 4224 introduced EXTRACHECKS for valid lba/data_len and state
at the end of the parsing phase of command processing.
However, the checks do not account for deferral of parsing to userland,
as occurs when SCST_USER_PARSE_CALL or SCST_USER_PARSE_EXCEPTION are specified.
In such cases the checks report errors on commands that userland has not yet
had an opportunity to parse.
NOTE: this includes a refactoring of the EXTRACHECKS to improve clarity.
The rework is not exactly equivalent to the original code, but does
conform to the comments describing the original code.
Specifically, the original code would not trap an illegal command state
unless there was also an illegal lba or data_len.
Signed-off-by: Steven J. Magnani <steve@digidescorp.com>
with some improvements
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5275 d57e44dd-8a1f-0410-8b47-8ef2f437770f
The sgv_purge_interval from userland is passed down without conversion to
jiffies. Yet, if it is zero, the default value is (60 * HZ).
Convert to jiffies before passing down.
Signed-off-by: Steven J. Magnani <steve@digidescorp.com>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5274 d57e44dd-8a1f-0410-8b47-8ef2f437770f
add_to_page_cache_lru and __lock_page_killable are exported since
kernel version 2.6.30. See also patch "Staging: pohmelfs: kconfig/makefile
and vfs changes" (commit 18bc0bbd162e3eb3e7ea2953c315ad4113a57164;
included in kernel v2.6.30).
Signed-off-by: Sebastian Herbszt <herbszt@gmx.de>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5273 d57e44dd-8a1f-0410-8b47-8ef2f437770f
In a fully-preemptible realtime kernel (CONFIG_PREEMPT_RT_FULL=y),
SCSI commands from an initiator time out because the userland target
application is never woken to process them.
This is because in a fully-preemptible realtime kernel, soft-IRQ
(tasklet) execution always occurs in a ksoftirqd thread and
preempt_count is not manipulated on soft-IRQ processing entry/exit.
This makes in_interrupt() useless for determining whether soft-IRQ
processing is occurring; instead, in_serving_softirq() should be
used for that purpose.
Signed-off-by: Steven J. Magnani <steve@digidescorp.com>
[bvanassche: Elaborated source code comment]
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5272 d57e44dd-8a1f-0410-8b47-8ef2f437770f
The sysfs API is supported from kernel 2.6.26 on and uses the swap()
macro while the swap() macro was introduced in kernel 2.6.29. Hence
provide a definition of the swap() macro for kernels before 2.6.29.
Signed-off-by: Sebastian Herbszt <herbszt@gmx.de>
[bvanassche: Moved swap() definition a few lines down and added #ifndef/#endif]
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5269 d57e44dd-8a1f-0410-8b47-8ef2f437770f
Avoid that disabling a target triggers a race condition with
SRP relogin. At least in theory this race condition could result
in a kernel crash.
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5268 d57e44dd-8a1f-0410-8b47-8ef2f437770f
Coverity warns that sgv may be used uninitialized. The warning
applies to WRITE SAME commands with LBDATA == PBDATA == 0 (replicate
a single block of user data into the specified LBA range).
The warning appears to be spurious - when LBDATA == PBDATA == 0,
scst_ws_write_cmd_finished() will not use the uninitialized value
saved by scst_ws_push_single_write().
Move initialization of sgv earlier in the function to quiesce the warning.
Signed-off-by: Steven J. Magnani <steve@digidescorp.com>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5266 d57e44dd-8a1f-0410-8b47-8ef2f437770f
Avoid that scst_local triggers "BUG: unable to handle kernel NULL
pointer dereference" on kernel versions before 2.6.37. This patch
fixes a regression introduced via patch "scst_local: Avoid
deadlock during module removal with kernel 3.6" (trunk r4566).
Reported-by: Sebastian Herbszt <herbszt@gmx.de>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5264 d57e44dd-8a1f-0410-8b47-8ef2f437770f
Since the time during which a PR read or write lock is held is short,
use a mutex to implement PR read and write locking. So although this
patch excludes multiple simultaneous readers that shouldn't affect the
time needed to process a PR operation measurably.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5254 d57e44dd-8a1f-0410-8b47-8ef2f437770f
Although it is possible to obtain these statistics by iterating over
all sessions and by computing the sum of the per-target statistics,
make per-target statistics directly available such that these can be
retrieved easily.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5249 d57e44dd-8a1f-0410-8b47-8ef2f437770f
Avoid that sparse reports the following warning:
warning: 'prot_usage' may be used uninitialized in this function
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5227 d57e44dd-8a1f-0410-8b47-8ef2f437770f
The libfc implementation can handle long SG lists, hence increase
ft_scst_template.sg_tablesize from 128 to 65535.
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5223 d57e44dd-8a1f-0410-8b47-8ef2f437770f
Kernel versions before 2.6.26 do not have a definition for the
ACCESS_ONCE() macro, hence provide one.
Signed-off-by: Sebastian Herbszt <herbszt@gmx.de>
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5220 d57e44dd-8a1f-0410-8b47-8ef2f437770f
Reduce the number of reservation state variables from (one per
device + one per session) to one per device. Introduce helper
functions for manipulating the SPC-2 reservation state.
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5218 d57e44dd-8a1f-0410-8b47-8ef2f437770f