public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/6] Ioctl to clear unused space in various ways
@ 2025-03-12 11:12 David Sterba
  2025-03-12 11:12 ` [PATCH v2 1/6] btrfs: extend trim callchains to pass the operation type David Sterba
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: David Sterba @ 2025-03-12 11:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

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(-)

-- 
2.47.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-03-17 20:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-12 11:12 [PATCH v2 0/6] Ioctl to clear unused space in various ways David Sterba
2025-03-12 11:12 ` [PATCH v2 1/6] btrfs: extend trim callchains to pass the operation type David Sterba
2025-03-12 11:12 ` [PATCH v2 2/6] btrfs: add new ioctl CLEAR_FREE David Sterba
2025-03-12 11:12 ` [PATCH v2 3/6] btrfs: add zeroout mode to CLEAR_FREE ioctl David Sterba
2025-03-12 11:12 ` [PATCH v2 4/6] btrfs: add secure erase " David Sterba
2025-03-12 11:12 ` [PATCH v2 5/6] btrfs: add more zeroout modes " David Sterba
2025-03-12 11:12 ` [PATCH v2 6/6] btrfs: add mode to clear chunk map status " David Sterba
2025-03-17 20:11 ` [PATCH v2 0/6] Ioctl to clear unused space in various ways David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox