The 3.18 branch of the Chrome OS kernel has disabled FALLOC_FL_PUNCH_HOLE for ext4, so translating discard from the block device into fallocate() fails and we fall back to writing buffers of zeroes. This is very slow for large discards (e.g. the entire disk). It's also not necessary in the case of a virtio block Discard command, which does not require that the discarded data return zeroes after the command completes (the spec says "The driver MUST NOT assume anything about the data returned by read requests after a range of sectors has been discarded").
We should be able to split up the implementation of Write Zeroes (which must read back as zeroes) and Discard so that Discard can just try the fallocate() and continue without reporting an error if it fails. This should restore reasonable performance on 3.18 kernels, although it will not actually free up space on the host filesystem on those systems.
Comment 1 by bugdroid1@chromium.org
, Oct 19