Patchwork [01/39] scsi: keep device alive while it has requests

login
register
mail settings
Submitter Paolo Bonzini
Date June 4, 2013, 6:51 p.m.
Message ID <1370371954-8479-2-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/248804/
State New
Headers show

Comments

Paolo Bonzini - June 4, 2013, 6:51 p.m.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/scsi/scsi-bus.c | 4 ++++
 1 file changed, 4 insertions(+)
Andreas Färber - June 7, 2013, 7:48 a.m.
Am 04.06.2013 20:51, schrieb Paolo Bonzini:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  hw/scsi/scsi-bus.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
> index 53ea906..e443193 100644
> --- a/hw/scsi/scsi-bus.c
> +++ b/hw/scsi/scsi-bus.c
> @@ -516,6 +516,8 @@ SCSIRequest *scsi_req_alloc(const SCSIReqOps *reqops, SCSIDevice *d,
>      req->status = -1;
>      req->sense_len = 0;
>      req->ops = reqops;
> +    object_ref(OBJECT(d));
> +    object_ref(OBJECT(req->bus->qbus.parent));

BusState *bus = BUS(req->bus);
...
object_ref(OBJECT(bus->parent));

Same below.

Andreas

>      trace_scsi_req_alloc(req->dev->id, req->lun, req->tag);
>      return req;
>  }
> @@ -1505,6 +1507,8 @@ void scsi_req_unref(SCSIRequest *req)
>          if (req->ops->free_req) {
>              req->ops->free_req(req);
>          }
> +        object_unref(OBJECT(req->dev));
> +        object_unref(OBJECT(bus->qbus.parent));
>          g_free(req);
>      }
>  }
>
Anthony Liguori - June 7, 2013, 2:01 p.m.
Andreas Färber <afaerber@suse.de> writes:

> Am 04.06.2013 20:51, schrieb Paolo Bonzini:
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>>  hw/scsi/scsi-bus.c | 4 ++++
>>  1 file changed, 4 insertions(+)
>> 
>> diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
>> index 53ea906..e443193 100644
>> --- a/hw/scsi/scsi-bus.c
>> +++ b/hw/scsi/scsi-bus.c
>> @@ -516,6 +516,8 @@ SCSIRequest *scsi_req_alloc(const SCSIReqOps *reqops, SCSIDevice *d,
>>      req->status = -1;
>>      req->sense_len = 0;
>>      req->ops = reqops;
>> +    object_ref(OBJECT(d));
>> +    object_ref(OBJECT(req->bus->qbus.parent));
>
> BusState *bus = BUS(req->bus);
> ...
> object_ref(OBJECT(bus->parent));
>
> Same below.

If Paolo has to respin, ack.  But for both ways:

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

Regards,

Anthony Liguori

>
> Andreas
>
>>      trace_scsi_req_alloc(req->dev->id, req->lun, req->tag);
>>      return req;
>>  }
>> @@ -1505,6 +1507,8 @@ void scsi_req_unref(SCSIRequest *req)
>>          if (req->ops->free_req) {
>>              req->ops->free_req(req);
>>          }
>> +        object_unref(OBJECT(req->dev));
>> +        object_unref(OBJECT(bus->qbus.parent));
>>          g_free(req);
>>      }
>>  }
>> 
>
>
> -- 
> SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
> GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

Patch

diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index 53ea906..e443193 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -516,6 +516,8 @@  SCSIRequest *scsi_req_alloc(const SCSIReqOps *reqops, SCSIDevice *d,
     req->status = -1;
     req->sense_len = 0;
     req->ops = reqops;
+    object_ref(OBJECT(d));
+    object_ref(OBJECT(req->bus->qbus.parent));
     trace_scsi_req_alloc(req->dev->id, req->lun, req->tag);
     return req;
 }
@@ -1505,6 +1507,8 @@  void scsi_req_unref(SCSIRequest *req)
         if (req->ops->free_req) {
             req->ops->free_req(req);
         }
+        object_unref(OBJECT(req->dev));
+        object_unref(OBJECT(bus->qbus.parent));
         g_free(req);
     }
 }