Skip to content

Ioctl to clear unused space in various ways

David Sterba linux-btrfs 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest6 patches 1 replyIn review
  2. v15 patches 8 repliesSuperseded

Changes in v2 from the cover letter

- return -EOPNOTSUPP for zoned mode, with a note
- add new operation to reset the chunk map status wrt trim

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6btrfs: extend trim callchains to pass the operation typefs/btrfs/discard.c fs/btrfs/extent-tree.c fs/btrfs/extent-tree.h +5 more+68 -400 replies
2/6btrfs: add new ioctl CLEAR_FREEfs/btrfs/extent-tree.c fs/btrfs/extent-tree.h fs/btrfs/ioctl.c +1 more+163 -00 replies
3/6btrfs: add zeroout mode to CLEAR_FREE ioctlfs/btrfs/extent-tree.c include/uapi/linux/btrfs.h+12 -00 replies
4/6btrfs: add secure erase mode to CLEAR_FREE ioctlfs/btrfs/extent-tree.c include/uapi/linux/btrfs.h+10 -00 replies
5/6btrfs: add more zeroout modes to CLEAR_FREE ioctlfs/btrfs/extent-tree.c include/uapi/linux/btrfs.h+14 -20 replies
6/6btrfs: add mode to clear chunk map status to CLEAR_FREE ioctlfs/btrfs/ioctl.c fs/btrfs/volumes.c fs/btrfs/volumes.h +1 more+26 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/6] Ioctl to clear unused space in various ways

Add ioctl that is similar to FITRIM and in addition to trim can do also zeroing (either plain overwrite, or unmap the blocks if the device supports it) and secure erase.

This can be used to zero the unused space in e.g. VM images (when run from inside the guest, if fstrim is not supported) or free space on thin-provisioned devices.

The secure erase is provided by blkdiscard command but I'm not aware of equivalent that can be run on a filesystem, so this is for parity.

v2:
- return -EOPNOTSUPP for zoned mode, with a note
- add new operation to reset the chunk map status wrt trim

David Sterba (6):
btrfs: extend trim callchains to pass the operation type
btrfs: add new ioctl CLEAR_FREE
btrfs: add zeroout mode to CLEAR_FREE ioctl
btrfs: add secure erase mode to CLEAR_FREE ioctl
btrfs: add more zeroout modes to CLEAR_FREE ioctl
btrfs: add mode to clear chunk map status to CLEAR_FREE ioctl

 fs/btrfs/discard.c          |   4 +-
 fs/btrfs/extent-tree.c      | 159 +++++++++++++++++++++++++++++++-----
 fs/btrfs/extent-tree.h      |   5 +-
 fs/btrfs/free-space-cache.c |  29 ++++---
 fs/btrfs/free-space-cache.h |   8 +-
 fs/btrfs/inode.c            |   2 +-
 fs/btrfs/ioctl.c            |  62 ++++++++++++++
 fs/btrfs/volumes.c          |   8 +-
 fs/btrfs/volumes.h          |   1 +
 include/uapi/linux/btrfs.h  |  53 ++++++++++++
 10 files changed, 291 insertions(+), 40 deletions(-)
Signature · 1 line
2.47.1