Re: [PATCH V2 3/5] ublk_drv: add SET_PARAM/GET_PARAM control command

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

 



On Thu, Jul 28, 2022 at 09:56:26AM +0800, Ming Lei wrote:
> Hi Christoph,
> 
> On Wed, Jul 27, 2022 at 06:22:34PM +0200, Christoph Hellwig wrote:
> > As stated in the previous discussion I think this is a very bad idea
> > that leads to a lot of boiler plate code.  If you don't want to rely
> 
> But you never point out where the boiler plate code is, care to share
> what/where it is?
> 
> If you don't like xarray, we can replace it with one plain array
> from the beginning, this change is just in implementation level.
> 
> Given it is ABI interface, I'd suggest to consolidate it from the
> beginning.
> 
> > on zeroed fields we can add a mask of valid fields, similar to how
> > e.g. the statx API works.
> 
> With one mask for marking valid fields, we still need to group
> fields, and one bit in mask has to represent one single group, and
> it can't represent each single field.
> 
> Also one length field has to be added in the header for keeping
> compatibility with old app.
> 
> With the above two change, it becomes very similar with the approach
> in this patch.
> 
> IMO there are more advantages in grouping parameter explicitly:
> 
> 1) avoid big chunk of memory for storing lots of unnecessary parameter
> if the big params data structure is extended, and we just store whatever
> the userspace cares.
> 
> 2) easy to add new type by just implementing two callbacks(both optionally),
> and code is actually well organized, and each callback just focuses on the
> interested parameter type 
> 
> 3) parameter is easier to verify, since we know each parameter's length and type.
> With mask, we can only know if one parameter type exists in the big
> parameters data structure or not.

Another thing with putting everything into single structure is that the
params structure will become a mess sooner or later, since all kinds of
parameters will be added at the end, none of them are related.

For example, Ziyang is working on userspace recovery feature which may
need some data which can't be hold in single bit flag, meantime someone
may work on zoned target implementation[1] which needs to send zoned
parameter, and I am planning to add backing pages for handling running
out of pages, which needs userspace to pre-allocate/send buffer to driver
as backing page[s], ... Then all these unrelated parameters are added at
the end, and the single structure becomes fatter and fatter, then become
unreadable and hard to maintain.


[1] https://lore.kernel.org/qemu-devel/fa7de750-8def-c532-8c86-64c7505608e0@xxxxxxxxxxxxxxxxxx/T/#u

Thanks,
Ming




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux