From: Ronnie Sahlberg <ronniesahlberg@gmail.com>
To: qemu-devel@nongnu.org
Cc: stefanha@gmail.com, 1191606@bugs.launchpad.net,
lersek@redhat.com, Ronnie Sahlberg <ronniesahlberg@gmail.com>
Subject: [Qemu-devel] [PATCH] Fix iSCSI crash on SG_IO with an iovector
Date: Thu, 20 Jun 2013 19:32:35 -0700 [thread overview]
Message-ID: <1371781955-2745-2-git-send-email-ronniesahlberg@gmail.com> (raw)
In-Reply-To: <1371781955-2745-1-git-send-email-ronniesahlberg@gmail.com>
Don't assume that SG_IO is always invoked with a simple buffer,
check the iovec_count and if it is > 1 then we need to pass an array
of iovectors to libiscsi instead of just a plain buffer.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
---
block/iscsi.c | 31 ++++++++++++++++++++++++-------
1 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/block/iscsi.c b/block/iscsi.c
index 0bbf0b1..2d1cb4e 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -727,25 +727,42 @@ static BlockDriverAIOCB *iscsi_aio_ioctl(BlockDriverState *bs,
memcpy(&acb->task->cdb[0], acb->ioh->cmdp, acb->ioh->cmd_len);
acb->task->expxferlen = acb->ioh->dxfer_len;
+ data.size = 0;
if (acb->task->xfer_dir == SCSI_XFER_WRITE) {
- data.data = acb->ioh->dxferp;
- data.size = acb->ioh->dxfer_len;
+ if (acb->ioh->iovec_count == 0) {
+ data.data = acb->ioh->dxferp;
+ data.size = acb->ioh->dxfer_len;
+ }
}
if (iscsi_scsi_command_async(iscsi, iscsilun->lun, acb->task,
iscsi_aio_ioctl_cb,
- (acb->task->xfer_dir == SCSI_XFER_WRITE) ?
- &data : NULL,
+ (data.size > 0) ? &data : NULL,
acb) != 0) {
scsi_free_scsi_task(acb->task);
qemu_aio_release(acb);
return NULL;
}
+ /* We got an iovector for writing to the target */
+ if (acb->task->xfer_dir == SCSI_XFER_WRITE) {
+ if (acb->ioh->iovec_count > 0) {
+ scsi_task_set_iov_out(acb->task,
+ (struct scsi_iovec *) acb->ioh->dxferp,
+ acb->ioh->iovec_count);
+ }
+ }
+
/* tell libiscsi to read straight into the buffer we got from ioctl */
if (acb->task->xfer_dir == SCSI_XFER_READ) {
- scsi_task_add_data_in_buffer(acb->task,
- acb->ioh->dxfer_len,
- acb->ioh->dxferp);
+ if (acb->ioh->iovec_count == 0) {
+ scsi_task_add_data_in_buffer(acb->task,
+ acb->ioh->dxfer_len,
+ acb->ioh->dxferp);
+ } else {
+ scsi_task_set_iov_in(acb->task,
+ (struct scsi_iovec *) acb->ioh->dxferp,
+ acb->ioh->iovec_count);
+ }
}
iscsi_set_events(iscsilun);
--
1.7.3.1
next prev parent reply other threads:[~2013-06-21 2:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-21 2:32 [Qemu-devel] [PATCH] iSCSI fix crash when using virtio and libiscsi Ronnie Sahlberg
2013-06-21 2:32 ` Ronnie Sahlberg [this message]
2013-06-21 7:38 ` Paolo Bonzini
2013-06-21 13:51 ` ronnie sahlberg
-- strict thread matches above, loose matches on Subject: below --
2013-06-22 1:37 [Qemu-devel] [PATCH] iSCSI fix crash when using virtio and libiscsi V2 Ronnie Sahlberg
2013-06-22 1:37 ` [Qemu-devel] [PATCH] Fix iSCSI crash on SG_IO with an iovector Ronnie Sahlberg
2013-06-23 10:01 ` Laszlo Ersek
2013-06-25 9:21 ` Stefan Hajnoczi
2013-06-23 15:07 [Qemu-devel] [PATCH] iSCSI fix crash when using virtio and libiscsi V3 Ronnie Sahlberg
2013-06-23 15:07 ` [Qemu-devel] [PATCH] Fix iSCSI crash on SG_IO with an iovector Ronnie Sahlberg
2013-06-23 15:23 ` Laszlo Ersek
2013-06-24 14:40 ` Paolo Bonzini
2013-06-25 9:24 ` Stefan Hajnoczi
2013-06-25 10:42 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1371781955-2745-2-git-send-email-ronniesahlberg@gmail.com \
--to=ronniesahlberg@gmail.com \
--cc=1191606@bugs.launchpad.net \
--cc=lersek@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).