Re: [PATCH 1/5] block: move discard checks into the ioctl handler

Christoph Hellwig
2024-03-12T22:31:36Z

On Tue, Mar 12, 2024 at 04:12:54PM -0600, Keith Busch wrote:
> > + if (!nr_sects)
> > return -EINVAL;
> > + if ((sector | nr_sects) & bs_mask)
> > return -EINVAL;
> > -
> > if (start + len > bdev_nr_bytes(bdev))
> > return -EINVAL;
>
> Maybe you want to shift lower bytes out of consideration, but it is
> different, right? For example, if I call this ioctl with start=5 and
> len=555, it would return EINVAL, but your change would let it succeed
> the same as if start=0, len=512.

We did the same before, just down in __blkdev_issue_discard instead of
in the ioctl handler.