* [Qemu-devel] [PATCH] block/iscsi: cancel libiscsi task when ABORT TASK TMF completes
@ 2018-02-15 11:15 Stefan Hajnoczi
2018-02-15 14:24 ` Peter Lieven
0 siblings, 1 reply; 5+ messages in thread
From: Stefan Hajnoczi @ 2018-02-15 11:15 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Lieven, Paolo Bonzini, Ronnie Sahlberg, Felipe Franciosi,
Stefan Hajnoczi
The libiscsi iscsi_task_mgmt_async() API documentation says:
abort_task will also cancel the scsi task. The callback for the scsi
task will be invoked with SCSI_STATUS_CANCELLED
The libiscsi implementation does not fulfil this promise. The task's
callback is not invoked and its struct iscsi_pdu remains in the internal
list (effectively leaked).
This patch invokes the libiscsi iscsi_scsi_cancel_task() API to force
the task's callback to be invoked with SCSI_STATUS_CANCELLED when the
ABORT TASK TMF completes and the task's callback hasn't been invoked
yet.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block/iscsi.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/block/iscsi.c b/block/iscsi.c
index 41e67cb371..4cb188ac2b 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -292,8 +292,12 @@ iscsi_abort_task_cb(struct iscsi_context *iscsi, int status, void *command_data,
{
IscsiAIOCB *acb = private_data;
- acb->status = -ECANCELED;
- iscsi_schedule_bh(acb);
+ /* If the command callback hasn't been called yet, drop the task */
+ if (!acb->bh) {
+ /* Call iscsi_aio_ioctl_cb() with SCSI_STATUS_CANCELLED */
+ iscsi_scsi_cancel_task(iscsi, acb->task);
+ }
+
qemu_aio_unref(acb); /* acquired in iscsi_aio_cancel() */
}
@@ -941,6 +945,14 @@ iscsi_aio_ioctl_cb(struct iscsi_context *iscsi, int status,
{
IscsiAIOCB *acb = opaque;
+ if (status == SCSI_STATUS_CANCELLED) {
+ if (!acb->bh) {
+ acb->status = -ECANCELED;
+ iscsi_schedule_bh(acb);
+ }
+ return;
+ }
+
acb->status = 0;
if (status < 0) {
error_report("Failed to ioctl(SG_IO) to iSCSI lun. %s",
--
2.14.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] block/iscsi: cancel libiscsi task when ABORT TASK TMF completes
2018-02-15 11:15 [Qemu-devel] [PATCH] block/iscsi: cancel libiscsi task when ABORT TASK TMF completes Stefan Hajnoczi
@ 2018-02-15 14:24 ` Peter Lieven
2018-02-15 17:27 ` Stefan Hajnoczi
0 siblings, 1 reply; 5+ messages in thread
From: Peter Lieven @ 2018-02-15 14:24 UTC (permalink / raw)
To: Stefan Hajnoczi, qemu-devel
Cc: Paolo Bonzini, Ronnie Sahlberg, Felipe Franciosi
Am 15.02.2018 um 12:15 schrieb Stefan Hajnoczi:
> The libiscsi iscsi_task_mgmt_async() API documentation says:
>
> abort_task will also cancel the scsi task. The callback for the scsi
> task will be invoked with SCSI_STATUS_CANCELLED
>
> The libiscsi implementation does not fulfil this promise. The task's
> callback is not invoked and its struct iscsi_pdu remains in the internal
> list (effectively leaked).
If that contract is fixed in libiscsi, will the Qemu iSCSI driver still work?
Peter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] block/iscsi: cancel libiscsi task when ABORT TASK TMF completes
2018-02-15 14:24 ` Peter Lieven
@ 2018-02-15 17:27 ` Stefan Hajnoczi
2018-02-20 15:12 ` Peter Lieven
0 siblings, 1 reply; 5+ messages in thread
From: Stefan Hajnoczi @ 2018-02-15 17:27 UTC (permalink / raw)
To: Peter Lieven; +Cc: qemu-devel, Paolo Bonzini, Ronnie Sahlberg, Felipe Franciosi
[-- Attachment #1: Type: text/plain, Size: 920 bytes --]
On Thu, Feb 15, 2018 at 03:24:54PM +0100, Peter Lieven wrote:
> Am 15.02.2018 um 12:15 schrieb Stefan Hajnoczi:
> > The libiscsi iscsi_task_mgmt_async() API documentation says:
> >
> > abort_task will also cancel the scsi task. The callback for the scsi
> > task will be invoked with SCSI_STATUS_CANCELLED
> >
> > The libiscsi implementation does not fulfil this promise. The task's
> > callback is not invoked and its struct iscsi_pdu remains in the internal
> > list (effectively leaked).
>
> If that contract is fixed in libiscsi, will the Qemu iSCSI driver still work?
In
+ /* If the command callback hasn't been called yet, drop the task */
+ if (!acb->bh) {
and
+ if (status == SCSI_STATUS_CANCELLED) {
+ if (!acb->bh) {
we're mindful of the fact that the callback may have been invoked by
libiscsi already. There is no risk of double-completion.
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] block/iscsi: cancel libiscsi task when ABORT TASK TMF completes
2018-02-15 17:27 ` Stefan Hajnoczi
@ 2018-02-20 15:12 ` Peter Lieven
2018-02-20 17:59 ` Stefan Hajnoczi
0 siblings, 1 reply; 5+ messages in thread
From: Peter Lieven @ 2018-02-20 15:12 UTC (permalink / raw)
To: Stefan Hajnoczi
Cc: qemu-devel, Paolo Bonzini, Ronnie Sahlberg, Felipe Franciosi
Am 15.02.2018 um 18:27 schrieb Stefan Hajnoczi:
> On Thu, Feb 15, 2018 at 03:24:54PM +0100, Peter Lieven wrote:
>> Am 15.02.2018 um 12:15 schrieb Stefan Hajnoczi:
>>> The libiscsi iscsi_task_mgmt_async() API documentation says:
>>>
>>> abort_task will also cancel the scsi task. The callback for the scsi
>>> task will be invoked with SCSI_STATUS_CANCELLED
>>>
>>> The libiscsi implementation does not fulfil this promise. The task's
>>> callback is not invoked and its struct iscsi_pdu remains in the internal
>>> list (effectively leaked).
>> If that contract is fixed in libiscsi, will the Qemu iSCSI driver still work?
> In
>
> + /* If the command callback hasn't been called yet, drop the task */
> + if (!acb->bh) {
>
> and
>
> + if (status == SCSI_STATUS_CANCELLED) {
> + if (!acb->bh) {
>
> we're mindful of the fact that the callback may have been invoked by
> libiscsi already. There is no risk of double-completion.
Hi Stefan,
thanks for the clarification. I am fine with this change. I will check with Ronnie for the
libiscsi fix.
Peter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] block/iscsi: cancel libiscsi task when ABORT TASK TMF completes
2018-02-20 15:12 ` Peter Lieven
@ 2018-02-20 17:59 ` Stefan Hajnoczi
0 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2018-02-20 17:59 UTC (permalink / raw)
To: Peter Lieven
Cc: Stefan Hajnoczi, Paolo Bonzini, qemu-devel, Ronnie Sahlberg,
Felipe Franciosi
On Tue, Feb 20, 2018 at 3:12 PM, Peter Lieven <pl@kamp.de> wrote:
> Am 15.02.2018 um 18:27 schrieb Stefan Hajnoczi:
>>
>> On Thu, Feb 15, 2018 at 03:24:54PM +0100, Peter Lieven wrote:
>>>
>>> Am 15.02.2018 um 12:15 schrieb Stefan Hajnoczi:
>>>>
>>>> The libiscsi iscsi_task_mgmt_async() API documentation says:
>>>>
>>>> abort_task will also cancel the scsi task. The callback for the scsi
>>>> task will be invoked with SCSI_STATUS_CANCELLED
>>>>
>>>> The libiscsi implementation does not fulfil this promise. The task's
>>>> callback is not invoked and its struct iscsi_pdu remains in the internal
>>>> list (effectively leaked).
>>>
>>> If that contract is fixed in libiscsi, will the Qemu iSCSI driver still
>>> work?
>>
>> In
>>
>> + /* If the command callback hasn't been called yet, drop the task */
>> + if (!acb->bh) {
>>
>> and
>>
>> + if (status == SCSI_STATUS_CANCELLED) {
>> + if (!acb->bh) {
>>
>> we're mindful of the fact that the callback may have been invoked by
>> libiscsi already. There is no risk of double-completion.
>
>
> Hi Stefan,
>
> thanks for the clarification. I am fine with this change. I will check with
> Ronnie for the
> libiscsi fix.
Great, then this patch can go via Paolo's SCSI tree.
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-02-20 17:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-15 11:15 [Qemu-devel] [PATCH] block/iscsi: cancel libiscsi task when ABORT TASK TMF completes Stefan Hajnoczi
2018-02-15 14:24 ` Peter Lieven
2018-02-15 17:27 ` Stefan Hajnoczi
2018-02-20 15:12 ` Peter Lieven
2018-02-20 17:59 ` Stefan Hajnoczi
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).