On Tue, Mar 19, 2013 at 09:48:56AM +1100, Gareth Pye wrote: > Would it make sense for btrfs to support a write zeros to empty space > erase? I know it would be slow as it would have to write to all the > free space in the file system but it would be useful. > > It's probably pretty far down the priority list for development though I > expect.
I have prototyped this some time ago http://repo.or.cz/w/linux-2.6/btrfs-unstable.git/commit/55ec5c00022be8f2bbed06b99b5f4be5832a5451 It reuses the trim code that already traverses the free space but calls blkdev_issue_zeroout instead. The overwrite pattern could be extended to random data, some posion patterns (like leaf that has 0 items and could be recognized in the code to catch misdirected writes; similarly for tree node blocks), or the secure discard. (I haven't resolved what to do if there's a mixture of HDDs and SSDs, rewriting the free space has different impact on the underlying devices.) The existing FITRIM ioctl structure fstrim_range does not contain any spare bytes so either we need to go with own ioctl or propose FITRIM_V2. david -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html