[PATCHv3] nvme: implement non-mdts command limits

Keith Busch kbusch at kernel.org
Thu Mar 25 15:30:35 GMT 2021


On Thu, Mar 25, 2021 at 07:50:28AM +0100, Christoph Hellwig wrote:
> On Wed, Mar 24, 2021 at 04:18:05PM -0700, Keith Busch wrote:
> >  
> > +static inline u32 nvme_mps_size_to_sectors(struct nvme_ctrl *ctrl, u8 size)
> > +{
> > +	int page_shift = NVME_CAP_MPSMIN(ctrl->cap) + 12;
> > +
> > +	return 1 << (size + page_shift - 9);
> 
> A little nitpick we can fix when applying if needed:  MPS already
> is the memory page size, so the size here seems redundant.

Sure, nvme_mps_to_sectors() is fine. And perhaps renaming the 'size'
parameter to something like 'units' might be more clear and aligns to
the spec terms.
 
> > +	/*
> > +	 * Even though NVMe spec explicitly states that MDTS is not applicable
> > +	 * to the write-zeroes, we are cautious and limit the size to the
> > +	 * controllers max_hw_sectors value, which is based on the MDTS field
> > +	 * and possibly other limiting factors.
> > +	 */
> > +	if (!(ctrl->quirks & NVME_QUIRK_DISABLE_WRITE_ZEROES) &&
> > +	    (ctrl->oncs & NVME_CTRL_ONCS_WRITE_ZEROES))
> 
> I would place the oncs check befoe the quirks check as it flows a lot
> more logical.
> 
> But all the actual logic looks fine to me.



More information about the Linux-nvme mailing list