]> www.infradead.org Git - users/jedix/linux-maple.git/commit
btrfs: add new ioctl to wait for cleaned subvolumes
authorDavid Sterba <dsterba@suse.com>
Mon, 21 Oct 2024 19:28:26 +0000 (21:28 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 11 Nov 2024 13:34:22 +0000 (14:34 +0100)
commit6c83d153ed86eb17c46eafe4e78af4ce2071a052
treeb889e9ce5932e148cb0cb00091a416828b883f91
parent5599f39356c6ec73d2015ae88286382d1034ef0d
btrfs: add new ioctl to wait for cleaned subvolumes

Add a new unprivileged ioctl that will let the command
'btrfs subvolume sync' work without the (privileged) SEARCH_TREE ioctl.

There are several modes of operation, where the most common ones are to
wait on a specific subvolume or all currently queued for cleaning. This
is utilized e.g. in backup applications that delete subvolumes and wait
until they're cleaned to check for remaining space.

The other modes are for flexibility, e.g. for monitoring or
checkpoints in the queue of deleted subvolumes, again without the need
to use SEARCH_TREE.

Notes:

- waiting is interruptible, the timeout is set to 1 second and is not
  configurable

- repeated calls to the ioctl see a different state, so this is
  inherently racy when using e.g. the count or peek next/last

Use cases:

- a subvolume A was deleted, wait for cleaning (WAIT_FOR_ONE)

- a bunch of subvolumes were deleted, wait for all (WAIT_FOR_QUEUED or
  PEEK_LAST + WAIT_FOR_ONE)

- count how many are queued (not blocking), for monitoring purposes

- report progress (PEEK_NEXT), may miss some if cleaning is quick

- own waiting in user space (PEEK_LAST until it's 0)

Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ioctl.c
include/uapi/linux/btrfs.h