All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] generic/563: use a loop device to avoid partition incompatibility
@ 2020-12-14 17:18 Brian Foster
  2020-12-15  0:13 ` Zorro Lang
  0 siblings, 1 reply; 2+ messages in thread
From: Brian Foster @ 2020-12-14 17:18 UTC (permalink / raw)
  To: fstests

cgroup writeback accounting does not track partition level
statistics. Instead, I/O is accounted against the parent device. As
a result, the test fails if the scratch device happens to be a
device partition. Since parent level stats are potentially polluted
by factors external to the test, wrap the scratch device in a
loopback device to guarantee the test always runs on a top-level
block device.

Reported-by: Boyang Xue <bxue@redhat.com>
Signed-off-by: Brian Foster <bfoster@redhat.com>
---

v2:
- Use _require_scratch_nocheck() since the scratch device is not used
  directly.
v1: https://lore.kernel.org/fstests/20201210161426.1927144-1-bfoster@redhat.com/

 tests/generic/563 | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/tests/generic/563 b/tests/generic/563
index 51deaa2f..b113eacf 100755
--- a/tests/generic/563
+++ b/tests/generic/563
@@ -2,7 +2,7 @@
 # SPDX-License-Identifier: GPL-2.0
 # Copyright (c) 2019 Red Hat, Inc.  All Rights Reserved.
 #
-# FS QA Test No. 011
+# FS QA Test No. 563
 #
 # This test verifies that cgroup aware writeback properly accounts I/Os in
 # various scenarios. We perform reads/writes from different combinations of
@@ -26,6 +26,8 @@ _cleanup()
 
 	echo $$ > $cgdir/cgroup.procs
 	rmdir $cgdir/$seq-cg* > /dev/null 2>&1
+	umount $SCRATCH_MNT > /dev/null 2>&1
+	_destroy_loop_device $LOOP_DEV > /dev/null 2>&1
 }
 
 # get standard environment, filters and checks
@@ -40,16 +42,14 @@ rm -f $seqres.full
 
 # Modify as appropriate.
 _supported_fs generic
-_require_scratch
+_require_scratch_nocheck
 _require_cgroup2 io
+_require_loop
 
 # cgroup v2 writeback is only support on block devices so far
 _require_block_device $SCRATCH_DEV
 
-smajor=$((0x`stat -L -c %t $SCRATCH_DEV`))
-sminor=$((0x`stat -L -c %T $SCRATCH_DEV`))
 cgdir=$CGROUP2_PATH
-
 iosize=$((1024 * 1024 * 8))
 
 # Check cgroup read/write charges against expected values. Allow for some
@@ -89,12 +89,19 @@ reset()
 	rmdir $cgdir/$seq-cg* > /dev/null 2>&1
 	$XFS_IO_PROG -fc "pwrite 0 $iosize" $SCRATCH_MNT/file \
 		>> $seqres.full 2>&1
-	_scratch_cycle_mount || _fail "mount failed"
+	umount $SCRATCH_MNT || _fail "umount failed"
+	_mount $LOOP_DEV $SCRATCH_MNT || _fail "mount failed"
 	stat $SCRATCH_MNT/file > /dev/null
 }
 
-_scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount
+# cgroup I/O accounting doesn't work on partitions. Use a loop device to rule
+# that out.
+LOOP_DEV=$(_create_loop_device $SCRATCH_DEV)
+smajor=$((0x`stat -L -c %t $LOOP_DEV`))
+sminor=$((0x`stat -L -c %T $LOOP_DEV`))
+
+_mkfs_dev $LOOP_DEV >> $seqres.full 2>&1
+_mount $LOOP_DEV $SCRATCH_MNT || _fail "mount failed"
 
 echo "+io" > $cgdir/cgroup.subtree_control || _fail "subtree control"
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] generic/563: use a loop device to avoid partition incompatibility
  2020-12-14 17:18 [PATCH v2] generic/563: use a loop device to avoid partition incompatibility Brian Foster
@ 2020-12-15  0:13 ` Zorro Lang
  0 siblings, 0 replies; 2+ messages in thread
From: Zorro Lang @ 2020-12-15  0:13 UTC (permalink / raw)
  To: Brian Foster; +Cc: fstests

