scsi: Free req and data in scsi_common::exec_inquery

It is not freed after we're done with it.

Signed-off-by: Asias He <asias@cloudius-systems.com>
scsi: Intorduce req->free_by_driver flag

This is used to tell lower-level scsi driver to free the request,
otherwise the scsi layer will free the request.

read/write/flush scsi are async request, they are freed by the
lower-level scsi driver. Other scsi request are freed by the scsi layer.

Signed-off-by: Asias He <asias@cloudius-systems.com>
scsi: Introduce req->cdb_len

Set req->cdb_len to the actual size of the scsi command and only copy
the actual size of the command.

This reduces the number of bytes we copy.

This also fixes the warning in pvscsi which complains the size of the
cdb is larger than expected.

Signed-off-by: Asias He <asias@cloudius-systems.com>
scsi: Construct cdb in-place

Instead of copying a scsi cdb, construct it in-place.
This saves 16 bytes of memory copying on every read or write.

Signed-off-by: Asias He <asias@cloudius-systems.com>
ahci: Add slot parameter to wait_ci_ready

Instead of wait for hardcoded slot 0, add slot parameter.

Signed-off-by: Asias He <asias@cloudius-systems.com>
ahci: Add slot parameter to wait_cmd_poll and wait_cmd_irq

This is a preparation for next patch. We will need the slot number in
wait_cmd_poll and wait_cmd_irq.

Signed-off-by: Asias He <asias@cloudius-systems.com>
ahci: Use cmd_active and PORT_CI to indicate completion of cmd

This simplifies the cmd completion code a bit.

Signed-off-by: Asias He <asias@cloudius-systems.com>
ahci: Do not wait for device and command issue ready

Currently, only one cmd will be pending at most. The device is always
ready when we send the next cmd.

Signed-off-by: Asias He <asias@cloudius-systems.com>
ahci: Do no write PORT_SACT

Writing to PORT_SACT is need for NCQ cmd only.

Signed-off-by: Asias He <asias@cloudius-systems.com>
ahci: Remove commented-out code

This line is useless.

Signed-off-by: Asias He <asias@cloudius-systems.com>
Fix crash in "perf stat memory_malloc"

This patch fixes "perf stat memory_malloc". This used to crash: When the
tracepoint was first reached, we called per_cpu_counter::increment();
If this was the first time this function was called, the lazy symbol
resolution caused program::resolve() to be called, which among other things
allocates memory again - yielding endless recursion.

The fix is to call per_cpu_counter::increment() once, on some silly junk
counter, before setting the tracepoint probe. This will ensure that this
function will have already been resolved by the time it is called in an
actual tracepoint.

Fixes #239.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Merge branch 'ahci.cleanup' of https://github.com/asias/osv

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Update apps/ for tomcat programmatic management

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
sched, x64: save and restore exception stack during reschedule

switch_to() always sets exception pointer in tss to primary exception
stack, so when scheduling happens from an exception nested stack
configuration is lost. Fix it by saving and restoring current exception
stack from tss.

Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
x64: disable interrupts before switching exception stack

Interrupt may happen after exception stack is switched, but before
exception handler returns. If interrupt handler will causes exception
it will overwrite current stack.

Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
x64: enlarge exception stack to 16k

Page fault handler may call into zfs and in some cases this causes
exception stack overflow. Enlarge exception stack to 16k to prevent
overflow.

Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
Merge branch 'flush-fixes' of https://github.com/gleb-cloudius/osv

"This series fixes problems that we see with Glaubers glommer/zfsbuffers
branch. The branch has code that maps read only pages directly from zfs
ARC cache. During heavy testing there are a lot of tlb flushes and page
faults and at some point test fails with stack corruption."

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
apps: update tomcat for Jenkins integration

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
trace: fix prof -h

Currently it fails with:

Traceback (most rTraceback (most recent call last):
  File "scripts/trace.py", line 433, in <module>
    args = parser.parse_args()
...
  File "/usr/lib/python2.7/argparse.py", line 601, in _expand_help
    return self._get_help_string(action) % params
ValueError: incomplete format

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
net: don't close the tcp connection within tcp_do_segment()

tcp_do_segment() has a nasty habit of sometimes closing the tcp connection.
This plays havoc with the locking rules (as updated for net channels), since
tcp_do_segment() is supposed to return with the lock held, yet tcp_close()
will unlock if the connection is disassociated from a socket.

Fix by having tcp_do_segment() not close the connection, and instead indicate
its desire to do so to its caller.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>