@@ -1253,6 +1253,9 @@ static int btrfs_issue_clear_op(struct block_device *bdev, u64 start, u64 size,
unsigned int flags = BLKDEV_ZERO_KILLABLE;
switch (clear) {
+ case BTRFS_CLEAR_OP_SECURE_ERASE:
+ return blkdev_issue_secure_erase(bdev, start >> SECTOR_SHIFT,
+ size >> SECTOR_SHIFT, GFP_NOFS);
case BTRFS_CLEAR_OP_DISCARD:
return blkdev_issue_discard(bdev, start >> SECTOR_SHIFT,
size >> SECTOR_SHIFT, GFP_NOFS);
@@ -1097,6 +1097,13 @@ enum btrfs_clear_op_type {
* (Same as blkdev_issue_zeroout() with 0 flags).
*/
BTRFS_CLEAR_OP_ZERO,
+ /*
+ * Do a secure erase operation on the range. If supported by the
+ * underlying hardware, this works as regular discard except that all
+ * copies of the discarded blocks that were possibly created by
+ * garbage collection must also be erased.
+ */
+ BTRFS_CLEAR_OP_SECURE_ERASE,
BTRFS_NR_CLEAR_OP_TYPES,
};
Add another type of clearing that will do secure erase on the unused space. This requires hardware support and works as a regular discard while also deleting any copied or cached blocks. Same as "blkdiscard --secure". The unused space ranges may not be aligned to the secure erase block or be of a sufficient length, the exact result depends on the device. Some blocks may still contain valid data even after this ioctl. Signed-off-by: David Sterba <dsterba@suse.com> --- fs/btrfs/extent-tree.c | 3 +++ include/uapi/linux/btrfs.h | 7 +++++++ 2 files changed, 10 insertions(+)