Skip to content

Add ioctl to clear unused space

David Sterba linux-btrfs 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest6 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6btrfs: extend trim callchain to pass the operation typefs/btrfs/ctree.h fs/btrfs/extent-tree.c fs/btrfs/free-space-cache.c +1 more+62 -280 replies
2/6btrfs: add wrapper to switch clearing operationfs/btrfs/extent-tree.c+14 -110 replies
3/6btrfs: add zeroing clear operationfs/btrfs/ctree.h fs/btrfs/extent-tree.c+4 -00 replies
4/6btrfs: add new ioctl BTRFS_IOC_CLEAR_FREEfs/btrfs/ctree.h fs/btrfs/extent-tree.c fs/btrfs/ioctl.c +1 more+112 -90 replies
5/6btrfs: add discard secure to clear unused spacefs/btrfs/extent-tree.c include/uapi/linux/btrfs.h+13 -20 replies
6/6btrfs: add more zeroout modes for clearing unused spacefs/btrfs/extent-tree.c include/uapi/linux/btrfs.h+16 -10 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH 0/6] Add ioctl to clear unused space

This patchset adds new ioctl similar to TRIM, that provides several other ways how to clear the unused space. The changelogs are incomplete, for preview not for inclusion yet.

It compiles and has been tested lightly, the clearing modes depend on hw capabilities (secure discard, sector unmapping instead of zeros), so I've tested only zeroing and discard.

I personally think the zeroing has a usecase and the other modes were easy to add. Further extensions can be considered, eg. WRITE_SAME, overwriting with a randomly generated pattern, or some filesystem canary patterns that can be used to report unused block read as metadata.

As this is modelled after the generic FITRIM ioctl, so this could be a new generic ioctl too. However, last time somebody wanted such ioctl, there was a pushback. I'll consider making a generic version and send it for comments to fsdevel eventually.

git://github.com/kdave/btrfs-devel dev/zero-free

David Sterba (6):
btrfs: extend trim callchain to pass the operation type
btrfs: add wrapper to switch clearing operation
btrfs: add zeroing clear operation
btrfs: add new ioctl BTRFS_IOC_CLEAR_FREE
btrfs: add discard secure to clear unused space
btrfs: add more zeroout modes for clearing unused space

 fs/btrfs/ctree.h            |   5 +-
 fs/btrfs/extent-tree.c      | 130 ++++++++++++++++++++++++++++++++++++++------
 fs/btrfs/free-space-cache.c |  22 +++++---
 fs/btrfs/free-space-cache.h |   3 +-
 fs/btrfs/ioctl.c            |  42 ++++++++++++++
 include/uapi/linux/btrfs.h  |  26 +++++++++
 6 files changed, 199 insertions(+), 29 deletions(-)
Signature · 1 line
2.16.2