Traditionally storage devices (hard drives) were assumed to have no mechanism to "delete" data beyond simply overwriting it. I can see a few theoretical scenarios where it would be useful for block devices to be informed that their underlying storage is no longer required but I don't see any mechanism to do so.
Use cases:
- Almost all modern SSDs use Wear Leveling to extend their life. This is achievable by simply having more blocks of internal storage than than the reported size and cycling between them. But if the SSD was told that blocks were no longer required it would give a much larger pool to cycle through.
- File systems created in RAM (NOT including tmpfs). Where files are deleted, the underlying ramdisk cannot return the allocated space to free RAM if the file system can't report the space is not required.
- Swap solutions such those using zram would need to inform the block device when pages are no longer used in swap space or they would leave a significant amount of "junk" sitting in RAM.
This looks like a similar concept to FALLOC_FL_PUNCH_HOLE. But from what I can read there, that is purely for de-allocating space from a file in a file system. That is to say, a user space application can inform a file system that space is not needed. But that's not the same as a file system informing a block device that space isn't needed or is it?
So is it a case that in each scenario there is a work around, or us there a mechanism that allows filesystems and swap to inform block devices when blocks are no longer needed?