On Fri, Jun 22, 2012 at 08:38:51PM -0700, Chris Wedgwood wrote: > > I'm not sure I understand, wouldn't the filesystem need to be involved > > at some level? How can the block layer differentiate lazilly discarded data > > blocks from ones that are still in use without the aid of the > > filesystem? > > It might be me that doesn't understand. > > Yes, the filesystem is involved. Current linux filesystems can trim > on demand or using fstrim. That mechanism seems to be like it should > suffice if exposed in the most common cases. >
You mean the "discard" mount option? I don't think that's generally enabled by default due to the performance impact on bare metal. A periodic, filesystem-wide call (like the FITRIM ioctl) is probably the better approach in those cases as well. I'm not sure what the penalty of auto-discard would be in the case of VMs, but there would be at least some additional overhead there due the hole punching operations run by the host, and the only use case I can think of where it's useful in that context is for reducing the size of the images before we do some work with them on the host, in which case an explicit FITRIM ioctl beforehand makes the most sense IMO.