* [PATCH] btrfs: test that we can't delete subvolume within swapfile
@ 2022-03-29 10:02 Kaiwen Hu
2022-03-29 10:21 ` Filipe Manana
0 siblings, 1 reply; 2+ messages in thread
From: Kaiwen Hu @ 2022-03-29 10:02 UTC (permalink / raw)
To: linux-btrfs, fstests; +Cc: robbieko, cccheng, seanding, Kaiwen Hu
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] btrfs: test that we can't delete subvolume within swapfile
2022-03-29 10:02 [PATCH] btrfs: test that we can't delete subvolume within swapfile Kaiwen Hu
@ 2022-03-29 10:21 ` Filipe Manana
0 siblings, 0 replies; 2+ messages in thread
From: Filipe Manana @ 2022-03-29 10:21 UTC (permalink / raw)
To: Kaiwen Hu; +Cc: linux-btrfs, fstests, robbieko, cccheng, seanding
On Tue, Mar 29, 2022 at 06:02:02PM +0800, Kaiwen Hu wrote:
> 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(+)
Thanks for doing this.
However we don't change existing tests to exercise bugs.
The few exceptions where we change an existing test case are, typically,
if the test case is very recent and we didn't get it quite right, or
if we had a filesystem behaviour change that makes the test fail - like
for example the recent changes that allow cross mount reflink operations.
So this should be a new test case.
>
> 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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-29 10:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-29 10:02 [PATCH] btrfs: test that we can't delete subvolume within swapfile Kaiwen Hu
2022-03-29 10:21 ` Filipe Manana
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox