From: Erwan Velu Date: Thu, 25 Feb 2016 13:08:10 +0000 (+0100) Subject: ceph-helpers.sh: Deleting forgoten btrfs subvolumes X-Git-Tag: v10.1.0~295^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cd0389ddb10b5762af56e6b7ff938dac7308cad9;p=ceph.git ceph-helpers.sh: Deleting forgoten btrfs subvolumes While running a make check on a btrfs system, many subvolumes are let at the end of the build. It's pretty common to have several hundreds of those. btrfs is pretty sensible to the path when requesting a subvolume removal. The current code was misleading the path and didn't deleted the remaining volumes. This patch list the current subvolumes, filter thoses created by the test process and ajust the path because brtfs reports erwan/chroot/ceph/src/testdir/test-7202/dev/osd1/snap_439 while regarding the current working directory we want to delete : testdir/test-7202/dev/osd1/snap_439 Signed-off-by: Erwan Velu --- diff --git a/qa/workunits/ceph-helpers.sh b/qa/workunits/ceph-helpers.sh index 15788886497..d53837edb97 100755 --- a/qa/workunits/ceph-helpers.sh +++ b/qa/workunits/ceph-helpers.sh @@ -126,13 +126,13 @@ function __teardown_btrfs() { local btrfs_base_dir=$1 btrfs_dirs=`ls -l $btrfs_base_dir | egrep '^d' | awk '{print $9}'` - for btrfs_dir in $btrfs_dirs - do - btrfs_subdirs=`ls -l $btrfs_base_dir/$btrfs_dir | egrep '^d' | awk '{print $9}'` - for btrfs_subdir in $btrfs_subdirs - do - btrfs subvolume delete $btrfs_base_dir/$btrfs_dir/$btrfs_subdir - done + current_path=`pwd` + # extracting the current existing subvolumes + for subvolume in $(cd $btrfs_base_dir; btrfs subvolume list . -t |egrep '^[0-9]' | awk '{print $4}' |grep "$btrfs_base_dir/$btrfs_dir"); do + # Compute the relative path by removing the local path + # Like "erwan/chroot/ceph/src/testdir/test-7202/dev/osd1/snap_439" while we want "testdir/test-7202/dev/osd1/snap_439" + local_subvolume=$(echo $subvolume | sed -e "s|.*$current_path/||"g) + btrfs subvolume delete $local_subvolume done }