Re: [PATCH V5 1/5] virtio-scsi: redo allocation of target data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Il 19/03/2013 12:32, James Bottomley ha scritto:
> On Tue, 2013-03-19 at 17:57 +0800, Wanlong Gao wrote:
>> From: Paolo Bonzini <pbonzini@xxxxxxxxxx>
>>
>> virtio_scsi_target_state is now empty.  We will find new uses for it in
>> the next few patches, so this patch does not drop it completely.
>> However, having dropped the sglist flexible array member, we can turn
>> the tgt array-of-pointers into a simple array.  This simplifies the
>> allocation.
>>
>> Even simpler would be to place the virtio_scsi_target_state structs in a
>> flexible array member at the end of struct virtio_scsi.  But we do not
>> do that, because we will place the virtqueues there in the next patches.
> 
> I'm really sorry, but I must have been asleep at the wheel when I let
> code like this go in.  No modern driver should have fixed arrays for
> target information.  The way this is supposed to work is that you have
> entries in the host template for target_alloc and target_destroy.  You
> hook into these and attach your struct virtio_scsi_target_state to
> scsi_target->hostdata,

So that would be sc->device->sdev_target->hostdata.

> which you kmalloc in the target_alloc routine and
> kfree in the target_destroy routine.  Now you get at it from the sdev
> with scsi_target(sdev)->hostdata. No messing around with fixed size
> arrays and bulk memory allocation and no need to pass in the maximum
> target size as a parameter because everything should now happen
> dynamically.

The maximum target size is not a module parameter, it is given by the
host; so the module itself is not placing arbitrary limitation.  Still
it is a good idea to do it like this.

Thanks for the review.

Paolo

> Since you're redoing the code anyway, can you fix it to work this way?
> 
> Thanks,
> 
> James
> 
> 

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux