Re: [PATCH 2/2] block: create ioctl to discard-or-zeroout a range of blocks

Christoph Hellwig
2016-03-03T18:00:09Z

On Thu, Mar 03, 2016 at 09:55:38AM -0800, Linus Torvalds wrote:
> Ugh.
>
> But that essentially says that we shouldn't expose this interface at
> all (unless we trust our white-lists - I'm sure they are getting
> better, but if nobody has ever really _relied_ on the zeroing behavior
> of trim, then I guess there could be tons of bugs lurking).

Fortunately what Ted said is close to the truth, but a little off.

The mess about ATA is all real, and we work around it by never claiming
discard zeroes data for any ATA device except those specificly
whitelisted because the vendors gave guarantees for it (see the
ATA_HORKAGE_ZERO_AFTER_TRIM flag and the commit introducing it).

The reason why we don't use it unconditionally is simply because
there are users that want blocks zeroed without deallocating the
physical blocks. Now if you want to opt into the trim/unmap
behavior is one question, but we clearly need the split.