Skip to contentSkip to conversation

fstests: btrfs/224: do not assign snapshot to a subvolume qgroup

PATCH In review Qu Wenruo 4 participants 5 messages Feb 26, 2024 Btrfs file system

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

PATCH 1/1 fstests: btrfs/224: do not assign snapshot to a subvolume qgroup

For "btrfs subvolume snapshot -i <qgroupid>", we only expect the target qgroup to be a higher level one.

Assigning a 0 level qgroup to another 0 level qgroup is only going to cause confusion, and I'm planning to do extra sanity checks both in kernel and btrfs-progs to reject such behavior.

So change the test case to do regular higher level qgroup assignment only.

---
 tests/btrfs/224 | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tests/btrfs/224 +3 -3
index de10942f..611df3ab 100755
@@ -67,7 +67,7 @@ assign_no_shared_test()
 	_check_scratch_fs
 }
 
-# Test snapshot with assigning qgroup for submodule
+# Test snapshot with assigning qgroup for higher level qgroup
 snapshot_test()
 {
 	_scratch_mkfs > /dev/null 2>&1
@@ -78,9 +78,9 @@ snapshot_test()
 	_qgroup_rescan $SCRATCH_MNT >> $seqres.full
 
 	$BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/a >> $seqres.full
+	$BTRFS_UTIL_PROG qgroup create 1/0 $SCRATCH_MNT >> $seqres.full
 	_ddt of="$SCRATCH_MNT"/a/file1 bs=1M count=1 >> $seqres.full 2>&1
-	subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT a)
-	$BTRFS_UTIL_PROG subvolume snapshot -i 0/$subvolid $SCRATCH_MNT/a $SCRATCH_MNT/b >> $seqres.full
+	$BTRFS_UTIL_PROG subvolume snapshot -i 1/0 $SCRATCH_MNT/a $SCRATCH_MNT/b >> $seqres.full
 
 	_scratch_unmount
 	_check_scratch_fs
Signature · 1 line
2.42.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Qu Wenruo

For "btrfs subvolume snapshot -i <qgroupid>", we only expect the target qgroup to be a higher level one.

Assigning a 0 level qgroup to another 0 level qgroup is only going to cause confusion, and I'm planning to do extra sanity checks both in kernel and btrfs-progs to reject such behavior.

So change the test case to do regular higher level qgroup assignment only.

looks good.

Applied to
https://github.com/asj/fstests.git for-next

Thanks, Anand

Quoted 29 lines
---
  tests/btrfs/224 | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
tests/btrfs/224 +3 -3
index de10942f..611df3ab 100755
@@ -67,7 +67,7 @@ assign_no_shared_test()
  	_check_scratch_fs
  }
 
-# Test snapshot with assigning qgroup for submodule
+# Test snapshot with assigning qgroup for higher level qgroup
  snapshot_test()
  {
  	_scratch_mkfs > /dev/null 2>&1
@@ -78,9 +78,9 @@ snapshot_test()
  	_qgroup_rescan $SCRATCH_MNT >> $seqres.full
 
  	$BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/a >> $seqres.full
+	$BTRFS_UTIL_PROG qgroup create 1/0 $SCRATCH_MNT >> $seqres.full
  	_ddt of="$SCRATCH_MNT"/a/file1 bs=1M count=1 >> $seqres.full 2>&1
-	subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT a)
-	$BTRFS_UTIL_PROG subvolume snapshot -i 0/$subvolid $SCRATCH_MNT/a $SCRATCH_MNT/b >> $seqres.full
+	$BTRFS_UTIL_PROG subvolume snapshot -i 1/0 $SCRATCH_MNT/a $SCRATCH_MNT/b >> $seqres.full
 
  	_scratch_unmount
  	_check_scratch_fs
author
#2 lore raw
Quoted 11 lines · Anand Jain
Quoted 10 lines · Qu Wenruo

For "btrfs subvolume snapshot -i <qgroupid>", we only expect the target qgroup to be a higher level one.

Assigning a 0 level qgroup to another 0 level qgroup is only going to cause confusion, and I'm planning to do extra sanity checks both in kernel and btrfs-progs to reject such behavior.

So change the test case to do regular higher level qgroup assignment only.

Quoted 8 lines
Quoted 1 line

looks good.

 Applied to
   https://github.com/asj/fstests.git for-next

Thanks for the review and merge, although I'd also like to get some feedback from the original author, to make sure there are not some weird use case.

Thanks,
Qu

Quoted 32 lines

