[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 05/21] scsi: reference-count requests
From: |
Christoph Hellwig |
Subject: |
Re: [Qemu-devel] [PATCH v3 05/21] scsi: reference-count requests |
Date: |
Fri, 20 May 2011 17:58:07 +0200 |
User-agent: |
Mutt/1.5.17 (2007-11-01) |
> --- a/hw/scsi-bus.c
> +++ b/hw/scsi-bus.c
> @@ -136,6 +136,7 @@ SCSIRequest *scsi_req_alloc(size_t size, SCSIDevice *d,
> uint32_t tag, uint32_t l
> SCSIRequest *req;
>
> req = qemu_mallocz(size);
> + req->refcount = 2;
> req->bus = scsi_bus_from_device(d);
> req->dev = d;
> req->tag = tag;
A little comment explaining why we start out with a reference count of 2
would be useful here. Might be worth making that a top of the function
block comment explaning the function a bit more while you're at it.
> void scsi_req_free(SCSIRequest *req)
> {
> - scsi_req_dequeue(req);
> + assert(req->refcount == 0);
> qemu_free(req);
> }
Is there any reason to keep a free function? The pattern should be
that people just call the function to decrement the reference count,
and that frees the structure when it hits zero. In the current model
that would mean moving the freeing out of ->free_req into scsi_req_unref,
but that seems pretty sensible anyway.
- [Qemu-devel] [PATCH v3 01/21] scsi: add tracing of scsi requests, (continued)
- [Qemu-devel] [PATCH v3 01/21] scsi: add tracing of scsi requests, Paolo Bonzini, 2011/05/17
- [Qemu-devel] [PATCH v3 03/21] scsi: introduce scsi_req_data, Paolo Bonzini, 2011/05/17
- [Qemu-devel] [PATCH v3 04/21] scsi: introduce SCSIBusOps, Paolo Bonzini, 2011/05/17
- [Qemu-devel] [PATCH v3 06/21] lsi: extract lsi_find_by_tag, Paolo Bonzini, 2011/05/17
- [Qemu-devel] [PATCH v3 05/21] scsi: reference-count requests, Paolo Bonzini, 2011/05/17
- Re: [Qemu-devel] [PATCH v3 05/21] scsi: reference-count requests,
Christoph Hellwig <=
- [Qemu-devel] [PATCH v3 07/21] scsi: Use 'SCSIRequest' directly, Paolo Bonzini, 2011/05/17
- [Qemu-devel] [PATCH v3 08/21] scsi: commonize purging requests, Paolo Bonzini, 2011/05/17
- [Qemu-devel] [PATCH v3 09/21] scsi: introduce scsi_req_abort, Paolo Bonzini, 2011/05/17
- [Qemu-devel] [PATCH v3 14/21] scsi: introduce scsi_req_new, Paolo Bonzini, 2011/05/17