public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Kaiwen Hu <kevinhu@synology.com>
To: linux-btrfs@vger.kernel.org, fstests@vger.kernel.org
Cc: robbieko@synology.com, cccheng@synology.com,
	seanding@synology.com, Kaiwen Hu <kevinhu@synology.com>
Subject: [PATCH] btrfs: test that we can't delete subvolume within swapfile
Date: Tue, 29 Mar 2022 18:02:02 +0800	[thread overview]
Message-ID: <20220329100201.1502010-1-kevinhu@synology.com> (raw)

Subvolumes with active swapfiles should be forbidden
to be deleted, because when the subvolume is deleted,
we cannot swapoff the swapfile in the deleted subvolume.

Fixed by the patch
	btrfs: prevent subvol with swapfile from being deleted

Reviewed-by: Robbie Ko <robbieko@synology.com>
Signed-off-by: Kaiwen Hu <kevinhu@synology.com>
---
 tests/btrfs/174     | 10 ++++++++++
 tests/btrfs/174.out |  3 +++
 2 files changed, 13 insertions(+)

diff --git a/tests/btrfs/174 b/tests/btrfs/174
index 3bb5e7f9..08d4af40 100755
--- a/tests/btrfs/174
+++ b/tests/btrfs/174
@@ -11,6 +11,7 @@
 _begin_fstest auto quick swap
 
 . ./common/filter
+. ./common/filter.btrfs
 
 _supported_fs btrfs
 _require_scratch_swapfile
@@ -43,7 +44,16 @@ echo "Defrag"
 # fragmented.
 $BTRFS_UTIL_PROG filesystem defrag -c "$swapfile" 2>&1 | grep -o "Text file busy"
 
+# We cannot delete sub-volume when the sub-volume contains active swapfile.
+echo "Delete subvol"
+$BTRFS_UTIL_PROG subvolume delete "$SCRATCH_MNT/swapvol" \
+	2>&1 | grep -o "Text file busy"
+
 swapoff "$swapfile"
+
+# Delete the sub-volume
+$BTRFS_UTIL_PROG subvolume delete $SCRATCH_MNT/swapvol | _filter_btrfs_subvol_delete
+
 _scratch_unmount
 
 status=0
diff --git a/tests/btrfs/174.out b/tests/btrfs/174.out
index 15bdf79e..8bed461b 100644
--- a/tests/btrfs/174.out
+++ b/tests/btrfs/174.out
@@ -8,3 +8,6 @@ Snapshot
 Text file busy
 Defrag
 Text file busy
+Delete subvol
+Text file busy
+Delete subvolume 'SCRATCH_MNT/swapvol'
-- 
2.25.1


             reply	other threads:[~2022-03-29 10:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-29 10:02 Kaiwen Hu [this message]
2022-03-29 10:21 ` [PATCH] btrfs: test that we can't delete subvolume within swapfile Filipe Manana

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=20220329100201.1502010-1-kevinhu@synology.com \
    --to=kevinhu@synology.com \
    --cc=cccheng@synology.com \
    --cc=fstests@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=robbieko@synology.com \
    --cc=seanding@synology.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