Thanks, Anand

Quoted 28 lines

---
  tests/btrfs/224 | 6 +++---

  1 file changed, 3 insertions(+), 3 deletions(-)
tests/btrfs/224 +0 -0
index de10942f..611df3ab 100755
@@ -67,7 +67,7 @@ assign_no_shared_test()

      _check_scratch_fs
  }

tests/btrfs/224 +1 -1
-# Test snapshot with assigning qgroup for submodule
+# Test snapshot with assigning qgroup for higher level qgroup

  snapshot_test()
  {
      _scratch_mkfs > /dev/null 2>&1

tests/btrfs/224 +0 -0
@@ -78,9 +78,9 @@ snapshot_test()

      _qgroup_rescan $SCRATCH_MNT >> $seqres.full $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/a >> $seqres.full +    $BTRFS_UTIL_PROG qgroup create 1/0 $SCRATCH_MNT >> $seqres.full _ddt of="$SCRATCH_MNT"/a/file1 bs=1M count=1 >> $seqres.full 2>&1 -    subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT a)
-    $BTRFS_UTIL_PROG subvolume snapshot -i 0/$subvolid $SCRATCH_MNT/a $SCRATCH_MNT/b >> $seqres.full
+    $BTRFS_UTIL_PROG subvolume snapshot -i 1/0 $SCRATCH_MNT/a $SCRATCH_MNT/b >> $seqres.full
      _scratch_unmount
      _check_scratch_fs

#3 lore raw
Quoted 18 lines · Qu Wenruo
Quoted 15 lines · Anand Jain
Quoted 11 lines · Qu Wenruo

For "btrfs subvolume snapshot -i <qgroupid>", we only expect the target qgroup to be a higher level one.

Assigning a 0 level qgroup to another 0 level qgroup is only going to cause confusion, and I'm planning to do extra sanity checks both in kernel and btrfs-progs to reject such behavior.

So change the test case to do regular higher level qgroup assignment only.

looks good.

Quoted 7 lines
Quoted 4 lines

 Applied to
   https://github.com/asj/fstests.git for-next

Thanks for the review and merge, although I'd also like to get some feedback from the original author, to make sure there are not some weird use case.

It seems that this line intented to assign a qgroup for new snapshot same as subvolume. But I agree that 0 level qgroup doesn't make sense. This patch Looks good to me. Thanks for asking to me.

Thanks,
Sidong

Quoted 35 lines

Thanks,
Qu

Quoted 32 lines

Thanks, Anand

Quoted 28 lines

---
  tests/btrfs/224 | 6 +++---

  1 file changed, 3 insertions(+), 3 deletions(-)
tests/btrfs/224 +0 -0
index de10942f..611df3ab 100755
@@ -67,7 +67,7 @@ assign_no_shared_test()

      _check_scratch_fs
  }

tests/btrfs/224 +1 -1
-# Test snapshot with assigning qgroup for submodule
+# Test snapshot with assigning qgroup for higher level qgroup

  snapshot_test()
  {
      _scratch_mkfs > /dev/null 2>&1

tests/btrfs/224 +0 -0
@@ -78,9 +78,9 @@ snapshot_test()

      _qgroup_rescan $SCRATCH_MNT >> $seqres.full $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/a >> $seqres.full +    $BTRFS_UTIL_PROG qgroup create 1/0 $SCRATCH_MNT >> $seqres.full _ddt of="$SCRATCH_MNT"/a/file1 bs=1M count=1 >> $seqres.full 2>&1 -    subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT a)
-    $BTRFS_UTIL_PROG subvolume snapshot -i 0/$subvolid $SCRATCH_MNT/a $SCRATCH_MNT/b >> $seqres.full
+    $BTRFS_UTIL_PROG subvolume snapshot -i 1/0 $SCRATCH_MNT/a $SCRATCH_MNT/b >> $seqres.full
      _scratch_unmount
      _check_scratch_fs

#4 lore raw
In reply to Qu Wenruo
Quoted 6 lines · Qu Wenruo

For "btrfs subvolume snapshot -i <qgroupid>", we only expect the target qgroup to be a higher level one.

Assigning a 0 level qgroup to another 0 level qgroup is only going to cause confusion, and I'm planning to do extra sanity checks both in kernel and btrfs-progs to reject such behavior.

I think this was never intended, the higher level were meant to group the leaf subvolumes. But it's possible that somebody is using it like is in the test. In that case we'd have to define the semantics or at least start warning about that and then remove it completely.