From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36328) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UteRZ-0006Ql-Kp for qemu-devel@nongnu.org; Mon, 01 Jul 2013 09:47:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UteRS-0002LD-Ib for qemu-devel@nongnu.org; Mon, 01 Jul 2013 09:47:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40897) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UteRS-0002Kv-AA for qemu-devel@nongnu.org; Mon, 01 Jul 2013 09:46:54 -0400 Date: Mon, 1 Jul 2013 15:46:15 +0200 From: Stefan Hajnoczi Message-ID: <20130701134614.GC20182@stefanha-thinkpad.redhat.com> References: <1372338695-411-1-git-send-email-pl@kamp.de> <1372338695-411-4-git-send-email-pl@kamp.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1372338695-411-4-git-send-email-pl@kamp.de> Subject: Re: [Qemu-devel] [PATCHv2 03/11] iscsi: add bdrv_co_is_allocated List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Lieven Cc: kwolf@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org, ronniesahlberg@gmail.com On Thu, Jun 27, 2013 at 03:11:27PM +0200, Peter Lieven wrote: > @@ -113,6 +122,45 @@ iscsi_schedule_bh(IscsiAIOCB *acb) > qemu_bh_schedule(acb->bh); > } > > +static void > +iscsi_co_generic_cb(struct iscsi_context *iscsi, int status, > + void *command_data, void *opaque) > +{ > + struct IscsiTask *iTask = opaque; > + struct scsi_task *task = command_data; > + > + iTask->complete = 1; > + iTask->status = status; > + iTask->do_retry = 0; > + iTask->task = task; > + > + if (iTask->retries-- > 0 && status == SCSI_STATUS_CHECK_CONDITION > + && task->sense.key == SCSI_SENSE_UNIT_ATTENTION) { > + iTask->do_retry = 1; > + goto out; > + } > + > + if (status != SCSI_STATUS_GOOD) { > + error_report("iSCSI: Failure. %s", iscsi_get_error(iscsi)); > + goto out; > + } > + > +out: > + if (iTask->status != SCSI_STATUS_GOOD) { > + scsi_free_scsi_task(iTask->task); > + iTask->task = NULL; > + } Not sure about freeing the task here since the caller is still responsible for freeing the task in the success case and higher-level error cases. I suggest keeping iTask->task alive here so the caller is easier to maintain (it can use a single out/error path).