|
|
Log in / Subscribe / Register

Ioctl to clear unused space in various ways

From:  David Sterba <dsterba-AT-suse.com>
To:  linux-btrfs-AT-vger.kernel.org
Subject:  [PATCH 0/5] Ioctl to clear unused space in various ways
Date:  Fri, 28 Feb 2025 15:49:20 +0100
Message-ID:  <cover.1740753608.git.dsterba@suse.com>
Cc:  David Sterba <dsterba-AT-suse.com>
Archive-link:  Article

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.

David Sterba (5):
  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

 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            |  42 ++++++++++
 fs/btrfs/volumes.c          |   3 +-
 include/uapi/linux/btrfs.h  |  46 +++++++++++
 9 files changed, 258 insertions(+), 40 deletions(-)

-- 
2.47.1




Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds