[PATCH v4 05/11] block: Add core atomic write support
Christoph Hellwig
hch at lst.de
Tue Feb 20 00:22:45 PST 2024
On Tue, Feb 20, 2024 at 09:58:39AM +1100, Dave Chinner wrote:
> > + lim->atomic_write_hw_max_sectors = 0;
> > + lim->atomic_write_max_sectors = 0;
> > + lim->atomic_write_hw_boundary_sectors = 0;
> > + lim->atomic_write_hw_unit_min_sectors = 0;
> > + lim->atomic_write_unit_min_sectors = 0;
> > + lim->atomic_write_hw_unit_max_sectors = 0;
> > + lim->atomic_write_unit_max_sectors = 0;
> > }
>
> Seems to me this function would do better to just
>
> memset(lim, 0, sizeof(*lim));
>
> and then set all the non-zero fields.
.. which the caller already has done :) In the block tree this
function looks completely different now and relies on the caller
provided zeroing.
> > +void blk_queue_atomic_write_max_bytes(struct request_queue *q,
> > + unsigned int bytes)
> > +{
> > + q->limits.atomic_write_hw_max_sectors = bytes >> SECTOR_SHIFT;
> > + blk_atomic_writes_update_limits(q);
> > +}
> > +EXPORT_SYMBOL(blk_queue_atomic_write_max_bytes);
>
> Ok, so this can silently set a limit that is different to what the
> caller asked to have set?
>
> How is the caller supposed to find this out if the smaller limit
> that was set is not compatible with their configuration?
>
> i.e. shouldn't this return an error if the requested size cannot
> be set exactly as specified?
That's how the blk limits all work. The driver provides the hardware
capabilities for a given value, and the block layer ensures it
works with other limits imposed by the block layer or other parts
of the device limits.
More information about the Linux-nvme
mailing list