qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Lieven <pl@dlhnet.de>
To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: kwolf@redhat.com, ronnie sahlberg <ronniesahlberg@gmail.com>
Subject: [Qemu-devel] [PATCH] iscsi: fix deadlock during login
Date: Thu, 15 Nov 2012 15:50:56 +0100	[thread overview]
Message-ID: <50A50150.8010201@dlhnet.de> (raw)

If the connection is interrupted before the first login is successfully
completed qemu-kvm is waiting forever in qemu_aio_wait().

This is fixed by performing an sync login to the target. If the
connection breaks after the first successful login errors are
handled internally by libiscsi.

Signed-off-by: Peter Lieven <pl@kamp.de>
---
  block/iscsi.c |   56 
+++++++++++++++++++++-----------------------------------
  1 file changed, 21 insertions(+), 35 deletions(-)

diff --git a/block/iscsi.c b/block/iscsi.c
index b5c3161..f44bb57 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -798,30 +798,6 @@ iscsi_inquiry_cb(struct iscsi_context *iscsi, int 
status, void *command_data,
      }
  }

-static void
-iscsi_connect_cb(struct iscsi_context *iscsi, int status, void 
*command_data,
-                 void *opaque)
-{
-    struct IscsiTask *itask = opaque;
-    struct scsi_task *task;
-
-    if (status != 0) {
-        itask->status   = 1;
-        itask->complete = 1;
-        return;
-    }
-
-    task = iscsi_inquiry_task(iscsi, itask->iscsilun->lun,
-                              0, 0, 36,
-                              iscsi_inquiry_cb, opaque);
-    if (task == NULL) {
-        error_report("iSCSI: failed to send inquiry command.");
-        itask->status   = 1;
-        itask->complete = 1;
-        return;
-    }
-}
-
  static int parse_chap(struct iscsi_context *iscsi, const char *target)
  {
      QemuOptsList *list;
@@ -934,7 +910,8 @@ static int iscsi_open(BlockDriverState *bs, const 
char *filename, int flags)
      IscsiLun *iscsilun = bs->opaque;
      struct iscsi_context *iscsi = NULL;
      struct iscsi_url *iscsi_url = NULL;
-    struct IscsiTask task;
+    struct IscsiTask itask;
+    struct scsi_task *task;
      char *initiator_name = NULL;
      int ret;

@@ -997,27 +974,36 @@ static int iscsi_open(BlockDriverState *bs, const 
char *filename, int flags)
      /* check if we got HEADER_DIGEST via the options */
      parse_header_digest(iscsi, iscsi_url->target);

-    task.iscsilun = iscsilun;
-    task.status = 0;
-    task.complete = 0;
-    task.bs = bs;
+    if (iscsi_full_connect_sync(iscsi, iscsi_url->portal, 
iscsi_url->lun) != 0) {
+        error_report("iSCSI: Failed to connect to LUN : %s",
+            iscsi_get_error(iscsi));
+        ret = -EINVAL;
+        goto out;
+    }
+
+    itask.iscsilun = iscsilun;
+    itask.status = 0;
+    itask.complete = 0;
+    itask.bs = bs;

      iscsilun->iscsi = iscsi;
      iscsilun->lun   = iscsi_url->lun;

-    if (iscsi_full_connect_async(iscsi, iscsi_url->portal, iscsi_url->lun,
-                                 iscsi_connect_cb, &task)
-        != 0) {
-        error_report("iSCSI: Failed to start async connect.");
+    task = iscsi_inquiry_task(iscsi, iscsilun->lun,
+                              0, 0, 36,
+                              iscsi_inquiry_cb, &itask);
+    if (task == NULL) {
+        error_report("iSCSI: failed to send inquiry command.");
          ret = -EINVAL;
          goto out;
      }

-    while (!task.complete) {
+    while (!itask.complete) {
          iscsi_set_events(iscsilun);
          qemu_aio_wait();
      }
-    if (task.status != 0) {
+
+    if (itask.status != 0) {
          error_report("iSCSI: Failed to connect to LUN : %s",
                       iscsi_get_error(iscsi));
          ret = -EINVAL;
-- 
1.7.9.5

             reply	other threads:[~2012-11-15 14:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-15 14:50 Peter Lieven [this message]
2012-11-15 14:57 ` [Qemu-devel] [PATCH] iscsi: fix deadlock during login ronnie sahlberg
2012-11-15 15:05   ` Peter Lieven
2012-11-15 15:54   ` Paolo Bonzini
2012-11-15 16:11     ` Peter Lieven
2012-11-15 16:13     ` ronnie sahlberg
2012-11-15 16:37       ` Paolo Bonzini
2012-11-16 10:38         ` Kevin Wolf
2012-11-16 17:38           ` Peter Lieven
2012-11-16 17:55             ` Paolo Bonzini
2012-11-15 18:28     ` Peter Lieven
2012-11-16  7:44       ` Paolo Bonzini
2012-11-16  9:26         ` Peter Lieven

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=50A50150.8010201@dlhnet.de \
    --to=pl@dlhnet.de \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=ronniesahlberg@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).