All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeffle Xu <jefflexu@linux.alibaba.com>
To: darrick.wong@oracle.com, guan@eryu.me
Cc: fstests@vger.kernel.org
Subject: [RFC PATCH] misc: skip fsx tests when op length not congruent with file allocation unit
Date: Wed,  7 Jul 2021 18:47:45 +0800	[thread overview]
Message-ID: <20210707104745.98822-1-jefflexu@linux.alibaba.com> (raw)
In-Reply-To: <20210706181452.GB11571@locust>


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(+)

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
-- 
1.8.3.1


  reply	other threads:[~2021-07-07 10:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-05  6:58 [RFC,2/2] xfstests: common/rc: add cluster size support for ext4 JeffleXu
2021-07-06 18:14 ` Darrick J. Wong
2021-07-07 10:47   ` Jeffle Xu [this message]
2021-07-18 13:51     ` [RFC PATCH] misc: skip fsx tests when op length not congruent with file allocation unit Eryu Guan

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=20210707104745.98822-1-jefflexu@linux.alibaba.com \
    --to=jefflexu@linux.alibaba.com \
    --cc=darrick.wong@oracle.com \
    --cc=fstests@vger.kernel.org \
    --cc=guan@eryu.me \
    /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 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.