From patchwork Thu Nov 15 14:50:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Lieven X-Patchwork-Id: 199315 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6A2E32C03DA for ; Fri, 16 Nov 2012 01:51:08 +1100 (EST) Received: from localhost ([::1]:41224 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TZ0mY-0001vG-Hm for incoming@patchwork.ozlabs.org; Thu, 15 Nov 2012 09:51:06 -0500 Received: from eggs.gnu.org ([208.118.235.92]:38146) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TZ0mO-0001uI-Q5 for qemu-devel@nongnu.org; Thu, 15 Nov 2012 09:50:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TZ0mL-0007a4-Mz for qemu-devel@nongnu.org; Thu, 15 Nov 2012 09:50:56 -0500 Received: from ssl.dlhnet.de ([91.198.192.8]:42880 helo=ssl.dlh.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TZ0mL-0007Zz-Bn for qemu-devel@nongnu.org; Thu, 15 Nov 2012 09:50:53 -0500 Received: from localhost (localhost [127.0.0.1]) by ssl.dlh.net (Postfix) with ESMTP id 1AB7114CB74; Thu, 15 Nov 2012 15:50:52 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at ssl.dlh.net Received: from ssl.dlh.net ([127.0.0.1]) by localhost (ssl.dlh.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6OqZa+H-oxTo; Thu, 15 Nov 2012 15:50:51 +0100 (CET) Received: from [172.21.12.60] (unknown [82.141.1.226]) by ssl.dlh.net (Postfix) with ESMTPSA id 4651B14BCB4; Thu, 15 Nov 2012 15:50:51 +0100 (CET) Message-ID: <50A50150.8010201@dlhnet.de> Date: Thu, 15 Nov 2012 15:50:56 +0100 From: Peter Lieven User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121028 Thunderbird/16.0.2 MIME-Version: 1.0 To: "qemu-devel@nongnu.org" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 91.198.192.8 Cc: kwolf@redhat.com, ronnie sahlberg Subject: [Qemu-devel] [PATCH] iscsi: fix deadlock during login X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Acked-by: ronniesahlberg@gmail.com --- block/iscsi.c | 56 +++++++++++++++++++++----------------------------------- 1 file changed, 21 insertions(+), 35 deletions(-) { 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; 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)