On Mon, Dec 14, 2020 at 12:18:54PM -0500, Brian Foster wrote:
> cgroup writeback accounting does not track partition level
> statistics. Instead, I/O is accounted against the parent device. As
> a result, the test fails if the scratch device happens to be a
> device partition. Since parent level stats are potentially polluted
> by factors external to the test, wrap the scratch device in a
> loopback device to guarantee the test always runs on a top-level
> block device.
> 
> Reported-by: Boyang Xue <bxue@redhat.com>
> Signed-off-by: Brian Foster <bfoster@redhat.com>
> ---
> 
> v2:
> - Use _require_scratch_nocheck() since the scratch device is not used
>   directly.

V2 looks good to me, thanks Brian.

Reviewed-by: Zorro Lang <zlang@redhat.com>

> v1: https://lore.kernel.org/fstests/20201210161426.1927144-1-bfoster@redhat.com/
> 
>  tests/generic/563 | 23 +++++++++++++++--------
>  1 file changed, 15 insertions(+), 8 deletions(-)
> 
> diff --git a/tests/generic/563 b/tests/generic/563
> index 51deaa2f..b113eacf 100755
> --- a/tests/generic/563
> +++ b/tests/generic/563
> @@ -2,7 +2,7 @@
>  # SPDX-License-Identifier: GPL-2.0
>  # Copyright (c) 2019 Red Hat, Inc.  All Rights Reserved.
>  #
> -# FS QA Test No. 011
> +# FS QA Test No. 563
>  #
>  # This test verifies that cgroup aware writeback properly accounts I/Os in
>  # various scenarios. We perform reads/writes from different combinations of
> @@ -26,6 +26,8 @@ _cleanup()
>  
>  	echo $$ > $cgdir/cgroup.procs
>  	rmdir $cgdir/$seq-cg* > /dev/null 2>&1
> +	umount $SCRATCH_MNT > /dev/null 2>&1
> +	_destroy_loop_device $LOOP_DEV > /dev/null 2>&1
>  }
>  
>  # get standard environment, filters and checks
> @@ -40,16 +42,14 @@ rm -f $seqres.full
>  
>  # Modify as appropriate.
>  _supported_fs generic
> -_require_scratch
> +_require_scratch_nocheck
>  _require_cgroup2 io
> +_require_loop
>  
>  # cgroup v2 writeback is only support on block devices so far
>  _require_block_device $SCRATCH_DEV
>  
> -smajor=$((0x`stat -L -c %t $SCRATCH_DEV`))
> -sminor=$((0x`stat -L -c %T $SCRATCH_DEV`))
>  cgdir=$CGROUP2_PATH
> -
>  iosize=$((1024 * 1024 * 8))
>  
>  # Check cgroup read/write charges against expected values. Allow for some
> @@ -89,12 +89,19 @@ reset()
>  	rmdir $cgdir/$seq-cg* > /dev/null 2>&1
>  	$XFS_IO_PROG -fc "pwrite 0 $iosize" $SCRATCH_MNT/file \
>  		>> $seqres.full 2>&1
> -	_scratch_cycle_mount || _fail "mount failed"
> +	umount $SCRATCH_MNT || _fail "umount failed"
> +	_mount $LOOP_DEV $SCRATCH_MNT || _fail "mount failed"
>  	stat $SCRATCH_MNT/file > /dev/null
>  }
>  
> -_scratch_mkfs >> $seqres.full 2>&1
> -_scratch_mount
> +# cgroup I/O accounting doesn't work on partitions. Use a loop device to rule
> +# that out.
> +LOOP_DEV=$(_create_loop_device $SCRATCH_DEV)
> +smajor=$((0x`stat -L -c %t $LOOP_DEV`))
> +sminor=$((0x`stat -L -c %T $LOOP_DEV`))
> +
> +_mkfs_dev $LOOP_DEV >> $seqres.full 2>&1
> +_mount $LOOP_DEV $SCRATCH_MNT || _fail "mount failed"
>  
>  echo "+io" > $cgdir/cgroup.subtree_control || _fail "subtree control"
>  
> -- 
> 2.26.2
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-15  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-14 17:18 [PATCH v2] generic/563: use a loop device to avoid partition incompatibility Brian Foster
2020-12-15  0:13 ` Zorro Lang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.