btrfs-progs: subvolume: Implement delete --subvolid <path>
Subsystems (2)
PATCH v2 1/1 btrfs-progs: subvolume: Implement delete --subvolid <path>
From: Marcos Paulo de Souza <[email protected]>
With this patch a user can delete a subvolume from a btrfs using only the subvolume id in the format
btrfs subvolume delete --subvolid <volid> <path>
---
Changes since v1:
* Break the usage message into different lines:
usage: btrfs subvolume delete [options] <subvolume> [<subvolume>...]
btrfs subvolume delete [options] -s|--subvolid <subvolid> <path>
...
(suggested by David Sterba)
* Changed subvol to subvolid in a comment of cmd_subvol_delete (suggested By AnandJain)
* Changed the documentation/btrfs-subvolume to show both formats of subvolume delete in the
* same line, following what other commands already do:
*delete* [options] <[<subvolume> [<subvolume>...]] | [-s|--subvolid <subvolid> <path>]>::
Documentation/btrfs-subvolume.asciidoc | 8 +++- cmds/subvolume.c | 41 +++++++++++++++++-- tests/misc-tests/038-delete-subvolume/test.sh | 30 ++++++++++++++ 3 files changed, 74 insertions(+), 5 deletions(-) create mode 100755 tests/misc-tests/038-delete-subvolume/test.sh
Documentation/btrfs-subvolume.asciidoc +7 -1
@@ -59,12 +59,15 @@ directory. Add the newly created subvolume to a qgroup. This option can be given multiple times. -*delete* [options] <subvolume> [<subvolume>...]:: +*delete* [options] <[<subvolume> [<subvolume>...]] | [-s|--subvolid <subvolid> <path>]>:: Delete the subvolume(s) from the filesystem. + If <subvolume> is not a subvolume, btrfs returns an error but continues if there are more arguments to process. + +If --subvolid if used, <path> must point to a btrfs filesystem. See `btrfs +subvolume list` how to get the subvolume id. ++ The corresponding directory is removed instantly but the data blocks are removed later in the background. The command returns immediately. See `btrfs subvolume sync` how to wait until the subvolume gets completely removed.
@@ -84,6 +87,9 @@ wait for transaction commit after deleting each subvolume. + -v|--verbose:::: verbose output of operations. ++ +-s|--subvolid:::: +subvolume id of the to be removed subvolume from <path> *find-new* <subvolume> <last_gen>:: List the recently modified files in a subvolume, after <last_gen> generation.
cmds/subvolume.c +37 -4
92 lines not on this page · raw message
tests/misc-tests/038-delete-subvolume/test.sh new file +30 -0
@@ -0,0 +1,30 @@ +#!/bin/bash +# test btrfs subvolume delete --subvolid <volid> <path> + +source "$TEST_TOP/common" + +check_prereq mkfs.btrfs +check_prereq btrfs + +setup_root_helper +prepare_test_dev + +run_check_mkfs_test_dev +run_check_mount_test_dev + +run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT"/mysubvol1 + +# subvolid expected failures +run_mustfail "subvolume delete --subvolid expects an integer" \ + $SUDO_HELPER "$TOP/btrfs" subvolume delete --subvolid aaa "$TEST_MNT" + +run_mustfail "subvolume delete --subvolid with invalid unexisting subvolume" \ + $SUDO_HELPER "$TOP/btrfs" subvolume delete --subvolid 999 "$TEST_MNT" + +run_mustfail "subvolume delete --subvolid expects only one extra argument: the mountpoint" \ + $SUDO_HELPER "$TOP/btrfs" subvolume delete --subvolid 256 "$TEST_MNT" "$TEST_MNT" + +# delete the recently created subvol using the subvolid +run_check $SUDO_HELPER "$TOP/btrfs" subvolume delete --subvolid 256 "$TEST_MNT" + +run_check_umount_test_dev
Signature · 1 line
2.23.0