From: Chengguang Xu <cgxu519@mykernel.net>
To: fstests@vger.kernel.org, linux-unionfs@vger.kernel.org
Cc: guaneryu@gmail.com, amir73il@gmail.com, miklos@szeredi.hu,
Chengguang Xu <cgxu519@mykernel.net>
Subject: [PATCH v3] overlay/066: copy-up test for variant sparse files
Date: Thu, 24 Oct 2019 20:29:23 +0800 [thread overview]
Message-ID: <20191024122923.24689-1-cgxu519@mykernel.net> (raw)
This is intensive copy-up test for sparse files,
these cases will be mainly used for regression test
of copy-up improvement for sparse files.
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>
---
v1->v2:
- Call _get_block_size to get fs block size.
- Add comment for test space requirement.
- Print meaningful error message when copy-up fail.
- Adjust random hole range to 1M~5M.
- Fix typo.
v2->v3:
- Fix space requiremnt for test.
- Add more descriptions for test files and hole patterns.
- Define well named variables to replace unexplained numbers.
- Fix random hole algorithm to what Amir suggested.
- Adjust iosize to start from 1K.
- Remove from quick test group.
tests/overlay/066 | 130 ++++++++++++++++++++++++++++++++++++++++++
tests/overlay/066.out | 2 +
tests/overlay/group | 1 +
3 files changed, 133 insertions(+)
create mode 100755 tests/overlay/066
create mode 100644 tests/overlay/066.out
diff --git a/tests/overlay/066 b/tests/overlay/066
new file mode 100755
index 00000000..285a5aff
--- /dev/null
+++ b/tests/overlay/066
@@ -0,0 +1,130 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 Chengguang Xu <cgxu519@mykernel.net>
+# All Rights Reserved.
+#
+# FS QA Test 066
+#
+# Test overlayfs copy-up function for variant sparse files.
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+ cd /
+ rm -f $tmp.*
+}
+
+# get standard environment, filters and checks.
+. ./common/rc
+. ./common/filter
+
+# remove previous $seqres.full before test.
+rm -f $seqres.full
+
+# real QA test starts here.
+
+# Modify as appropriate.
+_supported_fs generic
+_supported_os Linux
+_require_test
+_require_scratch
+
+# Remove all files from previous tests
+_scratch_mkfs
+
+# We have totally 14 test files in this test.
+# The detail as below:
+# 1 empty file(10M) + 2^0(K)..2^11(K) hole size files(each 10M) + 1 random hole size file(100M).
+#
+# Considering both upper and lower fs will fill zero when copy-up
+# hole area in the file, this test at least requires double disk
+# space of the sum of above test files' size.
+
+_require_fs_space $OVL_BASE_SCRATCH_MNT $(((10*1024*13 + 100*1024*1) * 2))
+
+lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
+upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
+testfile="copyup_sparse_test"
+
+# Create a completely empty hole file(10M).
+file_size=10240
+$XFS_IO_PROG -fc "truncate ${file_size}K" "${lowerdir}/${testfile}_empty_holefile" \
+ >>$seqres.full
+
+# Create 2^0(K)..2^11(K) hole size test files(each 10M).
+#
+# The pattern is like below, both hole and data are equal to
+# iosize except last hole.
+#
+# |-- hole --|-- data --| ... |-- data --|-- hole --|
+
+iosize=1
+max_iosize=2048
+file_size=10240
+max_pos=`expr $file_size - $max_iosize`
+
+while [ $iosize -le $max_iosize ]; do
+ pos=$iosize
+ $XFS_IO_PROG -fc "truncate ${file_size}K" \
+ "${lowerdir}/${testfile}_iosize${iosize}K_holefile" >>$seqres.full
+ while [ $pos -lt $max_pos ]; do
+ $XFS_IO_PROG -fc "pwrite ${pos}K ${iosize}K" \
+ "${lowerdir}/${testfile}_iosize${iosize}K_holefile" >>$seqres.full
+ pos=`expr $pos + $iosize + $iosize`
+ done
+ iosize=`expr $iosize + $iosize`
+done
+
+# Create test file with many random holes(hole size is between 1M and 5M),
+# total file size is 100M.
+
+pos=2048
+max_pos=81920
+file_size=102400
+min_hole=1024
+max_hole=5120
+
+$XFS_IO_PROG -fc "truncate ${file_size}K" "${lowerdir}/${testfile}_random_holefile" \
+ >>$seqres.full
+
+while [ $pos -le $max_pos ]; do
+ iosize=$(($RANDOM % ($max_hole - $min_hole) + $min_hole))
+ $XFS_IO_PROG -fc "pwrite ${pos}K ${iosize}K" \
+ "${lowerdir}/${testfile}_random_holefile" >>$seqres.full
+ pos=`expr $pos + $iosize + $iosize`
+done
+
+_scratch_mount
+
+# Open the test files, no errors are expected.
+for f in $SCRATCH_MNT/*; do
+ $XFS_IO_PROG -c "open" $f >>$seqres.full
+done
+
+echo "Silence is golden"
+
+# Check all copy-up files in upper layer.
+iosize=1
+while [ $iosize -le 2048 ]; do
+ diff "${lowerdir}/${testfile}_iosize${iosize}K_holefile" \
+ "${upperdir}/${testfile}_iosize${iosize}K_holefile" >>$seqres.full ||\
+ echo "${upperdir}/${testfile}_iosize${iosize}K_holefile" copy up failed!
+ iosize=`expr $iosize + $iosize`
+done
+
+diff "${lowerdir}/${testfile}_empty_holefile" "${upperdir}/${testfile}_empty_holefile" \
+ >>$seqres.full || echo "${upperdir}/${testfile}_empty_holefile" copy up failed!
+diff "${lowerdir}/${testfile}_random_holefile" "${upperdir}/${testfile}_random_holefile" \
+ >>$seqres.full || echo "${upperdir}/${testfile}_random_holefile" copy up failed!
+
+# success, all done
+status=0
+exit
diff --git a/tests/overlay/066.out b/tests/overlay/066.out
new file mode 100644
index 00000000..b60cc24c
--- /dev/null
+++ b/tests/overlay/066.out
@@ -0,0 +1,2 @@
+QA output created by 066
+Silence is golden
diff --git a/tests/overlay/group b/tests/overlay/group
index ef8517a1..e22134df 100644
--- a/tests/overlay/group
+++ b/tests/overlay/group
@@ -68,3 +68,4 @@
063 auto quick whiteout
064 auto quick copyup
065 auto quick mount
+066 auto copyup
--
2.20.1
next reply other threads:[~2019-10-24 12:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-24 12:29 Chengguang Xu [this message]
2019-10-24 21:02 ` [PATCH v3] overlay/066: copy-up test for variant sparse files Amir Goldstein
2019-10-25 1:19 ` Chengguang Xu
2019-10-27 13:59 ` Amir Goldstein
2019-10-28 12:08 ` Chengguang Xu
2019-10-28 12:29 ` Amir Goldstein
2019-10-28 14:11 ` Chengguang Xu
2019-10-28 14:34 ` Amir Goldstein
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=20191024122923.24689-1-cgxu519@mykernel.net \
--to=cgxu519@mykernel.net \
--cc=amir73il@gmail.com \
--cc=fstests@vger.kernel.org \
--cc=guaneryu@gmail.com \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox