fstests.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
To: dsterba@suse.com, wqu@suse.com, linux-btrfs@vger.kernel.org,
	fstests@vger.kernel.org
Cc: Marcos Paulo de Souza <mpdesouza@suse.com>
Subject: [PATCHv2 2/2]  btrfs: Test subvolume delete --subvolid feature
Date: Fri,  7 Feb 2020 10:19:51 -0300	[thread overview]
Message-ID: <20200207131951.15859-3-marcos.souza.org@gmail.com> (raw)
In-Reply-To: <20200207131951.15859-1-marcos.souza.org@gmail.com>

From: Marcos Paulo de Souza <mpdesouza@suse.com>

Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
Changes from v1:
* Added some prints printing what is being tested
* The test now uses the _btrfs_get_subvolid to get subvolumeids instead of using
  plain integers

 tests/btrfs/203     | 73 +++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/203.out | 14 +++++++++
 tests/btrfs/group   |  1 +
 3 files changed, 88 insertions(+)
 create mode 100755 tests/btrfs/203
 create mode 100644 tests/btrfs/203.out

diff --git a/tests/btrfs/203 b/tests/btrfs/203
new file mode 100755
index 00000000..b9f1391f
--- /dev/null
+++ b/tests/btrfs/203
@@ -0,0 +1,73 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved.
+#
+# FSQA Test No. 203
+#
+# Test subvolume deletion using the subvolume id, even when the subvolume in
+# question is in a different mount space.
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+tmp=/tmp/$$
+status=1	# failure is the default!
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/filter.btrfs
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_btrfs_command subvolume delete --subvolid
+
+_scratch_mkfs > /dev/null 2>&1
+_scratch_mount
+
+# Test creating a normal subvolumes
+_run_btrfs_util_prog subvolume create $SCRATCH_MNT/subvol1 | _filter_scratch
+_run_btrfs_util_prog subvolume create $SCRATCH_MNT/subvol2 | _filter_scratch
+_run_btrfs_util_prog subvolume create $SCRATCH_MNT/subvol3 | _filter_scratch
+
+echo "Current subvolume ids:"
+$BTRFS_UTIL_PROG subvolume list $SCRATCH_MNT | awk '{ print $NF }'
+
+# Delete the subvolume subvol1 using it's subvolume id
+SUBVOLID=$(_btrfs_get_subvolid $SCRATCH_MNT subvol1)
+$BTRFS_UTIL_PROG subvolume delete --subvolid $SUBVOLID  $SCRATCH_MNT | _filter_scratch
+
+echo "After deleting one subvolume:"
+# should present only two subvolumes
+$BTRFS_UTIL_PROG subvolume list $SCRATCH_MNT | awk '{ print $NF }'
+
+umount $SCRATCH_MNT
+
+# Now we mount the subvol2, which makes subvol3 not accessible for this mount
+# point, but we should be able to delete it using it's subvolume id
+$MOUNT_PROG -o subvol=subvol2 $SCRATCH_DEV $SCRATCH_MNT
+SUBVOLID=$(_btrfs_get_subvolid $SCRATCH_MNT subvol3)
+$BTRFS_UTIL_PROG subvolume delete --subvolid $SUBVOLID $SCRATCH_MNT | _filter_scratch
+
+echo "Last remaining subvolume:"
+$BTRFS_UTIL_PROG subvolume list $SCRATCH_MNT | awk '{ print $NF }'
+
+umount $SCRATCH_MNT
+
+# now mount the rootfs
+_scratch_mount
+
+# Delete the subvol2
+SUBVOLID=$(_btrfs_get_subvolid $SCRATCH_MNT subvol2)
+$BTRFS_UTIL_PROG subvolume delete --subvolid $SUBVOLID  $SCRATCH_MNT | _filter_scratch
+
+echo "All subvolumes removed."
+$BTRFS_UTIL_PROG subvolume list $SCRATCH_MNT | awk '{ print $NF }'
+
+umount $SCRATCH_MNT
+
+# success, all done
+status=0
+exit
diff --git a/tests/btrfs/203.out b/tests/btrfs/203.out
new file mode 100644
index 00000000..bca18c32
--- /dev/null
+++ b/tests/btrfs/203.out
@@ -0,0 +1,14 @@
+QA output created by 203
+Current subvolume ids:
+subvol1
+subvol2
+subvol3
+Delete subvolume (no-commit): 'SCRATCH_MNT/subvol1'
+After deleting one subvolume:
+subvol2
+subvol3
+Delete subvolume (no-commit): 'SCRATCH_MNT/subvol3'
+Last remaining subvolume:
+subvol2
+Delete subvolume (no-commit): 'SCRATCH_MNT/subvol2'
+All subvolumes removed.
diff --git a/tests/btrfs/group b/tests/btrfs/group
index 79f85e97..e7744217 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -204,3 +204,4 @@
 200 auto quick send clone
 201 auto quick punch log
 202 auto quick subvol snapshot
+203 auto quick subvol
-- 
2.24.0


  parent reply	other threads:[~2020-02-07 13:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-07 13:19 [PATCHv2 0/2] btrfs: Test subvolume delete by id feature Marcos Paulo de Souza
2020-02-07 13:19 ` [PATCHv2 1/2] common: btrfs: Improve _require_btrfs_command Marcos Paulo de Souza
2020-02-07 13:25   ` Nikolay Borisov
2020-02-07 13:19 ` Marcos Paulo de Souza [this message]
2020-02-17 13:10   ` [PATCHv2 2/2] btrfs: Test subvolume delete --subvolid feature Eryu Guan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200207131951.15859-3-marcos.souza.org@gmail.com \
    --to=marcos.souza.org@gmail.com \
    --cc=dsterba@suse.com \
    --cc=fstests@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=mpdesouza@suse.com \
    --cc=wqu@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).