]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test: sudo to rm btrfs subvol 8786/head
authorKefu Chai <kchai@redhat.com>
Wed, 27 Apr 2016 17:06:33 +0000 (01:06 +0800)
committerKefu Chai <tchaikov@gmail.com>
Wed, 27 Apr 2016 18:05:26 +0000 (02:05 +0800)
"btrfs subvolume {list,delete}" needs root privilege even if the current
user owns this subvol. one can only list/delete he/she is the root, or
if the btrfs volume was mounted with "-o user_subvol_rm_allowed".

Signed-off-by: Kefu Chai <kchai@redhat.com>
qa/workunits/ceph-helpers.sh
src/test/ceph_objectstore_tool.py

index 3fec15b4f15251ee594f66c121c1037acc325395..97b6dd3104d5979f93e3fedd05a38dade0683c6c 100755 (executable)
@@ -125,15 +125,10 @@ function teardown() {
 
 function __teardown_btrfs() {
     local btrfs_base_dir=$1
-
-    btrfs_dirs=`ls -l $btrfs_base_dir | egrep '^d' | awk '{print $9}'`
-    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
+    local btrfs_root=$(df -P . | tail -1 | awk '{print $NF}')
+    local btrfs_dirs=$(cd $btrfs_base_dir; sudo btrfs subvolume list . -t | awk '/^[0-9]/ {print $4}' | grep "$btrfs_base_dir/$btrfs_dir")
+    for subvolume in $btrfs_dirs; do
+       sudo btrfs subvolume delete $btrfs_root/$subvolume
     done
 }
 
index 91804751465e6405562fbff3d0dda4090c53e4d4..7d7b5344d7614cdbd3a931799f5fb172f2a306af 100755 (executable)
@@ -1874,14 +1874,14 @@ def remove_btrfs_subvolumes(path):
     result = subprocess.Popen("stat -f -c '%%T' %s" % path, shell=True, stdout=subprocess.PIPE)
     filesystem = result.stdout.readlines()[0]
     if filesystem.rstrip('\n') == "btrfs":
-        result = subprocess.Popen("btrfs subvolume list %s" % path, shell=True, stdout=subprocess.PIPE)
+        result = subprocess.Popen("sudo btrfs subvolume list %s" % path, shell=True, stdout=subprocess.PIPE)
         for line in result.stdout.readlines():
             subvolume=line.split()[8]
             # extracting the relative volume name
             m = re.search(".*(%s.*)" % path, subvolume)
             if m:
                 found = m.group(1)
-                call("btrfs subvolume delete %s" % found, shell=True)
+                call("sudo btrfs subvolume delete %s" % found, shell=True)
 
 
 if __name__ == "__main__":