diff mbox series

[RFC] misc: skip fsx tests when op length not congruent with file allocation unit

Message ID 20210707104745.98822-1-jefflexu@linux.alibaba.com (mailing list archive)
State New, archived
Headers show
Series [RFC] misc: skip fsx tests when op length not congruent with file allocation unit | expand

Commit Message

Jingbo Xu July 7, 2021, 10:47 a.m. UTC
Yes it works. For example in this RFC patch, generic/075 could be
skipped once 'bigalloc' is detected for ext4.

I could fix all related test cases in this way, if it is acceptable to
the community.

Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
---
 common/rc         | 20 ++++++++++++++++++++
 tests/generic/075 |  3 +++
 2 files changed, 23 insertions(+)

Comments

Eryu Guan July 18, 2021, 1:51 p.m. UTC | #1
On Wed, Jul 07, 2021 at 06:47:45PM +0800, Jeffle Xu wrote:
> 
> Yes it works. For example in this RFC patch, generic/075 could be
> skipped once 'bigalloc' is detected for ext4.
> 
> I could fix all related test cases in this way, if it is acceptable to
> the community.

Looks fine to me.

> 
> Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
> ---
>  common/rc         | 20 ++++++++++++++++++++
>  tests/generic/075 |  3 +++
>  2 files changed, 23 insertions(+)
> 
> diff --git a/common/rc b/common/rc
> index f58a542..92245e0 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -4041,6 +4041,23 @@ _sysfs_dev()
>  	min=$(echo "ibase=16; $min" | bc)
>  	echo /sys/dev/block/$maj:$min
>  }
> +		
> +_ext4_get_file_block_size()

Another ext4 specific helper in common/rc, perhaps it's time to create
its own file for ext4, i.e. common/ext4, and move all ext4 specific
helpers in common/rc there.

> +{
> +	local path="$1"
> +	path="$(readlink -m "$path")"
> +	local dev=`$DF_PROG $dir | tail -1 | $AWK_PROG '{print $1}'`

$dir is not defined, you mean $path here?

> +	
> +	# The alloc unit size equals block size for ext4 without 'bigalloc'.
> +	if ! (tune2fs -l $dev | grep -q 'Cluster size'); then

$TUNE2FS_PROG

Perhaps you could call tune2fs only once and save its "Cluster size"
line for later use.

Thanks,
Eryu

> +		_get_block_size "$path"
> +		return
> +	fi
> +
> +	# Otherwise, call tune2fs acquiring cluster size.
> +	tune2fs -l $dev | sed -n -e 's/^.*Cluster size:\s*\([0-9]*\).*$/\1/p'
> +
> +}
>  
>  # Get the minimum block size of a file.  Usually this is the
>  # minimum fs block size, but some filesystems (ocfs2) do block
> @@ -4059,6 +4076,9 @@ _get_file_block_size()
>  	"xfs")
>  		_xfs_get_file_block_size $1
>  		;;
> +	"ext4")
> +		_ext4_get_file_block_size $1
> +		;;
>  	*)
>  		_get_block_size $1
>  		;;
> diff --git a/tests/generic/075 b/tests/generic/075
> index 7467bb7..d269a7c 100755
> --- a/tests/generic/075
> +++ b/tests/generic/075
> @@ -109,6 +109,9 @@ _process_args()
>  _supported_fs generic
>  _require_test
>  
> +blksz=$(_get_block_size $TEST_DIR)
> +_require_congruent_file_oplen $TEST_DIR $blksz
> +
>  size10=`expr 10 \* 1024 \* 1024`	# 10 megabytes
>  filelen=$size10
>  numops1=1000
> -- 
> 1.8.3.1
diff mbox series

Patch

diff --git a/common/rc b/common/rc
index f58a542..92245e0 100644
--- a/common/rc
+++ b/common/rc
@@ -4041,6 +4041,23 @@  _sysfs_dev()
 	min=$(echo "ibase=16; $min" | bc)
 	echo /sys/dev/block/$maj:$min
 }
+		
+_ext4_get_file_block_size()
+{
+	local path="$1"
+	path="$(readlink -m "$path")"
+	local dev=`$DF_PROG $dir | tail -1 | $AWK_PROG '{print $1}'`
+	
+	# The alloc unit size equals block size for ext4 without 'bigalloc'.
+	if ! (tune2fs -l $dev | grep -q 'Cluster size'); then
+		_get_block_size "$path"
+		return
+	fi
+
+	# Otherwise, call tune2fs acquiring cluster size.
+	tune2fs -l $dev | sed -n -e 's/^.*Cluster size:\s*\([0-9]*\).*$/\1/p'
+
+}
 
 # Get the minimum block size of a file.  Usually this is the
 # minimum fs block size, but some filesystems (ocfs2) do block
@@ -4059,6 +4076,9 @@  _get_file_block_size()
 	"xfs")
 		_xfs_get_file_block_size $1
 		;;
+	"ext4")
+		_ext4_get_file_block_size $1
+		;;
 	*)
 		_get_block_size $1
 		;;
diff --git a/tests/generic/075 b/tests/generic/075
index 7467bb7..d269a7c 100755
--- a/tests/generic/075
+++ b/tests/generic/075
@@ -109,6 +109,9 @@  _process_args()
 _supported_fs generic
 _require_test
 
+blksz=$(_get_block_size $TEST_DIR)
+_require_congruent_file_oplen $TEST_DIR $blksz
+
 size10=`expr 10 \* 1024 \* 1024`	# 10 megabytes
 filelen=$size10
 numops1=1000